@testsprite/testsprite-cli 0.12.0 → 0.14.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 +59 -49
- package/dist/commands/agent.js +16 -13
- package/dist/commands/auth.d.ts +19 -0
- package/dist/commands/auth.js +60 -24
- package/dist/commands/ci.d.ts +86 -1
- package/dist/commands/ci.js +436 -5
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +34 -20
- package/dist/commands/init.js +14 -11
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +408 -70
- 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 +14 -5
- package/dist/commands/project.js +110 -70
- package/dist/commands/schedule.d.ts +14 -0
- package/dist/commands/schedule.js +193 -15
- package/dist/commands/test.d.ts +123 -44
- package/dist/commands/test.js +2993 -636
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +217 -47
- package/dist/commands/tunnel.d.ts +26 -3
- package/dist/commands/tunnel.js +221 -18
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.js +12 -5
- package/dist/index.js +39 -50
- package/dist/lib/agent-targets.d.ts +3 -3
- package/dist/lib/agent-targets.js +2 -2
- package/dist/lib/billing-refusal.d.ts +43 -0
- package/dist/lib/billing-refusal.js +171 -0
- package/dist/lib/bundle.d.ts +5 -0
- package/dist/lib/bundle.js +43 -13
- package/dist/lib/ci-linkage.d.ts +90 -0
- package/dist/lib/ci-linkage.js +181 -0
- package/dist/lib/client-factory.d.ts +16 -2
- package/dist/lib/client-factory.js +37 -6
- package/dist/lib/config.d.ts +17 -0
- package/dist/lib/config.js +20 -1
- package/dist/lib/conflict-reason.d.ts +27 -3
- package/dist/lib/conflict-reason.js +53 -4
- package/dist/lib/credentials.js +56 -14
- package/dist/lib/dry-run/samples.d.ts +13 -1
- package/dist/lib/dry-run/samples.js +104 -7
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.d.ts +18 -11
- package/dist/lib/errors.js +123 -14
- package/dist/lib/failing-fe-resolver.d.ts +1 -1
- package/dist/lib/failing-fe-resolver.js +3 -3
- package/dist/lib/gh-output.d.ts +1 -0
- package/dist/lib/gh-output.js +16 -4
- package/dist/lib/history-retention.d.ts +8 -0
- package/dist/lib/history-retention.js +24 -0
- package/dist/lib/http.d.ts +39 -19
- package/dist/lib/http.js +46 -24
- package/dist/lib/interrupt.d.ts +21 -13
- package/dist/lib/interrupt.js +32 -21
- package/dist/lib/junit-report.d.ts +18 -4
- package/dist/lib/junit-report.js +23 -5
- package/dist/lib/local-target.d.ts +14 -4
- package/dist/lib/local-target.js +48 -13
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.d.ts +11 -11
- package/dist/lib/plan-poll.js +15 -16
- package/dist/lib/plans.types.d.ts +9 -9
- package/dist/lib/plans.types.js +3 -3
- package/dist/lib/poll.d.ts +2 -2
- package/dist/lib/poll.js +9 -3
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +21 -5
- package/dist/lib/render-error.js +44 -0
- package/dist/lib/response-schemas.d.ts +54 -12
- package/dist/lib/response-schemas.js +88 -7
- package/dist/lib/runs.types.d.ts +68 -11
- package/dist/lib/secret-file.js +72 -14
- package/dist/lib/skill-nudge.d.ts +6 -1
- package/dist/lib/skill-nudge.js +32 -5
- package/dist/lib/target-url-preflight.d.ts +6 -4
- package/dist/lib/target-url-preflight.js +64 -51
- package/dist/lib/target-url.js +11 -11
- package/dist/lib/telemetry.d.ts +10 -8
- package/dist/lib/telemetry.js +24 -17
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +111 -4
- package/dist/lib/tunnel-session.d.ts +16 -4
- package/dist/lib/tunnel-session.js +7 -5
- package/dist/lib/tunnel.types.d.ts +12 -2
- package/dist/lib/tunnel.types.js +2 -2
- package/dist/lib/v3-advisory.js +0 -1
- package/dist/lib/wait-exit.d.ts +8 -0
- package/dist/lib/wait-exit.js +76 -4
- package/dist/lib/workspace-status.d.ts +23 -0
- package/dist/lib/workspace-status.js +15 -0
- 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-guard.d.ts +7 -1
- package/dist/version-guard.js +19 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/skills/testsprite-onboard.skill.md +8 -8
- package/skills/testsprite-verify.codex.md +59 -57
- package/skills/testsprite-verify.skill.md +53 -38
package/dist/commands/project.js
CHANGED
|
@@ -2,11 +2,12 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { createReadStream, readFileSync, statSync } from 'node:fs';
|
|
3
3
|
import { basename, extname } from 'node:path';
|
|
4
4
|
import { Readable } from 'node:stream';
|
|
5
|
-
import { Command } from 'commander';
|
|
5
|
+
import { Command, Option } from 'commander';
|
|
6
6
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, resolveRequestTimeoutMs, } from '../lib/client-factory.js';
|
|
7
|
+
import { resolveProfileName } from '../lib/config.js';
|
|
7
8
|
import { ApiError, InterruptError, RequestTimeoutError } from '../lib/errors.js';
|
|
8
9
|
import { globalShutdown } from '../lib/interrupt.js';
|
|
9
|
-
import { assertStoredLocalTargetListening, buildLocalTargetUrl,
|
|
10
|
+
import { assertStoredLocalTargetListening, buildLocalTargetUrl, parseStoredLocalTarget, } from '../lib/local-target.js';
|
|
10
11
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
11
12
|
import { readSecretFileGuarded } from '../lib/secret-file.js';
|
|
12
13
|
import { assertNotLocal } from '../lib/target-url.js';
|
|
@@ -14,6 +15,7 @@ import { renderTextTable, resolveTextColumns } from '../lib/text-table.js';
|
|
|
14
15
|
import { assertIdempotencyKey } from '../lib/validate.js';
|
|
15
16
|
import { fetchSinglePage, paginate, validatePaginationFlags, } from '../lib/pagination.js';
|
|
16
17
|
import { createProjectEnvCommand } from './project-env.js';
|
|
18
|
+
import { createProjectSignInCommand } from './project-sign-in.js';
|
|
17
19
|
/** Attribute names are interpolated into CSS selectors by the engine — keep them plain. */
|
|
18
20
|
const TEST_ID_ATTRIBUTE_NAME = /^[A-Za-z_][\w.:-]*$/;
|
|
19
21
|
const TEST_ID_ATTRIBUTES_MAX = 10;
|
|
@@ -102,6 +104,9 @@ export async function runCreate(opts, deps = {}) {
|
|
|
102
104
|
if (opts.password !== undefined && opts.password.trim().length === 0) {
|
|
103
105
|
throw localValidationError('--password must not be empty or whitespace-only');
|
|
104
106
|
}
|
|
107
|
+
if (opts.password !== undefined && opts.passwordFile !== undefined) {
|
|
108
|
+
stderr('Warning: --password takes precedence; --password-file was ignored.');
|
|
109
|
+
}
|
|
105
110
|
if (opts.name.length > 200) {
|
|
106
111
|
throw localValidationError('--name must be at most 200 characters');
|
|
107
112
|
}
|
|
@@ -119,12 +124,15 @@ export async function runCreate(opts, deps = {}) {
|
|
|
119
124
|
localHost: opts.localHost,
|
|
120
125
|
url: opts.targetUrl,
|
|
121
126
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
// A loopback --url is the same stored target as --local, so it gets the same
|
|
128
|
+
// refusal before anything is sent.
|
|
129
|
+
if (localTarget && opts.type !== 'frontend') {
|
|
130
|
+
throw localValidationError('a --url on this machine (localhost, 127.0.0.1, [::1]) is frontend-only; give a backend project a public URL');
|
|
131
|
+
}
|
|
132
|
+
const targetUrl = opts.targetUrl ??
|
|
133
|
+
(localTarget ? buildLocalTargetUrl(localTarget.host, localTarget.port) : undefined);
|
|
134
|
+
// Keep the existing public-address guard for targets a loopback tunnel cannot reach.
|
|
135
|
+
if (opts.targetUrl !== undefined && !localTarget) {
|
|
128
136
|
assertNotLocal(opts.targetUrl, {
|
|
129
137
|
field: 'url',
|
|
130
138
|
helpCommand: 'testsprite project create',
|
|
@@ -135,8 +143,8 @@ export async function runCreate(opts, deps = {}) {
|
|
|
135
143
|
throw localValidationError('--url is required for --type frontend');
|
|
136
144
|
}
|
|
137
145
|
if (opts.dryRun) {
|
|
138
|
-
//
|
|
139
|
-
//
|
|
146
|
+
// This path returns before makeClient() fires the banner, so emit it here
|
|
147
|
+
// — otherwise the canned sample can be mistaken for a live response.
|
|
140
148
|
emitDryRunBanner(stderr);
|
|
141
149
|
const idempotencyKey = opts.idempotencyKey ?? `cli-proj-create-${randomUUID()}`;
|
|
142
150
|
// P2-6: gate idempotency-key output behind --verbose/--debug/json (matches
|
|
@@ -264,23 +272,22 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
264
272
|
if (opts.password !== undefined && opts.password.trim().length === 0) {
|
|
265
273
|
throw localValidationError('--password must not be empty or whitespace-only');
|
|
266
274
|
}
|
|
275
|
+
if (opts.password !== undefined && opts.passwordFile !== undefined) {
|
|
276
|
+
stderr('Warning: --password takes precedence; --password-file was ignored.');
|
|
277
|
+
}
|
|
267
278
|
if (opts.name !== undefined && opts.name.length > 200) {
|
|
268
279
|
throw localValidationError('--name must be at most 200 characters');
|
|
269
280
|
}
|
|
270
|
-
//
|
|
271
|
-
//
|
|
272
|
-
// accepted form here and is redirected to `--local`. The project's type is
|
|
273
|
-
// not known client-side on update; the server refuses `--local` on a
|
|
274
|
-
// backend project.
|
|
281
|
+
// A loopback URL and --local shorthand use the same stored-target wire shape.
|
|
282
|
+
// The server owns project-type validation on update.
|
|
275
283
|
const localTarget = parseStoredLocalTarget({
|
|
276
284
|
local: opts.local,
|
|
277
285
|
localHost: opts.localHost,
|
|
278
286
|
url: opts.targetUrl,
|
|
279
287
|
});
|
|
280
|
-
const targetUrl =
|
|
281
|
-
? buildLocalTargetUrl(localTarget.host, localTarget.port)
|
|
282
|
-
|
|
283
|
-
if (opts.targetUrl !== undefined) {
|
|
288
|
+
const targetUrl = opts.targetUrl ??
|
|
289
|
+
(localTarget ? buildLocalTargetUrl(localTarget.host, localTarget.port) : undefined);
|
|
290
|
+
if (opts.targetUrl !== undefined && !localTarget) {
|
|
284
291
|
assertNotLocal(opts.targetUrl, {
|
|
285
292
|
field: 'url',
|
|
286
293
|
helpCommand: 'testsprite project update',
|
|
@@ -307,7 +314,7 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
307
314
|
'--instruction, --test-id-attributes, or --clear-test-id-attributes.');
|
|
308
315
|
}
|
|
309
316
|
if (opts.dryRun) {
|
|
310
|
-
//
|
|
317
|
+
// Emit the banner here (this path returns before makeClient() does).
|
|
311
318
|
emitDryRunBanner(stderr);
|
|
312
319
|
const idempotencyKey = opts.idempotencyKey ?? `cli-proj-update-${randomUUID()}`;
|
|
313
320
|
if (opts.idempotencyKey === undefined &&
|
|
@@ -550,7 +557,7 @@ function renderAutoAuthText(r) {
|
|
|
550
557
|
return lines.join('\n');
|
|
551
558
|
}
|
|
552
559
|
// ---------------------------------------------------------------------------
|
|
553
|
-
// project docs upload
|
|
560
|
+
// project docs upload
|
|
554
561
|
// ---------------------------------------------------------------------------
|
|
555
562
|
/**
|
|
556
563
|
* CLI-facing role flags → wire enum. Default is `api-doc` (stated in help);
|
|
@@ -578,7 +585,7 @@ const DEFAULT_DOC_CONTENT_TYPE = 'application/octet-stream';
|
|
|
578
585
|
* source so plan generation has inputs to feed on (closes the API-project
|
|
579
586
|
* cold start at `no_processed_inputs`).
|
|
580
587
|
*
|
|
581
|
-
* Three-step flow against the
|
|
588
|
+
* Three-step flow against the docs facade routes:
|
|
582
589
|
*
|
|
583
590
|
* 1. `POST /projects/{id}/docs/upload-url` — mints a one-hour presigned
|
|
584
591
|
* S3 PUT URL plus the S3 key to register afterwards.
|
|
@@ -683,17 +690,17 @@ export async function runDocsUpload(opts, deps = {}) {
|
|
|
683
690
|
// transfer-encoding on presigned PUTs, and Node's fetch uses the explicit
|
|
684
691
|
// header to keep identity framing with a streamed body.
|
|
685
692
|
const fetchImpl = deps.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
686
|
-
//
|
|
693
|
+
// A remote facade must mint a non-local https URL.
|
|
687
694
|
assertSafePresignedUploadUrl(minted.uploadUrl, client.resolvedBaseUrl);
|
|
688
695
|
// Same flag > TESTSPRITE_REQUEST_TIMEOUT_MS > default resolution (and 1-600s
|
|
689
696
|
// clamp) as makeHttpClient — this leg bypasses HttpClient, so resolve here.
|
|
690
697
|
const requestTimeoutMs = resolveRequestTimeoutMs(opts, deps.env ?? process.env);
|
|
691
698
|
const controller = new AbortController();
|
|
692
699
|
const timer = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
693
|
-
//
|
|
694
|
-
//
|
|
695
|
-
//
|
|
696
|
-
//
|
|
700
|
+
// Compose the shutdown signal into the PUT abort (manual listeners, house
|
|
701
|
+
// style — no AbortSignal.any) and arm the graceful scope for the upload's
|
|
702
|
+
// duration, so Ctrl-C during a long PUT takes the honest detach path
|
|
703
|
+
// instead of being unabortable.
|
|
697
704
|
const shutdown = deps.shutdown ?? globalShutdown;
|
|
698
705
|
const shutdownSignal = shutdown.signal;
|
|
699
706
|
const onShutdownAbort = () => controller.abort(shutdownSignal.reason);
|
|
@@ -709,7 +716,7 @@ export async function runDocsUpload(opts, deps = {}) {
|
|
|
709
716
|
headers: { 'content-type': contentType, 'content-length': String(stat.size) },
|
|
710
717
|
body: Readable.toWeb(createReadStream(opts.file)),
|
|
711
718
|
duplex: 'half',
|
|
712
|
-
//
|
|
719
|
+
// assertSafePresignedUploadUrl vets the MINTED url, but a
|
|
713
720
|
// default `redirect: 'follow'` would let a 3xx from that host resend
|
|
714
721
|
// the request to an unvetted Location (e.g. a 303 → 169.254.169.254) —
|
|
715
722
|
// an SSRF-shaped hop the guard never sees. A real S3 presigned PUT never
|
|
@@ -753,10 +760,10 @@ export async function runDocsUpload(opts, deps = {}) {
|
|
|
753
760
|
catch (cause) {
|
|
754
761
|
if (cause instanceof ApiError)
|
|
755
762
|
throw registerStepError(cause);
|
|
756
|
-
//
|
|
757
|
-
//
|
|
758
|
-
//
|
|
759
|
-
//
|
|
763
|
+
// A register timeout needs the same step-3 context — it is precisely the
|
|
764
|
+
// case where the caller can't tell whether the register landed. Class and
|
|
765
|
+
// exit 7 are preserved; only the text gains the upload-succeeded /
|
|
766
|
+
// safe-to-re-run explanation.
|
|
760
767
|
if (cause instanceof RequestTimeoutError) {
|
|
761
768
|
cause.message =
|
|
762
769
|
`Document register timed out (step 3 of 3) — the S3 upload succeeded, and the ` +
|
|
@@ -789,7 +796,7 @@ function describeCause(cause) {
|
|
|
789
796
|
return `${cause.message}${nestedMsg}`;
|
|
790
797
|
}
|
|
791
798
|
/**
|
|
792
|
-
*
|
|
799
|
+
* Defense-in-depth on the server-minted presigned URL.
|
|
793
800
|
*
|
|
794
801
|
* A REMOTE facade must mint a non-local `https:` URL; a localhost/private or
|
|
795
802
|
* plain-http mint from a remote facade is exactly the anomaly to reject
|
|
@@ -797,18 +804,17 @@ function describeCause(cause) {
|
|
|
797
804
|
* otherwise send the user's file wherever that URL points, before any bytes
|
|
798
805
|
* leave the machine. A facade that is ITSELF loopback (dev rig, localhost
|
|
799
806
|
* e2e) is a deliberate operator configuration and is trusted to mint local
|
|
800
|
-
* URLs — and ONLY loopback qualifies
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
* allow-listing by design.
|
|
807
|
+
* URLs — and ONLY loopback qualifies: the gate is a positive, fail-closed
|
|
808
|
+
* check, because gating on "anything `assertNotLocal` dislikes" would
|
|
809
|
+
* silently disable the guard for an unparsable base URL or a user-settable
|
|
810
|
+
* private-range endpoint (`--endpoint-url https://10.1.2.3`). Literal checks
|
|
811
|
+
* only (same scope as `assertNotLocal`); no host allow-listing by design.
|
|
806
812
|
*
|
|
807
|
-
* Known residual
|
|
808
|
-
*
|
|
809
|
-
*
|
|
810
|
-
*
|
|
811
|
-
*
|
|
813
|
+
* Known residual: a loopback facade that is really a TUNNEL to a remote
|
|
814
|
+
* backend (`ssh -L`, a localhost corporate proxy) is trusted here even though
|
|
815
|
+
* the real conversation is remote and MITM-able upstream. This is inherent to
|
|
816
|
+
* "loopback facade = trusted dev rig" and accepted — the CLI cannot tell a
|
|
817
|
+
* dev rig from a tunnel by the base URL alone.
|
|
812
818
|
*/
|
|
813
819
|
function assertSafePresignedUploadUrl(uploadUrl, facadeBaseUrl) {
|
|
814
820
|
if (isLoopbackFacade(facadeBaseUrl))
|
|
@@ -854,7 +860,7 @@ function isLocalUrl(url) {
|
|
|
854
860
|
}
|
|
855
861
|
}
|
|
856
862
|
/**
|
|
857
|
-
*
|
|
863
|
+
* The facade-trust gate for `assertSafePresignedUploadUrl`.
|
|
858
864
|
* Positive and narrow — only an explicitly-loopback facade (`localhost`,
|
|
859
865
|
* a `127.0.0.0/8` literal, or `[::1]`) is trusted to mint local upload URLs.
|
|
860
866
|
* Anything else — including an unparsable base URL or a private-range
|
|
@@ -951,7 +957,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
951
957
|
// raises a typed `ApiError(VALIDATION_ERROR)` and surfaces with
|
|
952
958
|
// the contract-mandated exit code 5.
|
|
953
959
|
await runList({
|
|
954
|
-
...resolveCommonOptions(command),
|
|
960
|
+
...resolveCommonOptions(command, deps.env),
|
|
955
961
|
pageSize: parseFlag(cmdOpts.pageSize, 'page-size'),
|
|
956
962
|
startingToken: cmdOpts.startingToken,
|
|
957
963
|
maxItems: parseFlag(cmdOpts.maxItems, 'max-items'),
|
|
@@ -964,17 +970,17 @@ export function createProjectCommand(deps = {}) {
|
|
|
964
970
|
.description('Get a project by id')
|
|
965
971
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
966
972
|
.action(async (projectId, _cmdOpts, command) => {
|
|
967
|
-
await runGet({ ...resolveCommonOptions(command), projectId }, deps);
|
|
973
|
+
await runGet({ ...resolveCommonOptions(command, deps.env), projectId }, deps);
|
|
968
974
|
});
|
|
969
975
|
project
|
|
970
976
|
.command('create')
|
|
971
977
|
.description('Create a new project')
|
|
972
978
|
.option('--type <frontend|backend>', 'project type (required)')
|
|
973
979
|
.option('--name <name>', 'project name (required)')
|
|
974
|
-
.option('--url <url>', 'target URL (required for frontend unless --local is used; also required for backend on the V3 execution ' +
|
|
980
|
+
.option('--url <url>', 'target URL (public http/https or a loopback http origin with an explicit port; required for frontend unless --local is used; also required for backend on the V3 execution ' +
|
|
975
981
|
'path — see `auth status` for your routing)')
|
|
976
|
-
.option('--local <port>', '
|
|
977
|
-
.
|
|
982
|
+
.option('--local <port>', 'shorthand for --url http://localhost:<port> (1-65535; excludes --url; runs open a tunnel automatically)')
|
|
983
|
+
.addOption(new Option('--local-host <host>', 'deprecated loopback host override; requires --local').hideHelp())
|
|
978
984
|
.option('--skip-preflight', 'skip the local TCP listener check before project creation')
|
|
979
985
|
.option('--description <text>', 'not supported — projects have no description (test-level descriptions are set on `test create`)')
|
|
980
986
|
.option('--username <user>', 'optional auth username')
|
|
@@ -995,7 +1001,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
995
1001
|
throw localValidationError('--type must be frontend or backend');
|
|
996
1002
|
}
|
|
997
1003
|
await runCreate({
|
|
998
|
-
...resolveCommonOptions(command),
|
|
1004
|
+
...resolveCommonOptions(command, deps.env),
|
|
999
1005
|
type,
|
|
1000
1006
|
name: cmdOpts.name,
|
|
1001
1007
|
targetUrl: cmdOpts.url,
|
|
@@ -1017,9 +1023,9 @@ export function createProjectCommand(deps = {}) {
|
|
|
1017
1023
|
.command('update <project-id>')
|
|
1018
1024
|
.description('Update project metadata')
|
|
1019
1025
|
.option('--name <name>', 'new project name')
|
|
1020
|
-
.option('--url <url>', 'new target URL (public
|
|
1021
|
-
.option('--local <port>', '
|
|
1022
|
-
.
|
|
1026
|
+
.option('--url <url>', 'new target URL (public http/https, or a loopback http origin with an explicit port)')
|
|
1027
|
+
.option('--local <port>', 'shorthand for --url http://localhost:<port> (1-65535; excludes --url; frontend only)')
|
|
1028
|
+
.addOption(new Option('--local-host <host>', 'deprecated loopback host override; requires --local').hideHelp())
|
|
1023
1029
|
.option('--skip-preflight', 'skip the local TCP listener check before the update')
|
|
1024
1030
|
.option('--username <user>', 'new auth username')
|
|
1025
1031
|
.option('--password <pw>', 'new auth password')
|
|
@@ -1032,7 +1038,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1032
1038
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
1033
1039
|
.action(async (projectId, cmdOpts, command) => {
|
|
1034
1040
|
await runUpdate({
|
|
1035
|
-
...resolveCommonOptions(command),
|
|
1041
|
+
...resolveCommonOptions(command, deps.env),
|
|
1036
1042
|
projectId,
|
|
1037
1043
|
name: cmdOpts.name,
|
|
1038
1044
|
targetUrl: cmdOpts.url,
|
|
@@ -1064,7 +1070,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1064
1070
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
1065
1071
|
.action(async (projectId, cmdOpts, command) => {
|
|
1066
1072
|
await runDelete({
|
|
1067
|
-
...resolveCommonOptions(command),
|
|
1073
|
+
...resolveCommonOptions(command, deps.env),
|
|
1068
1074
|
projectId,
|
|
1069
1075
|
confirm: cmdOpts.confirm === true,
|
|
1070
1076
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
@@ -1081,7 +1087,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1081
1087
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
1082
1088
|
.action(async (projectId, cmdOpts, command) => {
|
|
1083
1089
|
await runCredential({
|
|
1084
|
-
...resolveCommonOptions(command),
|
|
1090
|
+
...resolveCommonOptions(command, deps.env),
|
|
1085
1091
|
projectId,
|
|
1086
1092
|
authType: cmdOpts.type,
|
|
1087
1093
|
credential: cmdOpts.credential,
|
|
@@ -1120,7 +1126,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1120
1126
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
1121
1127
|
.action(async (projectId, cmdOpts, command) => {
|
|
1122
1128
|
await runAutoAuth({
|
|
1123
|
-
...resolveCommonOptions(command),
|
|
1129
|
+
...resolveCommonOptions(command, deps.env),
|
|
1124
1130
|
projectId,
|
|
1125
1131
|
disable: cmdOpts.disable,
|
|
1126
1132
|
method: cmdOpts.method,
|
|
@@ -1148,7 +1154,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1148
1154
|
const docs = new Command('docs').description('Manage project documents — the sources plan generation feeds on');
|
|
1149
1155
|
docs
|
|
1150
1156
|
.command('upload <file>')
|
|
1151
|
-
.description('Upload an API spec or PRD as a project source
|
|
1157
|
+
.description('Upload an API spec or PRD as a project source. Three steps:\n' +
|
|
1152
1158
|
'mint a presigned S3 URL, stream the file bytes to it, register the\n' +
|
|
1153
1159
|
'document — which starts processing + embedding. The local file is\n' +
|
|
1154
1160
|
'only read; nothing is written back to disk.\n' +
|
|
@@ -1166,7 +1172,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
1166
1172
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
1167
1173
|
.action(async (file, cmdOpts, command) => {
|
|
1168
1174
|
await runDocsUpload({
|
|
1169
|
-
...resolveCommonOptions(command),
|
|
1175
|
+
...resolveCommonOptions(command, deps.env),
|
|
1170
1176
|
file,
|
|
1171
1177
|
projectId: cmdOpts.project,
|
|
1172
1178
|
role: cmdOpts.role,
|
|
@@ -1175,9 +1181,10 @@ export function createProjectCommand(deps = {}) {
|
|
|
1175
1181
|
}, deps);
|
|
1176
1182
|
});
|
|
1177
1183
|
project.addCommand(docs);
|
|
1178
|
-
//
|
|
1179
|
-
//
|
|
1184
|
+
// `project env <verb>` — the per-project environment surface (credentials,
|
|
1185
|
+
// URL, default). Own module; `deps` threaded so tests inject.
|
|
1180
1186
|
project.addCommand(createProjectEnvCommand(deps));
|
|
1187
|
+
project.addCommand(createProjectSignInCommand(deps));
|
|
1181
1188
|
return project;
|
|
1182
1189
|
}
|
|
1183
1190
|
function parseFlag(raw, flagName) {
|
|
@@ -1197,11 +1204,11 @@ function parseFlag(raw, flagName) {
|
|
|
1197
1204
|
}
|
|
1198
1205
|
return n;
|
|
1199
1206
|
}
|
|
1200
|
-
function resolveCommonOptions(command) {
|
|
1207
|
+
function resolveCommonOptions(command, env) {
|
|
1201
1208
|
const globals = command.optsWithGlobals();
|
|
1202
1209
|
// P2-8: validate --output before allowing silent fallback to 'text'.
|
|
1203
1210
|
return {
|
|
1204
|
-
profile: globals.profile
|
|
1211
|
+
profile: resolveProfileName(globals.profile, env),
|
|
1205
1212
|
output: resolveOutputMode(globals.output),
|
|
1206
1213
|
endpointUrl: globals.endpointUrl,
|
|
1207
1214
|
debug: globals.debug ?? false,
|
|
@@ -1252,7 +1259,21 @@ const PROJECT_LIST_COLUMNS = [
|
|
|
1252
1259
|
width: rows => Math.max(3, ...rows.map(project => renderProjectUrl(project).length)),
|
|
1253
1260
|
render: renderProjectUrl,
|
|
1254
1261
|
},
|
|
1255
|
-
{
|
|
1262
|
+
{
|
|
1263
|
+
header: 'CREATED',
|
|
1264
|
+
width: rows => Math.max(7, ...rows.map(project => project.createdAt.length)),
|
|
1265
|
+
render: project => project.createdAt,
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
header: 'DEFAULT ENV',
|
|
1269
|
+
width: rows => Math.max(11, ...rows.map(project => (project.defaultEnvironment ?? '-').length)),
|
|
1270
|
+
render: project => project.defaultEnvironment ?? '-',
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
header: 'ENVS',
|
|
1274
|
+
width: 4,
|
|
1275
|
+
render: project => project.environmentCount?.toString() ?? '-',
|
|
1276
|
+
},
|
|
1256
1277
|
];
|
|
1257
1278
|
function renderProjectUrl(project) {
|
|
1258
1279
|
const url = project.targetUrl ?? '';
|
|
@@ -1300,6 +1321,13 @@ function renderProjectText(p) {
|
|
|
1300
1321
|
if (p.orgId !== undefined) {
|
|
1301
1322
|
lines.push(`org: ${p.orgName ?? '(name unknown)'} (${p.orgId})`);
|
|
1302
1323
|
}
|
|
1324
|
+
if ('defaultEnvironment' in p) {
|
|
1325
|
+
lines.push(`defaultEnv: ${p.defaultEnvironment ?? '-'}`);
|
|
1326
|
+
}
|
|
1327
|
+
if ('environmentCount' in p) {
|
|
1328
|
+
const count = p.environmentCount;
|
|
1329
|
+
lines.push(`envs: ${count}${count !== undefined && count > 0 ? ` (list with: testsprite project env list ${p.id})` : ''}`);
|
|
1330
|
+
}
|
|
1303
1331
|
// Presence, not truthiness — see the `targetUrl` docstring on `CliProject`.
|
|
1304
1332
|
// `'targetUrl' in p` distinguishes "the backend answered 'no URL'" (render the
|
|
1305
1333
|
// hint) from "this endpoint doesn't report it" (say nothing).
|
|
@@ -1338,8 +1366,7 @@ function renderCreateProjectText(p, localTarget) {
|
|
|
1338
1366
|
if (localTarget) {
|
|
1339
1367
|
const projectId = resolveCreatedProjectId(p) ?? '<project-id>';
|
|
1340
1368
|
const url = buildLocalTargetUrl(localTarget.host, localTarget.port);
|
|
1341
|
-
|
|
1342
|
-
lines.push(`Local project: TestSprite will reach ${url} only through a tunnel from this machine.`, 'Next: write a plan and run it locally:', ` In plan.json, set projectId to ${projectId}.`, ` testsprite test create --project ${projectId} --plan-from plan.json`, ` testsprite test run <test-id> --local ${localTarget.port}${hostFlag}`, `Portal runs of this project stay blocked (free) until you set a public URL with: testsprite project update ${projectId} --url https://...`);
|
|
1369
|
+
lines.push(`Local project: TestSprite will reach ${url} only through a tunnel from this machine.`, 'Next: write a plan and run it locally:', ` In plan.json, set projectId to ${projectId}.`, ` testsprite test create --project ${projectId} --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://...`);
|
|
1343
1370
|
}
|
|
1344
1371
|
return lines.join('\n');
|
|
1345
1372
|
}
|
|
@@ -1350,10 +1377,23 @@ function renderUpdateText(r, localTarget) {
|
|
|
1350
1377
|
];
|
|
1351
1378
|
if (r.updatedAt !== undefined)
|
|
1352
1379
|
lines.push(`updatedAt: ${r.updatedAt}`);
|
|
1380
|
+
if (r.environment !== undefined) {
|
|
1381
|
+
lines.push(`environment: ${r.environment.name} (default)`);
|
|
1382
|
+
const labels = {
|
|
1383
|
+
'environment.url': 'Environment URL updated',
|
|
1384
|
+
'environment.credentials': 'Environment credentials updated',
|
|
1385
|
+
'project.name': 'Project name updated',
|
|
1386
|
+
'project.instruction': 'Project instruction updated',
|
|
1387
|
+
'project.testIdAttributes': 'Project test ID attributes updated',
|
|
1388
|
+
};
|
|
1389
|
+
for (const effect of r.effects ?? []) {
|
|
1390
|
+
if (labels[effect])
|
|
1391
|
+
lines.push(`effect: ${labels[effect]}`);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1353
1394
|
if (localTarget) {
|
|
1354
1395
|
const url = buildLocalTargetUrl(localTarget.host, localTarget.port);
|
|
1355
|
-
|
|
1356
|
-
lines.push(`Local project: TestSprite will reach ${url} only through a tunnel from this machine.`, `Run its tests with: testsprite test run <test-id> --local ${localTarget.port}${hostFlag}`);
|
|
1396
|
+
lines.push(`Local project: TestSprite will reach ${url} only through a tunnel from this machine.`, 'Run its tests with: testsprite test run <test-id> (the CLI opens a tunnel automatically).');
|
|
1357
1397
|
}
|
|
1358
1398
|
return lines.join('\n');
|
|
1359
1399
|
}
|
|
@@ -1363,7 +1403,7 @@ function renderDeleteText(r) {
|
|
|
1363
1403
|
/**
|
|
1364
1404
|
* `--project` resolution for `project docs upload` — mirrors test.ts's
|
|
1365
1405
|
* resolveProjectId/requireProjectId so `TESTSPRITE_PROJECT_ID` works here the
|
|
1366
|
-
* same as on every other command
|
|
1406
|
+
* same as on every other command. Flag wins over env.
|
|
1367
1407
|
*/
|
|
1368
1408
|
function requireDocsProjectId(projectId, deps) {
|
|
1369
1409
|
const explicit = projectId?.trim();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
3
3
|
import type { FetchImpl } from '../lib/http.js';
|
|
4
|
+
import { type HistoryRetentionMeta } from '../lib/history-retention.js';
|
|
4
5
|
/** A schedule as returned by the API. */
|
|
5
6
|
export interface CliSchedule {
|
|
6
7
|
scheduleId: string;
|
|
@@ -9,6 +10,8 @@ export interface CliSchedule {
|
|
|
9
10
|
targetType: 'project' | 'testList';
|
|
10
11
|
/** Project id when `targetType` is `project`, else the test-list id. */
|
|
11
12
|
targetId: string | null;
|
|
13
|
+
environment?: string | null;
|
|
14
|
+
environmentMode?: 'inherit' | 'pinned' | null;
|
|
12
15
|
cron: string | null;
|
|
13
16
|
timezone: string | null;
|
|
14
17
|
startAt: string | null;
|
|
@@ -45,6 +48,7 @@ export interface CreateOptions extends CommonOptions {
|
|
|
45
48
|
name?: string;
|
|
46
49
|
targetType?: string;
|
|
47
50
|
targetId?: string;
|
|
51
|
+
env?: string;
|
|
48
52
|
cron?: string;
|
|
49
53
|
timezone?: string;
|
|
50
54
|
start?: string;
|
|
@@ -63,10 +67,19 @@ export interface CliCreateScheduleResponse {
|
|
|
63
67
|
* this side knows how often the cron fires; neither knows both.
|
|
64
68
|
*/
|
|
65
69
|
estimatedCreditsPerRun?: number | null;
|
|
70
|
+
/**
|
|
71
|
+
* Echoed back by a server that understands schedule environments — absent
|
|
72
|
+
* entirely on one that doesn't. That absence (not a falsy value) is what
|
|
73
|
+
* `runCreate` uses to detect an old server and refuse instead of confirming
|
|
74
|
+
* a pin that was never applied.
|
|
75
|
+
*/
|
|
76
|
+
environment?: string | null;
|
|
77
|
+
environmentMode?: 'inherit' | 'pinned' | null;
|
|
66
78
|
}
|
|
67
79
|
export interface UpdateOptions extends CommonOptions {
|
|
68
80
|
scheduleId: string;
|
|
69
81
|
name?: string;
|
|
82
|
+
env?: string;
|
|
70
83
|
cron?: string;
|
|
71
84
|
timezone?: string;
|
|
72
85
|
start?: string;
|
|
@@ -109,6 +122,7 @@ export interface CliScheduleRun {
|
|
|
109
122
|
/** `GET /schedules/{id}/runs` response. Not paginated. */
|
|
110
123
|
interface ScheduleRunListResponse {
|
|
111
124
|
runs: CliScheduleRun[];
|
|
125
|
+
meta?: HistoryRetentionMeta;
|
|
112
126
|
}
|
|
113
127
|
export declare function runList(opts: ListOptions, deps?: ScheduleDeps): Promise<ScheduleListResponse>;
|
|
114
128
|
export declare function runGet(opts: GetOptions, deps?: ScheduleDeps): Promise<CliSchedule>;
|