@testspectra/cli 1.0.34 → 1.0.35

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.
@@ -57,29 +57,81 @@ export class TypeGenerator {
57
57
  }
58
58
  static getPageObjectsDirsForScope(scopeDir, sharedDir) {
59
59
  const dirs = [];
60
- const candidates = [
61
- path.join(scopeDir, "page-objects"),
62
- path.join(scopeDir, "pageobjects"),
63
- ];
64
- if (sharedDir) {
65
- candidates.push(path.join(sharedDir, "page-objects"));
66
- candidates.push(path.join(sharedDir, "pageobjects"));
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
- for (const c of candidates) {
69
- if (fs.existsSync(c) && !dirs.includes(c))
70
- dirs.push(c);
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
- const candidates = [path.join(scopeDir, entityType)];
77
- if (sharedDir) {
78
- candidates.push(path.join(sharedDir, entityType));
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
- for (const c of candidates) {
81
- if (fs.existsSync(c) && !dirs.includes(c))
82
- dirs.push(c);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testspectra/cli",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "TestSpectra Zero-Config Cross-Platform Test Runner CLI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",