qat-cli 0.2.5 → 0.2.7
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/README.md +1 -1
- package/dist/cli.js +41 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Quick Auto Testing — 面向 Vue 项目,集成 Vitest & Playwright,AI 驱动覆盖测试全流程**
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/qat-cli)
|
|
8
8
|
[](https://nodejs.org/)
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
10
10
|
[](https://www.typescriptlang.org/)
|
package/dist/cli.js
CHANGED
|
@@ -467,17 +467,20 @@ async function loadConfig(configPath, forceReload = false) {
|
|
|
467
467
|
}
|
|
468
468
|
async function importConfig(filePath) {
|
|
469
469
|
const { resolve } = await import("path");
|
|
470
|
+
const { pathToFileURL } = await import("url");
|
|
470
471
|
const absolutePath = resolve(process.cwd(), filePath);
|
|
471
472
|
if (!fs2.existsSync(absolutePath)) {
|
|
472
473
|
throw new Error(`Cannot find module '${absolutePath}'`);
|
|
473
474
|
}
|
|
475
|
+
const fileUrl = pathToFileURL(absolutePath).href;
|
|
474
476
|
try {
|
|
475
|
-
const module = await import(
|
|
477
|
+
const module = await import(fileUrl);
|
|
476
478
|
return module.default || module;
|
|
477
479
|
} catch {
|
|
478
480
|
const jsPath = absolutePath.replace(/\.ts$/, ".js");
|
|
479
|
-
if (fs2.existsSync(jsPath)) {
|
|
480
|
-
const
|
|
481
|
+
if (jsPath !== absolutePath && fs2.existsSync(jsPath)) {
|
|
482
|
+
const jsUrl = pathToFileURL(jsPath).href;
|
|
483
|
+
const module = await import(jsUrl);
|
|
481
484
|
return module.default || module;
|
|
482
485
|
}
|
|
483
486
|
throw new Error(`\u65E0\u6CD5\u52A0\u8F7D\u914D\u7F6E\u6587\u4EF6: ${absolutePath}`);
|
|
@@ -2342,14 +2345,41 @@ async function executeInit(options) {
|
|
|
2342
2345
|
}
|
|
2343
2346
|
}
|
|
2344
2347
|
const config = buildProjectConfig(projectInfo);
|
|
2345
|
-
const fileSpinner = ora2("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...").start();
|
|
2346
2348
|
let configPath;
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2349
|
+
const existingConfigPath = path7.join(process.cwd(), "qat.config.js");
|
|
2350
|
+
const existingTsPath = path7.join(process.cwd(), "qat.config.ts");
|
|
2351
|
+
const configExists = fs7.existsSync(existingConfigPath) || fs7.existsSync(existingTsPath);
|
|
2352
|
+
if (configExists && !options.force) {
|
|
2353
|
+
const { overwrite } = await inquirer.prompt([
|
|
2354
|
+
{
|
|
2355
|
+
type: "confirm",
|
|
2356
|
+
name: "overwrite",
|
|
2357
|
+
message: "\u914D\u7F6E\u6587\u4EF6 qat.config.js \u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u8986\u76D6\uFF1F",
|
|
2358
|
+
default: true
|
|
2359
|
+
}
|
|
2360
|
+
]);
|
|
2361
|
+
if (!overwrite) {
|
|
2362
|
+
console.log(chalk3.gray(" \u4FDD\u7559\u73B0\u6709\u914D\u7F6E\u6587\u4EF6\uFF0C\u7EE7\u7EED\u540E\u7EED\u6B65\u9AA4..."));
|
|
2363
|
+
configPath = existingConfigPath;
|
|
2364
|
+
} else {
|
|
2365
|
+
const fileSpinner = ora2("\u6B63\u5728\u8986\u76D6\u914D\u7F6E\u6587\u4EF6...").start();
|
|
2366
|
+
try {
|
|
2367
|
+
configPath = await writeConfigFile(process.cwd(), config, true);
|
|
2368
|
+
fileSpinner.succeed("\u914D\u7F6E\u6587\u4EF6\u5DF2\u8986\u76D6");
|
|
2369
|
+
} catch (error) {
|
|
2370
|
+
fileSpinner.fail("\u914D\u7F6E\u6587\u4EF6\u8986\u76D6\u5931\u8D25");
|
|
2371
|
+
throw error;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
} else {
|
|
2375
|
+
const fileSpinner = ora2("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...").start();
|
|
2376
|
+
try {
|
|
2377
|
+
configPath = await writeConfigFile(process.cwd(), config, options.force);
|
|
2378
|
+
fileSpinner.succeed("\u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210");
|
|
2379
|
+
} catch (error) {
|
|
2380
|
+
fileSpinner.fail("\u914D\u7F6E\u6587\u4EF6\u751F\u6210\u5931\u8D25");
|
|
2381
|
+
throw error;
|
|
2382
|
+
}
|
|
2353
2383
|
}
|
|
2354
2384
|
const dirSpinner = ora2("\u6B63\u5728\u521B\u5EFA\u6D4B\u8BD5\u76EE\u5F55...").start();
|
|
2355
2385
|
const createdDirs = createTestDirectories(config);
|
|
@@ -5463,7 +5493,7 @@ async function executeChange(_options) {
|
|
|
5463
5493
|
}
|
|
5464
5494
|
|
|
5465
5495
|
// src/cli.ts
|
|
5466
|
-
var VERSION = "0.2.
|
|
5496
|
+
var VERSION = "0.2.7";
|
|
5467
5497
|
function printLogo() {
|
|
5468
5498
|
const logo = `
|
|
5469
5499
|
${chalk12.bold.cyan(" ___ _ _ _ _ _____ _ _ ")}
|