@wagq/wa-cli 0.6.15 → 0.6.16

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/lib/init/after.js CHANGED
@@ -41,16 +41,12 @@ const initHusky = (packageName) => {
41
41
  log.error("Husky 命令安装失败: \n" + error);
42
42
  }
43
43
  try {
44
+ execSync('echo "npx lint-staged" > .husky/pre-commit', execConfig);
44
45
  execSync(
45
- 'npx --no-install husky add .husky/pre-commit "npx lint-staged"',
46
+ 'echo "npx --no -- commitlint --edit ${1}" > .husky/commit-msg',
46
47
  execConfig
47
48
  );
48
- execSync(
49
- "npx --no-install husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'",
50
- execConfig
51
- );
52
- log.info("Husky 初始化完成");
53
- execSync(`code ${packageName}`, { cwd: cmdPath });
49
+ log.info(`Husky 初始化完成, 可打开${packageName}查看`);
54
50
  } catch (error) {
55
51
  log.error("Husky 命令写入失败: \n" + error);
56
52
  }
@@ -58,8 +54,9 @@ const initHusky = (packageName) => {
58
54
 
59
55
  const firstCommit = async (packageName) => {
60
56
  const execConfig = { cwd: `${cmdPath}/${packageName}` };
57
+ await execSync("git init", execConfig);
61
58
  await execSync("git add .", execConfig);
62
- await execSync("git commit -m 'feat: 初始化项目' --no-verify", execConfig);
59
+ await execSync(`git commit -m "feat: 初始化项目" --no-verify`, execConfig);
63
60
  };
64
61
 
65
62
  const installLibrary = async (packageName) => {
package/lib/init/index.js CHANGED
@@ -12,12 +12,26 @@ const uniAppBin = "npm create unibest";
12
12
  const urls = {
13
13
  vue单页面后台: { remote: "sdmu-gaoqi/vite-vue" },
14
14
  vue多页面项目: { remote: "sdmu-gaoqi/vite-vue-multiple" },
15
+ React: { key: "react" },
15
16
  vite: { bin: viteBin },
16
- 'uniapp(unibest)': { bin: uniAppBin },
17
+ "uniapp(unibest)": { bin: uniAppBin },
17
18
  "vscode插件-vue版": { remote: "sdmu-gaoqi/vscode-plugin#vue" },
18
19
  "vscode插件-react版": { remote: "sdmu-gaoqi/vscode-plugin#react" },
19
- 'umi': { bin: 'npx create-umi@latest' }
20
+ umi: { bin: "npx create-umi@latest" },
20
21
  };
22
+
23
+ const reactRepoMap = {
24
+ SPA: {
25
+ remote: "direct:https://gitee.com/wa_6/template-vite-react.git#template",
26
+ },
27
+ 微前端基座: {
28
+ remote: "direct:https://gitee.com/GQ-og/templat-qk-main.git#template",
29
+ },
30
+ 微前端子应用: {
31
+ remote: "direct:https://gitee.com/GQ-og/template-qk-module.git#template",
32
+ },
33
+ };
34
+
21
35
  const modeOptions = Object.keys(urls);
22
36
 
23
37
  const initQuestions = () => [
@@ -34,24 +48,44 @@ const nameOptions = () => [
34
48
  type: "input",
35
49
  name: "libraryName",
36
50
  message: `请输入项目名`,
37
- }
38
- ] // 项目nam
51
+ },
52
+ ]; // 项目nam
53
+
54
+ const reactOptions = [
55
+ {
56
+ type: "list",
57
+ name: "reactMode",
58
+ message: `请选择分支`,
59
+ choices: Object.keys(reactRepoMap),
60
+ },
61
+ ];
39
62
 
40
63
  const init = async () => {
41
64
  try {
42
65
  const { selectMode } = await Prompt.default.prompt(initQuestions());
43
- const { remote, bin } = urls?.[selectMode];
44
- const needName = !!remote
66
+ const { remote, bin, key } = urls?.[selectMode];
67
+ let repoRemote = remote;
68
+ const isReact = key === "react";
69
+ const needName = !!remote || isReact;
70
+ const cloneOptions = {};
71
+
72
+ if (isReact) {
73
+ const { reactMode } = await Prompt.default.prompt(reactOptions);
74
+ repoRemote = reactRepoMap[reactMode].remote;
75
+ cloneOptions.clone = true;
76
+ }
45
77
 
46
- if(needName) {
78
+ if (needName) {
47
79
  const { libraryName } = await Prompt.default.prompt(nameOptions());
80
+ if (!repoRemote) {
81
+ log.error("仓库正在建设中,请先选择其他模板");
82
+ }
48
83
  await check(libraryName);
49
- await clone(remote, libraryName);
84
+ await clone(repoRemote, libraryName, cloneOptions);
50
85
  await after(libraryName, selectMode);
51
- }
52
- else {
53
- const info = `准备从${selectMode}创建`
54
- log.info(info)
86
+ } else {
87
+ const info = `准备从${selectMode}创建`;
88
+ log.info(info);
55
89
  execSync(bin, {
56
90
  stdio: "inherit",
57
91
  cwd: process.cwd(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.6.15",
3
+ "version": "0.6.16",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {