@wagq/wa-cli 0.6.31 → 0.6.32-beta.2
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
|
@@ -6,6 +6,7 @@ const asyncDamlByApp = require("../lib/daml/asyncByApp");
|
|
|
6
6
|
const batchUpdate = require("../lib/batchUpdate");
|
|
7
7
|
const web2exe = require("../lib/exe");
|
|
8
8
|
const skill = require("../lib/skill");
|
|
9
|
+
const { generateIcon2Tsx } = require("../lib/generateIcon/tsx");
|
|
9
10
|
|
|
10
11
|
const command = [
|
|
11
12
|
{
|
|
@@ -26,12 +27,11 @@ const command = [
|
|
|
26
27
|
},
|
|
27
28
|
{
|
|
28
29
|
name: "damls",
|
|
29
|
-
description:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
其中origin
|
|
33
|
-
|
|
34
|
-
appName为应用名称,也是你区分不同应用的标识,所有生成的文件都会放在appName文件夹下`,
|
|
30
|
+
description: `
|
|
31
|
+
- 同步低码文件,
|
|
32
|
+
- 可将appId,branchid,token,origin配置到~/.damlrc文件中,
|
|
33
|
+
- 其中origin为域名,格式为低码应用的location.origin
|
|
34
|
+
- 初次执行没有配置文件会自动创建`,
|
|
35
35
|
alias: "da",
|
|
36
36
|
action: () => {
|
|
37
37
|
asyncDamlByApp();
|
|
@@ -96,7 +96,7 @@ const command = [
|
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
name: "web2exe [name] [path] [icon]",
|
|
99
|
-
alias:
|
|
99
|
+
alias: "we",
|
|
100
100
|
description: "将网页打包成exe",
|
|
101
101
|
positional: [
|
|
102
102
|
{
|
|
@@ -122,6 +122,28 @@ const command = [
|
|
|
122
122
|
description: "openskills指令快速导航",
|
|
123
123
|
action: skill,
|
|
124
124
|
},
|
|
125
|
+
{
|
|
126
|
+
name: "generateIcon2Tsx [svgPath]",
|
|
127
|
+
alias: "gitsx",
|
|
128
|
+
description: `
|
|
129
|
+
- svg配置文件将生成在svg文件夹同级下的svgConfig中
|
|
130
|
+
- txs将生成在svg文件夹统计下的icons中
|
|
131
|
+
- 同时将所有icon导出到路径下index.ts文件中
|
|
132
|
+
- 将svg文件生成为数据配置与TSX文件
|
|
133
|
+
- 请谨遵 outline、multipleTone、fill 方式分类管理icon源文件,并规范icon命名后缀
|
|
134
|
+
- like AuctionMenuMultipleTone.svg AuctionMenuMultipleTone.svg AddCircleOutlined.svg
|
|
135
|
+
`,
|
|
136
|
+
positional: [
|
|
137
|
+
{
|
|
138
|
+
key: "svgPath",
|
|
139
|
+
option: {
|
|
140
|
+
describe: "svg文件夹地址",
|
|
141
|
+
type: "string",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
action: generateIcon2Tsx,
|
|
146
|
+
},
|
|
125
147
|
];
|
|
126
148
|
|
|
127
149
|
module.exports = command;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const prettier = require('prettier')
|
|
2
|
+
|
|
3
|
+
const format = async (content) => {
|
|
4
|
+
const prettierConfig = await prettier.resolveConfig(process.cwd())
|
|
5
|
+
|
|
6
|
+
const result = await prettier.format(content, { ...prettierConfig, parser: 'typescript' })
|
|
7
|
+
|
|
8
|
+
return result
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = format
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file synchoronousSvgConfig
|
|
3
|
+
* @description 读取svgConfig并生成config配置文件到packages\cartech-library\packages\icon\src\svgConfig
|
|
4
|
+
* */
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const path = require('path')
|
|
7
|
+
const svgson = require('svgson')
|
|
8
|
+
const format = require('./prettier.js')
|
|
9
|
+
|
|
10
|
+
const synchoronousSvgConfig = async (fileName, content, isMultiple, configPath) => {
|
|
11
|
+
const config = svgson.parseSync(content)
|
|
12
|
+
const filePath = path.join(configPath, `/${fileName}.ts`)
|
|
13
|
+
if (isMultiple) {
|
|
14
|
+
config.isMultiple = true
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const fileContent = await format(`
|
|
18
|
+
const ${fileName} = ${JSON.stringify(config)}
|
|
19
|
+
|
|
20
|
+
export default ${fileName}
|
|
21
|
+
`)
|
|
22
|
+
|
|
23
|
+
fs.writeFileSync(filePath, fileContent)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = synchoronousSvgConfig
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { promisify } = require("util");
|
|
5
|
+
const format = require("./prettier.js");
|
|
6
|
+
const synchoronousSvgConfig = require("./synchoronousSvgConfig.js");
|
|
7
|
+
|
|
8
|
+
const generateIcon2Tsx = async (svgPath) => {
|
|
9
|
+
const cwd = process.cwd();
|
|
10
|
+
const iconDir = path.join(cwd, svgPath);
|
|
11
|
+
const indexPath = path.join(iconDir, "../index.ts");
|
|
12
|
+
const reactIconDir = path.join(iconDir, "../icons");
|
|
13
|
+
const configPath = path.join(iconDir, "../svgConfig");
|
|
14
|
+
// 线框风格
|
|
15
|
+
const outlineIconDir = path.join(iconDir, "/outline");
|
|
16
|
+
// 实底风格
|
|
17
|
+
const fillIconDir = path.join(iconDir, "/fill");
|
|
18
|
+
// 多色风格
|
|
19
|
+
const twoToneIconDir = path.join(iconDir, "/multipleTone");
|
|
20
|
+
let indexContent = "";
|
|
21
|
+
|
|
22
|
+
execSync(`rimraf ${reactIconDir}`, {
|
|
23
|
+
stdio: "inherit",
|
|
24
|
+
cwd: cwd,
|
|
25
|
+
shell: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const createIconDir = async () => {
|
|
29
|
+
try {
|
|
30
|
+
await promisify(fs.access)(reactIconDir);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
await promisify(fs.mkdir)(reactIconDir);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
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();
|
|
46
|
+
|
|
47
|
+
const outlineFiles = fs.readdirSync(outlineIconDir);
|
|
48
|
+
const fillFiles = fs.readdirSync(fillIconDir);
|
|
49
|
+
const twoToneFiles = fs.readdirSync(twoToneIconDir);
|
|
50
|
+
|
|
51
|
+
const createTsx = async (files, dirName) => {
|
|
52
|
+
for (const file of files) {
|
|
53
|
+
const fileName = file?.replace(".svg", "");
|
|
54
|
+
// synchronousDoc(dirName, fileName)
|
|
55
|
+
const svgFilePath = path.join(iconDir, `../svgs/${dirName}/${file}`);
|
|
56
|
+
const fileContent = fs.readFileSync(svgFilePath, {
|
|
57
|
+
encoding: "utf-8",
|
|
58
|
+
});
|
|
59
|
+
const isMultiple = dirName === "multipleTone";
|
|
60
|
+
synchoronousSvgConfig(fileName, fileContent, isMultiple, configPath);
|
|
61
|
+
|
|
62
|
+
indexContent += `;export { default as ${fileName} } from './icons/${fileName}'`;
|
|
63
|
+
|
|
64
|
+
const reactContent = `
|
|
65
|
+
import IconBase from '../components/IconBase'
|
|
66
|
+
import icon from '../svgConfig/${fileName}'
|
|
67
|
+
import { IconProps } from '@/types'
|
|
68
|
+
|
|
69
|
+
const ${fileName} = (props: IconProps) => {
|
|
70
|
+
|
|
71
|
+
return <IconBase { ...props } icon={icon} />
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default ${fileName}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
const content = await format(reactContent);
|
|
78
|
+
const tsxFilePath = `${reactIconDir}/${fileName}.tsx`;
|
|
79
|
+
|
|
80
|
+
fs.writeFileSync(tsxFilePath, content);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fs.writeFileSync(indexPath, await format(indexContent));
|
|
84
|
+
};
|
|
85
|
+
createTsx(outlineFiles, "outline");
|
|
86
|
+
createTsx(fillFiles, "fill");
|
|
87
|
+
createTsx(twoToneFiles, "multipleTone");
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
module.exports = {
|
|
91
|
+
generateIcon2Tsx,
|
|
92
|
+
};
|
package/package.json
CHANGED
|
@@ -1,48 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wagq/wa-cli",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "wa的脚手架",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"pub": "npm publish --access public --registry=https://registry.npmjs.org",
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@wagq/wa-cli",
|
|
3
|
+
"version": "0.6.32-beta.2",
|
|
4
|
+
"description": "wa的脚手架",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"pub": "npm publish --access public --registry=https://registry.npmjs.org",
|
|
9
|
+
"pub:beta": "npm publish --tag beta --access public --registry=https://registry.npmjs.org",
|
|
10
|
+
"dev": "node ./bin/wa.js"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
"cert": "./config/cert.pem",
|
|
14
|
+
"key": "./config/key.pem"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"wa的脚手架"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"wa": "bin/wa.js"
|
|
21
|
+
},
|
|
22
|
+
"author": "GQ-og",
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/sdmu-gaoqi/wa-cli"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"chalk": "^3.0.0",
|
|
34
|
+
"child_process": "^1.0.2",
|
|
35
|
+
"commander": "^13.1.0",
|
|
36
|
+
"compare-versions": "^6.1.1",
|
|
37
|
+
"download-git-repo": "^3.0.2",
|
|
38
|
+
"glob": "^11.0.1",
|
|
39
|
+
"http-server": "^14.1.1",
|
|
40
|
+
"inquirer": "^12.4.1",
|
|
41
|
+
"minimist": "^1.2.8",
|
|
42
|
+
"ora": "^4.0.3",
|
|
43
|
+
"prettier": "^3.5.3",
|
|
44
|
+
"xlsx": "^0.18.5"
|
|
45
|
+
},
|
|
46
|
+
"directories": {
|
|
47
|
+
"lib": "lib"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"rimraf": "^6.1.3",
|
|
51
|
+
"svgson": "^5.3.1"
|
|
52
|
+
}
|
|
53
|
+
}
|