intellitester 0.2.53 → 0.2.55
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/cli/index.cjs +35 -1
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +35 -1
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -1329,6 +1329,20 @@ var detectPackageManager = async () => {
|
|
|
1329
1329
|
if (await fileExists("yarn.lock")) return "yarn";
|
|
1330
1330
|
return "npm";
|
|
1331
1331
|
};
|
|
1332
|
+
var getAvailableScript = async (cwd, ...scriptNames) => {
|
|
1333
|
+
try {
|
|
1334
|
+
const pkgJsonPath = path4__namespace.default.join(cwd, "package.json");
|
|
1335
|
+
const pkgJson = await fs3__default.default.readFile(pkgJsonPath, "utf8");
|
|
1336
|
+
const pkg = JSON.parse(pkgJson);
|
|
1337
|
+
if (!pkg.scripts) return null;
|
|
1338
|
+
for (const name of scriptNames) {
|
|
1339
|
+
if (name in pkg.scripts) return name;
|
|
1340
|
+
}
|
|
1341
|
+
return null;
|
|
1342
|
+
} catch {
|
|
1343
|
+
return null;
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1332
1346
|
var execCommand = async (cmd, args, cwd) => {
|
|
1333
1347
|
return new Promise((resolve2, reject) => {
|
|
1334
1348
|
console.log(`Running: ${cmd} ${args.join(" ")}`);
|
|
@@ -1349,7 +1363,27 @@ var buildAndPreview = async (config, cwd, freshBuild = false) => {
|
|
|
1349
1363
|
const previewConfig = config?.preview || {};
|
|
1350
1364
|
const buildCmd = previewConfig.build?.command || `${pm} run build`;
|
|
1351
1365
|
const [buildExec, ...buildArgs] = buildCmd.split(" ");
|
|
1352
|
-
|
|
1366
|
+
let previewCmd;
|
|
1367
|
+
if (previewConfig.preview?.command) {
|
|
1368
|
+
previewCmd = previewConfig.preview.command;
|
|
1369
|
+
} else if (config?.webServer?.command) {
|
|
1370
|
+
previewCmd = config.webServer.command;
|
|
1371
|
+
} else {
|
|
1372
|
+
const availableScript = await getAvailableScript(cwd, "preview", "dev");
|
|
1373
|
+
if (!availableScript) {
|
|
1374
|
+
throw new Error(
|
|
1375
|
+
`No preview command configured and no "preview" or "dev" script found in package.json.
|
|
1376
|
+
Either add a script to package.json, or configure in intellitester.yaml:
|
|
1377
|
+
|
|
1378
|
+
webServer:
|
|
1379
|
+
command: "${pm} run dev" # or your preview command`
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
if (availableScript === "dev") {
|
|
1383
|
+
console.log(`No "preview" script found, falling back to "dev" script`);
|
|
1384
|
+
}
|
|
1385
|
+
previewCmd = `${pm} run ${availableScript}`;
|
|
1386
|
+
}
|
|
1353
1387
|
const [previewExec, ...previewArgs] = previewCmd.split(" ");
|
|
1354
1388
|
const previewUrl = previewConfig.url || config?.webServer?.url || config?.platforms?.web?.baseUrl || "http://localhost:4321";
|
|
1355
1389
|
const timeout = previewConfig.timeout || 6e4;
|