@sequenceholdings/studio-cli 0.5.1 → 0.5.3
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 +103 -38
- package/dist/agents/apply-chunks.d.ts +5 -1
- package/dist/agents/apply-chunks.js +4 -4
- package/dist/agents/commands.d.ts +10 -1
- package/dist/agents/commands.js +19 -2
- package/dist/app/adapters.d.ts +2 -2
- package/dist/app/adapters.js +18 -15
- package/dist/app/commands.d.ts +1 -1
- package/dist/app/commands.js +58 -20
- 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 +17 -14
- 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 +31 -18
- 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/auth.d.ts +17 -0
- package/dist/auth.js +29 -0
- 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.js +6 -1
- package/dist/orm/delegate.js +5 -2
- package/dist/pipeline/clone-deploy.d.ts +1 -1
- package/dist/pipeline/clone-deploy.js +3 -2
- package/dist/pipeline/commands.js +3 -2
- package/dist/process/commands.d.ts +6 -3
- package/dist/process/commands.js +26 -10
- package/dist/repos/commands.js +1 -1
- package/dist/repos/pulls.d.ts +19 -1
- package/dist/repos/pulls.js +15 -2
- package/dist/templates/process/example-process/process.ts +20 -24
- package/dist/templates/process/package.json +1 -1
- package/package.json +8 -7
- package/templates/process/example-process/process.ts +20 -24
- package/templates/process/package.json +1 -1
package/dist/app/commands.js
CHANGED
|
@@ -8,41 +8,52 @@ 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> --orm --function --artifact [options]
|
|
19
21
|
seq-studio init <dir> --template <name>@<version> -e <deployment>
|
|
20
22
|
|
|
21
23
|
Scaffold an app monorepo with ${APP_MANIFEST_FILENAME}, a Sequence app
|
|
22
24
|
README.md, AGENTS.md + CLAUDE.md guidance, and one subfolder per
|
|
23
|
-
selected primitive.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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.
|
|
28
34
|
|
|
29
35
|
Kinds: ${PRIMITIVE_KINDS.join(', ')}
|
|
30
36
|
|
|
31
37
|
Options:
|
|
32
|
-
--
|
|
33
|
-
-e, --env <name> registered deployment whose template catalog to read
|
|
34
|
-
--with <k1,k2,…> comma-separated kinds to scaffold
|
|
38
|
+
--with <k1,k2,…> comma-separated kinds to scaffold (default: ${DEFAULT_APP_KINDS.join(',')})
|
|
35
39
|
--orm --function … boolean aliases for --with
|
|
36
40
|
--function-name <n> name/slug for the first function (default: hello)
|
|
37
41
|
--pipeline-type <t> ingestion, transformation (default), or serving
|
|
38
|
-
--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
|
|
39
46
|
--description <text> optional app.description in the manifest
|
|
47
|
+
--skip-install skip pnpm install and ORM migration authoring (offline)
|
|
40
48
|
|
|
41
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
|
|
42
53
|
seq-studio init pokedex --with orm,function,artifact
|
|
43
54
|
seq-studio init pokedex --with orm,function,artifact --function-name get-pokemon
|
|
44
55
|
seq-studio init loan-tools --with function --function-name get-loan
|
|
45
|
-
|
|
56
|
+
seq-studio init review-app --with orm,function,agent,process,pipeline,artifact
|
|
46
57
|
seq-studio init review-app --template full-stack@1.0.0 -e banksouth-mortgage
|
|
47
58
|
`;
|
|
48
59
|
export const APP_ADD_USAGE = `usage:
|
|
@@ -79,7 +90,7 @@ export const APP_DEPLOY_USAGE = `usage:
|
|
|
79
90
|
Runs each kind's existing command:
|
|
80
91
|
orm → seq-studio orm apply <path> -e <env>
|
|
81
92
|
function → seq-studio functions deploy --dir <path> -e <env> [--yes]
|
|
82
|
-
agent → seq-studio agents apply --dir <path> -e <env> [--yes]
|
|
93
|
+
agent → seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)
|
|
83
94
|
process → seq-studio process apply --dir <path> -e <env>
|
|
84
95
|
pipeline → seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>
|
|
85
96
|
artifact → seq-studio artifact deploy <path> -e <env>
|
|
@@ -106,6 +117,9 @@ export const APP_DEPLOY_USAGE = `usage:
|
|
|
106
117
|
Commit generated migrations before the first deployment and schema changes.
|
|
107
118
|
Pipeline preflight reads the remote source and pins its commit; dry-run
|
|
108
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.
|
|
109
123
|
Version 2 writes the result to .sequence/deployments/<environment>.json.
|
|
110
124
|
`;
|
|
111
125
|
function pipelineTypeFlag(flags) {
|
|
@@ -150,7 +164,7 @@ export async function runAppInitCommand(args) {
|
|
|
150
164
|
return 1;
|
|
151
165
|
}
|
|
152
166
|
const artifactTemplate = args.flags.template === 'react-vite' || args.flags.template === 'nextjs';
|
|
153
|
-
if (args.flags.template !== undefined && !
|
|
167
|
+
if (args.flags.template !== undefined && !artifactTemplate) {
|
|
154
168
|
try {
|
|
155
169
|
if (args.flags.template === true)
|
|
156
170
|
throw new Error('--template requires <name>@<version>.');
|
|
@@ -168,9 +182,10 @@ export async function runAppInitCommand(args) {
|
|
|
168
182
|
return 1;
|
|
169
183
|
}
|
|
170
184
|
}
|
|
171
|
-
if (kinds.length === 0)
|
|
172
|
-
|
|
173
|
-
|
|
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`);
|
|
174
189
|
return 1;
|
|
175
190
|
}
|
|
176
191
|
const appRoot = resolve(target);
|
|
@@ -192,8 +207,11 @@ export async function runAppInitCommand(args) {
|
|
|
192
207
|
console.error(`${LOG} --description requires a value`);
|
|
193
208
|
return 1;
|
|
194
209
|
}
|
|
210
|
+
let manifest;
|
|
195
211
|
try {
|
|
196
|
-
|
|
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({
|
|
197
215
|
rootDir: appRoot,
|
|
198
216
|
appId,
|
|
199
217
|
kinds,
|
|
@@ -202,13 +220,33 @@ export async function runAppInitCommand(args) {
|
|
|
202
220
|
pipelineType: pipelineTypeFlag(args.flags),
|
|
203
221
|
artifactTemplate: artifactTemplateFlag({ flags: args.flags, kinds }),
|
|
204
222
|
});
|
|
205
|
-
|
|
206
|
-
|
|
223
|
+
if (declaration) {
|
|
224
|
+
await writeRepositoryDeclaration({ declaration });
|
|
225
|
+
console.log(`${LOG} ${declaration.created ? 'created' : 'updated'} ${REPOSITORY_INDEX_PATH} to declare ${declaration.appPath}`);
|
|
226
|
+
}
|
|
207
227
|
}
|
|
208
228
|
catch (error) {
|
|
209
229
|
printError(error);
|
|
210
230
|
return 1;
|
|
211
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
|
+
}
|
|
212
250
|
}
|
|
213
251
|
export async function runAppAddCommand({ kindArg, args, }) {
|
|
214
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
|
@@ -112,27 +112,30 @@ seq-studio login --env <environment-name>
|
|
|
112
112
|
seq-studio doctor -e <environment-name>
|
|
113
113
|
\`\`\`
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
For a fullstack app, scaffold with \`seq-studio init <app> --
|
|
118
|
-
Its Next.js artifact uses Node.js 24 and a separate install root
|
|
119
|
-
|
|
120
|
-
\`
|
|
121
|
-
|
|
122
|
-
output for the managed runtime. Run \`seq-studio repos ci init\`, commit the generated
|
|
123
|
-
\`.seq/pipeline.yml\`, and open or update a pull request to run checks with the
|
|
124
|
-
platform's managed defaults. \`sequence.app.yml\` supplies the resource inventory;
|
|
125
|
-
the pipeline needs no image digest or manual branch policy. Inspect the plan with
|
|
126
|
-
\`seq-studio repos ci show <namespace>/<repo> -e <environment> --pr <number>\`.
|
|
127
|
-
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.
|
|
128
122
|
Build-time values belong in \`build.public_env\` and must use \`NEXT_PUBLIC_*\` names.
|
|
129
123
|
Server secrets and resource credentials are attached only at runtime.
|
|
130
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
|
+
|
|
131
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.
|
|
132
135
|
|
|
133
136
|
## Shared packages
|
|
134
137
|
|
|
135
|
-
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:
|
|
136
139
|
|
|
137
140
|
\`\`\`ts
|
|
138
141
|
import { /* your exports */ } from '@${input.appId}/shared'
|
|
@@ -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>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declare a newly scaffolded app in its git repository's `.seq/repository.yml`,
|
|
3
|
+
* so repository CI checks and deploys it. CI treats an undeclared
|
|
4
|
+
* `sequence.app.yml` in an indexed repository as an error, and a repository
|
|
5
|
+
* without an index only reads a root manifest.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
10
|
+
import { isSeq, parseDocument } from 'yaml';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { APP_MANIFEST_FILENAME } from './manifest.js';
|
|
13
|
+
export const REPOSITORY_INDEX_PATH = '.seq/repository.yml';
|
|
14
|
+
const indexSchema = z.looseObject({
|
|
15
|
+
schema_version: z.literal(1),
|
|
16
|
+
applications: z.array(z.looseObject({ path: z.string().min(1) })).nullish(),
|
|
17
|
+
ignore: z.array(z.string().min(1)).nullish(),
|
|
18
|
+
});
|
|
19
|
+
function findGitRoot(start) {
|
|
20
|
+
for (let directory = resolve(start);; directory = dirname(directory)) {
|
|
21
|
+
if (existsSync(join(directory, '.git')))
|
|
22
|
+
return directory;
|
|
23
|
+
if (dirname(directory) === directory)
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Same containment rule as repository CI: equal, or a descendant of a non-root path. */
|
|
28
|
+
function under({ path, root }) {
|
|
29
|
+
return root === '.' || path === root || path.startsWith(`${root}/`);
|
|
30
|
+
}
|
|
31
|
+
const NEW_INDEX_HEADER = '# Repository CI checks every application listed here and deploys it when changes merge to main.\n';
|
|
32
|
+
/**
|
|
33
|
+
* Plan the index change for an app about to be scaffolded at `appRoot`.
|
|
34
|
+
* Returns null when nothing needs declaring: no enclosing git repository, an
|
|
35
|
+
* app at the root of a repository without an index, or an app already listed.
|
|
36
|
+
*/
|
|
37
|
+
export async function planRepositoryDeclaration({ appRoot }) {
|
|
38
|
+
const gitRoot = findGitRoot(appRoot);
|
|
39
|
+
if (gitRoot === null)
|
|
40
|
+
return null;
|
|
41
|
+
const appPath = relative(gitRoot, resolve(appRoot)).split(sep).join('/') || '.';
|
|
42
|
+
if (appPath.startsWith('..'))
|
|
43
|
+
return null;
|
|
44
|
+
const indexPath = join(gitRoot, REPOSITORY_INDEX_PATH);
|
|
45
|
+
if (!existsSync(indexPath)) {
|
|
46
|
+
if (appPath === '.')
|
|
47
|
+
return null;
|
|
48
|
+
const applications = [
|
|
49
|
+
...(existsSync(join(gitRoot, APP_MANIFEST_FILENAME)) ? ['.'] : []),
|
|
50
|
+
appPath,
|
|
51
|
+
];
|
|
52
|
+
const content = `${NEW_INDEX_HEADER}schema_version: 1\napplications:\n${applications.map((path) => ` - path: ${path}\n`).join('')}`;
|
|
53
|
+
return { indexPath, appPath, content, created: true };
|
|
54
|
+
}
|
|
55
|
+
const text = await readFile(indexPath, 'utf8');
|
|
56
|
+
const document = parseDocument(text);
|
|
57
|
+
if (document.errors.length > 0) {
|
|
58
|
+
throw new Error(`${REPOSITORY_INDEX_PATH} is not valid YAML: ${document.errors[0]?.message ?? 'parse error'}`);
|
|
59
|
+
}
|
|
60
|
+
const parsed = indexSchema.safeParse(document.toJS());
|
|
61
|
+
if (!parsed.success) {
|
|
62
|
+
throw new Error(`${REPOSITORY_INDEX_PATH} is not a schema_version 1 repository index; fix it before adding ${appPath}`);
|
|
63
|
+
}
|
|
64
|
+
const existing = (parsed.data.applications ?? []).map((application) => application.path);
|
|
65
|
+
if (existing.includes(appPath))
|
|
66
|
+
return null;
|
|
67
|
+
const ignored = (parsed.data.ignore ?? []).find((path) => under({ path: appPath, root: path }) || under({ path, root: appPath }));
|
|
68
|
+
if (ignored !== undefined) {
|
|
69
|
+
throw new Error(`${REPOSITORY_INDEX_PATH} ignores "${ignored}", which overlaps ${appPath}; remove that ignore entry or scaffold somewhere else`);
|
|
70
|
+
}
|
|
71
|
+
const enclosing = existing.find((path) => path !== '.' && under({ path: appPath, root: path }));
|
|
72
|
+
if (enclosing !== undefined) {
|
|
73
|
+
throw new Error(`${appPath} is inside the declared application ${enclosing}; scaffold a new app beside it, or use \`seq-studio add\` inside it`);
|
|
74
|
+
}
|
|
75
|
+
// The schema above admits only a list or an empty value here.
|
|
76
|
+
const applications = document.get('applications');
|
|
77
|
+
if (isSeq(applications))
|
|
78
|
+
applications.add(document.createNode({ path: appPath }));
|
|
79
|
+
else
|
|
80
|
+
document.set('applications', [{ path: appPath }]);
|
|
81
|
+
return { indexPath, appPath, content: document.toString(), created: false };
|
|
82
|
+
}
|
|
83
|
+
export async function writeRepositoryDeclaration({ declaration }) {
|
|
84
|
+
await mkdir(dirname(declaration.indexPath), { recursive: true });
|
|
85
|
+
await writeFile(declaration.indexPath, declaration.content, 'utf8');
|
|
86
|
+
}
|