@sequenceholdings/studio-cli 0.3.0 → 0.4.1
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 +465 -28
- package/dist/agents/commands.d.ts +1 -1
- package/dist/agents/commands.js +5 -0
- package/dist/agents/scaffold.js +5 -7
- package/dist/agents/voice-authoring.d.ts +5 -0
- package/dist/agents/voice-authoring.js +75 -0
- package/dist/agents/voice-publication.d.ts +5 -0
- package/dist/agents/voice-publication.js +63 -0
- package/dist/agents/voice-shared.d.ts +20 -0
- package/dist/agents/voice-shared.js +112 -0
- package/dist/agents/voice.d.ts +3 -0
- package/dist/agents/voice.js +57 -0
- package/dist/app/adapters.d.ts +6 -0
- package/dist/app/adapters.js +17 -2
- package/dist/app/agent-refs.d.ts +16 -0
- package/dist/app/agent-refs.js +36 -0
- package/dist/app/application-registration.d.ts +31 -5
- package/dist/app/application-registration.js +58 -14
- package/dist/app/commands.js +19 -2
- package/dist/app/deploy.d.ts +3 -0
- package/dist/app/deploy.js +18 -4
- package/dist/app/env-bindings.d.ts +21 -0
- package/dist/app/env-bindings.js +184 -0
- package/dist/app/manifest-validation.js +8 -0
- package/dist/app/manifest.d.ts +13 -9
- package/dist/app/manifest.js +1 -1
- package/dist/app/primitive-scaffold.d.ts +4 -1
- package/dist/app/primitive-scaffold.js +4 -4
- package/dist/app/readme.js +1 -0
- package/dist/app/scaffold-files.js +1 -1
- package/dist/app/scaffold.d.ts +6 -4
- package/dist/app/scaffold.js +7 -4
- package/dist/app/workspace-scaffold.js +12 -7
- package/dist/argv.d.ts +7 -0
- package/dist/argv.js +56 -0
- package/dist/artifact/delegate.js +8 -4
- package/dist/atlas-client.d.ts +6 -0
- package/dist/atlas-client.js +39 -2
- package/dist/auth.d.ts +32 -0
- package/dist/auth.js +170 -33
- package/dist/bin.js +23 -4
- package/dist/command-contract.d.ts +137 -0
- package/dist/command-contract.js +43 -0
- package/dist/command-help.d.ts +8 -0
- package/dist/command-help.js +71 -0
- package/dist/functions/commands.d.ts +1 -1
- package/dist/functions/commands.js +19 -3
- package/dist/functions/deploy-preflight.d.ts +21 -0
- package/dist/functions/deploy-preflight.js +58 -0
- package/dist/functions/egress-postgres.d.ts +7 -0
- package/dist/functions/egress-postgres.js +36 -0
- package/dist/functions/manifest.d.ts +8 -0
- package/dist/functions/manifest.js +9 -0
- package/dist/functions/source-selection.js +4 -1
- package/dist/main.js +58 -20
- package/dist/orm/delegate.d.ts +16 -0
- package/dist/orm/delegate.js +140 -7
- package/dist/pipeline/clone-deploy.d.ts +37 -0
- package/dist/pipeline/clone-deploy.js +125 -0
- package/dist/pipeline/codegen.js +6 -2
- package/dist/pipeline/commands.js +21 -5
- package/dist/pipeline/lifecycle.d.ts +1 -0
- package/dist/pipeline/lifecycle.js +95 -44
- package/dist/pipeline/repin-orm.js +6 -2
- package/dist/pipeline/stage-secrets.js +1 -1
- package/dist/process/build.js +17 -0
- package/dist/process/codegen.js +16 -0
- package/dist/process/commands.d.ts +15 -7
- package/dist/process/commands.js +291 -99
- package/dist/process/lint.js +35 -0
- package/dist/process/plan-diff.js +9 -0
- package/dist/process/simulate.js +8 -0
- package/dist/release-age.d.ts +12 -0
- package/dist/release-age.js +24 -0
- package/dist/repos/commands.d.ts +1 -1
- package/dist/repos/commands.js +36 -7
- package/dist/scaffold-guidance.d.ts +4 -0
- package/dist/scaffold-guidance.js +15 -0
- package/dist/storage/commands.js +23 -1
- package/dist/storage/gcs-download.d.ts +13 -0
- package/dist/storage/gcs-download.js +41 -0
- package/dist/storage/import-cycle.d.ts +41 -0
- package/dist/storage/import-cycle.js +123 -0
- package/dist/storage/import-files.d.ts +30 -0
- package/dist/storage/import-files.js +133 -0
- package/dist/storage/import-gcloud.d.ts +12 -0
- package/dist/storage/import-gcloud.js +54 -0
- package/dist/storage/import-identity.d.ts +12 -0
- package/dist/storage/import-identity.js +15 -0
- package/dist/storage/import-plan.d.ts +120 -0
- package/dist/storage/import-plan.js +189 -0
- package/dist/storage/import-preflight.d.ts +36 -0
- package/dist/storage/import-preflight.js +62 -0
- package/dist/storage/import-progress-map.d.ts +5 -0
- package/dist/storage/import-progress-map.js +22 -0
- package/dist/storage/import-recover.d.ts +97 -0
- package/dist/storage/import-recover.js +186 -0
- package/dist/storage/import-run.d.ts +14 -0
- package/dist/storage/import-run.js +140 -0
- package/dist/templates/guidance/AGENTS.md +10 -0
- package/dist/templates/guidance/CLAUDE.md +1 -0
- package/dist/templates/process/package.json +2 -2
- package/dist/templates/process/pnpm-workspace.yaml +7 -4
- package/dist/validation-detail.d.ts +2 -0
- package/dist/validation-detail.js +20 -0
- package/package.json +9 -9
- package/templates/guidance/AGENTS.md +10 -0
- package/templates/guidance/CLAUDE.md +1 -0
- package/templates/process/package.json +2 -2
- package/templates/process/pnpm-workspace.yaml +7 -4
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publish a local pipeline checkout into an environment's git service, then
|
|
3
|
+
* let the ordinary deploy read that commit back. The plan/deploy worker
|
|
4
|
+
* materializes source from the target environment's git service, so a laptop
|
|
5
|
+
* directory cannot be the deploy source by itself.
|
|
6
|
+
*
|
|
7
|
+
* Clone publish is limited to targets that do not require approval. BankSouth
|
|
8
|
+
* and production keep deploying commits that already live in that
|
|
9
|
+
* environment's git service.
|
|
10
|
+
*/
|
|
11
|
+
import { spawn } from 'node:child_process';
|
|
12
|
+
import { execFile } from 'node:child_process';
|
|
13
|
+
import { promisify } from 'node:util';
|
|
14
|
+
import { postJson } from '../atlas-client.js';
|
|
15
|
+
import { gitServiceCloneUrl, resolveGitPatFromEnv, withGitAskpass, } from '@sequenceholdings/artifact-studio/git-clone';
|
|
16
|
+
import { resolveRepo } from '@sequenceholdings/artifact-studio/git-service-client';
|
|
17
|
+
const execFileAsync = promisify(execFile);
|
|
18
|
+
export function assertCloneDeployAllowed(target) {
|
|
19
|
+
if (!target.requiresApproval)
|
|
20
|
+
return;
|
|
21
|
+
throw new Error(`pipeline deploy from a local clone is only supported on targets that do not require approval (got '${target.id}'). ` +
|
|
22
|
+
'Push the commit to that environment\'s git service, then deploy with --repo and --ref.');
|
|
23
|
+
}
|
|
24
|
+
const RELEASE_REPO = /^(pipelines|apps)\/([a-z][a-z0-9-]*)$/;
|
|
25
|
+
export function parseCloneDeployRepo(repo) {
|
|
26
|
+
const match = RELEASE_REPO.exec(repo);
|
|
27
|
+
if (!match) {
|
|
28
|
+
throw new Error(`--repo must be pipelines/<name> or apps/<name> (got '${repo}')`);
|
|
29
|
+
}
|
|
30
|
+
return { namespace: match[1], name: match[2] };
|
|
31
|
+
}
|
|
32
|
+
export async function readCloneHead(dir) {
|
|
33
|
+
const branch = (await gitOutput(dir, ['rev-parse', '--abbrev-ref', 'HEAD'])).trim();
|
|
34
|
+
if (!branch || branch === 'HEAD') {
|
|
35
|
+
throw new Error(`check out a branch in ${dir} before deploying it`);
|
|
36
|
+
}
|
|
37
|
+
if (!/^[A-Za-z0-9._/-]+$/.test(branch) || branch.includes('..') || branch.startsWith('/') || branch.endsWith('/')) {
|
|
38
|
+
throw new Error(`refusing to publish branch '${branch}'`);
|
|
39
|
+
}
|
|
40
|
+
const sha = (await gitOutput(dir, ['rev-parse', 'HEAD'])).trim().toLowerCase();
|
|
41
|
+
if (!/^[0-9a-f]{40}$/.test(sha)) {
|
|
42
|
+
throw new Error(`${dir} HEAD is not a commit (${sha || 'empty'})`);
|
|
43
|
+
}
|
|
44
|
+
const dirty = await gitOutput(dir, ['status', '--porcelain']);
|
|
45
|
+
if (dirty.trim()) {
|
|
46
|
+
throw new Error('clone deploy requires a clean worktree. Commit or stash local changes, then retry.');
|
|
47
|
+
}
|
|
48
|
+
return { sha, branch };
|
|
49
|
+
}
|
|
50
|
+
async function gitOutput(dir, args) {
|
|
51
|
+
try {
|
|
52
|
+
const { stdout } = await execFileAsync('git', args, { cwd: dir });
|
|
53
|
+
return stdout;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
57
|
+
throw new Error(`git ${args.join(' ')} failed in ${dir}: ${detail}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function pushCloneHead({ dir, cloneUrl, sha, branch, pat, }) {
|
|
61
|
+
await withGitAskpass({
|
|
62
|
+
pat,
|
|
63
|
+
fn: (env) => spawnGit({
|
|
64
|
+
args: ['push', cloneUrl, `${sha}:refs/heads/${branch}`],
|
|
65
|
+
cwd: dir,
|
|
66
|
+
env,
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function spawnGit({ args, cwd, env, }) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
const child = spawn('git', args, { cwd, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
73
|
+
let stderr = '';
|
|
74
|
+
child.stderr?.on('data', (chunk) => {
|
|
75
|
+
stderr += chunk.toString();
|
|
76
|
+
});
|
|
77
|
+
child.on('error', reject);
|
|
78
|
+
child.on('close', (code) => {
|
|
79
|
+
if (code === 0) {
|
|
80
|
+
resolve();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
reject(new Error(`git push failed (exit ${code ?? 'null'}): ${stderr.trim() || 'no stderr'}`));
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Ensure `<repo>` exists on the target environment and contains this
|
|
89
|
+
* checkout's HEAD. Returns the SHA the caller should pass as `--ref`.
|
|
90
|
+
*/
|
|
91
|
+
export async function publishCloneForDeploy({ dir, repo, baseUrl, token, pat = resolveGitPatFromEnv(), }) {
|
|
92
|
+
if (!pat) {
|
|
93
|
+
throw new Error('Deploying a local clone requires a git PAT. Set ATLAS_GIT_PAT to a token with repo:write ' +
|
|
94
|
+
'(create one in Atlas → Settings → Tokens, or `seq-studio auth pat create`).');
|
|
95
|
+
}
|
|
96
|
+
const { namespace, name } = parseCloneDeployRepo(repo);
|
|
97
|
+
const head = await readCloneHead(dir);
|
|
98
|
+
const destination = await ensureReleaseRepo({ baseUrl, token, namespace, name });
|
|
99
|
+
const cloneUrl = gitServiceCloneUrl(baseUrl, destination.id);
|
|
100
|
+
await pushCloneHead({ dir, cloneUrl, sha: head.sha, branch: head.branch, pat });
|
|
101
|
+
// A new walgit repo's default branch is main, but the ref does not exist until
|
|
102
|
+
// something is pushed to it. Publishing only the checkout branch leaves
|
|
103
|
+
// `repos clone` (no --ref) unable to resolve main.
|
|
104
|
+
if (destination.created && head.branch !== 'main') {
|
|
105
|
+
await pushCloneHead({ dir, cloneUrl, sha: head.sha, branch: 'main', pat });
|
|
106
|
+
}
|
|
107
|
+
return { ...head, repoId: destination.id, created: destination.created };
|
|
108
|
+
}
|
|
109
|
+
async function ensureReleaseRepo({ baseUrl, token, namespace, name, }) {
|
|
110
|
+
try {
|
|
111
|
+
const existing = await resolveRepo({ baseUrl, token, namespace, name });
|
|
112
|
+
return { id: existing.id, created: false };
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!(error instanceof Error) || !error.message.startsWith('Repo "'))
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
const created = await postJson({
|
|
119
|
+
baseUrl,
|
|
120
|
+
token,
|
|
121
|
+
path: '/api/git-service/repos',
|
|
122
|
+
body: { namespaceSlug: namespace, name, gitBackend: 'walgit' },
|
|
123
|
+
});
|
|
124
|
+
return { id: created.id, created: true };
|
|
125
|
+
}
|
package/dist/pipeline/codegen.js
CHANGED
|
@@ -55,7 +55,11 @@ export async function pipelineCodegenTablesCommand(args) {
|
|
|
55
55
|
const from = typeof args.flags.from === 'string'
|
|
56
56
|
? args.flags.from
|
|
57
57
|
: join(process.cwd(), 'authoring.tables.ts');
|
|
58
|
-
const
|
|
58
|
+
const pipelineRoot = resolve(typeof args.flags.dir === 'string' ? args.flags.dir : '.');
|
|
59
|
+
const config = await spec.loadPipelineConfig({ dir: pipelineRoot, allowMissingRoot: true });
|
|
60
|
+
const stageDirectory = config.stage_directories[0] ?? '.';
|
|
61
|
+
const dir = resolve(pipelineRoot, stageDirectory);
|
|
62
|
+
await spec.assertStageDirectoryContained({ root: pipelineRoot, directory: stageDirectory });
|
|
59
63
|
const dryRun = args.flags['dry-run'] === true;
|
|
60
64
|
let authoring;
|
|
61
65
|
try {
|
|
@@ -113,6 +117,6 @@ export async function pipelineCodegenTablesCommand(args) {
|
|
|
113
117
|
await writeFile(target, file.yaml, 'utf8');
|
|
114
118
|
console.log(`${LOG} wrote ${target}`);
|
|
115
119
|
}
|
|
116
|
-
console.log(`${LOG} next: seq-studio pipeline validate ${
|
|
120
|
+
console.log(`${LOG} next: seq-studio pipeline validate ${pipelineRoot === process.cwd() ? '.' : pipelineRoot}`);
|
|
117
121
|
return 0;
|
|
118
122
|
}
|
|
@@ -17,6 +17,7 @@ import { join, resolve } from 'node:path';
|
|
|
17
17
|
import { authenticatedRequestUrl, validateDeploymentBaseUrl, } from '@sequenceholdings/artifact-studio/deployment-validation';
|
|
18
18
|
import { tryGetAccessToken } from '../auth.js';
|
|
19
19
|
import { readConfig } from '../config.js';
|
|
20
|
+
import { writeScaffoldGuidance } from '../scaffold-guidance.js';
|
|
20
21
|
import { PIPELINE_DISCOVERY_USAGE, runPipelineDiscoveryCommand } from './discovery.js';
|
|
21
22
|
import { renderEntrypointStub, renderStageTemplate, STAGE_TYPES, } from './templates.js';
|
|
22
23
|
const LOG = '[seq-studio]';
|
|
@@ -25,7 +26,8 @@ export const ORM_CONTRACTS_FILENAME = 'orm-contracts.json';
|
|
|
25
26
|
const PIPELINE_USAGE = `usage:
|
|
26
27
|
${PIPELINE_DISCOVERY_USAGE}
|
|
27
28
|
seq-studio pipeline init --type ingestion|transformation|serving <name> [--dir <dir>]
|
|
28
|
-
scaffold <name>.stage.yml
|
|
29
|
+
scaffold <name>.stage.yml in the first configured stage directory (or
|
|
30
|
+
package root without config) + package-root-relative src/ entrypoint stub
|
|
29
31
|
|
|
30
32
|
seq-studio pipeline validate [dir] [--assets <file|url>] [--orm-contracts <file|url>] [--json]
|
|
31
33
|
run the offline spec gate: envelope + body validation, schema_ref
|
|
@@ -55,11 +57,20 @@ ${PIPELINE_DISCOVERY_USAGE}
|
|
|
55
57
|
skips this
|
|
56
58
|
--migration adds a coordinated writer/ORM assessment; it cannot be
|
|
57
59
|
applied through ordinary deploy
|
|
60
|
+
seq-studio pipeline plan --plan-request-id <id> -e <env> [--json]
|
|
61
|
+
read and poll an existing plan without enqueueing a new one or attaching
|
|
62
|
+
credentials. Use the request id printed when planning started.
|
|
63
|
+
JSON results use stdout; enqueue/polling progress uses stderr.
|
|
58
64
|
|
|
59
65
|
seq-studio pipeline deploy --repo <namespace>/<slug> --ref <sha|branch> -e <env>
|
|
60
66
|
[--target <id>] [--approved-by <sub>]
|
|
61
67
|
[--allow-destructive <resource-key> ...]
|
|
62
68
|
[--run-now] [--wait-timeout <duration>] [--no-wait] [--no-provision] [--json]
|
|
69
|
+
seq-studio pipeline deploy --dir <checkout> --repo <namespace>/<slug> -e <env>
|
|
70
|
+
publish a clean local checkout into that environment's git service, then
|
|
71
|
+
deploy the published commit. Only targets that do not require approval
|
|
72
|
+
(dev, staging). BankSouth and production still deploy a commit that
|
|
73
|
+
already exists in that environment's git service. Requires ATLAS_GIT_PAT.
|
|
63
74
|
plan (attaching missing credentials as for plan) then enqueue Trigger deploy (DAB bundle validate hard-gates before
|
|
64
75
|
bundle deploy). Default is plant-only: jobs/pipelines are created, not
|
|
65
76
|
run. Pass --run-now to run in-unit producer roots after bundle deploy.
|
|
@@ -79,12 +90,12 @@ ${PIPELINE_DISCOVERY_USAGE}
|
|
|
79
90
|
|
|
80
91
|
seq-studio pipeline promote --stage <slug> --version <v> -e <env>
|
|
81
92
|
[--target <id>] [--repo <namespace>/<slug>] [--approved-by <you>]
|
|
82
|
-
[--wait-timeout <duration>] [--no-wait]
|
|
93
|
+
[--wait-timeout <duration>] [--no-wait] [--json]
|
|
83
94
|
promote a validated version to the next environment (approvals are
|
|
84
95
|
self-recorded: --approved-by must name the authenticated caller)
|
|
85
96
|
|
|
86
97
|
seq-studio pipeline rollback --stage <slug> -e <env> [--target <id>] [--repo <namespace>/<slug>]
|
|
87
|
-
[--approved-by <you>] [--wait-timeout <duration>] [--no-wait]
|
|
98
|
+
[--approved-by <you>] [--wait-timeout <duration>] [--no-wait] [--json]
|
|
88
99
|
redeploy the previously retired deployment's version (production/
|
|
89
100
|
banksouth require --approved-by — approvals are explicit even for
|
|
90
101
|
rollbacks)
|
|
@@ -168,12 +179,16 @@ export async function pipelineInitCommand(args) {
|
|
|
168
179
|
return 1;
|
|
169
180
|
}
|
|
170
181
|
const dir = resolve(typeof args.flags.dir === 'string' ? args.flags.dir : '.');
|
|
171
|
-
const
|
|
182
|
+
const config = await spec.loadPipelineConfig({ dir, allowMissingRoot: true });
|
|
183
|
+
const stageDirectory = config.stage_directories[0] ?? '.';
|
|
184
|
+
const stageRoot = resolve(dir, stageDirectory);
|
|
185
|
+
await spec.assertStageDirectoryContained({ root: dir, directory: stageDirectory });
|
|
186
|
+
const specPath = join(stageRoot, `${name}.stage.yml`);
|
|
172
187
|
if (existsSync(specPath)) {
|
|
173
188
|
console.error(`${LOG} ${specPath} already exists — refusing to overwrite`);
|
|
174
189
|
return 1;
|
|
175
190
|
}
|
|
176
|
-
await mkdir(
|
|
191
|
+
await mkdir(stageRoot, { recursive: true });
|
|
177
192
|
await writeFile(specPath, renderStageTemplate(name, type), 'utf8');
|
|
178
193
|
console.log(`${LOG} wrote ${specPath}`);
|
|
179
194
|
// Serving stages are declarative — no entrypoint stub. The template's
|
|
@@ -189,6 +204,7 @@ export async function pipelineInitCommand(args) {
|
|
|
189
204
|
console.log(`${LOG} wrote ${stubPath}`);
|
|
190
205
|
}
|
|
191
206
|
}
|
|
207
|
+
await writeScaffoldGuidance({ directory: dir });
|
|
192
208
|
const displayDir = typeof args.flags.dir === 'string' ? args.flags.dir : '.';
|
|
193
209
|
if (type === 'serving') {
|
|
194
210
|
// A serving stage inherently references its producer — the scaffold's
|
|
@@ -6,6 +6,7 @@ import { type ResolvedEnv } from '../config.js';
|
|
|
6
6
|
import type { ParsedArgs } from '../process/commands.js';
|
|
7
7
|
export declare const DEFAULT_DEPLOYMENT_WAIT_TIMEOUT_MS: number;
|
|
8
8
|
export interface PlanApiResponse {
|
|
9
|
+
planRequestId?: string;
|
|
9
10
|
plan: {
|
|
10
11
|
hasDestructive: boolean;
|
|
11
12
|
findings: Array<{
|
|
@@ -6,6 +6,7 @@ import { getAccessToken, NotLoggedInError } from '../auth.js';
|
|
|
6
6
|
import { AtlasApiError, getJson, postJson } from '../atlas-client.js';
|
|
7
7
|
import { resolveEnvWithDiscovery } from '../config.js';
|
|
8
8
|
import { parseDurationMs } from '@sequenceholdings/lattice';
|
|
9
|
+
import { assertCloneDeployAllowed, publishCloneForDeploy } from './clone-deploy.js';
|
|
9
10
|
import { printReconcileResult, reconcileStageCredentials } from './stage-secrets.js';
|
|
10
11
|
const LOG = '[seq-studio]';
|
|
11
12
|
function rootOption(root) {
|
|
@@ -58,7 +59,7 @@ export async function envAndToken(args) {
|
|
|
58
59
|
const env = await resolveEnvWithDiscovery({ requested });
|
|
59
60
|
let token;
|
|
60
61
|
try {
|
|
61
|
-
token = await getAccessToken();
|
|
62
|
+
token = await getAccessToken({ env: env.name, targetUrl: env.url });
|
|
62
63
|
}
|
|
63
64
|
catch (error) {
|
|
64
65
|
if (error instanceof NotLoggedInError)
|
|
@@ -122,6 +123,7 @@ export async function resolvePipelineTarget({ args, env, token, }) {
|
|
|
122
123
|
export async function pipelinePlanCommand(args) {
|
|
123
124
|
const repo = flagString(args.flags, 'repo');
|
|
124
125
|
const ref = flagString(args.flags, 'ref');
|
|
126
|
+
const planRequestId = flagString(args.flags, 'plan-request-id');
|
|
125
127
|
const root = flagString(args.flags, 'root');
|
|
126
128
|
const migrationId = flagString(args.flags, 'migration');
|
|
127
129
|
const inPlace = flagOn(args.flags, 'in-place');
|
|
@@ -129,35 +131,39 @@ export async function pipelinePlanCommand(args) {
|
|
|
129
131
|
console.error(`${LOG} --in-place requires --migration; choose the mode when planning`);
|
|
130
132
|
return 1;
|
|
131
133
|
}
|
|
132
|
-
if (
|
|
133
|
-
console.error(
|
|
134
|
+
if (planRequestId && ['repo', 'ref', 'root', 'target', 'migration', 'in-place', 'no-provision'].some((flag) => args.flags[flag] !== undefined)) {
|
|
135
|
+
console.error(`${LOG} --plan-request-id reads an existing plan; do not combine it with planning options`);
|
|
134
136
|
return 1;
|
|
135
137
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let target;
|
|
139
|
-
try {
|
|
140
|
-
target = await resolvePipelineTarget({ args, env, token });
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
console.error(`${LOG} plan failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
138
|
+
if (!planRequestId && (!repo || !ref)) {
|
|
139
|
+
console.error('usage: seq-studio pipeline plan --repo <namespace>/<slug> --ref <sha|branch> [--root <directory>] -e <env> [--migration <id> [--in-place]] [--json]\n seq-studio pipeline plan --plan-request-id <id> -e <env> [--json]');
|
|
144
140
|
return 1;
|
|
145
141
|
}
|
|
142
|
+
const { env, token } = await envAndToken(args);
|
|
143
|
+
const json = args.flags.json === true || args.flags.json === 'true';
|
|
146
144
|
let response;
|
|
147
145
|
try {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
baseUrl: env.url,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
146
|
+
if (planRequestId) {
|
|
147
|
+
response = completedPlanResponse(await waitForPlanRequest({
|
|
148
|
+
baseUrl: env.url, token, planRequestId,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// Required source arguments were checked before authentication.
|
|
153
|
+
if (!repo || !ref)
|
|
154
|
+
return 1;
|
|
155
|
+
const target = await resolvePipelineTarget({ args, env, token });
|
|
156
|
+
response = await planAttachingCredentials({
|
|
157
|
+
request: {
|
|
158
|
+
baseUrl: env.url, token, repo, ref,
|
|
159
|
+
...rootOption(root),
|
|
160
|
+
environment: target.id,
|
|
161
|
+
...(migrationId ? { migrationId } : {}),
|
|
162
|
+
...(inPlace ? { executionMode: 'in_place' } : {}),
|
|
163
|
+
},
|
|
164
|
+
provision: !flagOn(args.flags, 'no-provision'),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
161
167
|
}
|
|
162
168
|
catch (error) {
|
|
163
169
|
console.error(`${LOG} plan failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -170,6 +176,9 @@ export async function pipelinePlanCommand(args) {
|
|
|
170
176
|
console.log(response.text);
|
|
171
177
|
printFindingsTable(response.plan.findings);
|
|
172
178
|
}
|
|
179
|
+
return planResultExitCode({ response, inPlace, migrationId });
|
|
180
|
+
}
|
|
181
|
+
function planResultExitCode({ response, inPlace, migrationId, }) {
|
|
173
182
|
if (inPlace && response.plan.migrationExecutionMode !== 'in_place') {
|
|
174
183
|
console.error(`${LOG} server did not confirm in-place mode; do not start this plan`);
|
|
175
184
|
return 1;
|
|
@@ -185,6 +194,7 @@ export async function pipelineDeployCommand(args) {
|
|
|
185
194
|
}
|
|
186
195
|
const repo = flagString(args.flags, 'repo');
|
|
187
196
|
const ref = flagString(args.flags, 'ref');
|
|
197
|
+
const dir = flagString(args.flags, 'dir');
|
|
188
198
|
const root = flagString(args.flags, 'root');
|
|
189
199
|
const deploymentId = flagString(args.flags, 'deployment-id');
|
|
190
200
|
const approvedBy = flagString(args.flags, 'approved-by');
|
|
@@ -225,13 +235,36 @@ export async function pipelineDeployCommand(args) {
|
|
|
225
235
|
});
|
|
226
236
|
}
|
|
227
237
|
else {
|
|
228
|
-
if (
|
|
229
|
-
console.error(
|
|
238
|
+
if (dir && ref) {
|
|
239
|
+
console.error(`${LOG} pass either --dir or --ref, not both`);
|
|
240
|
+
return 1;
|
|
241
|
+
}
|
|
242
|
+
let sourceRef = ref;
|
|
243
|
+
if (dir) {
|
|
244
|
+
if (!repo) {
|
|
245
|
+
console.error('usage: seq-studio pipeline deploy --dir <checkout> --repo <namespace>/<slug> -e <env>');
|
|
246
|
+
return 1;
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
assertCloneDeployAllowed(target);
|
|
250
|
+
const published = await publishCloneForDeploy({ dir, repo, baseUrl: env.url, token });
|
|
251
|
+
sourceRef = published.sha;
|
|
252
|
+
console.error(`${LOG} published ${repo}@${published.sha.slice(0, 12)} ` +
|
|
253
|
+
`(${published.branch}${published.created ? ', created repo' : ''}) on ${env.name}`);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
console.error(`${LOG} deploy failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
257
|
+
return 1;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (!repo || !sourceRef) {
|
|
261
|
+
console.error('usage: seq-studio pipeline deploy --repo <namespace>/<slug> --ref <sha|branch> [--root <directory>] -e <env> [--target <id>] [--approved-by <sub>] [--allow-destructive <resource-key> ...] [--run-now] [--wait-timeout <duration>] [--no-wait]\n' +
|
|
262
|
+
' seq-studio pipeline deploy --dir <checkout> --repo <namespace>/<slug> -e <env>');
|
|
230
263
|
return 1;
|
|
231
264
|
}
|
|
232
265
|
// Plan then deploy the first planning deployment.
|
|
233
266
|
const plan = await planAttachingCredentials({
|
|
234
|
-
request: { baseUrl: env.url, token, repo, ref, environment: target.id, ...rootOption(root) },
|
|
267
|
+
request: { baseUrl: env.url, token, repo, ref: sourceRef, environment: target.id, ...rootOption(root) },
|
|
235
268
|
provision: !flagOn(args.flags, 'no-provision'),
|
|
236
269
|
});
|
|
237
270
|
if (plan.plan.hasDestructive && allowDestructiveResourceKeys.length === 0) {
|
|
@@ -273,8 +306,10 @@ export async function pipelineDeployCommand(args) {
|
|
|
273
306
|
}
|
|
274
307
|
throw error;
|
|
275
308
|
}
|
|
276
|
-
console.
|
|
277
|
-
if (args.flags
|
|
309
|
+
console.error(`${LOG} enqueued deploy ${enqueue.deploymentId} (trigger=${enqueue.triggerRunId ?? 'n/a'})`);
|
|
310
|
+
if (flagOn(args.flags, 'no-wait')) {
|
|
311
|
+
if (flagOn(args.flags, 'json'))
|
|
312
|
+
console.log(JSON.stringify(enqueue, null, 2));
|
|
278
313
|
return 0;
|
|
279
314
|
}
|
|
280
315
|
return pollDeployment({
|
|
@@ -283,6 +318,7 @@ export async function pipelineDeployCommand(args) {
|
|
|
283
318
|
deploymentId: enqueue.deploymentId,
|
|
284
319
|
environment: env.name,
|
|
285
320
|
timeoutMs: waitTimeoutMs,
|
|
321
|
+
json: flagOn(args.flags, 'json'),
|
|
286
322
|
});
|
|
287
323
|
}
|
|
288
324
|
export async function pipelineStatusCommand(args) {
|
|
@@ -359,9 +395,12 @@ export async function pipelinePromoteCommand(args) {
|
|
|
359
395
|
}
|
|
360
396
|
throw error;
|
|
361
397
|
}
|
|
362
|
-
console.
|
|
363
|
-
if (args.flags
|
|
398
|
+
console.error(`${LOG} enqueued promote plan ${enqueue.planRequestId} (trigger=${enqueue.triggerRunId ?? 'n/a'})`);
|
|
399
|
+
if (flagOn(args.flags, 'no-wait')) {
|
|
400
|
+
if (flagOn(args.flags, 'json'))
|
|
401
|
+
console.log(JSON.stringify(enqueue, null, 2));
|
|
364
402
|
return 0;
|
|
403
|
+
}
|
|
365
404
|
const plan = await waitForPlanRequest({
|
|
366
405
|
baseUrl: env.url,
|
|
367
406
|
token,
|
|
@@ -378,6 +417,7 @@ export async function pipelinePromoteCommand(args) {
|
|
|
378
417
|
deploymentId,
|
|
379
418
|
environment: env.name,
|
|
380
419
|
timeoutMs: waitTimeoutMs,
|
|
420
|
+
json: flagOn(args.flags, 'json'),
|
|
381
421
|
});
|
|
382
422
|
}
|
|
383
423
|
export async function pipelineRunNowCommand(args) {
|
|
@@ -473,15 +513,19 @@ export async function pipelineRollbackCommand(args) {
|
|
|
473
513
|
}
|
|
474
514
|
throw error;
|
|
475
515
|
}
|
|
476
|
-
console.
|
|
477
|
-
if (args.flags
|
|
516
|
+
console.error(`${LOG} enqueued rollback ${enqueue.deploymentId}`);
|
|
517
|
+
if (flagOn(args.flags, 'no-wait')) {
|
|
518
|
+
if (flagOn(args.flags, 'json'))
|
|
519
|
+
console.log(JSON.stringify(enqueue, null, 2));
|
|
478
520
|
return 0;
|
|
521
|
+
}
|
|
479
522
|
return pollDeployment({
|
|
480
523
|
baseUrl: env.url,
|
|
481
524
|
token,
|
|
482
525
|
deploymentId: enqueue.deploymentId,
|
|
483
526
|
environment: env.name,
|
|
484
527
|
timeoutMs: waitTimeoutMs,
|
|
528
|
+
json: flagOn(args.flags, 'json'),
|
|
485
529
|
});
|
|
486
530
|
}
|
|
487
531
|
function printFindingsTable(findings) {
|
|
@@ -497,7 +541,7 @@ function printFindingsTable(findings) {
|
|
|
497
541
|
console.log(`${LOG} ${klass.padEnd(12)} ${f.resourceKey.padEnd(32)} ${f.message}`);
|
|
498
542
|
}
|
|
499
543
|
}
|
|
500
|
-
async function pollDeployment({ baseUrl, token, deploymentId, environment, timeoutMs, }) {
|
|
544
|
+
async function pollDeployment({ baseUrl, token, deploymentId, environment, timeoutMs, json, }) {
|
|
501
545
|
const started = Date.now();
|
|
502
546
|
let lastLoggedLabel = null;
|
|
503
547
|
let lastLogAt = started;
|
|
@@ -509,10 +553,12 @@ async function pollDeployment({ baseUrl, token, deploymentId, environment, timeo
|
|
|
509
553
|
});
|
|
510
554
|
const elapsedMs = Date.now() - started;
|
|
511
555
|
if (TERMINAL.has(detail.status)) {
|
|
556
|
+
if (json)
|
|
557
|
+
console.log(JSON.stringify(detail, null, 2));
|
|
512
558
|
const elapsed = formatElapsed(elapsedMs);
|
|
513
559
|
const progressSuffix = deploymentProgressSuffix(detail);
|
|
514
560
|
if (detail.status === 'active') {
|
|
515
|
-
console.
|
|
561
|
+
console.error(`${LOG} deployment ${deploymentId} succeeded (${elapsed})${progressSuffix}`);
|
|
516
562
|
return 0;
|
|
517
563
|
}
|
|
518
564
|
const detailText = detail.statusDetail ? `: ${detail.statusDetail}` : '';
|
|
@@ -522,12 +568,12 @@ async function pollDeployment({ baseUrl, token, deploymentId, environment, timeo
|
|
|
522
568
|
const progressSuffix = deploymentProgressSuffix(detail);
|
|
523
569
|
const statusLabel = deploymentStatusLabel(detail);
|
|
524
570
|
if (statusLabel !== lastLoggedLabel) {
|
|
525
|
-
console.
|
|
571
|
+
console.error(`${LOG} deployment ${deploymentId}: ${statusLabel} (${formatElapsed(elapsedMs)})${progressSuffix}`);
|
|
526
572
|
lastLoggedLabel = statusLabel;
|
|
527
573
|
lastLogAt = Date.now();
|
|
528
574
|
}
|
|
529
575
|
else if (Date.now() - lastLogAt >= HEARTBEAT_INTERVAL_MS) {
|
|
530
|
-
console.
|
|
576
|
+
console.error(`${LOG} deployment ${deploymentId}: still ${statusLabel} (${formatElapsed(elapsedMs)})${progressSuffix}`);
|
|
531
577
|
lastLogAt = Date.now();
|
|
532
578
|
}
|
|
533
579
|
await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
|
|
@@ -556,13 +602,13 @@ async function planAttachingCredentials({ request, provision, }) {
|
|
|
556
602
|
throw error;
|
|
557
603
|
if (!(await attachUnattachedCredentials({ request, stageIds: error.stageIds })))
|
|
558
604
|
throw error;
|
|
559
|
-
console.
|
|
605
|
+
console.error(`${LOG} re-planning with the attached secrets`);
|
|
560
606
|
return enqueueAndWaitForPlan(request);
|
|
561
607
|
}
|
|
562
608
|
// A new stage can also plan the legacy way (a same-named secret exists) with
|
|
563
609
|
// nothing attached, and its get_credential would then fail at runtime.
|
|
564
610
|
if (provision && (await attachUnattachedCredentials({ request, stageIds: response.stageIds }))) {
|
|
565
|
-
console.
|
|
611
|
+
console.error(`${LOG} re-planning with the attached secrets`);
|
|
566
612
|
return enqueueAndWaitForPlan(request);
|
|
567
613
|
}
|
|
568
614
|
return response;
|
|
@@ -615,16 +661,20 @@ async function enqueueAndWaitForPlan({ baseUrl, token, repo, ref, root, environm
|
|
|
615
661
|
path: '/api/data-pipelines/pipelines/plan',
|
|
616
662
|
body: { repo, ref, environment, ...rootOption(root), ...(migrationId ? { migration_id: migrationId } : {}), ...(executionMode ? { execution_mode: executionMode } : {}) },
|
|
617
663
|
});
|
|
618
|
-
console.
|
|
664
|
+
console.error(`${LOG} enqueued plan ${enqueue.planRequestId} (trigger=${enqueue.triggerRunId ?? 'n/a'})`);
|
|
619
665
|
const detail = await waitForPlanRequest({
|
|
620
666
|
baseUrl,
|
|
621
667
|
token,
|
|
622
668
|
planRequestId: enqueue.planRequestId,
|
|
623
669
|
});
|
|
670
|
+
return completedPlanResponse(detail);
|
|
671
|
+
}
|
|
672
|
+
function completedPlanResponse(detail) {
|
|
624
673
|
if (!detail.plan || !detail.text) {
|
|
625
674
|
throw new Error(`plan request ${detail.planRequestId} succeeded without a plan result`);
|
|
626
675
|
}
|
|
627
676
|
return {
|
|
677
|
+
planRequestId: detail.planRequestId,
|
|
628
678
|
plan: detail.plan,
|
|
629
679
|
deploymentIds: detail.deploymentIds,
|
|
630
680
|
stageIds: detail.stageIds,
|
|
@@ -640,7 +690,7 @@ async function waitForPlanRequest({ baseUrl, token, planRequestId, }) {
|
|
|
640
690
|
const detail = await getJson({
|
|
641
691
|
baseUrl,
|
|
642
692
|
token,
|
|
643
|
-
path: `/api/data-pipelines/plan-requests/${planRequestId}`,
|
|
693
|
+
path: `/api/data-pipelines/plan-requests/${encodeURIComponent(planRequestId)}`,
|
|
644
694
|
});
|
|
645
695
|
const elapsed = Date.now() - started;
|
|
646
696
|
const statusLabel = detail.statusDetail
|
|
@@ -653,18 +703,19 @@ async function waitForPlanRequest({ baseUrl, token, planRequestId, }) {
|
|
|
653
703
|
if (detail.status === 'succeeded')
|
|
654
704
|
return detail;
|
|
655
705
|
if (statusLabel !== lastStatus) {
|
|
656
|
-
console.
|
|
706
|
+
console.error(`${LOG} plan ${detail.planRequestId}: ${statusLabel} (${formatElapsed(elapsed)})`);
|
|
657
707
|
lastStatus = statusLabel;
|
|
658
708
|
lastLoggedAt = Date.now();
|
|
659
709
|
}
|
|
660
710
|
else if (Date.now() - lastLoggedAt >= HEARTBEAT_INTERVAL_MS) {
|
|
661
|
-
console.
|
|
711
|
+
console.error(`${LOG} plan ${detail.planRequestId}: still ${statusLabel} (${formatElapsed(elapsed)})`);
|
|
662
712
|
lastLoggedAt = Date.now();
|
|
663
713
|
}
|
|
664
714
|
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
665
715
|
}
|
|
666
716
|
throw new Error(`timed out waiting for plan request ${planRequestId} ` +
|
|
667
|
-
`(${formatElapsed(Date.now() - started)})`
|
|
717
|
+
`(${formatElapsed(Date.now() - started)}). Local polling stopped without cancelling the remote plan. ` +
|
|
718
|
+
`Read it again with: seq-studio pipeline plan --plan-request-id ${planRequestId} -e <environment> --json`);
|
|
668
719
|
}
|
|
669
720
|
export async function pipelineAdoptCommand(args) {
|
|
670
721
|
const stage = flagString(args.flags, 'stage');
|
|
@@ -162,8 +162,12 @@ export async function pipelineRepinOrmCommand(args) {
|
|
|
162
162
|
}
|
|
163
163
|
const writes = [];
|
|
164
164
|
for (const stage of pinnedStages) {
|
|
165
|
-
const file = pipeline.files.find((candidate) =>
|
|
166
|
-
|
|
165
|
+
const file = pipeline.files.find((candidate) => {
|
|
166
|
+
const basename = candidate.split('/').at(-1);
|
|
167
|
+
return basename === `${stage.stage}.stage.yml` || basename === `${stage.stage}.stage.yaml`;
|
|
168
|
+
});
|
|
169
|
+
if (!file)
|
|
170
|
+
throw new Error(`could not find the source file for stage '${stage.stage}'`);
|
|
167
171
|
const current = await readFile(join(dir, file), 'utf8');
|
|
168
172
|
const nextHash = nextHashes.get(stage.stage);
|
|
169
173
|
if (!nextHash)
|
|
@@ -160,7 +160,7 @@ function unresolvedReason({ credential, named, matches, }) {
|
|
|
160
160
|
}
|
|
161
161
|
export function printReconcileResult({ result, deployTarget }) {
|
|
162
162
|
for (const { stage, symbolic, managedSecretName } of result.attached) {
|
|
163
|
-
console.
|
|
163
|
+
console.error(`${LOG} attached ${managedSecretName} to ${stage.slug} (${symbolic}) for ${deployTarget}`);
|
|
164
164
|
}
|
|
165
165
|
for (const { stage, symbolic, managedSecretName, reason } of result.unresolved) {
|
|
166
166
|
console.error(`${LOG} ${stage.slug}: credential ${symbolic} has nothing attached for ${deployTarget} — ${reason}. ` +
|
package/dist/process/build.js
CHANGED
|
@@ -387,6 +387,23 @@ function serializeNodeMetadata(node) {
|
|
|
387
387
|
serializeMapperSlot(meta, 'output_mapper', mf.output);
|
|
388
388
|
return meta;
|
|
389
389
|
}
|
|
390
|
+
case 'managed_server': {
|
|
391
|
+
const server = node;
|
|
392
|
+
const meta = {
|
|
393
|
+
server_id: server.server,
|
|
394
|
+
path: server.path,
|
|
395
|
+
};
|
|
396
|
+
if (server.limits)
|
|
397
|
+
meta.limits = server.limits;
|
|
398
|
+
if (server.bindings)
|
|
399
|
+
meta.bindings = server.bindings;
|
|
400
|
+
if (server.run_as?.service_account) {
|
|
401
|
+
meta.run_as = { service_account: server.run_as.service_account };
|
|
402
|
+
}
|
|
403
|
+
serializeMapperSlot(meta, 'input_mapper', server.input);
|
|
404
|
+
serializeMapperSlot(meta, 'output_mapper', server.output);
|
|
405
|
+
return meta;
|
|
406
|
+
}
|
|
390
407
|
default:
|
|
391
408
|
return {};
|
|
392
409
|
}
|
package/dist/process/codegen.js
CHANGED
|
@@ -226,6 +226,22 @@ function emitNode(node, ctx) {
|
|
|
226
226
|
];
|
|
227
227
|
return call('defineManagedFunctionNode', fields);
|
|
228
228
|
}
|
|
229
|
+
case 'managed_server': {
|
|
230
|
+
ctx.used.add('defineManagedServerNode');
|
|
231
|
+
const fields = [
|
|
232
|
+
...head,
|
|
233
|
+
` server: ${lit(String(m.server_id))},`,
|
|
234
|
+
` path: ${lit(String(m.path))},`,
|
|
235
|
+
m.limits !== undefined ? ` limits: ${pretty(m.limits, 1)},` : null,
|
|
236
|
+
runAsField(m.run_as),
|
|
237
|
+
bindings(m.bindings),
|
|
238
|
+
middleware(m.middleware, ctx),
|
|
239
|
+
mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
|
|
240
|
+
mapper('output', undefined, m.output_mapper_expr, ctx),
|
|
241
|
+
tail,
|
|
242
|
+
];
|
|
243
|
+
return call('defineManagedServerNode', fields);
|
|
244
|
+
}
|
|
229
245
|
default:
|
|
230
246
|
throw new Error(`codegen: unsupported node kind "${node.kind}" (node "${node.id}")`);
|
|
231
247
|
}
|