@testspectra/cli 1.0.47 ā 1.0.48
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/commands/init.js +19 -0
- package/dist/commands/watch.d.ts +4 -3
- package/dist/commands/watch.js +59 -24
- package/dist/index.js +6 -0
- package/package.json +2 -2
- package/templates/default/.vscode/settings.json +5 -0
- package/templates/default/package.json +1 -1
- package/templates/nx/.vscode/settings.json +5 -0
- package/templates/nx/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -76,6 +76,23 @@ function ensurePnpmWorkspaceIncludes(pnpmWorkspacePath, targetPath) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
function ensureVsCodeSettings(cwd) {
|
|
80
|
+
const vscodeDir = path.join(cwd, ".vscode");
|
|
81
|
+
const settingsFile = path.join(vscodeDir, "settings.json");
|
|
82
|
+
if (!fs.existsSync(vscodeDir))
|
|
83
|
+
fs.mkdirSync(vscodeDir, { recursive: true });
|
|
84
|
+
let settings = {};
|
|
85
|
+
if (fs.existsSync(settingsFile)) {
|
|
86
|
+
try {
|
|
87
|
+
settings = JSON.parse(fs.readFileSync(settingsFile, "utf-8"));
|
|
88
|
+
}
|
|
89
|
+
catch { }
|
|
90
|
+
}
|
|
91
|
+
settings["typescript.tsdk"] = "node_modules/typescript/lib";
|
|
92
|
+
settings["typescript.enablePromptUseWorkspaceTsdk"] = true;
|
|
93
|
+
settings["typescript.tsserver.pluginPaths"] = ["./node_modules"];
|
|
94
|
+
fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
95
|
+
}
|
|
79
96
|
function scanDirectoriesForProjects(cwd, patterns) {
|
|
80
97
|
const foundProjects = [];
|
|
81
98
|
const visited = new Set();
|
|
@@ -502,6 +519,7 @@ export async function initCommand(options = {}) {
|
|
|
502
519
|
fs.writeFileSync(rootTsConfigPath, JSON.stringify(rootTsConfig, null, 2), "utf-8");
|
|
503
520
|
// 7. Generate Ambient Types in ROOT only
|
|
504
521
|
TypeGenerator.writeDeclarationFiles(cwd);
|
|
522
|
+
ensureVsCodeSettings(cwd);
|
|
505
523
|
const sharedPoLine = `${sharedTestingRelPath}/page-objects`.padEnd(28, " ");
|
|
506
524
|
const sharedStepsLine = `${sharedTestingRelPath}/steps`.padEnd(28, " ");
|
|
507
525
|
const sharedActLine = `${sharedTestingRelPath}/actions`.padEnd(28, " ");
|
|
@@ -692,6 +710,7 @@ pnpm type-check
|
|
|
692
710
|
}
|
|
693
711
|
}
|
|
694
712
|
TypeGenerator.writeDeclarationFiles(cwd);
|
|
713
|
+
ensureVsCodeSettings(cwd);
|
|
695
714
|
// Standalone Architecture Documentation
|
|
696
715
|
const standaloneArchDoc = `# TestSpectra Project Architecture
|
|
697
716
|
|
package/dist/commands/watch.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
export interface WatchCommandOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function watchCommand(options?: WatchCommandOptions): Promise<void>;
|
package/dist/commands/watch.js
CHANGED
|
@@ -1,30 +1,65 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
3
4
|
import { TypeGenerator } from "../types/generator.js";
|
|
4
|
-
export function watchCommand(options = {}) {
|
|
5
|
-
const cwd = process.cwd();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export async function watchCommand(options = {}) {
|
|
6
|
+
const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();
|
|
7
|
+
console.log(chalk.bold.cyan("\nš TestSpectra Ambient Types Watcher"));
|
|
8
|
+
console.log(chalk.gray(`Watching workspace: ${cwd}\n`));
|
|
9
|
+
// Initial generation
|
|
10
|
+
try {
|
|
11
|
+
TypeGenerator.writeDeclarationFiles(cwd);
|
|
12
|
+
console.log(chalk.green("ā Initialized ambient declarations in .testspectra/types/"));
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
14
|
+
catch (err) {
|
|
15
|
+
console.error(chalk.red(`ā Failed initial type generation: ${err?.message}`));
|
|
16
|
+
}
|
|
17
|
+
let debounceTimer = null;
|
|
18
|
+
const triggerRegen = (filePath, eventType) => {
|
|
19
|
+
if (debounceTimer)
|
|
20
|
+
clearTimeout(debounceTimer);
|
|
21
|
+
debounceTimer = setTimeout(() => {
|
|
22
|
+
try {
|
|
23
|
+
TypeGenerator.writeDeclarationFiles(cwd);
|
|
24
|
+
const time = new Date().toLocaleTimeString();
|
|
25
|
+
const rel = path.relative(cwd, filePath) || filePath;
|
|
26
|
+
console.log(chalk.gray(`[${time}] `) +
|
|
27
|
+
chalk.cyan(`⨠Updated ambient types `) +
|
|
28
|
+
chalk.gray(`(${eventType}: ${rel})`));
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
console.error(chalk.red(`ā Error regenerating declarations: ${err?.message}`));
|
|
32
|
+
}
|
|
33
|
+
}, 100);
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
const watcher = fs.watch(cwd, { recursive: true }, (eventType, filename) => {
|
|
37
|
+
if (!filename)
|
|
38
|
+
return;
|
|
39
|
+
const fn = filename.toString();
|
|
40
|
+
if (fn.includes(".testspectra") ||
|
|
41
|
+
fn.includes("node_modules") ||
|
|
42
|
+
fn.includes(".git") ||
|
|
43
|
+
fn.includes("dist") ||
|
|
44
|
+
fn.includes(".nx")) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (fn.includes("fixtures") ||
|
|
48
|
+
fn.includes("page-objects") ||
|
|
49
|
+
fn.includes("pageobjects") ||
|
|
50
|
+
fn.includes("actions") ||
|
|
51
|
+
fn.includes("steps") ||
|
|
52
|
+
fn.includes("hooks") ||
|
|
53
|
+
fn.includes("spectra.config")) {
|
|
54
|
+
triggerRegen(path.join(cwd, fn), eventType);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
watcher.on("error", (err) => {
|
|
58
|
+
console.error(chalk.red(`Watcher error: ${err?.message}`));
|
|
59
|
+
});
|
|
60
|
+
console.log(chalk.gray("Press Ctrl+C to stop watching.\n"));
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.error(chalk.red(`Failed to start workspace watcher: ${err?.message}`));
|
|
29
64
|
}
|
|
30
65
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { devicesCommand } from "./commands/devices.js";
|
|
|
4
4
|
import { doctorCommand } from "./commands/doctor.js";
|
|
5
5
|
import { initCommand } from "./commands/init.js";
|
|
6
6
|
import { runCommand } from "./commands/run.js";
|
|
7
|
+
import { watchCommand } from "./commands/watch.js";
|
|
7
8
|
import { init } from "./plugin.js";
|
|
8
9
|
export * from "./config/schema.js";
|
|
9
10
|
export * from "./config/loader.js";
|
|
@@ -29,6 +30,11 @@ export function createCliProgram() {
|
|
|
29
30
|
.option("-e, --e2e-folder <name>", "Name of E2E sub-folder (default: e2e)")
|
|
30
31
|
.option("-f, --force", "Overwrite existing module files if present")
|
|
31
32
|
.action(addCommand);
|
|
33
|
+
program
|
|
34
|
+
.command("watch")
|
|
35
|
+
.description("Watch workspace and continuously auto-generate TestSpectra ambient declarations")
|
|
36
|
+
.option("-w, --cwd <dir>", "Custom workspace directory")
|
|
37
|
+
.action(watchCommand);
|
|
32
38
|
program
|
|
33
39
|
.command("doctor")
|
|
34
40
|
.description("Verify local environment prerequisites (ADB, Java, Chrome, Bun, Node)")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testspectra/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.48",
|
|
4
4
|
"description": "TestSpectra Zero-Config Cross-Platform Test Runner CLI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@clack/prompts": "^1.7.0",
|
|
24
|
-
"@testspectra/matchers": "^1.0.
|
|
24
|
+
"@testspectra/matchers": "^1.0.48",
|
|
25
25
|
"chalk": "^5.3.0",
|
|
26
26
|
"commander": "^12.1.0",
|
|
27
27
|
"dotenv": "^16.4.5",
|