@sequenceholdings/studio-cli 0.9.23 → 0.9.24
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 +152 -144
- package/dist/access/commands.js +3 -5
- package/dist/access/principal.js +2 -2
- package/dist/access/tier-hosts.js +2 -2
- package/dist/agents/commands.d.ts +1 -1
- package/dist/agents/commands.js +9 -9
- package/dist/agents/scaffold.js +3 -3
- package/dist/agents/voice.d.ts +1 -1
- package/dist/agents/voice.js +1 -1
- package/dist/app/commands.d.ts +2 -2
- package/dist/app/commands.js +31 -21
- package/dist/app/deploy.d.ts +1 -1
- package/dist/app/deploy.js +1 -1
- package/dist/app/manifest.d.ts +9 -9
- package/dist/app/manifest.js +1 -1
- package/dist/app/prepare.js +1 -1
- package/dist/app/primitive-scaffold.js +1 -1
- package/dist/app/readme.js +6 -6
- package/dist/app/scaffold.js +1 -1
- package/dist/app/validate.d.ts +1 -1
- package/dist/app/workspace-scaffold.js +1 -1
- package/dist/artifact/delegate.d.ts +1 -1
- package/dist/artifact/delegate.js +43 -3
- package/dist/auth-cmds/commands.js +1 -2
- package/dist/bin.js +12 -2
- package/dist/cli-attribution.d.ts +4 -0
- package/dist/cli-attribution.js +25 -3
- package/dist/cli-errors.d.ts +9 -1
- package/dist/cli-errors.js +20 -9
- package/dist/command-contract.d.ts +7 -182
- package/dist/command-contract.js +9 -33
- package/dist/command-help.d.ts +4 -4
- package/dist/command-help.js +24 -24
- package/dist/command-telemetry.js +2 -2
- package/dist/config-dir.d.ts +8 -0
- package/dist/config-dir.js +35 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +15 -3
- package/dist/docs/commands.js +9 -4
- package/dist/env-registry.d.ts +4 -0
- package/dist/env-registry.js +15 -6
- package/dist/envs/commands.d.ts +3 -0
- package/dist/envs/commands.js +11 -0
- package/dist/exit-codes.d.ts +16 -0
- package/dist/exit-codes.js +27 -0
- package/dist/functions/bundle.d.ts +1 -1
- package/dist/functions/commands.js +19 -18
- package/dist/functions/manifest.js +1 -1
- package/dist/functions/service-account-guidance.d.ts +1 -1
- package/dist/functions/service-account-guidance.js +2 -2
- package/dist/lifecycle/check.d.ts +13 -0
- package/dist/lifecycle/check.js +116 -0
- package/dist/lifecycle/commands.d.ts +14 -0
- package/dist/lifecycle/commands.js +121 -0
- package/dist/lifecycle/plan.d.ts +28 -0
- package/dist/lifecycle/plan.js +113 -0
- package/dist/lifecycle/rollback.d.ts +7 -0
- package/dist/lifecycle/rollback.js +89 -0
- package/dist/lifecycle/seq-ci-tools.d.ts +107 -0
- package/dist/lifecycle/seq-ci-tools.js +177 -0
- package/dist/lifecycle/upgrade.d.ts +3 -0
- package/dist/lifecycle/upgrade.js +38 -0
- package/dist/machine-output.d.ts +11 -2
- package/dist/machine-output.js +32 -10
- package/dist/main.d.ts +16 -6
- package/dist/main.js +187 -361
- package/dist/orgs.d.ts +45 -0
- package/dist/orgs.js +106 -0
- package/dist/orm/delegate.d.ts +1 -1
- package/dist/orm/delegate.js +32 -18
- package/dist/orm/deployment-policy.js +1 -2
- package/dist/orm/discover.js +6 -8
- package/dist/orm/execute.d.ts +1 -1
- package/dist/orm/execute.js +5 -6
- package/dist/orm/failures.js +2 -2
- package/dist/orm/help.d.ts +1 -1
- package/dist/orm/help.js +5 -5
- package/dist/orm/history.js +1 -2
- package/dist/orm/operation-show.js +1 -2
- package/dist/orm/version-guard.d.ts +7 -2
- package/dist/orm/version-guard.js +12 -7
- package/dist/pipeline/codegen.js +2 -2
- package/dist/pipeline/commands.js +9 -7
- package/dist/pipeline/discovery.d.ts +1 -1
- package/dist/pipeline/discovery.js +2 -3
- package/dist/pipeline/help.d.ts +1 -1
- package/dist/pipeline/help.js +1 -1
- package/dist/pipeline/lifecycle.js +1 -1
- package/dist/pipeline/stage-secrets.js +4 -4
- package/dist/pipeline/templates.js +2 -2
- package/dist/pnpm-auto-update.js +3 -3
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +1 -1
- package/dist/principals/commands.d.ts +1 -1
- package/dist/principals/commands.js +13 -14
- package/dist/process/commands.js +4 -1
- package/dist/process/run-steps.d.ts +2 -2
- package/dist/process/runs.js +1 -2
- package/dist/registry/commands.d.ts +4 -0
- package/dist/registry/commands.js +281 -0
- package/dist/registry/help.d.ts +8 -0
- package/dist/registry/help.js +64 -0
- package/dist/registry/lifecycle-commands.d.ts +3 -0
- package/dist/registry/lifecycle-commands.js +60 -0
- package/dist/registry/lookup.d.ts +6 -0
- package/dist/registry/lookup.js +18 -0
- package/dist/registry/runners.d.ts +14 -0
- package/dist/registry/runners.js +206 -0
- package/dist/registry/spec.d.ts +45 -0
- package/dist/registry/spec.js +8 -0
- package/dist/repos/commands.js +1 -2
- package/dist/repos/github-connect-command.d.ts +10 -1
- package/dist/repos/github-connect-command.js +52 -11
- package/dist/repos/github-init.d.ts +9 -2
- package/dist/repos/github-init.js +18 -2
- package/dist/repos/init-repo.js +1 -2
- package/dist/run-pinned.d.ts +48 -0
- package/dist/run-pinned.js +127 -0
- package/dist/sdk-source.d.ts +64 -0
- package/dist/sdk-source.js +199 -0
- package/dist/secrets/commands.d.ts +1 -1
- package/dist/secrets/commands.js +29 -24
- package/dist/service-accounts/commands.d.ts +1 -1
- package/dist/service-accounts/commands.js +4 -5
- package/dist/staged-env.d.ts +14 -0
- package/dist/staged-env.js +73 -0
- package/dist/storage/commands.js +21 -22
- package/dist/templates/catalog.d.ts +4 -4
- package/dist/update-check.js +3 -3
- package/dist/version-support.d.ts +39 -0
- package/dist/version-support.js +71 -0
- package/package.json +8 -7
- package/release-summary.json +2 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run the repository's pinned seq-ci release on this machine: the same `affected.mjs` and `check.mjs` its GitHub
|
|
3
|
+
* jobs run, from the same tools image, against the same candidate images. Nothing here reimplements the planner, so
|
|
4
|
+
* a local pass means what a CI pass means.
|
|
5
|
+
*
|
|
6
|
+
* The tools are copied out of the release's tools image once per digest into
|
|
7
|
+
* `~/.cache/seq-studio/seq-ci-tools/<digest>`. Pulling the images needs read access to their registry, as CI has.
|
|
8
|
+
*/
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
10
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
11
|
+
import { mkdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
12
|
+
import { homedir } from 'node:os';
|
|
13
|
+
import { delimiter, isAbsolute, join } from 'node:path';
|
|
14
|
+
import { load as yamlLoad } from 'js-yaml';
|
|
15
|
+
const DIGEST_REF = /^[^\s@]+@sha256:([0-9a-f]{64})$/;
|
|
16
|
+
const ZERO_DIGEST = /@sha256:0{64}$/;
|
|
17
|
+
/** The images and policy version a seq-ci release's pipeline workflow pins. */
|
|
18
|
+
export function seqCiPinsFromWorkflow({ workflowText, release }) {
|
|
19
|
+
const workflow = yamlLoad(workflowText);
|
|
20
|
+
const env = workflow && typeof workflow === 'object' ? Reflect.get(workflow, 'env') : undefined;
|
|
21
|
+
const read = (name) => {
|
|
22
|
+
const value = env && typeof env === 'object' ? Reflect.get(env, name) : undefined;
|
|
23
|
+
if (typeof value !== 'string' || !value.trim())
|
|
24
|
+
throw new Error(`seq-ci ${release} does not set ${name}`);
|
|
25
|
+
return value.trim();
|
|
26
|
+
};
|
|
27
|
+
const image = (name) => {
|
|
28
|
+
const value = read(name);
|
|
29
|
+
if (!DIGEST_REF.test(value))
|
|
30
|
+
throw new Error(`seq-ci ${release} does not pin ${name} by digest`);
|
|
31
|
+
if (ZERO_DIGEST.test(value))
|
|
32
|
+
throw new Error(`seq-ci ${release} has no published images yet (${name} is a placeholder)`);
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
return { release, toolsImage: image('SEQ_CI_TOOLS_IMAGE'), candidateImage: image('SEQ_CI_CANDIDATE_IMAGE'),
|
|
36
|
+
nextImage: image('SEQ_CI_NEXT_IMAGE'), policyVersion: read('SEQ_CI_POLICY_VERSION') };
|
|
37
|
+
}
|
|
38
|
+
export const run = (command, args, options = {}) => {
|
|
39
|
+
const result = spawnSync(command, args, { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, ...options });
|
|
40
|
+
if (result.error)
|
|
41
|
+
return { status: null, stdout: '', stderr: result.error.message };
|
|
42
|
+
return { status: result.status, stdout: String(result.stdout ?? ''), stderr: String(result.stderr ?? '') };
|
|
43
|
+
};
|
|
44
|
+
function must({ result, what, next }) {
|
|
45
|
+
if (result.status !== 0)
|
|
46
|
+
throw new Error(`${what} failed: ${result.stderr.trim().split('\n').slice(-3).join(' ') || `exit ${result.status}`}. ${next}`);
|
|
47
|
+
return result.stdout.trim();
|
|
48
|
+
}
|
|
49
|
+
const REGISTRY_HINT = 'Pulling seq-ci images needs read access to their registry: run `gcloud auth configure-docker us-central1-docker.pkg.dev` with an account that has it.';
|
|
50
|
+
export function toolsCacheRoot() {
|
|
51
|
+
return join(process.env.XDG_CACHE_HOME ?? join(homedir(), '.cache'), 'seq-studio', 'seq-ci-tools');
|
|
52
|
+
}
|
|
53
|
+
/** The release's tools directory, copied out of its tools image the first time this digest is used. */
|
|
54
|
+
export async function seqCiToolsDirectory({ pins, docker = 'docker', exec = run, cacheRoot = toolsCacheRoot() }) {
|
|
55
|
+
const digest = DIGEST_REF.exec(pins.toolsImage)?.[1];
|
|
56
|
+
if (!digest)
|
|
57
|
+
throw new Error(`Invalid tools image ${pins.toolsImage}`);
|
|
58
|
+
const directory = join(cacheRoot, digest);
|
|
59
|
+
if (existsSync(join(directory, '.complete')))
|
|
60
|
+
return directory;
|
|
61
|
+
must({ result: exec(docker, ['pull', '--quiet', pins.toolsImage]), what: `docker pull ${pins.toolsImage}`, next: REGISTRY_HINT });
|
|
62
|
+
const container = must({ result: exec(docker, ['create', pins.toolsImage, '/noop']), what: 'docker create', next: 'Is Docker running?' });
|
|
63
|
+
const staging = `${directory}.partial-${process.pid}`;
|
|
64
|
+
try {
|
|
65
|
+
await rm(staging, { recursive: true, force: true });
|
|
66
|
+
await mkdir(cacheRoot, { recursive: true });
|
|
67
|
+
must({ result: exec(docker, ['cp', `${container}:/seq-ci`, staging]), what: 'copying the seq-ci tools', next: 'Is Docker running?' });
|
|
68
|
+
await writeFile(join(staging, '.complete'), `${pins.toolsImage}\n`);
|
|
69
|
+
await rm(directory, { recursive: true, force: true });
|
|
70
|
+
await rename(staging, directory);
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
exec(docker, ['rm', container]);
|
|
74
|
+
await rm(staging, { recursive: true, force: true });
|
|
75
|
+
}
|
|
76
|
+
return directory;
|
|
77
|
+
}
|
|
78
|
+
/** A pinned image's local image id, pulling it first: what the planner and checks key their toolchain on. */
|
|
79
|
+
export function localImageId({ image, docker = 'docker', exec = run }) {
|
|
80
|
+
must({ result: exec(docker, ['pull', '--quiet', image]), what: `docker pull ${image}`, next: REGISTRY_HINT });
|
|
81
|
+
const id = must({ result: exec(docker, ['image', 'inspect', '--format', '{{.Id}}', image]), what: `docker image inspect ${image}`, next: 'Is Docker running?' });
|
|
82
|
+
if (!/^sha256:[0-9a-f]{64}$/.test(id))
|
|
83
|
+
throw new Error(`Docker returned no image id for ${image}`);
|
|
84
|
+
return id;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* What a local run compares: the committed HEAD against where it left the dev branch, as a pull request into it would.
|
|
88
|
+
* Uncommitted edits are never part of a plan or check; CI sees only commits.
|
|
89
|
+
*/
|
|
90
|
+
export function localRevisions({ directory, devBranch, base, head, exec = run }) {
|
|
91
|
+
const git = (args, what) => must({ result: exec('git', ['-C', directory, ...args]), what, next: 'Run it inside a git checkout.' });
|
|
92
|
+
const resolvedHead = git(['rev-parse', '--verify', `${head ?? 'HEAD'}^{commit}`], `resolving ${head ?? 'HEAD'}`);
|
|
93
|
+
const resolvedBase = base
|
|
94
|
+
? git(['rev-parse', '--verify', `${base}^{commit}`], `resolving ${base}`)
|
|
95
|
+
: git(['merge-base', resolvedHead, `refs/remotes/origin/${devBranch}`], `finding where HEAD left origin/${devBranch} (git fetch origin ${devBranch}?)`);
|
|
96
|
+
const branch = exec('git', ['-C', directory, 'rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim() || 'HEAD';
|
|
97
|
+
return { base: resolvedBase, head: resolvedHead, branch };
|
|
98
|
+
}
|
|
99
|
+
/** `node affected.mjs` arguments, exactly as seq-ci's plan job passes them. */
|
|
100
|
+
export function affectedArgs({ tools, pins, directory, githubRepositoryId, repository, revisions, candidateId }) {
|
|
101
|
+
return [join(tools, 'affected.mjs'), '--dir', directory, '--base', revisions.base, '--head', revisions.head,
|
|
102
|
+
'--repo-id', `github:${githubRepositoryId}`, '--repository', repository,
|
|
103
|
+
'--toolchain-image', candidateId, '--policy-version', pins.policyVersion];
|
|
104
|
+
}
|
|
105
|
+
/** `node check.mjs` arguments for one target, exactly as seq-ci's check job passes them. */
|
|
106
|
+
export function checkArgs({ tools, pins, directory, githubRepositoryId, repository, revisions, candidateId, nextId, target, runId }) {
|
|
107
|
+
return [join(tools, 'check.mjs'), '--dir', directory, '--target', target, '--base', revisions.base, '--head', revisions.head,
|
|
108
|
+
'--repo-id', `github:${githubRepositoryId}`, '--repository', repository, '--toolchain-image', candidateId, '--next-image', nextId,
|
|
109
|
+
'--policy-version', pins.policyVersion, '--run-id', runId, '--branch', revisions.branch];
|
|
110
|
+
}
|
|
111
|
+
/** The targets in affected.mjs's JSON result. */
|
|
112
|
+
export function parseAffected(stdout) {
|
|
113
|
+
const parsed = JSON.parse(stdout);
|
|
114
|
+
const targets = parsed && typeof parsed === 'object' ? Reflect.get(parsed, 'targets') : undefined;
|
|
115
|
+
const findings = parsed && typeof parsed === 'object' ? Reflect.get(parsed, 'findings') : undefined;
|
|
116
|
+
if (!Array.isArray(targets))
|
|
117
|
+
throw new Error(`affected.mjs returned no targets: ${stdout.slice(0, 200)}`);
|
|
118
|
+
return {
|
|
119
|
+
targets: targets.flatMap((target) => {
|
|
120
|
+
if (!target || typeof target !== 'object')
|
|
121
|
+
return [];
|
|
122
|
+
const key = Reflect.get(target, 'key');
|
|
123
|
+
const reasons = Reflect.get(target, 'reasons');
|
|
124
|
+
return typeof key === 'string'
|
|
125
|
+
? [{ key, affected: Reflect.get(target, 'affected') === true, reasons: Array.isArray(reasons) ? reasons.map(String) : [] }]
|
|
126
|
+
: [];
|
|
127
|
+
}),
|
|
128
|
+
findings: Array.isArray(findings) ? findings.filter((finding) => !!finding && typeof finding === 'object' && typeof Reflect.get(finding, 'severity') === 'string' && typeof Reflect.get(finding, 'message') === 'string') : [],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The absolute path of `docker`, which seq-ci's check runner requires (it refuses bare executable names): SEQ_CI_DOCKER
|
|
133
|
+
* when set, else the first `docker` on PATH.
|
|
134
|
+
*/
|
|
135
|
+
export function dockerExecutable({ env = process.env, isExecutable = (path) => existsSync(path) } = {}) {
|
|
136
|
+
const configured = env.SEQ_CI_DOCKER?.trim();
|
|
137
|
+
if (configured) {
|
|
138
|
+
if (!isAbsolute(configured))
|
|
139
|
+
throw new Error(`SEQ_CI_DOCKER must be an absolute path (got ${configured})`);
|
|
140
|
+
return configured;
|
|
141
|
+
}
|
|
142
|
+
for (const directory of (env.PATH ?? '').split(delimiter).filter(Boolean)) {
|
|
143
|
+
const candidate = join(directory, 'docker');
|
|
144
|
+
if (isAbsolute(candidate) && isExecutable(candidate))
|
|
145
|
+
return candidate;
|
|
146
|
+
}
|
|
147
|
+
throw new Error('docker is not on PATH. Install Docker, or set SEQ_CI_DOCKER to its absolute path.');
|
|
148
|
+
}
|
|
149
|
+
const CHAINGUARD_AUTH = /^\s*\/\/libraries\.cgr\.dev\/[^:\s]*:_auth\s*=\s*(.+?)\s*$/;
|
|
150
|
+
/**
|
|
151
|
+
* The dependency registry credential seq-ci's dependency preparation uses: SEQ_CI_REGISTRY_AUTH when set, else the
|
|
152
|
+
* Chainguard `_auth` in the user's npm config, the same value CI's org secret holds. `${VAR}` references expand from the
|
|
153
|
+
* environment, as npm does. Undefined when neither has one.
|
|
154
|
+
*/
|
|
155
|
+
export function registryAuth({ env = process.env, readNpmrc = defaultReadNpmrc } = {}) {
|
|
156
|
+
const configured = env.SEQ_CI_REGISTRY_AUTH?.trim();
|
|
157
|
+
if (configured)
|
|
158
|
+
return configured;
|
|
159
|
+
const text = readNpmrc(env.NPM_CONFIG_USERCONFIG?.trim() || join(homedir(), '.npmrc'));
|
|
160
|
+
for (const line of (text ?? '').split('\n')) {
|
|
161
|
+
const match = CHAINGUARD_AUTH.exec(line);
|
|
162
|
+
if (!match)
|
|
163
|
+
continue;
|
|
164
|
+
const value = match[1].replace(/^["']|["']$/g, '').replace(/\$\{([A-Za-z0-9_]+)\}/g, (_, name) => env[name] ?? '');
|
|
165
|
+
if (value)
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
function defaultReadNpmrc(path) {
|
|
171
|
+
try {
|
|
172
|
+
return readFileSync(path, 'utf8');
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ExitCode, UsageError } from '../exit-codes.js';
|
|
2
|
+
const UPGRADE_USAGE = `usage:
|
|
3
|
+
seq-studio upgrade [--to <major.minor>] [--dir <checkout>] [--check]
|
|
4
|
+
|
|
5
|
+
Pin this repository to the running seq-studio's <major.minor> (or --to), in .seq/github.yml,
|
|
6
|
+
and refresh every file repo init manages to match. --check reports without writing (exit 3
|
|
7
|
+
when anything would change). Renovate opens the same change as a pull request.`;
|
|
8
|
+
export async function runUpgradeCommand(args) {
|
|
9
|
+
if (args.flags.help === true || args.flags.h === true) {
|
|
10
|
+
console.log(UPGRADE_USAGE);
|
|
11
|
+
return ExitCode.Ok;
|
|
12
|
+
}
|
|
13
|
+
const to = args.flags.to;
|
|
14
|
+
if (to !== undefined && (typeof to !== 'string' || !/^\d+\.\d+$/.test(to))) {
|
|
15
|
+
throw new UsageError('--to takes <major.minor>, for example --to 1.4');
|
|
16
|
+
}
|
|
17
|
+
const directory = typeof args.flags.dir === 'string' ? args.flags.dir : '.';
|
|
18
|
+
const { GITHUB_SETTINGS_PATH, initializeGitHubRepository, installedMajorMinor, resolveSettings } = await import('../repos/github-init.js');
|
|
19
|
+
const { repositorySettings } = await import('../orgs.js');
|
|
20
|
+
if (!await repositorySettings(directory)) {
|
|
21
|
+
throw new UsageError('No .seq/github.yml here; set the repository up first with: seq-studio repo init');
|
|
22
|
+
}
|
|
23
|
+
const cli = typeof to === 'string' ? to : installedMajorMinor();
|
|
24
|
+
const settings = await resolveSettings({ directory, cli });
|
|
25
|
+
const check = args.flags.check === true;
|
|
26
|
+
const preview = await initializeGitHubRepository({ directory, settings, write: false });
|
|
27
|
+
if (preview.some(({ path, status }) => path === GITHUB_SETTINGS_PATH && status === 'unmanaged')) {
|
|
28
|
+
throw new UsageError(`${GITHUB_SETTINGS_PATH} is not managed by seq-studio; edit its cli: pin by hand, or rerun seq-studio repo init`);
|
|
29
|
+
}
|
|
30
|
+
const reports = check ? preview : await initializeGitHubRepository({ directory, settings, write: true });
|
|
31
|
+
const changed = reports.filter(({ status }) => status === 'missing' || status === 'stale');
|
|
32
|
+
for (const report of reports)
|
|
33
|
+
console.log(`${report.status.padEnd(9)} ${report.path}`);
|
|
34
|
+
console.log(check
|
|
35
|
+
? `${changed.length === 0 ? 'Pinned to' : 'Would pin to'} seq-studio ${cli}.`
|
|
36
|
+
: `Pinned to seq-studio ${cli}. Commit the changed files.`);
|
|
37
|
+
return check && changed.length > 0 ? ExitCode.Blocked : ExitCode.Ok;
|
|
38
|
+
}
|
package/dist/machine-output.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
/** True when the arguments ask for JSON (or JSON Lines) on stdout. */
|
|
2
2
|
export declare function requestsMachineOutput(argv: readonly string[]): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Put `"schema": "<command>@1"` first in a JSON object document. Arrays and
|
|
5
|
+
* objects that already carry a `schema` key are printed unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withSchema(text: string, value: unknown, schema: string): string;
|
|
3
8
|
/**
|
|
4
9
|
* Route non-JSON console.log / console.info output to stderr until the
|
|
5
|
-
* returned restore function runs.
|
|
10
|
+
* returned restore function runs. With `schema`, single-document JSON objects
|
|
11
|
+
* also gain their schema name.
|
|
6
12
|
*/
|
|
7
|
-
export declare function guardMachineOutput(
|
|
13
|
+
export declare function guardMachineOutput({ schema, argv }?: {
|
|
14
|
+
schema?: string;
|
|
15
|
+
argv?: readonly string[];
|
|
16
|
+
}): () => void;
|
package/dist/machine-output.js
CHANGED
|
@@ -24,28 +24,50 @@ export function requestsMachineOutput(argv) {
|
|
|
24
24
|
}
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function parseJson(text) {
|
|
28
28
|
if (text.trim() === '')
|
|
29
|
-
return false;
|
|
29
|
+
return { ok: false };
|
|
30
30
|
try {
|
|
31
|
-
JSON.parse(text);
|
|
32
|
-
return true;
|
|
31
|
+
return { ok: true, value: JSON.parse(text) };
|
|
33
32
|
}
|
|
34
33
|
catch {
|
|
35
|
-
return false;
|
|
34
|
+
return { ok: false };
|
|
36
35
|
}
|
|
37
36
|
}
|
|
37
|
+
/** True for `--jsonl`, whose lines are stream items rather than one document. */
|
|
38
|
+
function requestsJsonLines(argv) {
|
|
39
|
+
return argv.some((arg) => arg === '--jsonl' || (arg.startsWith('--jsonl=') && arg !== '--jsonl=false'));
|
|
40
|
+
}
|
|
41
|
+
function indentOf(text) {
|
|
42
|
+
const match = /\n( +)\S/.exec(text);
|
|
43
|
+
return match?.[1]?.length ?? 0;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Put `"schema": "<command>@1"` first in a JSON object document. Arrays and
|
|
47
|
+
* objects that already carry a `schema` key are printed unchanged.
|
|
48
|
+
*/
|
|
49
|
+
export function withSchema(text, value, schema) {
|
|
50
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value) || 'schema' in value)
|
|
51
|
+
return text;
|
|
52
|
+
return JSON.stringify({ schema: `${schema}@1`, ...value }, null, indentOf(text) || undefined);
|
|
53
|
+
}
|
|
38
54
|
/**
|
|
39
55
|
* Route non-JSON console.log / console.info output to stderr until the
|
|
40
|
-
* returned restore function runs.
|
|
56
|
+
* returned restore function runs. With `schema`, single-document JSON objects
|
|
57
|
+
* also gain their schema name.
|
|
41
58
|
*/
|
|
42
|
-
export function guardMachineOutput() {
|
|
59
|
+
export function guardMachineOutput({ schema, argv = process.argv.slice(2) } = {}) {
|
|
43
60
|
const { log, info } = console;
|
|
61
|
+
const tagSchema = schema !== undefined && !requestsJsonLines(argv);
|
|
44
62
|
const route = (write) => (...args) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
const text = format(...args);
|
|
64
|
+
const parsed = parseJson(text);
|
|
65
|
+
if (!parsed.ok)
|
|
48
66
|
console.error(...args);
|
|
67
|
+
else if (tagSchema && args.length === 1 && typeof args[0] === 'string')
|
|
68
|
+
write(withSchema(text, parsed.value, schema));
|
|
69
|
+
else
|
|
70
|
+
write(...args);
|
|
49
71
|
};
|
|
50
72
|
console.log = route(log);
|
|
51
73
|
console.info = route(info);
|
package/dist/main.d.ts
CHANGED
|
@@ -7,24 +7,34 @@
|
|
|
7
7
|
* seq-studio deploy deploy all primitives from sequence.app.yml
|
|
8
8
|
* seq-studio process <sub> manage Lattice processes
|
|
9
9
|
* seq-studio artifact <sub> manage Artifact Studio apps
|
|
10
|
-
* seq-studio
|
|
11
|
-
* seq-studio
|
|
12
|
-
* seq-studio
|
|
10
|
+
* seq-studio function <sub> manage Managed Functions
|
|
11
|
+
* seq-studio agent <sub> manage typed agent definitions
|
|
12
|
+
* seq-studio secret <sub> manage org-owned Managed Secrets
|
|
13
13
|
* seq-studio repos <sub> manage platform git-service repos
|
|
14
14
|
* seq-studio templates <sub> publish and synchronize Git-backed templates
|
|
15
15
|
* seq-studio pipeline <sub> discover, query, author and operate Data Pipelines
|
|
16
16
|
* seq-studio auth <sub> manage Git authentication
|
|
17
17
|
* seq-studio docs <sub> search and read the environment's developer docs
|
|
18
18
|
* seq-studio feedback submit submit agent feedback
|
|
19
|
-
* seq-studio service-
|
|
19
|
+
* seq-studio service-account <sub> provision runtime identities
|
|
20
20
|
* seq-studio access <sub> manage resource access on every primitive
|
|
21
|
-
* seq-studio
|
|
21
|
+
* seq-studio principal <sub> find users, groups and service accounts to grant
|
|
22
22
|
* seq-studio envs <sub> add/list environments
|
|
23
23
|
* seq-studio login authenticate interactively with Auth0
|
|
24
24
|
* seq-studio logout remove cached user tokens
|
|
25
25
|
* seq-studio doctor check token + env + writer gate
|
|
26
26
|
* seq-studio help show usage
|
|
27
27
|
*/
|
|
28
|
-
/** Only command words from the router; never operands, flags, paths, or arguments. */
|
|
28
|
+
/** Only command words from the router; never operands, flags, paths, or arguments. Always the current spelling. */
|
|
29
29
|
export declare function commandTelemetryName(argv: string[]): string | null;
|
|
30
30
|
export declare function run(argv?: string[]): Promise<number>;
|
|
31
|
+
/** The command words that name a JSON document's schema, e.g. `repo status`. Always the current spelling. */
|
|
32
|
+
export declare function schemaName(argv: string[]): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* `--break-glass "<reason>"` on any command: removed from argv so no command's own parser sees it. An empty or
|
|
35
|
+
* missing reason is a usage error.
|
|
36
|
+
*/
|
|
37
|
+
export declare function takeBreakGlass(argv: string[]): {
|
|
38
|
+
argv: string[];
|
|
39
|
+
breakGlass?: string | Error;
|
|
40
|
+
};
|