@sequenceholdings/studio-cli 1.0.1 → 1.0.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 +4 -3
- package/dist/access/custom-role-hosts.js +8 -6
- package/dist/app/manifest-validation.js +4 -2
- package/dist/app/manifest.d.ts +2 -0
- package/dist/app/manifest.js +2 -0
- package/dist/app/paths.js +3 -0
- package/dist/app-preview/bundle-dependencies.d.ts +52 -0
- package/dist/app-preview/bundle-dependencies.js +121 -0
- package/dist/app-preview/commands.d.ts +2 -5
- package/dist/app-preview/commands.js +57 -62
- package/dist/app-preview/fork-setup.d.ts +66 -0
- package/dist/app-preview/fork-setup.js +123 -0
- package/dist/app-preview/fork.d.ts +171 -0
- package/dist/app-preview/fork.js +279 -0
- package/dist/app-preview/install.d.ts +23 -2
- package/dist/app-preview/install.js +67 -6
- package/dist/app-preview/orm-sdk.d.ts +31 -0
- package/dist/app-preview/orm-sdk.js +16 -0
- package/dist/app-preview/plan.d.ts +2 -0
- package/dist/app-preview/plan.js +2 -2
- package/dist/app-preview/report.d.ts +30 -0
- package/dist/app-preview/report.js +80 -0
- package/dist/app-preview/repository-manifest.d.ts +83 -0
- package/dist/app-preview/repository-manifest.js +179 -0
- package/dist/app-preview/runners.d.ts +14 -0
- package/dist/app-preview/runners.js +83 -23
- package/dist/app-preview/session-output.d.ts +5 -0
- package/dist/app-preview/session-output.js +28 -0
- package/dist/app-preview/source-includes.d.ts +12 -0
- package/dist/app-preview/source-includes.js +74 -0
- package/dist/app-preview/target.d.ts +8 -0
- package/dist/app-preview/target.js +4 -1
- package/dist/app-preview/usage.d.ts +7 -0
- package/dist/app-preview/usage.js +57 -0
- package/dist/envs/commands.js +2 -1
- package/dist/login.js +1 -1
- package/dist/orm/break-glass.d.ts +15 -0
- package/dist/orm/break-glass.js +22 -0
- package/dist/orm/delegate.js +10 -8
- package/dist/orm/version-guard.d.ts +6 -2
- package/dist/orm/version-guard.js +27 -7
- package/dist/registry/help.js +5 -6
- package/dist/repos/github-init-command.d.ts +2 -2
- package/dist/repos/github-init-command.js +18 -8
- package/dist/repos/github-init.d.ts +26 -3
- package/dist/repos/github-init.js +23 -9
- package/dist/repos/github-settings-check.d.ts +17 -0
- package/dist/repos/github-settings-check.js +58 -0
- package/dist/repos/primitive-declaration.d.ts +27 -0
- package/dist/repos/primitive-declaration.js +22 -6
- package/dist/repos/seq-ci-release.d.ts +10 -0
- package/dist/repos/seq-ci-release.js +27 -0
- package/dist/sdk-source.d.ts +15 -0
- package/dist/sdk-source.js +30 -11
- package/package.json +4 -4
- package/release-summary.json +3 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ParsedArgs } from '../argv.js';
|
|
2
2
|
import { type GitHubApi, type GitHubSettings } from './github-init.js';
|
|
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
|
|
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). It also reads the repository's GitHub settings with gh and reports any that\n --apply-github would change; one your gh login can't read is reported unchecked and doesn't fail the check.\n\n Branch rulesets, secret scanning and deleting merged branches need admin rights on the repository (not the org):\n --apply-github sets them with gh and confirms the repository can read seq-ci's org secrets; without it, the gh\n commands are printed for an 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.";
|
|
4
4
|
/** `org/name` from a github.com origin, or null when the origin is elsewhere. */
|
|
5
5
|
export declare function githubRepositoryFromRemote(url: string): string | null;
|
|
6
6
|
/**
|
|
7
|
-
* Apply the branch rulesets and
|
|
7
|
+
* Apply the branch rulesets and repository settings with `gh`, and check that the repository can use seq-ci. Shared by
|
|
8
8
|
* `repo init --apply-github` and `init --github --apply-github`; returns the exit code.
|
|
9
9
|
*/
|
|
10
10
|
export declare function applyGitHubSettingsWithReport({ repository, settings, say, api }: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { applyGitHubSettings, ensureSeqCi, githubSettingsCommands, initializeGitHubRepository, resolveSettings, SEQUENCE_CI_APP } from './github-init.js';
|
|
3
|
+
import { checkGitHubSettings } from './github-settings-check.js';
|
|
3
4
|
export const REPO_INIT_USAGE = `usage:
|
|
4
5
|
seq-studio repo init [--org <org>] [--dev <branch>] [--release <branch>] [--seq-ci <vX.Y.Z>] [--release-repository <namespace/name>]
|
|
5
6
|
[--pull-request-builds reuse|rebuild] [--dir <checkout>] [--apply-github] [--json]
|
|
@@ -8,11 +9,12 @@ export const REPO_INIT_USAGE = `usage:
|
|
|
8
9
|
Make a GitHub checkout a Sequence repository: .seq/github.yml (org and branches), the seq and seq promote
|
|
9
10
|
workflows, Renovate config, and an agent skill pointing at the platform docs. Writes only what's missing or
|
|
10
11
|
stale, and never overwrites a file it doesn't manage. --check reports the same and writes nothing (exit 3 when
|
|
11
|
-
anything is missing or stale).
|
|
12
|
+
anything is missing or stale). It also reads the repository's GitHub settings with gh and reports any that
|
|
13
|
+
--apply-github would change; one your gh login can't read is reported unchecked and doesn't fail the check.
|
|
12
14
|
|
|
13
|
-
Branch rulesets
|
|
14
|
-
with gh and confirms the repository can read seq-ci's org secrets; without it, the gh
|
|
15
|
-
admin. Commit and push the written files yourself.
|
|
15
|
+
Branch rulesets, secret scanning and deleting merged branches need admin rights on the repository (not the org):
|
|
16
|
+
--apply-github sets them with gh and confirms the repository can read seq-ci's org secrets; without it, the gh
|
|
17
|
+
commands are printed for an admin. Commit and push the written files yourself.
|
|
16
18
|
|
|
17
19
|
--pull-request-builds (default reuse): whether the dev branch's deploys reuse what a pull request's CI built and
|
|
18
20
|
checked from the change it merged. Sound only while the dev branch needs no approvals, as these rulesets set it;
|
|
@@ -49,14 +51,20 @@ function printReports(reports) {
|
|
|
49
51
|
process.stdout.write(` ${report.status.padEnd(9)} ${report.path}${note}\n`);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
54
|
+
function printSettingReports(reports) {
|
|
55
|
+
for (const report of reports) {
|
|
56
|
+
const note = report.status === 'unchecked' ? ' (your gh login can\'t read it; an admin can)' : '';
|
|
57
|
+
process.stdout.write(` ${report.status.padEnd(9)} GitHub: ${report.setting}${note}\n`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
52
60
|
/**
|
|
53
|
-
* Apply the branch rulesets and
|
|
61
|
+
* Apply the branch rulesets and repository settings with `gh`, and check that the repository can use seq-ci. Shared by
|
|
54
62
|
* `repo init --apply-github` and `init --github --apply-github`; returns the exit code.
|
|
55
63
|
*/
|
|
56
64
|
export async function applyGitHubSettingsWithReport({ repository, settings, say, api = ghApi }) {
|
|
57
65
|
try {
|
|
58
66
|
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`);
|
|
67
|
+
say(`Branch rulesets: created ${applied.created.join(', ') || 'none'}; updated ${applied.updated.join(', ') || 'none'}; the Sequence CI App bypasses ${settings.branches.release}. Secret scanning on; merged branches are deleted.\n`);
|
|
60
68
|
const org = repository.split('/')[0];
|
|
61
69
|
const seqCi = await ensureSeqCi({ repository, api });
|
|
62
70
|
if (seqCi.secrets.shared.length > 0)
|
|
@@ -86,14 +94,16 @@ export async function runRepoInitCommand(args) {
|
|
|
86
94
|
const reports = await initializeGitHubRepository({ directory, settings, write: !check });
|
|
87
95
|
const repository = originRepository(directory);
|
|
88
96
|
const commands = repository ? githubSettingsCommands({ repository, settings }) : [];
|
|
97
|
+
const github = check && repository ? await checkGitHubSettings({ repository, settings, api: ghApi }) : [];
|
|
89
98
|
if (args.flags.json === true) {
|
|
90
|
-
console.log(JSON.stringify({ settings, repository, files: reports, githubCommands: commands.map((command) => command.slice(0, -1)) }, null, 2));
|
|
99
|
+
console.log(JSON.stringify({ settings, repository, files: reports, ...(check ? { github } : {}), githubCommands: commands.map((command) => command.slice(0, -1)) }, null, 2));
|
|
91
100
|
}
|
|
92
101
|
else {
|
|
93
102
|
process.stdout.write(`${check ? 'Checking' : 'Initialized'} ${repository ?? directory} for org ${settings.org} (dev ${settings.branches.dev}, release ${settings.branches.release}, seq-ci ${settings.seq_ci}, pull-request builds ${settings.pull_request_builds})\n`);
|
|
94
103
|
printReports(reports);
|
|
104
|
+
printSettingReports(github);
|
|
95
105
|
}
|
|
96
|
-
const outstanding = reports.some((report) => report.status === 'missing' || report.status === 'stale');
|
|
106
|
+
const outstanding = [...reports, ...github].some((report) => report.status === 'missing' || report.status === 'stale');
|
|
97
107
|
if (check)
|
|
98
108
|
return outstanding ? 3 : 0;
|
|
99
109
|
// Prose goes to stderr under --json, so stdout stays one JSON document.
|
|
@@ -109,7 +109,23 @@ export declare function githubRulesets({ settings }: {
|
|
|
109
109
|
bypass_actors: unknown[];
|
|
110
110
|
};
|
|
111
111
|
}[];
|
|
112
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* The repository settings `repo init` keeps, as `PATCH repos/<repository>` takes them. A merged pull request's branch is
|
|
114
|
+
* deleted; the dev and release branches survive that, their rulesets forbid deletion.
|
|
115
|
+
*/
|
|
116
|
+
export declare const REPOSITORY_SETTINGS: {
|
|
117
|
+
delete_branch_on_merge: boolean;
|
|
118
|
+
security_and_analysis: {
|
|
119
|
+
secret_scanning: {
|
|
120
|
+
status: string;
|
|
121
|
+
};
|
|
122
|
+
secret_scanning_push_protection: {
|
|
123
|
+
status: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export declare const REPOSITORY_SETTING_NAMES: readonly [readonly ["delete_branch_on_merge", "delete merged branches"], readonly ["security_and_analysis", "secret scanning"]];
|
|
128
|
+
/** The GitHub API calls that set branch rules and repository settings on a repository that has none yet, for an admin to run. */
|
|
113
129
|
export declare function githubSettingsCommands({ repository, settings }: {
|
|
114
130
|
repository: string;
|
|
115
131
|
settings: GitHubSettings;
|
|
@@ -120,9 +136,16 @@ export type GitHubApi = (args: {
|
|
|
120
136
|
path: string;
|
|
121
137
|
body?: unknown;
|
|
122
138
|
}) => Promise<unknown>;
|
|
139
|
+
export declare function listRulesets({ repository, api }: {
|
|
140
|
+
repository: string;
|
|
141
|
+
api: GitHubApi;
|
|
142
|
+
}): Promise<{
|
|
143
|
+
id: number;
|
|
144
|
+
name: string;
|
|
145
|
+
}[]>;
|
|
123
146
|
/**
|
|
124
|
-
* Apply the rulesets and
|
|
125
|
-
* place, keeping any bypass actors an admin added alongside the Sequence CI App's, never duplicated.
|
|
147
|
+
* Apply the rulesets and repository settings, reconciling by ruleset name: an existing `seq: <branch>` ruleset is updated
|
|
148
|
+
* in place, keeping any bypass actors an admin added alongside the Sequence CI App's, never duplicated.
|
|
126
149
|
*/
|
|
127
150
|
export declare function applyGitHubSettings({ repository, settings, api }: {
|
|
128
151
|
repository: string;
|
|
@@ -4,6 +4,7 @@ import { lstat, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
|
4
4
|
import { dirname, join, resolve } from 'node:path';
|
|
5
5
|
import { dump as yamlDump, load as yamlLoad } from 'js-yaml';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
+
import { newestRelease, workflowSeqCiReleases } from './seq-ci-release.js';
|
|
7
8
|
/**
|
|
8
9
|
* `seq-studio repo init`: make a GitHub checkout a Sequence repository. Writes only files it owns, marked with a
|
|
9
10
|
* managed header, and only what's missing or stale; `check` reports the same without writing.
|
|
@@ -222,8 +223,10 @@ function pinnedCli({ cli, current }) {
|
|
|
222
223
|
export async function resolveSettings({ directory, org, dev, release, seqCi, releaseRepository, pullRequestBuilds, cli }) {
|
|
223
224
|
const existing = await readOptional(join(resolve(directory), GITHUB_SETTINGS_PATH));
|
|
224
225
|
const current = existing === null ? undefined : githubSettingsSchema.parse(yamlLoad(existing));
|
|
226
|
+
// An explicit --seq-ci wins, older or not; otherwise never step back from what the workflows already call.
|
|
227
|
+
const inUse = newestRelease([...(current ? [current.seq_ci] : []), ...await workflowSeqCiReleases({ root: resolve(directory), read: readOptional })]);
|
|
225
228
|
const settings = { schema_version: 1, org: org ?? current?.org, branches: { dev: dev ?? current?.branches.dev ?? 'staging', release: release ?? current?.branches.release ?? 'main' },
|
|
226
|
-
seq_ci: seqCi ??
|
|
229
|
+
seq_ci: seqCi ?? inUse ?? 'v1.0.5',
|
|
227
230
|
// On by default: the dev branch ruleset below requires no approvals.
|
|
228
231
|
pull_request_builds: pullRequestBuilds ?? current?.pull_request_builds ?? 'reuse',
|
|
229
232
|
...((releaseRepository ?? current?.release_repository) ? { release_repository: releaseRepository ?? current?.release_repository } : {}),
|
|
@@ -285,21 +288,32 @@ export function githubRulesets({ settings }) {
|
|
|
285
288
|
{ ...ruleset(settings.branches.release, [{ type: 'deletion' }, { type: 'non_fast_forward' }, { type: 'update' }]), bypass: [APP_BYPASS] },
|
|
286
289
|
].map(({ bypass = [], ...entry }) => ({ ...entry, body: { ...entry.body, bypass_actors: bypass } }));
|
|
287
290
|
}
|
|
288
|
-
|
|
289
|
-
|
|
291
|
+
/**
|
|
292
|
+
* The repository settings `repo init` keeps, as `PATCH repos/<repository>` takes them. A merged pull request's branch is
|
|
293
|
+
* deleted; the dev and release branches survive that, their rulesets forbid deletion.
|
|
294
|
+
*/
|
|
295
|
+
export const REPOSITORY_SETTINGS = {
|
|
296
|
+
delete_branch_on_merge: true,
|
|
297
|
+
security_and_analysis: { secret_scanning: { status: 'enabled' }, secret_scanning_push_protection: { status: 'enabled' } },
|
|
298
|
+
};
|
|
299
|
+
export const REPOSITORY_SETTING_NAMES = [['delete_branch_on_merge', 'delete merged branches'], ['security_and_analysis', 'secret scanning']];
|
|
300
|
+
/** The GitHub API calls that set branch rules and repository settings on a repository that has none yet, for an admin to run. */
|
|
290
301
|
export function githubSettingsCommands({ repository, settings }) {
|
|
291
302
|
return [
|
|
292
303
|
...githubRulesets({ settings }).map((ruleset) => ['gh', 'api', '--method', 'POST', `repos/${repository}/rulesets`, '--input', '-', JSON.stringify(ruleset.body)]),
|
|
293
|
-
['gh', 'api', '--method', 'PATCH', `repos/${repository}`, '--input', '-', JSON.stringify(
|
|
304
|
+
['gh', 'api', '--method', 'PATCH', `repos/${repository}`, '--input', '-', JSON.stringify(REPOSITORY_SETTINGS)],
|
|
294
305
|
];
|
|
295
306
|
}
|
|
307
|
+
export async function listRulesets({ repository, api }) {
|
|
308
|
+
const existing = await api({ method: 'GET', path: `repos/${repository}/rulesets?per_page=100` });
|
|
309
|
+
return Array.isArray(existing) ? existing.filter((entry) => typeof entry?.id === 'number' && typeof entry?.name === 'string') : [];
|
|
310
|
+
}
|
|
296
311
|
/**
|
|
297
|
-
* Apply the rulesets and
|
|
298
|
-
* place, keeping any bypass actors an admin added alongside the Sequence CI App's, never duplicated.
|
|
312
|
+
* Apply the rulesets and repository settings, reconciling by ruleset name: an existing `seq: <branch>` ruleset is updated
|
|
313
|
+
* in place, keeping any bypass actors an admin added alongside the Sequence CI App's, never duplicated.
|
|
299
314
|
*/
|
|
300
315
|
export async function applyGitHubSettings({ repository, settings, api }) {
|
|
301
|
-
const
|
|
302
|
-
const listed = Array.isArray(existing) ? existing.filter((entry) => typeof entry?.id === 'number' && typeof entry?.name === 'string') : [];
|
|
316
|
+
const listed = await listRulesets({ repository, api });
|
|
303
317
|
const result = { created: [], updated: [] };
|
|
304
318
|
for (const ruleset of githubRulesets({ settings })) {
|
|
305
319
|
const match = listed.find((entry) => entry.name === ruleset.name);
|
|
@@ -315,7 +329,7 @@ export async function applyGitHubSettings({ repository, settings, api }) {
|
|
|
315
329
|
await api({ method: 'PUT', path: `repos/${repository}/rulesets/${match.id}`, body: { ...ruleset.body, bypass_actors: bypass } });
|
|
316
330
|
result.updated.push(ruleset.name);
|
|
317
331
|
}
|
|
318
|
-
await api({ method: 'PATCH', path: `repos/${repository}`, body:
|
|
332
|
+
await api({ method: 'PATCH', path: `repos/${repository}`, body: REPOSITORY_SETTINGS });
|
|
319
333
|
return result;
|
|
320
334
|
}
|
|
321
335
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type GitHubApi, type GitHubSettings } from './github-init.js';
|
|
2
|
+
/**
|
|
3
|
+
* `seq-studio repo init --check`, the GitHub half: whether a repository still has the rulesets and settings
|
|
4
|
+
* `--apply-github` sets. Read-only.
|
|
5
|
+
*/
|
|
6
|
+
/** `unchecked`: the caller's token may not read it, so nothing is known either way. */
|
|
7
|
+
export type SettingStatus = 'missing' | 'stale' | 'current' | 'unchecked';
|
|
8
|
+
export interface SettingReport {
|
|
9
|
+
setting: string;
|
|
10
|
+
status: SettingStatus;
|
|
11
|
+
}
|
|
12
|
+
/** What `--apply-github` would change on a repository, read-only: each ruleset and repository setting it keeps. */
|
|
13
|
+
export declare function checkGitHubSettings({ repository, settings, api }: {
|
|
14
|
+
repository: string;
|
|
15
|
+
settings: GitHubSettings;
|
|
16
|
+
api: GitHubApi;
|
|
17
|
+
}): Promise<SettingReport[]>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { githubRulesets, listRulesets, REPOSITORY_SETTING_NAMES, REPOSITORY_SETTINGS } from './github-init.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether `actual` holds everything in `expected`. Not equality: GitHub returns defaults `repo init` never set, and an
|
|
4
|
+
* admin may add rules or bypass actors beside the ones it keeps. A value it does set must match exactly.
|
|
5
|
+
*/
|
|
6
|
+
function holds({ actual, expected }) {
|
|
7
|
+
if (Array.isArray(expected)) {
|
|
8
|
+
return Array.isArray(actual) && expected.every((item) => actual.some((candidate) => holds({ actual: candidate, expected: item })));
|
|
9
|
+
}
|
|
10
|
+
if (expected !== null && typeof expected === 'object') {
|
|
11
|
+
return actual !== null && typeof actual === 'object' &&
|
|
12
|
+
Object.entries(expected).every(([key, value]) => holds({ actual: Reflect.get(actual, key), expected: value }));
|
|
13
|
+
}
|
|
14
|
+
return actual === expected;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Whether a ruleset exempts no branch. `holds` can't say: it accepts whatever an admin added, and an exclusion is the one
|
|
18
|
+
* addition that weakens a ruleset, lifting its rules off the branch it names.
|
|
19
|
+
*/
|
|
20
|
+
function excludesNoBranch(ruleset) {
|
|
21
|
+
const read = (value, key) => value !== null && typeof value === 'object' ? Reflect.get(value, key) : undefined;
|
|
22
|
+
const exclude = read(read(read(ruleset, 'conditions'), 'ref_name'), 'exclude');
|
|
23
|
+
return Array.isArray(exclude) && exclude.length === 0;
|
|
24
|
+
}
|
|
25
|
+
async function rulesetReports({ repository, settings, api }) {
|
|
26
|
+
const expected = githubRulesets({ settings });
|
|
27
|
+
const report = (name, status) => ({ setting: `ruleset ${name}`, status });
|
|
28
|
+
try {
|
|
29
|
+
const listed = await listRulesets({ repository, api });
|
|
30
|
+
return await Promise.all(expected.map(async ({ name, body }) => {
|
|
31
|
+
const match = listed.find((entry) => entry.name === name);
|
|
32
|
+
if (!match)
|
|
33
|
+
return report(name, 'missing');
|
|
34
|
+
const current = await api({ method: 'GET', path: `repos/${repository}/rulesets/${match.id}` });
|
|
35
|
+
// GitHub shows a ruleset's bypass actors only to those who can write to the repository.
|
|
36
|
+
const readable = current !== null && typeof current === 'object' && Array.isArray(Reflect.get(current, 'bypass_actors'));
|
|
37
|
+
const { bypass_actors: _unreadable, ...rules } = body;
|
|
38
|
+
const kept = holds({ actual: current, expected: readable ? body : rules }) && excludesNoBranch(current);
|
|
39
|
+
return report(name, kept ? 'current' : 'stale');
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return expected.map(({ name }) => report(name, 'unchecked'));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function repositorySettingReports({ repository, api }) {
|
|
47
|
+
const current = await api({ method: 'GET', path: `repos/${repository}` }).catch(() => null);
|
|
48
|
+
return REPOSITORY_SETTING_NAMES.map(([key, setting]) => {
|
|
49
|
+
// Absent rather than off: GitHub leaves these fields out for a token that can't administer the repository.
|
|
50
|
+
const actual = current !== null && typeof current === 'object' ? Reflect.get(current, key) : undefined;
|
|
51
|
+
const status = actual === undefined ? 'unchecked' : holds({ actual, expected: REPOSITORY_SETTINGS[key] }) ? 'current' : 'stale';
|
|
52
|
+
return { setting, status };
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** What `--apply-github` would change on a repository, read-only: each ruleset and repository setting it keeps. */
|
|
56
|
+
export async function checkGitHubSettings({ repository, settings, api }) {
|
|
57
|
+
return [...await rulesetReports({ repository, settings, api }), ...await repositorySettingReports({ repository, api })];
|
|
58
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
export type StandalonePrimitiveKind = 'orm' | 'function' | 'artifact';
|
|
2
3
|
export interface ResourceEntry {
|
|
3
4
|
id: string;
|
|
@@ -17,6 +18,31 @@ export type ResourceDeclarationPlan = {
|
|
|
17
18
|
action: 'skip';
|
|
18
19
|
reason?: string;
|
|
19
20
|
};
|
|
21
|
+
declare const indexSchema: z.ZodObject<{
|
|
22
|
+
schema_version: z.ZodLiteral<1>;
|
|
23
|
+
applications: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
24
|
+
path: z.ZodString;
|
|
25
|
+
}, z.core.$loose>>>>;
|
|
26
|
+
resources: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
path: z.ZodString;
|
|
29
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
30
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
31
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
32
|
+
project_id: z.ZodOptional<z.ZodString>;
|
|
33
|
+
name: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$loose>>>>;
|
|
35
|
+
ignore: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
36
|
+
}, z.core.$loose>;
|
|
37
|
+
export type IndexedResource = NonNullable<RepositoryIndex['resources']>[number];
|
|
38
|
+
type RepositoryIndex = z.infer<typeof indexSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* The resources a repository's index declares, as written (unknown fields kept), for a reader that only looks.
|
|
41
|
+
* Null when the repository has no index; throws when the file is there and cannot be read as one.
|
|
42
|
+
*/
|
|
43
|
+
export declare function readRepositoryResources({ gitRoot }: {
|
|
44
|
+
gitRoot: string;
|
|
45
|
+
}): Promise<IndexedResource[] | null>;
|
|
20
46
|
/** Plan the index change for a primitive just scaffolded at `dir`. */
|
|
21
47
|
export declare function planResourceDeclaration({ kind, dir }: {
|
|
22
48
|
kind: StandalonePrimitiveKind;
|
|
@@ -41,3 +67,4 @@ export declare function runStandaloneInit({ kind, argv, defaultDir, run }: {
|
|
|
41
67
|
defaultDir?: string;
|
|
42
68
|
run: () => Promise<number>;
|
|
43
69
|
}): Promise<number>;
|
|
70
|
+
export {};
|
|
@@ -99,19 +99,35 @@ function uniqueId(id, taken) {
|
|
|
99
99
|
if (!taken.has(`${id}-${n}`))
|
|
100
100
|
return `${id}-${n}`;
|
|
101
101
|
}
|
|
102
|
-
/** The existing index (with its document
|
|
103
|
-
async function
|
|
102
|
+
/** The existing index (with its document), none, or what is wrong with the file. */
|
|
103
|
+
async function parseIndex(indexPath) {
|
|
104
104
|
if (!existsSync(indexPath))
|
|
105
105
|
return null;
|
|
106
106
|
const document = parseDocument(await readFile(indexPath, 'utf8'));
|
|
107
107
|
if (document.errors.length > 0)
|
|
108
|
-
return {
|
|
108
|
+
return { problem: `${REPOSITORY_INDEX_PATH} is not valid YAML` };
|
|
109
109
|
const parsed = indexSchema.safeParse(document.toJS());
|
|
110
|
-
if (!parsed.success)
|
|
111
|
-
return {
|
|
112
|
-
}
|
|
110
|
+
if (!parsed.success)
|
|
111
|
+
return { problem: `${REPOSITORY_INDEX_PATH} is not a schema_version 1 repository index` };
|
|
113
112
|
return { document, index: parsed.data };
|
|
114
113
|
}
|
|
114
|
+
/** The existing index (with its document, to edit in place), none, or why it cannot be edited. */
|
|
115
|
+
async function readIndex({ indexPath, path }) {
|
|
116
|
+
const existing = await parseIndex(indexPath);
|
|
117
|
+
return existing && 'problem' in existing ? { reason: `${existing.problem}; declare ${path} under resources by hand` } : existing;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The resources a repository's index declares, as written (unknown fields kept), for a reader that only looks.
|
|
121
|
+
* Null when the repository has no index; throws when the file is there and cannot be read as one.
|
|
122
|
+
*/
|
|
123
|
+
export async function readRepositoryResources({ gitRoot }) {
|
|
124
|
+
const existing = await parseIndex(join(gitRoot, REPOSITORY_INDEX_PATH));
|
|
125
|
+
if (existing === null)
|
|
126
|
+
return null;
|
|
127
|
+
if ('problem' in existing)
|
|
128
|
+
throw new Error(existing.problem);
|
|
129
|
+
return existing.index.resources ?? [];
|
|
130
|
+
}
|
|
115
131
|
/** Why `path` must not become a resource, or null when it can. */
|
|
116
132
|
function conflict({ path, gitRoot, index }) {
|
|
117
133
|
const applications = index
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The newest of these `vX.Y.Z` releases. */
|
|
2
|
+
export declare function newestRelease(releases: readonly string[]): string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* The seq-ci releases the checked-in seq and seq promote workflows call. A hand edit can move these ahead of
|
|
5
|
+
* `.seq/github.yml`, so settings never render the workflows older than they already are.
|
|
6
|
+
*/
|
|
7
|
+
export declare function workflowSeqCiReleases({ root, read }: {
|
|
8
|
+
root: string;
|
|
9
|
+
read: (path: string) => Promise<string | null>;
|
|
10
|
+
}): Promise<string[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Which seq-ci release a repository's checked-in workflows already call. */
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const SEQ_CI_WORKFLOW_REF = new RegExp(`sequenceholdings\\/seq-ci\\/\\.github\\/workflows\\/[\\w.-]+@(v\\d+\\.\\d+\\.\\d+)\\b`, 'g');
|
|
4
|
+
const SEQ_CI_WORKFLOW_PATHS = ['.github/workflows/seq.yml', '.github/workflows/seq-promote.yml'];
|
|
5
|
+
function releaseParts(release) {
|
|
6
|
+
return release.slice(1).split('.').map(Number);
|
|
7
|
+
}
|
|
8
|
+
/** The newest of these `vX.Y.Z` releases. */
|
|
9
|
+
export function newestRelease(releases) {
|
|
10
|
+
return [...releases].sort((a, b) => {
|
|
11
|
+
const [x, y] = [releaseParts(a), releaseParts(b)];
|
|
12
|
+
return (x[0] - y[0]) || (x[1] - y[1]) || (x[2] - y[2]);
|
|
13
|
+
}).at(-1);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The seq-ci releases the checked-in seq and seq promote workflows call. A hand edit can move these ahead of
|
|
17
|
+
* `.seq/github.yml`, so settings never render the workflows older than they already are.
|
|
18
|
+
*/
|
|
19
|
+
export async function workflowSeqCiReleases({ root, read }) {
|
|
20
|
+
const releases = [];
|
|
21
|
+
for (const path of SEQ_CI_WORKFLOW_PATHS) {
|
|
22
|
+
const text = await read(join(root, path));
|
|
23
|
+
for (const match of text?.matchAll(SEQ_CI_WORKFLOW_REF) ?? [])
|
|
24
|
+
releases.push(match[1]);
|
|
25
|
+
}
|
|
26
|
+
return releases;
|
|
27
|
+
}
|
package/dist/sdk-source.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export declare function compareSdk({ name, cwd }: {
|
|
|
35
35
|
}): SdkComparison;
|
|
36
36
|
/** The version of `name` this command loaded through importSdk, or undefined before it has. */
|
|
37
37
|
export declare function selectedSdkVersion(name: string): string | undefined;
|
|
38
|
+
/** Whether the load of `name` was asked for the project's copy, including when it fell back to the bundled one. */
|
|
39
|
+
export declare function projectSdkRequested(name: string): boolean;
|
|
38
40
|
/**
|
|
39
41
|
* The file `<name><subpath>` resolves to in the copy this command loaded, so a module imported indirectly (an ORM
|
|
40
42
|
* schema importing `@sequenceholdings/orm/authoring`) matches it. Undefined when that copy does not export it.
|
|
@@ -43,6 +45,19 @@ export declare function selectedSdkFile({ name, subpath }: {
|
|
|
43
45
|
name: string;
|
|
44
46
|
subpath: string;
|
|
45
47
|
}): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* What the CLI itself calls on a module it loads through importSdk, keyed by `<package><subpath>`.
|
|
50
|
+
*
|
|
51
|
+
* A list, not "every export of the bundled copy": a project pinned to an older SDK that has everything the CLI calls
|
|
52
|
+
* must still run, and it never has the helpers a newer bundled copy added for other callers. Add a name here when
|
|
53
|
+
* the CLI starts calling it (orm/delegate.ts, app/adapters.ts). A module not listed is compared against every
|
|
54
|
+
* bundled export.
|
|
55
|
+
*
|
|
56
|
+
* The list covers calls only. What the CLI hands a module through the environment (the ORM's break-glass reason,
|
|
57
|
+
* whose answer also carries the deploy notice) is not an export, so an older copy passes this check and ignores
|
|
58
|
+
* it: the caller that sets such a variable checks the loaded copy reads it (orm/delegate.ts breakGlassRefusal).
|
|
59
|
+
*/
|
|
60
|
+
export declare const USED_SDK_EXPORTS: Readonly<Record<string, readonly string[]>>;
|
|
46
61
|
/**
|
|
47
62
|
* Import `<name><subpath>` from the copy this command runs. `bundled` is the CLI's own static import, so the bundler
|
|
48
63
|
* keeps it. Prints a note once when the project's copy is a different version than the one used.
|
package/dist/sdk-source.js
CHANGED
|
@@ -89,12 +89,16 @@ export function compareSdk({ name, cwd }) {
|
|
|
89
89
|
return { name, bundled, project, differs: Boolean(bundled && project && bundled !== project) };
|
|
90
90
|
}
|
|
91
91
|
const noted = new Set();
|
|
92
|
-
/** The copy of each SDK this command loaded: its version,
|
|
92
|
+
/** The copy of each SDK this command loaded: its version, the project's directory when it was the project's, and the mode asked for. */
|
|
93
93
|
const selected = new Map();
|
|
94
94
|
/** The version of `name` this command loaded through importSdk, or undefined before it has. */
|
|
95
95
|
export function selectedSdkVersion(name) {
|
|
96
96
|
return selected.get(name)?.version;
|
|
97
97
|
}
|
|
98
|
+
/** Whether the load of `name` was asked for the project's copy, including when it fell back to the bundled one. */
|
|
99
|
+
export function projectSdkRequested(name) {
|
|
100
|
+
return selected.get(name)?.mode === 'project';
|
|
101
|
+
}
|
|
98
102
|
/**
|
|
99
103
|
* The file `<name><subpath>` resolves to in the copy this command loaded, so a module imported indirectly (an ORM
|
|
100
104
|
* schema importing `@sequenceholdings/orm/authoring`) matches it. Undefined when that copy does not export it.
|
|
@@ -110,14 +114,29 @@ export function selectedSdkFile({ name, subpath }) {
|
|
|
110
114
|
return undefined;
|
|
111
115
|
}
|
|
112
116
|
}
|
|
113
|
-
/**
|
|
114
|
-
|
|
117
|
+
/**
|
|
118
|
+
* What the CLI itself calls on a module it loads through importSdk, keyed by `<package><subpath>`.
|
|
119
|
+
*
|
|
120
|
+
* A list, not "every export of the bundled copy": a project pinned to an older SDK that has everything the CLI calls
|
|
121
|
+
* must still run, and it never has the helpers a newer bundled copy added for other callers. Add a name here when
|
|
122
|
+
* the CLI starts calling it (orm/delegate.ts, app/adapters.ts). A module not listed is compared against every
|
|
123
|
+
* bundled export.
|
|
124
|
+
*
|
|
125
|
+
* The list covers calls only. What the CLI hands a module through the environment (the ORM's break-glass reason,
|
|
126
|
+
* whose answer also carries the deploy notice) is not an export, so an older copy passes this check and ignores
|
|
127
|
+
* it: the caller that sets such a variable checks the loaded copy reads it (orm/delegate.ts breakGlassRefusal).
|
|
128
|
+
*/
|
|
129
|
+
export const USED_SDK_EXPORTS = {
|
|
130
|
+
'@sequenceholdings/orm/cli': ['runCli', 'setTokenProvider', 'ORM_MODULE_PATH_ENV'],
|
|
131
|
+
};
|
|
132
|
+
/** The API the CLI calls (`used`; else all of the bundled copy's) that the bundled copy has and the project's lacks. */
|
|
133
|
+
function missingExports({ loaded, bundled, used }) {
|
|
115
134
|
if (typeof bundled !== 'object' || bundled === null || typeof loaded !== 'object' || loaded === null)
|
|
116
135
|
return [];
|
|
117
|
-
return Object.keys(bundled).filter((key) => !(key in loaded));
|
|
136
|
+
return (used ?? Object.keys(bundled)).filter((key) => key in bundled && !(key in loaded));
|
|
118
137
|
}
|
|
119
138
|
/** The project's copy at `file`, or the bundled one with a warning when it cannot load or lacks what the CLI calls. */
|
|
120
|
-
async function projectCopy({ name, file, directory, bundled, comparison }) {
|
|
139
|
+
async function projectCopy({ name, subpath, file, directory, bundled, comparison }) {
|
|
121
140
|
const fallbackTo = comparison.bundled ?? 'copy';
|
|
122
141
|
let loaded;
|
|
123
142
|
try {
|
|
@@ -134,11 +153,11 @@ async function projectCopy({ name, file, directory, bundled, comparison }) {
|
|
|
134
153
|
catch {
|
|
135
154
|
// ORM and pipeline-spec are optional peers of a global CLI: with no bundled copy to compare against or fall
|
|
136
155
|
// back to, the project's copy that loaded is the one to run.
|
|
137
|
-
selected.set(name, { version: comparison.project, projectDirectory: directory });
|
|
156
|
+
selected.set(name, { version: comparison.project, projectDirectory: directory, mode: 'project' });
|
|
138
157
|
// The project's copy of the same package, which loaded.
|
|
139
158
|
return loaded;
|
|
140
159
|
}
|
|
141
|
-
const missing = missingExports({ loaded, bundled: fallback });
|
|
160
|
+
const missing = missingExports({ loaded, bundled: fallback, used: USED_SDK_EXPORTS[`${name}${subpath.slice(1)}`] });
|
|
142
161
|
if (missing.length) {
|
|
143
162
|
note(name, `warning: this project's ${name} ${comparison.project ?? ''} lacks ${missing.slice(0, 3).join(', ')}${missing.length > 3 ? ', …' : ''}, ` +
|
|
144
163
|
`which seq-studio uses; using the bundled ${fallbackTo}. Upgrade the project's ${name} to run it.`);
|
|
@@ -146,8 +165,8 @@ async function projectCopy({ name, file, directory, bundled, comparison }) {
|
|
|
146
165
|
}
|
|
147
166
|
if (comparison.differs)
|
|
148
167
|
note(name, `note: using this project's ${name} ${comparison.project} (sdk: project), not the bundled ${comparison.bundled}`);
|
|
149
|
-
selected.set(name, { version: comparison.project, projectDirectory: directory });
|
|
150
|
-
//
|
|
168
|
+
selected.set(name, { version: comparison.project, projectDirectory: directory, mode: 'project' });
|
|
169
|
+
// Has what the CLI calls, checked above: the project's copy of the same package.
|
|
151
170
|
return loaded;
|
|
152
171
|
}
|
|
153
172
|
/**
|
|
@@ -160,9 +179,9 @@ export async function importSdk({ name, subpath = '.', bundled, cwd }) {
|
|
|
160
179
|
const project = mode === 'project' ? projectSdk({ name, cwd }) : undefined;
|
|
161
180
|
const file = project ? exportedFile({ directory: project.directory, subpath }) : undefined;
|
|
162
181
|
// Every path below and every fallback in projectCopy loads the bundled copy; projectCopy overrides on success.
|
|
163
|
-
selected.set(name, { version: comparison.bundled });
|
|
182
|
+
selected.set(name, { version: comparison.bundled, mode });
|
|
164
183
|
if (file && project)
|
|
165
|
-
return projectCopy({ name, file, directory: project.directory, bundled, comparison });
|
|
184
|
+
return projectCopy({ name, subpath, file, directory: project.directory, bundled, comparison });
|
|
166
185
|
if (mode === 'project' && !project)
|
|
167
186
|
note(name, `note: sdk: project, but this project does not install ${name}; using the bundled ${comparison.bundled ?? 'copy'}`);
|
|
168
187
|
else if (comparison.differs) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequenceholdings/studio-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth whoami`. Includes Auth0 browser login shared with seqapi.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"yaml": "^2.8.4",
|
|
47
47
|
"zod": "4.6.6",
|
|
48
48
|
"@sequenceholdings/agent-spec": "0.1.6",
|
|
49
|
-
"@sequenceholdings/artifact-studio": "0.11.
|
|
50
|
-
"@sequenceholdings/lattice": "0.1.9",
|
|
49
|
+
"@sequenceholdings/artifact-studio": "0.11.25",
|
|
51
50
|
"@sequenceholdings/storage": "0.1.8",
|
|
52
51
|
"@sequenceholdings/platform": "0.1.5",
|
|
53
|
-
"@sequenceholdings/managed-functions": "0.5.16"
|
|
52
|
+
"@sequenceholdings/managed-functions": "0.5.16",
|
|
53
|
+
"@sequenceholdings/lattice": "0.1.9"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@sequenceholdings/orm": "2.12.1",
|
package/release-summary.json
CHANGED
|
@@ -12,5 +12,7 @@
|
|
|
12
12
|
"0.9.26": "Includes ORM 2.12.0: resolved tables can set rows: { keys: 'indexed' } so a policy or link filter that probes them by key reaches every source's index instead of rebuilding the view per probed row. Atlas checks that only the generated view reads its key relations.",
|
|
13
13
|
"0.9.27": "Includes ORM 2.12.1: orm generate --migration-export writes compact JSON, so namespaces with many operations stay under the export size limit, and committed migration chain links carry their reviewed destructive flag, which repository CI reads as consent to apply that data loss.",
|
|
14
14
|
"1.0.0": "seq-studio 1.0: commands, flags, exit codes and JSON output are now stable. Old spellings still work. promote, secret attach and apply, repos, and --repo from git-service are deprecated: each prints its replacement and is removed in 2.0.",
|
|
15
|
-
"1.0.1": "Next.js artifacts may now pin next@16.4.6, which fixes two Next.js security advisories, as well as 16.4.1. New apps are still scaffolded on 16.4.1 until every Atlas environment admits 16.4.6."
|
|
15
|
+
"1.0.1": "Next.js artifacts may now pin next@16.4.6, which fixes two Next.js security advisories, as well as 16.4.1. New apps are still scaffolded on 16.4.1 until every Atlas environment admits 16.4.6.",
|
|
16
|
+
"1.0.2": "seq-studio upgrade and repo init no longer move the seq-ci workflows back to an older release when they were bumped ahead of seq_ci in .seq/github.yml. Top-level help and setup hints now point at seq-studio login <deployment-url>.",
|
|
17
|
+
"1.0.3": "Artifact builds now use Atlas UI 4.2.0, including the shared SideNav and SideNavLayout components, through Artifact Studio 0.11.25."
|
|
16
18
|
}
|