@testsprite/testsprite-cli 0.11.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.
@@ -15,29 +15,32 @@
15
15
  * notice names the npm LATEST and fires whenever a newer release exists. Each
16
16
  * owns its own number — the backend never advertises "latest".
17
17
  *
18
+ * Under GitHub Actions the same below-floor observation is surfaced as a
19
+ * `::warning::` workflow command instead (see {@link formatPinnedVersionWarning}):
20
+ * a `ci init`-generated workflow pins `cli-version` to the version that
21
+ * generated it, so the job keeps running that version forever and the plain
22
+ * stderr line (TTY-gated) would never be seen. The floor header is the only
23
+ * version signal a CI run has in-process — the npm update check is skipped
24
+ * under `CI` by design — so this fires only when the pin has fallen BELOW the
25
+ * floor, not merely behind the newest release.
26
+ *
18
27
  * Reuses `compareSemver` and the `TESTSPRITE_NO_UPDATE_NOTIFIER` opt-out from
19
28
  * `update-check.ts` so the gating and semver semantics stay consistent.
20
29
  */
21
30
  import { compareSemver, UPDATE_CHECK_OPT_OUT_ENV } from './update-check.js';
22
31
  import { VERSION } from '../version.js';
23
32
  /**
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.
33
+ * The gates every advisory shares: opt-out env, dry-run, a present + parseable
34
+ * floor, and the running version strictly below it. Pure.
27
35
  */
28
- export function shouldWarnBelowFloor(info, deps = {}) {
36
+ function isBelowFloor(info, deps) {
29
37
  const env = deps.env ?? process.env;
30
38
  const currentVersion = deps.currentVersion ?? VERSION;
31
- const isTTY = deps.isTTY ?? process.stderr.isTTY === true;
32
39
  const optOut = env[UPDATE_CHECK_OPT_OUT_ENV];
33
40
  if (optOut !== undefined && optOut !== '')
34
41
  return false;
35
- if (deps.outputMode === 'json')
36
- return false;
37
42
  if (deps.dryRun === true)
38
43
  return false;
39
- if (!isTTY)
40
- return false;
41
44
  const minVersion = info.minVersion;
42
45
  if (!minVersion)
43
46
  return false;
@@ -45,6 +48,33 @@ export function shouldWarnBelowFloor(info, deps = {}) {
45
48
  // Unparseable input on either side compares as 0, so garbage never warns.
46
49
  return compareSemver(currentVersion, minVersion) === -1;
47
50
  }
51
+ /**
52
+ * True when every gate passes and the running version is strictly below the
53
+ * advertised floor. Gates mirror the update notice: opt-out env, JSON output,
54
+ * dry-run, and non-TTY all suppress. Pure — no side effects, no process state.
55
+ */
56
+ export function shouldWarnBelowFloor(info, deps = {}) {
57
+ const isTTY = deps.isTTY ?? process.stderr.isTTY === true;
58
+ if (deps.outputMode === 'json')
59
+ return false;
60
+ if (!isTTY)
61
+ return false;
62
+ return isBelowFloor(info, deps);
63
+ }
64
+ /**
65
+ * True when the below-floor state should be surfaced as a GitHub Actions
66
+ * `::warning::` annotation: running under Actions (`GITHUB_ACTIONS=true`), not
67
+ * opted out, not dry-run, and strictly below the floor. Deliberately NOT gated
68
+ * on TTY or `--output json` — an Actions job is never a TTY, and a workflow
69
+ * command is parsed by the runner from either stream, so it can ride stderr
70
+ * without touching a JSON envelope on stdout.
71
+ */
72
+ export function shouldWarnPinnedInActions(info, deps = {}) {
73
+ const env = deps.env ?? process.env;
74
+ if (env.GITHUB_ACTIONS !== 'true')
75
+ return false;
76
+ return isBelowFloor(info, deps);
77
+ }
48
78
  /**
49
79
  * The single advisory line. Names the floor (the backend's authority) and the
50
80
  * upgrade command — it deliberately does NOT name a target release; the npm
@@ -55,6 +85,18 @@ export function formatBelowFloorNotice(currentVersion, minVersion) {
55
85
  `Upgrade: npm install -g @testsprite/testsprite-cli ` +
56
86
  `(disable this notice with ${UPDATE_CHECK_OPT_OUT_ENV}=1).`);
57
87
  }
88
+ /**
89
+ * The GitHub Actions workflow-command form of the advisory. Names the pinned
90
+ * (running) version, the floor it has fallen below, and the one command that
91
+ * re-pins the workflow to a current release. Both versions come from semver
92
+ * strings that already parsed (see `isBelowFloor`), so no command-data escaping
93
+ * is needed — neither can carry `%`, CR or LF.
94
+ */
95
+ export function formatPinnedVersionWarning(currentVersion, minVersion) {
96
+ return (`::warning title=TestSprite::testsprite-cli ${currentVersion} is pinned in this workflow ` +
97
+ `and is below the minimum supported version ${minVersion}. ` +
98
+ `Regenerate with testsprite ci init github --force.`);
99
+ }
58
100
  /** Module-level guard: at most one below-floor advisory per process. */
59
101
  let warnedThisProcess = false;
60
102
  /** Test-only: reset the once-per-process guard between cases. */
@@ -64,20 +106,25 @@ export function resetBelowFloorNoticeState() {
64
106
  /**
65
107
  * Emit the below-floor advisory at most once per process. Wired to the HTTP
66
108
  * client's `onServerVersion` hook. Never throws — an advisory must not break or
67
- * delay the command it rides along with.
109
+ * delay the command it rides along with. Under GitHub Actions the advisory is
110
+ * the `::warning::` workflow command (annotates the job) instead of the plain
111
+ * TTY line; exactly one of the two is ever emitted.
68
112
  */
69
113
  export function noteServerVersion(info, deps = {}) {
70
114
  try {
71
115
  if (warnedThisProcess)
72
116
  return;
73
- if (!shouldWarnBelowFloor(info, deps))
117
+ const inActions = shouldWarnPinnedInActions(info, deps);
118
+ if (!inActions && !shouldWarnBelowFloor(info, deps))
74
119
  return;
75
120
  const minVersion = info.minVersion;
76
121
  if (!minVersion)
77
122
  return;
78
123
  const currentVersion = deps.currentVersion ?? VERSION;
79
124
  const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
80
- stderr(formatBelowFloorNotice(currentVersion, minVersion));
125
+ stderr(inActions
126
+ ? formatPinnedVersionWarning(currentVersion, minVersion)
127
+ : formatBelowFloorNotice(currentVersion, minVersion));
81
128
  warnedThisProcess = true;
82
129
  }
83
130
  catch {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.11.0";
1
+ export declare const VERSION = "0.12.0";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED by scripts/generate-version.mjs — do not edit by hand.
2
2
  // Run `npm run build` (or `npm run generate:version`) to regenerate.
3
- export const VERSION = '0.11.0';
3
+ export const VERSION = '0.12.0';
4
4
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testsprite/testsprite-cli",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Official TestSprite command-line interface",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,7 +29,9 @@ or RFC1918 address, and not a general local-network escape hatch) to the test
29
29
  runner. Two constraints: frontend tests only (a backend test's target is baked
30
30
  into its generated code, so run it normally), and it needs an API key with the
31
31
  `run:tunnel` scope. Keys minted before that scope existed must be replaced;
32
- the CLI names the missing scope (exit 3).
32
+ the CLI names the missing scope (exit 3). Add `--env <name>` to log in
33
+ with a named project environment's test account instead of the default one's
34
+ (`testsprite project env list <projectId>` shows the names).
33
35
 
34
36
  If the user explicitly named a tool (the CLI or the MCP), honor that choice
35
37
  regardless of which one the change's reachability would otherwise suggest.