@testsprite/testsprite-cli 0.10.0 → 0.12.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 +65 -41
- package/dist/commands/auth.d.ts +5 -1
- package/dist/commands/auth.js +17 -5
- package/dist/commands/ci.js +34 -4
- package/dist/commands/init.d.ts +6 -1
- package/dist/commands/init.js +13 -5
- package/dist/commands/project-env.d.ts +90 -0
- package/dist/commands/project-env.js +486 -0
- package/dist/commands/project.d.ts +19 -0
- package/dist/commands/project.js +92 -25
- package/dist/commands/test.d.ts +42 -4
- package/dist/commands/test.js +344 -49
- package/dist/commands/testlist.js +29 -3
- package/dist/commands/tunnel.d.ts +2 -2
- package/dist/commands/tunnel.js +139 -31
- package/dist/index.js +42 -14
- package/dist/lib/client-factory.d.ts +4 -1
- package/dist/lib/client-factory.js +14 -4
- package/dist/lib/client-tag.d.ts +13 -0
- package/dist/lib/client-tag.js +44 -0
- package/dist/lib/conflict-reason.d.ts +43 -2
- package/dist/lib/conflict-reason.js +100 -14
- package/dist/lib/credentials.d.ts +4 -0
- package/dist/lib/credentials.js +43 -4
- package/dist/lib/cron.js +8 -1
- package/dist/lib/errors.d.ts +44 -1
- package/dist/lib/errors.js +69 -12
- package/dist/lib/gh-output.d.ts +25 -11
- package/dist/lib/gh-output.js +36 -13
- package/dist/lib/http.d.ts +21 -2
- package/dist/lib/http.js +45 -8
- package/dist/lib/local-target.d.ts +32 -0
- package/dist/lib/local-target.js +77 -0
- package/dist/lib/output.d.ts +27 -1
- package/dist/lib/output.js +22 -3
- package/dist/lib/response-schemas.d.ts +5 -2
- package/dist/lib/response-schemas.js +39 -1
- package/dist/lib/runs.types.d.ts +50 -2
- package/dist/lib/target-url.d.ts +1 -1
- package/dist/lib/target-url.js +35 -12
- package/dist/lib/telemetry.d.ts +174 -4
- package/dist/lib/telemetry.js +286 -13
- package/dist/lib/tunnel-session.d.ts +13 -2
- package/dist/lib/tunnel-session.js +92 -23
- package/dist/lib/tunnel.types.d.ts +3 -1
- package/dist/lib/version-notice.d.ts +20 -1
- package/dist/lib/version-notice.js +59 -12
- package/dist/vendor/tunnel-client/client.d.ts +11 -0
- package/dist/vendor/tunnel-client/client.js +383 -56
- package/dist/vendor/tunnel-client/config.d.ts +11 -3
- package/dist/vendor/tunnel-client/config.js +11 -3
- package/dist/vendor/tunnel-client/types.d.ts +26 -1
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +3 -2
- package/dist/vendor/tunnel-client/ws-compat.js +3 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/skills/testsprite-onboard.skill.md +74 -59
- package/skills/testsprite-verify.codex.md +82 -97
- package/skills/testsprite-verify.skill.md +64 -15
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ Get this exact skeleton without hand-copying it (and without the risk of it drif
|
|
|
116
116
|
|
|
117
117
|
> The `$schema` URL above is pinned to the CLI version that generated this doc (`v0.4.0`) — `--plan-template`'s live output always pins to **your installed version** instead, which is what actually resolves. If you're reading this on a later release, run the command yourself rather than trusting this snippet verbatim.
|
|
118
118
|
|
|
119
|
-
**Don't want to write the first tests yourself?**
|
|
119
|
+
**Don't want to write the first tests yourself?** For a deployed target, ask TestSprite to propose them. Local projects use the authored-plan flow below. `testsprite test plan generate --project <id>` explores your app (or reads the API spec you uploaded with `project docs upload`), drafts test cases, and stages them for review — nothing is written to your disk. You read the printed table and keep what you want:
|
|
120
120
|
|
|
121
121
|
```bash
|
|
122
122
|
testsprite test plan generate --project proj_8f0f6 # stages proposals for review
|
|
@@ -128,48 +128,72 @@ It only runs what the project is still missing, so a second call picks up where
|
|
|
128
128
|
|
|
129
129
|
Prefer to configure each step by hand (or learn the surface offline with `--dry-run` first)? See [Manual setup](./DOCUMENTATION.md#manual-setup) and [Install & verify](./DOCUMENTATION.md#install--verify).
|
|
130
130
|
|
|
131
|
+
## Testing an app on your machine (--local)
|
|
132
|
+
|
|
133
|
+
Frontend tests can reach your running app through a TestSprite tunnel, including on the Free plan (ordinary run credits apply).
|
|
134
|
+
Use an API key with `run:tunnel`: keys minted before that scope existed need to be replaced; the CLI names the missing scope.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
testsprite project create --type frontend --name "My local app" --local 3000
|
|
138
|
+
testsprite test create --plan-from ./checkout.plan.json --project <project-id>
|
|
139
|
+
testsprite test run <test-id> --local 3000 # per-run tunnel; waits up to 1200 seconds
|
|
140
|
+
# Or keep one tunnel open in terminal A (no port argument)
|
|
141
|
+
testsprite tunnel start --ttl 3600
|
|
142
|
+
# Terminal B: borrow the clientId printed above; keep terminal A running
|
|
143
|
+
testsprite test run <test-id> --local 3000 --tunnel-client <client-uuid>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Run one test per invocation; parallel invocations are fine (5 live tunnel bindings per user); `--all --local` is refused.
|
|
147
|
+
A second `tunnel start` or process using the same credential takes over, and the first exits **10**.
|
|
148
|
+
The examples use `127.0.0.1`. For another loopback listener, pass the same `--local-host localhost` or `--local-host ::1` to project creation and every follow-up run. The selected host is stored in the project URL (`::1` becomes `http://[::1]:<port>`); `project get/list` exposes `originMode: 'local'` in JSON and shows `(Local)` in text output.
|
|
149
|
+
The control plane is WebSocket over TLS (`wss://control.tun.testsprite.com/ws`). The data plane, which carries the tunnel secret and proxied traffic, uses TLS at `data.tun.testsprite.com:443` and verifies the certificate with Node's default trust store: its bundled Mozilla roots, plus certificates supplied through `NODE_EXTRA_CA_CERTS` and the system CAs when Node is started with `--use-system-ca`. Node 20 is supported without losing `NODE_EXTRA_CA_CERTS`. Verification cannot be disabled, and the CLI never falls back from TLS to plaintext. On a network that re-signs TLS, export your organisation's root CA to a PEM file and set `NODE_EXTRA_CA_CERTS=/path/to/ca.pem` before running `testsprite`. Plaintext connects and TLS handshakes each time out after 10 seconds. The first failed attempt starts a **60-second** retry episode; writing `TunnelHello` is not enough to reset it. The episode ends only after the first inbound tunnel stream or after the socket remains open for 5 seconds following the hello. A real deadline timer stays armed across retries and destroys an in-flight socket when it expires. After that, an owned `test run --local` run is cancelled and refunded and the command exits **10**; `tunnel start` exits **10**. If a self-hosted or older TestSprite server does not advertise a TLS endpoint, the CLI prints a one-time warning and uses legacy plaintext port **7400** under the same timeout and retry rules. `tunnel start` prints `transport: tls` or `transport: plaintext`.
|
|
150
|
+
An owned tunnel's timeout or Ctrl-C cancels the run by default. A borrowed run still detaches without cancellation on Ctrl-C/SIGTERM because its owner keeps the tunnel alive; if that owner disappears while the run is active, the borrower cancels its own run and reports `cancelled`, `already finished`, or `skipped`. A run cancelled before it finishes is refunded. `--no-cancel-on-interrupt` also skips this owner-gone cancellation. Keep the early `Run <runId>` receipt on stderr and read the reported run before re-running.
|
|
151
|
+
Local projects skip exploration/plan generation; author plans with `test create --plan-from`. Portal runs are blocked for free until you set a public project URL.
|
|
152
|
+
See [the full local-testing reference](./DOCUMENTATION.md#local-frontend-testing-and-tunnels) for flags, login, billing/refunds, timeouts, and retargeting.
|
|
153
|
+
|
|
131
154
|
## Commands
|
|
132
155
|
|
|
133
|
-
| Group | Command
|
|
134
|
-
| -------------- |
|
|
135
|
-
| **Setup** | `setup`
|
|
136
|
-
| | `doctor`
|
|
137
|
-
| **Auth** | `auth status`
|
|
138
|
-
| | `auth remove`
|
|
139
|
-
| | `usage` (alias `credits`)
|
|
140
|
-
| **Read** | `project list` / `project get`
|
|
141
|
-
| | `test list` / `test get`
|
|
142
|
-
| | `test code get`
|
|
143
|
-
| | `test steps`
|
|
144
|
-
| | `test result`
|
|
145
|
-
| | `test failure get`
|
|
146
|
-
| | `test failure summary`
|
|
147
|
-
| | `test diff`
|
|
148
|
-
| **Write** | `test scaffold` / `test lint`
|
|
149
|
-
| | `test create` / `test create-batch`
|
|
150
|
-
| | `test update` / `test delete` / `test delete-batch`
|
|
151
|
-
| | `test code put`
|
|
152
|
-
| | `test plan put`
|
|
153
|
-
| | `project create` / `project update` / `project delete`
|
|
154
|
-
| | `project credential` / `project auto-auth`
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
| | `
|
|
158
|
-
|
|
|
159
|
-
|
|
|
160
|
-
| | `test
|
|
161
|
-
| | `test
|
|
162
|
-
| | `test
|
|
163
|
-
| | `test
|
|
164
|
-
|
|
|
165
|
-
|
|
|
166
|
-
| | `testlist
|
|
167
|
-
|
|
|
168
|
-
|
|
|
169
|
-
| | `schedule
|
|
170
|
-
| | `schedule
|
|
171
|
-
| | `schedule
|
|
172
|
-
|
|
|
156
|
+
| Group | Command | What it does |
|
|
157
|
+
| -------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
158
|
+
| **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
|
|
159
|
+
| | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
|
|
160
|
+
| **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
|
|
161
|
+
| | `auth remove` | Remove the active profile from the credentials file |
|
|
162
|
+
| | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
|
|
163
|
+
| **Read** | `project list` / `project get` | List projects / fetch one by id |
|
|
164
|
+
| | `test list` / `test get` | List tests under a project / fetch one by id |
|
|
165
|
+
| | `test code get` | Print (or write) the generated test source |
|
|
166
|
+
| | `test steps` | List the latest run's steps with screenshot / DOM pointers |
|
|
167
|
+
| | `test result` | Latest result; `--history` lists a test's prior runs (ENV column; `--env <name>` filters by environment) |
|
|
168
|
+
| | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
|
|
169
|
+
| | `test failure summary` | One-screen triage card (no media download) |
|
|
170
|
+
| | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
|
|
171
|
+
| **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
|
|
172
|
+
| | `test create` / `test create-batch` | Create a test (or bulk-create from a plan file); `--step-timeout <ms>` sets a per-test timeout; dependency flags wire BE metadata |
|
|
173
|
+
| | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required) |
|
|
174
|
+
| | `test code put` | Replace generated code (etag-guarded) |
|
|
175
|
+
| | `test plan put` | Replace a frontend test's plan-steps |
|
|
176
|
+
| | `project create` / `project update` / `project delete` | Manage projects; `--test-id-attributes <list>` registers the app's own test-hook attributes (priority order) for exported locators, `--clear-test-id-attributes` reverts; `delete` removes a project and everything under it (`--confirm` required, no restore window) |
|
|
177
|
+
| | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
|
|
178
|
+
| | `project env list` / `create` / `update` / `delete` / `set-default` | Manage a project's environments — named URL + login bundles that `test run --env <name>` selects. An app on your own machine is named with `--local <port>` instead of `--url` — the same spelling as `project create` — and run with `test run --local <port>`; `delete` refuses the default environment |
|
|
179
|
+
| **Generate** | `test plan generate` | Ask TestSprite to propose test cases for a project — proposals are staged server-side for review, never written to disk; only the stages the project is missing actually run |
|
|
180
|
+
| | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only` |
|
|
181
|
+
| | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read |
|
|
182
|
+
| **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order `--env <name>` runs against a named environment. |
|
|
183
|
+
| | `test rerun` | Replay one/many tests (FE verbatim; BE with deps); billed as a run (0.5 credits FE / 0.2 BE); `--all --project <id>` reruns all tests `--env <name>` replays against a named environment. |
|
|
184
|
+
| | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
|
|
185
|
+
| | `test wait` | Block on one or more `runId`s until terminal |
|
|
186
|
+
| | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches, `cancel` is the real stop — except an owned `--local` run, which Ctrl-C cancels by default) |
|
|
187
|
+
| | `test artifact get` | Download the failure bundle for a specific `runId` |
|
|
188
|
+
| **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
|
|
189
|
+
| | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
|
|
190
|
+
| | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar |
|
|
191
|
+
| **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures) |
|
|
192
|
+
| | `schedule create` | Run a project or test list on a 5-field cron; states the frequency before sending and the per-run / monthly credit cost once priced |
|
|
193
|
+
| | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it |
|
|
194
|
+
| | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
|
|
195
|
+
| | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
|
|
196
|
+
| **Agent** | `agent install` / `agent list` / `agent status` | Add, list, or health-check coding-agent skills (pure-local): `claude`, `codex`, `cursor`, `cline`, `antigravity`, `kiro`, `windsurf`, `copilot` |
|
|
173
197
|
|
|
174
198
|
> The earlier command names — `init`, `auth configure`, `auth whoami`, `auth logout` — still work as hidden, deprecated aliases (each prints a one-line notice pointing at the new name), so existing scripts keep running. `auth configure` now runs the full `setup` (it also installs the skill).
|
|
175
199
|
|
package/dist/commands/auth.d.ts
CHANGED
|
@@ -92,7 +92,11 @@ interface ConfigureOptions extends CommonOptions {
|
|
|
92
92
|
*/
|
|
93
93
|
skipIfConfigured?: boolean;
|
|
94
94
|
}
|
|
95
|
-
export
|
|
95
|
+
export interface ConfigureResult {
|
|
96
|
+
persisted: boolean;
|
|
97
|
+
source: 'env' | 'prompt' | 'profile' | 'dry-run';
|
|
98
|
+
}
|
|
99
|
+
export declare function runConfigure(opts: ConfigureOptions, deps?: AuthDeps): Promise<ConfigureResult>;
|
|
96
100
|
export declare function runWhoami(opts: CommonOptions, deps?: AuthDeps): Promise<MeResponse>;
|
|
97
101
|
export declare function runLogout(opts: CommonOptions, deps?: AuthDeps): Promise<void>;
|
|
98
102
|
export declare function createAuthCommand(deps?: AuthDeps): Command;
|
package/dist/commands/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ import { assertValidApiKey, assertValidEndpointUrl, emitDryRunBanner, makeHttpCl
|
|
|
3
3
|
import { ApiError, CLIError } from '../lib/errors.js';
|
|
4
4
|
import { facadeBaseUrl } from '../lib/facade.js';
|
|
5
5
|
import { HttpClient } from '../lib/http.js';
|
|
6
|
-
import { defaultCredentialsPath, deleteProfile, readProfile, writeProfile, } from '../lib/credentials.js';
|
|
6
|
+
import { defaultCredentialsPath, deleteProfile, isCredentialsWritePermissionError, readProfile, writeProfile, } from '../lib/credentials.js';
|
|
7
7
|
import { loadConfig, normalizeEnvVar } from '../lib/config.js';
|
|
8
8
|
import { emitDeprecationNotice } from '../lib/deprecate.js';
|
|
9
9
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
@@ -38,7 +38,7 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
38
38
|
const d = data;
|
|
39
39
|
return `Profile "${d.profile}" configured (dry-run). Endpoint: ${d.apiUrl}`;
|
|
40
40
|
});
|
|
41
|
-
return;
|
|
41
|
+
return { persisted: false, source: 'dry-run' };
|
|
42
42
|
}
|
|
43
43
|
let apiKey;
|
|
44
44
|
// Read the existing profile once — used for apiUrl inheritance in both
|
|
@@ -73,7 +73,7 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
73
73
|
const d = data;
|
|
74
74
|
return `Profile "${d.profile}" already configured. Endpoint: ${d.apiUrl}`;
|
|
75
75
|
});
|
|
76
|
-
return;
|
|
76
|
+
return { persisted: true, source: 'profile' };
|
|
77
77
|
}
|
|
78
78
|
const promptApi = deps.prompt ?? { secret: (q) => promptSecret(q) };
|
|
79
79
|
prelude(`Configuring profile "${opts.profile}".\n`);
|
|
@@ -129,15 +129,27 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
129
129
|
// misconfigured fetchImpl). Exit 3 (auth family).
|
|
130
130
|
throw new CLIError(`API key rejected by ${apiUrl}: ${message} — did you mean to set TESTSPRITE_API_URL?`, 3);
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
let persisted = true;
|
|
133
|
+
try {
|
|
134
|
+
writeProfile(opts.profile, { apiKey, apiUrl }, { path: credentialsPath });
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (!opts.fromEnv || !isCredentialsWritePermissionError(error))
|
|
138
|
+
throw error;
|
|
139
|
+
persisted = false;
|
|
140
|
+
stderr(`Using TESTSPRITE_API_KEY for this session; credentials could not be saved to ${credentialsPath} (${error.code}). Set TESTSPRITE_API_KEY in every shell that runs testsprite.`);
|
|
141
|
+
}
|
|
133
142
|
out.print({ profile: opts.profile, apiUrl, status: 'configured' }, data => {
|
|
134
143
|
const d = data;
|
|
135
|
-
return
|
|
144
|
+
return persisted
|
|
145
|
+
? `Profile "${d.profile}" configured. Endpoint: ${d.apiUrl}`
|
|
146
|
+
: `Profile "${d.profile}" configured for this session only (credentials not saved). Endpoint: ${d.apiUrl}`;
|
|
136
147
|
});
|
|
137
148
|
// Note: the old "run `testsprite agent install`" self-bootstrap tip was
|
|
138
149
|
// removed with the setup consolidation. `runConfigure` now only runs as part
|
|
139
150
|
// of `setup` (the sole credential-writing path), which installs the skill
|
|
140
151
|
// itself (unless --no-agent) — so the tip would be redundant or misleading.
|
|
152
|
+
return { persisted, source: opts.fromEnv ? 'env' : 'prompt' };
|
|
141
153
|
}
|
|
142
154
|
export async function runWhoami(opts, deps = {}) {
|
|
143
155
|
const out = makeOutput(opts.output, deps);
|
package/dist/commands/ci.js
CHANGED
|
@@ -7,6 +7,7 @@ import { CLIError, localValidationError } from '../lib/errors.js';
|
|
|
7
7
|
import { loadConfig } from '../lib/config.js';
|
|
8
8
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
9
9
|
import { assertNotLocal } from '../lib/target-url.js';
|
|
10
|
+
import { recordTelemetryExtras } from '../lib/telemetry.js';
|
|
10
11
|
import { VERSION } from '../version.js';
|
|
11
12
|
// ── constants ────────────────────────────────────────────────────────────────
|
|
12
13
|
/** Platforms `ci init` can scaffold. One today; the positional arg leaves room. */
|
|
@@ -259,16 +260,43 @@ function trySetSecret(opts, deps, cwd) {
|
|
|
259
260
|
}
|
|
260
261
|
// ── orchestrator ─────────────────────────────────────────────────────────────
|
|
261
262
|
export async function runCiInit(opts, deps = {}) {
|
|
263
|
+
if (!SUPPORTED_PLATFORMS.includes(opts.platform)) {
|
|
264
|
+
throw localValidationError('platform', `unsupported "${opts.platform}" — supported: ${SUPPORTED_PLATFORMS.join(', ')}`, undefined, 'field');
|
|
265
|
+
}
|
|
266
|
+
const platform = opts.platform;
|
|
267
|
+
// Telemetry facts for this invocation (see lib/telemetry.ts — low-cardinality
|
|
268
|
+
// only: never the path, the project id, or the filter). `workflowExisted` is
|
|
269
|
+
// learned only once the write is attempted, so it is filled in below and the
|
|
270
|
+
// whole set is recorded on every exit path, including a thrown error.
|
|
271
|
+
let workflowExisted;
|
|
272
|
+
try {
|
|
273
|
+
await runCiInitScaffold(opts, deps, platform, existed => {
|
|
274
|
+
workflowExisted = existed;
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
finally {
|
|
278
|
+
recordTelemetryExtras({
|
|
279
|
+
platform,
|
|
280
|
+
force: opts.force,
|
|
281
|
+
projectResolved: opts.project ? 'flag' : 'auto',
|
|
282
|
+
...(workflowExisted !== undefined ? { workflowExisted } : {}),
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The scaffold proper (everything after platform validation). Reports whether a
|
|
288
|
+
* workflow file already existed at the target path via `onExisted` the moment
|
|
289
|
+
* that is known — BEFORE the `--force` decision throws or overwrites. Under
|
|
290
|
+
* `--dry-run` it returns before the write is attempted, so `onExisted` is never
|
|
291
|
+
* called and the fact stays unknown.
|
|
292
|
+
*/
|
|
293
|
+
async function runCiInitScaffold(opts, deps, platform, onExisted) {
|
|
262
294
|
const stdout = deps.stdout ?? ((line) => process.stdout.write(`${line}\n`));
|
|
263
295
|
const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
264
296
|
const fs = deps.fs ?? defaultCiFs;
|
|
265
297
|
const spawn = deps.spawn ?? defaultSpawn;
|
|
266
298
|
const cwd = deps.cwd ?? process.cwd();
|
|
267
299
|
const out = new Output(opts.output, { stdout, stderr });
|
|
268
|
-
if (!SUPPORTED_PLATFORMS.includes(opts.platform)) {
|
|
269
|
-
throw localValidationError('platform', `unsupported "${opts.platform}" — supported: ${SUPPORTED_PLATFORMS.join(', ')}`, undefined, 'field');
|
|
270
|
-
}
|
|
271
|
-
const platform = opts.platform;
|
|
272
300
|
// Validate the caller's own inputs up front — BEFORE the project-list round
|
|
273
301
|
// trip — so a bad --filter/--project fails fast without a wasted request.
|
|
274
302
|
if (opts.filter)
|
|
@@ -336,6 +364,7 @@ export async function runCiInit(opts, deps = {}) {
|
|
|
336
364
|
let wrote = true;
|
|
337
365
|
try {
|
|
338
366
|
await fs.writeFile(absPath, workflow, { exclusive: true });
|
|
367
|
+
onExisted(false);
|
|
339
368
|
}
|
|
340
369
|
catch (err) {
|
|
341
370
|
const code = err.code;
|
|
@@ -344,6 +373,7 @@ export async function runCiInit(opts, deps = {}) {
|
|
|
344
373
|
}
|
|
345
374
|
if (code !== 'EEXIST')
|
|
346
375
|
throw err;
|
|
376
|
+
onExisted(true);
|
|
347
377
|
const prior = await fs.readFile(absPath);
|
|
348
378
|
if (prior === workflow) {
|
|
349
379
|
// Already exactly what we'd write — no rewrite, no `.bak` churn. This also
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { Command } from 'commander';
|
|
15
15
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
16
|
-
import type { AuthDeps } from './auth.js';
|
|
16
|
+
import type { AuthDeps, ConfigureResult } from './auth.js';
|
|
17
17
|
import type { AgentFs } from './agent.js';
|
|
18
18
|
import { type AgentTarget } from '../lib/agent-targets.js';
|
|
19
19
|
import { type AgentDetection, type DetectAgentDeps } from '../lib/agent-detect.js';
|
|
@@ -69,6 +69,11 @@ export interface InitSummary {
|
|
|
69
69
|
env: string;
|
|
70
70
|
email?: string;
|
|
71
71
|
scopes: string[];
|
|
72
|
+
/** Credential persistence outcome; omitted for a dry-run preview. */
|
|
73
|
+
credentials?: {
|
|
74
|
+
persisted: boolean;
|
|
75
|
+
source: ConfigureResult['source'] | 'flag';
|
|
76
|
+
};
|
|
72
77
|
/**
|
|
73
78
|
* Agent skill install outcome. `action` is an AGGREGATE across the installed
|
|
74
79
|
* skills (setup installs {@link DEFAULT_SKILLS}); `skills` lists which skills
|
package/dist/commands/init.js
CHANGED
|
@@ -332,7 +332,7 @@ export async function runInit(opts, deps = {}) {
|
|
|
332
332
|
// --api-key takes precedence over --from-env: when an explicit key is supplied,
|
|
333
333
|
// force fromEnv=false so runConfigure uses the injected key (toAuthDeps wires it
|
|
334
334
|
// as the prompt) instead of reading TESTSPRITE_API_KEY from the environment (codex).
|
|
335
|
-
await runConfigure({
|
|
335
|
+
const configured = await runConfigure({
|
|
336
336
|
...opts,
|
|
337
337
|
fromEnv: opts.apiKey ? false : opts.fromEnv,
|
|
338
338
|
// --api-key always overwrites; skip only applies when no explicit key source was given.
|
|
@@ -413,10 +413,11 @@ export async function runInit(opts, deps = {}) {
|
|
|
413
413
|
installedSkills = [...new Set(capturedInstallResults.flatMap(r => r.skills ?? []))];
|
|
414
414
|
}
|
|
415
415
|
catch (installErr) {
|
|
416
|
-
//
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
416
|
+
// Explain the credential outcome before re-throwing the install failure.
|
|
417
|
+
const credentialStatus = configured.persisted
|
|
418
|
+
? `credentials saved for profile "${opts.profile}"`
|
|
419
|
+
: 'credentials are session-only (TESTSPRITE_API_KEY; not saved)';
|
|
420
|
+
stderrFn(`[info] ${credentialStatus}; only the agent skill install failed — ` +
|
|
420
421
|
`re-run 'testsprite agent install --target ${resolution.targets.join(',')}' after fixing the path`);
|
|
421
422
|
throw installErr;
|
|
422
423
|
}
|
|
@@ -441,6 +442,10 @@ export async function runInit(opts, deps = {}) {
|
|
|
441
442
|
env: me.env,
|
|
442
443
|
email: me.email,
|
|
443
444
|
scopes: me.scopes,
|
|
445
|
+
credentials: {
|
|
446
|
+
persisted: configured.persisted,
|
|
447
|
+
source: opts.apiKey ? 'flag' : configured.source,
|
|
448
|
+
},
|
|
444
449
|
agent: agentSummary,
|
|
445
450
|
...(agentSummary === null && agentSkippedBy ? { agentSkippedBy } : {}),
|
|
446
451
|
status: 'initialized',
|
|
@@ -462,6 +467,9 @@ function renderInitText(data) {
|
|
|
462
467
|
lines.push(` email: ${s.email}`);
|
|
463
468
|
if (s.scopes.length > 0)
|
|
464
469
|
lines.push(` scopes: ${s.scopes.join(', ')}`);
|
|
470
|
+
if (s.credentials?.persisted === false) {
|
|
471
|
+
lines.push(' credentials: session-only (TESTSPRITE_API_KEY; not saved)');
|
|
472
|
+
}
|
|
465
473
|
lines.push('');
|
|
466
474
|
if (s.agent) {
|
|
467
475
|
const targets = s.agent.targets.length > 0 ? s.agent.targets : [s.agent.target];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { type CommonOptions } from '../lib/client-factory.js';
|
|
3
|
+
import type { ProjectDeps } from './project.js';
|
|
4
|
+
/** One environment row as the facade returns it. Never carries a password. */
|
|
5
|
+
export interface CliProjectEnvironment {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* The address runs against this environment open. May be a loopback URL for
|
|
10
|
+
* an app that only runs on your own machine — pair it with `--local`.
|
|
11
|
+
*/
|
|
12
|
+
url: string;
|
|
13
|
+
isDefault: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* How a run signs in: `account` (the stored test account), `otp` (a one-time
|
|
16
|
+
* code account), `manual` (a human-captured Google/SSO session, set up in the
|
|
17
|
+
* Portal) or `public` (no sign-in). Open string, rendered verbatim, so a mode
|
|
18
|
+
* added server-side shows up without a CLI release.
|
|
19
|
+
*/
|
|
20
|
+
authMode: string;
|
|
21
|
+
/** Whether a test-account username/password is stored. The password is never returned. */
|
|
22
|
+
hasCredentials: boolean;
|
|
23
|
+
/** The test-account username this environment signs in with; `null` when none is stored. */
|
|
24
|
+
username: string | null;
|
|
25
|
+
enableOtp: boolean;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CliProjectEnvListResponse {
|
|
29
|
+
environments: CliProjectEnvironment[];
|
|
30
|
+
}
|
|
31
|
+
export interface CliProjectEnvCreateResponse {
|
|
32
|
+
environment: CliProjectEnvironment;
|
|
33
|
+
created: true;
|
|
34
|
+
}
|
|
35
|
+
export interface CliProjectEnvUpdateResponse {
|
|
36
|
+
environment: CliProjectEnvironment;
|
|
37
|
+
}
|
|
38
|
+
export interface CliProjectEnvDeleteResponse {
|
|
39
|
+
deleted: true;
|
|
40
|
+
name: string;
|
|
41
|
+
}
|
|
42
|
+
interface EnvListOptions extends CommonOptions {
|
|
43
|
+
projectId: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function runEnvList(opts: EnvListOptions, deps?: ProjectDeps): Promise<CliProjectEnvListResponse>;
|
|
46
|
+
interface EnvCreateOptions extends CommonOptions {
|
|
47
|
+
projectId: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
url?: string;
|
|
50
|
+
/** `--local <port>`: an app on this machine; builds the loopback URL and sends the marker. */
|
|
51
|
+
local?: string;
|
|
52
|
+
localHost?: string;
|
|
53
|
+
skipPreflight?: boolean;
|
|
54
|
+
username?: string;
|
|
55
|
+
password?: string;
|
|
56
|
+
passwordFile?: string;
|
|
57
|
+
setDefault?: boolean;
|
|
58
|
+
idempotencyKey?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare function runEnvCreate(opts: EnvCreateOptions, deps?: ProjectDeps): Promise<CliProjectEnvCreateResponse>;
|
|
61
|
+
interface EnvUpdateOptions extends CommonOptions {
|
|
62
|
+
projectId: string;
|
|
63
|
+
name: string;
|
|
64
|
+
url?: string;
|
|
65
|
+
/** `--local <port>`: repoint at an app on this machine (see `runEnvCreate`). */
|
|
66
|
+
local?: string;
|
|
67
|
+
localHost?: string;
|
|
68
|
+
skipPreflight?: boolean;
|
|
69
|
+
username?: string;
|
|
70
|
+
password?: string;
|
|
71
|
+
passwordFile?: string;
|
|
72
|
+
rename?: string;
|
|
73
|
+
idempotencyKey?: string;
|
|
74
|
+
}
|
|
75
|
+
export declare function runEnvUpdate(opts: EnvUpdateOptions, deps?: ProjectDeps): Promise<CliProjectEnvUpdateResponse>;
|
|
76
|
+
interface EnvDeleteOptions extends CommonOptions {
|
|
77
|
+
projectId: string;
|
|
78
|
+
name: string;
|
|
79
|
+
confirm: boolean;
|
|
80
|
+
idempotencyKey?: string;
|
|
81
|
+
}
|
|
82
|
+
export declare function runEnvDelete(opts: EnvDeleteOptions, deps?: ProjectDeps): Promise<CliProjectEnvDeleteResponse>;
|
|
83
|
+
interface EnvSetDefaultOptions extends CommonOptions {
|
|
84
|
+
projectId: string;
|
|
85
|
+
name: string;
|
|
86
|
+
idempotencyKey?: string;
|
|
87
|
+
}
|
|
88
|
+
export declare function runEnvSetDefault(opts: EnvSetDefaultOptions, deps?: ProjectDeps): Promise<CliProjectEnvUpdateResponse>;
|
|
89
|
+
export declare function createProjectEnvCommand(deps?: ProjectDeps): Command;
|
|
90
|
+
export {};
|