@sequenceholdings/studio-cli 0.1.26 → 0.1.28
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 +265 -81
- package/dist/app/adapters.d.ts +9 -0
- package/dist/app/adapters.js +176 -0
- package/dist/app/commands.d.ts +2 -2
- package/dist/app/commands.js +98 -22
- package/dist/app/deploy.d.ts +9 -10
- package/dist/app/deploy.js +83 -141
- package/dist/app/graph.d.ts +15 -0
- package/dist/app/graph.js +36 -0
- package/dist/app/manifest-validation.d.ts +16 -0
- package/dist/app/manifest-validation.js +99 -0
- package/dist/app/manifest.d.ts +27 -9
- package/dist/app/manifest.js +23 -107
- package/dist/app/paths.d.ts +14 -0
- package/dist/app/paths.js +77 -0
- package/dist/app/primitive-scaffold.d.ts +18 -0
- package/dist/app/primitive-scaffold.js +136 -0
- package/dist/app/readme.d.ts +4 -18
- package/dist/app/readme.js +107 -229
- package/dist/app/run-deployment.d.ts +8 -0
- package/dist/app/run-deployment.js +50 -0
- package/dist/app/scaffold-files.d.ts +13 -0
- package/dist/app/scaffold-files.js +68 -0
- package/dist/app/scaffold.d.ts +11 -3
- package/dist/app/scaffold.js +77 -245
- package/dist/app/workspace-compile.d.ts +18 -0
- package/dist/app/workspace-compile.js +143 -0
- package/dist/app/workspace-model.d.ts +70 -0
- package/dist/app/workspace-model.js +159 -0
- package/dist/app/workspace-scaffold.d.ts +27 -0
- package/dist/app/workspace-scaffold.js +126 -0
- package/dist/app/workspace.d.ts +14 -0
- package/dist/app/workspace.js +147 -0
- package/dist/atlas-client.js +28 -6
- package/dist/auth-cmds/commands.d.ts +1 -1
- package/dist/auth-cmds/commands.js +5 -2
- package/dist/functions/commands.js +7 -1
- package/dist/functions/manifest.d.ts +18 -0
- package/dist/functions/manifest.js +29 -4
- package/dist/main.js +9 -4
- package/dist/orm/delegate.js +30 -23
- package/dist/pat-hints.js +1 -0
- package/dist/pipeline/commands.js +27 -9
- package/dist/pipeline/lifecycle.d.ts +2 -0
- package/dist/pipeline/lifecycle.js +91 -11
- package/dist/process/build.js +59 -43
- package/dist/process/codegen.d.ts +3 -2
- package/dist/process/codegen.js +143 -27
- package/dist/process/commands.d.ts +2 -0
- package/dist/process/commands.js +63 -18
- package/dist/process/discover.d.ts +6 -3
- package/dist/process/discover.js +11 -3
- package/dist/process/lint.d.ts +14 -0
- package/dist/process/lint.js +143 -5
- package/dist/process/plan-diff.d.ts +8 -0
- package/dist/process/plan-diff.js +61 -4
- package/dist/process/safety-baseline.d.ts +154 -0
- package/dist/process/safety-baseline.js +387 -0
- package/dist/process/simulate.js +64 -22
- package/dist/repos/commands.d.ts +1 -1
- package/dist/repos/commands.js +29 -3
- package/package.json +8 -7
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/** App orchestration reuses each primitive's validation and deployment policy. */
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { load as loadYaml } from 'js-yaml';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { assertActiveDeployProvenance } from '@sequenceholdings/artifact-studio/active-deploy-policy';
|
|
8
|
+
import { localGitMetadata, resolveArtifactSource } from '@sequenceholdings/artifact-studio/source-resolver';
|
|
9
|
+
const functionIdentitySchema = z.object({ function: z.object({ id: z.string() }) });
|
|
10
|
+
const artifactIdentitySchema = z.object({ artifact: z.object({ project_id: z.string() }) });
|
|
11
|
+
function selectedFlags({ entry }) {
|
|
12
|
+
return {
|
|
13
|
+
...(entry.target ? { target: entry.target } : {}),
|
|
14
|
+
...(entry.only?.length ? { only: entry.only.join(',') } : {}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Keep source identity checks ahead of builds and all remote mutations. */
|
|
18
|
+
async function validatePrimitiveIdentity({ entry, path }) {
|
|
19
|
+
let actual;
|
|
20
|
+
let expected;
|
|
21
|
+
if (entry.kind === 'function' && entry.slug) {
|
|
22
|
+
const raw = loadYaml(await readFile(join(path, 'managed-function.yml'), 'utf8'));
|
|
23
|
+
actual = functionIdentitySchema.parse(raw).function.id;
|
|
24
|
+
expected = entry.slug;
|
|
25
|
+
}
|
|
26
|
+
else if (entry.kind === 'artifact' && entry.project_id) {
|
|
27
|
+
const raw = loadYaml(await readFile(join(path, 'artifact.bundle.yml'), 'utf8'));
|
|
28
|
+
actual = artifactIdentitySchema.parse(raw).artifact.project_id;
|
|
29
|
+
expected = entry.project_id;
|
|
30
|
+
}
|
|
31
|
+
else if (entry.kind === 'orm' && entry.namespace) {
|
|
32
|
+
if (existsSync(join(path, 'sequence.config.ts'))) {
|
|
33
|
+
const { loadNamespaceFromDir } = await import('@sequenceholdings/orm/authoring');
|
|
34
|
+
const { ORM_MODULE_PATH_ENV } = await import('@sequenceholdings/orm/cli');
|
|
35
|
+
const ormModulePath = process.env[ORM_MODULE_PATH_ENV]?.trim();
|
|
36
|
+
actual = (await loadNamespaceFromDir(path, ormModulePath ? { ormModulePath } : {})).canonical.namespace;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const { loadNamespaceDefinition } = await import('@sequenceholdings/orm');
|
|
40
|
+
actual = (await loadNamespaceDefinition(path)).definition.namespace;
|
|
41
|
+
}
|
|
42
|
+
expected = entry.namespace;
|
|
43
|
+
}
|
|
44
|
+
if (actual !== expected) {
|
|
45
|
+
throw new Error(`Primitive "${entry.id}" declares identity "${expected}" in sequence.app.yml, ` +
|
|
46
|
+
`but its source declares "${actual}". Update the app inventory or source before deploying.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function requirePipelineSource({ entry }) {
|
|
50
|
+
if (!entry.repo || !entry.ref) {
|
|
51
|
+
throw new Error(`Pipeline "${entry.id}" requires repo and ref in sequence.app.yml. ` +
|
|
52
|
+
'Push its source to a pipelines/<name> repository and pin that repository/ref; ' +
|
|
53
|
+
'pipeline deployment reads committed source from the platform git service.');
|
|
54
|
+
}
|
|
55
|
+
return { repo: entry.repo, ref: entry.ref };
|
|
56
|
+
}
|
|
57
|
+
/** Pin the source validated during preflight so a moving branch cannot swap it. */
|
|
58
|
+
async function validatePipelineSource(args) {
|
|
59
|
+
const { repo, ref } = requirePipelineSource(args);
|
|
60
|
+
const { buildContext, clientOptions } = await import('../functions/commands.js');
|
|
61
|
+
const context = await buildContext({ positional: [], flags: { env: args.env } });
|
|
62
|
+
const [namespace, name] = repo.split('/');
|
|
63
|
+
if (namespace !== 'pipelines' || !name || repo.split('/').length !== 2) {
|
|
64
|
+
throw new Error(`Pipeline "${args.entry.id}" requires a pipelines/<name> repository.`);
|
|
65
|
+
}
|
|
66
|
+
const source = await resolveArtifactSource({ kind: 'git-service', namespace, name, ref }, { ...clientOptions(context), ...(context.authMode ? { authMode: context.authMode } : {}) });
|
|
67
|
+
try {
|
|
68
|
+
const commit = source.provenance.gitCommit;
|
|
69
|
+
if (!commit || !/^[0-9a-f]{40}$/i.test(commit)) {
|
|
70
|
+
throw new Error(`Pipeline "${args.entry.id}" source did not resolve to a commit; retry with a full commit SHA.`);
|
|
71
|
+
}
|
|
72
|
+
const { pipelineValidateCommand } = await import('../pipeline/commands.js');
|
|
73
|
+
const code = await pipelineValidateCommand({ positional: [source.dir], flags: {} });
|
|
74
|
+
assertValidationSucceeded({ args, code });
|
|
75
|
+
console.log(`[seq-studio] pinned pipeline ${args.entry.id}: ${repo}@${commit}`);
|
|
76
|
+
return { ...args.entry, ref: commit };
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
await source.cleanup();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function assertValidationSucceeded({ args, code }) {
|
|
83
|
+
if (code !== 0) {
|
|
84
|
+
throw new Error(`Primitive "${args.entry.id}" failed ${args.entry.kind} validation (exit ${code}). No app resources were deployed.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Validate every selected source before any deployer runs. Pipeline source is
|
|
89
|
+
* materialized read-only from git and pinned. Live runtime reference checks
|
|
90
|
+
* remain inside apply, after dependencies deploy.
|
|
91
|
+
*/
|
|
92
|
+
export async function validateAppPrimitive(args) {
|
|
93
|
+
const { entry, path, env } = args;
|
|
94
|
+
// A pipeline's path is its authoring location; its declared repository is
|
|
95
|
+
// the deployment source. Validate the exact committed bytes used by deploy.
|
|
96
|
+
if (entry.kind === 'pipeline')
|
|
97
|
+
return validatePipelineSource(args);
|
|
98
|
+
const sourceStat = await stat(path).catch(() => null);
|
|
99
|
+
if (!sourceStat?.isDirectory()) {
|
|
100
|
+
throw new Error(`Primitive "${entry.id}" source is not a directory: ${path}`);
|
|
101
|
+
}
|
|
102
|
+
await validatePrimitiveIdentity(args);
|
|
103
|
+
let code;
|
|
104
|
+
switch (entry.kind) {
|
|
105
|
+
case 'orm': {
|
|
106
|
+
const { runOrmCommand } = await import('../orm/delegate.js');
|
|
107
|
+
code = await runOrmCommand('validate', [path]);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
case 'function': {
|
|
111
|
+
const { functionsBuildCommand } = await import('../functions/commands.js');
|
|
112
|
+
code = await functionsBuildCommand({ positional: [], flags: { dir: path } });
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case 'agent': {
|
|
116
|
+
const { agentsValidateCommand } = await import('../agents/commands.js');
|
|
117
|
+
code = await agentsValidateCommand({
|
|
118
|
+
positional: [], flags: { dir: path, target: entry.target ?? env, ...selectedFlags(args) },
|
|
119
|
+
});
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case 'process': {
|
|
123
|
+
const { lintCommand } = await import('../process/commands.js');
|
|
124
|
+
code = await lintCommand({ positional: [], flags: { dir: path, offline: true, ...selectedFlags(args) } });
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
case 'artifact': {
|
|
128
|
+
if (env !== 'local')
|
|
129
|
+
assertActiveDeployProvenance(localGitMetadata(path));
|
|
130
|
+
const { runArtifactCommand } = await import('../artifact/delegate.js');
|
|
131
|
+
code = await runArtifactCommand('validate', [path]);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
assertValidationSucceeded({ args, code });
|
|
136
|
+
}
|
|
137
|
+
export async function createDefaultDeployers() {
|
|
138
|
+
const { runOrmCommand } = await import('../orm/delegate.js');
|
|
139
|
+
const { functionsDeployCommand } = await import('../functions/commands.js');
|
|
140
|
+
const { agentsApplyCommand } = await import('../agents/commands.js');
|
|
141
|
+
const { applyCommand } = await import('../process/commands.js');
|
|
142
|
+
const { pipelineDeployCommand } = await import('../pipeline/lifecycle.js');
|
|
143
|
+
const { runArtifactCommand } = await import('../artifact/delegate.js');
|
|
144
|
+
return {
|
|
145
|
+
async orm({ path, env }) {
|
|
146
|
+
return runOrmCommand('apply', [path, '--env', env]);
|
|
147
|
+
},
|
|
148
|
+
async function({ path, env, yes }) {
|
|
149
|
+
// The primitive waits for its version to be active. Never use --no-wait:
|
|
150
|
+
// dependents need a successfully deployed function, not an enqueued one.
|
|
151
|
+
return functionsDeployCommand({ positional: [], flags: { dir: path, env, ...(yes ? { yes: true } : {}) } });
|
|
152
|
+
},
|
|
153
|
+
async agent(args) {
|
|
154
|
+
return agentsApplyCommand({ positional: [], flags: {
|
|
155
|
+
dir: args.path, env: args.env, ...selectedFlags(args), ...(args.yes ? { yes: true } : {}),
|
|
156
|
+
} });
|
|
157
|
+
},
|
|
158
|
+
async process(args) {
|
|
159
|
+
return applyCommand({ positional: [], flags: { dir: args.path, env: args.env, ...selectedFlags(args) } });
|
|
160
|
+
},
|
|
161
|
+
async pipeline(args) {
|
|
162
|
+
const { repo, ref } = requirePipelineSource(args);
|
|
163
|
+
const { env, approvedBy, waitTimeout } = args;
|
|
164
|
+
return pipelineDeployCommand({ positional: [], flags: {
|
|
165
|
+
// Validated above. Preserve the primitive's repo-only deployment
|
|
166
|
+
// boundary and wait for terminal deployment status before dependents.
|
|
167
|
+
repo, ref, env, ...selectedFlags(args),
|
|
168
|
+
...(approvedBy ? { 'approved-by': approvedBy } : {}),
|
|
169
|
+
...(waitTimeout ? { 'wait-timeout': waitTimeout } : {}),
|
|
170
|
+
} });
|
|
171
|
+
},
|
|
172
|
+
async artifact({ path, env }) {
|
|
173
|
+
return runArtifactCommand('deploy', [path, '--env', env]);
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
package/dist/app/commands.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ParsedArgs } from '../process/commands.js';
|
|
8
8
|
export declare const APP_INIT_USAGE: string;
|
|
9
|
-
export declare const APP_ADD_USAGE
|
|
10
|
-
export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Deploy
|
|
9
|
+
export declare const APP_ADD_USAGE: string;
|
|
10
|
+
export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Deploy the app declared in sequence.app.yml. Version 2 uses\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio functions deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agents apply --dir <path> -e <env> [--yes]\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio deploy -e staging --yes\n seq-studio deploy -e local --only get-pokemon --yes\n seq-studio deploy --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm generate <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Pipeline preflight reads the remote source and pins its commit; dry-run\n therefore needs network/auth for pipelines. Version 1 dry-run only lists.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
|
|
11
11
|
export declare function runAppInitCommand(args: ParsedArgs): Promise<number>;
|
|
12
12
|
export declare function runAppAddCommand({ kindArg, args, }: {
|
|
13
13
|
kindArg: string | undefined;
|
package/dist/app/commands.js
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
* seq-studio deploy -e <env>
|
|
6
6
|
*/
|
|
7
7
|
import { basename, resolve } from 'node:path';
|
|
8
|
+
import { parseDurationMs } from '@sequenceholdings/lattice';
|
|
8
9
|
import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
|
|
9
10
|
import { deployApp } from './deploy.js';
|
|
10
11
|
import { resolveRequestedKinds } from './kinds.js';
|
|
12
|
+
import { addSharedPackageToApp } from './workspace-scaffold.js';
|
|
11
13
|
import { APP_MANIFEST_FILENAME, isPrimitiveKind, PRIMITIVE_KINDS, slugifyAppId, } from './manifest.js';
|
|
12
|
-
import { addPrimitiveToApp, defaultScaffoldNames, initAppMonorepo, printInitNextSteps, } from './scaffold.js';
|
|
14
|
+
import { addPrimitiveToApp, defaultScaffoldNames, initAppMonorepo, printInitNextSteps, printOrmPreparation, } from './scaffold.js';
|
|
13
15
|
const LOG = '[seq-studio]';
|
|
14
16
|
export const APP_INIT_USAGE = `usage:
|
|
15
17
|
seq-studio init <dir> --with <kinds> [options]
|
|
@@ -27,43 +29,58 @@ export const APP_INIT_USAGE = `usage:
|
|
|
27
29
|
--with <k1,k2,…> comma-separated kinds to scaffold
|
|
28
30
|
--orm --function … boolean aliases for --with
|
|
29
31
|
--function-name <n> name/slug for the first function (default: hello)
|
|
32
|
+
--pipeline-type <t> ingestion, transformation (default), or serving
|
|
30
33
|
--description <text> optional app.description in the manifest
|
|
31
34
|
|
|
32
35
|
Examples:
|
|
33
36
|
seq-studio init pokedex --with orm,function,artifact
|
|
34
37
|
seq-studio init pokedex --with orm,function,artifact --function-name get-pokemon
|
|
35
38
|
seq-studio init loan-tools --with function --function-name get-loan
|
|
39
|
+
seq-studio init review-app --with orm,function,agent,process,pipeline,artifact
|
|
36
40
|
`;
|
|
37
41
|
export const APP_ADD_USAGE = `usage:
|
|
38
|
-
seq-studio add <kind> <name>
|
|
42
|
+
seq-studio add <kind> <name> [--depends-on <ids>] [--pipeline-type <type>]
|
|
43
|
+
seq-studio add package <name>
|
|
39
44
|
|
|
40
45
|
Scaffold another primitive into the current app monorepo (must contain
|
|
41
46
|
${APP_MANIFEST_FILENAME}) and append it to the manifest.
|
|
42
47
|
|
|
43
|
-
Kinds:
|
|
44
|
-
|
|
48
|
+
Kinds: ${PRIMITIVE_KINDS.join(', ')}
|
|
49
|
+
|
|
50
|
+
--depends-on <ids> comma-separated prerequisite primitive ids
|
|
51
|
+
--pipeline-type <t> ingestion, transformation (default), or serving
|
|
45
52
|
|
|
46
53
|
Examples:
|
|
47
54
|
seq-studio add function list-types
|
|
48
55
|
seq-studio add artifact ui
|
|
56
|
+
seq-studio add agent reviewer --depends-on list-types
|
|
57
|
+
seq-studio add process approvals --depends-on reviewer-agent
|
|
58
|
+
seq-studio add orm audit
|
|
59
|
+
seq-studio add package contracts
|
|
49
60
|
|
|
50
61
|
Run from the app root (directory with ${APP_MANIFEST_FILENAME}).
|
|
51
62
|
`;
|
|
52
63
|
export const APP_DEPLOY_USAGE = `usage:
|
|
53
64
|
seq-studio deploy -e <env> [options]
|
|
54
65
|
|
|
55
|
-
Deploy
|
|
56
|
-
|
|
66
|
+
Deploy the app declared in ${APP_MANIFEST_FILENAME}. Version 2 uses
|
|
67
|
+
depends_on prerequisites; deploy.order optionally orders ready primitives.
|
|
68
|
+
Runs each kind's existing command:
|
|
57
69
|
orm → seq-studio orm apply <path> -e <env>
|
|
58
70
|
function → seq-studio functions deploy --dir <path> -e <env> [--yes]
|
|
71
|
+
agent → seq-studio agents apply --dir <path> -e <env> [--yes]
|
|
72
|
+
process → seq-studio process apply --dir <path> -e <env>
|
|
73
|
+
pipeline → seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>
|
|
59
74
|
artifact → seq-studio artifact deploy <path> -e <env>
|
|
60
75
|
|
|
61
76
|
Options:
|
|
62
77
|
-e, --env <name> target environment (required)
|
|
63
78
|
--dir <path> app root (default: cwd; must contain ${APP_MANIFEST_FILENAME})
|
|
64
|
-
--only <id1,id2> deploy
|
|
65
|
-
--yes non-interactive (forwarded to
|
|
66
|
-
--dry-run
|
|
79
|
+
--only <id1,id2> deploy these ids and their prerequisites (v2)
|
|
80
|
+
--yes non-interactive (forwarded to primitive commands)
|
|
81
|
+
--dry-run validate/compile selected sources without deploying (v2)
|
|
82
|
+
--approved-by <sub> recorded caller approval for protected pipeline targets
|
|
83
|
+
--wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h
|
|
67
84
|
|
|
68
85
|
Examples:
|
|
69
86
|
seq-studio deploy -e staging --yes
|
|
@@ -71,7 +88,23 @@ export const APP_DEPLOY_USAGE = `usage:
|
|
|
71
88
|
seq-studio deploy --dir ./pokedex -e staging --dry-run
|
|
72
89
|
|
|
73
90
|
Run from the app root (directory with ${APP_MANIFEST_FILENAME}), or pass --dir.
|
|
91
|
+
Version 1 manifests keep their existing ordering and exact --only behavior.
|
|
92
|
+
Pipelines require repo and ref in their manifest entry.
|
|
93
|
+
ORM namespaces require generated code and a reviewed migration ledger:
|
|
94
|
+
seq-studio orm generate <path> && seq-studio orm diff <path>
|
|
95
|
+
Commit generated migrations before the first deployment and schema changes.
|
|
96
|
+
Pipeline preflight reads the remote source and pins its commit; dry-run
|
|
97
|
+
therefore needs network/auth for pipelines. Version 1 dry-run only lists.
|
|
98
|
+
Version 2 writes the result to .sequence/deployments/<environment>.json.
|
|
74
99
|
`;
|
|
100
|
+
function pipelineTypeFlag(flags) {
|
|
101
|
+
const value = flags['pipeline-type'];
|
|
102
|
+
if (value === undefined)
|
|
103
|
+
return undefined;
|
|
104
|
+
if (value === 'ingestion' || value === 'transformation' || value === 'serving')
|
|
105
|
+
return value;
|
|
106
|
+
throw new Error('--pipeline-type requires ingestion, transformation, or serving');
|
|
107
|
+
}
|
|
75
108
|
function printError(error) {
|
|
76
109
|
const message = error instanceof Error ? error.message : String(error);
|
|
77
110
|
console.error(`${LOG} ${message}`);
|
|
@@ -126,6 +159,7 @@ export async function runAppInitCommand(args) {
|
|
|
126
159
|
kinds,
|
|
127
160
|
names,
|
|
128
161
|
description,
|
|
162
|
+
pipelineType: pipelineTypeFlag(args.flags),
|
|
129
163
|
});
|
|
130
164
|
printInitNextSteps({ appRoot, manifest });
|
|
131
165
|
return 0;
|
|
@@ -140,15 +174,11 @@ export async function runAppAddCommand({ kindArg, args, }) {
|
|
|
140
174
|
console.log(APP_ADD_USAGE);
|
|
141
175
|
return kindArg ? 0 : 1;
|
|
142
176
|
}
|
|
143
|
-
if (!isPrimitiveKind(kindArg)) {
|
|
144
|
-
console.error(`${LOG} unknown kind '${kindArg}' — expected one of: ${PRIMITIVE_KINDS.join(', ')}`);
|
|
177
|
+
if (!isPrimitiveKind(kindArg) && kindArg !== 'package') {
|
|
178
|
+
console.error(`${LOG} unknown kind '${kindArg}' — expected one of: ${PRIMITIVE_KINDS.join(', ')}, package`);
|
|
145
179
|
console.error(APP_ADD_USAGE);
|
|
146
180
|
return 1;
|
|
147
181
|
}
|
|
148
|
-
if (kindArg === 'orm') {
|
|
149
|
-
console.error(`${LOG} \`seq-studio add orm\` is not supported — orm is created at init`);
|
|
150
|
-
return 1;
|
|
151
|
-
}
|
|
152
182
|
const nameRaw = args.positional[0];
|
|
153
183
|
if (!nameRaw) {
|
|
154
184
|
console.error(`${LOG} usage: seq-studio add ${kindArg} <name>`);
|
|
@@ -160,16 +190,32 @@ export async function runAppAddCommand({ kindArg, args, }) {
|
|
|
160
190
|
return 1;
|
|
161
191
|
}
|
|
162
192
|
try {
|
|
193
|
+
if (kindArg === 'package') {
|
|
194
|
+
const entry = await addSharedPackageToApp({ rootDir: process.cwd(), name });
|
|
195
|
+
console.log(`${LOG} added shared package "${entry.name}" at ${entry.path}`);
|
|
196
|
+
console.log(`${LOG} use pnpm --filter <consumer-package> add '${entry.name}@workspace:*' to share it`);
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
const dependsOnFlag = args.flags['depends-on'];
|
|
200
|
+
if (dependsOnFlag === true)
|
|
201
|
+
throw new Error('--depends-on requires a comma-separated list of primitive ids');
|
|
202
|
+
const dependsOn = typeof dependsOnFlag === 'string'
|
|
203
|
+
? [...new Set(dependsOnFlag.split(',').map((part) => part.trim()).filter(Boolean))]
|
|
204
|
+
: undefined;
|
|
205
|
+
if (dependsOn?.length === 0)
|
|
206
|
+
throw new Error('--depends-on requires at least one primitive id');
|
|
163
207
|
const { entry } = await addPrimitiveToApp({
|
|
164
208
|
rootDir: process.cwd(),
|
|
165
209
|
kind: kindArg,
|
|
166
210
|
name,
|
|
211
|
+
pipelineType: pipelineTypeFlag(args.flags),
|
|
212
|
+
dependsOn,
|
|
167
213
|
});
|
|
168
214
|
console.log(`${LOG} added ${entry.kind} "${entry.id}" at ${entry.path}`);
|
|
169
215
|
console.log(`${LOG} updated ${APP_MANIFEST_FILENAME}`);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
216
|
+
console.log(`${LOG} next: pnpm install`);
|
|
217
|
+
printOrmPreparation({ primitives: [entry] });
|
|
218
|
+
console.log(` seq-studio deploy --only ${entry.id} -e <env>`);
|
|
173
219
|
return 0;
|
|
174
220
|
}
|
|
175
221
|
catch (error) {
|
|
@@ -184,11 +230,43 @@ function flagString(flags, key) {
|
|
|
184
230
|
function flagBool(flags, key) {
|
|
185
231
|
return flags[key] === true;
|
|
186
232
|
}
|
|
233
|
+
function validateDeployOptions(args) {
|
|
234
|
+
const valueFlags = new Set(['e', 'env', 'dir', 'only', 'approved-by', 'wait-timeout']);
|
|
235
|
+
const booleanFlags = new Set(['yes', 'dry-run', 'help', 'h']);
|
|
236
|
+
for (const [flag, value] of Object.entries(args.flags)) {
|
|
237
|
+
if (valueFlags.has(flag)) {
|
|
238
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
239
|
+
throw new Error(`--${flag} requires a value`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
else if (!booleanFlags.has(flag) || value !== true) {
|
|
243
|
+
throw new Error(booleanFlags.has(flag) ? `--${flag} is a boolean flag` : `unknown option --${flag}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (args.positional.length > 0) {
|
|
247
|
+
throw new Error(`unexpected arguments: ${args.positional.join(' ')}; use --dir for the app root`);
|
|
248
|
+
}
|
|
249
|
+
const waitTimeout = flagString(args.flags, 'wait-timeout');
|
|
250
|
+
if (waitTimeout !== undefined) {
|
|
251
|
+
const duration = parseDurationMs(waitTimeout);
|
|
252
|
+
if (duration === null || !Number.isFinite(duration) || duration <= 0) {
|
|
253
|
+
throw new Error('--wait-timeout requires a positive duration such as 10m or 2h');
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
187
257
|
export async function runAppDeployCommand(args) {
|
|
188
258
|
if (args.flags.help === true || args.flags.h === true) {
|
|
189
259
|
console.log(APP_DEPLOY_USAGE);
|
|
190
260
|
return 0;
|
|
191
261
|
}
|
|
262
|
+
try {
|
|
263
|
+
validateDeployOptions(args);
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
printError(error);
|
|
267
|
+
return 1;
|
|
268
|
+
}
|
|
269
|
+
const waitTimeout = flagString(args.flags, 'wait-timeout');
|
|
192
270
|
const env = flagString(args.flags, 'env') ?? flagString(args.flags, 'e');
|
|
193
271
|
if (!env) {
|
|
194
272
|
console.error(`${LOG} ${REQUIRE_EXPLICIT_ENV_MESSAGE}`);
|
|
@@ -199,10 +277,6 @@ export async function runAppDeployCommand(args) {
|
|
|
199
277
|
const rootDir = resolve(dirFlag ?? process.cwd());
|
|
200
278
|
let only;
|
|
201
279
|
const onlyRaw = flagString(args.flags, 'only');
|
|
202
|
-
if (args.flags.only === true) {
|
|
203
|
-
console.error(`${LOG} --only requires a comma-separated list of primitive ids`);
|
|
204
|
-
return 1;
|
|
205
|
-
}
|
|
206
280
|
if (onlyRaw) {
|
|
207
281
|
only = onlyRaw
|
|
208
282
|
.split(',')
|
|
@@ -220,6 +294,8 @@ export async function runAppDeployCommand(args) {
|
|
|
220
294
|
only,
|
|
221
295
|
yes: flagBool(args.flags, 'yes'),
|
|
222
296
|
dryRun: flagBool(args.flags, 'dry-run'),
|
|
297
|
+
approvedBy: flagString(args.flags, 'approved-by'),
|
|
298
|
+
waitTimeout,
|
|
223
299
|
});
|
|
224
300
|
return result.exitCode;
|
|
225
301
|
}
|
package/dist/app/deploy.d.ts
CHANGED
|
@@ -4,22 +4,18 @@
|
|
|
4
4
|
* Child primitives keep their own deploy/apply verbs; this command only
|
|
5
5
|
* orchestrates them. Injectable runners keep unit tests offline.
|
|
6
6
|
*/
|
|
7
|
+
export { resolveContainedPrimitivePath } from './paths.js';
|
|
8
|
+
export { createDefaultDeployers } from './adapters.js';
|
|
7
9
|
import { type AppManifest, type PrimitiveEntry, type PrimitiveKind } from './manifest.js';
|
|
8
|
-
/**
|
|
9
|
-
* Resolve a manifest primitive path under the app root. Rejects absolute paths,
|
|
10
|
-
* lexical traversal, and symlink escapes (via realpath) before a deployer runs.
|
|
11
|
-
* Missing targets keep the lexical candidate after a lexical containment check.
|
|
12
|
-
*/
|
|
13
|
-
export declare function resolveContainedPrimitivePath({ rootDir, entryPath, }: {
|
|
14
|
-
rootDir: string;
|
|
15
|
-
entryPath: string;
|
|
16
|
-
}): Promise<string>;
|
|
17
10
|
export type DeployPrimitiveArgs = {
|
|
18
11
|
entry: PrimitiveEntry;
|
|
19
12
|
/** Absolute path to the primitive directory. */
|
|
20
13
|
path: string;
|
|
21
14
|
env: string;
|
|
22
15
|
yes: boolean;
|
|
16
|
+
rootDir: string;
|
|
17
|
+
approvedBy?: string;
|
|
18
|
+
waitTimeout?: string;
|
|
23
19
|
};
|
|
24
20
|
export type PrimitiveDeployers = {
|
|
25
21
|
[K in PrimitiveKind]: (args: DeployPrimitiveArgs) => Promise<number>;
|
|
@@ -32,6 +28,9 @@ export type DeployAppOptions = {
|
|
|
32
28
|
yes?: boolean;
|
|
33
29
|
dryRun?: boolean;
|
|
34
30
|
deployers?: PrimitiveDeployers;
|
|
31
|
+
validatePrimitive?: (args: DeployPrimitiveArgs) => Promise<PrimitiveEntry | void>;
|
|
32
|
+
approvedBy?: string;
|
|
33
|
+
waitTimeout?: string;
|
|
35
34
|
};
|
|
36
35
|
export type DeployAppResult = {
|
|
37
36
|
attempted: string[];
|
|
@@ -39,11 +38,11 @@ export type DeployAppResult = {
|
|
|
39
38
|
failed: string[];
|
|
40
39
|
skipped: string[];
|
|
41
40
|
exitCode: number;
|
|
41
|
+
reportPath?: string;
|
|
42
42
|
};
|
|
43
43
|
/** Resolve ordered primitive entries for deploy, validating order / --only ids. */
|
|
44
44
|
export declare function resolveDeployEntries({ manifest, only, }: {
|
|
45
45
|
manifest: AppManifest;
|
|
46
46
|
only?: readonly string[];
|
|
47
47
|
}): PrimitiveEntry[];
|
|
48
|
-
export declare function createDefaultDeployers(): Promise<PrimitiveDeployers>;
|
|
49
48
|
export declare function deployApp(options: DeployAppOptions): Promise<DeployAppResult>;
|