@testsprite/testsprite-cli 0.16.0 → 0.18.0
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 +52 -147
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +48 -63
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +40 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +293 -487
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +741 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +129 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +108 -66
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +434 -43
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -229
- package/dist/commands/project.d.ts +19 -186
- package/dist/commands/project.js +108 -926
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +216 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1838
- package/dist/commands/test.js +1880 -13917
- package/dist/commands/testlist.d.ts +130 -5
- package/dist/commands/testlist.js +300 -342
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +23 -20
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +191 -110
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +12 -4
- package/dist/lib/client-factory.js +41 -30
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +9 -3
- package/dist/lib/conflict-reason.js +6 -3
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +75 -0
- package/dist/lib/conversation/api.js +151 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +29 -0
- package/dist/lib/conversation/context.js +82 -0
- package/dist/lib/conversation/environment.d.ts +16 -0
- package/dist/lib/conversation/environment.js +21 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +318 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +158 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +100 -0
- package/dist/lib/download.js +408 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +375 -747
- package/dist/lib/environment-tunnel.d.ts +19 -30
- package/dist/lib/environment-tunnel.js +168 -202
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +20 -30
- package/dist/lib/first-suite-hint.js +57 -72
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +354 -291
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +57 -4
- package/dist/lib/junit-report.js +202 -32
- package/dist/lib/local-target.d.ts +8 -7
- package/dist/lib/local-target.js +14 -13
- package/dist/lib/output.d.ts +2 -41
- package/dist/lib/output.js +13 -51
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +170 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +207 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +73 -0
- package/dist/lib/result/evidence.js +422 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +118 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +8 -8
- package/dist/lib/target-url.js +14 -24
- package/dist/lib/telemetry.d.ts +35 -15
- package/dist/lib/telemetry.js +38 -9
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +8 -2
- package/dist/lib/tunnel-session.js +24 -11
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/skills/testsprite-ci.skill.md +52 -23
- package/skills/testsprite-onboard.skill.md +70 -153
- package/skills/testsprite-verify.codex.md +54 -58
- package/skills/testsprite-verify.skill.md +189 -358
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -32
- package/dist/lib/deprecate.js +0 -39
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/commands/auth.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { formatWorkspaceStatus } from '../lib/workspace-status.js';
|
|
3
|
-
import { assertValidApiKey, assertValidEndpointUrl, emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
4
|
-
import { ApiError, CLIError, InterruptError } from '../lib/errors.js';
|
|
3
|
+
import { assertValidApiKey, assertValidEndpointUrl, emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, resolveRequestTimeoutMs, } from '../lib/client-factory.js';
|
|
4
|
+
import { ApiError, CLIError, InterruptError, RequestTimeoutError } from '../lib/errors.js';
|
|
5
5
|
import { facadeBaseUrl, resolvePortalBase } from '../lib/facade.js';
|
|
6
6
|
import { HttpClient } from '../lib/http.js';
|
|
7
7
|
import { globalShutdown } from '../lib/interrupt.js';
|
|
8
8
|
import { defaultCredentialsPath, deleteProfile, isCredentialsWritePermissionError, readProfile, writeProfile, } from '../lib/credentials.js';
|
|
9
9
|
import { loadConfig, normalizeEnvVar, resolveProfileName } from '../lib/config.js';
|
|
10
|
-
import { emitDeprecationNotice } from '../lib/deprecate.js';
|
|
11
10
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
12
11
|
import { promptSecret } from '../lib/prompt.js';
|
|
13
12
|
import { ME_RESPONSE_SCHEMA } from '../lib/response-schemas.js';
|
|
14
13
|
import { formatOrgBinding, formatOrgsSummary, formatPersonalScopeHint } from '../lib/org-render.js';
|
|
15
|
-
import {
|
|
14
|
+
import { terminalSafeLine, terminalSafeWriter } from '../lib/terminal-text.js';
|
|
16
15
|
const DEFAULT_API_URL = 'https://api.testsprite.com';
|
|
17
16
|
const FROM_ENV_MISSING_KEY = 'TESTSPRITE_API_KEY is not set in the environment. Set it and re-run with --from-env, or omit --from-env to enter the key interactively.';
|
|
18
|
-
const API_KEY_PAGE_PATH = '/dashboard/settings/apikey';
|
|
17
|
+
const API_KEY_PAGE_PATH = '/dashboard-v3/settings/apikey';
|
|
19
18
|
/**
|
|
20
19
|
* Where a key comes from. Names the Portal origin that matches the API
|
|
21
20
|
* endpoint; for an endpoint the host map does not know, names the page by
|
|
@@ -52,7 +51,7 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
52
51
|
// it defaults to stderr — stdout stays a pure result stream (the configured
|
|
53
52
|
// JSON/text), which matters under `--output json` (§8.1 stdout purity).
|
|
54
53
|
const prelude = deps.preludeWrite ?? ((chunk) => process.stderr.write(chunk));
|
|
55
|
-
const stderr = deps.stderr
|
|
54
|
+
const stderr = terminalSafeWriter(deps.stderr);
|
|
56
55
|
// Normalize the env endpoint: an empty / whitespace-only TESTSPRITE_API_URL is
|
|
57
56
|
// treated as unset. Without this, `''` (e.g. `export TESTSPRITE_API_URL=` in a
|
|
58
57
|
// shell profile) is non-nullish and would short-circuit the `??` chains below to
|
|
@@ -140,7 +139,10 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
140
139
|
baseUrl: facadeBaseUrl(apiUrl),
|
|
141
140
|
apiKey,
|
|
142
141
|
fetchImpl: deps.fetchImpl,
|
|
143
|
-
|
|
142
|
+
// Same precedence as every other command's client (flag > env > default,
|
|
143
|
+
// same clamping): `setup --from-env` previously read the flag only, so a
|
|
144
|
+
// TESTSPRITE_REQUEST_TIMEOUT_MS deadline was silently ignored here.
|
|
145
|
+
requestTimeoutMs: resolveRequestTimeoutMs(opts, env),
|
|
144
146
|
shutdownSignal: deps.shutdownSignal ?? globalShutdown.signal,
|
|
145
147
|
shutdown: deps.shutdown ?? globalShutdown,
|
|
146
148
|
});
|
|
@@ -155,7 +157,14 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
155
157
|
if (err instanceof InterruptError)
|
|
156
158
|
throw err;
|
|
157
159
|
const message = err instanceof Error ? err.message : String(err);
|
|
158
|
-
|
|
160
|
+
// A client-side timeout says nothing about the key. Rethrow it unchanged so
|
|
161
|
+
// it keeps its REQUEST_TIMEOUT code, exit 7 and request id, instead of the
|
|
162
|
+
// exit-3 "rejected" wrapper below that sends the user to rotate a good key.
|
|
163
|
+
if (err instanceof RequestTimeoutError) {
|
|
164
|
+
stderr(`API key check against ${apiUrl} timed out, profile NOT updated: ${terminalSafeLine(message)}`);
|
|
165
|
+
throw err;
|
|
166
|
+
}
|
|
167
|
+
stderr(`API key rejected by ${apiUrl}: ${terminalSafeLine(message)} — profile NOT updated`);
|
|
159
168
|
// When the verification call returned a typed API error (AUTH_INVALID,
|
|
160
169
|
// AUTH_FORBIDDEN, etc.), re-throw it directly so `index.ts` renders the
|
|
161
170
|
// full typed envelope under `--output json` (code, nextAction, requestId,
|
|
@@ -164,12 +173,12 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
164
173
|
// Augment the message with the endpoint context so text-mode users still
|
|
165
174
|
// see which host rejected the key.
|
|
166
175
|
if (err instanceof ApiError) {
|
|
167
|
-
err.message = `API key rejected by ${apiUrl}: ${message}
|
|
176
|
+
err.message = `API key rejected by ${apiUrl}: ${message}`;
|
|
168
177
|
throw err;
|
|
169
178
|
}
|
|
170
|
-
//
|
|
179
|
+
// Anything else (truly unexpected throws like a TypeError from a
|
|
171
180
|
// misconfigured fetchImpl). Exit 3 (auth family).
|
|
172
|
-
throw new CLIError(`API key rejected by ${apiUrl}: ${message}
|
|
181
|
+
throw new CLIError(`API key rejected by ${apiUrl}: ${message}`, 3);
|
|
173
182
|
}
|
|
174
183
|
let persisted = true;
|
|
175
184
|
try {
|
|
@@ -196,7 +205,6 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
196
205
|
export async function runWhoami(opts, deps = {}) {
|
|
197
206
|
const out = makeOutput(opts.output, deps);
|
|
198
207
|
const env = deps.env ?? process.env;
|
|
199
|
-
const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
200
208
|
// Resolve the endpoint URL so it can be surfaced in text output.
|
|
201
209
|
// Dry-run uses the flag/env/default chain without touching credentials.
|
|
202
210
|
// Real path uses the same loadConfig the HttpClient factory uses so the
|
|
@@ -227,41 +235,41 @@ export async function runWhoami(opts, deps = {}) {
|
|
|
227
235
|
out.print(me, data => {
|
|
228
236
|
const m = data;
|
|
229
237
|
const lines = [
|
|
230
|
-
`userId: ${m.userId}`,
|
|
238
|
+
`userId: ${terminalSafeLine(m.userId)}`,
|
|
231
239
|
// Human-readable identity, rendered only when the backend supplies it
|
|
232
240
|
// (dogfood L1866) — confirm the account at a glance before a billable run.
|
|
233
|
-
...(m.displayName ? [`name: ${m.displayName}`] : []),
|
|
234
|
-
...(m.email ? [`email: ${m.email}`] : []),
|
|
235
|
-
`keyId: ${m.keyId}`,
|
|
241
|
+
...(m.displayName ? [`name: ${terminalSafeLine(m.displayName)}`] : []),
|
|
242
|
+
...(m.email ? [`email: ${terminalSafeLine(m.email)}`] : []),
|
|
243
|
+
`keyId: ${terminalSafeLine(m.keyId)}`,
|
|
236
244
|
// Show the resolved endpoint so the user knows which env they are bound to
|
|
237
245
|
// without having to infer from the `env` field alone (dogfood L1788).
|
|
238
246
|
`endpoint: ${resolvedEndpoint}`,
|
|
239
|
-
`env: ${m.env}`,
|
|
240
|
-
`scopes: ${m.scopes.join(', ')}`,
|
|
241
|
-
// Org context — confirms whose wallet a billable command will draw
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
247
|
+
`env: ${terminalSafeLine(m.env)}`,
|
|
248
|
+
`scopes: ${terminalSafeLine(m.scopes.join(', '))}`,
|
|
249
|
+
// Org context — confirms whose wallet a billable command will draw from.
|
|
250
|
+
...(m.activeOrg
|
|
251
|
+
? [
|
|
252
|
+
`org: ${terminalSafeLine(m.activeOrg.name)} (${terminalSafeLine(m.activeOrg.plan)}, ${terminalSafeLine(m.activeOrg.role)})`,
|
|
253
|
+
]
|
|
246
254
|
: []),
|
|
247
255
|
// A paused (or payment-pending) workspace refuses every write, so say so
|
|
248
256
|
// next to the org it applies to instead of letting the next command find out.
|
|
249
|
-
...(
|
|
257
|
+
...(formatWorkspaceStatus(m.activeOrg?.workspace)
|
|
250
258
|
? [`workspace: ${formatWorkspaceStatus(m.activeOrg?.workspace)}`]
|
|
251
259
|
: []),
|
|
252
|
-
// Authoritative routing mode, rendered only when the backend supplies it.
|
|
253
|
-
...(m.v3Enabled !== undefined ? [`routing: ${routingLabel(m.v3Enabled)}`] : []),
|
|
254
260
|
// Org attribution — account-wide membership list, rendered only when
|
|
255
261
|
// the backend supplies a non-empty list.
|
|
256
262
|
...(formatOrgsSummary(m.organizations)
|
|
257
|
-
? [`orgs: ${formatOrgsSummary(m.organizations)}`]
|
|
263
|
+
? [`orgs: ${terminalSafeLine(String(formatOrgsSummary(m.organizations)))}`]
|
|
258
264
|
: []),
|
|
259
265
|
// The calling key's own org binding — membership keys only.
|
|
260
|
-
...(formatOrgBinding(m.org)
|
|
266
|
+
...(formatOrgBinding(m.org)
|
|
267
|
+
? [`org binding: ${terminalSafeLine(String(formatOrgBinding(m.org)))}`]
|
|
268
|
+
: []),
|
|
261
269
|
// A personal-scoped key held by someone who is also in a team: say so
|
|
262
270
|
// here rather than letting the team's projects just not show up.
|
|
263
271
|
...(formatPersonalScopeHint(m.organizations, m.org)
|
|
264
|
-
? [`note: ${formatPersonalScopeHint(m.organizations, m.org)}`]
|
|
272
|
+
? [`note: ${terminalSafeLine(String(formatPersonalScopeHint(m.organizations, m.org)))}`]
|
|
265
273
|
: []),
|
|
266
274
|
];
|
|
267
275
|
// C2: warn in text mode when key cannot write/run
|
|
@@ -271,17 +279,12 @@ export async function runWhoami(opts, deps = {}) {
|
|
|
271
279
|
}
|
|
272
280
|
return lines.join('\n');
|
|
273
281
|
});
|
|
274
|
-
// When V3 routing is on, warn (text mode only) about the still-open behavior
|
|
275
|
-
// gaps. JSON consumers read `v3Enabled` directly; stdout stays pure.
|
|
276
|
-
if (opts.output !== 'json' && me.v3Enabled === true) {
|
|
277
|
-
emitV3RoutingAdvisory(stderr);
|
|
278
|
-
}
|
|
279
282
|
return me;
|
|
280
283
|
}
|
|
281
284
|
export async function runLogout(opts, deps = {}) {
|
|
282
285
|
const credentialsPath = deps.credentialsPath ?? defaultCredentialsPath();
|
|
283
286
|
const out = makeOutput(opts.output, deps);
|
|
284
|
-
const stderr = deps.stderr
|
|
287
|
+
const stderr = terminalSafeWriter(deps.stderr);
|
|
285
288
|
if (opts.dryRun) {
|
|
286
289
|
emitDryRunBanner(stderr);
|
|
287
290
|
stderr(`[dry-run] would remove credentials for profile="${opts.profile}" from ${credentialsPath}`);
|
|
@@ -303,24 +306,13 @@ export function createAuthCommand(deps = {}) {
|
|
|
303
306
|
const auth = new Command('auth')
|
|
304
307
|
.description('Manage TestSprite credentials')
|
|
305
308
|
.addHelpText('after', '\nTo add credentials, run: testsprite setup');
|
|
306
|
-
//
|
|
307
|
-
// here — `auth configure` is a hidden, deprecated alias for `setup` (attached
|
|
308
|
-
// in index.ts), and `setup` is the only command that writes credentials.
|
|
309
|
+
// Credential writes live in `setup`, the only command that writes credentials.
|
|
309
310
|
auth
|
|
310
311
|
.command('status')
|
|
311
312
|
.summary('Show the active profile and its credentials')
|
|
312
|
-
.description('Show the active profile: user, API key id, endpoint, env, scopes and, when available, org
|
|
313
|
-
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
314
|
-
.action(async (_cmdOpts, command) => {
|
|
315
|
-
await runWhoami(resolveCommonOptions(command, deps.env), deps);
|
|
316
|
-
});
|
|
317
|
-
// `whoami` — hidden, deprecated alias for `status` (kept so scripts/agents
|
|
318
|
-
// on the old name keep working; invisible to --help).
|
|
319
|
-
auth
|
|
320
|
-
.command('whoami', { hidden: true })
|
|
313
|
+
.description('Show the active profile: user, API key id, endpoint, env, scopes and, when available, org and workspace')
|
|
321
314
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
322
315
|
.action(async (_cmdOpts, command) => {
|
|
323
|
-
emitDeprecationNotice('auth whoami', 'auth status', deps.stderr);
|
|
324
316
|
await runWhoami(resolveCommonOptions(command, deps.env), deps);
|
|
325
317
|
});
|
|
326
318
|
auth
|
|
@@ -331,14 +323,6 @@ export function createAuthCommand(deps = {}) {
|
|
|
331
323
|
.action(async (_cmdOpts, command) => {
|
|
332
324
|
await runLogout(resolveCommonOptions(command, deps.env), deps);
|
|
333
325
|
});
|
|
334
|
-
// `logout` — hidden, deprecated alias for `remove`.
|
|
335
|
-
auth
|
|
336
|
-
.command('logout', { hidden: true })
|
|
337
|
-
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
338
|
-
.action(async (_cmdOpts, command) => {
|
|
339
|
-
emitDeprecationNotice('auth logout', 'auth remove', deps.stderr);
|
|
340
|
-
await runLogout(resolveCommonOptions(command, deps.env), deps);
|
|
341
|
-
});
|
|
342
326
|
return auth;
|
|
343
327
|
}
|
|
344
328
|
function resolveCommonOptions(command, env) {
|
package/dist/commands/ci.d.ts
CHANGED
|
@@ -2,17 +2,18 @@ import { type SpawnSyncReturns } from 'node:child_process';
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
4
4
|
import { type FetchImpl } from '../lib/http.js';
|
|
5
|
-
import { type
|
|
5
|
+
import { type TargetPathFs } from '../lib/target-path.js';
|
|
6
6
|
import { type RunTestRunAllOptions, type TestDeps } from './test.js';
|
|
7
7
|
/** Platforms `ci init` can scaffold. One today; the positional arg leaves room. */
|
|
8
8
|
declare const SUPPORTED_PLATFORMS: readonly ["github"];
|
|
9
9
|
type Platform = (typeof SUPPORTED_PLATFORMS)[number];
|
|
10
10
|
/**
|
|
11
11
|
* Minimal fs seam (mirrors `agent.ts`'s `AgentFs` semantics: exclusive writes to
|
|
12
|
-
* refuse clobbering, recursive mkdir to create parent dirs).
|
|
13
|
-
*
|
|
12
|
+
* refuse clobbering, recursive mkdir to create parent dirs). Path inspection
|
|
13
|
+
* shares the agent installer's component walk.
|
|
14
14
|
*/
|
|
15
|
-
export interface CiFs {
|
|
15
|
+
export interface CiFs extends TargetPathFs {
|
|
16
|
+
realpath(target: string): Promise<string>;
|
|
16
17
|
writeFile(target: string, data: string, opts?: {
|
|
17
18
|
exclusive?: boolean;
|
|
18
19
|
}): Promise<void>;
|
|
@@ -22,12 +23,10 @@ export interface CiFs {
|
|
|
22
23
|
readdir(dir: string): Promise<string[]>;
|
|
23
24
|
}
|
|
24
25
|
/** Injectable subprocess runner (defaults to a real `spawnSync`), so tests never
|
|
25
|
-
* shell out. Runs `
|
|
26
|
-
* history) and `npx vercel` (`ci connect`). */
|
|
26
|
+
* shell out. Runs `gh` (optional secret set). */
|
|
27
27
|
export type SpawnImpl = (cmd: string, args: string[], opts: {
|
|
28
28
|
input?: string;
|
|
29
29
|
cwd?: string;
|
|
30
|
-
shell?: boolean;
|
|
31
30
|
}) => SpawnSyncReturns<string>;
|
|
32
31
|
export interface CiDeps extends Pick<TestDeps, 'shutdown' | 'onWaitTimeout'> {
|
|
33
32
|
env?: NodeJS.ProcessEnv;
|
|
@@ -38,10 +37,8 @@ export interface CiDeps extends Pick<TestDeps, 'shutdown' | 'onWaitTimeout'> {
|
|
|
38
37
|
cwd?: string;
|
|
39
38
|
fs?: CiFs;
|
|
40
39
|
spawn?: SpawnImpl;
|
|
41
|
-
/** Injected by
|
|
40
|
+
/** Injected by tests so polling never really sleeps. */
|
|
42
41
|
sleep?: (ms: number) => Promise<void>;
|
|
43
|
-
/** OS seam for the Windows `npx` shim handling (defaults to `process.platform`). */
|
|
44
|
-
platform?: NodeJS.Platform;
|
|
45
42
|
}
|
|
46
43
|
type CommonOptions = FactoryCommonOptions;
|
|
47
44
|
export interface CiInitOptions extends CommonOptions {
|
|
@@ -105,84 +102,6 @@ export declare function buildGithubWorkflow(input: {
|
|
|
105
102
|
workflowPath: string;
|
|
106
103
|
}): string;
|
|
107
104
|
export declare function runCiInit(opts: CiInitOptions, deps?: CiDeps): Promise<void>;
|
|
108
|
-
export interface CiDoctorOptions extends CommonOptions {
|
|
109
|
-
repo?: string;
|
|
110
|
-
/** Poll until a NEW deployment record arrives (the post-connect check). */
|
|
111
|
-
wait: boolean;
|
|
112
|
-
/** Bound for `--wait`, in seconds; undefined = `--timeout` was not given. */
|
|
113
|
-
waitTimeoutSeconds?: number;
|
|
114
|
-
}
|
|
115
|
-
export interface CiDoctorSummary {
|
|
116
|
-
repo: string;
|
|
117
|
-
status: LinkageStatus;
|
|
118
|
-
ok: boolean;
|
|
119
|
-
detail: string;
|
|
120
|
-
lastDeployAt: string | null;
|
|
121
|
-
creators: string[];
|
|
122
|
-
hasPreview: boolean;
|
|
123
|
-
/** Whether this run watched for a new record (`--wait`). */
|
|
124
|
-
waited: boolean;
|
|
125
|
-
/** `--wait` only: the record whose arrival ended the wait, or null. */
|
|
126
|
-
newDeployment: DeploymentRecord | null;
|
|
127
|
-
/** Set when history could not be read at all — then the rest is not a verdict. */
|
|
128
|
-
error: string | null;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* `owner/repo` for the check: the explicit `--repo`, else the `origin` remote.
|
|
132
|
-
* Returns null when neither resolves — the caller turns that into guidance
|
|
133
|
-
* rather than an opaque failure.
|
|
134
|
-
*/
|
|
135
|
-
export declare function resolveRepoSlug(explicit: string | undefined, cwd: string, spawn: SpawnImpl): string | null;
|
|
136
|
-
/**
|
|
137
|
-
* Diagnose whether deployment events reach this repo — the precondition every
|
|
138
|
-
* deployment-gated workflow rests on, and the only one that fails *silently*.
|
|
139
|
-
*
|
|
140
|
-
* Exits non-zero when the chain is not live, so a script (or `ci init`) can
|
|
141
|
-
* gate on it. `--wait` makes the post-connect verification one command instead
|
|
142
|
-
* of "go watch GitHub yourself": it baselines the history on the first read and
|
|
143
|
-
* succeeds when a NEW record arrives. That success condition is a hard fact,
|
|
144
|
-
* deliberately independent of the preview/production heuristic — pushing to a
|
|
145
|
-
* default branch produces a *production* deployment, and that still proves the
|
|
146
|
-
* link is live.
|
|
147
|
-
*/
|
|
148
|
-
export declare function runCiDoctor(opts: CiDoctorOptions, deps?: CiDeps): Promise<void>;
|
|
149
|
-
export declare function renderCiDoctorText(s: CiDoctorSummary): string;
|
|
150
|
-
export interface CiConnectOptions extends CommonOptions {
|
|
151
|
-
/** Vercel project to link when this directory is not linked yet. */
|
|
152
|
-
project?: string;
|
|
153
|
-
}
|
|
154
|
-
export interface CiConnectSummary {
|
|
155
|
-
platform: 'vercel';
|
|
156
|
-
/** The commands that were actually spawned, in order — no secrets in them. */
|
|
157
|
-
ran: string[];
|
|
158
|
-
connected: boolean;
|
|
159
|
-
alreadyConnected: boolean;
|
|
160
|
-
reason: string | null;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Link the deploy platform to the repo — the fix for `ci doctor`'s `none`.
|
|
164
|
-
*
|
|
165
|
-
* Runs the platform's OWN CLI as a subprocess (`npx vercel …`, so nothing needs
|
|
166
|
-
* pre-installing) rather than calling Vercel's API ourselves. That is a
|
|
167
|
-
* deliberate boundary: any other approach would require the user to hand us a
|
|
168
|
-
* Vercel token, and a third-party credential should never pass through this
|
|
169
|
-
* CLI. Vercel's CLI keeps its own credentials; we only read exit codes.
|
|
170
|
-
*
|
|
171
|
-
* Every step runs `--non-interactive`, and `--yes` is NEVER passed to the
|
|
172
|
-
* Vercel CLI on any path. `--yes` does not mean "skip confirmations": on an
|
|
173
|
-
* unlinked directory `vercel link --yes` answers the new-project questions
|
|
174
|
-
* with the default scope and the current directory name — creating a project
|
|
175
|
-
* nobody asked for, which `git connect` then wires the repo to and starts
|
|
176
|
-
* deploying. `ci doctor` would report that as `linked`: the exact silent
|
|
177
|
-
* false-green this command exists to prevent. When Vercel needs a decision it
|
|
178
|
-
* refuses with a structured reason instead, and that is relayed.
|
|
179
|
-
*
|
|
180
|
-
* `vercel git connect` is effectively idempotent — an already-connected repo
|
|
181
|
-
* says so, which also resolves the one ambiguity `ci doctor` cannot see from
|
|
182
|
-
* GitHub: "never linked" vs "linked but never deployed".
|
|
183
|
-
*/
|
|
184
|
-
export declare function runCiConnect(opts: CiConnectOptions, deps?: CiDeps): Promise<void>;
|
|
185
|
-
export declare function renderCiConnectText(s: CiConnectSummary): string;
|
|
186
105
|
export declare function renderCiInitText(s: CiInitSummary): string;
|
|
187
106
|
export type CiRunOptions = Omit<RunTestRunAllOptions, 'wait' | 'ci' | 'admission' | 'previewName' | 'githubTrigger'> & {
|
|
188
107
|
failOnSkipped?: boolean;
|
|
@@ -190,9 +109,22 @@ export type CiRunOptions = Omit<RunTestRunAllOptions, 'wait' | 'ci' | 'admission
|
|
|
190
109
|
executionReportTimeoutSeconds?: number;
|
|
191
110
|
/** `--no-execution-report`: job summary stays the local table; nothing is read or written for the report. */
|
|
192
111
|
executionReport?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* `--target-url-template`: the preview address as a pattern (`{pr}`,
|
|
114
|
+
* `{branch-slug}`, `{sha}`, …), filled on the runner from the pull request's
|
|
115
|
+
* facts; mutually exclusive with `--target-url`.
|
|
116
|
+
*/
|
|
117
|
+
targetUrlTemplate?: string;
|
|
118
|
+
/** `--wait-for-status`: the commit status context / check-run name that says the preview exists. */
|
|
119
|
+
waitForStatus?: string;
|
|
120
|
+
/** `--status-timeout`: how long `--wait-for-status` waits (seconds; default 900). */
|
|
121
|
+
statusTimeoutSeconds?: number;
|
|
193
122
|
};
|
|
123
|
+
/** How long `--wait-for-status` waits by default — a preview build is minutes, so its own budget, not `--timeout`'s. */
|
|
124
|
+
export declare const DEFAULT_STATUS_TIMEOUT_SECONDS = 900;
|
|
125
|
+
export declare function parseStatusTimeoutSeconds(raw: unknown): number;
|
|
194
126
|
/**
|
|
195
|
-
* `ci run` = `
|
|
127
|
+
* `ci run` = `run --project --wait` with CI's defaults, plus what only a CI
|
|
196
128
|
* job can add:
|
|
197
129
|
*
|
|
198
130
|
* - `admission: 'all'` — one request, one execution, server-side pacing (as
|
|
@@ -204,19 +136,10 @@ export type CiRunOptions = Omit<RunTestRunAllOptions, 'wait' | 'ci' | 'admission
|
|
|
204
136
|
* deployment's commit), `--env X --target-url U` runs in a temporary clone
|
|
205
137
|
* of X at U named `github-pr-<N>`, and the run is stamped with the PR so
|
|
206
138
|
* the Portal links back to it — the GitHub App's own mechanism.
|
|
207
|
-
* - Outside a pull request the run keeps `
|
|
139
|
+
* - Outside a pull request the run keeps `run`'s semantics: X's sign-in
|
|
208
140
|
* against U, recorded under X.
|
|
209
141
|
*/
|
|
210
142
|
export declare function runCiRun(opts: CiRunOptions, deps?: TestDeps): Promise<void>;
|
|
143
|
+
/** Build CI run and workflow scaffolding commands with injectable runtime dependencies. */
|
|
211
144
|
export declare function createCiCommand(deps?: CiDeps): Command;
|
|
212
|
-
/**
|
|
213
|
-
* One stderr line per run of a deprecated `ci` subcommand, naming the
|
|
214
|
-
* equivalent commands (stdout stays clean for JSON pipelines). The
|
|
215
|
-
* replacements are not `testsprite` commands, so this does not reuse
|
|
216
|
-
* `emitDeprecationNotice`.
|
|
217
|
-
*/
|
|
218
|
-
export declare const CI_DEPRECATION_NOTICES: {
|
|
219
|
-
readonly doctor: string;
|
|
220
|
-
readonly connect: string;
|
|
221
|
-
};
|
|
222
145
|
export {};
|