@sequenceholdings/studio-cli 0.9.23 → 0.9.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -146
- package/dist/access/commands.js +3 -5
- package/dist/access/principal.js +2 -2
- package/dist/access/tier-hosts.js +2 -2
- package/dist/agents/commands.d.ts +1 -1
- package/dist/agents/commands.js +9 -9
- package/dist/agents/scaffold.js +3 -3
- package/dist/agents/voice.d.ts +1 -1
- package/dist/agents/voice.js +1 -1
- package/dist/app/commands.d.ts +2 -2
- package/dist/app/commands.js +31 -21
- package/dist/app/deploy.d.ts +1 -1
- package/dist/app/deploy.js +1 -1
- package/dist/app/manifest.d.ts +9 -9
- package/dist/app/manifest.js +1 -1
- package/dist/app/prepare.js +1 -1
- package/dist/app/primitive-scaffold.js +1 -1
- package/dist/app/readme.js +6 -6
- package/dist/app/scaffold.js +1 -1
- package/dist/app/validate.d.ts +1 -1
- package/dist/app/workspace-scaffold.js +1 -1
- package/dist/app-preview/commands.d.ts +7 -0
- package/dist/app-preview/commands.js +264 -0
- package/dist/app-preview/fingerprint.d.ts +20 -0
- package/dist/app-preview/fingerprint.js +32 -0
- package/dist/app-preview/install.d.ts +31 -0
- package/dist/app-preview/install.js +53 -0
- package/dist/app-preview/namespace-probe.d.ts +13 -0
- package/dist/app-preview/namespace-probe.js +50 -0
- package/dist/app-preview/plan.d.ts +28 -0
- package/dist/app-preview/plan.js +41 -0
- package/dist/app-preview/run.d.ts +32 -0
- package/dist/app-preview/run.js +48 -0
- package/dist/app-preview/runners.d.ts +73 -0
- package/dist/app-preview/runners.js +226 -0
- package/dist/app-preview/secrets.d.ts +48 -0
- package/dist/app-preview/secrets.js +104 -0
- package/dist/app-preview/target.d.ts +28 -0
- package/dist/app-preview/target.js +62 -0
- package/dist/artifact/delegate.d.ts +1 -12
- package/dist/artifact/delegate.js +43 -124
- package/dist/artifact/sandbox.js +1 -1
- package/dist/auth-cmds/commands.js +1 -2
- package/dist/auth.js +1 -3
- package/dist/bin.js +12 -2
- package/dist/cli-attribution.d.ts +4 -0
- package/dist/cli-attribution.js +25 -3
- package/dist/cli-errors.d.ts +9 -1
- package/dist/cli-errors.js +20 -9
- package/dist/command-contract.d.ts +7 -182
- package/dist/command-contract.js +9 -33
- package/dist/command-help.d.ts +6 -6
- package/dist/command-help.js +31 -27
- package/dist/command-telemetry.js +2 -2
- package/dist/config-dir.d.ts +8 -0
- package/dist/config-dir.js +35 -0
- package/dist/config.d.ts +6 -7
- package/dist/config.js +15 -15
- package/dist/docs/commands.js +9 -4
- package/dist/edge-auth-headers.js +1 -18
- package/dist/env-registry.d.ts +4 -0
- package/dist/env-registry.js +15 -6
- package/dist/envs/commands.d.ts +3 -0
- package/dist/envs/commands.js +11 -0
- package/dist/exit-codes.d.ts +16 -0
- package/dist/exit-codes.js +27 -0
- package/dist/functions/bundle.d.ts +1 -1
- package/dist/functions/commands.d.ts +15 -0
- package/dist/functions/commands.js +86 -29
- package/dist/functions/manifest.js +1 -1
- package/dist/functions/service-account-guidance.d.ts +1 -1
- package/dist/functions/service-account-guidance.js +2 -2
- package/dist/lifecycle/check.d.ts +13 -0
- package/dist/lifecycle/check.js +116 -0
- package/dist/lifecycle/commands.d.ts +14 -0
- package/dist/lifecycle/commands.js +121 -0
- package/dist/lifecycle/plan.d.ts +28 -0
- package/dist/lifecycle/plan.js +113 -0
- package/dist/lifecycle/rollback.d.ts +7 -0
- package/dist/lifecycle/rollback.js +89 -0
- package/dist/lifecycle/seq-ci-tools.d.ts +107 -0
- package/dist/lifecycle/seq-ci-tools.js +177 -0
- package/dist/lifecycle/upgrade.d.ts +3 -0
- package/dist/lifecycle/upgrade.js +38 -0
- package/dist/machine-output.d.ts +11 -2
- package/dist/machine-output.js +32 -10
- package/dist/main.d.ts +16 -6
- package/dist/main.js +187 -361
- package/dist/orgs.d.ts +45 -0
- package/dist/orgs.js +106 -0
- package/dist/orm/delegate.d.ts +1 -1
- package/dist/orm/delegate.js +32 -18
- package/dist/orm/deployment-policy.js +1 -2
- package/dist/orm/discover.js +6 -8
- package/dist/orm/execute.d.ts +1 -1
- package/dist/orm/execute.js +5 -6
- package/dist/orm/failures.js +2 -2
- package/dist/orm/help.d.ts +1 -1
- package/dist/orm/help.js +5 -5
- package/dist/orm/history.js +1 -2
- package/dist/orm/operation-show.js +1 -2
- package/dist/orm/version-guard.d.ts +7 -2
- package/dist/orm/version-guard.js +12 -7
- package/dist/pipeline/codegen.js +2 -2
- package/dist/pipeline/commands.js +9 -7
- package/dist/pipeline/discovery.d.ts +1 -1
- package/dist/pipeline/discovery.js +2 -3
- package/dist/pipeline/help.d.ts +1 -1
- package/dist/pipeline/help.js +1 -1
- package/dist/pipeline/lifecycle.js +1 -1
- package/dist/pipeline/stage-secrets.js +4 -4
- package/dist/pipeline/templates.js +2 -2
- package/dist/pnpm-auto-update.js +3 -3
- package/dist/principals/commands.d.ts +1 -1
- package/dist/principals/commands.js +13 -14
- package/dist/process/commands.js +4 -1
- package/dist/process/run-steps.d.ts +2 -2
- package/dist/process/runs.js +1 -2
- package/dist/registry/commands.d.ts +4 -0
- package/dist/registry/commands.js +281 -0
- package/dist/registry/help.d.ts +8 -0
- package/dist/registry/help.js +64 -0
- package/dist/registry/lifecycle-commands.d.ts +3 -0
- package/dist/registry/lifecycle-commands.js +67 -0
- package/dist/registry/lookup.d.ts +6 -0
- package/dist/registry/lookup.js +18 -0
- package/dist/registry/runners.d.ts +14 -0
- package/dist/registry/runners.js +206 -0
- package/dist/registry/spec.d.ts +45 -0
- package/dist/registry/spec.js +8 -0
- package/dist/repos/commands.d.ts +1 -4
- package/dist/repos/commands.js +3 -21
- package/dist/repos/github-connect-command.d.ts +10 -1
- package/dist/repos/github-connect-command.js +52 -11
- package/dist/repos/github-init.d.ts +9 -2
- package/dist/repos/github-init.js +18 -2
- package/dist/repos/init-repo.js +1 -2
- package/dist/run-pinned.d.ts +48 -0
- package/dist/run-pinned.js +127 -0
- package/dist/sdk-source.d.ts +64 -0
- package/dist/sdk-source.js +199 -0
- package/dist/secrets/commands.d.ts +1 -1
- package/dist/secrets/commands.js +29 -24
- package/dist/service-accounts/commands.d.ts +1 -1
- package/dist/service-accounts/commands.js +4 -5
- package/dist/staged-env.d.ts +14 -0
- package/dist/staged-env.js +73 -0
- package/dist/storage/commands.js +21 -22
- package/dist/templates/catalog.d.ts +5 -5
- package/dist/templates/catalog.js +1 -1
- package/dist/update-check.js +3 -3
- package/dist/version-support.d.ts +39 -0
- package/dist/version-support.js +71 -0
- package/package.json +11 -10
- package/release-summary.json +4 -1
- package/dist/preview.d.ts +0 -90
- package/dist/preview.js +0 -292
package/dist/env-registry.js
CHANGED
|
@@ -5,6 +5,7 @@ import { dirname, join } from 'node:path';
|
|
|
5
5
|
import { validateDeploymentAudience, validateDeploymentBaseUrl, } from '@sequenceholdings/artifact-studio/deployment-validation';
|
|
6
6
|
import { deleteRealmTokens, isSequenceAuthEnvName, isSharedLoginDeploymentName, usesSharedSequenceLogin, validateAuth0Domain, } from './auth.js';
|
|
7
7
|
import { withCrossProcessFileLock } from './file-lock.js';
|
|
8
|
+
import { parseCliOrg } from './orgs.js';
|
|
8
9
|
const DISCOVERY_PATH = '/api/auth/cli-config';
|
|
9
10
|
const ENV_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
10
11
|
function isRecord(value) {
|
|
@@ -30,7 +31,7 @@ function validateEnvironmentName(input) {
|
|
|
30
31
|
return name;
|
|
31
32
|
}
|
|
32
33
|
async function discoverRealm({ baseUrl, fetchImpl, }) {
|
|
33
|
-
const { cliEnvironment, ...login } = await fetchDeploymentLogin({ baseUrl, fetchImpl });
|
|
34
|
+
const { cliEnvironment, cliOrg, ...login } = await fetchDeploymentLogin({ baseUrl, fetchImpl });
|
|
34
35
|
// A tenant registration never trusts the shared Sequence login, so a first-party deployment
|
|
35
36
|
// is saved under its reserved name instead: say which, rather than refuse its audience.
|
|
36
37
|
if (usesSharedSequenceLogin(login)) {
|
|
@@ -38,7 +39,8 @@ async function discoverRealm({ baseUrl, fetchImpl, }) {
|
|
|
38
39
|
throw new Error(`${baseUrl} signs in with the shared Sequence login, so it is a first-party deployment. ` +
|
|
39
40
|
`Save it under its first-party name instead: seq-studio envs add ${reserved} ${baseUrl}`);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
const realm = { ...login, audience: validateDeploymentAudience({ audience: login.audience, baseUrl }) };
|
|
43
|
+
return cliOrg ? { realm, cliOrg } : { realm };
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
46
|
* Read a deployment's public CLI login config (`/api/auth/cli-config`) without
|
|
@@ -90,16 +92,23 @@ export async function fetchDeploymentLogin({ baseUrl, fetchImpl = fetch, }) {
|
|
|
90
92
|
if (missing.length > 0 || !domain || !clientId || !audience) {
|
|
91
93
|
throw new Error(`${url} response is missing auth0.{${missing.join(', ')}}.`);
|
|
92
94
|
}
|
|
93
|
-
const cliEnvironment = isRecord(data) ? optionalString(Reflect.get(data, 'cliEnvironment')) : undefined;
|
|
94
95
|
return {
|
|
95
96
|
domain: validateAuth0Domain(domain),
|
|
96
97
|
clientId,
|
|
97
98
|
audience,
|
|
98
99
|
organization: optionalString(Reflect.get(auth0, 'organization')),
|
|
99
100
|
m2mClientId: optionalString(Reflect.get(auth0, 'm2mClientId')),
|
|
100
|
-
...(
|
|
101
|
+
...advertisedIdentity(data),
|
|
101
102
|
};
|
|
102
103
|
}
|
|
104
|
+
/** The CLI environment name, and org and stage, a deployment advertises for itself. */
|
|
105
|
+
function advertisedIdentity(data) {
|
|
106
|
+
if (!isRecord(data))
|
|
107
|
+
return {};
|
|
108
|
+
const cliEnvironment = optionalString(Reflect.get(data, 'cliEnvironment'));
|
|
109
|
+
const cliOrg = parseCliOrg(Reflect.get(data, 'cliOrg'));
|
|
110
|
+
return { ...(cliEnvironment ? { cliEnvironment } : {}), ...(cliOrg ? { cliOrg } : {}) };
|
|
111
|
+
}
|
|
103
112
|
async function loadConfig(configFile) {
|
|
104
113
|
try {
|
|
105
114
|
const parsed = JSON.parse(await readFile(configFile, 'utf8'));
|
|
@@ -188,7 +197,7 @@ async function clearEnvironmentCredentials({ configFile, name, }) {
|
|
|
188
197
|
export async function registerEnvironment({ baseUrl: rawBaseUrl, clearCredentials, configFile = seqapiConfigPath(), fetchImpl = fetch, name: rawName, }) {
|
|
189
198
|
const name = validateEnvironmentName(rawName);
|
|
190
199
|
const baseUrl = validateDeploymentBaseUrl(rawBaseUrl);
|
|
191
|
-
const realm = await discoverRealm({ baseUrl, fetchImpl });
|
|
200
|
+
const { realm, cliOrg } = await discoverRealm({ baseUrl, fetchImpl });
|
|
192
201
|
// Lock ordering contract: credential cleanup may acquire tokens.json.lock
|
|
193
202
|
// while this is held; token-file code must never acquire config.json.lock.
|
|
194
203
|
const replacing = await withCrossProcessFileLock({
|
|
@@ -217,5 +226,5 @@ export async function registerEnvironment({ baseUrl: rawBaseUrl, clearCredential
|
|
|
217
226
|
return isReplacement;
|
|
218
227
|
},
|
|
219
228
|
});
|
|
220
|
-
return { name, baseUrl, replacing, realm };
|
|
229
|
+
return { name, baseUrl, replacing, realm, ...(cliOrg ? { cliOrg } : {}) };
|
|
221
230
|
}
|
package/dist/envs/commands.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
+
import { type CliOrg } from '../orgs.js';
|
|
1
2
|
export declare function runEnvsCommand(sub: string | undefined, rest: string[]): Promise<number>;
|
|
3
|
+
/** Record the deployment's org so `-e <org>/<stage>` resolves; say so when it does. */
|
|
4
|
+
export declare function rememberOrg(cliOrg: CliOrg | undefined): Promise<void>;
|
package/dist/envs/commands.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { addLocalEnvironment, addSharedLoginEnvironment, readConfig, configPath, manualEnvConfigHint } from '../config.js';
|
|
2
2
|
import { isSharedLoginDeploymentName } from '../auth.js';
|
|
3
|
+
import { recordCliOrg, STAGES } from '../orgs.js';
|
|
3
4
|
import { readRegisteredEnvironmentUrls, registerEnvironment, } from '../env-registry.js';
|
|
4
5
|
import { describeSandboxTarget, SANDBOX_ENV_NAME, sandboxTarget, sandboxUsageFooter, } from '../sandbox-auth.js';
|
|
5
6
|
const ENVS_USAGE = `usage:
|
|
@@ -81,10 +82,12 @@ async function addCommand(rest) {
|
|
|
81
82
|
const added = await addSharedLoginEnvironment({ name: name.toLowerCase(), baseUrl });
|
|
82
83
|
console.log(`${added.changed ? 'Added' : 'Already configured:'} environment '${added.name}' -> ${added.baseUrl} ` +
|
|
83
84
|
`(shared Sequence login, saved in ${configPath()})`);
|
|
85
|
+
await rememberOrg(added.cliOrg);
|
|
84
86
|
console.log('Next: seq-studio login');
|
|
85
87
|
return 0;
|
|
86
88
|
}
|
|
87
89
|
const registration = await registerEnvironment({ name, baseUrl });
|
|
90
|
+
await rememberOrg(registration.cliOrg);
|
|
88
91
|
const verb = registration.replacing ? 'Updated' : 'Registered';
|
|
89
92
|
console.log(`${verb} environment '${registration.name}' -> ${registration.baseUrl}`);
|
|
90
93
|
console.log(` auth0 domain: ${registration.realm.domain}`);
|
|
@@ -103,6 +106,14 @@ async function addCommand(rest) {
|
|
|
103
106
|
return 1;
|
|
104
107
|
}
|
|
105
108
|
}
|
|
109
|
+
/** Record the deployment's org so `-e <org>/<stage>` resolves; say so when it does. */
|
|
110
|
+
export async function rememberOrg(cliOrg) {
|
|
111
|
+
if (!cliOrg)
|
|
112
|
+
return;
|
|
113
|
+
const orgs = await recordCliOrg(cliOrg);
|
|
114
|
+
const stages = STAGES.filter((stage) => orgs[cliOrg.org]?.[stage]);
|
|
115
|
+
console.log(` org: ${cliOrg.org} (${stages.map((stage) => `-e ${cliOrg.org}/${stage}`).join(', ')})`);
|
|
116
|
+
}
|
|
106
117
|
async function listCommand() {
|
|
107
118
|
const [config, registered] = await Promise.all([
|
|
108
119
|
readConfig(),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Process exit codes. Part of the 1.0 contract: scripts may branch on them. */
|
|
2
|
+
export declare const ExitCode: {
|
|
3
|
+
readonly Ok: 0;
|
|
4
|
+
readonly Failed: 1;
|
|
5
|
+
/** Unknown command, verb or flag, or a removed command. */
|
|
6
|
+
readonly Usage: 2;
|
|
7
|
+
/** validate, plan or a --check found blocking items; nothing was changed. */
|
|
8
|
+
readonly Blocked: 3;
|
|
9
|
+
/** Not authenticated or not allowed. */
|
|
10
|
+
readonly Auth: 4;
|
|
11
|
+
};
|
|
12
|
+
/** A mistake in how the command was invoked, as opposed to the operation failing. */
|
|
13
|
+
export declare class UsageError extends Error {
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function exitCodeFor(error: unknown): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Process exit codes. Part of the 1.0 contract: scripts may branch on them. */
|
|
2
|
+
export const ExitCode = {
|
|
3
|
+
Ok: 0,
|
|
4
|
+
Failed: 1,
|
|
5
|
+
/** Unknown command, verb or flag, or a removed command. */
|
|
6
|
+
Usage: 2,
|
|
7
|
+
/** validate, plan or a --check found blocking items; nothing was changed. */
|
|
8
|
+
Blocked: 3,
|
|
9
|
+
/** Not authenticated or not allowed. */
|
|
10
|
+
Auth: 4,
|
|
11
|
+
};
|
|
12
|
+
/** A mistake in how the command was invoked, as opposed to the operation failing. */
|
|
13
|
+
export class UsageError extends Error {
|
|
14
|
+
name = 'UsageError';
|
|
15
|
+
}
|
|
16
|
+
export function exitCodeFor(error) {
|
|
17
|
+
if (error instanceof UsageError)
|
|
18
|
+
return ExitCode.Usage;
|
|
19
|
+
// Matched by name and status rather than instanceof: this module is loaded by
|
|
20
|
+
// the bin entry point, which must not pull in the Atlas client.
|
|
21
|
+
if (error instanceof Error && (error.name === 'AtlasApiError' || error.name === 'PlatformError')) {
|
|
22
|
+
const status = Reflect.get(error, 'status');
|
|
23
|
+
if (status === 401 || status === 403)
|
|
24
|
+
return ExitCode.Auth;
|
|
25
|
+
}
|
|
26
|
+
return ExitCode.Failed;
|
|
27
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Local bundle collection for `seq-studio
|
|
2
|
+
* Local bundle collection for `seq-studio function deploy`. The CLI
|
|
3
3
|
* ALWAYS excludes dotenv files (the server rejects them as a backstop),
|
|
4
4
|
* plus node_modules (vendored server-side), VCS metadata, and .npmrc
|
|
5
5
|
* (the registry is pinned server-side). Pnpm hook files are kept in the
|
|
@@ -77,6 +77,21 @@ export declare function promptHidden(question: string): Promise<string>;
|
|
|
77
77
|
export declare function printError(error: unknown): void;
|
|
78
78
|
export declare function functionsInitCommand(args: ParsedArgs): Promise<number>;
|
|
79
79
|
export declare function functionsBuildCommand(args: ParsedArgs): Promise<number>;
|
|
80
|
+
/**
|
|
81
|
+
* Rebind a function row that a database fork copied to the local Atlas being deployed to.
|
|
82
|
+
* Only a local Atlas on a personal or devbox database branch offers this; anywhere else it is refused.
|
|
83
|
+
*/
|
|
84
|
+
export declare function adoptIntoLocalRuntime({ ctx, functionId }: {
|
|
85
|
+
ctx: CommandContext;
|
|
86
|
+
functionId: string;
|
|
87
|
+
}): Promise<{
|
|
88
|
+
ok: true;
|
|
89
|
+
adopted: boolean;
|
|
90
|
+
from: string;
|
|
91
|
+
} | {
|
|
92
|
+
ok: false;
|
|
93
|
+
message: string;
|
|
94
|
+
}>;
|
|
80
95
|
export declare function functionsDeployCommand(args: ParsedArgs): Promise<number>;
|
|
81
96
|
export declare function pollVersion({ ctx, functionId, versionId, egressNote, immutableRelease, }: {
|
|
82
97
|
ctx: CommandContext;
|
|
@@ -111,7 +111,7 @@ export async function readManifestOptional(dir) {
|
|
|
111
111
|
async function readManifest(dir) {
|
|
112
112
|
const manifest = await readManifestOptional(dir);
|
|
113
113
|
if (!manifest) {
|
|
114
|
-
throw new Error(`No ${MF_MANIFEST_FILENAME} in ${dir}. Run \`seq-studio
|
|
114
|
+
throw new Error(`No ${MF_MANIFEST_FILENAME} in ${dir}. Run \`seq-studio function init\` to scaffold one, or pass --dir.`);
|
|
115
115
|
}
|
|
116
116
|
return manifest;
|
|
117
117
|
}
|
|
@@ -125,7 +125,7 @@ async function readSourceManifest(dir, spec) {
|
|
|
125
125
|
if (manifest)
|
|
126
126
|
return manifest;
|
|
127
127
|
throw new Error(spec.kind === 'local'
|
|
128
|
-
? `No ${MF_MANIFEST_FILENAME} in ${dir}. Run \`seq-studio
|
|
128
|
+
? `No ${MF_MANIFEST_FILENAME} in ${dir}. Run \`seq-studio function init\` to scaffold one, or pass --dir.`
|
|
129
129
|
: `No ${MF_MANIFEST_FILENAME} in the selected remote source directory — keep it at the repo root or select a function directory with --path.`);
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
@@ -144,7 +144,7 @@ async function resolveFunction({ ctx, args, required = true, }) {
|
|
|
144
144
|
});
|
|
145
145
|
const fn = functions.find((f) => f.slug === slug) ?? null;
|
|
146
146
|
if (!fn && required) {
|
|
147
|
-
throw new Error(`Managed function "${slug}" not found on ${ctx.env.name} (or you don't have access). Run \`seq-studio
|
|
147
|
+
throw new Error(`Managed function "${slug}" not found on ${ctx.env.name} (or you don't have access). Run \`seq-studio function list -e ${ctx.env.name}\` to see what exists.`);
|
|
148
148
|
}
|
|
149
149
|
return fn;
|
|
150
150
|
}
|
|
@@ -225,7 +225,7 @@ async function gitMetadata(dir) {
|
|
|
225
225
|
/** Prompt on the TTY with echo suppressed — secret values are never displayed. */
|
|
226
226
|
export async function promptHidden(question) {
|
|
227
227
|
if (!process.stdin.isTTY) {
|
|
228
|
-
// Piped stdin: read it all (`echo "$VALUE" | seq-studio
|
|
228
|
+
// Piped stdin: read it all (`echo "$VALUE" | seq-studio secret set KEY`).
|
|
229
229
|
const chunks = [];
|
|
230
230
|
for await (const chunk of process.stdin)
|
|
231
231
|
chunks.push(chunk);
|
|
@@ -288,7 +288,7 @@ limits:
|
|
|
288
288
|
# @sequenceholdings/managed-functions/orm (no operations.manifest.json copy).
|
|
289
289
|
# Data access on behalf of the caller needs no service account. To also act as
|
|
290
290
|
# the function itself (createFunctionServiceOrmExecutor, Lattice runs), name a
|
|
291
|
-
# service_account you hold the actor role on (seq-studio service-
|
|
291
|
+
# service_account you hold the actor role on (seq-studio service-account list |
|
|
292
292
|
# create): the account then acts in every namespace, or only in the ones you
|
|
293
293
|
# mark service: true. service: true requires a service_account.
|
|
294
294
|
# capabilities:
|
|
@@ -386,7 +386,7 @@ dist/
|
|
|
386
386
|
export async function functionsInitCommand(args) {
|
|
387
387
|
const target = args.positional[0];
|
|
388
388
|
if (!target) {
|
|
389
|
-
console.error('usage: seq-studio
|
|
389
|
+
console.error('usage: seq-studio function init <dir> [--repo <ns>/<name> -e <env>]');
|
|
390
390
|
return 1;
|
|
391
391
|
}
|
|
392
392
|
if (args.flags.repo !== undefined) {
|
|
@@ -420,9 +420,9 @@ export async function functionsInitCommand(args) {
|
|
|
420
420
|
console.log('');
|
|
421
421
|
console.log('Next steps (init is only needed when creating a function from scratch):');
|
|
422
422
|
console.log(` cd ${target}`);
|
|
423
|
-
console.log(' seq-studio
|
|
423
|
+
console.log(' seq-studio function build # local pre-flight checks');
|
|
424
424
|
console.log(' # Add secret names to managed-function.yml (secrets: [MY_SECRET]) and values to .env');
|
|
425
|
-
console.log(' seq-studio
|
|
425
|
+
console.log(' seq-studio function deploy -e <env> # upload, apply secrets, then deploy');
|
|
426
426
|
return 0;
|
|
427
427
|
}
|
|
428
428
|
// ---------------------------------------------------------------------------
|
|
@@ -467,7 +467,7 @@ async function buildFromResolvedSource({ spec, source, }) {
|
|
|
467
467
|
...manifestEgressIpRanges(manifest.egress),
|
|
468
468
|
])}`);
|
|
469
469
|
for (const excluded of excludedEnvFiles) {
|
|
470
|
-
console.warn(`${LOG} excluded ${excluded} — dotenv files never enter bundles; use .env as a value source for \`seq-studio
|
|
470
|
+
console.warn(`${LOG} excluded ${excluded} — dotenv files never enter bundles; use .env as a value source for \`seq-studio function deploy\``);
|
|
471
471
|
}
|
|
472
472
|
for (const issue of issues) {
|
|
473
473
|
const log = issue.level === 'error' ? console.error : issue.level === 'warning' ? console.warn : console.log;
|
|
@@ -509,6 +509,33 @@ async function getFunctionDetail(ctx, functionId) {
|
|
|
509
509
|
throw error;
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
|
+
const ADOPTED_FROM = {
|
|
513
|
+
hosted: 'a hosted runtime',
|
|
514
|
+
'other-local-workspace': 'another local workspace',
|
|
515
|
+
'never-deployed': 'a runtime that never deployed it',
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* Rebind a function row that a database fork copied to the local Atlas being deployed to.
|
|
519
|
+
* Only a local Atlas on a personal or devbox database branch offers this; anywhere else it is refused.
|
|
520
|
+
*/
|
|
521
|
+
export async function adoptIntoLocalRuntime({ ctx, functionId }) {
|
|
522
|
+
try {
|
|
523
|
+
const result = await postJson({
|
|
524
|
+
...clientOptions(ctx),
|
|
525
|
+
path: `/api/managed-functions/${functionId}/local-adoption`,
|
|
526
|
+
});
|
|
527
|
+
return { ok: true, adopted: result.adopted === true, from: ADOPTED_FROM[result.from ?? ''] ?? 'another runtime' };
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
if (error instanceof AtlasApiError && error.status === 404) {
|
|
531
|
+
return { ok: false, message: `--adopt works only against a local Atlas; ${ctx.env.name} does not offer it` };
|
|
532
|
+
}
|
|
533
|
+
if (error instanceof AtlasApiError && (error.status === 409 || error.status === 403)) {
|
|
534
|
+
return { ok: false, message: error.message };
|
|
535
|
+
}
|
|
536
|
+
throw error;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
512
539
|
export async function functionsDeployCommand(args) {
|
|
513
540
|
// Fail before source resolution / auth so a missing `-e` never becomes
|
|
514
541
|
// `fetch failed` against localhost. `buildContext` enforces the same rule.
|
|
@@ -611,18 +638,31 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
611
638
|
...clientOptions(ctx),
|
|
612
639
|
path: `/api/managed-functions?slug=${encodeURIComponent(slug)}`,
|
|
613
640
|
});
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
641
|
+
let existingShell = functions.find((f) => f.slug === slug) ?? null;
|
|
642
|
+
// Adoption changes the copied row, so it waits for the confirmation below like every other
|
|
643
|
+
// write. It also clears a copied immutable release, so those refusals wait for it too.
|
|
644
|
+
const adopting = existingShell !== null && flagBool(args.flags, 'adopt');
|
|
645
|
+
const immutableRefusal = (shell) => {
|
|
646
|
+
if (shell?.immutableRelease === true) {
|
|
647
|
+
return 'this function is an immutable release. Create a new function ID; this identity cannot be redeployed.';
|
|
648
|
+
}
|
|
649
|
+
if (manifest.function.immutable_release === true && shell?.activeVersionId) {
|
|
650
|
+
return 'immutable release opt-in must precede first activation. Create a new function ID.';
|
|
651
|
+
}
|
|
652
|
+
return null;
|
|
653
|
+
};
|
|
654
|
+
if (!adopting) {
|
|
655
|
+
const refusal = immutableRefusal(existingShell);
|
|
656
|
+
if (refusal) {
|
|
657
|
+
console.error(`${LOG} ${refusal}`);
|
|
658
|
+
return 1;
|
|
659
|
+
}
|
|
622
660
|
}
|
|
623
|
-
const shellAction = existingShell
|
|
624
|
-
? `
|
|
625
|
-
:
|
|
661
|
+
const shellAction = !existingShell
|
|
662
|
+
? `will register new shell on ${ctx.env.name}`
|
|
663
|
+
: adopting
|
|
664
|
+
? `existing shell on ${ctx.env.name}; adopted into this local Atlas if another runtime owns it`
|
|
665
|
+
: `existing shell on ${ctx.env.name}`;
|
|
626
666
|
let versions = [];
|
|
627
667
|
if (existingShell) {
|
|
628
668
|
try {
|
|
@@ -667,7 +707,7 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
667
707
|
for (const envName of Object.values(binding.entries)) {
|
|
668
708
|
if (!envValues[envName])
|
|
669
709
|
continue;
|
|
670
|
-
console.error(`${LOG} ${envName} is mapped from key/value set ${binding.secret}; remove its local .env value and update the set with seq-studio
|
|
710
|
+
console.error(`${LOG} ${envName} is mapped from key/value set ${binding.secret}; remove its local .env value and update the set with seq-studio secret set --from-json`);
|
|
671
711
|
return 1;
|
|
672
712
|
}
|
|
673
713
|
}
|
|
@@ -686,7 +726,7 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
686
726
|
if (secret)
|
|
687
727
|
serverInfoByName.set(envName, { id: secret.id, hasDefaultValue: secret.hasDefaultValue, attachmentCount: secret.attachmentCount });
|
|
688
728
|
if (envValues[envName]) {
|
|
689
|
-
console.error(`${LOG} ${envName} is mapped from key/value set ${secret?.name ?? a.secretId}; remove its local .env value and update the set with seq-studio
|
|
729
|
+
console.error(`${LOG} ${envName} is mapped from key/value set ${secret?.name ?? a.secretId}; remove its local .env value and update the set with seq-studio secret set --from-json`);
|
|
690
730
|
return 1;
|
|
691
731
|
}
|
|
692
732
|
}
|
|
@@ -703,7 +743,7 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
703
743
|
if (classification.blocked.length > 0) {
|
|
704
744
|
for (const c of classification.blocked) {
|
|
705
745
|
console.error(`${LOG} secret "${c.name}" is declared but has no value — ` +
|
|
706
|
-
`add it to .env, run \`seq-studio
|
|
746
|
+
`add it to .env, run \`seq-studio secret set ${c.name} -e ${ctx.env.name}\`, or set it in the Sequence app`);
|
|
707
747
|
}
|
|
708
748
|
console.error(`${LOG} resolve the above before deploying`);
|
|
709
749
|
return 1;
|
|
@@ -758,13 +798,13 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
758
798
|
const problems = [];
|
|
759
799
|
if (!existingShell) {
|
|
760
800
|
problems.push(`function "${slug}" is not registered on ${ctx.env.name} — run ` +
|
|
761
|
-
`\`seq-studio
|
|
801
|
+
`\`seq-studio function deploy -e ${ctx.env.name}\` once with your own login (` +
|
|
762
802
|
`\`seq-studio login\`) to register it`);
|
|
763
803
|
}
|
|
764
804
|
for (const c of classification?.secrets ?? []) {
|
|
765
805
|
if (c.category === 'UPLOAD_NEW' || c.category === 'OVERWRITE') {
|
|
766
806
|
problems.push(`secret "${c.name}" would be written from a local value — provision it server-side first: ` +
|
|
767
|
-
`\`seq-studio
|
|
807
|
+
`\`seq-studio secret set ${c.name} -e ${ctx.env.name}\``);
|
|
768
808
|
}
|
|
769
809
|
}
|
|
770
810
|
if (problems.length > 0) {
|
|
@@ -778,6 +818,22 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
778
818
|
const ok = await confirmYes({ preview, confirmed });
|
|
779
819
|
if (!ok)
|
|
780
820
|
return 1;
|
|
821
|
+
if (adopting && existingShell) {
|
|
822
|
+
const adoption = await adoptIntoLocalRuntime({ ctx, functionId: existingShell.id });
|
|
823
|
+
if (!adoption.ok) {
|
|
824
|
+
console.error(`${LOG} ${adoption.message}`);
|
|
825
|
+
return 1;
|
|
826
|
+
}
|
|
827
|
+
if (adoption.adopted) {
|
|
828
|
+
console.log(`${LOG} adopted ${slug} into this local Atlas (it came from ${adoption.from}); the runtime it was copied from is untouched`);
|
|
829
|
+
existingShell = await resolveFunction({ ctx, args: { positional: [], flags: { fn: slug } }, required: false });
|
|
830
|
+
}
|
|
831
|
+
const refusal = immutableRefusal(existingShell);
|
|
832
|
+
if (refusal) {
|
|
833
|
+
console.error(`${LOG} ${refusal}`);
|
|
834
|
+
return 1;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
781
837
|
// Ensure the function shell exists before reconciling secrets (which need the fn id).
|
|
782
838
|
let fn = existingShell;
|
|
783
839
|
let createdShell = false;
|
|
@@ -835,8 +891,9 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
835
891
|
}
|
|
836
892
|
catch (error) {
|
|
837
893
|
if (error instanceof AtlasApiError && error.status === 409) {
|
|
838
|
-
|
|
839
|
-
|
|
894
|
+
// Only an uncoded 409 is a version race; any other conflict (an immutable release, a local workspace
|
|
895
|
+
// mismatch) says what it is.
|
|
896
|
+
if (typeof error.body === 'object' && error.body !== null && typeof Reflect.get(error.body, 'code') === 'string') {
|
|
840
897
|
console.error(`${LOG} ${error.message}`);
|
|
841
898
|
return 1;
|
|
842
899
|
}
|
|
@@ -850,7 +907,7 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
850
907
|
}
|
|
851
908
|
console.log(`${LOG} version ${version.version} uploaded — building (server-side install + function startup)`);
|
|
852
909
|
if (args.flags['no-wait']) {
|
|
853
|
-
console.log(`${LOG} not waiting (--no-wait). Poll with: seq-studio
|
|
910
|
+
console.log(`${LOG} not waiting (--no-wait). Poll with: seq-studio function list -e ${ctx.env.name}`);
|
|
854
911
|
return 0;
|
|
855
912
|
}
|
|
856
913
|
return pollVersion({
|
|
@@ -1284,7 +1341,7 @@ async function listVersions(ctx, functionId) {
|
|
|
1284
1341
|
export async function functionsPromoteCommand(args) {
|
|
1285
1342
|
const versionName = args.positional[0];
|
|
1286
1343
|
if (!versionName) {
|
|
1287
|
-
console.error('usage: seq-studio
|
|
1344
|
+
console.error('usage: seq-studio function promote <version> -e <env> [--fn slug]');
|
|
1288
1345
|
return 1;
|
|
1289
1346
|
}
|
|
1290
1347
|
const ctx = await buildContext(args);
|
|
@@ -569,7 +569,7 @@ export const SERVICE_ACCOUNT_REQUIRED = 'SERVICE_ACCOUNT_REQUIRED';
|
|
|
569
569
|
/** The refusal for a manifest that needs a service account and names none, without caller-specific guidance. */
|
|
570
570
|
export function missingServiceAccountMessage(requirements) {
|
|
571
571
|
return `This function acts as itself, not as its caller, for ${requirements.join(', ')}, so managed-function.yml must name ` +
|
|
572
|
-
'a service_account. Create one with `seq-studio service-
|
|
572
|
+
'a service_account. Create one with `seq-studio service-account create <slug> --display-name "<name>"` (needs Can create ' +
|
|
573
573
|
'on Service Accounts) or use an existing account you hold the actor role on, then add `service_account: <slug>`. ' +
|
|
574
574
|
'Data access on behalf of the caller alone (capabilities.data without service: true) needs no account.';
|
|
575
575
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* names none. The manifest schema refuses it offline with a generic message;
|
|
4
4
|
* `functions deploy` can reach Atlas, so it also says whether this caller may
|
|
5
5
|
* create an account and which accounts they can already attach — the same
|
|
6
|
-
* facts `seq-studio service-
|
|
6
|
+
* facts `seq-studio service-account list` shows. Mirrors the server's refusal
|
|
7
7
|
* (atlas/src/server/services/managed-functions/service-account-guidance.ts).
|
|
8
8
|
*/
|
|
9
9
|
import { type ClientOptions } from '../atlas-client.js';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* names none. The manifest schema refuses it offline with a generic message;
|
|
4
4
|
* `functions deploy` can reach Atlas, so it also says whether this caller may
|
|
5
5
|
* create an account and which accounts they can already attach — the same
|
|
6
|
-
* facts `seq-studio service-
|
|
6
|
+
* facts `seq-studio service-account list` shows. Mirrors the server's refusal
|
|
7
7
|
* (atlas/src/server/services/managed-functions/service-account-guidance.ts).
|
|
8
8
|
*/
|
|
9
9
|
import { getJson } from '../atlas-client.js';
|
|
@@ -37,7 +37,7 @@ export function formatMissingServiceAccount({ requirements, canCreate, attachabl
|
|
|
37
37
|
lines.push(`Accounts you can attach (you hold the actor role): ${attachable.join(', ')}.`);
|
|
38
38
|
}
|
|
39
39
|
lines.push(canCreate
|
|
40
|
-
? 'You can create one: `seq-studio service-
|
|
40
|
+
? 'You can create one: `seq-studio service-account create <slug> --display-name "<name>" -e <env>`, then add ' +
|
|
41
41
|
'`service_account: <slug>` and redeploy. As its creator you hold the actor role needed to attach it.'
|
|
42
42
|
: 'You cannot create service accounts (that needs Can create on Service Accounts). Ask someone who holds it to create ' +
|
|
43
43
|
'one and grant you its actor role, or attach an existing account you hold the actor role on.');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ParsedArgs } from '../argv.js';
|
|
2
|
+
import { type Run } from './seq-ci-tools.js';
|
|
3
|
+
export interface CheckDeps {
|
|
4
|
+
exec: Run;
|
|
5
|
+
/** The release's pipeline workflow text, `gh` reading seq-ci at the pinned tag. */
|
|
6
|
+
workflowText: (release: string) => string;
|
|
7
|
+
githubRepository: (directory: string) => {
|
|
8
|
+
repository: string;
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function runAffectedCommand(args: ParsedArgs, deps?: CheckDeps): Promise<number>;
|
|
13
|
+
export declare function runCheckCommand(args: ParsedArgs, deps?: CheckDeps): Promise<number>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** `seq-studio affected` and `seq-studio check`: this repository's seq-ci release, run locally. */
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { ExitCode, UsageError } from '../exit-codes.js';
|
|
4
|
+
import { affectedArgs, checkArgs, dockerExecutable, localImageId, localRevisions, parseAffected, registryAuth, run, seqCiPinsFromWorkflow, seqCiToolsDirectory, } from './seq-ci-tools.js';
|
|
5
|
+
const AFFECTED_USAGE = `usage:
|
|
6
|
+
seq-studio affected [--base <rev>] [--head <rev>] [--dir <checkout>] [--json]
|
|
7
|
+
|
|
8
|
+
Which targets a change reaches, computed by this repository's pinned seq-ci release exactly as its pull request
|
|
9
|
+
job does. Compares the committed HEAD with where it left the dev branch (origin/<dev>), or --base. Uncommitted
|
|
10
|
+
edits are not included. Needs Docker, gh, and read access to the seq-ci image registry.`;
|
|
11
|
+
const CHECK_USAGE = `usage:
|
|
12
|
+
seq-studio check [<target>...] [--base <rev>] [--head <rev>] [--dir <checkout>]
|
|
13
|
+
|
|
14
|
+
Run seq-ci's checks locally, in the same sandboxes and images CI uses: every affected target, or the ones named.
|
|
15
|
+
Exit 0 when all pass, 1 when any fails, 3 when the plan has blocking findings. Needs Docker, gh, and read access
|
|
16
|
+
to the seq-ci image registry. Dependencies install from the Chainguard registry with the _auth in ~/.npmrc (or
|
|
17
|
+
SEQ_CI_REGISTRY_AUTH), as CI does with its org secret. Docker is found on PATH, or set SEQ_CI_DOCKER.`;
|
|
18
|
+
function flagString(args, name) {
|
|
19
|
+
const value = args.flags[name];
|
|
20
|
+
if (value === true)
|
|
21
|
+
throw new UsageError(`--${name} needs a value`);
|
|
22
|
+
return typeof value === 'string' ? value : undefined;
|
|
23
|
+
}
|
|
24
|
+
async function defaultDeps() {
|
|
25
|
+
const { gh, githubRepository } = await import('../repos/github-connect-command.js');
|
|
26
|
+
const { SEQ_CI_REPOSITORY } = await import('../repos/github-init.js');
|
|
27
|
+
return {
|
|
28
|
+
exec: run,
|
|
29
|
+
workflowText: (release) => Buffer.from(gh(['api', `repos/${SEQ_CI_REPOSITORY}/contents/.github/workflows/pipeline.yml?ref=${release}`, '--jq', '.content']), 'base64').toString('utf8'),
|
|
30
|
+
githubRepository: (directory) => githubRepository({ directory }),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Everything a local run needs, read from the checkout's `.seq/github.yml` and its pinned seq-ci release. */
|
|
34
|
+
async function prepare({ args, deps }) {
|
|
35
|
+
const directory = resolve(flagString(args, 'dir') ?? '.');
|
|
36
|
+
const { resolveSettings } = await import('../repos/github-init.js');
|
|
37
|
+
const settings = await resolveSettings({ directory }).catch((error) => {
|
|
38
|
+
throw new UsageError(`No usable .seq/github.yml in ${directory}: ${error instanceof Error ? error.message : String(error)}. Set the repository up with seq-studio repo init.`);
|
|
39
|
+
});
|
|
40
|
+
const pins = seqCiPinsFromWorkflow({ workflowText: deps.workflowText(settings.seq_ci), release: settings.seq_ci });
|
|
41
|
+
const github = deps.githubRepository(directory);
|
|
42
|
+
const revisions = localRevisions({ directory, devBranch: settings.branches.dev, base: flagString(args, 'base'), head: flagString(args, 'head'), exec: deps.exec });
|
|
43
|
+
// Resolved once so SEQ_CI_DOCKER reaches every image step, not only the check runner.
|
|
44
|
+
const docker = dockerExecutable();
|
|
45
|
+
const tools = await seqCiToolsDirectory({ pins, docker, exec: deps.exec });
|
|
46
|
+
const candidateId = localImageId({ image: pins.candidateImage, docker, exec: deps.exec });
|
|
47
|
+
// Managed Pipelines stay released under the git-service name, as Atlas plans them.
|
|
48
|
+
return { tools, pins, directory, githubRepositoryId: github.id, repository: settings.release_repository ?? github.repository, revisions, candidateId, docker };
|
|
49
|
+
}
|
|
50
|
+
function affected({ prepared, deps }) {
|
|
51
|
+
const result = deps.exec(process.execPath, affectedArgs(prepared), { cwd: prepared.directory });
|
|
52
|
+
if (result.status !== 0 && result.status !== ExitCode.Blocked) {
|
|
53
|
+
throw new Error(`affected.mjs failed: ${result.stderr.trim().split('\n').slice(-3).join(' ') || `exit ${result.status}`}`);
|
|
54
|
+
}
|
|
55
|
+
return { stdout: result.stdout, stderr: result.stderr, blocked: result.status === ExitCode.Blocked, ...parseAffected(result.stdout) };
|
|
56
|
+
}
|
|
57
|
+
export async function runAffectedCommand(args, deps) {
|
|
58
|
+
if (args.flags.help === true || args.flags.h === true) {
|
|
59
|
+
console.log(AFFECTED_USAGE);
|
|
60
|
+
return ExitCode.Ok;
|
|
61
|
+
}
|
|
62
|
+
const resolved = deps ?? await defaultDeps();
|
|
63
|
+
const prepared = await prepare({ args, deps: resolved });
|
|
64
|
+
const result = affected({ prepared, deps: resolved });
|
|
65
|
+
if (args.flags.json === true)
|
|
66
|
+
console.log(result.stdout.trim());
|
|
67
|
+
else {
|
|
68
|
+
console.log(`seq-ci ${prepared.pins.release} · ${prepared.revisions.base.slice(0, 7)}..${prepared.revisions.head.slice(0, 7)}`);
|
|
69
|
+
for (const target of result.targets)
|
|
70
|
+
console.log(`${target.affected ? 'check' : 'skip '} ${target.key}${target.reasons.length ? ` ${target.reasons.join('; ')}` : ''}`);
|
|
71
|
+
}
|
|
72
|
+
for (const finding of result.findings)
|
|
73
|
+
console.error(`${finding.severity}: ${finding.target ? `${finding.target}: ` : ''}${finding.message}`);
|
|
74
|
+
return result.blocked ? ExitCode.Blocked : ExitCode.Ok;
|
|
75
|
+
}
|
|
76
|
+
export async function runCheckCommand(args, deps) {
|
|
77
|
+
if (args.flags.help === true || args.flags.h === true) {
|
|
78
|
+
console.log(CHECK_USAGE);
|
|
79
|
+
return ExitCode.Ok;
|
|
80
|
+
}
|
|
81
|
+
const resolved = deps ?? await defaultDeps();
|
|
82
|
+
const prepared = await prepare({ args, deps: resolved });
|
|
83
|
+
const plan = affected({ prepared, deps: resolved });
|
|
84
|
+
for (const finding of plan.findings)
|
|
85
|
+
console.error(`${finding.severity}: ${finding.target ? `${finding.target}: ` : ''}${finding.message}`);
|
|
86
|
+
if (plan.blocked)
|
|
87
|
+
return ExitCode.Blocked;
|
|
88
|
+
const known = new Set(plan.targets.map(({ key }) => key));
|
|
89
|
+
const unknown = args.positional.filter((target) => !known.has(target));
|
|
90
|
+
if (unknown.length)
|
|
91
|
+
throw new UsageError(`Unknown target${unknown.length > 1 ? 's' : ''} ${unknown.join(', ')}. Targets: ${[...known].join(', ') || 'none'}`);
|
|
92
|
+
const targets = args.positional.length ? args.positional : plan.targets.filter(({ affected: reached }) => reached).map(({ key }) => key);
|
|
93
|
+
if (!targets.length) {
|
|
94
|
+
console.log('Nothing to check: no target is affected by this change.');
|
|
95
|
+
return ExitCode.Ok;
|
|
96
|
+
}
|
|
97
|
+
const { docker } = prepared;
|
|
98
|
+
const auth = registryAuth();
|
|
99
|
+
if (!auth) {
|
|
100
|
+
throw new Error('check installs dependencies from the Chainguard registry, as CI does, and found no credential for it. ' +
|
|
101
|
+
'Log in to libraries.cgr.dev in ~/.npmrc (an //libraries.cgr.dev/...:_auth= line), or set SEQ_CI_REGISTRY_AUTH to that value.');
|
|
102
|
+
}
|
|
103
|
+
const nextId = localImageId({ image: prepared.pins.nextImage, docker, exec: resolved.exec });
|
|
104
|
+
const runId = `local:${Date.now()}`;
|
|
105
|
+
const failed = [];
|
|
106
|
+
for (const target of targets) {
|
|
107
|
+
console.error(`checking ${target}…`);
|
|
108
|
+
const result = resolved.exec(process.execPath, checkArgs({ ...prepared, nextId, target, runId }), {
|
|
109
|
+
cwd: prepared.directory, stdio: 'inherit', env: { ...process.env, SEQ_CI_DOCKER: docker, SEQ_CI_REGISTRY_AUTH: auth },
|
|
110
|
+
});
|
|
111
|
+
if (result.status !== 0)
|
|
112
|
+
failed.push(target);
|
|
113
|
+
}
|
|
114
|
+
console.log(failed.length ? `${failed.length} of ${targets.length} failed: ${failed.join(', ')}` : `${targets.length} passed`);
|
|
115
|
+
return failed.length ? ExitCode.Failed : ExitCode.Ok;
|
|
116
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App lifecycle at the top level: `apply` and `status` (spec §4).
|
|
3
|
+
*
|
|
4
|
+
* `apply` is the app-level deploy under its 1.0 name. Once a repository is
|
|
5
|
+
* connected to deploy from GitHub, deploying one of its stages from a laptop is
|
|
6
|
+
* refused unless the caller names a reason with `--break-glass`.
|
|
7
|
+
*
|
|
8
|
+
* This is the CLI's half. Atlas checks every laptop deploy of a resource a connected
|
|
9
|
+
* repository controls: it warns, or refuses where the connection enforces it, unless the
|
|
10
|
+
* request carries the break-glass reason (laptop-deploy-guard.ts).
|
|
11
|
+
*/
|
|
12
|
+
import type { ParsedArgs } from '../argv.js';
|
|
13
|
+
export declare function runApplyCommand(args: ParsedArgs): Promise<number>;
|
|
14
|
+
export declare function runStatusCommand(args: ParsedArgs): Promise<number>;
|