@jackie_qian/create-vue-app 1.0.0 → 1.0.1
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/utils/constants.js +2 -2
- package/dist/utils/util.js +24 -4
- package/package.json +1 -1
package/dist/utils/constants.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const FEATURES_OPTIONS = [
|
|
2
2
|
{ value: "router", label: "Router (SPA 开发)" },
|
|
3
3
|
{ value: "pinia", label: "Pinia (状态管理)" },
|
|
4
|
-
{ value: "piniaPersist", label: "Pinia 状态持久化" },
|
|
4
|
+
{ value: "piniaPersist", label: "Pinia-plugin-persistedstate (状态持久化)" },
|
|
5
5
|
{ value: "sassEmbedded", label: "SassEmbedded" },
|
|
6
|
-
{ value: "eslintAntfu", label: "ESLint (Antfu
|
|
6
|
+
{ value: "eslintAntfu", label: "ESLint (Antfu风格)" },
|
|
7
7
|
{ value: "stylelint", label: "Stylelint" },
|
|
8
8
|
{ value: "gitHooks", label: "GitHooks (simple-git-hooks + lint-staged)" },
|
|
9
9
|
];
|
package/dist/utils/util.js
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { promises as fs } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
function spawnSyncCrossPlatform(cmd, args, options) {
|
|
5
|
+
let result = spawnSync(cmd, args, options);
|
|
6
|
+
if (process.platform !== "win32") return result;
|
|
7
|
+
const code = result.error?.code;
|
|
8
|
+
if (code !== "ENOENT") return result;
|
|
9
|
+
const base = path.basename(cmd);
|
|
10
|
+
const hasPathSeparators = cmd.includes("/") || cmd.includes("\\");
|
|
11
|
+
const hasExtension = /\.[a-z0-9]+$/i.test(base);
|
|
12
|
+
if (hasPathSeparators || hasExtension) return result;
|
|
13
|
+
result = spawnSync(`${cmd}.cmd`, args, options);
|
|
14
|
+
if (result.error?.code === "ENOENT")
|
|
15
|
+
result = spawnSync(`${cmd}.exe`, args, options);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
4
18
|
export function runCapture(cmd, args, cwd) {
|
|
5
|
-
const result =
|
|
6
|
-
if (result.status !== 0)
|
|
19
|
+
const result = spawnSyncCrossPlatform(cmd, args, { cwd, encoding: "utf8" });
|
|
20
|
+
if (result.status !== 0) {
|
|
21
|
+
const detail = result.error ? `: ${result.error.message}` : "";
|
|
22
|
+
throw new Error(`${cmd} ${args.join(" ")} 执行失败${detail}`);
|
|
23
|
+
}
|
|
7
24
|
return `${result.stdout ?? ""}`.trim();
|
|
8
25
|
}
|
|
9
26
|
export function run(cmd, args, cwd) {
|
|
10
|
-
const result =
|
|
11
|
-
if (result.status !== 0)
|
|
27
|
+
const result = spawnSyncCrossPlatform(cmd, args, { cwd, stdio: "inherit" });
|
|
28
|
+
if (result.status !== 0) {
|
|
29
|
+
const detail = result.error ? `: ${result.error.message}` : "";
|
|
30
|
+
throw new Error(`${cmd} ${args.join(" ")} 执行失败${detail}`);
|
|
31
|
+
}
|
|
12
32
|
}
|
|
13
33
|
export function installCommand(pm) {
|
|
14
34
|
if (pm === "pnpm") return { cmd: "pnpm", args: ["install"] };
|