Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions docs/cli-reference.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/cleanup/orgCleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function cleanupOrgData(orgId: string, userId?: string): void {
if (existsSync(keepPath)) {
try {
unlinkSync(keepPath);
console.log(' Removed keep.lock (no longer a member).');
console.log(' Removed this folder\'s Capy setup (no longer a member).');
} catch {}
}
const workingKeepPath = join(process.cwd(), '.capy', 'keep.lock');
Expand Down
10 changes: 5 additions & 5 deletions src/commands/capyCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ export class CapyCommand {

this.fileManager.writeKeepFile(keep);

keySpinner.succeed('keep.lock created (0 secrets)');
keySpinner.succeed('Project set up (0 secrets)');

// Create the initial branch the person chose above. `POST /projects` no longer auto-creates
// one. Protection isn't asked here - branches are unprotected
Expand Down Expand Up @@ -969,7 +969,7 @@ export class CapyCommand {
);

if (syncResult.ok) {
syncSpinner.succeed(`keep.lock created (pinned to ${initialBranchName}, ${localVarCount} secrets)`);
syncSpinner.succeed(`Project set up (on ${initialBranchName}, ${localVarCount} secrets)`);

// Install git hooks
this.installGitHooks();
Expand Down Expand Up @@ -1127,7 +1127,7 @@ export class CapyCommand {
return this.resolveSetUpScreen({ offered, fixed: offered.length === 0 ? fitting[0] : undefined, variables, ...this.scriptsRow() });
}

/** CAP-960: the Set up step's "Run your scripts with the encrypted .env" row, when package.json has local scripts to wrap. */
/** CAP-960: the Set up step's "Run your scripts with your encrypted variables" row, when package.json has local scripts to wrap. */
private scriptsRow(): { readonly scripts?: readonly string[]; readonly bin?: string } {
const wrap = folderScriptPlan(process.cwd())?.wrap ?? [];
return wrap.length === 0 ? {} : { scripts: wrap, bin: binName(this.devMode) };
Expand Down Expand Up @@ -2372,7 +2372,7 @@ export class CapyCommand {
}
})();
if (pushedCount === 'stale') return this.syncProjectValues(projectState, true);
this.say(`\n> keep.lock updated (${diffs.length} changes)`);
this.say(`\n> Variables updated (${diffs.length} changes)`);
this.say(
localMode
? `\nStored ${pushedCount} change(s) locally (local-only mode).`
Expand Down Expand Up @@ -2410,7 +2410,7 @@ export class CapyCommand {
keep_hash: setSyncKeepHash(existingSyncState, branch, SyncEngine.computeKeepHash(finalKeep, branch)),
});

this.say(`\n> keep.lock updated (${diffs.length} changes)`);
this.say(`\n> Variables updated (${diffs.length} changes)`);

// Install hooks on every run (idempotent)
this.installGitHooks();
Expand Down
3 changes: 2 additions & 1 deletion src/commands/checkoutCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { conflictFlagsOrExit, type RawConflictFlags } from '../sync/conflicts';
import { pinnedHashes } from '../sync/commit';
import { isInteractive } from '../ui/interactive';
import { SETUP_COPY } from '../core/setupCopy';
import { PROJECT_FILE_COPY } from '../core/projectFileCopy';

const B = (s: string) => `\x1b[1m${s}\x1b[0m`;

Expand Down Expand Up @@ -187,7 +188,7 @@ export class CheckoutCommand {
// Read keep.lock — must be initialized
const projectState = await this.projectManager.detectProjectState();
if (!projectState.initialized) {
console.error(`No keep.lock file found. Run ${B('capy')} first to initialize the project.`);
console.error(PROJECT_FILE_COPY.notSetUp(B('capy')));
process.exit(1);
}

Expand Down
7 changes: 4 additions & 3 deletions src/commands/connectors/discoverySteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
GitRemoteRef,
defaultDiscoveryProjectName,
} from './dokployDiscovery';
import { PROJECT_FILE_COPY } from '../../core/projectFileCopy';

export async function defaultConfirm(message: string, defaultValue: boolean): Promise<boolean> {
const inquirer = (await import('inquirer')).default;
Expand Down Expand Up @@ -400,7 +401,7 @@ async function ensureProjectSafe(
return {
ok: false,
code: opts.codes.folderNotInitialized,
message: `${folder || '.'} has no keep.lock. Run \`capy\` there to initialize it, then re-run discovery.`,
message: `${PROJECT_FILE_COPY.folderNotSetUp(folder || '.')} Run \`capy\` there to set it up, then re-run discovery.`,
};
}
const snapshot = opts.existingProjectsSnapshot;
Expand Down Expand Up @@ -711,7 +712,7 @@ async function checkoutBranchSafe(

const existingKeep = pm.readKeepFile();
if (!existingKeep) {
return { ok: false, code: codes.keepMissing, message: `${folder || '.'} has no keep.lock.` };
return { ok: false, code: codes.keepMissing, message: PROJECT_FILE_COPY.folderNotSetUp(folder || '.') };
}
// Splice in only THIS branch's server pins — keep.lock holds every
// branch's metadata and is git-owned; a sibling branch's pins must not
Expand Down Expand Up @@ -791,7 +792,7 @@ async function importIntoBranchSafe(
}
const keep = pm.readKeepFile();
if (!keep) {
return { ok: false, code: runOpts.codes.keepMissing, message: `${folder || '.'} has no keep.lock.` };
return { ok: false, code: runOpts.codes.keepMissing, message: PROJECT_FILE_COPY.folderNotSetUp(folder || '.') };
}

const keyOps = {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/connectors/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { KeepFile, ConnectorMetadata, CapyError, ERROR_CODES, AuthResult } from
import type { ImportOutcome } from './registry';
import { reportRepoLinkForCommand, type RepoLinkWarning } from '../../core/repoLinkReporter';
import { clearedPlaceholders, withPlaceholders, type PlaceholderRequest } from '../../core/placeholder';
import { PROJECT_FILE_COPY } from '../../core/projectFileCopy';

const B = (s: string) => `\x1b[1m${s}\x1b[0m`;

Expand Down Expand Up @@ -83,7 +84,7 @@ export async function resolveContext(
const projectState = await pm.detectProjectState();

if (!projectState.initialized || !projectState.organizationId || !projectState.projectId) {
return refuse(ERROR_CODES.NO_KEEP_FILE, `No keep.lock found. Run ${B('capy')} to initialize.`);
return refuse(ERROR_CODES.NO_KEEP_FILE, PROJECT_FILE_COPY.notSetUp(B('capy')));
}
const orgId = projectState.organizationId;
const projectId = projectState.projectId;
Expand All @@ -94,7 +95,7 @@ export async function resolveContext(

const keep = pm.readKeepFile();
if (!keep) {
return refuse(ERROR_CODES.NO_KEEP_FILE, 'Could not read keep.lock');
return refuse(ERROR_CODES.NO_KEEP_FILE, PROJECT_FILE_COPY.damagedNext(B('capy')));
}

const fileManager = new FileManager();
Expand Down
2 changes: 1 addition & 1 deletion src/commands/connectors/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ async function rotate(
const nonTty = opts.nonTty;
if (previous.mode !== 'test' && previous.mode !== 'live') {
console.error(
`\n ${varName} keep.lock entry has invalid mode "${previous.mode ?? '(unset)'}".`,
`\n ${varName} has an invalid connector mode in Capy's project file: "${previous.mode ?? '(unset)'}".`,
);
console.error(` Expected 'test' or 'live'. Re-run \`capy connect stripe\`.`);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/connectors/workos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ async function chooseEnvironment(
// app uses, so a silent divergence there is worth one line.
if (match && match.id !== recorded.id) {
console.log(`\n ${B(clientIdVar)} points at ${B(environmentLabel(match))}, but`);
console.log(` keep.lock records ${B(environmentLabel(recorded))}. Using the recorded one.\n`);
console.log(` This project records ${B(environmentLabel(recorded))}. Using the recorded one.\n`);
}
return recorded;
}
Expand Down
7 changes: 4 additions & 3 deletions src/commands/decryptCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
saveRecoverySession,
} from '../config/globalConfig';
import { ERROR_CODES } from '../types/index';
import { PROJECT_FILE_COPY } from '../core/projectFileCopy';

const bold = (s: string) => `\x1b[1m${s}\x1b[0m`;

Expand All @@ -27,7 +28,7 @@ export class DecryptCommand {
// Require keep.lock
const keep = pm.readKeepFile();
if (!keep) {
console.error(`\n No keep.lock file found. Run ${bold('capy')} first to initialize.\n`);
console.error(`\n ${PROJECT_FILE_COPY.notSetUp(bold('capy'))}\n`);
process.exit(1);
}

Expand All @@ -47,7 +48,7 @@ export class DecryptCommand {
console.error(
`\n .env was encrypted for a different organization.` +
`\n .env org: ${envMeta.org_id}` +
`\n keep.lock org: ${orgId}` +
`\n This folder's org: ${orgId}` +
`\n\n This .env cannot be decrypted in this project.\n`
);
process.exit(1);
Expand All @@ -56,7 +57,7 @@ export class DecryptCommand {
console.error(
`\n .env was encrypted for a different project.` +
`\n .env project: ${envMeta.project_id}` +
`\n keep.lock project: ${projectId}` +
`\n This folder's project: ${projectId}` +
`\n\n This .env cannot be decrypted in this project.\n`
);
process.exit(1);
Expand Down
37 changes: 19 additions & 18 deletions src/commands/deployCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import {
upsertTarget,
} from '../deploy/config';
import { fillCommandFor } from '../deploy/minimalTarget';
import { PROJECT_FILE_COPY } from '../core/projectFileCopy';

const B = (s: string) => `\x1b[1m${s}\x1b[0m`;
const DIM = (s: string) => `\x1b[90m${s}\x1b[0m`;
Expand Down Expand Up @@ -305,7 +306,7 @@ async function decryptCurrentBranch(

const keep = readKeep(cwd);
if (!keep) {
throw new Error('no keep.lock — run `capy` to sync first.');
throw new Error(PROJECT_FILE_COPY.notSetUp('`capy`'));
}

const { AuthService, silentAuthFailureMessage } = await import('../auth/authService');
Expand Down Expand Up @@ -355,7 +356,7 @@ async function mintForDeploy(
devMode: boolean = false,
): Promise<{ secretsBlob: string; deployKey: string; deployId: string; valueHashes: Record<string, string> }> {
const keep = readKeep(cwd);
if (!keep) throw new Error('no keep.lock — run `capy` to sync first.');
if (!keep) throw new Error(PROJECT_FILE_COPY.notSetUp('`capy`'));

const { AuthService, silentAuthFailureMessage } = await import('../auth/authService');
const { ServiceClient } = await import('../service/serviceClient');
Expand Down Expand Up @@ -531,13 +532,13 @@ async function pushKeepTransform(
if (!keep) return { ok: false };
if (transform(keep) === keep) return { ok: true };

const fresh = await resolveFreshSnapshot(cwd, branch, devMode, `${label} in keep.lock`, opts.warnCode);
const fresh = await resolveFreshSnapshot(cwd, branch, devMode, label, opts.warnCode);
if (!fresh) return { ok: false };

// The shared keep-only upload (sync/commit.ts): the server's latest keep and blob, `base_keep_hash`, one retry if stale.
const done = await uploadKeepOnly(fresh.serviceClient, fresh.projectId, branch, transform);
if (!done.ok) {
console.error(` ${YELLOW('!')} could not ${label} in keep.lock: ${codePrefix}${done.code}`);
console.error(` ${YELLOW('!')} could not ${label}: ${codePrefix}${done.code}`);
return { ok: false };
}

Expand All @@ -546,7 +547,7 @@ async function pushKeepTransform(
}
return { ok: true };
} catch (err: any) {
console.error(` ${YELLOW('!')} could not ${label} in keep.lock: ${codePrefix}${scrubError(err)}`);
console.error(` ${YELLOW('!')} could not ${label}: ${codePrefix}${scrubError(err)}`);
return { ok: false };
}
}
Expand Down Expand Up @@ -620,7 +621,7 @@ async function resolveFreshSnapshot(
const localHash = SyncEngine.computeKeepHash(keep, branch);
if (latest.keep_hash !== localHash) {
console.error(
` ${YELLOW('!')} could not ${label} — ${codePrefix}local keep.lock is out of sync with the server for branch "${branch}"; run \`capy\` to sync first.`,
` ${YELLOW('!')} could not ${label} — ${codePrefix}${PROJECT_FILE_COPY.outOfSync} for branch "${branch}"; run \`capy\` to sync first.`,
);
return null;
}
Expand All @@ -643,7 +644,7 @@ function warnIfTokenUntracked(result: { ok: boolean }, deployId: string | undefi
if (result.ok || !deployId) return;
console.error(
` ${RED('✗')} ${ERROR_CODES.DEPLOY_TOKEN_UNTRACKED}: deploy token "${deployId}" for "${targetName}" was minted ` +
`but could not be recorded in keep.lock — it is now UNTRACKED. Run \`capy deploy revoke ${deployId}\` to revoke it.`,
`but could not be recorded — it is now UNTRACKED. Run \`capy deploy revoke ${deployId}\` to revoke it.`,
);
}

Expand Down Expand Up @@ -723,7 +724,7 @@ async function recordDeployTargetsCi(
const outcome = await recordCiDeliveryOnServer(cwd, target.branch, [{ delivery, values, deliveredAt }], devMode);
if (!outcome.ok) {
console.error(
` ${YELLOW('!')} could not record deploy targets in keep.lock: ${ERROR_CODES.CI_DEPLOY_TARGETS_RECORD_FAILED}: ${outcome.detail}`,
` ${YELLOW('!')} could not record deploy targets: ${ERROR_CODES.CI_DEPLOY_TARGETS_RECORD_FAILED}: ${outcome.detail}`,
);
}
warnIfTokenUntracked(outcome, deployId, target.name);
Expand Down Expand Up @@ -1387,8 +1388,8 @@ async function resolveMode(
): Promise<DeployMode> {
if (adapter.ciOnly) return 'ci';
const ciHelp = adapter.ciOnly
? `commit keep.lock on a branch + open PR; ${adapter.label}'s git CI deploys on merge`
: `commit keep.lock on a branch + push secrets + open PR; CI deploys on merge`;
? `commit Capy's project file on a branch + open PR; ${adapter.label}'s git CI deploys on merge`
: `commit Capy's project file on a branch + push secrets + open PR; CI deploys on merge`;
const ans = await inquirer.prompt([
{
type: 'list',
Expand All @@ -1402,7 +1403,7 @@ async function resolveMode(
short: 'ci',
},
{
name: `Deploy directly ${DIM('— commit keep.lock + push secrets + deploy now')}`,
name: `Deploy directly ${DIM("— commit Capy's project file + push secrets + deploy now")}`,
value: 'direct',
short: 'direct',
},
Expand Down Expand Up @@ -1831,7 +1832,7 @@ export async function deployRemove(
);
if (!stripResult.ok) {
console.error(
` ${YELLOW('!')} kept ${deployIds.length} deploy token(s) for "${name}" live — the keep.lock strip ` +
` ${YELLOW('!')} kept ${deployIds.length} deploy token(s) for "${name}" live — removing the targets ` +
`did not complete (see the warning above), so revoking them now would leave a stale record. ` +
// COPY-FLAG
`The target was kept; run \`capy\` to sync, then remove it again.`,
Expand All @@ -1842,7 +1843,7 @@ export async function deployRemove(
const { AuthService } = await import('../auth/authService');
const { ServiceClient } = await import('../service/serviceClient');
const projectState = await pm.detectProjectState();
if (!projectState.organizationId) throw new Error('no organization id in keep.lock');
if (!projectState.organizationId) throw new Error("This folder's Capy project file does not name its organization");
const authService = new AuthService(undefined, opts.devMode, projectState.userId);
const serviceClient = new ServiceClient(undefined, opts.devMode);
serviceClient.setTokenProvider((rejected, refusal) => authService.getValidToken(rejected, refusal));
Expand Down Expand Up @@ -1892,7 +1893,7 @@ export async function ensureDeployTarget(cwd: string = process.cwd()): Promise<T
const keep = readKeep(cwd);
if (!keep) {
console.error(
`No keep.lock in ${basename(cwd)}. Run ${B('capy')} here first to sync.`,
PROJECT_FILE_COPY.folderNotSetUp(basename(cwd)) + ` Run ${B('capy')} here to set it up.`,
);
return null;
}
Expand Down Expand Up @@ -2043,7 +2044,7 @@ async function resolveForceRedeploy(
name: 'force',
message:
`No secret changes vs origin/${baseBranch} — force a redeploy ` +
`(touch keep.lock to re-trigger CI)?`,
`(touch Capy's project file to re-trigger CI)?`,
default: false,
},
]);
Expand Down Expand Up @@ -2551,8 +2552,8 @@ async function confirmOrEdit(
const summary = !tracksKeepLock(cwd)
? `Deliver ${keep.projectName ?? keep.projectId} / ${target.branch} to ${adapter.label} target ${target.name}?`
: mode === 'ci'
? `Open a deploy PR (commit keep.lock + push secrets, no live deploy)?`
: `Deploy now (commit keep.lock + ship from HEAD; your WIP is stashed and restored)?`;
? `Open a deploy PR (commit Capy's project file + push secrets, no live deploy)?`
: `Deploy now (commit Capy's project file + ship from HEAD; your WIP is stashed and restored)?`;
const action = await keypressConfirm({ message: summary });
if (action === 'confirm') return stepOk(target);
if (action === 'cancel') {
Expand Down Expand Up @@ -2647,7 +2648,7 @@ export async function deployCommand(
const keep = readKeep(cwd);
if (!keep) {
console.error(
`No keep.lock in ${basename(cwd)}. Run ${B('capy')} here first to sync.`,
PROJECT_FILE_COPY.folderNotSetUp(basename(cwd)) + ` Run ${B('capy')} here to set it up.`,
);
return 1;
}
Expand Down
13 changes: 7 additions & 6 deletions src/commands/deployTokenCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { ProjectState } from '../types/index';
import { gateFirst } from '../sync/gate';
import { conflictFlagsOrExit, type RawConflictFlags } from '../sync/conflicts';
import { DEPLOY_KEY_RUNTIME_PAIR, OLD_RUNTIME_PAIR } from '../deploy/dokployApi';
import { PROJECT_FILE_COPY } from '../core/projectFileCopy';

/**
* `deploy revoke <id>` (CAP-679): strip every `targets` element carrying
Expand Down Expand Up @@ -63,7 +64,7 @@ async function stripRevokedTargets(
const branch = projectState.activeBranch;
if (!branch) {
console.error(
` \x1b[33m!\x1b[0m could not strip revoked deploy targets in keep.lock — ` +
` \x1b[33m!\x1b[0m could not remove the revoked deploy targets — ` +
`[${ERROR_CODES.DEPLOY_BRANCH_UNKNOWN}] the active branch could not be determined.`,
);
return;
Expand All @@ -73,14 +74,14 @@ async function stripRevokedTargets(
// moves, so nothing in this folder's `.env` can leak into the blob or revert anyone's value.
const done = await uploadKeepOnly(serviceClient, projectState.projectId, branch, (latest) => stripTargetsForDeployId(latest, deployId));
if (!done.ok) {
console.error(` \x1b[33m!\x1b[0m could not strip revoked deploy targets in keep.lock: ${done.code}`);
console.error(` \x1b[33m!\x1b[0m could not remove the revoked deploy targets: ${done.code}`);
return;
}
if (done.pushed) {
new FileManager().writeKeepFile(SyncEngine.spliceKeepBranch(keep, SyncEngine.adoptServerKeep(done.serverKeepFile, done.keep, branch), branch));
}
} catch (err: any) {
console.error(` \x1b[33m!\x1b[0m could not strip revoked deploy targets in keep.lock: ${err?.message ?? err}`);
console.error(` \x1b[33m!\x1b[0m could not remove the revoked deploy targets: ${err?.message ?? err}`);
}
}

Expand Down Expand Up @@ -573,7 +574,7 @@ export class DeployCommand {
const projectState = await pm.detectProjectState();

if (!projectState.initialized || !projectState.organizationId || !projectState.projectId) {
console.error(`No keep.lock file found. Run ${B('capy')} first to initialize.`);
console.error(PROJECT_FILE_COPY.notSetUp(B('capy')));
process.exit(1);
}

Expand Down Expand Up @@ -688,7 +689,7 @@ export class DeployRevokeCommand {
const projectState = await pm.detectProjectState();

if (!projectState.initialized || !projectState.organizationId) {
console.error(`No keep.lock file found. Run ${B('capy')} first to initialize.`);
console.error(PROJECT_FILE_COPY.notSetUp(B('capy')));
process.exit(1);
}

Expand Down Expand Up @@ -778,7 +779,7 @@ export class DeployListCommand {
const projectState = await pm.detectProjectState();

if (!projectState.initialized || !projectState.organizationId || !projectState.projectId) {
console.error(`No keep.lock file found. Run ${B('capy')} first to initialize.`);
console.error(PROJECT_FILE_COPY.notSetUp(B('capy')));
process.exit(1);
}

Expand Down
Loading
Loading