@zibby/cli 0.1.6 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Zibby CLI - Test automation generator and runner",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,10 +37,9 @@
37
37
  "chalk": "^5.3.0",
38
38
  "commander": "^12.0.0",
39
39
  "dotenv": "^17.2.3",
40
- "glob": "^10.3.10",
40
+ "glob": "^11.0.0",
41
41
  "handlebars": "^4.7.8",
42
42
  "inquirer": "^13.3.0",
43
- "node-fetch": "^3.3.2",
44
43
  "open": "^10.2.0",
45
44
  "ora": "^8.0.1"
46
45
  },
@@ -205,10 +205,21 @@ export async function initCommand(projectName, options) {
205
205
  }
206
206
  }
207
207
 
208
- // Only create package.json if new project
208
+ // Create package.json for new projects, or ensure "type": "module" in existing ones
209
209
  if (isNewProject) {
210
210
  const packageJsonContent = generatePackageJson(projectNameActual, answers);
211
211
  await writeFile(join(targetDir, 'package.json'), packageJsonContent);
212
+ } else if (!existsSync(join(targetDir, 'package.json'))) {
213
+ const minimalPkg = JSON.stringify({ type: 'module', private: true }, null, 2);
214
+ await writeFile(join(targetDir, 'package.json'), minimalPkg);
215
+ } else {
216
+ try {
217
+ const existingPkg = JSON.parse(await readFile(join(targetDir, 'package.json'), 'utf-8'));
218
+ if (!existingPkg.type) {
219
+ existingPkg.type = 'module';
220
+ await writeFile(join(targetDir, 'package.json'), JSON.stringify(existingPkg, null, 2));
221
+ }
222
+ } catch { /* leave existing package.json alone if unparseable */ }
212
223
  }
213
224
 
214
225
  // Create .gitignore if doesn't exist
@@ -5,7 +5,6 @@ import { glob } from 'glob';
5
5
  import chalk from 'chalk';
6
6
  import ora from 'ora';
7
7
  import dotenv from 'dotenv';
8
- import fetch from 'node-fetch';
9
8
  import open from 'open';
10
9
  import { getApiUrl, getAccountApiUrl, getCurrentEnvironment, getFrontendUrl } from '../config/environments.js';
11
10
  import { getSessionToken, getUserInfo } from '../config/config.js';
@@ -25,6 +24,21 @@ envFiles.forEach(envFile => {
25
24
  }
26
25
  });
27
26
 
27
+ function ensureEsmPackageJson(dir) {
28
+ const pkgPath = resolve(dir, 'package.json');
29
+ try {
30
+ if (existsSync(pkgPath)) {
31
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
32
+ if (!pkg.type) {
33
+ pkg.type = 'module';
34
+ writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
35
+ }
36
+ } else {
37
+ writeFileSync(pkgPath, JSON.stringify({ type: 'module', private: true }, null, 2) + '\n');
38
+ }
39
+ } catch { /* leave it alone */ }
40
+ }
41
+
28
42
  function getGeneratedTestPath(specPath, config) {
29
43
  const specsDir = config?.paths?.specs || 'test-specs';
30
44
  const generatedDir = config?.paths?.generated || 'tests';
@@ -576,6 +590,7 @@ export async function runCommand(specPath, options) {
576
590
  playwrightArtifacts: true, // Enable trace.zip generation for exact selectors
577
591
  };
578
592
 
593
+ ensureEsmPackageJson(process.cwd());
579
594
  const configPath = resolve(process.cwd(), options.config);
580
595
  if (existsSync(configPath)) {
581
596
  try {
@@ -603,6 +618,8 @@ export async function runCommand(specPath, options) {
603
618
  };
604
619
  } catch (_error) {
605
620
  console.log(chalk.yellow(`⚠️ Could not load config from ${options.config}`));
621
+ config.agent = { provider: options.agent || 'claude' };
622
+ config.cloudSync = false;
606
623
  }
607
624
  } else {
608
625
  // No config file, use defaults