@testsprite/testsprite-cli 0.13.0 → 0.15.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 +54 -49
- package/dist/commands/ci.d.ts +66 -17
- package/dist/commands/ci.js +466 -104
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.js +62 -20
- package/dist/commands/init.js +17 -3
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +399 -61
- package/dist/commands/project-sign-in.d.ts +60 -0
- package/dist/commands/project-sign-in.js +289 -0
- package/dist/commands/project.d.ts +9 -0
- package/dist/commands/project.js +82 -28
- package/dist/commands/schedule.d.ts +12 -0
- package/dist/commands/schedule.js +175 -5
- package/dist/commands/test.d.ts +126 -30
- package/dist/commands/test.js +1928 -447
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +170 -30
- package/dist/commands/tunnel.js +11 -5
- package/dist/index.js +17 -38
- 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 +35 -1
- package/dist/lib/client-factory.js +21 -10
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +1 -1
- package/dist/lib/credentials.d.ts +0 -1
- package/dist/lib/credentials.js +51 -14
- package/dist/lib/dry-run/samples.js +95 -1
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.js +12 -1
- 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 +152 -7
- package/dist/lib/github-context.d.ts +21 -0
- package/dist/lib/github-context.js +153 -0
- package/dist/lib/http.d.ts +12 -1
- package/dist/lib/http.js +9 -1
- package/dist/lib/junit-report.d.ts +11 -7
- package/dist/lib/junit-report.js +13 -7
- package/dist/lib/local-target.d.ts +13 -3
- package/dist/lib/local-target.js +47 -12
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.js +3 -4
- package/dist/lib/plans.types.d.ts +1 -1
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +19 -5
- package/dist/lib/render-error.js +31 -0
- package/dist/lib/response-schemas.d.ts +5 -1
- package/dist/lib/response-schemas.js +54 -0
- package/dist/lib/runs.types.d.ts +115 -1
- package/dist/lib/target-url.js +5 -5
- package/dist/lib/telemetry.d.ts +31 -8
- package/dist/lib/telemetry.js +55 -7
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +18 -0
- package/dist/lib/tunnel-session.d.ts +3 -4
- package/dist/lib/tunnel-session.js +3 -4
- package/dist/lib/v3-advisory.js +0 -1
- package/dist/vendor/tunnel-client/client.d.ts +15 -8
- package/dist/vendor/tunnel-client/client.js +477 -407
- package/dist/vendor/tunnel-client/config.d.ts +5 -5
- package/dist/vendor/tunnel-client/config.js +5 -5
- package/dist/vendor/tunnel-client/index.d.ts +4 -4
- package/dist/vendor/tunnel-client/index.js +4 -4
- package/dist/vendor/tunnel-client/types.d.ts +19 -34
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
- package/dist/vendor/tunnel-client/ws-compat.js +70 -12
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schemas/plan.schema.json +2 -2
- package/skills/testsprite-ci.skill.md +154 -0
- package/skills/testsprite-onboard.skill.md +4 -4
|
@@ -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 });
|
|
@@ -199,7 +239,7 @@ async function checkConnectivity(opts, deps, ctx) {
|
|
|
199
239
|
}
|
|
200
240
|
}
|
|
201
241
|
/**
|
|
202
|
-
* Can this key open a tunnel
|
|
242
|
+
* Can this key open a tunnel for an environment on this machine?
|
|
203
243
|
*
|
|
204
244
|
* A READ, not a mint. `GET /tunnel/<random-uuid>` runs the same scope guard
|
|
205
245
|
* and the same environment-configured check as the mint, and answers 404 for
|
|
@@ -207,13 +247,10 @@ async function checkConnectivity(opts, deps, ctx) {
|
|
|
207
247
|
* one of the caller's few concurrent live bindings or any rate-limit budget on
|
|
208
248
|
* a diagnostic.
|
|
209
249
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* wild — gets a 403 the first time someone tries `--local`, and the remedy is
|
|
213
|
-
* to mint a NEW key rather than to re-authenticate. Nothing else in the CLI
|
|
214
|
-
* says that until a run has already been refused.
|
|
250
|
+
* Keys deliberately narrowed without `run:tunnel` receive a 403. Older
|
|
251
|
+
* servers may also exclude the scope from their legacy-key grant.
|
|
215
252
|
*
|
|
216
|
-
* Never `fail`: a caller who does not use
|
|
253
|
+
* Never `fail`: a caller who does not use a tunnel should not see `doctor`
|
|
217
254
|
* exit 1 over a surface that is not even configured in their environment.
|
|
218
255
|
*/
|
|
219
256
|
async function checkLocalTunnel(opts, deps, ctx) {
|
|
@@ -241,6 +278,7 @@ async function checkLocalTunnel(opts, deps, ctx) {
|
|
|
241
278
|
credentialsPath: deps.credentialsPath,
|
|
242
279
|
fetchImpl: deps.fetchImpl,
|
|
243
280
|
stderr: deps.stderr,
|
|
281
|
+
config: ctx.config,
|
|
244
282
|
// The retry sleeper listens to the client shutdown signal. Compose
|
|
245
283
|
// the probe deadline with process shutdown so either aborts the fetch.
|
|
246
284
|
shutdownSignal: controller.signal,
|
|
@@ -266,21 +304,25 @@ async function checkLocalTunnel(opts, deps, ctx) {
|
|
|
266
304
|
};
|
|
267
305
|
}
|
|
268
306
|
if (error.code === 'NOT_FOUND') {
|
|
269
|
-
return {
|
|
307
|
+
return {
|
|
308
|
+
name,
|
|
309
|
+
status: 'ok',
|
|
310
|
+
detail: 'available; this key can open a tunnel for an environment on this machine',
|
|
311
|
+
};
|
|
270
312
|
}
|
|
271
313
|
if (error.code === 'AUTH_FORBIDDEN') {
|
|
272
314
|
return {
|
|
273
315
|
name,
|
|
274
316
|
status: 'warn',
|
|
275
|
-
detail: 'this API key
|
|
276
|
-
'Mint a new API key in the dashboard to
|
|
317
|
+
detail: 'this API key does not have the `run:tunnel` scope. ' +
|
|
318
|
+
'Mint a new API key with that scope in the dashboard to run an environment on this machine.',
|
|
277
319
|
};
|
|
278
320
|
}
|
|
279
321
|
if (error.code === 'UNAVAILABLE') {
|
|
280
322
|
return {
|
|
281
323
|
name,
|
|
282
324
|
status: 'warn',
|
|
283
|
-
detail: '
|
|
325
|
+
detail: 'tunnels for environments on this machine are not available on this endpoint',
|
|
284
326
|
};
|
|
285
327
|
}
|
|
286
328
|
return { name, status: 'warn', detail: `could not check (${error.code})` };
|
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('');
|
|
@@ -7,7 +7,7 @@ export interface CliProjectEnvironment {
|
|
|
7
7
|
name: string;
|
|
8
8
|
/**
|
|
9
9
|
* The address runs against this environment open. May be a loopback URL for
|
|
10
|
-
* an app that only runs on your own machine —
|
|
10
|
+
* an app that only runs on your own machine — frontend runs open a tunnel.
|
|
11
11
|
*/
|
|
12
12
|
url: string;
|
|
13
13
|
isDefault: boolean;
|
|
@@ -24,6 +24,7 @@ export interface CliProjectEnvironment {
|
|
|
24
24
|
username: string | null;
|
|
25
25
|
enableOtp: boolean;
|
|
26
26
|
updatedAt: string;
|
|
27
|
+
variables?: Record<string, string>;
|
|
27
28
|
}
|
|
28
29
|
export interface CliProjectEnvListResponse {
|
|
29
30
|
environments: CliProjectEnvironment[];
|
|
@@ -43,6 +44,9 @@ interface EnvListOptions extends CommonOptions {
|
|
|
43
44
|
projectId: string;
|
|
44
45
|
}
|
|
45
46
|
export declare function runEnvList(opts: EnvListOptions, deps?: ProjectDeps): Promise<CliProjectEnvListResponse>;
|
|
47
|
+
export declare function runEnvGet(opts: EnvListOptions & {
|
|
48
|
+
name: string;
|
|
49
|
+
}, deps?: ProjectDeps): Promise<CliProjectEnvUpdateResponse>;
|
|
46
50
|
interface EnvCreateOptions extends CommonOptions {
|
|
47
51
|
projectId: string;
|
|
48
52
|
name?: string;
|
|
@@ -54,8 +58,12 @@ interface EnvCreateOptions extends CommonOptions {
|
|
|
54
58
|
username?: string;
|
|
55
59
|
password?: string;
|
|
56
60
|
passwordFile?: string;
|
|
61
|
+
vars?: string[];
|
|
57
62
|
setDefault?: boolean;
|
|
58
63
|
idempotencyKey?: string;
|
|
64
|
+
signIn?: string;
|
|
65
|
+
otpChannel?: string[];
|
|
66
|
+
sessionTtl?: string;
|
|
59
67
|
}
|
|
60
68
|
export declare function runEnvCreate(opts: EnvCreateOptions, deps?: ProjectDeps): Promise<CliProjectEnvCreateResponse>;
|
|
61
69
|
interface EnvUpdateOptions extends CommonOptions {
|
|
@@ -69,6 +77,8 @@ interface EnvUpdateOptions extends CommonOptions {
|
|
|
69
77
|
username?: string;
|
|
70
78
|
password?: string;
|
|
71
79
|
passwordFile?: string;
|
|
80
|
+
clearCredentials?: boolean;
|
|
81
|
+
vars?: string[];
|
|
72
82
|
rename?: string;
|
|
73
83
|
idempotencyKey?: string;
|
|
74
84
|
}
|