@testsprite/testsprite-cli 0.14.0 → 0.16.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 +27 -17
- package/dist/commands/agent.js +7 -2
- package/dist/commands/auth.js +7 -3
- package/dist/commands/ci.d.ts +66 -17
- package/dist/commands/ci.js +486 -122
- package/dist/commands/completion.js +2 -1
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.js +52 -10
- package/dist/commands/init.js +25 -5
- package/dist/commands/project-env.js +39 -17
- package/dist/commands/project-sign-in.js +9 -4
- package/dist/commands/project.js +43 -22
- package/dist/commands/schedule.js +24 -15
- package/dist/commands/test.d.ts +105 -36
- package/dist/commands/test.js +1494 -847
- package/dist/commands/testlist.js +13 -3
- package/dist/commands/tunnel.js +23 -25
- package/dist/commands/usage.js +1 -0
- package/dist/index.js +14 -7
- package/dist/lib/agent-targets.d.ts +8 -3
- package/dist/lib/agent-targets.js +15 -4
- package/dist/lib/ci-run.d.ts +11 -0
- package/dist/lib/ci-run.js +34 -0
- package/dist/lib/client-factory.d.ts +23 -0
- package/dist/lib/client-factory.js +7 -6
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +1 -1
- package/dist/lib/conflict-reason.d.ts +24 -3
- package/dist/lib/conflict-reason.js +33 -2
- package/dist/lib/credentials.d.ts +0 -1
- package/dist/lib/credentials.js +51 -14
- package/dist/lib/deprecate.d.ts +22 -0
- package/dist/lib/deprecate.js +26 -0
- package/dist/lib/dry-run/samples.js +56 -5
- package/dist/lib/environment-tunnel.d.ts +2 -1
- package/dist/lib/environment-tunnel.js +1 -4
- package/dist/lib/first-suite-hint.d.ts +55 -0
- package/dist/lib/first-suite-hint.js +101 -0
- package/dist/lib/gh-output.d.ts +62 -4
- package/dist/lib/gh-output.js +149 -7
- package/dist/lib/github-context.d.ts +21 -0
- package/dist/lib/github-context.js +153 -0
- package/dist/lib/http.d.ts +10 -1
- package/dist/lib/http.js +29 -3
- package/dist/lib/junit-report.d.ts +3 -0
- package/dist/lib/junit-report.js +8 -1
- package/dist/lib/output.d.ts +11 -1
- package/dist/lib/output.js +17 -2
- package/dist/lib/plans.types.d.ts +1 -1
- package/dist/lib/response-schemas.d.ts +5 -1
- package/dist/lib/response-schemas.js +57 -0
- package/dist/lib/runs.types.d.ts +122 -0
- package/dist/lib/telemetry.d.ts +26 -2
- package/dist/lib/telemetry.js +47 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/schemas/plan.schema.json +2 -2
- package/skills/testsprite-ci.skill.md +154 -0
- package/skills/testsprite-verify.codex.md +7 -7
- package/skills/testsprite-verify.skill.md +24 -21
|
@@ -91,7 +91,8 @@ export function createCompletionCommand(getSpec, deps = {}) {
|
|
|
91
91
|
return new Command('completion')
|
|
92
92
|
.description('Print a shell completion script (bash|zsh|fish)')
|
|
93
93
|
.argument('[shell]', 'Shell to generate for (bash|zsh|fish); auto-detected from $SHELL when omitted')
|
|
94
|
-
.addHelpText('after', '\
|
|
94
|
+
.addHelpText('after', '\nCompletes commands and their subcommands one level deep; option names are not completed.\n' +
|
|
95
|
+
'\nExamples:\n' +
|
|
95
96
|
' eval "$(testsprite completion bash)" # bash, current session\n' +
|
|
96
97
|
' testsprite completion zsh > ~/.zsh/_testsprite\n' +
|
|
97
98
|
' testsprite completion fish | source # fish, current session')
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Command } from 'commander';
|
|
18
18
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
19
|
+
import { loadConfig } from '../lib/config.js';
|
|
19
20
|
import type { FetchImpl } from '../lib/http.js';
|
|
20
21
|
export type DoctorStatus = 'ok' | 'warn' | 'fail';
|
|
21
22
|
export interface DoctorCheck {
|
|
@@ -44,6 +45,8 @@ export interface DoctorDeps {
|
|
|
44
45
|
nodeVersion?: string;
|
|
45
46
|
existsSync?: (p: string) => boolean;
|
|
46
47
|
readFileSync?: (p: string) => string;
|
|
48
|
+
/** Config resolver. Defaults to `loadConfig`; injectable for tests. */
|
|
49
|
+
loadConfigFn?: typeof loadConfig;
|
|
47
50
|
}
|
|
48
51
|
type CommonOptions = FactoryCommonOptions;
|
|
49
52
|
export declare function runDoctor(opts: CommonOptions, deps?: DoctorDeps): Promise<DoctorReport>;
|
package/dist/commands/doctor.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Command } from 'commander';
|
|
18
18
|
import { assertValidEndpointUrl, makeHttpClient, } from '../lib/client-factory.js';
|
|
19
|
-
import { loadConfig, resolveProfileName } from '../lib/config.js';
|
|
19
|
+
import { loadConfig, resolveProfileName, DEFAULT_API_URL, normalizeEnvVar, } from '../lib/config.js';
|
|
20
20
|
import { ApiError, CLIError, InterruptError, RequestTimeoutError, localValidationError, } from '../lib/errors.js';
|
|
21
21
|
import { globalShutdown } from '../lib/interrupt.js';
|
|
22
22
|
import { formatOrgBinding, formatOrgsSummary, formatPersonalScopeHint } from '../lib/org-render.js';
|
|
@@ -31,25 +31,46 @@ export async function runDoctor(opts, deps = {}) {
|
|
|
31
31
|
const env = deps.env ?? process.env;
|
|
32
32
|
const cwd = deps.cwd ?? process.cwd();
|
|
33
33
|
const nodeVersion = deps.nodeVersion ?? process.versions.node;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const loadConfigFn = deps.loadConfigFn ?? loadConfig;
|
|
35
|
+
let config;
|
|
36
|
+
// Set when the credentials file exists but the OS refuses the read (e.g. a
|
|
37
|
+
// Windows ACL locked out by an affected CLI version): degrade, don't crash.
|
|
38
|
+
let credentialsReadError;
|
|
39
|
+
try {
|
|
40
|
+
config = loadConfigFn({
|
|
41
|
+
profile: opts.profile,
|
|
42
|
+
endpointUrl: opts.endpointUrl,
|
|
43
|
+
env,
|
|
44
|
+
credentialsPath: deps.credentialsPath,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (!isFsPermissionError(error))
|
|
49
|
+
throw error;
|
|
50
|
+
credentialsReadError = error.code;
|
|
51
|
+
config = {
|
|
52
|
+
profile: resolveProfileName(opts.profile, env),
|
|
53
|
+
apiUrl: opts.endpointUrl ?? normalizeEnvVar(env.TESTSPRITE_API_URL) ?? DEFAULT_API_URL,
|
|
54
|
+
apiKey: normalizeEnvVar(env.TESTSPRITE_API_KEY),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
40
57
|
const endpointCheck = checkEndpoint(config.apiUrl);
|
|
41
58
|
const hasKey = Boolean(config.apiKey);
|
|
42
59
|
const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
43
60
|
const connectivity = await checkConnectivity(opts, deps, {
|
|
44
61
|
hasKey,
|
|
45
62
|
endpointOk: endpointCheck.status === 'ok',
|
|
63
|
+
// Pass the already-resolved config down so the client below never re-reads
|
|
64
|
+
// the credentials file — with an ACL-bricked file a second read throws the
|
|
65
|
+
// same EPERM and surfaces as a bogus Connectivity failure.
|
|
66
|
+
config,
|
|
46
67
|
});
|
|
47
68
|
const checks = [
|
|
48
69
|
{ name: 'CLI version', status: 'ok', detail: VERSION },
|
|
49
70
|
checkNodeVersion(nodeVersion),
|
|
50
71
|
{ name: 'Profile', status: 'ok', detail: config.profile },
|
|
51
72
|
endpointCheck,
|
|
52
|
-
checkCredentials(hasKey, config.profile, opts.dryRun ?? false),
|
|
73
|
+
checkCredentials(hasKey, config.profile, opts.dryRun ?? false, credentialsReadError),
|
|
53
74
|
connectivity.check,
|
|
54
75
|
];
|
|
55
76
|
// Informational routing line, only when the backend reported it (no new call).
|
|
@@ -81,6 +102,7 @@ export async function runDoctor(opts, deps = {}) {
|
|
|
81
102
|
checks.push(await checkLocalTunnel(opts, deps, {
|
|
82
103
|
hasKey,
|
|
83
104
|
endpointOk: endpointCheck.status === 'ok',
|
|
105
|
+
config,
|
|
84
106
|
}));
|
|
85
107
|
checks.push(checkSkill(cwd, deps));
|
|
86
108
|
const failures = checks.filter(check => check.status === 'fail').length;
|
|
@@ -98,6 +120,14 @@ export async function runDoctor(opts, deps = {}) {
|
|
|
98
120
|
}
|
|
99
121
|
return report;
|
|
100
122
|
}
|
|
123
|
+
/** True for EPERM/EACCES fs errors — the signature of an unreadable credentials file. */
|
|
124
|
+
function isFsPermissionError(error) {
|
|
125
|
+
return (typeof error === 'object' &&
|
|
126
|
+
error !== null &&
|
|
127
|
+
'code' in error &&
|
|
128
|
+
(error.code === 'EPERM' ||
|
|
129
|
+
error.code === 'EACCES'));
|
|
130
|
+
}
|
|
101
131
|
function checkNodeVersion(nodeVersion) {
|
|
102
132
|
// Reuse the CLI runtime guard so doctor and startup enforce and describe the same range.
|
|
103
133
|
const rejected = shouldRejectNodeVersion(nodeVersion);
|
|
@@ -122,7 +152,16 @@ function checkEndpoint(apiUrl) {
|
|
|
122
152
|
};
|
|
123
153
|
}
|
|
124
154
|
}
|
|
125
|
-
function checkCredentials(hasKey, profile, dryRun) {
|
|
155
|
+
function checkCredentials(hasKey, profile, dryRun, readError) {
|
|
156
|
+
if (readError) {
|
|
157
|
+
return {
|
|
158
|
+
name: 'Credentials',
|
|
159
|
+
status: hasKey ? 'warn' : 'fail',
|
|
160
|
+
detail: `credentials file exists but cannot be read (${readError}); its ACL may be locked out ` +
|
|
161
|
+
'by an earlier CLI version — delete the file and re-run `testsprite setup`' +
|
|
162
|
+
(hasKey ? ' (TESTSPRITE_API_KEY is set, so commands still work)' : ''),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
126
165
|
if (hasKey) {
|
|
127
166
|
// Never print any part of the key (security). Confirm presence only.
|
|
128
167
|
return {
|
|
@@ -167,6 +206,7 @@ async function checkConnectivity(opts, deps, ctx) {
|
|
|
167
206
|
credentialsPath: deps.credentialsPath,
|
|
168
207
|
fetchImpl: deps.fetchImpl,
|
|
169
208
|
stderr: deps.stderr,
|
|
209
|
+
config: ctx.config,
|
|
170
210
|
shutdownSignal: deps.shutdownSignal,
|
|
171
211
|
});
|
|
172
212
|
const me = await client.get('/me', { schema: ME_IDENTITY_SCHEMA });
|
|
@@ -238,6 +278,7 @@ async function checkLocalTunnel(opts, deps, ctx) {
|
|
|
238
278
|
credentialsPath: deps.credentialsPath,
|
|
239
279
|
fetchImpl: deps.fetchImpl,
|
|
240
280
|
stderr: deps.stderr,
|
|
281
|
+
config: ctx.config,
|
|
241
282
|
// The retry sleeper listens to the client shutdown signal. Compose
|
|
242
283
|
// the probe deadline with process shutdown so either aborts the fetch.
|
|
243
284
|
shutdownSignal: controller.signal,
|
|
@@ -321,7 +362,8 @@ function renderDoctor(report) {
|
|
|
321
362
|
}
|
|
322
363
|
export function createDoctorCommand(deps = {}) {
|
|
323
364
|
const cmd = new Command('doctor')
|
|
324
|
-
.
|
|
365
|
+
.summary('Diagnose CLI setup: credentials, connectivity, skill')
|
|
366
|
+
.description('Diagnose CLI setup: version, Node, profile, endpoint, credentials, API connectivity, workspace routing, tunnel permission (run:tunnel) and the verify skill in this directory. Exit 1 if any check fails; warnings do not.')
|
|
325
367
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
326
368
|
.addHelpText('after', '\nExamples:\n' +
|
|
327
369
|
' testsprite doctor # run all checks (exit 1 if any fails)\n' +
|
package/dist/commands/init.js
CHANGED
|
@@ -501,7 +501,11 @@ function renderInitText(data) {
|
|
|
501
501
|
lines.push('');
|
|
502
502
|
if (s.agent) {
|
|
503
503
|
lines.push(' # 2. Generate tests: ask your coding agent (the testsprite-onboard skill is installed),');
|
|
504
|
-
lines.push(' # or
|
|
504
|
+
lines.push(' # or have TestSprite propose them directly (uses credits), review them, then accept:');
|
|
505
|
+
lines.push(' testsprite test plan generate --project <projectId>');
|
|
506
|
+
lines.push(' testsprite test plan accept --project <projectId>');
|
|
507
|
+
lines.push('');
|
|
508
|
+
lines.push(' # 3. Run them (use the projectId from step 1):');
|
|
505
509
|
lines.push(' testsprite test run --all --project <projectId>');
|
|
506
510
|
lines.push('');
|
|
507
511
|
lines.push(' # Manage installed agent skills');
|
|
@@ -509,8 +513,18 @@ function renderInitText(data) {
|
|
|
509
513
|
lines.push(' testsprite agent install --target=<t> # re-install or install additional targets');
|
|
510
514
|
}
|
|
511
515
|
else {
|
|
512
|
-
|
|
513
|
-
|
|
516
|
+
// Without an agent, this is the only place a new user learns that
|
|
517
|
+
// TestSprite can propose the first suite. Printing this runs and charges
|
|
518
|
+
// nothing; generating does use credits, which the line says. The
|
|
519
|
+
// hand-authored path stays visible as the fallback.
|
|
520
|
+
lines.push(' # 2. Let TestSprite propose your first tests (uses credits), review them, then accept:');
|
|
521
|
+
lines.push(' # Backend project? Upload your API spec first:');
|
|
522
|
+
lines.push(' # testsprite project docs upload ./openapi.yaml --project <projectId>');
|
|
523
|
+
lines.push(' testsprite test plan generate --project <projectId>');
|
|
524
|
+
lines.push(' testsprite test plan accept --project <projectId>');
|
|
525
|
+
lines.push(' # Prefer to write one yourself: testsprite test create --plan-template');
|
|
526
|
+
lines.push('');
|
|
527
|
+
lines.push(' # 3. Run them (use the projectId from step 1):');
|
|
514
528
|
lines.push(' testsprite test run --all --project <projectId>');
|
|
515
529
|
lines.push(' # Tip: `testsprite agent install` sets up the onboarding skill for your coding agent');
|
|
516
530
|
lines.push('');
|
|
@@ -550,7 +564,7 @@ export function addSetupOptions(cmd, validTargets, defaultAgent) {
|
|
|
550
564
|
.option('--no-agent', 'Skip the agent skill install (configure credentials only)')
|
|
551
565
|
.option('--force', 'Overwrite an existing skill file (a .bak backup is kept)')
|
|
552
566
|
.option('--dir <path>', 'Project root for the skill install (default: current directory)')
|
|
553
|
-
.option('-y, --yes', 'Non-interactive: accept
|
|
567
|
+
.option('-y, --yes', 'Non-interactive: accept defaults, never prompt (needs --from-env or --api-key)')
|
|
554
568
|
.option('--skip-if-configured', 'Skip the API key prompt when credentials already exist for this profile (CI-safe idempotent re-run)');
|
|
555
569
|
}
|
|
556
570
|
/** Build {@link InitOptions} from raw Commander opts + globals. */
|
|
@@ -603,8 +617,14 @@ export function createSetupCommand(deps = {}) {
|
|
|
603
617
|
const validTargets = Object.keys(TARGETS);
|
|
604
618
|
const defaultAgent = 'claude';
|
|
605
619
|
return addSetupOptions(new Command('setup'), validTargets, defaultAgent)
|
|
620
|
+
.summary('Configure your API key and install the agent skills')
|
|
606
621
|
.description(SETUP_DESCRIPTION)
|
|
607
|
-
.addHelpText('after',
|
|
622
|
+
.addHelpText('after', '\nValidates the key (GET /me), saves it to your profile and writes the skills into the project\n' +
|
|
623
|
+
'directory. With --yes or no terminal (CI) the key must come from --from-env or --api-key\n' +
|
|
624
|
+
'(or --skip-if-configured with a saved key); otherwise setup exits 5.\n' +
|
|
625
|
+
'\nExample:\n' +
|
|
626
|
+
' TESTSPRITE_API_KEY=sk-... testsprite setup --from-env --yes --agent claude\n' +
|
|
627
|
+
GLOBAL_OPTS_HINT)
|
|
608
628
|
.action(async (cmdOpts, command) => {
|
|
609
629
|
await runSetupAction(cmdOpts, command, deps);
|
|
610
630
|
});
|
|
@@ -673,12 +673,27 @@ export async function runEnvSetDefault(opts, deps = {}) {
|
|
|
673
673
|
return res;
|
|
674
674
|
}
|
|
675
675
|
const IDEMPOTENCY_HELP = 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.';
|
|
676
|
-
const
|
|
676
|
+
const LIST_EXIT_CODE_NOTE = '\nExit codes:\n' +
|
|
677
677
|
' 0 success\n' +
|
|
678
678
|
' 3 auth error\n' +
|
|
679
|
-
' 4 project
|
|
680
|
-
' 5 validation error
|
|
681
|
-
|
|
679
|
+
' 4 project not found\n' +
|
|
680
|
+
' 5 validation error';
|
|
681
|
+
const GET_EXIT_CODE_NOTE = '\nExit codes:\n' +
|
|
682
|
+
' 0 success\n' +
|
|
683
|
+
' 3 auth error\n' +
|
|
684
|
+
' 4 project or environment not found\n' +
|
|
685
|
+
' 5 validation error';
|
|
686
|
+
const DELETE_EXIT_CODE_NOTE = '\nExit codes:\n' +
|
|
687
|
+
' 0 success\n' +
|
|
688
|
+
' 3 auth error\n' +
|
|
689
|
+
' 4 project or environment not found\n' +
|
|
690
|
+
' 5 validation error (e.g., missing --confirm)\n' +
|
|
691
|
+
' 6 conflict (the default environment cannot be deleted)';
|
|
692
|
+
const SET_DEFAULT_EXIT_CODE_NOTE = '\nExit codes:\n' +
|
|
693
|
+
' 0 success\n' +
|
|
694
|
+
' 3 auth error\n' +
|
|
695
|
+
' 4 project or environment not found\n' +
|
|
696
|
+
' 5 validation error';
|
|
682
697
|
const UPDATE_EXIT_CODE_NOTE = '\nExit codes:\n' +
|
|
683
698
|
' 0 success\n' +
|
|
684
699
|
' 3 auth error\n' +
|
|
@@ -698,25 +713,29 @@ const CREATE_EXIT_CODE_NOTE = '\nExit codes:\n' +
|
|
|
698
713
|
'\n 14 client too old';
|
|
699
714
|
export function createProjectEnvCommand(deps = {}) {
|
|
700
715
|
const env = new Command('env')
|
|
716
|
+
.summary("Manage a project's environments")
|
|
701
717
|
.description("Manage a project's environments — named URL + test-account bundles that `test run --env <name>` selects")
|
|
702
718
|
.addHelpText('after', '\nFor an app that only runs on this machine, create or update the environment with\n' +
|
|
703
719
|
'`--url http://localhost:<port>` or `--local <port>`; `test run <id> --env <name>` opens a tunnel automatically.');
|
|
704
720
|
env
|
|
705
721
|
.command('list <project-id>')
|
|
706
|
-
.
|
|
722
|
+
.summary("List a project's environments")
|
|
723
|
+
.description("List a project's environments (name, default, URL, auth)." + LIST_EXIT_CODE_NOTE)
|
|
707
724
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
708
725
|
.action(async (projectId, _cmdOpts, command) => {
|
|
709
726
|
await runEnvList({ ...resolveCommonOptions(command, deps.env), projectId }, deps);
|
|
710
727
|
});
|
|
711
728
|
env
|
|
712
729
|
.command('get <project-id> <name>')
|
|
713
|
-
.
|
|
730
|
+
.summary('Get one environment by name')
|
|
731
|
+
.description('Get one environment by name, including its login settings.' + GET_EXIT_CODE_NOTE)
|
|
714
732
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
715
733
|
.action(async (projectId, name, _cmdOpts, command) => {
|
|
716
734
|
await runEnvGet({ ...resolveCommonOptions(command, deps.env), projectId, name }, deps);
|
|
717
735
|
});
|
|
718
736
|
env
|
|
719
737
|
.command('create <project-id>')
|
|
738
|
+
.summary('Create an environment')
|
|
720
739
|
.description('Create an environment (--name and one of --url / --local are required).' +
|
|
721
740
|
CREATE_EXIT_CODE_NOTE)
|
|
722
741
|
.option('--name <name>', 'environment name, unique within the project (required)')
|
|
@@ -725,11 +744,11 @@ export function createProjectEnvCommand(deps = {}) {
|
|
|
725
744
|
.addOption(new Option('--local-host <host>', 'deprecated loopback host override; requires --local').hideHelp())
|
|
726
745
|
.option('--skip-preflight', 'skip the local TCP listener check before creating')
|
|
727
746
|
.option('--username <user>', 'test-account username the browser logs in with')
|
|
728
|
-
.option('--password <pw>', 'test-account password (prefer --password-file)')
|
|
747
|
+
.option('--password <pw>', 'test-account password (prefer --password-file, exclusive)')
|
|
729
748
|
.option('--password-file <path>', 'read the password from a file instead of the command line')
|
|
730
|
-
.option('--var <KEY=VALUE>', 'set a custom variable (repeatable); shown in plain text by `env get
|
|
731
|
-
.option('--sign-in <mode>', 'public, account, otp, or manual (aliases: none, credentials, sso)')
|
|
732
|
-
.option('--otp-channel <email,sms>', 'OTP channels: email and/or sms; repeat or comma-separate', (value, previous = []) => [...previous, value])
|
|
749
|
+
.option('--var <KEY=VALUE>', 'set a custom variable (repeatable; max 50, 4096 bytes each, key [A-Za-z_][A-Za-z0-9_]*, reserved names like url/username/password rejected); shown in plain text by `env get`, not for secrets', collectVar, [])
|
|
750
|
+
.option('--sign-in <mode>', 'public, account, otp, or manual (aliases: none, credentials, sso). manual: log in once in the Portal, runs reuse that session (not signed in until then). otp and manual: not for local environments')
|
|
751
|
+
.option('--otp-channel <email,sms>', 'OTP channels: email and/or sms; repeat or comma-separate (default: email)', (value, previous = []) => [...previous, value])
|
|
733
752
|
.option('--session-ttl <seconds|never>', 'SSO session reuse lifetime: 1–2592000 seconds or never (manual only)')
|
|
734
753
|
.option('--set-default', "make this the project's default environment", false)
|
|
735
754
|
.option('--idempotency-key <token>', IDEMPOTENCY_HELP)
|
|
@@ -756,16 +775,18 @@ export function createProjectEnvCommand(deps = {}) {
|
|
|
756
775
|
});
|
|
757
776
|
env
|
|
758
777
|
.command('update <project-id> <name>')
|
|
759
|
-
.
|
|
778
|
+
.summary('Change an environment')
|
|
779
|
+
.description("Change an environment's URL, credentials, custom variables or name (sign-in mode: `project sign-in set`)." +
|
|
780
|
+
UPDATE_EXIT_CODE_NOTE)
|
|
760
781
|
.option('--url <url>', 'new address runs open (public http/https, or a loopback http origin with an explicit port)')
|
|
761
782
|
.option('--local <port>', 'shorthand for --url http://localhost:<port> (1-65535; excludes --url)')
|
|
762
783
|
.addOption(new Option('--local-host <host>', 'deprecated loopback host override; requires --local').hideHelp())
|
|
763
784
|
.option('--skip-preflight', 'skip the local TCP listener check before the update')
|
|
764
785
|
.option('--username <user>', 'new test-account username')
|
|
765
|
-
.option('--password <pw>', 'new test-account password (prefer --password-file)')
|
|
786
|
+
.option('--password <pw>', 'new test-account password (prefer --password-file, exclusive)')
|
|
766
787
|
.option('--password-file <path>', 'read the new password from a file')
|
|
767
788
|
.option('--clear-credentials', 'remove stored username and password; disable account login')
|
|
768
|
-
.option('--var <KEY=VALUE>', 'merge a custom variable (repeatable); shown in plain text by `env get
|
|
789
|
+
.option('--var <KEY=VALUE>', 'merge a custom variable (repeatable; max 50, 4096 bytes each, key [A-Za-z_][A-Za-z0-9_]*, reserved names like url/username/password rejected); shown in plain text by `env get`, not for secrets', collectVar, [])
|
|
769
790
|
.option('--rename <new-name>', 'rename the environment (runs keep referring to it by the new name)')
|
|
770
791
|
.option('--idempotency-key <token>', IDEMPOTENCY_HELP)
|
|
771
792
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
@@ -789,9 +810,10 @@ export function createProjectEnvCommand(deps = {}) {
|
|
|
789
810
|
});
|
|
790
811
|
env
|
|
791
812
|
.command('delete <project-id> <name>')
|
|
813
|
+
.summary('Delete an environment (requires --confirm)')
|
|
792
814
|
.description('Delete an environment and its stored credentials. Requires --confirm; the default\n' +
|
|
793
815
|
'environment cannot be deleted (set another default first).' +
|
|
794
|
-
|
|
816
|
+
DELETE_EXIT_CODE_NOTE)
|
|
795
817
|
.option('--confirm', 'required: explicit confirmation for the destructive operation', false)
|
|
796
818
|
.option('--idempotency-key <token>', IDEMPOTENCY_HELP)
|
|
797
819
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
@@ -806,9 +828,9 @@ export function createProjectEnvCommand(deps = {}) {
|
|
|
806
828
|
});
|
|
807
829
|
env
|
|
808
830
|
.command('set-default <project-id> <name>')
|
|
809
|
-
.
|
|
810
|
-
'
|
|
811
|
-
|
|
831
|
+
.summary('Make an environment the project default')
|
|
832
|
+
.description('Make an environment the project default — what every run without --env uses.' +
|
|
833
|
+
SET_DEFAULT_EXIT_CODE_NOTE)
|
|
812
834
|
.option('--idempotency-key <token>', IDEMPOTENCY_HELP)
|
|
813
835
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
814
836
|
.action(async (projectId, name, cmdOpts, command) => {
|
|
@@ -261,9 +261,12 @@ export async function runSignInSet(opts, deps = {}) {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
export function createProjectSignInCommand(deps = {}) {
|
|
264
|
-
const group = new Command('sign-in')
|
|
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.');
|
|
265
267
|
group
|
|
266
268
|
.command('get <project-id>')
|
|
269
|
+
.summary('Show the environment sign-in mode and status')
|
|
267
270
|
.description('Show the environment sign-in mode, credentials status, OTP channels, or SSO session.')
|
|
268
271
|
.option('--env <name>', 'environment name (defaults to the project default)')
|
|
269
272
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
@@ -272,11 +275,13 @@ export function createProjectSignInCommand(deps = {}) {
|
|
|
272
275
|
});
|
|
273
276
|
group
|
|
274
277
|
.command('set <project-id>')
|
|
275
|
-
.
|
|
276
|
-
.
|
|
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)')
|
|
277
282
|
.option('--env <name>', 'environment name (defaults to the project default)')
|
|
278
283
|
.option('--username <user>', 'test-account username (account only)')
|
|
279
|
-
.option('--password <pw>', 'test-account password (prefer --password-file; account only)')
|
|
284
|
+
.option('--password <pw>', 'test-account password (prefer --password-file, exclusive; account only)')
|
|
280
285
|
.option('--password-file <path>', 'read the test-account password from a file (account only)')
|
|
281
286
|
.option('--session-ttl <seconds|never>', 'SSO session reuse lifetime: 1–2592000 seconds or never (manual only)')
|
|
282
287
|
.option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
|
package/dist/commands/project.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Command, Option } from 'commander';
|
|
|
6
6
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, resolveRequestTimeoutMs, } from '../lib/client-factory.js';
|
|
7
7
|
import { resolveProfileName } from '../lib/config.js';
|
|
8
8
|
import { ApiError, InterruptError, RequestTimeoutError } from '../lib/errors.js';
|
|
9
|
+
import { firstSuiteNextSteps } from '../lib/first-suite-hint.js';
|
|
9
10
|
import { globalShutdown } from '../lib/interrupt.js';
|
|
10
11
|
import { assertStoredLocalTargetListening, buildLocalTargetUrl, parseStoredLocalTarget, } from '../lib/local-target.js';
|
|
11
12
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
@@ -252,6 +253,15 @@ export async function runCreate(opts, deps = {}) {
|
|
|
252
253
|
`no-target-resolvable until one is set. Fix: testsprite project update ` +
|
|
253
254
|
`${resolvedId ?? '<project-id>'} --url <url>`);
|
|
254
255
|
}
|
|
256
|
+
// A new project with no tests is where activation stalls. Point at
|
|
257
|
+
// the generate -> accept path (text mode only: a JSON caller already holds
|
|
258
|
+
// the id; --dry-run returned above, its id is the canned sample). Printed
|
|
259
|
+
// after the URL advisory so a fix-first warning is never buried below it.
|
|
260
|
+
// A --local project is skipped: its record above already ends with the
|
|
261
|
+
// hand-written-plan next steps.
|
|
262
|
+
if (opts.output !== 'json' && resolvedId !== undefined && !localTarget) {
|
|
263
|
+
stderr(firstSuiteNextSteps(resolvedId, opts.type));
|
|
264
|
+
}
|
|
255
265
|
return created;
|
|
256
266
|
}
|
|
257
267
|
/** Resolve the updated project's id regardless of which field name the backend used. */
|
|
@@ -938,16 +948,17 @@ export function createProjectCommand(deps = {}) {
|
|
|
938
948
|
const project = new Command('project').description('Manage TestSprite projects');
|
|
939
949
|
project
|
|
940
950
|
.command('list')
|
|
951
|
+
.summary('List projects visible to the API key')
|
|
941
952
|
.description('List projects visible to the API key\n' +
|
|
942
953
|
'\nExit codes:\n' +
|
|
943
954
|
' 0 success\n' +
|
|
944
955
|
' 3 auth error\n' +
|
|
945
956
|
' 5 validation error (e.g., bad --page-size)\n' +
|
|
946
957
|
' 10 transport/network failure (UNAVAILABLE) — retry the command')
|
|
947
|
-
.option('--page-size <n>', '
|
|
958
|
+
.option('--page-size <n>', 'page size (1-100, default 25); alone it returns one page plus a next --starting-token (add --max-items to auto-page)')
|
|
948
959
|
.option('--starting-token <token>', 'opaque cursor from a previous list response')
|
|
949
960
|
.option('--max-items <n>', 'stop after this many items across auto-paged pages')
|
|
950
|
-
.option('--columns <list>', 'select/reorder text table columns (comma-separated keys)')
|
|
961
|
+
.option('--columns <list>', 'select/reorder text table columns (comma-separated keys: id, name, type, from, org, url, created, defaultenv, envs)')
|
|
951
962
|
.option('--no-header', 'suppress the text table header row')
|
|
952
963
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
953
964
|
.action(async (cmdOpts, command) => {
|
|
@@ -977,15 +988,14 @@ export function createProjectCommand(deps = {}) {
|
|
|
977
988
|
.description('Create a new project')
|
|
978
989
|
.option('--type <frontend|backend>', 'project type (required)')
|
|
979
990
|
.option('--name <name>', 'project name (required)')
|
|
980
|
-
.option('--url <url>', 'target URL (public http/https
|
|
981
|
-
'
|
|
982
|
-
.option('--local <port>', 'shorthand for --url http://localhost:<port> (1-65535; excludes --url; runs open a tunnel automatically)')
|
|
991
|
+
.option('--url <url>', 'target URL (public http/https; a loopback http origin with an explicit port is frontend only; required for frontend unless --local; also required for backend on the V3 path, see `auth status`)')
|
|
992
|
+
.option('--local <port>', 'shorthand for --url http://localhost:<port> (1-65535; excludes --url; frontend only; runs open a tunnel automatically)')
|
|
983
993
|
.addOption(new Option('--local-host <host>', 'deprecated loopback host override; requires --local').hideHelp())
|
|
984
994
|
.option('--skip-preflight', 'skip the local TCP listener check before project creation')
|
|
985
995
|
.option('--description <text>', 'not supported — projects have no description (test-level descriptions are set on `test create`)')
|
|
986
|
-
.option('--username <user>', 'optional auth username')
|
|
987
|
-
.option('--password <pw>', 'optional auth password
|
|
988
|
-
.option('--password-file <path>', 'read password from file
|
|
996
|
+
.option('--username <user>', 'optional auth username (give with --password)')
|
|
997
|
+
.option('--password <pw>', 'optional auth password, with --username (--password-file for non-interactive)')
|
|
998
|
+
.option('--password-file <path>', 'read password from file (if both are given, --password wins with a warning)')
|
|
989
999
|
.option('--instruction <text>', 'optional FE plan-gen instruction hint')
|
|
990
1000
|
.option('--test-id-attributes <list>', 'comma-separated DOM attributes the engine should prefer as locators, highest priority first ' +
|
|
991
1001
|
'(e.g. data-element,data-testid). Unique values are exported as page.locator(\'[attr="…"]\').')
|
|
@@ -1029,7 +1039,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1029
1039
|
.option('--skip-preflight', 'skip the local TCP listener check before the update')
|
|
1030
1040
|
.option('--username <user>', 'new auth username')
|
|
1031
1041
|
.option('--password <pw>', 'new auth password')
|
|
1032
|
-
.option('--password-file <path>', 'read new password from file')
|
|
1042
|
+
.option('--password-file <path>', 'read new password from file (if both are given, --password wins with a warning)')
|
|
1033
1043
|
.option('--instruction <text>', 'new FE plan-gen instruction hint')
|
|
1034
1044
|
.option('--test-id-attributes <list>', 'comma-separated DOM attributes the engine should prefer as locators, highest priority first ' +
|
|
1035
1045
|
'(e.g. data-element,data-testid); replaces the current list')
|
|
@@ -1058,6 +1068,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1058
1068
|
});
|
|
1059
1069
|
project
|
|
1060
1070
|
.command('delete <project-id>')
|
|
1071
|
+
.summary('Permanently delete a project (requires --confirm)')
|
|
1061
1072
|
.description('Permanently delete a project and everything under it (sub-projects,\n' +
|
|
1062
1073
|
'their tests, and backend fixtures). Requires --confirm.\n' +
|
|
1063
1074
|
'\nExit codes:\n' +
|
|
@@ -1078,9 +1089,10 @@ export function createProjectCommand(deps = {}) {
|
|
|
1078
1089
|
});
|
|
1079
1090
|
project
|
|
1080
1091
|
.command('credential <project-id>')
|
|
1081
|
-
.
|
|
1082
|
-
'
|
|
1083
|
-
|
|
1092
|
+
.summary('Set the static credential injected into backend tests')
|
|
1093
|
+
.description('Set the static backend credential injected into every backend test. Free tier.\n' +
|
|
1094
|
+
"On V3 accounts it is stored on the project's default environment.")
|
|
1095
|
+
.requiredOption('--type <type>', 'required: public | "Bearer token" | "API key" | "basic token" (exact, lowercase)')
|
|
1084
1096
|
.option('--credential <value>', 'credential value (required unless --type public)')
|
|
1085
1097
|
.option('--credential-file <path>', 'read the credential value from a file')
|
|
1086
1098
|
.option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
|
|
@@ -1097,11 +1109,14 @@ export function createProjectCommand(deps = {}) {
|
|
|
1097
1109
|
});
|
|
1098
1110
|
project
|
|
1099
1111
|
.command('auto-auth <project-id>')
|
|
1100
|
-
.
|
|
1101
|
-
'
|
|
1112
|
+
.summary('Configure auto-refresh login for backend tests (paid)')
|
|
1113
|
+
.description('Configure the recurring-token (auto-refresh login) for backend tests (paid plans):\n' +
|
|
1114
|
+
'a fresh token is fetched on each run and injected into every backend test.\n' +
|
|
1115
|
+
'Each method needs its own flags (password: --login-url, --token-path, ...;\n' +
|
|
1116
|
+
'refresh_token: --token-endpoint, --client-id, ...; aws_cognito_refresh: --region, ...).')
|
|
1102
1117
|
.requiredOption('--method <method>', 'password | refresh_token | aws_cognito_refresh')
|
|
1103
1118
|
.requiredOption('--inject <where>', 'bearer | header | cookie')
|
|
1104
|
-
.option('--disable', 'turn auto-auth off
|
|
1119
|
+
.option('--disable', 'turn auto-auth off, keeping stored config (--method and --inject are still required)')
|
|
1105
1120
|
.option('--inject-key <name>', 'header/cookie name when --inject is header/cookie')
|
|
1106
1121
|
// password method
|
|
1107
1122
|
.option('--login-url <url>', 'login endpoint (method=password)')
|
|
@@ -1151,13 +1166,15 @@ export function createProjectCommand(deps = {}) {
|
|
|
1151
1166
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
1152
1167
|
}, deps);
|
|
1153
1168
|
});
|
|
1154
|
-
const docs = new Command('docs')
|
|
1169
|
+
const docs = new Command('docs')
|
|
1170
|
+
.summary('Manage project documents (plan-generation sources)')
|
|
1171
|
+
.description('Manage project documents — the sources plan generation feeds on');
|
|
1155
1172
|
docs
|
|
1156
1173
|
.command('upload <file>')
|
|
1157
|
-
.
|
|
1158
|
-
'mint a presigned S3 URL, stream the file
|
|
1159
|
-
'document — which starts processing + embedding
|
|
1160
|
-
'
|
|
1174
|
+
.summary('Upload an API spec or PRD as a project source')
|
|
1175
|
+
.description('Upload an API spec or PRD as a project source: mint a presigned S3 URL, stream the file\n' +
|
|
1176
|
+
'to it, register the document — which starts processing + embedding and spends credits\n' +
|
|
1177
|
+
'(see `testsprite usage`). The local file is only read.\n' +
|
|
1161
1178
|
'\nExit codes:\n' +
|
|
1162
1179
|
' 0 upload registered (processing started)\n' +
|
|
1163
1180
|
' 3 auth error\n' +
|
|
@@ -1165,7 +1182,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1165
1182
|
' 5 validation error (missing/empty file, bad --role)\n' +
|
|
1166
1183
|
' 7 request timeout (also: backend predates the docs routes)\n' +
|
|
1167
1184
|
' 10 presigned S3 PUT failed — re-run to mint a fresh URL')
|
|
1168
|
-
.option('--project <id>', 'project id
|
|
1185
|
+
.option('--project <id>', 'project id (required unless TESTSPRITE_PROJECT_ID is set)')
|
|
1169
1186
|
.option('--role <role>', 'document role: api-doc (API spec, default) | prd')
|
|
1170
1187
|
.option('--name <display-name>', 'display name for the document (default: file basename)')
|
|
1171
1188
|
.option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
|
|
@@ -1366,7 +1383,11 @@ function renderCreateProjectText(p, localTarget) {
|
|
|
1366
1383
|
if (localTarget) {
|
|
1367
1384
|
const projectId = resolveCreatedProjectId(p) ?? '<project-id>';
|
|
1368
1385
|
const url = buildLocalTargetUrl(localTarget.host, localTarget.port);
|
|
1369
|
-
lines.push(`Local project: TestSprite will reach ${url} only through a tunnel from this machine.`, 'Next: write a plan and run it locally:',
|
|
1386
|
+
lines.push(`Local project: TestSprite will reach ${url} only through a tunnel from this machine.`, 'Next: write a plan and run it locally:',
|
|
1387
|
+
// The only next step a --local project gets (it has no first-suite hint),
|
|
1388
|
+
// so it names how to get a plan file. `--plan-from` takes the project from
|
|
1389
|
+
// the file and ignores `--project`, hence "set projectId" and no flag.
|
|
1390
|
+
' testsprite test create --plan-template > plan.json', ` In plan.json, set projectId to ${projectId} and edit the steps.`, ' testsprite test create --plan-from plan.json', ' testsprite test run <test-id>', `Portal runs of this project stay blocked (free) until you set a public URL with: testsprite project update ${projectId} --url https://...`);
|
|
1370
1391
|
}
|
|
1371
1392
|
return lines.join('\n');
|
|
1372
1393
|
}
|