@testspectra/cli 1.0.29 → 1.0.30

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.
@@ -293,7 +293,10 @@ export async function initCommand(options = {}) {
293
293
  // --- MONOREPO INTERACTIVE FLOW ---
294
294
  if (templateName === "nx" && (detectedProjects.length > 0 || isMonorepo)) {
295
295
  let chosenProjects = [];
296
- if (detectedProjects.length > 0) {
296
+ if (options.force) {
297
+ chosenProjects = detectedProjects.map((p) => p.relPath);
298
+ }
299
+ else if (detectedProjects.length > 0) {
297
300
  p.log.step(chalk.cyan(`Monorepo Auto-Discovery: Found ${detectedProjects.length} workspace feature package(s)`));
298
301
  const projectChoices = await p.multiselect({
299
302
  message: "Select workspace features to initialize with TestSpectra:",
@@ -311,34 +314,77 @@ export async function initCommand(options = {}) {
311
314
  }
312
315
  chosenProjects = projectChoices;
313
316
  }
314
- const e2eFolderNameInput = await p.text({
315
- message: "Enter E2E test folder name for each selected feature:",
316
- placeholder: "e2e",
317
- defaultValue: "e2e",
318
- });
319
- if (p.isCancel(e2eFolderNameInput)) {
320
- p.cancel("Setup cancelled.");
321
- return;
322
- }
323
- const sharedTestingPathInput = await p.text({
324
- message: "Enter path for Shared Testing library (POMs, Steps, Actions, Fixtures):",
325
- placeholder: "shared/testing",
326
- defaultValue: "shared/testing",
327
- });
328
- if (p.isCancel(sharedTestingPathInput)) {
329
- p.cancel("Setup cancelled.");
330
- return;
317
+ let e2eFolderName = "e2e";
318
+ let sharedTestingRelPath = "shared/testing";
319
+ if (!options.force) {
320
+ const e2eFolderNameInput = await p.text({
321
+ message: "Enter E2E test folder name for each selected feature:",
322
+ placeholder: "e2e",
323
+ defaultValue: "e2e",
324
+ });
325
+ if (p.isCancel(e2eFolderNameInput)) {
326
+ p.cancel("Setup cancelled.");
327
+ return;
328
+ }
329
+ const sharedTestingPathInput = await p.text({
330
+ message: "Enter path for Shared Testing library (POMs, Steps, Actions, Fixtures):",
331
+ placeholder: "shared/testing",
332
+ defaultValue: "shared/testing",
333
+ });
334
+ if (p.isCancel(sharedTestingPathInput)) {
335
+ p.cancel("Setup cancelled.");
336
+ return;
337
+ }
338
+ e2eFolderName = e2eFolderNameInput.trim() || "e2e";
339
+ sharedTestingRelPath = sharedTestingPathInput.trim() || "shared/testing";
331
340
  }
332
- const e2eFolderName = e2eFolderNameInput.trim() || "e2e";
333
- const sharedTestingRelPath = sharedTestingPathInput.trim() || "shared/testing";
334
341
  const sharedTestingAbsPath = path.join(cwd, sharedTestingRelPath);
335
342
  const s = p.spinner();
336
343
  s.start("Scaffolding distributed monorepo structure and ambient types...");
337
- // 1. Centralized Root Config
338
- const rootConfigSrc = path.join(templateDir, "spectra.config.ts");
339
- const rootConfigDest = path.join(cwd, "spectra.config.ts");
340
- if (fs.existsSync(rootConfigSrc) && (!fs.existsSync(rootConfigDest) || options.force)) {
341
- fs.copyFileSync(rootConfigSrc, rootConfigDest);
344
+ // 1. Centralized Root Configs & Orchestration
345
+ const rootConfigFiles = [
346
+ "spectra.config.ts",
347
+ "tsconfig.spectra.json",
348
+ "tsconfig.spectra.web.json",
349
+ "tsconfig.spectra.android.json",
350
+ "tsconfig.spectra.ios.json",
351
+ "nx.json",
352
+ ];
353
+ for (const cf of rootConfigFiles) {
354
+ const src = path.join(templateDir, cf);
355
+ const dest = path.join(cwd, cf);
356
+ if (fs.existsSync(src) && (!fs.existsSync(dest) || options.force)) {
357
+ fs.copyFileSync(src, dest);
358
+ }
359
+ }
360
+ // Ensure root package.json has TestSpectra devDependencies
361
+ const rootPkgPath = path.join(cwd, "package.json");
362
+ if (!fs.existsSync(rootPkgPath)) {
363
+ const templatePkgSrc = path.join(templateDir, "package.json");
364
+ if (fs.existsSync(templatePkgSrc)) {
365
+ copyRecursive(templatePkgSrc, rootPkgPath);
366
+ }
367
+ }
368
+ else {
369
+ try {
370
+ const rootPkg = JSON.parse(fs.readFileSync(rootPkgPath, "utf-8"));
371
+ if (!rootPkg.devDependencies)
372
+ rootPkg.devDependencies = {};
373
+ if (!rootPkg.devDependencies["@testspectra/cli"])
374
+ rootPkg.devDependencies["@testspectra/cli"] = cliDepVersion;
375
+ if (!rootPkg.devDependencies["typescript"])
376
+ rootPkg.devDependencies["typescript"] = "^5.4.5";
377
+ if (!rootPkg.devDependencies["@wdio/globals"])
378
+ rootPkg.devDependencies["@wdio/globals"] = "^9.2.8";
379
+ if (!rootPkg.devDependencies["@wdio/mocha-framework"])
380
+ rootPkg.devDependencies["@wdio/mocha-framework"] = "^9.2.8";
381
+ if (!rootPkg.devDependencies["@types/node"])
382
+ rootPkg.devDependencies["@types/node"] = "^20.14.0";
383
+ if (!rootPkg.devDependencies["webdriverio"])
384
+ rootPkg.devDependencies["webdriverio"] = "^9.2.8";
385
+ fs.writeFileSync(rootPkgPath, JSON.stringify(rootPkg, null, 2), "utf-8");
386
+ }
387
+ catch { }
342
388
  }
343
389
  // 2. Centralized Root .testspectra folder for cache/logs
344
390
  const rootTestDataDir = path.join(cwd, ".testspectra");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testspectra/cli",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "TestSpectra Zero-Config Cross-Platform Test Runner CLI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",