@sequenceholdings/studio-cli 0.9.21 → 0.9.22
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 +29 -2
- package/dist/app/commands.js +35 -7
- package/dist/app/scaffold.d.ts +3 -1
- package/dist/app/scaffold.js +5 -3
- package/dist/repos/github-init-command.d.ts +11 -0
- package/dist/repos/github-init-command.js +28 -18
- package/dist/repos/github-init.d.ts +14 -1
- package/dist/repos/github-init.js +92 -2
- package/dist/repos/init-github.d.ts +50 -0
- package/dist/repos/init-github.js +181 -0
- package/dist/repos/pulls.d.ts +5 -1
- package/dist/repos/pulls.js +31 -9
- package/dist/templates/github/pr-type.mjs +285 -0
- package/dist/templates/github/pr-types.json +40 -0
- package/package.json +3 -3
- package/release-summary.json +2 -1
- package/templates/github/pr-type.mjs +285 -0
- package/templates/github/pr-types.json +40 -0
package/README.md
CHANGED
|
@@ -2264,6 +2264,31 @@ a human identity or extend a human login's expiry.
|
|
|
2264
2264
|
Add `--help` to a repo command to read its usage offline, without an
|
|
2265
2265
|
environment or credentials.
|
|
2266
2266
|
|
|
2267
|
+
### Start an app in a new GitHub repository (`init --github`)
|
|
2268
|
+
|
|
2269
|
+
`seq-studio init <dir> --github <owner>/<name> --org <org>` starts an app in its own new private GitHub repository, ready
|
|
2270
|
+
for seq-ci, in one step:
|
|
2271
|
+
|
|
2272
|
+
1. checks that `gh` is installed and signed in, `<owner>/<name>` doesn't exist yet, and `<dir>` is new or empty and
|
|
2273
|
+
not inside another Git checkout;
|
|
2274
|
+
2. `git init`s `<dir>` on the release branch and scaffolds the app into it (the same scaffold as `init`, including
|
|
2275
|
+
`--with` and the other scaffold options);
|
|
2276
|
+
3. creates the repository with `gh repo create --private` (only after the scaffold succeeded) and sets it as `origin`;
|
|
2277
|
+
4. writes the files of `repo init` below for `--org`, with `--dev`/`--release` branches if given.
|
|
2278
|
+
|
|
2279
|
+
```bash
|
|
2280
|
+
seq-studio init loan-tools --github my-org/loan-tools --org <org> -e <env>
|
|
2281
|
+
```
|
|
2282
|
+
|
|
2283
|
+
Nothing is committed or pushed: it prints the commands to commit, push both branches, apply the branch rulesets
|
|
2284
|
+
(`repo init --apply-github`, or pass `--apply-github` to `init` to do it in the same step) and `repo connect` each
|
|
2285
|
+
stage. `-e` only fills in those printed `repo connect` lines.
|
|
2286
|
+
|
|
2287
|
+
Creating a repository is opt-in. Without `--github` (or `--repo` for a platform git-service repository), `init`
|
|
2288
|
+
creates no repository, so an app that belongs in an existing repository is scaffolded into it with plain
|
|
2289
|
+
`seq-studio init <subdir>`. `--github` inside an existing checkout is refused for the same reason; use `repo init` to
|
|
2290
|
+
set up an existing GitHub checkout.
|
|
2291
|
+
|
|
2267
2292
|
### Set up a GitHub repository (`repo init`)
|
|
2268
2293
|
|
|
2269
2294
|
`seq-studio repo init --org <org>` makes a GitHub checkout a Sequence repository. It writes, and afterwards manages:
|
|
@@ -2275,8 +2300,9 @@ environment or credentials.
|
|
|
2275
2300
|
| `.github/workflows/seq-promote.yml` | The Promote button that fast-forwards the release branch |
|
|
2276
2301
|
| `renovate.json` | Keeps the `seq-ci` release and CLI pin current |
|
|
2277
2302
|
| `.claude/skills/sequence-platform/SKILL.md` | Points agents at the platform docs; `AGENTS.md` gets a one-line pointer |
|
|
2303
|
+
| `.github/workflows/seq-pr-type.yml`, `.github/scripts/seq-pr-type.mjs`, `.github/pr-types.json` | The `pr-type` check: every pull request needs exactly one `type: bug`, `type: performance`, `type: enhancement`, `type: feature` or `type: chore` label. With no label it asks Claude to pick one when the repository can read an `ANTHROPIC_API_KEY` secret, and otherwise fails naming the labels to add. A push of `.github/pr-types.json` to the dev branch creates the labels |
|
|
2278
2304
|
|
|
2279
|
-
It writes only what's missing or stale and never overwrites a file it doesn't manage. `--check` reports the same and writes nothing (exit 3 when anything is missing or stale). Rerunning keeps the existing org and branches. Branch rulesets (`seq / checks` required on the dev branch; the release branch updatable only by the Sequence CI GitHub App, which Promote pushes as) and secret scanning need admin rights on the repository, which its creator has; no org owner is needed. `--apply-github` applies them with `gh` and confirms the repository can read seq-ci's `SEQ_CI_*` org secrets (`SEQ_CI_IMAGE_PULL_KEY`, the read-only key that pulls seq-ci's images, and `SEQ_CI_REGISTRY_AUTH`, a read-only dependency-registry pull token). Both are visible to every private repository in the org, as the Sequence CI App is installed on every repository. If an org owner has narrowed either to selected repositories, an owner's `--apply-github` (`gh auth refresh -s admin:org`) adds the repository. Anyone else gets an error naming the secret, and exit 1. Otherwise the ruleset commands are printed for an admin. Commit and push the files yourself.
|
|
2305
|
+
It writes only what's missing or stale and never overwrites a file it doesn't manage. `--check` reports the same and writes nothing (exit 3 when anything is missing or stale). Rerunning keeps the existing org and branches. Branch rulesets (`seq / checks` and `pr-type` required on the dev branch; the release branch updatable only by the Sequence CI GitHub App, which Promote pushes as) and secret scanning need admin rights on the repository, which its creator has; no org owner is needed. `--apply-github` applies them with `gh` and confirms the repository can read seq-ci's `SEQ_CI_*` org secrets (`SEQ_CI_IMAGE_PULL_KEY`, the read-only key that pulls seq-ci's images, and `SEQ_CI_REGISTRY_AUTH`, a read-only dependency-registry pull token). Both are visible to every private repository in the org, as the Sequence CI App is installed on every repository. If an org owner has narrowed either to selected repositories, an owner's `--apply-github` (`gh auth refresh -s admin:org`) adds the repository. Anyone else gets an error naming the secret, and exit 1. Otherwise the ruleset commands are printed for an admin. Commit and push the files yourself.
|
|
2280
2306
|
|
|
2281
2307
|
### Deploy a GitHub repository (`repo connect`, `repo status`)
|
|
2282
2308
|
|
|
@@ -3517,7 +3543,8 @@ on deployment. These operations do not issue credentials.
|
|
|
3517
3543
|
### Repository Pulls
|
|
3518
3544
|
|
|
3519
3545
|
```bash
|
|
3520
|
-
seq-studio repos pulls create <namespace/name> --head <branch> --base main --title "Build task app" --body-file review.md -e <env>
|
|
3546
|
+
seq-studio repos pulls create <namespace/name> --head <branch> --base main --title "Build task app" --body-file review.md --type feature -e <env>
|
|
3547
|
+
seq-studio repos pulls edit <namespace/name> <number> --type bug -e <env>
|
|
3521
3548
|
seq-studio repos pulls list <namespace/name> --state open -e <env>
|
|
3522
3549
|
seq-studio repos pulls show <namespace/name> <number> -e <env>
|
|
3523
3550
|
seq-studio repos pulls diff <namespace/name> <number> -e <env>
|
package/dist/app/commands.js
CHANGED
|
@@ -51,10 +51,20 @@ export const APP_INIT_USAGE = `usage:
|
|
|
51
51
|
missing: clone it into <dir>, or set it as origin when
|
|
52
52
|
<dir> is inside a Git checkout. Needs -e (or an agent
|
|
53
53
|
sandbox). Prints the commit and push commands.
|
|
54
|
+
--github <owner>/<name>
|
|
55
|
+
start the app in its own new private GitHub repository:
|
|
56
|
+
creates it with gh (signed in), git-inits <dir> (new or
|
|
57
|
+
empty, not inside a checkout), scaffolds, sets origin and
|
|
58
|
+
writes the seq-ci files of seq-studio repo init. Needs
|
|
59
|
+
--org <org> (the Sequence org it deploys for). Optional
|
|
60
|
+
--dev/--release branches and --apply-github (rulesets).
|
|
61
|
+
Without --github or --repo no repository is created, so
|
|
62
|
+
an app inside an existing repository stays in it.
|
|
54
63
|
|
|
55
64
|
Examples:
|
|
56
65
|
seq-studio init pokedex
|
|
57
66
|
seq-studio init pokedex --repo apps/pokedex -e staging
|
|
67
|
+
seq-studio init pokedex --github my-org/pokedex --org acme
|
|
58
68
|
seq-studio init . --template nextjs
|
|
59
69
|
seq-studio init reports # a new app inside an existing repository
|
|
60
70
|
seq-studio init pokedex --with orm,function,artifact
|
|
@@ -236,8 +246,27 @@ function publishedTemplateRequest({ flags, kinds }) {
|
|
|
236
246
|
export async function runAppInitCommand(args) {
|
|
237
247
|
return initApp({ args, intoCheckout: false });
|
|
238
248
|
}
|
|
239
|
-
/**
|
|
240
|
-
|
|
249
|
+
/**
|
|
250
|
+
* `--github` (a new GitHub repository) or `--repo` (a git-service repository): prepare the checkout, then scaffold
|
|
251
|
+
* into it. Undefined when neither flag is given, so the app is scaffolded where it is, inside any existing repository.
|
|
252
|
+
*/
|
|
253
|
+
async function initIntoRepository({ args, target }) {
|
|
254
|
+
if (args.flags.github !== undefined) {
|
|
255
|
+
const { runInitWithGitHub, withoutGitHubFlags } = await import('../repos/init-github.js');
|
|
256
|
+
return runInitWithGitHub({
|
|
257
|
+
args,
|
|
258
|
+
target,
|
|
259
|
+
scaffold: (root) => initApp({ args: { ...withoutGitHubFlags(args), positional: [root] }, intoCheckout: true, githubSteps: true }),
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (args.flags.repo !== undefined) {
|
|
263
|
+
const { runInitWithRepo, withoutRepoFlag } = await import('../repos/init-repo.js');
|
|
264
|
+
return runInitWithRepo({ args, target, scaffold: () => initApp({ args: withoutRepoFlag(args), intoCheckout: true }) });
|
|
265
|
+
}
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
/** `intoCheckout`: the target is the checkout `--repo` or `--github` just prepared. */
|
|
269
|
+
async function initApp({ args, intoCheckout, githubSteps }) {
|
|
241
270
|
if (args.flags.help === true || args.flags.h === true) {
|
|
242
271
|
console.log(APP_INIT_USAGE);
|
|
243
272
|
return 0;
|
|
@@ -258,10 +287,9 @@ async function initApp({ args, intoCheckout }) {
|
|
|
258
287
|
console.error(APP_INIT_USAGE);
|
|
259
288
|
return 1;
|
|
260
289
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return
|
|
264
|
-
}
|
|
290
|
+
const intoRepository = await initIntoRepository({ args, target });
|
|
291
|
+
if (intoRepository !== undefined)
|
|
292
|
+
return intoRepository;
|
|
265
293
|
if (published) {
|
|
266
294
|
try {
|
|
267
295
|
const { initFromTemplate } = await import('../templates/commands.js');
|
|
@@ -321,7 +349,7 @@ async function initApp({ args, intoCheckout }) {
|
|
|
321
349
|
return 1;
|
|
322
350
|
}
|
|
323
351
|
const prepared = args.flags['skip-install'] === true ? false : await prepareApp({ appRoot, manifest });
|
|
324
|
-
printInitNextSteps({ appRoot, manifest, prepared });
|
|
352
|
+
printInitNextSteps({ appRoot, manifest, prepared, githubSteps });
|
|
325
353
|
return prepared === 'failed' ? 1 : 0;
|
|
326
354
|
}
|
|
327
355
|
async function prepareApp({ appRoot, manifest }) {
|
package/dist/app/scaffold.d.ts
CHANGED
|
@@ -41,9 +41,11 @@ export declare function firstMissingDirectory({ appRoot, absPath }: {
|
|
|
41
41
|
export declare function printOrmPreparation({ primitives }: {
|
|
42
42
|
primitives: readonly PrimitiveEntry[];
|
|
43
43
|
}): void;
|
|
44
|
-
export declare function printInitNextSteps({ appRoot, manifest, prepared, }: {
|
|
44
|
+
export declare function printInitNextSteps({ appRoot, manifest, prepared, githubSteps, }: {
|
|
45
45
|
appRoot: string;
|
|
46
46
|
manifest: AppManifest;
|
|
47
47
|
/** true: dependencies installed and migrations authored; false: skipped; 'failed': partly done. */
|
|
48
48
|
prepared: boolean | 'failed';
|
|
49
|
+
/** `init --github` prints its own repository steps after these. */
|
|
50
|
+
githubSteps?: boolean;
|
|
49
51
|
}): void;
|
package/dist/app/scaffold.js
CHANGED
|
@@ -189,7 +189,7 @@ export function printOrmPreparation({ primitives }) {
|
|
|
189
189
|
console.log(` # review and commit ${entry.path}/migrations/ before deploying`);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
export function printInitNextSteps({ appRoot, manifest, prepared, }) {
|
|
192
|
+
export function printInitNextSteps({ appRoot, manifest, prepared, githubSteps = false, }) {
|
|
193
193
|
const rel = relative(process.cwd(), appRoot);
|
|
194
194
|
const display = !rel || rel.startsWith('..') ? appRoot : rel;
|
|
195
195
|
console.log(`${LOG} scaffolded app "${manifest.app.id}" in ${display}`);
|
|
@@ -208,8 +208,10 @@ export function printInitNextSteps({ appRoot, manifest, prepared, }) {
|
|
|
208
208
|
console.log(' pnpm install');
|
|
209
209
|
printOrmPreparation({ primitives: manifest.primitives });
|
|
210
210
|
}
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
if (!githubSteps) {
|
|
212
|
+
console.log(' Push a branch and open a PR; checks run automatically, and merging to main publishes the app.');
|
|
213
|
+
console.log(` No repository yet? seq-studio repos create <namespace>/${manifest.app.id} -e <env> (your team's namespace), or seq-studio init <dir> --github <owner>/<name> --org <org> for a new GitHub repository.`);
|
|
214
|
+
}
|
|
213
215
|
console.log(' # add another primitive later:');
|
|
214
216
|
console.log(' seq-studio add function list-types');
|
|
215
217
|
console.log(' seq-studio add package contracts');
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { ParsedArgs } from '../argv.js';
|
|
2
|
+
import { type GitHubApi, type GitHubSettings } from './github-init.js';
|
|
2
3
|
export declare const REPO_INIT_USAGE = "usage:\n seq-studio repo init [--org <org>] [--dev <branch>] [--release <branch>] [--seq-ci <vX.Y.Z>] [--release-repository <namespace/name>]\n [--pull-request-builds reuse|rebuild] [--dir <checkout>] [--apply-github] [--json]\n seq-studio repo init --check [--dir <checkout>] [--json]\n\n Make a GitHub checkout a Sequence repository: .seq/github.yml (org and branches), the seq and seq promote\n workflows, Renovate config, and an agent skill pointing at the platform docs. Writes only what's missing or\n stale, and never overwrites a file it doesn't manage. --check reports the same and writes nothing (exit 3 when\n anything is missing or stale).\n\n Branch rulesets and secret scanning need admin rights on the repository (not the org): --apply-github runs them\n with gh and confirms the repository can read seq-ci's org secrets; without it, the gh commands are printed for an\n admin. Commit and push the written files yourself.\n\n --pull-request-builds (default reuse): whether the dev branch's deploys reuse what a pull request's CI built and\n checked from the change it merged. Sound only while the dev branch needs no approvals, as these rulesets set it;\n once reviews are required, use rebuild. repo connect --stage staging records it on the Atlas.";
|
|
3
4
|
/** `org/name` from a github.com origin, or null when the origin is elsewhere. */
|
|
4
5
|
export declare function githubRepositoryFromRemote(url: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Apply the branch rulesets and secret scanning with `gh`, and check that the repository can use seq-ci. Shared by
|
|
8
|
+
* `repo init --apply-github` and `init --github --apply-github`; returns the exit code.
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyGitHubSettingsWithReport({ repository, settings, say, api }: {
|
|
11
|
+
repository: string;
|
|
12
|
+
settings: GitHubSettings;
|
|
13
|
+
say: (text: string) => void;
|
|
14
|
+
api?: GitHubApi;
|
|
15
|
+
}): Promise<number>;
|
|
5
16
|
export declare function runRepoInitCommand(args: ParsedArgs): Promise<number>;
|
|
@@ -49,6 +49,31 @@ function printReports(reports) {
|
|
|
49
49
|
process.stdout.write(` ${report.status.padEnd(9)} ${report.path}${note}\n`);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Apply the branch rulesets and secret scanning with `gh`, and check that the repository can use seq-ci. Shared by
|
|
54
|
+
* `repo init --apply-github` and `init --github --apply-github`; returns the exit code.
|
|
55
|
+
*/
|
|
56
|
+
export async function applyGitHubSettingsWithReport({ repository, settings, say, api = ghApi }) {
|
|
57
|
+
try {
|
|
58
|
+
const applied = await applyGitHubSettings({ repository, settings, api });
|
|
59
|
+
say(`Branch rulesets: created ${applied.created.join(', ') || 'none'}; updated ${applied.updated.join(', ') || 'none'}; the Sequence CI App bypasses ${settings.branches.release}. Secret scanning on.\n`);
|
|
60
|
+
const org = repository.split('/')[0];
|
|
61
|
+
const seqCi = await ensureSeqCi({ repository, api });
|
|
62
|
+
if (seqCi.secrets.shared.length > 0)
|
|
63
|
+
say(`seq-ci org secrets available: ${seqCi.secrets.shared.join(', ')}.\n`);
|
|
64
|
+
say(INSTALLATION_NOTES[seqCi.installation](org));
|
|
65
|
+
if (seqCi.secrets.missing.length > 0) {
|
|
66
|
+
process.stderr.write(`${repository} can't read ${seqCi.secrets.missing.join(', ')}, so seq-ci will fail. An ${org} org owner must make ` +
|
|
67
|
+
`${seqCi.secrets.missing.length === 1 ? 'it' : 'them'} visible to all private repositories (Settings → Secrets and variables → Actions), then rerun.\n`);
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
process.stderr.write(`GitHub settings failed (admin rights needed?): ${error instanceof Error ? error.message : String(error)}\n`);
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
52
77
|
export async function runRepoInitCommand(args) {
|
|
53
78
|
if (args.flags.help) {
|
|
54
79
|
process.stdout.write(`${REPO_INIT_USAGE}\n`);
|
|
@@ -78,24 +103,9 @@ export async function runRepoInitCommand(args) {
|
|
|
78
103
|
return 0;
|
|
79
104
|
}
|
|
80
105
|
if (args.flags['apply-github'] === true) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const org = repository.split('/')[0];
|
|
85
|
-
const seqCi = await ensureSeqCi({ repository, api: ghApi });
|
|
86
|
-
if (seqCi.secrets.shared.length > 0)
|
|
87
|
-
say(`seq-ci org secrets available: ${seqCi.secrets.shared.join(', ')}.\n`);
|
|
88
|
-
say(INSTALLATION_NOTES[seqCi.installation](org));
|
|
89
|
-
if (seqCi.secrets.missing.length > 0) {
|
|
90
|
-
process.stderr.write(`${repository} can't read ${seqCi.secrets.missing.join(', ')}, so seq-ci will fail. An ${org} org owner must make ` +
|
|
91
|
-
`${seqCi.secrets.missing.length === 1 ? 'it' : 'them'} visible to all private repositories (Settings → Secrets and variables → Actions), then rerun.\n`);
|
|
92
|
-
return 1;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
process.stderr.write(`GitHub settings failed (admin rights needed?): ${error instanceof Error ? error.message : String(error)}\n`);
|
|
97
|
-
return 1;
|
|
98
|
-
}
|
|
106
|
+
const code = await applyGitHubSettingsWithReport({ repository, settings, say });
|
|
107
|
+
if (code !== 0)
|
|
108
|
+
return code;
|
|
99
109
|
}
|
|
100
110
|
else {
|
|
101
111
|
say('\nGitHub settings (need admin rights): rerun with --apply-github, or have an admin run:\n');
|
|
@@ -36,6 +36,19 @@ export declare function renovateConfig(): string;
|
|
|
36
36
|
export declare function agentSkill({ settings }: {
|
|
37
37
|
settings: GitHubSettings;
|
|
38
38
|
}): string;
|
|
39
|
+
/** The PR-type check's status context: every pull request into the dev branch needs exactly one `type: *` label. */
|
|
40
|
+
export declare const PR_TYPE_CHECK = "pr-type";
|
|
41
|
+
/**
|
|
42
|
+
* Every pull request needs exactly one `type: *` label (bug, performance, enhancement, feature, chore) so merged work
|
|
43
|
+
* can be measured by kind. With no label, Claude picks one when the repository can see an `ANTHROPIC_API_KEY` secret;
|
|
44
|
+
* otherwise the check fails and says which labels to add. The script and taxonomy run from the base commit, never the
|
|
45
|
+
* pull request's head, because the job holds a write-scoped token.
|
|
46
|
+
*/
|
|
47
|
+
export declare function prTypeWorkflow({ settings }: {
|
|
48
|
+
settings: GitHubSettings;
|
|
49
|
+
}): string;
|
|
50
|
+
export declare function prTypeScript(): string;
|
|
51
|
+
export declare function prTypesTaxonomy(): string;
|
|
39
52
|
export interface ManagedFile {
|
|
40
53
|
path: string;
|
|
41
54
|
content: string;
|
|
@@ -76,7 +89,7 @@ export declare const SEQUENCE_CI_APP: {
|
|
|
76
89
|
/** The App's key is not among them: only prod Atlases hold it, and they move release branches as the App. */
|
|
77
90
|
export declare const SEQ_CI_SECRETS: readonly ["SEQ_CI_IMAGE_PULL_KEY", "SEQ_CI_REGISTRY_AUTH"];
|
|
78
91
|
/**
|
|
79
|
-
* The branch rulesets `repo init` keeps on a repository, by name. The dev branch requires `seq / checks` and no
|
|
92
|
+
* The branch rulesets `repo init` keeps on a repository, by name. The dev branch requires `seq / checks`, `pr-type` and no
|
|
80
93
|
* approvals: what `pull_request_builds: reuse` relies on (`githubSettingsSchema`). It doesn't require pull requests to
|
|
81
94
|
* be up to date with the branch: every push to it builds and checks again before deploying, reusing a pull request's
|
|
82
95
|
* builds only when the merged tree carries every change that pull request's last run tested.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
1
2
|
import { lstat, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
3
|
import { dirname, join, resolve } from 'node:path';
|
|
3
4
|
import { dump as yamlDump, load as yamlLoad } from 'js-yaml';
|
|
@@ -80,10 +81,96 @@ description: Read before using seq-studio or changing anything under .seq/, sequ
|
|
|
80
81
|
This repository deploys to the Sequence platform for the \`${settings.org}\` org.
|
|
81
82
|
|
|
82
83
|
- Read the platform docs first: \`seq-studio docs search "<topic>" -e <env>\`, then \`seq-studio docs read <slug> -e <env>\` (\`seq-studio envs list\` prints the environments). They match the deployed platform version; use them rather than guessing command shapes.
|
|
84
|
+
- Every pull request needs exactly one type label: \`type: bug\`, \`type: performance\`, \`type: enhancement\`, \`type: feature\` or \`type: chore\` (see .github/pr-types.json). Pick it yourself when you open the pull request (\`gh pr create --label "type: …"\`).
|
|
83
85
|
- \`${settings.branches.dev}\` deploys to staging; \`${settings.branches.release}\` deploys to prod and moves only through the Promote workflow in GitHub.
|
|
84
86
|
- Never use \`--break-glass\` unless the user explicitly asks for it in this conversation and gives the reason.
|
|
85
87
|
`;
|
|
86
88
|
}
|
|
89
|
+
/** The PR-type check's status context: every pull request into the dev branch needs exactly one `type: *` label. */
|
|
90
|
+
export const PR_TYPE_CHECK = 'pr-type';
|
|
91
|
+
const PR_TYPE_SCRIPT_PATH = '.github/scripts/seq-pr-type.mjs';
|
|
92
|
+
const PR_TYPES_PATH = '.github/pr-types.json';
|
|
93
|
+
/** The shared PR-type script and taxonomy, as studio-cli ships them (studio's own PR check runs the same copy). */
|
|
94
|
+
function prTypeTemplate(name) {
|
|
95
|
+
return readFileSync(new URL(`../../templates/github/${name}`, import.meta.url), 'utf8');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Every pull request needs exactly one `type: *` label (bug, performance, enhancement, feature, chore) so merged work
|
|
99
|
+
* can be measured by kind. With no label, Claude picks one when the repository can see an `ANTHROPIC_API_KEY` secret;
|
|
100
|
+
* otherwise the check fails and says which labels to add. The script and taxonomy run from the base commit, never the
|
|
101
|
+
* pull request's head, because the job holds a write-scoped token.
|
|
102
|
+
*/
|
|
103
|
+
export function prTypeWorkflow({ settings }) {
|
|
104
|
+
return `${header('.github/workflows/seq-pr-type.yml')}name: PR type
|
|
105
|
+
on:
|
|
106
|
+
pull_request:
|
|
107
|
+
types: [opened, reopened, ready_for_review, synchronize, labeled, unlabeled]
|
|
108
|
+
push:
|
|
109
|
+
branches: [${JSON.stringify(settings.branches.dev)}]
|
|
110
|
+
paths: [${JSON.stringify(PR_TYPES_PATH)}]
|
|
111
|
+
workflow_dispatch: {}
|
|
112
|
+
permissions: {}
|
|
113
|
+
jobs:
|
|
114
|
+
${PR_TYPE_CHECK}:
|
|
115
|
+
name: ${PR_TYPE_CHECK}
|
|
116
|
+
if: github.event_name == 'pull_request'
|
|
117
|
+
runs-on: ubuntu-latest
|
|
118
|
+
timeout-minutes: 5
|
|
119
|
+
concurrency:
|
|
120
|
+
group: pr-type-\${{ github.event.pull_request.number }}
|
|
121
|
+
cancel-in-progress: true
|
|
122
|
+
permissions: { contents: read, issues: write, pull-requests: write }
|
|
123
|
+
steps:
|
|
124
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
125
|
+
with:
|
|
126
|
+
ref: \${{ github.event.pull_request.base.sha }}
|
|
127
|
+
sparse-checkout: |
|
|
128
|
+
${PR_TYPES_PATH}
|
|
129
|
+
${PR_TYPE_SCRIPT_PATH}
|
|
130
|
+
sparse-checkout-cone-mode: false
|
|
131
|
+
persist-credentials: false
|
|
132
|
+
- name: Require exactly one type label
|
|
133
|
+
env:
|
|
134
|
+
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
|
|
135
|
+
ANTHROPIC_API_KEY: \${{ secrets.ANTHROPIC_API_KEY }}
|
|
136
|
+
PR_TYPES_PATH: ${PR_TYPES_PATH}
|
|
137
|
+
# Label events only re-check: classifying on unlabeled would race an author swapping types.
|
|
138
|
+
PR_TYPE_CLASSIFY: \${{ github.event.action != 'labeled' && github.event.action != 'unlabeled' }}
|
|
139
|
+
# The base commit predates the check only on the pull request that introduces it.
|
|
140
|
+
run: |
|
|
141
|
+
if [ ! -f ${PR_TYPE_SCRIPT_PATH} ]; then
|
|
142
|
+
echo "::notice::The PR type check is not on the base branch yet; skipping until it merges."
|
|
143
|
+
exit 0
|
|
144
|
+
fi
|
|
145
|
+
node ${PR_TYPE_SCRIPT_PATH}
|
|
146
|
+
sync-labels:
|
|
147
|
+
name: sync labels
|
|
148
|
+
if: github.event_name != 'pull_request'
|
|
149
|
+
runs-on: ubuntu-latest
|
|
150
|
+
timeout-minutes: 5
|
|
151
|
+
permissions: { contents: read, issues: write }
|
|
152
|
+
steps:
|
|
153
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
154
|
+
with:
|
|
155
|
+
sparse-checkout: |
|
|
156
|
+
${PR_TYPES_PATH}
|
|
157
|
+
${PR_TYPE_SCRIPT_PATH}
|
|
158
|
+
sparse-checkout-cone-mode: false
|
|
159
|
+
persist-credentials: false
|
|
160
|
+
- name: Create or update type labels
|
|
161
|
+
env:
|
|
162
|
+
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
|
|
163
|
+
PR_TYPES_PATH: ${PR_TYPES_PATH}
|
|
164
|
+
run: node ${PR_TYPE_SCRIPT_PATH} sync-labels
|
|
165
|
+
`;
|
|
166
|
+
}
|
|
167
|
+
export function prTypeScript() {
|
|
168
|
+
return `// ${MANAGED_MARKER} (template ${TEMPLATE_VERSION}). Change it with \`seq-studio repo init\`; check it with \`seq-studio repo init --check\`.\n${prTypeTemplate('pr-type.mjs')}`;
|
|
169
|
+
}
|
|
170
|
+
export function prTypesTaxonomy() {
|
|
171
|
+
const taxonomy = JSON.parse(prTypeTemplate('pr-types.json'));
|
|
172
|
+
return `${JSON.stringify({ ...taxonomy, $comment: `${MANAGED_MARKER} (template ${TEMPLATE_VERSION}). Change it with \`seq-studio repo init\`. Add a type, never rename one: renaming splits the trend lines.` }, null, 2)}\n`;
|
|
173
|
+
}
|
|
87
174
|
const AGENTS_POINTER = 'Before using seq-studio here, read .claude/skills/sequence-platform/SKILL.md.';
|
|
88
175
|
export function managedFiles({ settings }) {
|
|
89
176
|
return [
|
|
@@ -92,6 +179,9 @@ export function managedFiles({ settings }) {
|
|
|
92
179
|
{ path: '.github/workflows/seq-promote.yml', content: promoteWorkflow({ settings }) },
|
|
93
180
|
{ path: 'renovate.json', content: renovateConfig() },
|
|
94
181
|
{ path: '.claude/skills/sequence-platform/SKILL.md', content: agentSkill({ settings }) },
|
|
182
|
+
{ path: '.github/workflows/seq-pr-type.yml', content: prTypeWorkflow({ settings }) },
|
|
183
|
+
{ path: PR_TYPE_SCRIPT_PATH, content: prTypeScript() },
|
|
184
|
+
{ path: PR_TYPES_PATH, content: prTypesTaxonomy() },
|
|
95
185
|
];
|
|
96
186
|
}
|
|
97
187
|
async function readOptional(path) {
|
|
@@ -163,7 +253,7 @@ const APP_BYPASS = { actor_id: SEQUENCE_CI_APP.id, actor_type: 'Integration', by
|
|
|
163
253
|
/** The App's key is not among them: only prod Atlases hold it, and they move release branches as the App. */
|
|
164
254
|
export const SEQ_CI_SECRETS = ['SEQ_CI_IMAGE_PULL_KEY', 'SEQ_CI_REGISTRY_AUTH'];
|
|
165
255
|
/**
|
|
166
|
-
* The branch rulesets `repo init` keeps on a repository, by name. The dev branch requires `seq / checks` and no
|
|
256
|
+
* The branch rulesets `repo init` keeps on a repository, by name. The dev branch requires `seq / checks`, `pr-type` and no
|
|
167
257
|
* approvals: what `pull_request_builds: reuse` relies on (`githubSettingsSchema`). It doesn't require pull requests to
|
|
168
258
|
* be up to date with the branch: every push to it builds and checks again before deploying, reusing a pull request's
|
|
169
259
|
* builds only when the merged tree carries every change that pull request's last run tested.
|
|
@@ -174,7 +264,7 @@ export function githubRulesets({ settings }) {
|
|
|
174
264
|
return [
|
|
175
265
|
ruleset(settings.branches.dev, [
|
|
176
266
|
{ type: 'deletion' }, { type: 'non_fast_forward' }, { type: 'pull_request', parameters: { required_approving_review_count: 0, dismiss_stale_reviews_on_push: false, require_code_owner_review: false, require_last_push_approval: false, required_review_thread_resolution: false } },
|
|
177
|
-
{ type: 'required_status_checks', parameters: { strict_required_status_checks_policy: false, required_status_checks: [{ context: 'seq / checks' }] } },
|
|
267
|
+
{ type: 'required_status_checks', parameters: { strict_required_status_checks_policy: false, required_status_checks: [{ context: 'seq / checks' }, { context: PR_TYPE_CHECK }] } },
|
|
178
268
|
]),
|
|
179
269
|
{ ...ruleset(settings.branches.release, [{ type: 'deletion' }, { type: 'non_fast_forward' }, { type: 'update' }]), bypass: [APP_BYPASS] },
|
|
180
270
|
].map(({ bypass = [], ...entry }) => ({ ...entry, body: { ...entry.body, bypass_actors: bypass } }));
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ParsedArgs } from '../argv.js';
|
|
2
|
+
import { type GitHubSettings } from './github-init.js';
|
|
3
|
+
import { applyGitHubSettingsWithReport } from './github-init-command.js';
|
|
4
|
+
export interface CommandResult {
|
|
5
|
+
status: number | null;
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
}
|
|
9
|
+
/** Runs an external command; injectable so tests never touch `gh`, `git` or GitHub. */
|
|
10
|
+
export type RunCommand = (command: string, args: readonly string[], options?: {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
}) => CommandResult;
|
|
13
|
+
export declare const defaultRunCommand: RunCommand;
|
|
14
|
+
/** `owner/name`, validated the way GitHub names them; throws with a usable message otherwise. */
|
|
15
|
+
export declare function parseGitHubRepository(value: unknown): {
|
|
16
|
+
owner: string;
|
|
17
|
+
name: string;
|
|
18
|
+
slug: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function githubCloneUrl(slug: string): string;
|
|
21
|
+
/** Everything that must hold before anything is created. Returns the resolved target. */
|
|
22
|
+
export declare function preflightGitHubInit({ args, target, run }: {
|
|
23
|
+
args: ParsedArgs;
|
|
24
|
+
target: string;
|
|
25
|
+
run: RunCommand;
|
|
26
|
+
}): {
|
|
27
|
+
slug: string;
|
|
28
|
+
root: string;
|
|
29
|
+
};
|
|
30
|
+
/** The commit, push and connect steps after a successful `init --github`. */
|
|
31
|
+
export declare function githubNextSteps({ root, slug, settings, applied, env }: {
|
|
32
|
+
root: string;
|
|
33
|
+
slug: string;
|
|
34
|
+
settings: GitHubSettings;
|
|
35
|
+
applied: boolean;
|
|
36
|
+
env: string | undefined;
|
|
37
|
+
}): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Run the whole flow. `scaffold` writes the app into `root` (an initialized,
|
|
40
|
+
* empty Git checkout) and returns its exit code.
|
|
41
|
+
*/
|
|
42
|
+
export declare function runInitWithGitHub({ args, target, scaffold, run, apply }: {
|
|
43
|
+
args: ParsedArgs;
|
|
44
|
+
target: string;
|
|
45
|
+
scaffold: (root: string) => Promise<number>;
|
|
46
|
+
run?: RunCommand;
|
|
47
|
+
apply?: typeof applyGitHubSettingsWithReport;
|
|
48
|
+
}): Promise<number>;
|
|
49
|
+
/** The same parsed arguments without the GitHub-only flags, for the scaffold itself. */
|
|
50
|
+
export declare function withoutGitHubFlags(args: ParsedArgs): ParsedArgs;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `seq-studio init <dir> --github <owner>/<name> --org <org>`: start an app in
|
|
3
|
+
* its own new GitHub repository, ready for seq-ci. One command does what used to
|
|
4
|
+
* be four: create the repository with `gh`, `git init` the directory, scaffold
|
|
5
|
+
* the app, point `origin` at GitHub and write the `repo init` files.
|
|
6
|
+
*
|
|
7
|
+
* Creating a repository is opt-in. Without `--github`, `init` keeps its existing
|
|
8
|
+
* behavior, so an app that belongs in an existing repository (a monorepo) is
|
|
9
|
+
* still scaffolded into it with plain `init <subdir>`. `--github` inside an
|
|
10
|
+
* existing checkout is refused for the same reason.
|
|
11
|
+
*
|
|
12
|
+
* Every local refusal happens before anything is created, and the scaffold runs
|
|
13
|
+
* before the GitHub repository is created, so a failed scaffold leaves nothing
|
|
14
|
+
* behind on GitHub. Nothing is committed or pushed: the exact commands are
|
|
15
|
+
* printed instead, as with `--repo`.
|
|
16
|
+
*/
|
|
17
|
+
import { spawnSync } from 'node:child_process';
|
|
18
|
+
import { existsSync, mkdirSync, readdirSync } from 'node:fs';
|
|
19
|
+
import { isAbsolute, relative, resolve } from 'node:path';
|
|
20
|
+
import { LOG } from '../functions/commands.js';
|
|
21
|
+
import { initializeGitHubRepository, resolveSettings } from './github-init.js';
|
|
22
|
+
import { applyGitHubSettingsWithReport } from './github-init-command.js';
|
|
23
|
+
export const defaultRunCommand = (command, args, options) => {
|
|
24
|
+
const result = spawnSync(command, [...args], { cwd: options?.cwd, encoding: 'utf8' });
|
|
25
|
+
if (result.error)
|
|
26
|
+
return { status: null, stdout: '', stderr: result.error.message };
|
|
27
|
+
return { status: result.status, stdout: result.stdout ?? '', stderr: result.stderr ?? '' };
|
|
28
|
+
};
|
|
29
|
+
const GITHUB_REPOSITORY = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9._-]{1,100}$/;
|
|
30
|
+
/** `owner/name`, validated the way GitHub names them; throws with a usable message otherwise. */
|
|
31
|
+
export function parseGitHubRepository(value) {
|
|
32
|
+
if (typeof value !== 'string' || !GITHUB_REPOSITORY.test(value) || value.endsWith('.git')) {
|
|
33
|
+
throw new Error('--github needs <owner>/<name>, for example --github my-org/loan-tools');
|
|
34
|
+
}
|
|
35
|
+
const [owner, name] = value.split('/');
|
|
36
|
+
return { owner, name, slug: value };
|
|
37
|
+
}
|
|
38
|
+
export function githubCloneUrl(slug) {
|
|
39
|
+
return `https://github.com/${slug}.git`;
|
|
40
|
+
}
|
|
41
|
+
function flag(args, name) {
|
|
42
|
+
const value = args.flags[name];
|
|
43
|
+
return typeof value === 'string' ? value : undefined;
|
|
44
|
+
}
|
|
45
|
+
/** Everything that must hold before anything is created. Returns the resolved target. */
|
|
46
|
+
export function preflightGitHubInit({ args, target, run }) {
|
|
47
|
+
if (args.flags.repo !== undefined) {
|
|
48
|
+
throw new Error('Use --github (a new GitHub repository) or --repo (a platform git-service repository), not both.');
|
|
49
|
+
}
|
|
50
|
+
if (args.flags.template !== undefined && args.flags.template !== 'react-vite' && args.flags.template !== 'nextjs') {
|
|
51
|
+
throw new Error('--github scaffolds a new app; start it without a published --template.');
|
|
52
|
+
}
|
|
53
|
+
const { slug } = parseGitHubRepository(args.flags.github);
|
|
54
|
+
if (!flag(args, 'org')) {
|
|
55
|
+
throw new Error('--github needs --org <org>: the Sequence org this repository deploys for (written to .seq/github.yml).');
|
|
56
|
+
}
|
|
57
|
+
const root = resolve(target);
|
|
58
|
+
const inside = run('git', ['-C', nearestExisting(root), 'rev-parse', '--show-toplevel']);
|
|
59
|
+
if (inside.status === 0) {
|
|
60
|
+
throw new Error(`${target} is inside the Git checkout ${inside.stdout.trim()}. --github starts an app in its own new repository. ` +
|
|
61
|
+
'To add the app to that repository instead, run init without --github; to set that checkout up for GitHub, run seq-studio repo init there.');
|
|
62
|
+
}
|
|
63
|
+
if (existsSync(root) && readdirSync(root).length > 0) {
|
|
64
|
+
throw new Error(`${target} exists and is not empty. --github scaffolds into a new or empty directory.`);
|
|
65
|
+
}
|
|
66
|
+
const auth = run('gh', ['auth', 'status']);
|
|
67
|
+
if (auth.status !== 0) {
|
|
68
|
+
throw new Error(auth.status === null
|
|
69
|
+
? '--github needs the GitHub CLI (gh). Install it from https://cli.github.com, run gh auth login, then retry.'
|
|
70
|
+
: '--github needs gh to be signed in: run gh auth login, then retry.');
|
|
71
|
+
}
|
|
72
|
+
const existing = run('gh', ['repo', 'view', slug, '--json', 'name']);
|
|
73
|
+
if (existing.status === 0) {
|
|
74
|
+
throw new Error(`${slug} already exists on GitHub. Clone it and run seq-studio repo init in the clone, or pick another name.`);
|
|
75
|
+
}
|
|
76
|
+
return { slug, root };
|
|
77
|
+
}
|
|
78
|
+
function nearestExisting(path) {
|
|
79
|
+
let current = path;
|
|
80
|
+
while (!existsSync(current)) {
|
|
81
|
+
const parent = resolve(current, '..');
|
|
82
|
+
if (parent === current)
|
|
83
|
+
return current;
|
|
84
|
+
current = parent;
|
|
85
|
+
}
|
|
86
|
+
return current;
|
|
87
|
+
}
|
|
88
|
+
function shellArg(value) {
|
|
89
|
+
return /^[\w./:@=+-]+$/.test(value) ? value : `'${value.replace(/'/g, "'\\''")}'`;
|
|
90
|
+
}
|
|
91
|
+
function displayPath(path) {
|
|
92
|
+
const fromCwd = relative(process.cwd(), path);
|
|
93
|
+
if (fromCwd === '')
|
|
94
|
+
return '.';
|
|
95
|
+
return fromCwd.startsWith('..') || isAbsolute(fromCwd) ? path : fromCwd;
|
|
96
|
+
}
|
|
97
|
+
/** The commit, push and connect steps after a successful `init --github`. */
|
|
98
|
+
export function githubNextSteps({ root, slug, settings, applied, env }) {
|
|
99
|
+
const dir = shellArg(displayPath(root));
|
|
100
|
+
const gitC = `git -C ${dir}`;
|
|
101
|
+
const { dev, release } = settings.branches;
|
|
102
|
+
const envFlag = env ? `-e ${shellArg(env)}` : '-e <env>';
|
|
103
|
+
const lines = [
|
|
104
|
+
`${LOG} ${slug} is ready but nothing is committed. Commit and push both branches:`,
|
|
105
|
+
` ${gitC} add -A && ${gitC} commit -m ${shellArg(`Scaffold ${slug.split('/')[1]}`)}`,
|
|
106
|
+
` ${gitC} push -u origin HEAD:${shellArg(release)} && ${gitC} push origin HEAD:${shellArg(dev)}`,
|
|
107
|
+
];
|
|
108
|
+
if (!applied) {
|
|
109
|
+
lines.push(`${LOG} then apply the branch rulesets and secret scanning (needs admin on ${slug}, which its creator has):`);
|
|
110
|
+
lines.push(` (cd ${dir} && seq-studio repo init --apply-github)`);
|
|
111
|
+
}
|
|
112
|
+
lines.push(`${LOG} then let it deploy (${dev} → staging, ${release} → prod through Promote):`);
|
|
113
|
+
lines.push(` (cd ${dir} && seq-studio repo connect ${envFlag} --stage staging)`);
|
|
114
|
+
lines.push(` (cd ${dir} && seq-studio repo connect ${envFlag} --stage prod)`);
|
|
115
|
+
return lines;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Run the whole flow. `scaffold` writes the app into `root` (an initialized,
|
|
119
|
+
* empty Git checkout) and returns its exit code.
|
|
120
|
+
*/
|
|
121
|
+
export async function runInitWithGitHub({ args, target, scaffold, run = defaultRunCommand, apply = applyGitHubSettingsWithReport }) {
|
|
122
|
+
let slug;
|
|
123
|
+
let root;
|
|
124
|
+
let settings;
|
|
125
|
+
try {
|
|
126
|
+
;
|
|
127
|
+
({ slug, root } = preflightGitHubInit({ args, target, run }));
|
|
128
|
+
mkdirSync(root, { recursive: true });
|
|
129
|
+
// Settings first: they validate --org/--dev/--release before anything else is written.
|
|
130
|
+
settings = await resolveSettings({
|
|
131
|
+
directory: root, org: flag(args, 'org'), dev: flag(args, 'dev'), release: flag(args, 'release'),
|
|
132
|
+
});
|
|
133
|
+
const init = run('git', ['init', '-b', settings.branches.release, root]);
|
|
134
|
+
if (init.status !== 0)
|
|
135
|
+
throw new Error(`git init failed: ${init.stderr.trim()}`);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error(`${LOG} ${error instanceof Error ? error.message : String(error)}`);
|
|
139
|
+
return 1;
|
|
140
|
+
}
|
|
141
|
+
const code = await scaffold(root);
|
|
142
|
+
if (code !== 0) {
|
|
143
|
+
console.error(`${LOG} the scaffold failed, so ${slug} was not created on GitHub. Fix the error and rerun in an empty directory.`);
|
|
144
|
+
return code;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const created = run('gh', ['repo', 'create', slug, '--private']);
|
|
148
|
+
if (created.status !== 0)
|
|
149
|
+
throw new Error(`gh repo create ${slug} failed: ${created.stderr.trim()}`);
|
|
150
|
+
console.log(`${LOG} created ${slug} on GitHub (private)`);
|
|
151
|
+
const origin = run('git', ['-C', root, 'remote', 'add', 'origin', githubCloneUrl(slug)]);
|
|
152
|
+
if (origin.status !== 0)
|
|
153
|
+
throw new Error(`git remote add origin failed: ${origin.stderr.trim()}`);
|
|
154
|
+
const reports = await initializeGitHubRepository({ directory: root, settings, write: true });
|
|
155
|
+
const written = reports.filter((report) => report.status === 'missing' || report.status === 'stale').map((report) => report.path);
|
|
156
|
+
console.log(`${LOG} wrote ${written.join(', ')} for org ${settings.org} (dev ${settings.branches.dev}, release ${settings.branches.release})`);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
console.error(`${LOG} ${error instanceof Error ? error.message : String(error)}`);
|
|
160
|
+
console.error(`${LOG} the app is scaffolded in ${root}; finish with gh repo create, git remote add origin and seq-studio repo init there.`);
|
|
161
|
+
return 1;
|
|
162
|
+
}
|
|
163
|
+
let applied = false;
|
|
164
|
+
if (args.flags['apply-github'] === true) {
|
|
165
|
+
const applyCode = await apply({ repository: slug, settings, say: (text) => process.stdout.write(text) });
|
|
166
|
+
if (applyCode !== 0)
|
|
167
|
+
return applyCode;
|
|
168
|
+
applied = true;
|
|
169
|
+
}
|
|
170
|
+
const env = flag(args, 'env') ?? flag(args, 'e');
|
|
171
|
+
for (const line of githubNextSteps({ root, slug, settings, applied, env }))
|
|
172
|
+
console.log(line);
|
|
173
|
+
return 0;
|
|
174
|
+
}
|
|
175
|
+
/** The same parsed arguments without the GitHub-only flags, for the scaffold itself. */
|
|
176
|
+
export function withoutGitHubFlags(args) {
|
|
177
|
+
const flags = { ...args.flags };
|
|
178
|
+
for (const name of ['github', 'org', 'dev', 'release', 'apply-github'])
|
|
179
|
+
delete flags[name];
|
|
180
|
+
return { ...args, flags };
|
|
181
|
+
}
|