@wagq/wa-cli 0.6.33 → 0.6.36

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 CHANGED
@@ -20,35 +20,45 @@ wa --help
20
20
 
21
21
  ### init
22
22
 
23
- - **作用**:项目初始化工具
24
- - **用法**:`wa init <name>`
25
- - **别名**:`wa i <name>`
23
+ - **作用**:项目初始化工具,交互式选择模板创建项目
24
+ - **用法**:`wa init`
25
+ - **别名**:`wa i`
26
+ - **可选模板**
27
+ - `vue单页面后台` — 从 GitHub 仓库 `sdmu-gaoqi/vite-vue` 克隆
28
+ - `vue多页面项目` — 从 GitHub 仓库 `sdmu-gaoqi/vite-vue-multiple` 克隆
29
+ - `React` — 支持 SPA / 微前端基座 / 微前端子应用
30
+ - `vite` — 调用 `npm create vite@latest`
31
+ - `uniapp(unibest)` — 调用 `npm create unibest`
32
+ - `vscode插件-vue版` / `vscode插件-react版`
33
+ - `umi` — 调用 `npx create-umi@latest`
34
+ - `react-native` — 调用 `npx create-expo-app --template`
26
35
 
27
36
  ```bash
28
- wa init my-app
37
+ wa init
38
+ wa i
29
39
  ```
30
40
 
31
41
  ### server
32
42
 
33
- - **作用**:启动本地静态服务
43
+ - **作用**:启动本地静态服务(基于 `http-server`)
34
44
  - **用法**:`wa server [path]`
35
45
  - **别名**:`wa s [path]`
36
46
  - **位置参数**
37
47
  - `path`:文件路径,默认 `dist`
38
48
  - **选项**
39
- - `-P, --port <port>`:端口
40
- - `-S, --https <boolean>`:是否开启 https
49
+ - `-P, --port <port>`:端口(默认 `3000`)
50
+ - `-S, --https <boolean>`:是否开启 https,开启后会提示输入证书/私钥路径(也可使用 CLI 自带证书)
41
51
 
42
52
  ```bash
43
53
  wa server
44
- wa server dist -P 3000 -S true
54
+ wa s dist -P 3000 -S true
45
55
  ```
46
56
 
47
57
  ### xlsx2Config
48
58
 
49
59
  - **作用**:xlsx 文件转多语言配置
50
- - **用法**:`wa xlsx2Config <path> <name> <ext>`
51
- - **别名**:`wa l <path> <name> <ext>`
60
+ - **用法**:`wa xlsx2Config [path] [name] [ext]`
61
+ - **别名**:`wa l [path] [name] [ext]`
52
62
  - **位置参数**
53
63
  - `path`:文件路径
54
64
  - `name`:xlsx 文件名称
@@ -60,12 +70,16 @@ wa xlsx2Config ./locale excel.xlsx json
60
70
 
61
71
  ### daml
62
72
 
63
- - **作用**:同步低代码逻辑器文件
73
+ - **作用**:交互式同步低代码逻辑器文件(需在项目根目录提供 `scripts/asyncDamlFetch.js`)
64
74
  - **用法**:`wa daml`
65
75
  - **别名**:`wa d`
76
+ - **交互选项**
77
+ - 备注信息(文件夹名称,默认 `asyncData`)
78
+ - 同步数据类型:`逻辑编辑器` / `变量编辑器` / `变量与逻辑`
66
79
 
67
80
  ```bash
68
81
  wa daml
82
+ wa d
69
83
  ```
70
84
 
71
85
  ### damls
@@ -73,39 +87,45 @@ wa daml
73
87
  - **作用**:从应用同步所有页面的逻辑器与变量值
74
88
  - **用法**:`wa damls`
75
89
  - **别名**:`wa da`
76
- - **配置**:可将 `appId`、`branchid`、`token` 写入 `~/.damlrc`(数组形式)
90
+ - **配置**:在项目根目录创建 `.damlrc.json`(数组形式),初次执行会自动生成模板文件
77
91
 
78
- `~/.damlrc` 示例(JSON):
92
+ `.damlrc.json` 示例:
79
93
 
80
94
  ```json
81
95
  [
82
96
  {
97
+ "appName": "my-app",
83
98
  "origin": "https://example.com",
84
99
  "appId": "xxx",
85
100
  "branchid": "yyy",
86
- "token": "zzz",
87
- "appName": "my-app"
101
+ "token": "zzz"
88
102
  }
89
103
  ]
90
104
  ```
91
105
 
92
106
  - **字段说明**
93
- - `origin`:请求域名(`/api/assembler/page/list` 页面列表接口域名)
94
- - `appId` / `branchid` / `token`:请求参数
95
- - `appName`:应用名称(区分不同应用的标识);生成的文件会放在以 `appName` 命名的文件夹下
107
+ - `origin`:低代码平台域名
108
+ - `appId` / `branchid` / `token`:接口鉴权参数
109
+ - `appName`:应用名称(生成的文件会放在以 `appName` 命名的文件夹下)
110
+ - **交互选项**
111
+ - 是否将目录加入 `.gitignore`
112
+ - 是否使用 prettier 格式化代码
96
113
 
97
114
  ```bash
98
115
  wa damls
116
+ wa da
99
117
  ```
100
118
 
101
119
  ### batchUpdate
102
120
 
103
- - **作用**:批量升级依赖包(可指定组织,只更新组织下的依赖)
121
+ - **作用**:批量升级依赖包,可指定组织范围
104
122
  - **用法**:`wa batchUpdate`
105
123
  - **别名**:`wa bu`
124
+ - **交互**:输入需要更新的包组织前缀(如 `@wagq`),会自动更新 `dependencies` 中匹配该前缀的依赖
106
125
 
107
126
  ```bash
108
127
  wa batchUpdate
128
+ wa bu
109
129
  ```
110
130
 
111
131
  ### web2exe
@@ -115,7 +135,7 @@ wa batchUpdate
115
135
  - **别名**:`wa we <name> <path> [icon]`
116
136
  - **参数说明**
117
137
  - `name`:应用名称
118
- - `path`:网页地址或本地 `html` 文件路径(会透传给 `nativefier`)
138
+ - `path`:网页地址或本地 `html` 文件路径(透传给 `nativefier`)
119
139
  - `icon`:图标路径(可选)
120
140
 
121
141
  ```bash
@@ -124,13 +144,32 @@ wa web2exe MyApp https://example.com ./icon.ico
124
144
 
125
145
  ### skills
126
146
 
127
- - **作用**:交互选择并执行与 `openskills` 相关的常用命令(需本机可执行 `npx`)
147
+ - **作用**:交互选择并执行 `openskills` 相关命令
128
148
  - **用法**:`wa skills`
129
149
  - **别名**:`wa sk`
130
150
  - **交互选项**
131
- - `getList`:执行 `npx openskills install anthropics/skills`
132
- - `sync`:执行 `npx openskills sync`
151
+ - `getList` — 执行 `npx openskills install anthropics/skills`
152
+ - `sync` — 执行 `npx openskills sync`
133
153
 
134
154
  ```bash
135
155
  wa skills
156
+ wa sk
157
+ ```
158
+
159
+ ### generateIcon2Tsx
160
+
161
+ - **作用**:将 SVG 图标文件批量生成 TSX React 组件与配置文件
162
+ - **用法**:`wa generateIcon2Tsx <svgPath>`
163
+ - **别名**:`wa gitsx <svgPath>`
164
+ - **参数说明**
165
+ - `svgPath`:SVG 文件夹地址(需包含 `outline/`、`fill/`、`multipleTone/` 子目录)
166
+ - **输出**
167
+ - `svgConfig/` — SVG 数据配置文件
168
+ - `icons/` — 生成的 TSX 组件
169
+ - `index.ts` — 所有图标统一导出入口
170
+ - **命名规范**:SVG 文件需按 `outline`、`multipleTone`、`fill` 风格分类存放,并规范后缀命名,如 `AuctionMenuMultipleTone.svg`、`AddCircleOutlined.svg`
171
+
172
+ ```bash
173
+ wa generateIcon2Tsx ./svgs
174
+ wa gitsx ./svgs
136
175
  ```
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("dumi dev");
9
+ break;
10
+ case "doc":
11
+ bins.push('echo "准备构建文档 `n@author: wa 1224362143@qq.com"');
12
+ bins.push("dumi build");
13
+ break;
14
+ case "changeset":
15
+ bins.push("changeset");
16
+ break;
17
+ case "ver":
18
+ bins.push("changeset version");
19
+ break;
20
+ case "turboBuild":
21
+ bins.push('echo "准备打包 `n@author: wa 1224362143@qq.com"');
22
+ bins.push("turbo build");
23
+ break;
24
+ case "enterBeta":
25
+ bins.push('echo "进入beta模式 `n@author: wa 1224362143@qq.com"');
26
+ bins.push("changeset pre enter beta");
27
+ break;
28
+ case "exitBeta":
29
+ bins.push('echo "退出beta模式 `n@author: wa 1224362143@qq.com"');
30
+ bins.push("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,42 @@
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 = (targetDir = process.cwd()) => {
22
+ try {
23
+ const vscodeDir = path.join(targetDir, ".vscode");
24
+ const settingsPath = path.join(vscodeDir, "settings.json");
25
+
26
+ if (!fs.existsSync(vscodeDir)) {
27
+ fs.mkdirSync(vscodeDir, { recursive: true });
28
+ log.info(".vscode 目录已创建");
29
+ }
30
+
31
+ fs.writeFileSync(
32
+ settingsPath,
33
+ JSON.stringify(settingsContent, null, 2),
34
+ "utf-8",
35
+ );
36
+ log.info(".vscode/settings.json 已写入");
37
+ } catch (error) {
38
+ log.error(error);
39
+ }
40
+ };
41
+
42
+ module.exports = initVsSetting;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.6.33",
3
+ "version": "0.6.36",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {