@testspectra/cli 1.3.8 → 1.3.10

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/dist/index.js CHANGED
@@ -17,6 +17,7 @@ import { lintCommand } from './commands/lint.js';
17
17
  import { licenseCommand } from './commands/license.js';
18
18
  import { docsUpdateCommand } from './commands/docs.js';
19
19
  import { skillsInitCommand, skillsListCommand, skillsAddCommand, skillsUpdateCommand, skillsRemoveCommand, } from './commands/skills.js';
20
+ import { readInstalledVersion } from './utils/update-notifier.js';
20
21
  export * from './config/schema.js';
21
22
  export * from './config/loader.js';
22
23
  export * from './generator/index.js';
@@ -27,7 +28,10 @@ export * from './types/generator.js';
27
28
  export * from '@testspectra/matchers';
28
29
  export function createCliProgram() {
29
30
  const program = new Command();
30
- program.name('spectra').description('TestSpectra Cross-Platform Test Runner CLI').version('1.0.0');
31
+ program
32
+ .name('spectra')
33
+ .description('TestSpectra Cross-Platform Test Runner CLI')
34
+ .version(readInstalledVersion('@testspectra/cli') ?? 'unknown');
31
35
  program
32
36
  .command('init')
33
37
  .description('Initialize spectra.config.ts and project directories')
@@ -9,7 +9,12 @@ interface CachedUpdate {
9
9
  pkg: string;
10
10
  latest?: string;
11
11
  }
12
- /** First cached package whose installed version differs from its latest version. */
12
+ /**
13
+ * Whether semver `latest` is newer than `current`. A prerelease sorts below its release
14
+ * (`1.2.0-rc.1` < `1.2.0`); prerelease identifiers compare numerically when both are numbers.
15
+ */
16
+ export declare function isNewerVersion(latest: string, current: string): boolean;
17
+ /** First cached package whose latest version is newer than the installed one. */
13
18
  export declare function findAvailableUpdate(candidates: CachedUpdate[], resolveInstalled?: (pkgName: string) => string | null): {
14
19
  pkg: string;
15
20
  current: string;
@@ -68,13 +68,45 @@ export function readInstalledVersion(pkgName) {
68
68
  return null;
69
69
  }
70
70
  }
71
- /** First cached package whose installed version differs from its latest version. */
71
+ /**
72
+ * Whether semver `latest` is newer than `current`. A prerelease sorts below its release
73
+ * (`1.2.0-rc.1` < `1.2.0`); prerelease identifiers compare numerically when both are numbers.
74
+ */
75
+ export function isNewerVersion(latest, current) {
76
+ const [latestCore, latestPre] = splitVersion(latest);
77
+ const [currentCore, currentPre] = splitVersion(current);
78
+ for (let i = 0; i < 3; i++) {
79
+ const diff = (latestCore[i] ?? 0) - (currentCore[i] ?? 0);
80
+ if (diff !== 0)
81
+ return diff > 0;
82
+ }
83
+ if (!latestPre || !currentPre)
84
+ return !latestPre && !!currentPre;
85
+ const a = latestPre.split('.');
86
+ const b = currentPre.split('.');
87
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
88
+ if (a[i] === undefined)
89
+ return false;
90
+ if (b[i] === undefined)
91
+ return true;
92
+ if (a[i] === b[i])
93
+ continue;
94
+ const [na, nb] = [Number(a[i]), Number(b[i])];
95
+ return Number.isInteger(na) && Number.isInteger(nb) ? na > nb : a[i] > b[i];
96
+ }
97
+ return false;
98
+ }
99
+ function splitVersion(version) {
100
+ const [core, ...pre] = version.replace(/^v/, '').split('-');
101
+ return [core.split('.').map(Number), pre.length > 0 ? pre.join('-') : undefined];
102
+ }
103
+ /** First cached package whose latest version is newer than the installed one. */
72
104
  export function findAvailableUpdate(candidates, resolveInstalled = readInstalledVersion) {
73
105
  for (const candidate of candidates) {
74
106
  if (!candidate.latest)
75
107
  continue;
76
108
  const current = resolveInstalled(candidate.pkg);
77
- if (current && current !== candidate.latest) {
109
+ if (current && isNewerVersion(candidate.latest, current)) {
78
110
  return { pkg: candidate.pkg, current, latest: candidate.latest };
79
111
  }
80
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testspectra/cli",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "TestSpectra Cross-Platform Test Runner CLI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,11 +25,11 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@clack/prompts": "^1.7.0",
28
- "@testspectra/matchers": "^1.3.8",
29
- "@testspectra/react": "^1.3.8",
30
- "@testspectra/react-native": "^1.3.8",
31
- "@testspectra/reporter": "^1.3.8",
32
- "@testspectra/skills": "^1.3.8",
28
+ "@testspectra/matchers": "^1.3.10",
29
+ "@testspectra/react": "^1.3.10",
30
+ "@testspectra/react-native": "^1.3.10",
31
+ "@testspectra/reporter": "^1.3.10",
32
+ "@testspectra/skills": "^1.3.10",
33
33
  "chalk": "^5.3.0",
34
34
  "commander": "^12.1.0",
35
35
  "cross-spawn": "^7.0.6",
@@ -40,9 +40,9 @@
40
40
  "zod": "^3.23.8"
41
41
  },
42
42
  "optionalDependencies": {
43
- "@testspectra/cli-darwin-arm64": "1.3.8",
44
- "@testspectra/cli-linux-x64": "1.3.8",
45
- "@testspectra/cli-win32-x64": "1.3.8"
43
+ "@testspectra/cli-darwin-arm64": "1.3.10",
44
+ "@testspectra/cli-linux-x64": "1.3.10",
45
+ "@testspectra/cli-win32-x64": "1.3.10"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/cross-spawn": "^6.0.6",
@@ -17,9 +17,9 @@
17
17
  "postinstall": "spectra sync-types"
18
18
  },
19
19
  "devDependencies": {
20
- "@testspectra/cli": "^1.3.8",
21
- "@testspectra/matchers": "^1.3.8",
22
- "@testspectra/plugin-demo": "^1.3.8",
20
+ "@testspectra/cli": "^1.3.10",
21
+ "@testspectra/matchers": "^1.3.10",
22
+ "@testspectra/plugin-demo": "^1.3.10",
23
23
  "@types/node": "^20.14.0",
24
24
  "@wdio/cli": "^9.2.8",
25
25
  "@wdio/local-runner": "^9.2.8",
@@ -12,8 +12,8 @@
12
12
  "postinstall": "spectra sync-types"
13
13
  },
14
14
  "devDependencies": {
15
- "@testspectra/cli": "^1.3.8",
16
- "@testspectra/matchers": "^1.3.8",
15
+ "@testspectra/cli": "^1.3.10",
16
+ "@testspectra/matchers": "^1.3.10",
17
17
  "@types/node": "^20.14.0",
18
18
  "@wdio/cli": "^9.2.8",
19
19
  "@wdio/local-runner": "^9.2.8",
@@ -14,9 +14,9 @@
14
14
  "postinstall": "spectra sync-types"
15
15
  },
16
16
  "devDependencies": {
17
- "@testspectra/cli": "^1.3.8",
18
- "@testspectra/matchers": "^1.3.8",
19
- "@testspectra/react": "^1.3.8",
17
+ "@testspectra/cli": "^1.3.10",
18
+ "@testspectra/matchers": "^1.3.10",
19
+ "@testspectra/react": "^1.3.10",
20
20
  "@types/node": "^20.14.0",
21
21
  "@types/react": "^18.3.3",
22
22
  "@types/react-dom": "^18.3.0",
@@ -12,9 +12,9 @@
12
12
  "postinstall": "spectra sync-types"
13
13
  },
14
14
  "devDependencies": {
15
- "@testspectra/cli": "^1.3.8",
16
- "@testspectra/matchers": "^1.3.8",
17
- "@testspectra/react-native": "^1.3.8",
15
+ "@testspectra/cli": "^1.3.10",
16
+ "@testspectra/matchers": "^1.3.10",
17
+ "@testspectra/react-native": "^1.3.10",
18
18
  "@types/node": "^20.14.0",
19
19
  "@types/react": "^18.3.12",
20
20
  "@types/react-native": "^0.73.0",