@testsprite/testsprite-cli 0.16.0 → 0.17.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 +51 -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 +38 -54
- 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 +702 -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 +388 -37
- 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 +15 -186
- package/dist/commands/project.js +89 -924
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +215 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1816
- package/dist/commands/test.js +1951 -13902
- package/dist/commands/testlist.d.ts +128 -5
- package/dist/commands/testlist.js +269 -339
- package/dist/commands/tunnel.d.ts +2 -2
- package/dist/commands/tunnel.js +23 -19
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +182 -104
- 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 +10 -2
- package/dist/lib/client-factory.js +38 -26
- 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 +71 -0
- package/dist/lib/conversation/api.js +150 -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 +19 -0
- package/dist/lib/conversation/context.js +70 -0
- package/dist/lib/conversation/environment.d.ts +15 -0
- package/dist/lib/conversation/environment.js +33 -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 +315 -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 +156 -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 +71 -0
- package/dist/lib/download.js +274 -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 +16 -27
- package/dist/lib/environment-tunnel.js +161 -154
- 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 +16 -22
- package/dist/lib/first-suite-hint.js +38 -47
- 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 +352 -289
- 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 +3 -3
- package/dist/lib/local-target.js +3 -3
- package/dist/lib/output.d.ts +1 -40
- package/dist/lib/output.js +11 -49
- 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 +154 -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 +71 -0
- package/dist/lib/result/evidence.js +420 -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 +1 -1
- package/dist/lib/target-url.js +6 -16
- package/dist/lib/telemetry.d.ts +31 -11
- package/dist/lib/telemetry.js +37 -8
- 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 +7 -1
- package/dist/lib/tunnel-session.js +22 -9
- 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 +48 -18
- package/skills/testsprite-onboard.skill.md +66 -151
- package/skills/testsprite-verify.codex.md +50 -52
- package/skills/testsprite-verify.skill.md +184 -351
- 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
|
@@ -1,49 +1,5 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { type CommonOptions } from '../lib/client-factory.js';
|
|
3
1
|
import { ApiError } from '../lib/errors.js';
|
|
4
|
-
import type { CliProjectEnvironment } from './project-env.js';
|
|
5
|
-
import type { ProjectDeps } from './project.js';
|
|
6
|
-
export interface CliProjectSignInResponse {
|
|
7
|
-
projectId: string;
|
|
8
|
-
environment: CliProjectEnvironment;
|
|
9
|
-
signIn: {
|
|
10
|
-
mode: string;
|
|
11
|
-
account: {
|
|
12
|
-
username: string | null;
|
|
13
|
-
passwordSet: boolean;
|
|
14
|
-
} | null;
|
|
15
|
-
otp: {
|
|
16
|
-
channels: Array<'email' | 'sms'>;
|
|
17
|
-
email: string | null;
|
|
18
|
-
phone: string | null;
|
|
19
|
-
} | null;
|
|
20
|
-
manual: {
|
|
21
|
-
sessionReuseTtlSeconds: number;
|
|
22
|
-
hasValidSession: boolean;
|
|
23
|
-
needsReauth: boolean;
|
|
24
|
-
reason: 'never' | 'expired' | null;
|
|
25
|
-
capturedAt: string | null;
|
|
26
|
-
expiresAt: string | null;
|
|
27
|
-
} | null;
|
|
28
|
-
};
|
|
29
|
-
nextAction: string | null;
|
|
30
|
-
}
|
|
31
|
-
export interface CliProjectSignInSetResponse extends CliProjectSignInResponse {
|
|
32
|
-
changed: boolean;
|
|
33
|
-
}
|
|
34
2
|
export type SignInMode = 'public' | 'account' | 'otp' | 'manual';
|
|
35
|
-
type GetOptions = CommonOptions & {
|
|
36
|
-
projectId: string;
|
|
37
|
-
env?: string;
|
|
38
|
-
};
|
|
39
|
-
type SetOptions = GetOptions & {
|
|
40
|
-
mode?: string;
|
|
41
|
-
username?: string;
|
|
42
|
-
password?: string;
|
|
43
|
-
passwordFile?: string;
|
|
44
|
-
sessionTtl?: string;
|
|
45
|
-
idempotencyKey?: string;
|
|
46
|
-
};
|
|
47
3
|
export declare function signInValidationError(message: string, reason?: string): ApiError;
|
|
48
4
|
export declare function parseSignInMode(raw: string | undefined, flag: string): SignInMode;
|
|
49
5
|
export declare function parseSessionTtl(raw: string): number;
|
|
@@ -54,7 +10,3 @@ export declare function validateSignInFlags(mode: SignInMode | undefined, opts:
|
|
|
54
10
|
sessionTtl?: string;
|
|
55
11
|
otpChannel?: string[];
|
|
56
12
|
}, requireAccountPair: boolean): void;
|
|
57
|
-
export declare function runSignInGet(opts: GetOptions, deps?: ProjectDeps): Promise<CliProjectSignInResponse>;
|
|
58
|
-
export declare function runSignInSet(opts: SetOptions, deps?: ProjectDeps): Promise<CliProjectSignInSetResponse>;
|
|
59
|
-
export declare function createProjectSignInCommand(deps?: ProjectDeps): Command;
|
|
60
|
-
export {};
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
4
|
-
import { resolveProfileName } from '../lib/config.js';
|
|
5
|
-
import { ApiError, InterruptError } from '../lib/errors.js';
|
|
6
|
-
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
7
|
-
import { readSecretFileGuarded } from '../lib/secret-file.js';
|
|
8
|
-
import { assertIdempotencyKey } from '../lib/validate.js';
|
|
1
|
+
import { ApiError } from '../lib/errors.js';
|
|
9
2
|
export function signInValidationError(message, reason = 'invalid_sign_in_flags') {
|
|
10
3
|
return ApiError.fromEnvelope({
|
|
11
4
|
error: {
|
|
@@ -70,225 +63,4 @@ export function validateSignInFlags(mode, opts, requireAccountPair) {
|
|
|
70
63
|
if (opts.sessionTtl !== undefined)
|
|
71
64
|
parseSessionTtl(opts.sessionTtl);
|
|
72
65
|
}
|
|
73
|
-
function commonOptions(command, env) {
|
|
74
|
-
const globals = command.optsWithGlobals();
|
|
75
|
-
return {
|
|
76
|
-
profile: resolveProfileName(globals.profile, env),
|
|
77
|
-
output: resolveOutputMode(globals.output),
|
|
78
|
-
endpointUrl: globals.endpointUrl,
|
|
79
|
-
debug: globals.debug ?? false,
|
|
80
|
-
verbose: globals.verbose ?? false,
|
|
81
|
-
dryRun: globals.dryRun ?? false,
|
|
82
|
-
requestTimeoutMs: parseRequestTimeoutFlag(globals.requestTimeout),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function stderrOf(deps) {
|
|
86
|
-
return deps.stderr ?? (line => process.stderr.write(`${line}\n`));
|
|
87
|
-
}
|
|
88
|
-
function pathFor(projectId) {
|
|
89
|
-
return `/projects/${encodeURIComponent(projectId)}/sign-in`;
|
|
90
|
-
}
|
|
91
|
-
function clientFor(opts, deps) {
|
|
92
|
-
return makeHttpClient(opts, {
|
|
93
|
-
env: deps.env,
|
|
94
|
-
credentialsPath: deps.credentialsPath,
|
|
95
|
-
fetchImpl: deps.fetchImpl,
|
|
96
|
-
stderr: deps.stderr,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
function ttlText(seconds) {
|
|
100
|
-
if (seconds === -1)
|
|
101
|
-
return 'never expires';
|
|
102
|
-
if (seconds % 86400 === 0)
|
|
103
|
-
return `${seconds / 86400}d`;
|
|
104
|
-
if (seconds % 3600 === 0)
|
|
105
|
-
return `${seconds / 3600}h`;
|
|
106
|
-
if (seconds % 60 === 0)
|
|
107
|
-
return `${seconds / 60}m`;
|
|
108
|
-
return `${seconds}s`;
|
|
109
|
-
}
|
|
110
|
-
function renderText(result) {
|
|
111
|
-
const { environment, signIn } = result;
|
|
112
|
-
const labels = {
|
|
113
|
-
public: 'No sign-in',
|
|
114
|
-
account: 'Test account credentials',
|
|
115
|
-
otp: 'OTP (one-time password) login',
|
|
116
|
-
manual: 'SSO: log in once in a live browser, runs reuse the session',
|
|
117
|
-
};
|
|
118
|
-
const lines = [
|
|
119
|
-
`Environment ${environment.name}${environment.isDefault ? ' (default)' : ''} — ${environment.url}`,
|
|
120
|
-
`Sign-in ${signIn.mode}${labels[signIn.mode] ? ` — ${labels[signIn.mode]}` : ''}`,
|
|
121
|
-
];
|
|
122
|
-
if (signIn.mode === 'account' && signIn.account)
|
|
123
|
-
lines.push(`Username ${signIn.account.username}`, `Password ${signIn.account.passwordSet ? 'set' : 'not set'}`);
|
|
124
|
-
if (signIn.mode === 'otp' && signIn.otp) {
|
|
125
|
-
lines.push(`Channels ${signIn.otp.channels.join(', ')}`);
|
|
126
|
-
if (signIn.otp.email)
|
|
127
|
-
lines.push(`Inbox ${signIn.otp.email}`);
|
|
128
|
-
if (signIn.otp.phone)
|
|
129
|
-
lines.push(`Phone ${signIn.otp.phone}`);
|
|
130
|
-
}
|
|
131
|
-
if (signIn.mode === 'manual') {
|
|
132
|
-
const manual = signIn.manual;
|
|
133
|
-
let session = 'none captured yet — runs will NOT be signed in until someone logs in once';
|
|
134
|
-
if (manual?.hasValidSession) {
|
|
135
|
-
session =
|
|
136
|
-
manual.expiresAt && manual.sessionReuseTtlSeconds !== -1
|
|
137
|
-
? `valid until ${manual.expiresAt}`
|
|
138
|
-
: 'valid (never expires)';
|
|
139
|
-
if (manual.capturedAt)
|
|
140
|
-
session += ` — captured ${manual.capturedAt}`;
|
|
141
|
-
}
|
|
142
|
-
else if (manual?.reason === 'expired') {
|
|
143
|
-
session = `expired ${manual.expiresAt ?? '(expiration unknown)'} — runs will NOT be signed in until someone logs in again`;
|
|
144
|
-
}
|
|
145
|
-
lines.push(`Session ${session}`);
|
|
146
|
-
if (manual)
|
|
147
|
-
lines.push(`Session TTL ${ttlText(manual.sessionReuseTtlSeconds)}`);
|
|
148
|
-
}
|
|
149
|
-
if (result.nextAction)
|
|
150
|
-
lines.push(`Next ${result.nextAction}`);
|
|
151
|
-
return lines.join('\n');
|
|
152
|
-
}
|
|
153
|
-
function dryRunResponse(projectId, mode = 'public') {
|
|
154
|
-
return {
|
|
155
|
-
projectId,
|
|
156
|
-
environment: {
|
|
157
|
-
id: 'env_dryrun',
|
|
158
|
-
name: 'default',
|
|
159
|
-
url: 'https://app.example.com',
|
|
160
|
-
isDefault: true,
|
|
161
|
-
authMode: mode,
|
|
162
|
-
hasCredentials: mode === 'account',
|
|
163
|
-
username: mode === 'account' ? 'qa@example.com' : null,
|
|
164
|
-
enableOtp: mode === 'otp',
|
|
165
|
-
updatedAt: '2026-09-25T00:00:00.000Z',
|
|
166
|
-
},
|
|
167
|
-
signIn: {
|
|
168
|
-
mode,
|
|
169
|
-
account: mode === 'account' ? { username: 'qa@example.com', passwordSet: true } : null,
|
|
170
|
-
otp: mode === 'otp' ? { channels: ['email'], email: 'dryrun@inbox.example', phone: null } : null,
|
|
171
|
-
manual: mode === 'manual'
|
|
172
|
-
? {
|
|
173
|
-
sessionReuseTtlSeconds: 3600,
|
|
174
|
-
hasValidSession: false,
|
|
175
|
-
needsReauth: true,
|
|
176
|
-
reason: 'never',
|
|
177
|
-
capturedAt: null,
|
|
178
|
-
expiresAt: null,
|
|
179
|
-
}
|
|
180
|
-
: null,
|
|
181
|
-
},
|
|
182
|
-
nextAction: mode === 'manual' ? 'Log in once in the Portal.' : null,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function redactSecret(value, secret) {
|
|
186
|
-
if (typeof value === 'string')
|
|
187
|
-
return value.split(secret).join('[REDACTED]');
|
|
188
|
-
if (Array.isArray(value))
|
|
189
|
-
return value.map(item => redactSecret(item, secret));
|
|
190
|
-
if (value !== null && typeof value === 'object') {
|
|
191
|
-
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
192
|
-
key.split(secret).join('[REDACTED]'),
|
|
193
|
-
redactSecret(item, secret),
|
|
194
|
-
]));
|
|
195
|
-
}
|
|
196
|
-
return value;
|
|
197
|
-
}
|
|
198
|
-
export async function runSignInGet(opts, deps = {}) {
|
|
199
|
-
if (opts.env !== undefined && !opts.env.trim())
|
|
200
|
-
throw signInValidationError('--env must not be empty or whitespace-only.');
|
|
201
|
-
const out = new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr });
|
|
202
|
-
if (opts.dryRun) {
|
|
203
|
-
emitDryRunBanner(stderrOf(deps));
|
|
204
|
-
const sample = dryRunResponse(opts.projectId);
|
|
205
|
-
out.print(sample, data => renderText(data));
|
|
206
|
-
return sample;
|
|
207
|
-
}
|
|
208
|
-
const result = await clientFor(opts, deps).get(pathFor(opts.projectId), opts.env === undefined ? {} : { query: { environment: opts.env } });
|
|
209
|
-
out.print(result, data => renderText(data));
|
|
210
|
-
return result;
|
|
211
|
-
}
|
|
212
|
-
export async function runSignInSet(opts, deps = {}) {
|
|
213
|
-
if (opts.env !== undefined && !opts.env.trim())
|
|
214
|
-
throw signInValidationError('--env must not be empty or whitespace-only.');
|
|
215
|
-
const mode = parseSignInMode(opts.mode, '--mode');
|
|
216
|
-
validateSignInFlags(mode, opts, false);
|
|
217
|
-
assertIdempotencyKey(opts.idempotencyKey);
|
|
218
|
-
const out = new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr });
|
|
219
|
-
const stderr = stderrOf(deps);
|
|
220
|
-
const key = opts.idempotencyKey ?? `cli-proj-signin-set-${randomUUID()}`;
|
|
221
|
-
if (opts.idempotencyKey === undefined && (opts.output === 'json' || opts.verbose || opts.debug))
|
|
222
|
-
stderr(`idempotency-key: ${key}`);
|
|
223
|
-
if (opts.dryRun) {
|
|
224
|
-
emitDryRunBanner(stderr);
|
|
225
|
-
const sample = { ...dryRunResponse(opts.projectId, mode), changed: mode !== 'otp' };
|
|
226
|
-
out.print(sample, data => renderText(data));
|
|
227
|
-
return sample;
|
|
228
|
-
}
|
|
229
|
-
const password = opts.passwordFile === undefined
|
|
230
|
-
? opts.password
|
|
231
|
-
: readSecretFileGuarded('password-file', opts.passwordFile);
|
|
232
|
-
const body = { mode };
|
|
233
|
-
if (opts.env !== undefined)
|
|
234
|
-
body.environment = opts.env;
|
|
235
|
-
if (opts.username !== undefined)
|
|
236
|
-
body.username = opts.username;
|
|
237
|
-
if (password !== undefined)
|
|
238
|
-
body.password = password;
|
|
239
|
-
if (opts.sessionTtl !== undefined)
|
|
240
|
-
body.sessionReuseTtlSeconds = parseSessionTtl(opts.sessionTtl);
|
|
241
|
-
try {
|
|
242
|
-
const result = await clientFor(opts, deps).put(pathFor(opts.projectId), { body, headers: { 'idempotency-key': key } });
|
|
243
|
-
out.print(result, data => renderText(data));
|
|
244
|
-
return result;
|
|
245
|
-
}
|
|
246
|
-
catch (err) {
|
|
247
|
-
if (err instanceof InterruptError)
|
|
248
|
-
throw err;
|
|
249
|
-
if (err instanceof ApiError && password) {
|
|
250
|
-
throw new ApiError({
|
|
251
|
-
code: err.code,
|
|
252
|
-
message: redactSecret(err.message, password),
|
|
253
|
-
nextAction: redactSecret(err.nextAction, password),
|
|
254
|
-
requestId: err.requestId,
|
|
255
|
-
details: redactSecret(err.details, password),
|
|
256
|
-
}, err.httpStatus, err.retryAfterMs);
|
|
257
|
-
}
|
|
258
|
-
if (err instanceof Error && password)
|
|
259
|
-
err.message = redactSecret(err.message, password);
|
|
260
|
-
throw err;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
export function createProjectSignInCommand(deps = {}) {
|
|
264
|
-
const group = new Command('sign-in')
|
|
265
|
-
.summary('Inspect or change how an environment signs in')
|
|
266
|
-
.description('Inspect or change how an environment signs in to the app under test.');
|
|
267
|
-
group
|
|
268
|
-
.command('get <project-id>')
|
|
269
|
-
.summary('Show the environment sign-in mode and status')
|
|
270
|
-
.description('Show the environment sign-in mode, credentials status, OTP channels, or SSO session.')
|
|
271
|
-
.option('--env <name>', 'environment name (defaults to the project default)')
|
|
272
|
-
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
273
|
-
.action(async (projectId, flags, command) => {
|
|
274
|
-
await runSignInGet({ ...commonOptions(command, deps.env), projectId, env: flags.env }, deps);
|
|
275
|
-
});
|
|
276
|
-
group
|
|
277
|
-
.command('set <project-id>')
|
|
278
|
-
.summary('Set the environment sign-in mode')
|
|
279
|
-
.description('Set the sign-in mode. OTP can only be chosen at `project env create --sign-in otp`, never switched to or from.\n' +
|
|
280
|
-
'manual (log in once in the Portal; runs are not signed in until then) and otp are not available on local environments.')
|
|
281
|
-
.option('--mode <mode>', 'required: public, account or manual (aliases: none, credentials, sso)')
|
|
282
|
-
.option('--env <name>', 'environment name (defaults to the project default)')
|
|
283
|
-
.option('--username <user>', 'test-account username (account only)')
|
|
284
|
-
.option('--password <pw>', 'test-account password (prefer --password-file, exclusive; account only)')
|
|
285
|
-
.option('--password-file <path>', 'read the test-account password from a file (account only)')
|
|
286
|
-
.option('--session-ttl <seconds|never>', 'SSO session reuse lifetime: 1–2592000 seconds or never (manual only)')
|
|
287
|
-
.option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
|
|
288
|
-
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
289
|
-
.action(async (projectId, flags, command) => {
|
|
290
|
-
await runSignInSet({ ...commonOptions(command, deps.env), projectId, ...flags }, deps);
|
|
291
|
-
});
|
|
292
|
-
return group;
|
|
293
|
-
}
|
|
294
66
|
//# sourceMappingURL=project-sign-in.js.map
|
|
@@ -21,33 +21,11 @@ export interface CliProject {
|
|
|
21
21
|
*/
|
|
22
22
|
orgId?: string;
|
|
23
23
|
orgName?: string;
|
|
24
|
-
/**
|
|
25
|
-
* The project's default target/environment URL, or `null` when the project has
|
|
26
|
-
* none configured.
|
|
27
|
-
*
|
|
28
|
-
* **Absent vs. `null` is load-bearing here.** `null` means "the server resolved
|
|
29
|
-
* it and this project has no URL configured" — actionable, so the renderer
|
|
30
|
-
* prints the `project update … --url` remedy. **Absent** means "no answer", and
|
|
31
|
-
* the server uses it for every case where a remedy would be a lie: an older
|
|
32
|
-
* backend, the `list` endpoint (which would pay an extra read per row), a
|
|
33
|
-
* resolution that failed (a transient outage must never be reported as "no URL
|
|
34
|
-
* set"), and a V2 backend project (V2 backend runs resolve no project URL at
|
|
35
|
-
* all, so there is nothing to report and nothing `--url` would change).
|
|
36
|
-
*
|
|
37
|
-
* So the renderer must key on presence, not truthiness: printing "(not set)"
|
|
38
|
-
* for an absent field would report every project on an older backend — and
|
|
39
|
-
* every project in a `list` — as having no URL, including the ones that do.
|
|
40
|
-
*
|
|
41
|
-
* A backend project with no URL is not merely cosmetic: on the V3 execution
|
|
42
|
-
* path the first run of any of its tests is rejected `no-target-resolvable`
|
|
43
|
-
* (see the `project create --type backend` note in CLAUDE.md).
|
|
44
|
-
*/
|
|
45
|
-
targetUrl?: string | null;
|
|
46
|
-
/** Absent on older servers, V2 projects, or when the environment read failed. */
|
|
24
|
+
/** Absent on older servers, or when the environment read failed. */
|
|
47
25
|
defaultEnvironment?: string | null;
|
|
48
26
|
environmentCount?: number;
|
|
49
|
-
/**
|
|
50
|
-
|
|
27
|
+
/** Project detail only. Null when unset, absent on older servers. */
|
|
28
|
+
instruction?: string | null;
|
|
51
29
|
/**
|
|
52
30
|
* Project-level test-id attribute priority list (e.g. `['data-element',
|
|
53
31
|
* 'data-testid']`). The execution engine tries these DOM attributes, in
|
|
@@ -90,10 +68,6 @@ export declare function runGet(opts: GetOptions, deps?: ProjectDeps): Promise<Cl
|
|
|
90
68
|
export interface CliCreateProjectRequest {
|
|
91
69
|
type: 'frontend' | 'backend';
|
|
92
70
|
name: string;
|
|
93
|
-
targetUrl?: string;
|
|
94
|
-
originMode?: 'local';
|
|
95
|
-
username?: string;
|
|
96
|
-
password?: string;
|
|
97
71
|
instruction?: string;
|
|
98
72
|
/** Ordered test-id attribute list — see `CliProject.testIdAttributes`. */
|
|
99
73
|
testIdAttributes?: string[];
|
|
@@ -105,11 +79,11 @@ export interface CliCreateProjectRequest {
|
|
|
105
79
|
* response keying its id as `projectId` (matching `CliDeleteProjectResponse`'s
|
|
106
80
|
* convention), not `id` like the read paths (`GET /projects`, `GET
|
|
107
81
|
* /projects/{id}` — those are proven-`id` via the dev-e2e smoke test) — and
|
|
108
|
-
* possibly omitting `
|
|
82
|
+
* possibly omitting `updatedAt` entirely. Rather than guess which
|
|
109
83
|
* single shape is "the real one" and risk flipping the drift instead of
|
|
110
84
|
* fixing it, both id field names are accepted here (and normalized — see
|
|
111
85
|
* `resolveCreatedProjectId` — so JSON consumers keyed on either `id` or
|
|
112
|
-
* `projectId` keep working), and `
|
|
86
|
+
* `projectId` keep working), and `updatedAt` is optional.
|
|
113
87
|
*/
|
|
114
88
|
export interface CliCreateProjectResponse {
|
|
115
89
|
/** Preferred — matches the live backend's response and `project delete`'s `projectId`. */
|
|
@@ -122,26 +96,14 @@ export interface CliCreateProjectResponse {
|
|
|
122
96
|
createdAt: string;
|
|
123
97
|
/** Absent-safe: not guaranteed on every backend response. */
|
|
124
98
|
updatedAt?: string;
|
|
125
|
-
targetUrl?: string;
|
|
126
|
-
originMode?: 'local';
|
|
127
99
|
}
|
|
128
100
|
/** Resolve the created project's id regardless of which field name the backend used. */
|
|
129
101
|
export declare function resolveCreatedProjectId(r: CliCreateProjectResponse): string | undefined;
|
|
130
102
|
interface CreateOptions extends CommonOptions {
|
|
131
|
-
/** `'local'` marks the target as an app on the caller's own machine. */
|
|
132
|
-
originMode?: 'local';
|
|
133
103
|
type: 'frontend' | 'backend';
|
|
134
104
|
name: string;
|
|
135
|
-
targetUrl?: string;
|
|
136
|
-
local?: string;
|
|
137
|
-
localHost?: string;
|
|
138
|
-
skipPreflight?: boolean;
|
|
139
|
-
description?: string;
|
|
140
|
-
testIdAttributes?: string[];
|
|
141
|
-
username?: string;
|
|
142
|
-
password?: string;
|
|
143
|
-
passwordFile?: string;
|
|
144
105
|
instruction?: string;
|
|
106
|
+
testIdAttributes?: string[];
|
|
145
107
|
idempotencyKey?: string;
|
|
146
108
|
}
|
|
147
109
|
export declare function runCreate(opts: CreateOptions, deps?: ProjectDeps): Promise<CliCreateProjectResponse>;
|
|
@@ -161,30 +123,12 @@ export interface CliUpdateProjectResponse {
|
|
|
161
123
|
updatedFields?: string[];
|
|
162
124
|
/** Absent-safe: not guaranteed on every backend response. */
|
|
163
125
|
updatedAt?: string;
|
|
164
|
-
/** Present on servers that report which default environment was edited. */
|
|
165
|
-
environment?: {
|
|
166
|
-
name: string;
|
|
167
|
-
isDefault: true;
|
|
168
|
-
};
|
|
169
|
-
effects?: string[];
|
|
170
126
|
}
|
|
171
127
|
/** Resolve the updated project's id regardless of which field name the backend used. */
|
|
172
128
|
export declare function resolveUpdatedProjectId(r: CliUpdateProjectResponse): string | undefined;
|
|
173
129
|
interface UpdateOptions extends CommonOptions {
|
|
174
130
|
projectId: string;
|
|
175
131
|
name?: string;
|
|
176
|
-
targetUrl?: string;
|
|
177
|
-
/**
|
|
178
|
-
* `--local <port>`: point the project at an app on this machine. The same
|
|
179
|
-
* spelling as `project create`; builds the loopback URL and sends the
|
|
180
|
-
* `originMode: 'local'` marker that lets the server store it.
|
|
181
|
-
*/
|
|
182
|
-
local?: string;
|
|
183
|
-
localHost?: string;
|
|
184
|
-
skipPreflight?: boolean;
|
|
185
|
-
username?: string;
|
|
186
|
-
password?: string;
|
|
187
|
-
passwordFile?: string;
|
|
188
132
|
instruction?: string;
|
|
189
133
|
/** Ordered test-id attribute list; `clearTestIdAttributes` sends `null` to unset. */
|
|
190
134
|
testIdAttributes?: string[];
|
|
@@ -217,130 +161,15 @@ interface DeleteOptions extends CommonOptions {
|
|
|
217
161
|
* the server; the CLI surfaces the envelope as-is (exit 4), no client branching.
|
|
218
162
|
*/
|
|
219
163
|
export declare function runDelete(opts: DeleteOptions, deps?: ProjectDeps): Promise<CliDeleteProjectResponse>;
|
|
220
|
-
export
|
|
221
|
-
projectId: string;
|
|
222
|
-
authType: string;
|
|
223
|
-
rewroteCount: number;
|
|
224
|
-
}
|
|
225
|
-
interface CredentialOptions extends CommonOptions {
|
|
226
|
-
projectId: string;
|
|
227
|
-
authType: string;
|
|
228
|
-
credential?: string;
|
|
229
|
-
credentialFile?: string;
|
|
230
|
-
idempotencyKey?: string;
|
|
231
|
-
}
|
|
232
|
-
export declare function runCredential(opts: CredentialOptions, deps?: ProjectDeps): Promise<CliProjectCredentialResponse>;
|
|
233
|
-
export interface CliProjectAutoAuthResponse {
|
|
234
|
-
projectId: string;
|
|
235
|
-
enabled: boolean;
|
|
236
|
-
method: string;
|
|
237
|
-
inject: string;
|
|
238
|
-
/**
|
|
239
|
-
* Present when the server's trial refresh failed: `enabled` is then `false`
|
|
240
|
-
* and this carries the reason (e.g. a bad refresh token). The config is still
|
|
241
|
-
* stored, but auto-auth won't run until the login succeeds.
|
|
242
|
-
*/
|
|
243
|
-
lastRefreshError?: string;
|
|
244
|
-
}
|
|
245
|
-
interface AutoAuthOptions extends CommonOptions {
|
|
246
|
-
projectId: string;
|
|
247
|
-
disable?: boolean;
|
|
248
|
-
method: string;
|
|
249
|
-
inject: string;
|
|
250
|
-
injectKey?: string;
|
|
251
|
-
loginUrl?: string;
|
|
252
|
-
loginMethod?: string;
|
|
253
|
-
loginContentType?: string;
|
|
254
|
-
loginBodyTemplate?: string;
|
|
255
|
-
username?: string;
|
|
256
|
-
password?: string;
|
|
257
|
-
passwordFile?: string;
|
|
258
|
-
tokenPath?: string;
|
|
259
|
-
tokenEndpoint?: string;
|
|
260
|
-
clientId?: string;
|
|
261
|
-
clientSecret?: string;
|
|
262
|
-
clientSecretFile?: string;
|
|
263
|
-
refreshToken?: string;
|
|
264
|
-
refreshTokenFile?: string;
|
|
265
|
-
scope?: string;
|
|
266
|
-
region?: string;
|
|
267
|
-
idempotencyKey?: string;
|
|
268
|
-
}
|
|
269
|
-
export declare function runAutoAuth(opts: AutoAuthOptions, deps?: ProjectDeps): Promise<CliProjectAutoAuthResponse>;
|
|
270
|
-
/**
|
|
271
|
-
* CLI-facing role flags → wire enum. Default is `api-doc` (stated in help);
|
|
272
|
-
* no inference from project type in v1 (design §3.4).
|
|
273
|
-
*/
|
|
274
|
-
declare const DOC_ROLES: {
|
|
275
|
-
readonly 'api-doc': "API_DOC";
|
|
276
|
-
readonly prd: "PRD";
|
|
277
|
-
};
|
|
278
|
-
type DocRoleFlag = keyof typeof DOC_ROLES;
|
|
279
|
-
type DocRoleWire = (typeof DOC_ROLES)[DocRoleFlag];
|
|
280
|
-
/** `POST /projects/{id}/docs/upload-url` response (docs facade). */
|
|
281
|
-
export interface CliDocsUploadUrlResponse {
|
|
282
|
-
uploadUrl: string;
|
|
283
|
-
s3Key: string;
|
|
284
|
-
expiresInSeconds: number;
|
|
285
|
-
}
|
|
286
|
-
/** `POST /projects/{id}/docs` (register) response (docs facade). */
|
|
287
|
-
export interface CliDocsRegisterResponse {
|
|
288
|
-
resourceId: string;
|
|
289
|
-
displayName: string;
|
|
290
|
-
docRole: DocRoleWire | null;
|
|
291
|
-
processStatus: string;
|
|
292
|
-
}
|
|
293
|
-
/** Success result — the JSON-mode stdout shape. */
|
|
294
|
-
export interface CliDocsUploadResult {
|
|
295
|
-
resourceId: string;
|
|
296
|
-
displayName: string;
|
|
297
|
-
role: DocRoleWire | null;
|
|
298
|
-
size: number;
|
|
299
|
-
processStatus: string;
|
|
300
|
-
}
|
|
301
|
-
/** Dry-run result: the would-be plan. Zero network, nothing read beyond a stat. */
|
|
302
|
-
export interface CliDocsUploadPlan {
|
|
303
|
-
dryRun: true;
|
|
304
|
-
projectId: string;
|
|
305
|
-
file: string;
|
|
306
|
-
fileName: string;
|
|
307
|
-
displayName: string;
|
|
308
|
-
role: DocRoleWire;
|
|
309
|
-
contentType: string;
|
|
310
|
-
size: number;
|
|
311
|
-
steps: string[];
|
|
312
|
-
}
|
|
313
|
-
interface DocsUploadOptions extends CommonOptions {
|
|
314
|
-
file: string;
|
|
315
|
-
projectId?: string;
|
|
316
|
-
role?: string;
|
|
317
|
-
name?: string;
|
|
318
|
-
idempotencyKey?: string;
|
|
319
|
-
}
|
|
164
|
+
export declare function createProjectCommand(deps?: ProjectDeps): Command;
|
|
320
165
|
/**
|
|
321
|
-
* `project
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* Three-step flow against the docs facade routes:
|
|
326
|
-
*
|
|
327
|
-
* 1. `POST /projects/{id}/docs/upload-url` — mints a one-hour presigned
|
|
328
|
-
* S3 PUT URL plus the S3 key to register afterwards.
|
|
329
|
-
* 2. HTTP PUT of the file bytes to the presigned URL — **streamed**
|
|
330
|
-
* (`createReadStream` → web stream), never buffering the whole file.
|
|
331
|
-
* This request goes straight to S3: no facade base URL, no API key.
|
|
332
|
-
* 3. `POST /projects/{id}/docs` — registers the S3 object with its role
|
|
333
|
-
* and display name, which starts processing + embedding.
|
|
334
|
-
*
|
|
335
|
-
* Reading the local file as INPUT is allowed by DR-21 (the no-local-OUTPUTS
|
|
336
|
-
* rule); nothing is ever written back to disk.
|
|
337
|
-
*
|
|
338
|
-
* Failure modes are deliberately distinguished (design non-negotiable): a
|
|
339
|
-
* step-2 failure names the presigned PUT and the fix (re-running mints a
|
|
340
|
-
* fresh URL — they expire); a step-3 failure preserves the server envelope
|
|
341
|
-
* and says the upload already succeeded (re-running is safe: the server
|
|
342
|
-
* upserts the document by S3 key, so no duplicate is created).
|
|
166
|
+
* Render `project list`'s text table over a fetched page. Falls back to the
|
|
167
|
+
* default column set (ORG/URL included only when the data carries them).
|
|
168
|
+
* Exported for direct unit coverage of the CJK display-width regression
|
|
169
|
+
* (#369): later columns must not shift when a project name is full-width.
|
|
343
170
|
*/
|
|
344
|
-
export declare function
|
|
345
|
-
|
|
171
|
+
export declare function renderProjectListText(page: Page<CliProject>, options?: {
|
|
172
|
+
columns?: string;
|
|
173
|
+
noHeader?: boolean;
|
|
174
|
+
}): string;
|
|
346
175
|
export {};
|