@soybeanjs/cli 0.1.6 → 0.1.7

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
@@ -1,17 +1,54 @@
1
1
  # @soybeanjs/cli
2
2
 
3
- SoybeanJS's command lint tools
3
+ SoybeanJS 的命令行工具
4
4
 
5
- ## Usage
5
+ ## 用法
6
6
 
7
- ### install
7
+ ### 安装
8
8
 
9
9
  ```bash
10
10
  pnpm i -D @soybeanjs/cli
11
11
  ```
12
12
 
13
- ### Use command
13
+ ### 使用
14
+
15
+ 示例:
14
16
 
15
17
  ```bash
16
- pnpm soybean -h
18
+ pnpm soy -h
17
19
  ```
20
+
21
+ ## 命令介绍
22
+
23
+ | 命令 | 作用 |
24
+ | ----------------- | ---------------------------------------- |
25
+ | help | 查看全部命令用法 |
26
+ | git-commit | 生成符合 Angular 规范的 git 提交信息 |
27
+ | git-commit-verify | 校验 git 的提交信息是否符合 Angular 规范 |
28
+ | cleanup | 清空依赖和构建产物 |
29
+ | cleanup-deep | 清空依赖和构建产物(包含 深层级) |
30
+ | init-git-hooks | 初始化 simple-gi t-hooks 钩子 |
31
+ | update-pkg | 升级依赖 |
32
+ | prettier-format | prettier 格式化 |
33
+
34
+ ### prettier-format
35
+
36
+ 底层调用 prettier --write 达到格式化文件的目的
37
+
38
+ 默认忽略的格式化文件:
39
+
40
+ - js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro
41
+ > 以上文件通过 eslint 去格式化
42
+ - node_modules
43
+ - _.min._
44
+ - CHANGELOG.md
45
+ - dist
46
+ - LICENSE\*
47
+ - output
48
+ - coverage
49
+ - public
50
+ - temp
51
+ - package-lock.json
52
+ - pnpm-lock.yaml
53
+ - yarn.lock
54
+ - **snapshots**
@@ -15,6 +15,10 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
18
22
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
19
23
  mod
20
24
  ));
@@ -26,7 +30,7 @@ var import_kolorist2 = require("kolorist");
26
30
  // package.json
27
31
  var package_default = {
28
32
  name: "@soybeanjs/cli",
29
- version: "0.1.5",
33
+ version: "0.1.6",
30
34
  description: "SoybeanJS's command lint tools",
31
35
  author: {
32
36
  name: "Soybean",
@@ -42,11 +46,11 @@ var package_default = {
42
46
  url: "https://github.com/honghuangdc/soybean-cli/issues"
43
47
  },
44
48
  bin: {
45
- soybean: "dist/index.mjs",
46
- soy: "dist/index.mjs"
49
+ soybean: "bin/index.mjs",
50
+ soy: "bin/index.mjs"
47
51
  },
48
52
  files: [
49
- "dist"
53
+ "bin"
50
54
  ],
51
55
  scripts: {
52
56
  build: "tsup",
@@ -59,26 +63,25 @@ var package_default = {
59
63
  release: "pnpm update-version && pnpm publish-pkg"
60
64
  },
61
65
  dependencies: {
62
- commander: "^9.4.1",
63
- execa: "5.1.1",
64
- kolorist: "^1.6.0",
65
- minimist: "^1.2.7",
66
- "npm-check-updates": "^16.6.2",
66
+ commander: "^10.0.0",
67
+ execa: "7.0.0",
68
+ kolorist: "^1.7.0",
69
+ minimist: "^1.2.8",
70
+ "npm-check-updates": "^16.7.12",
67
71
  prompts: "^2.4.2",
68
- rimraf: "^3.0.2",
69
- zx: "^7.1.1"
72
+ rimraf: "^4.4.0"
70
73
  },
71
74
  devDependencies: {
72
75
  "@soybeanjs/cli": "workspace:*",
73
76
  "@types/prompts": "^2.4.2",
74
- bumpp: "^8.2.1",
75
- eslint: "^8.31.0",
76
- "eslint-config-soybeanjs": "0.2.1",
77
+ bumpp: "^9.0.0",
78
+ eslint: "^8.36.0",
79
+ "eslint-config-soybeanjs": "0.3.0",
77
80
  esno: "^0.16.3",
78
- "lint-staged": "^13.1.0",
81
+ "lint-staged": "^13.2.0",
79
82
  "simple-git-hooks": "^2.8.1",
80
- tsup: "^6.5.0",
81
- typescript: "^4.9.4"
83
+ tsup: "^6.6.3",
84
+ typescript: "^4.9.5"
82
85
  },
83
86
  "simple-git-hooks": {
84
87
  "commit-msg": "pnpm soybean git-commit-verify",
@@ -96,7 +99,7 @@ var package_default = {
96
99
 
97
100
  // src/command/git/commit.ts
98
101
  var import_prompts = __toESM(require("prompts"));
99
- var import_execa = __toESM(require("execa"));
102
+ var import_execa = require("execa");
100
103
 
101
104
  // src/command/git/config.ts
102
105
  var types = [
@@ -153,7 +156,7 @@ async function gitCommit() {
153
156
  }
154
157
  ]);
155
158
  const commitMsg = `${result.types}(${result.scopes}): ${result.description}`;
156
- (0, import_execa.default)("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
159
+ (0, import_execa.execa)("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
157
160
  }
158
161
 
159
162
  // src/command/git/verify-commit.ts
@@ -176,24 +179,59 @@ function verifyGitCommit() {
176
179
  }
177
180
 
178
181
  // src/scripts/cleanup.ts
179
- var import_zx = require("zx");
180
- async function cleanup() {
181
- await import_zx.$`pnpm rimraf node_modules dist package-lock.json yarn.lock pnpm-lock.yaml ./**/node_modules ./**/dist ./**/package-lock.json ./**/yarn.lock ./**/pnpm-lock.yaml`;
182
+ var import_rimraf = require("rimraf");
183
+ var pathStrs = ["node_modules", "dist", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"];
184
+ function cleanup() {
185
+ (0, import_rimraf.rimraf)(pathStrs);
186
+ }
187
+ async function cleanupDeep() {
188
+ const deepPathStrs = pathStrs.map((item) => `./**/${item}`);
189
+ const allPathStrs = pathStrs.concat(deepPathStrs);
190
+ (0, import_rimraf.rimraf)(allPathStrs);
182
191
  }
183
192
 
184
193
  // src/scripts/git-hooks.ts
185
- var import_zx2 = require("zx");
194
+ var import_fs2 = require("fs");
195
+ var import_execa2 = require("execa");
196
+ var import_rimraf2 = require("rimraf");
186
197
  async function initSimpleGitHooks() {
187
- await import_zx2.$`pnpm rimraf .husky`;
188
- await import_zx2.$`git config core.hooksPath .git/hooks/`;
189
- await import_zx2.$`rimraf .git/hooks`;
190
- await import_zx2.$`pnpm simple-git-hooks`;
198
+ const huskyDir = `${process.cwd()}/.husky`;
199
+ const existHusky = (0, import_fs2.existsSync)(huskyDir);
200
+ if (existHusky) {
201
+ await (0, import_rimraf2.rimraf)(".husky");
202
+ await (0, import_execa2.execa)("git", ["config", "core.hooksPath", ".git/hooks/"], { stdio: "inherit" });
203
+ }
204
+ await (0, import_rimraf2.rimraf)(".git/hooks");
205
+ await (0, import_execa2.execa)("npx", ["simple-git-hooks"], { stdio: "inherit" });
191
206
  }
192
207
 
193
208
  // src/scripts/update-pkg.ts
194
- var import_zx3 = require("zx");
209
+ var import_execa3 = require("execa");
195
210
  async function updatePkg() {
196
- await import_zx3.$`ncu --deep -u`;
211
+ (0, import_execa3.execa)("npx", ["ncu", "--deep", "-u"], { stdio: "inherit" });
212
+ }
213
+
214
+ // src/scripts/format.ts
215
+ var import_execa4 = require("execa");
216
+ function prettierFormat() {
217
+ const formatFiles = [
218
+ "!**/*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}",
219
+ "!*.min.*",
220
+ "!CHANGELOG.md",
221
+ "!dist",
222
+ "!LICENSE*",
223
+ "!output",
224
+ "!coverage",
225
+ "!public",
226
+ "!temp",
227
+ "!package-lock.json",
228
+ "!pnpm-lock.yaml",
229
+ "!yarn.lock",
230
+ "!__snapshots__"
231
+ ];
232
+ (0, import_execa4.execa)("npx", ["prettier", ".", "--write", ...formatFiles], {
233
+ stdio: "inherit"
234
+ });
197
235
  }
198
236
 
199
237
  // src/index.ts
@@ -204,13 +242,19 @@ import_commander.program.command("git-commit-verify").description("\u6821\u9A8Cg
204
242
  verifyGitCommit();
205
243
  });
206
244
  import_commander.program.command("cleanup").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269").action(() => {
245
+ cleanupDeep();
246
+ });
247
+ import_commander.program.command("cleanup-deep").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269(\u5305\u542B\u6DF1\u5C42\u7EA7)").action(() => {
207
248
  cleanup();
208
249
  });
209
- import_commander.program.command("init-git-hooks").description("\u521D\u59CB\u5316git\u94A9\u5B50").action(() => {
250
+ import_commander.program.command("init-git-hooks").description("\u521D\u59CB\u5316simple-git-hooks\u94A9\u5B50").action(() => {
210
251
  initSimpleGitHooks();
211
252
  });
212
253
  import_commander.program.command("update-pkg").description("\u5347\u7EA7\u4F9D\u8D56").action(() => {
213
254
  updatePkg();
214
255
  });
256
+ import_commander.program.command("prettier-format").description("prettier\u683C\u5F0F\u5316").action(() => {
257
+ prettierFormat();
258
+ });
215
259
  import_commander.program.version(package_default.version).description((0, import_kolorist2.blue)("soybean alias soy\n\nhttps://github.com/soybeanjs/cli"));
216
260
  import_commander.program.parse(process.argv);
@@ -7,7 +7,7 @@ import { blue } from "kolorist";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "@soybeanjs/cli",
10
- version: "0.1.5",
10
+ version: "0.1.6",
11
11
  description: "SoybeanJS's command lint tools",
12
12
  author: {
13
13
  name: "Soybean",
@@ -23,11 +23,11 @@ var package_default = {
23
23
  url: "https://github.com/honghuangdc/soybean-cli/issues"
24
24
  },
25
25
  bin: {
26
- soybean: "dist/index.mjs",
27
- soy: "dist/index.mjs"
26
+ soybean: "bin/index.mjs",
27
+ soy: "bin/index.mjs"
28
28
  },
29
29
  files: [
30
- "dist"
30
+ "bin"
31
31
  ],
32
32
  scripts: {
33
33
  build: "tsup",
@@ -40,26 +40,25 @@ var package_default = {
40
40
  release: "pnpm update-version && pnpm publish-pkg"
41
41
  },
42
42
  dependencies: {
43
- commander: "^9.4.1",
44
- execa: "5.1.1",
45
- kolorist: "^1.6.0",
46
- minimist: "^1.2.7",
47
- "npm-check-updates": "^16.6.2",
43
+ commander: "^10.0.0",
44
+ execa: "7.0.0",
45
+ kolorist: "^1.7.0",
46
+ minimist: "^1.2.8",
47
+ "npm-check-updates": "^16.7.12",
48
48
  prompts: "^2.4.2",
49
- rimraf: "^3.0.2",
50
- zx: "^7.1.1"
49
+ rimraf: "^4.4.0"
51
50
  },
52
51
  devDependencies: {
53
52
  "@soybeanjs/cli": "workspace:*",
54
53
  "@types/prompts": "^2.4.2",
55
- bumpp: "^8.2.1",
56
- eslint: "^8.31.0",
57
- "eslint-config-soybeanjs": "0.2.1",
54
+ bumpp: "^9.0.0",
55
+ eslint: "^8.36.0",
56
+ "eslint-config-soybeanjs": "0.3.0",
58
57
  esno: "^0.16.3",
59
- "lint-staged": "^13.1.0",
58
+ "lint-staged": "^13.2.0",
60
59
  "simple-git-hooks": "^2.8.1",
61
- tsup: "^6.5.0",
62
- typescript: "^4.9.4"
60
+ tsup: "^6.6.3",
61
+ typescript: "^4.9.5"
63
62
  },
64
63
  "simple-git-hooks": {
65
64
  "commit-msg": "pnpm soybean git-commit-verify",
@@ -77,7 +76,7 @@ var package_default = {
77
76
 
78
77
  // src/command/git/commit.ts
79
78
  import prompts from "prompts";
80
- import execa from "execa";
79
+ import { execa } from "execa";
81
80
 
82
81
  // src/command/git/config.ts
83
82
  var types = [
@@ -157,24 +156,59 @@ function verifyGitCommit() {
157
156
  }
158
157
 
159
158
  // src/scripts/cleanup.ts
160
- import { $ } from "zx";
161
- async function cleanup() {
162
- await $`pnpm rimraf node_modules dist package-lock.json yarn.lock pnpm-lock.yaml ./**/node_modules ./**/dist ./**/package-lock.json ./**/yarn.lock ./**/pnpm-lock.yaml`;
159
+ import { rimraf } from "rimraf";
160
+ var pathStrs = ["node_modules", "dist", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"];
161
+ function cleanup() {
162
+ rimraf(pathStrs);
163
+ }
164
+ async function cleanupDeep() {
165
+ const deepPathStrs = pathStrs.map((item) => `./**/${item}`);
166
+ const allPathStrs = pathStrs.concat(deepPathStrs);
167
+ rimraf(allPathStrs);
163
168
  }
164
169
 
165
170
  // src/scripts/git-hooks.ts
166
- import { $ as $2 } from "zx";
171
+ import { existsSync } from "fs";
172
+ import { execa as execa2 } from "execa";
173
+ import { rimraf as rimraf2 } from "rimraf";
167
174
  async function initSimpleGitHooks() {
168
- await $2`pnpm rimraf .husky`;
169
- await $2`git config core.hooksPath .git/hooks/`;
170
- await $2`rimraf .git/hooks`;
171
- await $2`pnpm simple-git-hooks`;
175
+ const huskyDir = `${process.cwd()}/.husky`;
176
+ const existHusky = existsSync(huskyDir);
177
+ if (existHusky) {
178
+ await rimraf2(".husky");
179
+ await execa2("git", ["config", "core.hooksPath", ".git/hooks/"], { stdio: "inherit" });
180
+ }
181
+ await rimraf2(".git/hooks");
182
+ await execa2("npx", ["simple-git-hooks"], { stdio: "inherit" });
172
183
  }
173
184
 
174
185
  // src/scripts/update-pkg.ts
175
- import { $ as $3 } from "zx";
186
+ import { execa as execa3 } from "execa";
176
187
  async function updatePkg() {
177
- await $3`ncu --deep -u`;
188
+ execa3("npx", ["ncu", "--deep", "-u"], { stdio: "inherit" });
189
+ }
190
+
191
+ // src/scripts/format.ts
192
+ import { execa as execa4 } from "execa";
193
+ function prettierFormat() {
194
+ const formatFiles = [
195
+ "!**/*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}",
196
+ "!*.min.*",
197
+ "!CHANGELOG.md",
198
+ "!dist",
199
+ "!LICENSE*",
200
+ "!output",
201
+ "!coverage",
202
+ "!public",
203
+ "!temp",
204
+ "!package-lock.json",
205
+ "!pnpm-lock.yaml",
206
+ "!yarn.lock",
207
+ "!__snapshots__"
208
+ ];
209
+ execa4("npx", ["prettier", ".", "--write", ...formatFiles], {
210
+ stdio: "inherit"
211
+ });
178
212
  }
179
213
 
180
214
  // src/index.ts
@@ -185,13 +219,19 @@ program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u6
185
219
  verifyGitCommit();
186
220
  });
187
221
  program.command("cleanup").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269").action(() => {
222
+ cleanupDeep();
223
+ });
224
+ program.command("cleanup-deep").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269(\u5305\u542B\u6DF1\u5C42\u7EA7)").action(() => {
188
225
  cleanup();
189
226
  });
190
- program.command("init-git-hooks").description("\u521D\u59CB\u5316git\u94A9\u5B50").action(() => {
227
+ program.command("init-git-hooks").description("\u521D\u59CB\u5316simple-git-hooks\u94A9\u5B50").action(() => {
191
228
  initSimpleGitHooks();
192
229
  });
193
230
  program.command("update-pkg").description("\u5347\u7EA7\u4F9D\u8D56").action(() => {
194
231
  updatePkg();
195
232
  });
233
+ program.command("prettier-format").description("prettier\u683C\u5F0F\u5316").action(() => {
234
+ prettierFormat();
235
+ });
196
236
  program.version(package_default.version).description(blue("soybean alias soy\n\nhttps://github.com/soybeanjs/cli"));
197
237
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soybeanjs/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "SoybeanJS's command lint tools",
5
5
  "author": {
6
6
  "name": "Soybean",
@@ -16,40 +16,39 @@
16
16
  "url": "https://github.com/honghuangdc/soybean-cli/issues"
17
17
  },
18
18
  "bin": {
19
- "soybean": "dist/index.mjs",
20
- "soy": "dist/index.mjs"
19
+ "soybean": "bin/index.mjs",
20
+ "soy": "bin/index.mjs"
21
21
  },
22
22
  "files": [
23
- "dist"
23
+ "bin"
24
24
  ],
25
25
  "dependencies": {
26
- "commander": "^9.4.1",
27
- "execa": "5.1.1",
28
- "kolorist": "^1.6.0",
29
- "minimist": "^1.2.7",
30
- "npm-check-updates": "^16.6.2",
26
+ "commander": "^10.0.0",
27
+ "execa": "7.0.0",
28
+ "kolorist": "^1.7.0",
29
+ "minimist": "^1.2.8",
30
+ "npm-check-updates": "^16.7.12",
31
31
  "prompts": "^2.4.2",
32
- "rimraf": "^3.0.2",
33
- "zx": "^7.1.1"
32
+ "rimraf": "^4.4.0"
34
33
  },
35
34
  "devDependencies": {
36
35
  "@types/prompts": "^2.4.2",
37
- "bumpp": "^8.2.1",
38
- "eslint": "^8.31.0",
39
- "eslint-config-soybeanjs": "0.2.1",
36
+ "bumpp": "^9.0.0",
37
+ "eslint": "^8.36.0",
38
+ "eslint-config-soybeanjs": "0.3.0",
40
39
  "esno": "^0.16.3",
41
- "lint-staged": "^13.1.0",
40
+ "lint-staged": "^13.2.0",
42
41
  "simple-git-hooks": "^2.8.1",
43
- "tsup": "^6.5.0",
44
- "typescript": "^4.9.4",
45
- "@soybeanjs/cli": "0.1.6"
42
+ "tsup": "^6.6.3",
43
+ "typescript": "^4.9.5",
44
+ "@soybeanjs/cli": "0.1.7"
46
45
  },
47
46
  "simple-git-hooks": {
48
47
  "commit-msg": "pnpm soybean git-commit-verify",
49
48
  "pre-commit": "pnpm exec lint-staged --concurrent false"
50
49
  },
51
50
  "lint-staged": {
52
- "*": [
51
+ "*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}": [
53
52
  "eslint . --fix"
54
53
  ]
55
54
  },
@@ -59,6 +58,7 @@
59
58
  "scripts": {
60
59
  "build": "tsup",
61
60
  "lint": "eslint . --fix",
61
+ "format": "soy prettier-format",
62
62
  "commit": "soy git-commit",
63
63
  "cleanup": "soy cleanup",
64
64
  "update-pkg": "soy update-pkg",
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node