@wagq/wa-cli 0.5.6 → 0.5.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.
Files changed (2) hide show
  1. package/lib/init/index.js +26 -39
  2. package/package.json +1 -1
package/lib/init/index.js CHANGED
@@ -13,9 +13,10 @@ const urls = {
13
13
  vue单页面后台: { remote: "sdmu-gaoqi/vite-vue" },
14
14
  vue多页面项目: { remote: "sdmu-gaoqi/vite-vue-multiple" },
15
15
  vite: { bin: viteBin },
16
- uniapp: { bin: uniAppBin },
16
+ 'uniapp(unibest)': { bin: uniAppBin },
17
17
  "vscode插件-vue版": { remote: "sdmu-gaoqi/vscode-plugin#vue" },
18
18
  "vscode插件-react版": { remote: "sdmu-gaoqi/vscode-plugin#react" },
19
+ 'umi': { bin: 'npx create-umi@latest' }
19
20
  };
20
21
  const modeOptions = Object.keys(urls);
21
22
 
@@ -26,50 +27,36 @@ const initQuestions = () => [
26
27
  message: `请选择模板`,
27
28
  choices: modeOptions,
28
29
  },
30
+ ];
31
+
32
+ const nameOptions = () => [
29
33
  {
30
34
  type: "input",
31
- name: "name",
32
- message: `请输入项目名(uni-app随便输入非空值)`,
33
- choices: modeOptions,
34
- },
35
- ];
35
+ name: "libraryName",
36
+ message: `请输入项目名`,
37
+ }
38
+ ] // 项目nam
36
39
 
37
40
  const init = async () => {
38
41
  try {
39
- const { name, selectMode } = await Prompt.default.prompt(initQuestions());
40
- if (name) {
41
- const { remote, bin } = urls?.[selectMode];
42
-
43
- const initByVite = bin === viteBin;
44
- const initByUniApp = bin === uniAppBin;
42
+ const { selectMode } = await Prompt.default.prompt(initQuestions());
43
+ const { remote, bin } = urls?.[selectMode];
44
+ const needName = !!remote
45
45
 
46
- if (!initByUniApp) {
47
- await check(name);
48
- }
49
-
50
- if (initByVite) {
51
- log.info("准备从vite创建");
52
- execSync(`${bin} ${name}`, {
53
- stdio: "inherit",
54
- cwd: process.cwd(),
55
- shell: true,
56
- });
57
- } else if (initByUniApp) {
58
- log.info("准备从unibest创建");
59
- execSync(bin, {
60
- stdio: "inherit",
61
- cwd: process.cwd(),
62
- shell: true,
63
- });
64
- } else {
65
- if (!remote) {
66
- throw new Error(`未找到${selectMode}模板`);
67
- }
68
- await clone(remote, name);
69
- await after(name, selectMode);
70
- }
71
- } else {
72
- log.info("程序提前结束");
46
+ if(needName) {
47
+ const { libraryName } = await Prompt.default.prompt(nameOptions());
48
+ await check(libraryName);
49
+ await clone(remote, libraryName);
50
+ await after(libraryName, selectMode);
51
+ }
52
+ else {
53
+ const info = `准备从${selectMode}创建`
54
+ log.info(info)
55
+ execSync(bin, {
56
+ stdio: "inherit",
57
+ cwd: process.cwd(),
58
+ shell: true,
59
+ });
73
60
  }
74
61
  } catch (error) {
75
62
  log.error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {