@testsprite/testsprite-cli 0.3.0 → 0.4.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 +30 -29
- package/dist/commands/auth.d.ts +5 -0
- package/dist/commands/auth.js +9 -0
- package/dist/commands/doctor.js +36 -14
- package/dist/commands/project.d.ts +25 -1
- package/dist/commands/project.js +74 -4
- package/dist/commands/test.d.ts +93 -1
- package/dist/commands/test.js +568 -94
- package/dist/index.js +41 -4
- package/dist/lib/bundle.js +19 -1
- package/dist/lib/client-factory.d.ts +6 -0
- package/dist/lib/client-factory.js +16 -0
- package/dist/lib/dry-run/samples.js +36 -0
- package/dist/lib/errors.d.ts +28 -1
- package/dist/lib/errors.js +40 -0
- package/dist/lib/failing-fe-resolver.d.ts +15 -0
- package/dist/lib/failing-fe-resolver.js +49 -1
- package/dist/lib/http.d.ts +53 -1
- package/dist/lib/http.js +113 -5
- package/dist/lib/interrupt.d.ts +65 -10
- package/dist/lib/interrupt.js +94 -9
- package/dist/lib/poll.d.ts +11 -0
- package/dist/lib/poll.js +70 -5
- package/dist/lib/runs.types.d.ts +9 -0
- package/dist/lib/v3-advisory.d.ts +13 -0
- package/dist/lib/v3-advisory.js +24 -0
- package/dist/lib/version-notice.d.ts +37 -0
- package/dist/lib/version-notice.js +87 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-verify.codex.md +6 -0
- package/skills/testsprite-verify.skill.md +15 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Version-compatibility signal observed on a backend response (the floor). */
|
|
2
|
+
export interface ServerVersionInfo {
|
|
3
|
+
minVersion?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface VersionNoticeDeps {
|
|
6
|
+
/** Version the running binary reports. Defaults to the built-in `VERSION`. */
|
|
7
|
+
currentVersion?: string;
|
|
8
|
+
env?: NodeJS.ProcessEnv;
|
|
9
|
+
/** Whether stderr is an interactive terminal. */
|
|
10
|
+
isTTY?: boolean;
|
|
11
|
+
/** The command's `--output` mode; `'json'` suppresses the advisory. */
|
|
12
|
+
outputMode?: string;
|
|
13
|
+
/** Suppress under `--dry-run` (the dry-run fetch returns no real headers). */
|
|
14
|
+
dryRun?: boolean;
|
|
15
|
+
/** Sink for the single advisory line. */
|
|
16
|
+
stderr?: (line: string) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* True when every gate passes and the running version is strictly below the
|
|
20
|
+
* advertised floor. Gates mirror the update notice: opt-out env, JSON output,
|
|
21
|
+
* dry-run, and non-TTY all suppress. Pure — no side effects, no process state.
|
|
22
|
+
*/
|
|
23
|
+
export declare function shouldWarnBelowFloor(info: ServerVersionInfo, deps?: VersionNoticeDeps): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The single advisory line. Names the floor (the backend's authority) and the
|
|
26
|
+
* upgrade command — it deliberately does NOT name a target release; the npm
|
|
27
|
+
* update-notice is the single source of truth for the newest version.
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatBelowFloorNotice(currentVersion: string, minVersion: string): string;
|
|
30
|
+
/** Test-only: reset the once-per-process guard between cases. */
|
|
31
|
+
export declare function resetBelowFloorNoticeState(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Emit the below-floor advisory at most once per process. Wired to the HTTP
|
|
34
|
+
* client's `onServerVersion` hook. Never throws — an advisory must not break or
|
|
35
|
+
* delay the command it rides along with.
|
|
36
|
+
*/
|
|
37
|
+
export declare function noteServerVersion(info: ServerVersionInfo, deps?: VersionNoticeDeps): void;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline "your CLI is below the backend's minimum supported version" advisory.
|
|
3
|
+
*
|
|
4
|
+
* The backend advertises its supported floor on every `/api/cli/v1` response via
|
|
5
|
+
* the `X-TestSprite-CLI-Min-Version` header. Unlike the npm-registry update
|
|
6
|
+
* notice (`update-check.ts`, which runs in a Commander `preAction` hook before
|
|
7
|
+
* any HTTP request), this advisory reacts to a header observed *during* the
|
|
8
|
+
* request, so it is emitted from the HTTP layer's `onServerVersion` hook (wired
|
|
9
|
+
* in `client-factory.ts`) rather than the pre-request notifier — no cross-run
|
|
10
|
+
* cache needed.
|
|
11
|
+
*
|
|
12
|
+
* Distinct from the update notice on purpose, and non-redundant: this names the
|
|
13
|
+
* backend FLOOR and fires only when the running version is strictly below it (a
|
|
14
|
+
* serious "you will be rejected once enforcement is on" state); the update
|
|
15
|
+
* notice names the npm LATEST and fires whenever a newer release exists. Each
|
|
16
|
+
* owns its own number — the backend never advertises "latest".
|
|
17
|
+
*
|
|
18
|
+
* Reuses `compareSemver` and the `TESTSPRITE_NO_UPDATE_NOTIFIER` opt-out from
|
|
19
|
+
* `update-check.ts` so the gating and semver semantics stay consistent.
|
|
20
|
+
*/
|
|
21
|
+
import { compareSemver, UPDATE_CHECK_OPT_OUT_ENV } from './update-check.js';
|
|
22
|
+
import { VERSION } from '../version.js';
|
|
23
|
+
/**
|
|
24
|
+
* True when every gate passes and the running version is strictly below the
|
|
25
|
+
* advertised floor. Gates mirror the update notice: opt-out env, JSON output,
|
|
26
|
+
* dry-run, and non-TTY all suppress. Pure — no side effects, no process state.
|
|
27
|
+
*/
|
|
28
|
+
export function shouldWarnBelowFloor(info, deps = {}) {
|
|
29
|
+
const env = deps.env ?? process.env;
|
|
30
|
+
const currentVersion = deps.currentVersion ?? VERSION;
|
|
31
|
+
const isTTY = deps.isTTY ?? process.stderr.isTTY === true;
|
|
32
|
+
const optOut = env[UPDATE_CHECK_OPT_OUT_ENV];
|
|
33
|
+
if (optOut !== undefined && optOut !== '')
|
|
34
|
+
return false;
|
|
35
|
+
if (deps.outputMode === 'json')
|
|
36
|
+
return false;
|
|
37
|
+
if (deps.dryRun === true)
|
|
38
|
+
return false;
|
|
39
|
+
if (!isTTY)
|
|
40
|
+
return false;
|
|
41
|
+
const minVersion = info.minVersion;
|
|
42
|
+
if (!minVersion)
|
|
43
|
+
return false;
|
|
44
|
+
// compareSemver returns -1 when the first arg is OLDER than the second.
|
|
45
|
+
// Unparseable input on either side compares as 0, so garbage never warns.
|
|
46
|
+
return compareSemver(currentVersion, minVersion) === -1;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The single advisory line. Names the floor (the backend's authority) and the
|
|
50
|
+
* upgrade command — it deliberately does NOT name a target release; the npm
|
|
51
|
+
* update-notice is the single source of truth for the newest version.
|
|
52
|
+
*/
|
|
53
|
+
export function formatBelowFloorNotice(currentVersion, minVersion) {
|
|
54
|
+
return (`Your testsprite-cli (${currentVersion}) is below the minimum supported version ${minVersion}. ` +
|
|
55
|
+
`Upgrade: npm install -g @testsprite/testsprite-cli ` +
|
|
56
|
+
`(disable this notice with ${UPDATE_CHECK_OPT_OUT_ENV}=1).`);
|
|
57
|
+
}
|
|
58
|
+
/** Module-level guard: at most one below-floor advisory per process. */
|
|
59
|
+
let warnedThisProcess = false;
|
|
60
|
+
/** Test-only: reset the once-per-process guard between cases. */
|
|
61
|
+
export function resetBelowFloorNoticeState() {
|
|
62
|
+
warnedThisProcess = false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Emit the below-floor advisory at most once per process. Wired to the HTTP
|
|
66
|
+
* client's `onServerVersion` hook. Never throws — an advisory must not break or
|
|
67
|
+
* delay the command it rides along with.
|
|
68
|
+
*/
|
|
69
|
+
export function noteServerVersion(info, deps = {}) {
|
|
70
|
+
try {
|
|
71
|
+
if (warnedThisProcess)
|
|
72
|
+
return;
|
|
73
|
+
if (!shouldWarnBelowFloor(info, deps))
|
|
74
|
+
return;
|
|
75
|
+
const minVersion = info.minVersion;
|
|
76
|
+
if (!minVersion)
|
|
77
|
+
return;
|
|
78
|
+
const currentVersion = deps.currentVersion ?? VERSION;
|
|
79
|
+
const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
80
|
+
stderr(formatBelowFloorNotice(currentVersion, minVersion));
|
|
81
|
+
warnedThisProcess = true;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Advisory is best-effort; never surface its failures to the command.
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=version-notice.js.map
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.4.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -10,6 +10,12 @@ docs/config and is about to be reported complete.
|
|
|
10
10
|
Run after a feature or fix lands. Skip only for: docs-only edits, pure
|
|
11
11
|
build/config changes, or when the repo has no TestSprite project linked.
|
|
12
12
|
|
|
13
|
+
The CLI only tests a reachable deployed URL (it rejects localhost). If the
|
|
14
|
+
change is only running locally, hand off to the TestSprite MCP when it's
|
|
15
|
+
available — it tunnels your local server; otherwise report the change as
|
|
16
|
+
unverified-because-undeployed and stop. If the user explicitly named a tool
|
|
17
|
+
(the CLI or the MCP), honor that over this reachability heuristic.
|
|
18
|
+
|
|
13
19
|
## Core loop
|
|
14
20
|
|
|
15
21
|
### 1. Preflight
|
|
@@ -21,6 +21,17 @@ Run the loop only once the change is live somewhere reachable (e.g. open the PR,
|
|
|
21
21
|
let CI deploy the preview/staging environment) and pass that URL as
|
|
22
22
|
`--target-url`. Running earlier verifies the previous build, not your change.
|
|
23
23
|
|
|
24
|
+
This CLI only tests a reachable deployed URL (it rejects localhost). If the
|
|
25
|
+
change is only running locally and isn't deployed anywhere reachable yet:
|
|
26
|
+
|
|
27
|
+
- if the TestSprite MCP is available in this environment, hand off to it — it
|
|
28
|
+
tunnels your local server and tests the running app;
|
|
29
|
+
- otherwise report the change as unverified-because-undeployed and stop — don't
|
|
30
|
+
run against a stale deployment to manufacture a verdict.
|
|
31
|
+
|
|
32
|
+
If the user explicitly named a tool (the CLI or the MCP), honor that over this
|
|
33
|
+
reachability heuristic.
|
|
34
|
+
|
|
24
35
|
## When to skip
|
|
25
36
|
|
|
26
37
|
The skip list is narrow:
|
|
@@ -225,10 +236,10 @@ testsprite test create --type backend --project <projectId> --name "fixture user
|
|
|
225
236
|
ordering: trigger the set with `test run --all` (§4) and producers run before
|
|
226
237
|
consumers, `teardown` last. Chaining `run A --wait && run B --wait` yourself
|
|
227
238
|
loses the engine's variable passing and conflicts with concurrent runs.
|
|
228
|
-
- **Declarations are
|
|
229
|
-
`
|
|
230
|
-
|
|
231
|
-
|
|
239
|
+
- **Declarations are editable.** `test update` amends them (`--produces` /
|
|
240
|
+
`--needs` / `--category`, repeatable) and `test get` echoes them back —
|
|
241
|
+
still declare the graph at create time when you can, so wave ordering is
|
|
242
|
+
right on the first run.
|
|
232
243
|
|
|
233
244
|
**Show the user the drafted plan / code before creating it** — creating writes to
|
|
234
245
|
their project. One short confirmation; let them edit the tempfile first.
|