@wagq/wa-cli 0.6.32-beta.0 → 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
@@ -123,7 +123,7 @@ const command = [
123
123
  action: skill,
124
124
  },
125
125
  {
126
- name: "generateIcon2Tsx",
126
+ name: "generateIcon2Tsx [svgPath]",
127
127
  alias: "gitsx",
128
128
  description: `
129
129
  - svg配置文件将生成在svg文件夹同级下的svgConfig中
@@ -1,30 +1,29 @@
1
1
  const { execSync } = require("child_process");
2
2
  const fs = require("fs");
3
3
  const path = require("path");
4
- const { fileURLToPath } = require("url");
5
4
  const { promisify } = require("util");
6
5
  const format = require("./prettier.js");
7
6
  const synchoronousSvgConfig = require("./synchoronousSvgConfig.js");
8
7
 
9
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
-
11
- export const generateIcon2Tsx = async (svgPath) => {
12
- execSync(svgPath, {
13
- stdio: "inherit",
14
- cwd: process.cwd(),
15
- shell: true,
16
- });
17
-
18
- const iconDir = path.join(__dirname, svgPath);
19
- const indexPath = path.join(__dirname, "../index.ts");
20
- const reactIconDir = path.join(__dirname, "../icons")
21
- const configPath = path.join(__dirname, "../svgConfig");
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");
22
14
  // 线框风格
23
15
  const outlineIconDir = path.join(iconDir, "/outline");
24
16
  // 实底风格
25
17
  const fillIconDir = path.join(iconDir, "/fill");
26
18
  // 多色风格
27
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
+ });
28
27
 
29
28
  const createIconDir = async () => {
30
29
  try {
@@ -34,7 +33,16 @@ export const generateIcon2Tsx = async (svgPath) => {
34
33
  }
35
34
  };
36
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
+
37
44
  await createIconDir();
45
+ await createConfigDir();
38
46
 
39
47
  const outlineFiles = fs.readdirSync(outlineIconDir);
40
48
  const fillFiles = fs.readdirSync(fillIconDir);
@@ -44,7 +52,7 @@ export const generateIcon2Tsx = async (svgPath) => {
44
52
  for (const file of files) {
45
53
  const fileName = file?.replace(".svg", "");
46
54
  // synchronousDoc(dirName, fileName)
47
- const svgFilePath = path.join(__srcDir, `/svgs/${dirName}/${file}`);
55
+ const svgFilePath = path.join(iconDir, `../svgs/${dirName}/${file}`);
48
56
  const fileContent = fs.readFileSync(svgFilePath, {
49
57
  encoding: "utf-8",
50
58
  });
@@ -67,7 +75,7 @@ export const generateIcon2Tsx = async (svgPath) => {
67
75
  `;
68
76
 
69
77
  const content = await format(reactContent);
70
- const tsxFilePath = `${iconDir}/${fileName}.tsx`;
78
+ const tsxFilePath = `${reactIconDir}/${fileName}.tsx`;
71
79
 
72
80
  fs.writeFileSync(tsxFilePath, content);
73
81
  }
@@ -78,3 +86,7 @@ export const generateIcon2Tsx = async (svgPath) => {
78
86
  createTsx(fillFiles, "fill");
79
87
  createTsx(twoToneFiles, "multipleTone");
80
88
  };
89
+
90
+ module.exports = {
91
+ generateIcon2Tsx,
92
+ };
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "@wagq/wa-cli",
3
- "version": "0.6.32-beta.0",
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
- }
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
+ }
@@ -1,71 +0,0 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
- const { fileURLToPath } = require('url')
4
- const { promisify } = require('util')
5
- const format = require('./prettier.js')
6
- const synchoronousSvgConfig = require('./synchoronousSvgConfig.js')
7
-
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
- const __srcDir = path.join(__dirname, '../src')
10
- const iconDir = path.join(__srcDir, '/icons')
11
- const indexPath = path.join(__srcDir, '/index.ts')
12
- let indexContent = ''
13
-
14
- const createIconDir = async () => {
15
- try {
16
- await promisify(fs.access)(iconDir)
17
- } catch (err) {
18
- await promisify(fs.mkdir)(iconDir)
19
- }
20
- }
21
-
22
- await createIconDir()
23
-
24
- // 线框风格
25
- const outlineIconDir = path.join(__dirname, '../src/svgs/outline')
26
- // 实底风格
27
- const fillIconDir = path.join(__dirname, '../src/svgs/fill')
28
- // 多色风格
29
- const twoToneIconDir = path.join(__dirname, '../src/svgs/multipleTone')
30
-
31
- const createTsx = async (files, dirName) => {
32
- for (const file of files) {
33
- const fileName = file?.replace('.svg', '')
34
- // synchronousDoc(dirName, fileName)
35
- const svgFilePath = path.join(__srcDir, `/svgs/${dirName}/${file}`)
36
- const fileContent = fs.readFileSync(svgFilePath, {
37
- encoding: 'utf-8',
38
- })
39
- const isMultiple = dirName === 'multipleTone'
40
- synchoronousSvgConfig(fileName, fileContent, isMultiple)
41
-
42
- indexContent += `;export { default as ${fileName} } from './icons/${fileName}'`
43
-
44
- const reactContent = `
45
- import IconBase from '../components/IconBase'
46
- import icon from '../svgConfig/${fileName}'
47
- import { IconProps } from '@/types'
48
-
49
- const ${fileName} = (props: IconProps) => {
50
-
51
- return <IconBase { ...props } icon={icon} />
52
- }
53
-
54
- export default ${fileName}
55
- `
56
-
57
- const content = await format(reactContent)
58
- const tsxFilePath = `${iconDir}/${fileName}.tsx`
59
-
60
- fs.writeFileSync(tsxFilePath, content)
61
- }
62
-
63
- fs.writeFileSync(indexPath, await format(indexContent))
64
- }
65
-
66
- const outlineFiles = fs.readdirSync(outlineIconDir)
67
- const fillFiles = fs.readdirSync(fillIconDir)
68
- const twoToneFiles = fs.readdirSync(twoToneIconDir)
69
- createTsx(outlineFiles, 'outline')
70
- createTsx(fillFiles, 'fill')
71
- createTsx(twoToneFiles, 'multipleTone')