@sequenceholdings/studio-cli 0.4.7 → 0.5.2
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 +162 -84
- package/dist/agents/commands.js +7 -0
- package/dist/app/adapters.d.ts +2 -2
- package/dist/app/adapters.js +15 -14
- package/dist/app/commands.d.ts +1 -1
- package/dist/app/commands.js +77 -14
- package/dist/app/deploy.d.ts +2 -0
- package/dist/app/deploy.js +25 -13
- package/dist/app/kinds.d.ts +6 -0
- package/dist/app/kinds.js +6 -0
- package/dist/app/manifest.js +1 -1
- package/dist/app/official-source.d.ts +10 -0
- package/dist/app/official-source.js +23 -0
- package/dist/app/prepare.d.ts +27 -0
- package/dist/app/prepare.js +58 -0
- package/dist/app/primitive-ids.d.ts +6 -0
- package/dist/app/primitive-ids.js +16 -0
- package/dist/app/primitive-scaffold.d.ts +0 -4
- package/dist/app/primitive-scaffold.js +7 -18
- package/dist/app/readme.js +23 -16
- package/dist/app/repository-index.d.ts +19 -0
- package/dist/app/repository-index.js +86 -0
- package/dist/app/scaffold.d.ts +12 -1
- package/dist/app/scaffold.js +32 -19
- package/dist/app/workspace-compile.d.ts +9 -0
- package/dist/app/workspace-compile.js +13 -1
- package/dist/app/workspace-scaffold.js +5 -1
- package/dist/artifact/delegate.js +4 -4
- package/dist/auth-cmds/commands.d.ts +1 -13
- package/dist/auth-cmds/commands.js +11 -246
- package/dist/auth.d.ts +17 -0
- package/dist/auth.js +29 -0
- package/dist/bin.js +1 -1
- package/dist/command-contract.d.ts +11 -5
- package/dist/command-contract.js +4 -3
- package/dist/command-help.d.ts +2 -2
- package/dist/command-help.js +14 -16
- package/dist/config.d.ts +16 -0
- package/dist/config.js +38 -5
- package/dist/env-registry.d.ts +8 -0
- package/dist/env-registry.js +9 -1
- package/dist/envs/commands.js +14 -1
- package/dist/functions/manifest.d.ts +4 -1
- package/dist/functions/manifest.js +8 -2
- package/dist/main.d.ts +3 -2
- package/dist/main.js +12 -6
- package/dist/orm/delegate.js +5 -2
- package/dist/pipeline/clone-deploy.d.ts +2 -3
- package/dist/pipeline/clone-deploy.js +9 -10
- package/dist/pipeline/commands.js +4 -3
- package/dist/pipeline/lifecycle.d.ts +3 -1
- package/dist/pipeline/lifecycle.js +12 -4
- package/dist/process/commands.d.ts +6 -3
- package/dist/process/commands.js +26 -10
- package/dist/repos/commands.d.ts +2 -11
- package/dist/repos/commands.js +71 -157
- package/dist/repos/git-clone.d.ts +1 -10
- package/dist/repos/git-clone.js +1 -49
- package/dist/repos/git-credential.d.ts +15 -0
- package/dist/repos/git-credential.js +91 -0
- package/dist/repos/pulls.d.ts +19 -1
- package/dist/repos/pulls.js +15 -2
- package/dist/templates/catalog.d.ts +69 -0
- package/dist/templates/catalog.js +68 -0
- package/dist/templates/commands.d.ts +29 -0
- package/dist/templates/commands.js +443 -0
- package/dist/templates/process/example-process/process.ts +2 -0
- package/dist/templates/process/package.json +1 -1
- package/package.json +13 -11
- package/templates/process/example-process/process.ts +2 -0
- package/templates/process/package.json +1 -1
- package/dist/pat-hints.d.ts +0 -15
- package/dist/pat-hints.js +0 -28
package/dist/app/commands.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { ParsedArgs } from '../process/commands.js';
|
|
8
8
|
export declare const APP_INIT_USAGE: string;
|
|
9
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.
|
|
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. Versions 2 and 3 use\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 A dry-run never opens a browser login: without a session it skips the\n workspace-binding check and says so. It warns, rather than fails, when the\n artifact source is not committed and clean on main.\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
|
@@ -8,36 +8,53 @@ import { basename, resolve } from 'node:path';
|
|
|
8
8
|
import { parseDurationMs } from '@sequenceholdings/lattice';
|
|
9
9
|
import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
|
|
10
10
|
import { deployApp } from './deploy.js';
|
|
11
|
-
import { resolveRequestedKinds } from './kinds.js';
|
|
11
|
+
import { DEFAULT_APP_KINDS, resolveRequestedKinds } from './kinds.js';
|
|
12
|
+
import { AppPreparationError, prepareScaffoldedApp } from './prepare.js';
|
|
13
|
+
import { planRepositoryDeclaration, REPOSITORY_INDEX_PATH, writeRepositoryDeclaration } from './repository-index.js';
|
|
12
14
|
import { addSharedPackageToApp } from './workspace-scaffold.js';
|
|
13
15
|
import { APP_MANIFEST_FILENAME, isPrimitiveKind, PRIMITIVE_KINDS, slugifyAppId, } from './manifest.js';
|
|
14
16
|
import { addPrimitiveToApp, defaultScaffoldNames, initAppMonorepo, printInitNextSteps, printOrmPreparation, } from './scaffold.js';
|
|
15
17
|
const LOG = '[seq-studio]';
|
|
16
18
|
export const APP_INIT_USAGE = `usage:
|
|
19
|
+
seq-studio init <dir> [options]
|
|
17
20
|
seq-studio init <dir> --with <kinds> [options]
|
|
18
|
-
seq-studio init <dir> --
|
|
21
|
+
seq-studio init <dir> --template <name>@<version> -e <deployment>
|
|
19
22
|
|
|
20
23
|
Scaffold an app monorepo with ${APP_MANIFEST_FILENAME}, a Sequence app
|
|
21
24
|
README.md, AGENTS.md + CLAUDE.md guidance, and one subfolder per
|
|
22
|
-
selected primitive.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
selected primitive. With no kinds it scaffolds ${DEFAULT_APP_KINDS.join(', ')}:
|
|
26
|
+
the kinds repository CI/CD creates and deploys when a pull request merges.
|
|
27
|
+
Then it runs pnpm install and authors the first ORM migration, so the
|
|
28
|
+
first pull request passes checks with no edits.
|
|
29
|
+
|
|
30
|
+
A git-service clone whose README.md contains the seq-studio seed marker is
|
|
31
|
+
a valid target (\`init .\`); ordinary docs-only repositories are refused so
|
|
32
|
+
we do not overwrite them. Inside an existing repository, \`init <subdir>\`
|
|
33
|
+
also declares the app in ${REPOSITORY_INDEX_PATH} so CI picks it up.
|
|
25
34
|
|
|
26
35
|
Kinds: ${PRIMITIVE_KINDS.join(', ')}
|
|
27
36
|
|
|
28
37
|
Options:
|
|
29
|
-
--with <k1,k2,…> comma-separated kinds to scaffold
|
|
38
|
+
--with <k1,k2,…> comma-separated kinds to scaffold (default: ${DEFAULT_APP_KINDS.join(',')})
|
|
30
39
|
--orm --function … boolean aliases for --with
|
|
31
40
|
--function-name <n> name/slug for the first function (default: hello)
|
|
32
41
|
--pipeline-type <t> ingestion, transformation (default), or serving
|
|
33
|
-
--template <t>
|
|
42
|
+
--template <t> react-vite (default) or nextjs for the artifact, or
|
|
43
|
+
<name>@<version> to start from a published app
|
|
44
|
+
template in the -e deployment
|
|
45
|
+
-e, --env <name> registered deployment whose template catalog to read
|
|
34
46
|
--description <text> optional app.description in the manifest
|
|
47
|
+
--skip-install skip pnpm install and ORM migration authoring (offline)
|
|
35
48
|
|
|
36
49
|
Examples:
|
|
50
|
+
seq-studio init pokedex
|
|
51
|
+
seq-studio init . --template nextjs
|
|
52
|
+
seq-studio init uw362 # a new app inside an existing repository
|
|
37
53
|
seq-studio init pokedex --with orm,function,artifact
|
|
38
54
|
seq-studio init pokedex --with orm,function,artifact --function-name get-pokemon
|
|
39
55
|
seq-studio init loan-tools --with function --function-name get-loan
|
|
40
56
|
seq-studio init review-app --with orm,function,agent,process,pipeline,artifact
|
|
57
|
+
seq-studio init review-app --template full-stack@1.0.0 -e banksouth-mortgage
|
|
41
58
|
`;
|
|
42
59
|
export const APP_ADD_USAGE = `usage:
|
|
43
60
|
seq-studio add <kind> <name> [--depends-on <ids>] [--pipeline-type <type>] [--template <t>]
|
|
@@ -68,7 +85,7 @@ export const APP_ADD_USAGE = `usage:
|
|
|
68
85
|
export const APP_DEPLOY_USAGE = `usage:
|
|
69
86
|
seq-studio deploy -e <env> [options]
|
|
70
87
|
|
|
71
|
-
Deploy the app declared in ${APP_MANIFEST_FILENAME}.
|
|
88
|
+
Deploy the app declared in ${APP_MANIFEST_FILENAME}. Versions 2 and 3 use
|
|
72
89
|
depends_on prerequisites; deploy.order optionally orders ready primitives.
|
|
73
90
|
Runs each kind's existing command:
|
|
74
91
|
orm → seq-studio orm apply <path> -e <env>
|
|
@@ -100,6 +117,9 @@ export const APP_DEPLOY_USAGE = `usage:
|
|
|
100
117
|
Commit generated migrations before the first deployment and schema changes.
|
|
101
118
|
Pipeline preflight reads the remote source and pins its commit; dry-run
|
|
102
119
|
therefore needs network/auth for pipelines. Version 1 dry-run only lists.
|
|
120
|
+
A dry-run never opens a browser login: without a session it skips the
|
|
121
|
+
workspace-binding check and says so. It warns, rather than fails, when the
|
|
122
|
+
artifact source is not committed and clean on main.
|
|
103
123
|
Version 2 writes the result to .sequence/deployments/<environment>.json.
|
|
104
124
|
`;
|
|
105
125
|
function pipelineTypeFlag(flags) {
|
|
@@ -143,9 +163,29 @@ export async function runAppInitCommand(args) {
|
|
|
143
163
|
console.error(APP_INIT_USAGE);
|
|
144
164
|
return 1;
|
|
145
165
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
const artifactTemplate = args.flags.template === 'react-vite' || args.flags.template === 'nextjs';
|
|
167
|
+
if (args.flags.template !== undefined && !artifactTemplate) {
|
|
168
|
+
try {
|
|
169
|
+
if (args.flags.template === true)
|
|
170
|
+
throw new Error('--template requires <name>@<version>.');
|
|
171
|
+
const env = args.flags.env ?? args.flags.e;
|
|
172
|
+
if (typeof env !== 'string')
|
|
173
|
+
throw new Error('--template requires -e <deployment>.');
|
|
174
|
+
if (kinds.length > 0)
|
|
175
|
+
throw new Error('Use either --template or --with/primitive flags.');
|
|
176
|
+
const { initFromTemplate } = await import('../templates/commands.js');
|
|
177
|
+
await initFromTemplate({ selection: args.flags.template, target, environment: env });
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
printError(error);
|
|
182
|
+
return 1;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (kinds.length === 0)
|
|
186
|
+
kinds = [...DEFAULT_APP_KINDS];
|
|
187
|
+
if (args.flags['skip-install'] !== undefined && args.flags['skip-install'] !== true) {
|
|
188
|
+
console.error(`${LOG} --skip-install is a boolean flag`);
|
|
149
189
|
return 1;
|
|
150
190
|
}
|
|
151
191
|
const appRoot = resolve(target);
|
|
@@ -167,8 +207,11 @@ export async function runAppInitCommand(args) {
|
|
|
167
207
|
console.error(`${LOG} --description requires a value`);
|
|
168
208
|
return 1;
|
|
169
209
|
}
|
|
210
|
+
let manifest;
|
|
170
211
|
try {
|
|
171
|
-
|
|
212
|
+
// Validate the repository index before writing anything, so a refusal leaves no scaffold behind.
|
|
213
|
+
const declaration = await planRepositoryDeclaration({ appRoot });
|
|
214
|
+
manifest = await initAppMonorepo({
|
|
172
215
|
rootDir: appRoot,
|
|
173
216
|
appId,
|
|
174
217
|
kinds,
|
|
@@ -177,13 +220,33 @@ export async function runAppInitCommand(args) {
|
|
|
177
220
|
pipelineType: pipelineTypeFlag(args.flags),
|
|
178
221
|
artifactTemplate: artifactTemplateFlag({ flags: args.flags, kinds }),
|
|
179
222
|
});
|
|
180
|
-
|
|
181
|
-
|
|
223
|
+
if (declaration) {
|
|
224
|
+
await writeRepositoryDeclaration({ declaration });
|
|
225
|
+
console.log(`${LOG} ${declaration.created ? 'created' : 'updated'} ${REPOSITORY_INDEX_PATH} to declare ${declaration.appPath}`);
|
|
226
|
+
}
|
|
182
227
|
}
|
|
183
228
|
catch (error) {
|
|
184
229
|
printError(error);
|
|
185
230
|
return 1;
|
|
186
231
|
}
|
|
232
|
+
const prepared = args.flags['skip-install'] === true ? false : await prepareApp({ appRoot, manifest });
|
|
233
|
+
printInitNextSteps({ appRoot, manifest, prepared });
|
|
234
|
+
return prepared === 'failed' ? 1 : 0;
|
|
235
|
+
}
|
|
236
|
+
async function prepareApp({ appRoot, manifest }) {
|
|
237
|
+
try {
|
|
238
|
+
await prepareScaffoldedApp({ appRoot, manifest });
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
printError(error);
|
|
243
|
+
if (error instanceof AppPreparationError) {
|
|
244
|
+
console.error(`${LOG} the scaffold is in place; finish preparing it with:`);
|
|
245
|
+
for (const step of error.remaining)
|
|
246
|
+
console.error(` ${step}`);
|
|
247
|
+
}
|
|
248
|
+
return 'failed';
|
|
249
|
+
}
|
|
187
250
|
}
|
|
188
251
|
export async function runAppAddCommand({ kindArg, args, }) {
|
|
189
252
|
if (!kindArg || kindArg === 'help' || kindArg === '--help' || kindArg === '-h') {
|
package/dist/app/deploy.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export type DeployPrimitiveArgs = {
|
|
|
18
18
|
rootDir: string;
|
|
19
19
|
approvedBy?: string;
|
|
20
20
|
waitTimeout?: string;
|
|
21
|
+
/** A dry-run validates without deploying, so official-deploy rules only warn. */
|
|
22
|
+
dryRun?: boolean;
|
|
21
23
|
};
|
|
22
24
|
export type PrimitiveDeployers = {
|
|
23
25
|
[K in PrimitiveKind]: (args: DeployPrimitiveArgs) => Promise<number>;
|
package/dist/app/deploy.js
CHANGED
|
@@ -18,7 +18,8 @@ import { dependencyClosure, dependencyOrder } from './graph.js';
|
|
|
18
18
|
import { createDefaultDeployers, validateAppPrimitive } from './adapters.js';
|
|
19
19
|
import { prepareAppWorkspace } from './workspace.js';
|
|
20
20
|
import { localGitMetadata } from '@sequenceholdings/artifact-studio/source-resolver';
|
|
21
|
-
import {
|
|
21
|
+
import { checkOfficialArtifactSource } from './official-source.js';
|
|
22
|
+
import { NotLoggedInError, withoutAutoLogin } from '../auth.js';
|
|
22
23
|
export { createDefaultDeployers } from './adapters.js';
|
|
23
24
|
import { defaultDeployOrder, loadAppManifest, usesAppGraph, } from './manifest.js';
|
|
24
25
|
import { warnOnManifestRoles } from '../manifest-roles-notice.js';
|
|
@@ -89,16 +90,18 @@ function assertAppDeploymentSource({ manifest, options, rootDir, entries }) {
|
|
|
89
90
|
// Shared sources live outside the UI directory. Check the entire original
|
|
90
91
|
// app before packaging so ignored staging cannot conceal a dirty package.
|
|
91
92
|
if (usesAppGraph(manifest) && options.env !== 'local' && entries.some((entry) => entry.kind === 'artifact')) {
|
|
92
|
-
|
|
93
|
-
...localGitMetadata(rootDir),
|
|
94
|
-
environment: options.env,
|
|
95
|
-
});
|
|
93
|
+
checkOfficialArtifactSource({ dir: rootDir, env: options.env, dryRun: options.dryRun });
|
|
96
94
|
}
|
|
97
95
|
if (usesAppGraph(manifest) && manifest.packages?.length && options.env !== 'local' && !options.dryRun && !existsSync(join(rootDir, 'pnpm-lock.yaml'))) {
|
|
98
96
|
throw new Error('App workspace deployment requires a root pnpm-lock.yaml. Run pnpm install at the app root and commit the lockfile before deploying.');
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
export async function deployApp(options) {
|
|
100
|
+
// A dry-run never signs anyone in: it uses an existing session or skips
|
|
101
|
+
// the checks that need one.
|
|
102
|
+
return options.dryRun ? withoutAutoLogin(() => runDeployApp(options)) : runDeployApp(options);
|
|
103
|
+
}
|
|
104
|
+
async function runDeployApp(options) {
|
|
102
105
|
const rootDir = resolve(options.rootDir);
|
|
103
106
|
const manifest = await loadAppManifest(rootDir);
|
|
104
107
|
await warnOnManifestRoles({ dir: rootDir, file: 'sequence.app.yml', kind: 'application' });
|
|
@@ -119,14 +122,22 @@ export async function deployApp(options) {
|
|
|
119
122
|
console.log(`${LOG} - ${entry.kind.padEnd(9)} ${entry.id} (${entry.path})`);
|
|
120
123
|
}
|
|
121
124
|
assertAppDeploymentSource({ manifest, options, rootDir, entries });
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
try {
|
|
126
|
+
await assertAppEnvironmentBindings({
|
|
127
|
+
manifest,
|
|
128
|
+
entries,
|
|
129
|
+
paths: resolvedPaths,
|
|
130
|
+
rootDir,
|
|
131
|
+
deployEnvironment: options.env,
|
|
132
|
+
...(options.environmentBindings ? { loadContext: options.environmentBindings } : {}),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (!options.dryRun || !(error instanceof NotLoggedInError))
|
|
137
|
+
throw error;
|
|
138
|
+
console.warn(`${LOG} dry-run: skipped checking workspace bindings against ${options.env} (not signed in). ` +
|
|
139
|
+
`Run \`seq-studio login -e ${options.env}\` to include them.`);
|
|
140
|
+
}
|
|
130
141
|
const provenance = localGitMetadata(rootDir);
|
|
131
142
|
const prepared = usesAppGraph(manifest)
|
|
132
143
|
? await prepareAppWorkspace({ rootDir, manifest, entries, paths: resolvedPaths })
|
|
@@ -136,6 +147,7 @@ export async function deployApp(options) {
|
|
|
136
147
|
const argsFor = (entry) => ({
|
|
137
148
|
entry: pinnedEntries.get(entry.id), path: prepared.paths.get(entry.id), rootDir, env: options.env,
|
|
138
149
|
yes: options.yes === true, approvedBy: options.approvedBy, waitTimeout: options.waitTimeout,
|
|
150
|
+
...(options.dryRun ? { dryRun: true } : {}),
|
|
139
151
|
});
|
|
140
152
|
if (usesAppGraph(manifest)) {
|
|
141
153
|
const validate = options.validatePrimitive ?? validateAppPrimitive;
|
package/dist/app/kinds.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type PrimitiveKind } from './manifest.js';
|
|
2
|
+
/**
|
|
3
|
+
* What `seq-studio init` scaffolds when no kinds are requested: exactly the
|
|
4
|
+
* kinds repository CI/CD creates and deploys on merge, so a fresh app ships
|
|
5
|
+
* with no further setup. Other kinds stay available through --with.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_APP_KINDS: readonly PrimitiveKind[];
|
|
2
8
|
/**
|
|
3
9
|
* Resolve which primitive kinds to scaffold from CLI flags.
|
|
4
10
|
*
|
package/dist/app/kinds.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { isPrimitiveKind, PRIMITIVE_KINDS } from './manifest.js';
|
|
2
|
+
/**
|
|
3
|
+
* What `seq-studio init` scaffolds when no kinds are requested: exactly the
|
|
4
|
+
* kinds repository CI/CD creates and deploys on merge, so a fresh app ships
|
|
5
|
+
* with no further setup. Other kinds stay available through --with.
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_APP_KINDS = ['orm', 'function', 'process', 'artifact'];
|
|
2
8
|
/**
|
|
3
9
|
* Resolve which primitive kinds to scaffold from CLI flags.
|
|
4
10
|
*
|
package/dist/app/manifest.js
CHANGED
|
@@ -53,7 +53,7 @@ const primitiveEntrySchema = z
|
|
|
53
53
|
project_id: z.string().min(1).optional(),
|
|
54
54
|
target: z.string().min(1).optional(),
|
|
55
55
|
only: z.array(z.string().min(1)).min(1).optional(),
|
|
56
|
-
repo: z.string().regex(/^
|
|
56
|
+
repo: z.string().regex(/^[a-z][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/, 'repo must be <namespace>/<name>').optional(),
|
|
57
57
|
ref: z.string().min(1).refine((ref) => !ref.startsWith('-'), 'ref cannot start with -').optional(),
|
|
58
58
|
})
|
|
59
59
|
.strict()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official artifact deploys need committed, clean source on `main` (or
|
|
3
|
+
* `staging` for a staging target). A dry-run deploys nothing, so there it
|
|
4
|
+
* reports what a real deploy would refuse instead of failing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function checkOfficialArtifactSource({ dir, env, dryRun, }: {
|
|
7
|
+
dir: string;
|
|
8
|
+
env: string;
|
|
9
|
+
dryRun?: boolean;
|
|
10
|
+
}): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ActiveDeployPolicyError, assertActiveDeployProvenance, } from '@sequenceholdings/artifact-studio/active-deploy-policy';
|
|
2
|
+
import { localGitMetadata } from '@sequenceholdings/artifact-studio/source-resolver';
|
|
3
|
+
const LOG = '[seq-studio]';
|
|
4
|
+
/**
|
|
5
|
+
* Official artifact deploys need committed, clean source on `main` (or
|
|
6
|
+
* `staging` for a staging target). A dry-run deploys nothing, so there it
|
|
7
|
+
* reports what a real deploy would refuse instead of failing.
|
|
8
|
+
*/
|
|
9
|
+
export function checkOfficialArtifactSource({ dir, env, dryRun = false, }) {
|
|
10
|
+
const provenance = localGitMetadata(dir);
|
|
11
|
+
try {
|
|
12
|
+
if (!provenance.gitCommit) {
|
|
13
|
+
throw new ActiveDeployPolicyError(`${dir} is not in a git repository with a commit. Official artifact deploys need committed ` +
|
|
14
|
+
'source on `main`: run `git init`, commit, then deploy, or use a preview deploy.');
|
|
15
|
+
}
|
|
16
|
+
assertActiveDeployProvenance({ ...provenance, environment: env });
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (!dryRun || !(error instanceof ActiveDeployPolicyError))
|
|
20
|
+
throw error;
|
|
21
|
+
console.warn(`${LOG} dry-run: a real deploy to ${env} would refuse: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AppManifest } from './manifest.js';
|
|
2
|
+
export type CommandRunner = (args: {
|
|
3
|
+
command: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
cwd: string;
|
|
6
|
+
}) => Promise<number>;
|
|
7
|
+
export type OrmRunner = (sub: string, rest: string[]) => Promise<number>;
|
|
8
|
+
/** The app root plus every primitive that keeps its own install root (a hosted Next.js artifact). */
|
|
9
|
+
export declare function installRoots({ appRoot, manifest }: {
|
|
10
|
+
appRoot: string;
|
|
11
|
+
manifest: AppManifest;
|
|
12
|
+
}): string[];
|
|
13
|
+
export declare class AppPreparationError extends Error {
|
|
14
|
+
readonly remaining: readonly string[];
|
|
15
|
+
constructor(message: string, remaining: readonly string[]);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Install dependencies, then generate each ORM namespace and author its first
|
|
19
|
+
* migration. On failure the scaffold stays in place; the error lists the
|
|
20
|
+
* commands still to run.
|
|
21
|
+
*/
|
|
22
|
+
export declare function prepareScaffoldedApp({ appRoot, manifest, run, orm, }: {
|
|
23
|
+
appRoot: string;
|
|
24
|
+
manifest: AppManifest;
|
|
25
|
+
run?: CommandRunner;
|
|
26
|
+
orm?: OrmRunner;
|
|
27
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make a fresh scaffold CI-ready: repository CI installs with
|
|
3
|
+
* `pnpm install --frozen-lockfile --offline`, so every install root needs a
|
|
4
|
+
* committed lockfile, and an ORM namespace deploys its committed migration.
|
|
5
|
+
*/
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
const runCommand = ({ command, args, cwd }) => new Promise((resolvePromise, reject) => {
|
|
10
|
+
const child = spawn(command, args, { cwd, stdio: 'inherit', shell: false });
|
|
11
|
+
child.once('error', reject);
|
|
12
|
+
child.once('exit', (code) => resolvePromise(code ?? 1));
|
|
13
|
+
});
|
|
14
|
+
const runOrm = async (sub, rest) => {
|
|
15
|
+
const { runOrmCommand } = await import('../orm/delegate.js');
|
|
16
|
+
return runOrmCommand(sub, rest);
|
|
17
|
+
};
|
|
18
|
+
/** The app root plus every primitive that keeps its own install root (a hosted Next.js artifact). */
|
|
19
|
+
export function installRoots({ appRoot, manifest }) {
|
|
20
|
+
const standalone = manifest.primitives
|
|
21
|
+
.map((entry) => join(appRoot, entry.path))
|
|
22
|
+
.filter((directory) => existsSync(join(directory, 'pnpm-workspace.yaml')));
|
|
23
|
+
return [appRoot, ...standalone];
|
|
24
|
+
}
|
|
25
|
+
export class AppPreparationError extends Error {
|
|
26
|
+
remaining;
|
|
27
|
+
constructor(message, remaining) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.remaining = remaining;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Install dependencies, then generate each ORM namespace and author its first
|
|
34
|
+
* migration. On failure the scaffold stays in place; the error lists the
|
|
35
|
+
* commands still to run.
|
|
36
|
+
*/
|
|
37
|
+
export async function prepareScaffoldedApp({ appRoot, manifest, run = runCommand, orm = runOrm, }) {
|
|
38
|
+
const roots = installRoots({ appRoot, manifest });
|
|
39
|
+
const namespaces = manifest.primitives.filter((entry) => entry.kind === 'orm').map((entry) => join(appRoot, entry.path));
|
|
40
|
+
const steps = [
|
|
41
|
+
...roots.map((cwd) => ({ label: `pnpm install (in ${cwd})`, perform: () => run({ command: 'pnpm', args: ['install'], cwd }) })),
|
|
42
|
+
...namespaces.flatMap((directory) => [
|
|
43
|
+
{ label: `seq-studio orm generate ${directory}`, perform: () => orm('generate', [directory]) },
|
|
44
|
+
{ label: `seq-studio orm diff ${directory}`, perform: () => orm('diff', [directory]) },
|
|
45
|
+
]),
|
|
46
|
+
];
|
|
47
|
+
for (const [index, step] of steps.entries()) {
|
|
48
|
+
let code;
|
|
49
|
+
try {
|
|
50
|
+
code = await step.perform();
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new AppPreparationError(`${step.label} could not start: ${error instanceof Error ? error.message : String(error)}`, steps.slice(index).map((item) => item.label));
|
|
54
|
+
}
|
|
55
|
+
if (code !== 0)
|
|
56
|
+
throw new AppPreparationError(`${step.label} failed (exit ${code})`, steps.slice(index).map((item) => item.label));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PrimitiveKind } from './manifest.js';
|
|
2
|
+
/** `name` plus its kind's suffix, unless the name already ends with it (`ui` stays `ui`, not `ui-ui`). */
|
|
3
|
+
export declare function primitiveIdFor({ kind, name }: {
|
|
4
|
+
kind: PrimitiveKind;
|
|
5
|
+
name: string;
|
|
6
|
+
}): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const PRIMITIVE_ID_SUFFIX = {
|
|
2
|
+
orm: 'orm',
|
|
3
|
+
artifact: 'ui',
|
|
4
|
+
function: null,
|
|
5
|
+
agent: 'agent',
|
|
6
|
+
process: 'process',
|
|
7
|
+
pipeline: 'pipeline',
|
|
8
|
+
workspace: 'workspace',
|
|
9
|
+
};
|
|
10
|
+
/** `name` plus its kind's suffix, unless the name already ends with it (`ui` stays `ui`, not `ui-ui`). */
|
|
11
|
+
export function primitiveIdFor({ kind, name }) {
|
|
12
|
+
const suffix = PRIMITIVE_ID_SUFFIX[kind];
|
|
13
|
+
if (!suffix || name === suffix || name.endsWith(`-${suffix}`))
|
|
14
|
+
return name;
|
|
15
|
+
return `${name}-${suffix}`;
|
|
16
|
+
}
|
|
@@ -2,10 +2,6 @@ import { type PrimitiveEntry, type PrimitiveKind } from './manifest.js';
|
|
|
2
2
|
export type AppPipelineType = 'ingestion' | 'transformation' | 'serving';
|
|
3
3
|
/** Same templates as `seq-studio artifact init --template`. */
|
|
4
4
|
export type AppArtifactTemplate = 'react-vite' | 'nextjs';
|
|
5
|
-
export declare function primitiveIdFor({ kind, name }: {
|
|
6
|
-
kind: PrimitiveKind;
|
|
7
|
-
name: string;
|
|
8
|
-
}): string;
|
|
9
5
|
export declare function relativePathFor({ kind, appId, name, }: {
|
|
10
6
|
kind: PrimitiveKind;
|
|
11
7
|
appId: string;
|
|
@@ -7,21 +7,7 @@ import { initCommand as processInitCommand, parseArgs } from '../process/command
|
|
|
7
7
|
import { agentsInitCommand } from '../agents/scaffold.js';
|
|
8
8
|
import { pipelineInitCommand } from '../pipeline/commands.js';
|
|
9
9
|
import { ormNamespaceFromAppId, titleizeSlug } from './manifest.js';
|
|
10
|
-
|
|
11
|
-
switch (kind) {
|
|
12
|
-
case 'orm':
|
|
13
|
-
return `${name}-orm`;
|
|
14
|
-
case 'artifact':
|
|
15
|
-
return `${name}-ui`;
|
|
16
|
-
case 'function':
|
|
17
|
-
return name;
|
|
18
|
-
case 'agent':
|
|
19
|
-
case 'process':
|
|
20
|
-
case 'pipeline':
|
|
21
|
-
case 'workspace':
|
|
22
|
-
return `${name}-${kind}`;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
10
|
+
import { primitiveIdFor } from './primitive-ids.js';
|
|
25
11
|
export function relativePathFor({ kind, appId, name, }) {
|
|
26
12
|
switch (kind) {
|
|
27
13
|
case 'orm':
|
|
@@ -53,8 +39,11 @@ function buildPrimitiveEntry({ kind, appId, name, dependsOn, }) {
|
|
|
53
39
|
return { ...base, project_id: name };
|
|
54
40
|
case 'workspace':
|
|
55
41
|
return { ...base, name };
|
|
56
|
-
case 'agent':
|
|
57
42
|
case 'process':
|
|
43
|
+
// `process init` names the scaffolded process after its directory. Naming it
|
|
44
|
+
// here gives CI one exact process to register as an Application member.
|
|
45
|
+
return { ...base, only: [name] };
|
|
46
|
+
case 'agent':
|
|
58
47
|
case 'pipeline':
|
|
59
48
|
return base;
|
|
60
49
|
}
|
|
@@ -87,8 +76,8 @@ async function scaffoldOrm({ absPath }) {
|
|
|
87
76
|
const code = await runOrmCommand('init', [absPath]);
|
|
88
77
|
if (code !== 0) {
|
|
89
78
|
throw new Error(`orm init failed for ${absPath} (exit ${code}). ` +
|
|
90
|
-
'`seq-studio init --with orm` requires `@sequenceholdings/orm` ' +
|
|
91
|
-
'(
|
|
79
|
+
'`seq-studio init --with orm` requires `@sequenceholdings/orm` installed alongside the CLI ' +
|
|
80
|
+
'(`pnpm add -D @sequenceholdings/orm` in your app, then `pnpm exec seq-studio`).');
|
|
92
81
|
}
|
|
93
82
|
}
|
|
94
83
|
async function scaffoldArtifact({ absPath, appId, template, }) {
|
package/dist/app/readme.js
CHANGED
|
@@ -65,6 +65,10 @@ ${description}
|
|
|
65
65
|
|
|
66
66
|
This repository is a **seq-studio app bundle**. Its root \`sequence.app.yml\` defines the app's deployable primitives, source locations, and deployment prerequisites. Keep this file, shared packages, primitive manifests, and the root lockfile together in Git.
|
|
67
67
|
|
|
68
|
+
A new scaffold uses schema version 3. After its primitives deploy successfully,
|
|
69
|
+
Atlas registers the app as a Builder Studio project. Scaffolding alone does not
|
|
70
|
+
create a visible project. Configure its roles and grants in Atlas after registration.
|
|
71
|
+
|
|
68
72
|
**Platform documentation:** ${docsLink({ atlasOrigin, label: 'Sequence Platform' })}
|
|
69
73
|
|
|
70
74
|
Documentation lives at \`/docs\` on the Atlas URL for your target environment. Find that URL with \`seq-studio envs list\` or ask your platform administrator; use it wherever \`<atlas-url>\` appears. The environment name is a CLI label, not a hostname. Keep the \`/docs/…\` path when switching environments.
|
|
@@ -108,27 +112,30 @@ seq-studio login --env <environment-name>
|
|
|
108
112
|
seq-studio doctor -e <environment-name>
|
|
109
113
|
\`\`\`
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
For a fullstack app, scaffold with \`seq-studio init <app> --
|
|
114
|
-
Its Next.js artifact uses Node.js 24 and a separate install root
|
|
115
|
-
|
|
116
|
-
\`
|
|
117
|
-
|
|
118
|
-
output for the managed runtime. Run \`seq-studio repos ci init\`, commit the generated
|
|
119
|
-
\`.seq/pipeline.yml\`, and open or update a pull request to run checks with the
|
|
120
|
-
platform's managed defaults. \`sequence.app.yml\` supplies the resource inventory;
|
|
121
|
-
the pipeline needs no image digest or manual branch policy. Inspect the plan with
|
|
122
|
-
\`seq-studio repos ci show <namespace>/<repo> -e <environment> --pr <number>\`.
|
|
123
|
-
Deployment still needs authorized resource bindings and native permissions.
|
|
115
|
+
\`seq-studio init\` runs \`pnpm install\` for you and generates the first ORM migration. Commit the generated root \`pnpm-lock.yaml\` and \`migrations/\`; CI uses \`pnpm install --frozen-lockfile\`. App scaffolding consolidates the standalone templates' install configuration at the root. The root workspace retains the seven-day dependency age gate and explicit build-script allowlist.
|
|
116
|
+
|
|
117
|
+
For a fullstack app, scaffold with \`seq-studio init <app> --template nextjs\`.
|
|
118
|
+
Its Next.js artifact uses Node.js 24 and a separate install root with its own
|
|
119
|
+
\`artifact/pnpm-lock.yaml\` (also generated by \`init\`). Keep its \`lint\`, \`type-check\`,
|
|
120
|
+
\`test\` and \`build\` scripts; repository CI runs them and an SSR/API smoke test before
|
|
121
|
+
packaging the standalone output for the managed runtime.
|
|
124
122
|
Build-time values belong in \`build.public_env\` and must use \`NEXT_PUBLIC_*\` names.
|
|
125
123
|
Server secrets and resource credentials are attached only at runtime.
|
|
126
124
|
|
|
125
|
+
## Ship it: pull request → checks → merge → live
|
|
126
|
+
|
|
127
|
+
Inside a git-service repository (\`seq-studio repos create\` turns on deploy-on-merge for \`main\`),
|
|
128
|
+
push a branch and open a pull request. Checks run automatically; the pull request lists
|
|
129
|
+
what merging will create or update. Merging to \`main\` creates any new ORM namespace,
|
|
130
|
+
function, artifact and Lattice process as the person who merges, then deploys every change.
|
|
131
|
+
Nothing needs configuring in repository settings. Inspect a plan with
|
|
132
|
+
\`seq-studio repos ci show <namespace>/<repo> -e <environment> --pr <number>\`.
|
|
133
|
+
|
|
127
134
|
Use the environment name your administrator supplies. \`local\` means a real Atlas server at \`http://localhost:5001\`, not a standalone Vite server. Login proves identity; resource permissions are still required. ORM and pipeline commands require the matching \`@sequenceholdings/orm\` / \`@sequenceholdings/pipeline-spec\` SDK installed alongside the CLI.
|
|
128
135
|
|
|
129
136
|
## Shared packages
|
|
130
137
|
|
|
131
|
-
Export common types, validation, and helpers from \`packages/shared/src/index.ts\`.
|
|
138
|
+
Export common types, validation, and helpers from \`packages/shared/src/index.ts\`. Artifacts and processes depend on \`@${input.appId}/shared\` through \`workspace:*\`; ordinary imports work across the app. A function's dependencies ship as-is and a deployed bundle cannot follow a \`workspace:*\` link, so functions don't get one by default:
|
|
132
139
|
|
|
133
140
|
\`\`\`ts
|
|
134
141
|
import { /* your exports */ } from '@${input.appId}/shared'
|
|
@@ -155,9 +162,9 @@ seq-studio add agent reviewer
|
|
|
155
162
|
seq-studio add process approvals --depends-on reviewer-agent
|
|
156
163
|
\`\`\`
|
|
157
164
|
|
|
158
|
-
|
|
165
|
+
Versions 2 and 3 derive a deterministic order from this graph. An optional \`deploy.order\` only prioritizes primitives whose prerequisites are ready. \`--only <id>\` includes that primitive's prerequisites. \`deploy.on_error: stop\` stops on failure; \`continue\` runs independent primitives and skips dependents of failed or skipped prerequisites. Deployment is not an atomic transaction: already successful primitives remain deployed if a later one fails. Removing an entry does not delete its deployed resource.
|
|
159
166
|
|
|
160
|
-
|
|
167
|
+
Versions 2 and 3 validate and compile the selected sources before deployment. Pipeline preflight reads the remote repository and pins its commit, so its dry run requires network access and authentication. Results are saved under \`.sequence/deployments/<encoded-env>.json\`.
|
|
161
168
|
|
|
162
169
|
Review and deploy from this directory:
|
|
163
170
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const REPOSITORY_INDEX_PATH = ".seq/repository.yml";
|
|
2
|
+
/** One write to perform after the scaffold succeeds; validated before it starts. */
|
|
3
|
+
export interface RepositoryDeclaration {
|
|
4
|
+
indexPath: string;
|
|
5
|
+
appPath: string;
|
|
6
|
+
content: string;
|
|
7
|
+
created: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Plan the index change for an app about to be scaffolded at `appRoot`.
|
|
11
|
+
* Returns null when nothing needs declaring: no enclosing git repository, an
|
|
12
|
+
* app at the root of a repository without an index, or an app already listed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function planRepositoryDeclaration({ appRoot }: {
|
|
15
|
+
appRoot: string;
|
|
16
|
+
}): Promise<RepositoryDeclaration | null>;
|
|
17
|
+
export declare function writeRepositoryDeclaration({ declaration }: {
|
|
18
|
+
declaration: RepositoryDeclaration;
|
|
19
|
+
}): Promise<void>;
|