@testspectra/cli 1.0.34 → 1.0.36
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 +10 -1
- package/dist/types/generator.js +68 -16
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -363,7 +363,16 @@ export async function initCommand(options = {}) {
|
|
|
363
363
|
if (!fs.existsSync(rootPkgPath)) {
|
|
364
364
|
const templatePkgSrc = path.join(templateDir, "package.json");
|
|
365
365
|
if (fs.existsSync(templatePkgSrc)) {
|
|
366
|
-
|
|
366
|
+
try {
|
|
367
|
+
const tPkg = JSON.parse(fs.readFileSync(templatePkgSrc, "utf-8"));
|
|
368
|
+
if (tPkg.devDependencies && tPkg.devDependencies["@testspectra/cli"]) {
|
|
369
|
+
tPkg.devDependencies["@testspectra/cli"] = cliDepVersion;
|
|
370
|
+
}
|
|
371
|
+
fs.writeFileSync(rootPkgPath, JSON.stringify(tPkg, null, 2), "utf-8");
|
|
372
|
+
}
|
|
373
|
+
catch {
|
|
374
|
+
fs.copyFileSync(templatePkgSrc, rootPkgPath);
|
|
375
|
+
}
|
|
367
376
|
}
|
|
368
377
|
}
|
|
369
378
|
else {
|
package/dist/types/generator.js
CHANGED
|
@@ -57,29 +57,81 @@ export class TypeGenerator {
|
|
|
57
57
|
}
|
|
58
58
|
static getPageObjectsDirsForScope(scopeDir, sharedDir) {
|
|
59
59
|
const dirs = [];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
function scanDir(dir, maxDepth) {
|
|
61
|
+
if (maxDepth <= 0 || !fs.existsSync(dir))
|
|
62
|
+
return;
|
|
63
|
+
const base = path.basename(dir);
|
|
64
|
+
if (base === "node_modules" || base === "dist" || base === ".git" || base === ".testspectra")
|
|
65
|
+
return;
|
|
66
|
+
if (base === "page-objects" || base === "pageobjects") {
|
|
67
|
+
if (!dirs.includes(dir))
|
|
68
|
+
dirs.push(dir);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (entry.isDirectory()) {
|
|
75
|
+
scanDir(path.join(dir, entry.name), maxDepth - 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch { }
|
|
80
|
+
}
|
|
81
|
+
if (!sharedDir && (fs.existsSync(path.join(scopeDir, "pnpm-workspace.yaml")) || fs.existsSync(path.join(scopeDir, "nx.json")))) {
|
|
82
|
+
scanDir(scopeDir, 6);
|
|
67
83
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
else {
|
|
85
|
+
const candidates = [
|
|
86
|
+
path.join(scopeDir, "page-objects"),
|
|
87
|
+
path.join(scopeDir, "pageobjects"),
|
|
88
|
+
];
|
|
89
|
+
if (sharedDir) {
|
|
90
|
+
candidates.push(path.join(sharedDir, "page-objects"));
|
|
91
|
+
candidates.push(path.join(sharedDir, "pageobjects"));
|
|
92
|
+
}
|
|
93
|
+
for (const c of candidates) {
|
|
94
|
+
if (fs.existsSync(c) && !dirs.includes(c))
|
|
95
|
+
dirs.push(c);
|
|
96
|
+
}
|
|
71
97
|
}
|
|
72
98
|
return dirs;
|
|
73
99
|
}
|
|
74
100
|
static getEntityDirsForScope(entityType, scopeDir, sharedDir) {
|
|
75
101
|
const dirs = [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
102
|
+
function scanDir(dir, maxDepth) {
|
|
103
|
+
if (maxDepth <= 0 || !fs.existsSync(dir))
|
|
104
|
+
return;
|
|
105
|
+
const base = path.basename(dir);
|
|
106
|
+
if (base === "node_modules" || base === "dist" || base === ".git" || base === ".testspectra")
|
|
107
|
+
return;
|
|
108
|
+
if (base === entityType) {
|
|
109
|
+
if (!dirs.includes(dir))
|
|
110
|
+
dirs.push(dir);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
115
|
+
for (const entry of entries) {
|
|
116
|
+
if (entry.isDirectory()) {
|
|
117
|
+
scanDir(path.join(dir, entry.name), maxDepth - 1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch { }
|
|
122
|
+
}
|
|
123
|
+
if (!sharedDir && (fs.existsSync(path.join(scopeDir, "pnpm-workspace.yaml")) || fs.existsSync(path.join(scopeDir, "nx.json")))) {
|
|
124
|
+
scanDir(scopeDir, 6);
|
|
79
125
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
126
|
+
else {
|
|
127
|
+
const candidates = [path.join(scopeDir, entityType)];
|
|
128
|
+
if (sharedDir) {
|
|
129
|
+
candidates.push(path.join(sharedDir, entityType));
|
|
130
|
+
}
|
|
131
|
+
for (const c of candidates) {
|
|
132
|
+
if (fs.existsSync(c) && !dirs.includes(c))
|
|
133
|
+
dirs.push(c);
|
|
134
|
+
}
|
|
83
135
|
}
|
|
84
136
|
return dirs;
|
|
85
137
|
}
|