@wagq/wa-cli 0.6.34 → 0.6.37-beta.0

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/config/command.js CHANGED
@@ -7,6 +7,8 @@ const batchUpdate = require("../lib/batchUpdate");
7
7
  const web2exe = require("../lib/exe");
8
8
  const skill = require("../lib/skill");
9
9
  const { generateIcon2Tsx } = require("../lib/generateIcon/tsx");
10
+ const changesetDoc = require("../lib/changesetDoc");
11
+ const vsSetting = require("../lib/vsSetting");
10
12
 
11
13
  const command = [
12
14
  {
@@ -144,6 +146,18 @@ const command = [
144
146
  ],
145
147
  action: generateIcon2Tsx,
146
148
  },
149
+ {
150
+ name: "changesetDoc [mode]",
151
+ alias: "chd",
152
+ description: "包版本管理",
153
+ action: changesetDoc,
154
+ },
155
+ {
156
+ name: "vsSetting",
157
+ alias: "vs",
158
+ description: "生成vscode配置文件",
159
+ action: vsSetting,
160
+ }
147
161
  ];
148
162
 
149
163
  module.exports = command;
@@ -0,0 +1,44 @@
1
+ const { execSync } = require("child_process");
2
+
3
+ const changesetDoc = (mode) => {
4
+ let bins = [];
5
+ switch (mode) {
6
+ case "dev":
7
+ bins.push("echo 准备启动文档预览 `n@author: wa 1224362143@qq.com");
8
+ bins.push("npx dumi dev");
9
+ break;
10
+ case "doc":
11
+ bins.push("echo 准备构建文档 `n@author: wa 1224362143@qq.com");
12
+ bins.push("npx dumi build");
13
+ break;
14
+ case "changeset":
15
+ bins.push("npx changeset");
16
+ break;
17
+ case "ver":
18
+ bins.push("npx changeset version");
19
+ break;
20
+ case "turboBuild":
21
+ bins.push("echo 准备打包 `n@author: wa 1224362143@qq.com");
22
+ bins.push("npx turbo build");
23
+ break;
24
+ case "enterBeta":
25
+ bins.push("echo 进入beta模式 `n@author: wa 1224362143@qq.com");
26
+ bins.push("npx changeset pre enter beta");
27
+ break;
28
+ case "exitBeta":
29
+ bins.push("echo 退出beta模式 `n@author: wa 1224362143@qq.com");
30
+ bins.push("npx changeset pre exit");
31
+ break;
32
+ }
33
+
34
+ if (bins.length > 0) {
35
+ bins.forEach((bin) => {
36
+ execSync(bin, {
37
+ stdio: "inherit",
38
+ cwd: process.cwd(),
39
+ });
40
+ });
41
+ }
42
+ };
43
+
44
+ module.exports = changesetDoc;
@@ -25,24 +25,19 @@ const generateIcon2Tsx = async (svgPath) => {
25
25
  shell: true,
26
26
  });
27
27
 
28
- const createIconDir = async () => {
28
+ const createDir = async (path) => {
29
29
  try {
30
- await promisify(fs.access)(reactIconDir);
30
+ await promisify(fs.access)(path);
31
31
  } catch (err) {
32
- await promisify(fs.mkdir)(reactIconDir);
32
+ await promisify(fs.mkdir)(path);
33
33
  }
34
34
  };
35
35
 
36
- const createConfigDir = async () => {
37
- try {
38
- await promisify(fs.access)(configPath);
39
- } catch (err) {
40
- await promisify(fs.mkdir)(configPath);
41
- }
42
- };
43
-
44
- await createIconDir();
45
- await createConfigDir();
36
+ await createDir(reactIconDir);
37
+ await createDir(configPath);
38
+ await createDir(outlineIconDir);
39
+ await createDir(outlineIconDir);
40
+ await createDir(fillIconDir);
46
41
 
47
42
  const outlineFiles = fs.readdirSync(outlineIconDir);
48
43
  const fillFiles = fs.readdirSync(fillIconDir);
@@ -0,0 +1,43 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const log = require("../../utils/log.js");
4
+
5
+ const settingsContent = {
6
+ "editor.codeActionsOnSave": {
7
+ "source.fixAll": "always",
8
+ "source.fixAll.eslint": "always",
9
+ },
10
+ "eslint.validate": ["typescript", "typescriptreact"],
11
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
12
+ "editor.formatOnSave": true,
13
+ "[typescriptreact]": {
14
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
15
+ },
16
+ "[typescript]": {
17
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
18
+ },
19
+ };
20
+
21
+ const initVsSetting = () => {
22
+ const targetDir = process.cwd()
23
+ try {
24
+ const vscodeDir = path.join(targetDir, ".vscode");
25
+ const settingsPath = path.join(vscodeDir, "settings.json");
26
+
27
+ if (!fs.existsSync(vscodeDir)) {
28
+ fs.mkdirSync(vscodeDir, { recursive: true });
29
+ log.info(".vscode 目录已创建");
30
+ }
31
+
32
+ fs.writeFileSync(
33
+ settingsPath,
34
+ JSON.stringify(settingsContent, null, 2),
35
+ "utf-8",
36
+ );
37
+ log.info(".vscode/settings.json 已写入");
38
+ } catch (error) {
39
+ log.error(error);
40
+ }
41
+ };
42
+
43
+ module.exports = initVsSetting;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.6.34",
3
+ "version": "0.6.37-beta.0",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {