@sequenceholdings/studio-cli 0.9.23 → 0.9.24
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 +152 -144
- 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/artifact/delegate.d.ts +1 -1
- package/dist/artifact/delegate.js +43 -3
- package/dist/auth-cmds/commands.js +1 -2
- 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 +4 -4
- package/dist/command-help.js +24 -24
- 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 -0
- package/dist/config.js +15 -3
- package/dist/docs/commands.js +9 -4
- 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.js +19 -18
- 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/preview.d.ts +1 -1
- package/dist/preview.js +1 -1
- 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 +60 -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.js +1 -2
- 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 +4 -4
- 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 +8 -7
- package/release-summary.json +2 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { cliConfigDir } from './config-dir.js';
|
|
1
2
|
import { randomUUID } from 'node:crypto';
|
|
2
3
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { currentVersion } from './update-check.js';
|
|
6
6
|
import { edgeAuthHeaders } from './edge-auth-headers.js';
|
|
7
|
-
const preferencePath = () => join(
|
|
7
|
+
const preferencePath = () => join(cliConfigDir(), 'telemetry.json');
|
|
8
8
|
const targets = new Map();
|
|
9
9
|
let active = false;
|
|
10
10
|
let terminalFailure;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function cliConfigDir(home?: string): string;
|
|
2
|
+
export declare function legacyConfigDir(home?: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Move `~/.config/lattice` to `~/.config/seq-studio` once. Best-effort: on any
|
|
5
|
+
* failure both paths are left as they were and the error is returned, so a
|
|
6
|
+
* read-only home never stops a command.
|
|
7
|
+
*/
|
|
8
|
+
export declare function migrateLegacyConfigDir(home?: string): Error | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where seq-studio keeps user configuration: `~/.config/seq-studio`.
|
|
3
|
+
*
|
|
4
|
+
* Earlier releases used `~/.config/lattice`. The first run moves that directory
|
|
5
|
+
* here and leaves a symlink at the old path, so tools that still read it (and
|
|
6
|
+
* older CLI versions pinned by a repository) see the same files.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, lstatSync, renameSync, symlinkSync } from 'node:fs';
|
|
9
|
+
import { homedir } from 'node:os';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
export function cliConfigDir(home = homedir()) {
|
|
12
|
+
return join(home, '.config', 'seq-studio');
|
|
13
|
+
}
|
|
14
|
+
export function legacyConfigDir(home = homedir()) {
|
|
15
|
+
return join(home, '.config', 'lattice');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Move `~/.config/lattice` to `~/.config/seq-studio` once. Best-effort: on any
|
|
19
|
+
* failure both paths are left as they were and the error is returned, so a
|
|
20
|
+
* read-only home never stops a command.
|
|
21
|
+
*/
|
|
22
|
+
export function migrateLegacyConfigDir(home = homedir()) {
|
|
23
|
+
const legacy = legacyConfigDir(home);
|
|
24
|
+
const current = cliConfigDir(home);
|
|
25
|
+
try {
|
|
26
|
+
if (existsSync(current) || !existsSync(legacy) || lstatSync(legacy).isSymbolicLink())
|
|
27
|
+
return null;
|
|
28
|
+
renameSync(legacy, current);
|
|
29
|
+
symlinkSync(current, legacy, 'dir');
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
34
|
+
}
|
|
35
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CliOrg, type OrgRegistry } from './orgs.js';
|
|
1
2
|
/**
|
|
2
3
|
* `--env preview:<branch-or-slug>` targets a per-PR Vercel preview deployment
|
|
3
4
|
* without a config.toml entry. The slug after the prefix is run through the
|
|
@@ -10,6 +11,10 @@ export interface LatticeConfig {
|
|
|
10
11
|
envs: Record<string, {
|
|
11
12
|
url: string;
|
|
12
13
|
}>;
|
|
14
|
+
/** Orgs learned from deployments' discovery, for `-e <org>/<stage>`. */
|
|
15
|
+
orgs?: OrgRegistry;
|
|
16
|
+
/** The `org` of the repository the command runs in (`.seq/github.yml`). */
|
|
17
|
+
repoOrg?: string;
|
|
13
18
|
defaultEnv: string;
|
|
14
19
|
}
|
|
15
20
|
export declare function globalConfigDir(): string;
|
|
@@ -70,6 +75,7 @@ export declare function addSharedLoginEnvironment({ name, baseUrl: rawBaseUrl, f
|
|
|
70
75
|
name: string;
|
|
71
76
|
baseUrl: string;
|
|
72
77
|
changed: boolean;
|
|
78
|
+
cliOrg?: CliOrg;
|
|
73
79
|
}>;
|
|
74
80
|
/**
|
|
75
81
|
* Save `local:<name>` for an Atlas on a loopback port that is not a
|
package/dist/config.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { cliConfigDir } from './config-dir.js';
|
|
2
|
+
import { isStage, readOrgs, repositoryOrg } from './orgs.js';
|
|
3
|
+
import { knownOrgs, resolveStagedEnv } from './staged-env.js';
|
|
1
4
|
import { execFile } from 'node:child_process';
|
|
2
5
|
import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
3
6
|
import { existsSync } from 'node:fs';
|
|
@@ -92,7 +95,7 @@ async function worktreeEnvironmentUrls() {
|
|
|
92
95
|
return environments;
|
|
93
96
|
}
|
|
94
97
|
export function globalConfigDir() {
|
|
95
|
-
return
|
|
98
|
+
return cliConfigDir();
|
|
96
99
|
}
|
|
97
100
|
export function configPath() {
|
|
98
101
|
return join(globalConfigDir(), 'config.toml');
|
|
@@ -136,6 +139,10 @@ export async function readConfig() {
|
|
|
136
139
|
for (const [name, value] of Object.entries(registered)) {
|
|
137
140
|
merged.envs[name] = value;
|
|
138
141
|
}
|
|
142
|
+
merged.orgs = await readOrgs();
|
|
143
|
+
const repoOrg = await repositoryOrg();
|
|
144
|
+
if (repoOrg)
|
|
145
|
+
merged.repoOrg = repoOrg;
|
|
139
146
|
return merged;
|
|
140
147
|
}
|
|
141
148
|
export async function localAuthRealmOptions(envName) {
|
|
@@ -196,14 +203,18 @@ export function resolveEnv({ config, requested, }) {
|
|
|
196
203
|
const { slug, url } = resolvePreviewFromSlug(name.slice(PREVIEW_ENV_PREFIX.length));
|
|
197
204
|
return { name: `${PREVIEW_ENV_PREFIX}${slug}`, url };
|
|
198
205
|
}
|
|
206
|
+
const staged = resolveStagedEnv({ config, name });
|
|
207
|
+
if (staged)
|
|
208
|
+
return staged;
|
|
199
209
|
const env = config.envs[name];
|
|
200
210
|
if (!env) {
|
|
201
211
|
const known = Object.keys(config.envs).join(', ');
|
|
202
212
|
const addHint = isSequenceAuthEnvName(name) && !isSharedLoginDeploymentName(name)
|
|
203
213
|
? `add an [env.${name}] entry to ${configPath()}`
|
|
204
214
|
: `register the deployment with: seq-studio envs add ${name} <url>`;
|
|
215
|
+
const orgHint = isStage(name) ? ` For an org's ${name}, use -e <org>/${name} (known orgs: ${knownOrgs(config)}).` : '';
|
|
205
216
|
throw new Error(`Unknown env "${name}". Known envs: ${known}. ` +
|
|
206
|
-
`Pass --env <name>, set default_env in ${configPath()}, or ${addHint}`);
|
|
217
|
+
`Pass --env <name>, set default_env in ${configPath()}, or ${addHint}.${orgHint}`);
|
|
207
218
|
}
|
|
208
219
|
return { name, url: env.url };
|
|
209
220
|
}
|
|
@@ -227,7 +238,8 @@ export async function addSharedLoginEnvironment({ name, baseUrl: rawBaseUrl, fet
|
|
|
227
238
|
throw new Error(`'${name}' is reserved for a deployment on the shared Sequence login, and ${baseUrl} uses its own ` +
|
|
228
239
|
`login. Register it under another name: seq-studio envs add <name> ${baseUrl}`);
|
|
229
240
|
}
|
|
230
|
-
|
|
241
|
+
const added = await appendEnvTable({ name, baseUrl });
|
|
242
|
+
return login.cliOrg ? { ...added, cliOrg: login.cliOrg } : added;
|
|
231
243
|
}
|
|
232
244
|
/**
|
|
233
245
|
* Save `local:<name>` for an Atlas on a loopback port that is not a
|
package/dist/docs/commands.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `seq-studio docs`: read the target environment's published developer docs from the terminal, so an agent in any
|
|
3
3
|
* checkout (cloned, created or scaffolded) reaches the docs that match the deployment it builds against, through the
|
|
4
|
-
* same origin, edge credentials and login the rest of the CLI uses. The docs
|
|
5
|
-
*
|
|
4
|
+
* same origin, edge credentials and login the rest of the CLI uses. The docs are for signed-in users: the login is
|
|
5
|
+
* sent whenever one is cached or injected. Without one the request goes out anonymously, which an Atlas that still
|
|
6
|
+
* serves public docs answers and a current one refuses with 401, reported as a sign-in step.
|
|
6
7
|
*/
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
import { AtlasApiError, getJson } from '../atlas-client.js';
|
|
@@ -10,6 +11,7 @@ import { fetchWithCliAttribution } from '../cli-attribution.js';
|
|
|
10
11
|
import { resolveConfiguredEnv } from '../config.js';
|
|
11
12
|
import { edgeAuthHeaders } from '../edge-auth-headers.js';
|
|
12
13
|
import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
|
|
14
|
+
import { ExitCode } from '../exit-codes.js';
|
|
13
15
|
import { requestedEnvironment } from '../functions/commands.js';
|
|
14
16
|
import { DOCS_HELP } from './help.js';
|
|
15
17
|
const SUBCOMMANDS = new Set(['search', 'read', 'list']);
|
|
@@ -29,7 +31,7 @@ const listResponseSchema = z.object({
|
|
|
29
31
|
}).loose();
|
|
30
32
|
class DocsUsageError extends Error {
|
|
31
33
|
}
|
|
32
|
-
/** Send the login when one is cached or injected; never start a browser login just to read
|
|
34
|
+
/** Send the login when one is cached or injected; never start a browser login just to read docs. */
|
|
33
35
|
async function docsRequester(env) {
|
|
34
36
|
const { getAccessTokenWithMode } = await import('../auth.js');
|
|
35
37
|
const token = await getAccessTokenWithMode({ env: env.name, targetUrl: env.url, allowInteractiveLogin: false })
|
|
@@ -127,7 +129,7 @@ export async function runDocsCommand(sub, args, client) {
|
|
|
127
129
|
console.error(docsErrorMessage({ error, sub }));
|
|
128
130
|
if (error instanceof DocsUsageError)
|
|
129
131
|
console.error(DOCS_HELP);
|
|
130
|
-
return 1;
|
|
132
|
+
return error instanceof AtlasApiError && error.status === 401 ? ExitCode.Auth : 1;
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
function docsPath({ sub, args }) {
|
|
@@ -156,6 +158,9 @@ function docsPath({ sub, args }) {
|
|
|
156
158
|
function docsErrorMessage({ error, sub }) {
|
|
157
159
|
if (error instanceof DocsUsageError)
|
|
158
160
|
return error.message;
|
|
161
|
+
if (error instanceof AtlasApiError && error.status === 401) {
|
|
162
|
+
return 'The Sequence docs are for signed-in users. Sign in with seq-studio login -e <env>, then run this again.';
|
|
163
|
+
}
|
|
159
164
|
if (error instanceof AtlasApiError && error.status === 404) {
|
|
160
165
|
return sub === 'read'
|
|
161
166
|
? 'Documentation page not found. Find a published slug with seq-studio docs search <query> or seq-studio docs list.'
|
package/dist/env-registry.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CliOrg } from './orgs.js';
|
|
1
2
|
interface DiscoveredRealm {
|
|
2
3
|
domain: string;
|
|
3
4
|
clientId: string;
|
|
@@ -8,12 +9,15 @@ interface DiscoveredRealm {
|
|
|
8
9
|
/** A deployment's public CLI login, and the CLI environment name it advertises for itself. */
|
|
9
10
|
interface DeploymentLogin extends DiscoveredRealm {
|
|
10
11
|
cliEnvironment?: string;
|
|
12
|
+
/** The deployment's org and stage, when it advertises them. */
|
|
13
|
+
cliOrg?: CliOrg;
|
|
11
14
|
}
|
|
12
15
|
interface RegistrationResult {
|
|
13
16
|
name: string;
|
|
14
17
|
baseUrl: string;
|
|
15
18
|
replacing: boolean;
|
|
16
19
|
realm: DiscoveredRealm;
|
|
20
|
+
cliOrg?: CliOrg;
|
|
17
21
|
}
|
|
18
22
|
export declare function seqapiConfigPath(): string;
|
|
19
23
|
/**
|
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
|
|
@@ -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;
|
|
@@ -667,7 +667,7 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
667
667
|
for (const envName of Object.values(binding.entries)) {
|
|
668
668
|
if (!envValues[envName])
|
|
669
669
|
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
|
|
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 secret set --from-json`);
|
|
671
671
|
return 1;
|
|
672
672
|
}
|
|
673
673
|
}
|
|
@@ -686,7 +686,7 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
686
686
|
if (secret)
|
|
687
687
|
serverInfoByName.set(envName, { id: secret.id, hasDefaultValue: secret.hasDefaultValue, attachmentCount: secret.attachmentCount });
|
|
688
688
|
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
|
|
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 secret set --from-json`);
|
|
690
690
|
return 1;
|
|
691
691
|
}
|
|
692
692
|
}
|
|
@@ -703,7 +703,7 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
703
703
|
if (classification.blocked.length > 0) {
|
|
704
704
|
for (const c of classification.blocked) {
|
|
705
705
|
console.error(`${LOG} secret "${c.name}" is declared but has no value — ` +
|
|
706
|
-
`add it to .env, run \`seq-studio
|
|
706
|
+
`add it to .env, run \`seq-studio secret set ${c.name} -e ${ctx.env.name}\`, or set it in the Sequence app`);
|
|
707
707
|
}
|
|
708
708
|
console.error(`${LOG} resolve the above before deploying`);
|
|
709
709
|
return 1;
|
|
@@ -758,13 +758,13 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
758
758
|
const problems = [];
|
|
759
759
|
if (!existingShell) {
|
|
760
760
|
problems.push(`function "${slug}" is not registered on ${ctx.env.name} — run ` +
|
|
761
|
-
`\`seq-studio
|
|
761
|
+
`\`seq-studio function deploy -e ${ctx.env.name}\` once with your own login (` +
|
|
762
762
|
`\`seq-studio login\`) to register it`);
|
|
763
763
|
}
|
|
764
764
|
for (const c of classification?.secrets ?? []) {
|
|
765
765
|
if (c.category === 'UPLOAD_NEW' || c.category === 'OVERWRITE') {
|
|
766
766
|
problems.push(`secret "${c.name}" would be written from a local value — provision it server-side first: ` +
|
|
767
|
-
`\`seq-studio
|
|
767
|
+
`\`seq-studio secret set ${c.name} -e ${ctx.env.name}\``);
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
770
|
if (problems.length > 0) {
|
|
@@ -835,8 +835,9 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
835
835
|
}
|
|
836
836
|
catch (error) {
|
|
837
837
|
if (error instanceof AtlasApiError && error.status === 409) {
|
|
838
|
-
|
|
839
|
-
|
|
838
|
+
// Only an uncoded 409 is a version race; any other conflict (an immutable release, a local workspace
|
|
839
|
+
// mismatch) says what it is.
|
|
840
|
+
if (typeof error.body === 'object' && error.body !== null && typeof Reflect.get(error.body, 'code') === 'string') {
|
|
840
841
|
console.error(`${LOG} ${error.message}`);
|
|
841
842
|
return 1;
|
|
842
843
|
}
|
|
@@ -850,7 +851,7 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, ori
|
|
|
850
851
|
}
|
|
851
852
|
console.log(`${LOG} version ${version.version} uploaded — building (server-side install + function startup)`);
|
|
852
853
|
if (args.flags['no-wait']) {
|
|
853
|
-
console.log(`${LOG} not waiting (--no-wait). Poll with: seq-studio
|
|
854
|
+
console.log(`${LOG} not waiting (--no-wait). Poll with: seq-studio function list -e ${ctx.env.name}`);
|
|
854
855
|
return 0;
|
|
855
856
|
}
|
|
856
857
|
return pollVersion({
|
|
@@ -1284,7 +1285,7 @@ async function listVersions(ctx, functionId) {
|
|
|
1284
1285
|
export async function functionsPromoteCommand(args) {
|
|
1285
1286
|
const versionName = args.positional[0];
|
|
1286
1287
|
if (!versionName) {
|
|
1287
|
-
console.error('usage: seq-studio
|
|
1288
|
+
console.error('usage: seq-studio function promote <version> -e <env> [--fn slug]');
|
|
1288
1289
|
return 1;
|
|
1289
1290
|
}
|
|
1290
1291
|
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>;
|