@soybeanjs/cli 0.0.1

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 ADDED
@@ -0,0 +1,17 @@
1
+ # @soybeanjs/cli
2
+
3
+ SoybeanJS's command lint tools
4
+
5
+ ## Usage
6
+
7
+ ### install
8
+
9
+ ```bash
10
+ pnpm i -D @soybeanjs/cli
11
+ ```
12
+
13
+ ### Use command
14
+
15
+ ```bash
16
+ pnpm soybean -h
17
+ ```
package/dist/commit.js ADDED
@@ -0,0 +1,80 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
17
+ mod
18
+ ));
19
+
20
+ // src/commit.ts
21
+ var import_prompts = __toESM(require("prompts"));
22
+ var import_execa = __toESM(require("execa"));
23
+
24
+ // src/config.ts
25
+ var types = [
26
+ { value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" },
27
+ { value: "feat", title: "feat: \u6DFB\u52A0\u65B0\u7279\u6027" },
28
+ { value: "fix", title: "fix: \u4FEE\u590Dbug" },
29
+ { value: "docs", title: "docs: \u4EC5\u4EC5\u4FEE\u6539\u6587\u6863" },
30
+ { value: "style", title: "style: \u4EC5\u4EC5\u4FEE\u6539\u4E86\u7A7A\u683C\u3001\u683C\u5F0F\u7F29\u8FDB\u3001\u9017\u53F7\u7B49\u7B49\uFF0C\u4E0D\u6539\u53D8\u4EE3\u7801\u903B\u8F91" },
31
+ { value: "refactor", title: "refactor: \u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug" },
32
+ { value: "perf", title: "perf: \u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C" },
33
+ { value: "test", title: "test: \u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B" },
34
+ { value: "build", title: "build: \u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9" },
35
+ { value: "ci", title: "ci: CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539" },
36
+ { value: "chore", title: "chore: \u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49" },
37
+ { value: "revert", title: "revert: \u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C" }
38
+ ];
39
+ var scopes = [
40
+ ["projects", "\u9879\u76EE\u642D\u5EFA"],
41
+ ["components", "\u7EC4\u4EF6\u76F8\u5173"],
42
+ ["hooks", "hook \u76F8\u5173"],
43
+ ["utils", "utils \u76F8\u5173"],
44
+ ["types", "ts\u7C7B\u578B\u76F8\u5173"],
45
+ ["styles", "\u6837\u5F0F\u76F8\u5173"],
46
+ ["deps", "\u9879\u76EE\u4F9D\u8D56"],
47
+ ["auth", "\u5BF9 auth \u4FEE\u6539"],
48
+ ["other", "\u5176\u4ED6\u4FEE\u6539"]
49
+ ].map(([value, description]) => {
50
+ return {
51
+ value,
52
+ title: `${value.padEnd(30)} (${description})`
53
+ };
54
+ });
55
+
56
+ // src/commit.ts
57
+ async function init() {
58
+ const result = await (0, import_prompts.default)([
59
+ {
60
+ name: "types",
61
+ type: "select",
62
+ message: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7684\u7C7B\u578B",
63
+ choices: types
64
+ },
65
+ {
66
+ name: "scopes",
67
+ type: "select",
68
+ message: "\u9009\u62E9\u4E00\u4E2Ascope",
69
+ choices: scopes
70
+ },
71
+ {
72
+ name: "description",
73
+ type: "text",
74
+ message: "\u8BF7\u8F93\u5165\u63D0\u4EA4\u63CF\u8FF0"
75
+ }
76
+ ]);
77
+ const commitMsg = `${result.types}(${result.scopes}): ${result.description}`;
78
+ await (0, import_execa.default)("git", ["commit", "-m", commitMsg]);
79
+ }
80
+ init();
@@ -0,0 +1,61 @@
1
+ // src/commit.ts
2
+ import promptos from "prompts";
3
+ import execa from "execa";
4
+
5
+ // src/config.ts
6
+ var types = [
7
+ { value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" },
8
+ { value: "feat", title: "feat: \u6DFB\u52A0\u65B0\u7279\u6027" },
9
+ { value: "fix", title: "fix: \u4FEE\u590Dbug" },
10
+ { value: "docs", title: "docs: \u4EC5\u4EC5\u4FEE\u6539\u6587\u6863" },
11
+ { value: "style", title: "style: \u4EC5\u4EC5\u4FEE\u6539\u4E86\u7A7A\u683C\u3001\u683C\u5F0F\u7F29\u8FDB\u3001\u9017\u53F7\u7B49\u7B49\uFF0C\u4E0D\u6539\u53D8\u4EE3\u7801\u903B\u8F91" },
12
+ { value: "refactor", title: "refactor: \u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug" },
13
+ { value: "perf", title: "perf: \u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C" },
14
+ { value: "test", title: "test: \u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B" },
15
+ { value: "build", title: "build: \u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9" },
16
+ { value: "ci", title: "ci: CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539" },
17
+ { value: "chore", title: "chore: \u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49" },
18
+ { value: "revert", title: "revert: \u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C" }
19
+ ];
20
+ var scopes = [
21
+ ["projects", "\u9879\u76EE\u642D\u5EFA"],
22
+ ["components", "\u7EC4\u4EF6\u76F8\u5173"],
23
+ ["hooks", "hook \u76F8\u5173"],
24
+ ["utils", "utils \u76F8\u5173"],
25
+ ["types", "ts\u7C7B\u578B\u76F8\u5173"],
26
+ ["styles", "\u6837\u5F0F\u76F8\u5173"],
27
+ ["deps", "\u9879\u76EE\u4F9D\u8D56"],
28
+ ["auth", "\u5BF9 auth \u4FEE\u6539"],
29
+ ["other", "\u5176\u4ED6\u4FEE\u6539"]
30
+ ].map(([value, description]) => {
31
+ return {
32
+ value,
33
+ title: `${value.padEnd(30)} (${description})`
34
+ };
35
+ });
36
+
37
+ // src/commit.ts
38
+ async function init() {
39
+ const result = await promptos([
40
+ {
41
+ name: "types",
42
+ type: "select",
43
+ message: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7684\u7C7B\u578B",
44
+ choices: types
45
+ },
46
+ {
47
+ name: "scopes",
48
+ type: "select",
49
+ message: "\u9009\u62E9\u4E00\u4E2Ascope",
50
+ choices: scopes
51
+ },
52
+ {
53
+ name: "description",
54
+ type: "text",
55
+ message: "\u8BF7\u8F93\u5165\u63D0\u4EA4\u63CF\u8FF0"
56
+ }
57
+ ]);
58
+ const commitMsg = `${result.types}(${result.scopes}): ${result.description}`;
59
+ await execa("git", ["commit", "-m", commitMsg]);
60
+ }
61
+ init();
package/dist/index.js ADDED
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
18
+ mod
19
+ ));
20
+
21
+ // src/index.ts
22
+ var import_commander = require("commander");
23
+ var import_kolorist2 = require("kolorist");
24
+
25
+ // package.json
26
+ var package_default = {
27
+ name: "@soybeanjs/cli",
28
+ version: "0.0.1",
29
+ description: "SoybeanJS's command lint tool",
30
+ author: "Soybean <honghuangdc@gmail.com> (https://github.com/honghuangdc)",
31
+ license: "MIT",
32
+ bin: {
33
+ soybean: "dist/index.js"
34
+ },
35
+ files: [
36
+ "dist"
37
+ ],
38
+ scripts: {
39
+ ipkg: "pnpm i --registry https://registry.npmmirror.com/",
40
+ build: "tsup",
41
+ esno: "esno",
42
+ lint: "eslint . --fix",
43
+ "update-version": "bumpp package.json",
44
+ "publish-pkg": "pnpm -r publish --access public",
45
+ release: "pnpm update-version && pnpm publish-pkg",
46
+ prepare: "husky install"
47
+ },
48
+ dependencies: {
49
+ commander: "^9.4.1",
50
+ execa: "5.1.1",
51
+ kolorist: "^1.6.0",
52
+ minimist: "^1.2.7",
53
+ prompts: "^2.4.2"
54
+ },
55
+ devDependencies: {
56
+ "@types/prompts": "^2.4.1",
57
+ bumpp: "^8.2.1",
58
+ eslint: "^8.26.0",
59
+ "eslint-config-soybeanjs": "0.1.1",
60
+ esno: "^0.16.3",
61
+ husky: "^8.0.1",
62
+ tsup: "^6.3.0",
63
+ typescript: "^4.8.4",
64
+ zx: "^7.1.1"
65
+ }
66
+ };
67
+
68
+ // src/command/git/commit.ts
69
+ var import_prompts = __toESM(require("prompts"));
70
+ var import_execa = __toESM(require("execa"));
71
+
72
+ // src/command/git/config.ts
73
+ var types = [
74
+ { value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" },
75
+ { value: "feat", title: "feat: \u6DFB\u52A0\u65B0\u7279\u6027" },
76
+ { value: "fix", title: "fix: \u4FEE\u590Dbug" },
77
+ { value: "docs", title: "docs: \u4EC5\u4EC5\u4FEE\u6539\u6587\u6863" },
78
+ { value: "style", title: "style: \u4EC5\u4EC5\u4FEE\u6539\u4E86\u7A7A\u683C\u3001\u683C\u5F0F\u7F29\u8FDB\u3001\u9017\u53F7\u7B49\u7B49\uFF0C\u4E0D\u6539\u53D8\u4EE3\u7801\u903B\u8F91" },
79
+ { value: "refactor", title: "refactor: \u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug" },
80
+ { value: "perf", title: "perf: \u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C" },
81
+ { value: "test", title: "test: \u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B" },
82
+ { value: "build", title: "build: \u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9" },
83
+ { value: "ci", title: "ci: CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539" },
84
+ { value: "chore", title: "chore: \u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49" },
85
+ { value: "revert", title: "revert: \u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C" }
86
+ ];
87
+ var scopes = [
88
+ ["projects", "\u9879\u76EE\u642D\u5EFA"],
89
+ ["components", "\u7EC4\u4EF6\u76F8\u5173"],
90
+ ["hooks", "hook \u76F8\u5173"],
91
+ ["utils", "utils \u76F8\u5173"],
92
+ ["types", "ts\u7C7B\u578B\u76F8\u5173"],
93
+ ["styles", "\u6837\u5F0F\u76F8\u5173"],
94
+ ["deps", "\u9879\u76EE\u4F9D\u8D56"],
95
+ ["auth", "\u5BF9 auth \u4FEE\u6539"],
96
+ ["other", "\u5176\u4ED6\u4FEE\u6539"]
97
+ ].map(([value, description]) => {
98
+ return {
99
+ value,
100
+ title: `${value.padEnd(30)} (${description})`
101
+ };
102
+ });
103
+
104
+ // src/command/git/commit.ts
105
+ async function gitCommit() {
106
+ const result = await (0, import_prompts.default)([
107
+ {
108
+ name: "types",
109
+ type: "select",
110
+ message: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7684\u7C7B\u578B",
111
+ choices: types
112
+ },
113
+ {
114
+ name: "scopes",
115
+ type: "select",
116
+ message: "\u9009\u62E9\u4E00\u4E2Ascope",
117
+ choices: scopes
118
+ },
119
+ {
120
+ name: "description",
121
+ type: "text",
122
+ message: "\u8BF7\u8F93\u5165\u63D0\u4EA4\u63CF\u8FF0"
123
+ }
124
+ ]);
125
+ const commitMsg = `${result.types}(${result.scopes}): ${result.description}`;
126
+ await (0, import_execa.default)("git", ["commit", "-m", commitMsg]);
127
+ }
128
+
129
+ // src/command/git/verify-commit.ts
130
+ var import_fs = require("fs");
131
+ var import_kolorist = require("kolorist");
132
+ function verifyGitCommit() {
133
+ const gitMsgPath = "./.git/COMMIT_EDITMSG";
134
+ const commitMsg = (0, import_fs.readFileSync)(gitMsgPath, "utf-8").trim();
135
+ const RELEASE_MSG = "chore: release";
136
+ const REG_EXP = new RegExp(
137
+ `(${types.map((item) => item.value).join("|")})\\((${scopes.map((item) => item.value).join("|")})\\):\\s.{1,50}`
138
+ );
139
+ if (!REG_EXP.test(commitMsg) && !commitMsg.includes(RELEASE_MSG)) {
140
+ throw new Error((0, import_kolorist.red)("\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303"));
141
+ }
142
+ }
143
+
144
+ // src/index.ts
145
+ import_commander.program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").action(() => {
146
+ gitCommit();
147
+ });
148
+ import_commander.program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303").action(() => {
149
+ verifyGitCommit();
150
+ });
151
+ import_commander.program.option("-gc, --git-commit", "\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").option("-gcv, --git-commit-verify", "\u6821\u9A8Cgit\u7684commit");
152
+ import_commander.program.version(package_default.version).description((0, import_kolorist2.blue)("soybeanjs https://soybean.pro"));
153
+ import_commander.program.parse(process.argv);
package/dist/index.mjs ADDED
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { program } from "commander";
5
+ import { blue } from "kolorist";
6
+
7
+ // package.json
8
+ var package_default = {
9
+ name: "@soybeanjs/cli",
10
+ version: "0.0.1",
11
+ description: "SoybeanJS's command lint tool",
12
+ author: "Soybean <honghuangdc@gmail.com> (https://github.com/honghuangdc)",
13
+ license: "MIT",
14
+ bin: {
15
+ soybean: "dist/index.js"
16
+ },
17
+ files: [
18
+ "dist"
19
+ ],
20
+ scripts: {
21
+ ipkg: "pnpm i --registry https://registry.npmmirror.com/",
22
+ build: "tsup",
23
+ esno: "esno",
24
+ lint: "eslint . --fix",
25
+ "update-version": "bumpp package.json",
26
+ "publish-pkg": "pnpm -r publish --access public",
27
+ release: "pnpm update-version && pnpm publish-pkg",
28
+ prepare: "husky install"
29
+ },
30
+ dependencies: {
31
+ commander: "^9.4.1",
32
+ execa: "5.1.1",
33
+ kolorist: "^1.6.0",
34
+ minimist: "^1.2.7",
35
+ prompts: "^2.4.2"
36
+ },
37
+ devDependencies: {
38
+ "@types/prompts": "^2.4.1",
39
+ bumpp: "^8.2.1",
40
+ eslint: "^8.26.0",
41
+ "eslint-config-soybeanjs": "0.1.1",
42
+ esno: "^0.16.3",
43
+ husky: "^8.0.1",
44
+ tsup: "^6.3.0",
45
+ typescript: "^4.8.4",
46
+ zx: "^7.1.1"
47
+ }
48
+ };
49
+
50
+ // src/command/git/commit.ts
51
+ import promptos from "prompts";
52
+ import execa from "execa";
53
+
54
+ // src/command/git/config.ts
55
+ var types = [
56
+ { value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" },
57
+ { value: "feat", title: "feat: \u6DFB\u52A0\u65B0\u7279\u6027" },
58
+ { value: "fix", title: "fix: \u4FEE\u590Dbug" },
59
+ { value: "docs", title: "docs: \u4EC5\u4EC5\u4FEE\u6539\u6587\u6863" },
60
+ { value: "style", title: "style: \u4EC5\u4EC5\u4FEE\u6539\u4E86\u7A7A\u683C\u3001\u683C\u5F0F\u7F29\u8FDB\u3001\u9017\u53F7\u7B49\u7B49\uFF0C\u4E0D\u6539\u53D8\u4EE3\u7801\u903B\u8F91" },
61
+ { value: "refactor", title: "refactor: \u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug" },
62
+ { value: "perf", title: "perf: \u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C" },
63
+ { value: "test", title: "test: \u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B" },
64
+ { value: "build", title: "build: \u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9" },
65
+ { value: "ci", title: "ci: CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539" },
66
+ { value: "chore", title: "chore: \u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49" },
67
+ { value: "revert", title: "revert: \u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C" }
68
+ ];
69
+ var scopes = [
70
+ ["projects", "\u9879\u76EE\u642D\u5EFA"],
71
+ ["components", "\u7EC4\u4EF6\u76F8\u5173"],
72
+ ["hooks", "hook \u76F8\u5173"],
73
+ ["utils", "utils \u76F8\u5173"],
74
+ ["types", "ts\u7C7B\u578B\u76F8\u5173"],
75
+ ["styles", "\u6837\u5F0F\u76F8\u5173"],
76
+ ["deps", "\u9879\u76EE\u4F9D\u8D56"],
77
+ ["auth", "\u5BF9 auth \u4FEE\u6539"],
78
+ ["other", "\u5176\u4ED6\u4FEE\u6539"]
79
+ ].map(([value, description]) => {
80
+ return {
81
+ value,
82
+ title: `${value.padEnd(30)} (${description})`
83
+ };
84
+ });
85
+
86
+ // src/command/git/commit.ts
87
+ async function gitCommit() {
88
+ const result = await promptos([
89
+ {
90
+ name: "types",
91
+ type: "select",
92
+ message: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7684\u7C7B\u578B",
93
+ choices: types
94
+ },
95
+ {
96
+ name: "scopes",
97
+ type: "select",
98
+ message: "\u9009\u62E9\u4E00\u4E2Ascope",
99
+ choices: scopes
100
+ },
101
+ {
102
+ name: "description",
103
+ type: "text",
104
+ message: "\u8BF7\u8F93\u5165\u63D0\u4EA4\u63CF\u8FF0"
105
+ }
106
+ ]);
107
+ const commitMsg = `${result.types}(${result.scopes}): ${result.description}`;
108
+ await execa("git", ["commit", "-m", commitMsg]);
109
+ }
110
+
111
+ // src/command/git/verify-commit.ts
112
+ import { readFileSync } from "fs";
113
+ import { red } from "kolorist";
114
+ function verifyGitCommit() {
115
+ const gitMsgPath = "./.git/COMMIT_EDITMSG";
116
+ const commitMsg = readFileSync(gitMsgPath, "utf-8").trim();
117
+ const RELEASE_MSG = "chore: release";
118
+ const REG_EXP = new RegExp(
119
+ `(${types.map((item) => item.value).join("|")})\\((${scopes.map((item) => item.value).join("|")})\\):\\s.{1,50}`
120
+ );
121
+ if (!REG_EXP.test(commitMsg) && !commitMsg.includes(RELEASE_MSG)) {
122
+ throw new Error(red("\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303"));
123
+ }
124
+ }
125
+
126
+ // src/index.ts
127
+ program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").action(() => {
128
+ gitCommit();
129
+ });
130
+ program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303").action(() => {
131
+ verifyGitCommit();
132
+ });
133
+ program.option("-gc, --git-commit", "\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").option("-gcv, --git-commit-verify", "\u6821\u9A8Cgit\u7684commit");
134
+ program.version(package_default.version).description(blue("soybeanjs https://soybean.pro"));
135
+ program.parse(process.argv);
@@ -0,0 +1 @@
1
+ { "scope": "" }
@@ -0,0 +1,46 @@
1
+ // src/verify-commit.ts
2
+ var import_fs = require("fs");
3
+ var import_kolorist = require("kolorist");
4
+
5
+ // src/config.ts
6
+ var types = [
7
+ { value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" },
8
+ { value: "feat", title: "feat: \u6DFB\u52A0\u65B0\u7279\u6027" },
9
+ { value: "fix", title: "fix: \u4FEE\u590Dbug" },
10
+ { value: "docs", title: "docs: \u4EC5\u4EC5\u4FEE\u6539\u6587\u6863" },
11
+ { value: "style", title: "style: \u4EC5\u4EC5\u4FEE\u6539\u4E86\u7A7A\u683C\u3001\u683C\u5F0F\u7F29\u8FDB\u3001\u9017\u53F7\u7B49\u7B49\uFF0C\u4E0D\u6539\u53D8\u4EE3\u7801\u903B\u8F91" },
12
+ { value: "refactor", title: "refactor: \u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug" },
13
+ { value: "perf", title: "perf: \u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C" },
14
+ { value: "test", title: "test: \u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B" },
15
+ { value: "build", title: "build: \u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9" },
16
+ { value: "ci", title: "ci: CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539" },
17
+ { value: "chore", title: "chore: \u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49" },
18
+ { value: "revert", title: "revert: \u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C" }
19
+ ];
20
+ var scopes = [
21
+ ["projects", "\u9879\u76EE\u642D\u5EFA"],
22
+ ["components", "\u7EC4\u4EF6\u76F8\u5173"],
23
+ ["hooks", "hook \u76F8\u5173"],
24
+ ["utils", "utils \u76F8\u5173"],
25
+ ["types", "ts\u7C7B\u578B\u76F8\u5173"],
26
+ ["styles", "\u6837\u5F0F\u76F8\u5173"],
27
+ ["deps", "\u9879\u76EE\u4F9D\u8D56"],
28
+ ["auth", "\u5BF9 auth \u4FEE\u6539"],
29
+ ["other", "\u5176\u4ED6\u4FEE\u6539"]
30
+ ].map(([value, description]) => {
31
+ return {
32
+ value,
33
+ title: `${value.padEnd(30)} (${description})`
34
+ };
35
+ });
36
+
37
+ // src/verify-commit.ts
38
+ var gitMsgPath = "./.git/COMMIT_EDITMSG";
39
+ var commitMsg = (0, import_fs.readFileSync)(gitMsgPath, "utf-8").trim();
40
+ var RELEASE_MSG = "chore: release";
41
+ var REG_EXP = new RegExp(
42
+ `(${types.map((item) => item.value).join("|")})\\((${scopes.map((item) => item.value).join("|")})\\):\\s.{1,50}`
43
+ );
44
+ if (!REG_EXP.test(commitMsg) && !commitMsg.includes(RELEASE_MSG)) {
45
+ throw new Error((0, import_kolorist.red)("\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303"));
46
+ }
@@ -0,0 +1,46 @@
1
+ // src/verify-commit.ts
2
+ import { readFileSync } from "fs";
3
+ import { red } from "kolorist";
4
+
5
+ // src/config.ts
6
+ var types = [
7
+ { value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" },
8
+ { value: "feat", title: "feat: \u6DFB\u52A0\u65B0\u7279\u6027" },
9
+ { value: "fix", title: "fix: \u4FEE\u590Dbug" },
10
+ { value: "docs", title: "docs: \u4EC5\u4EC5\u4FEE\u6539\u6587\u6863" },
11
+ { value: "style", title: "style: \u4EC5\u4EC5\u4FEE\u6539\u4E86\u7A7A\u683C\u3001\u683C\u5F0F\u7F29\u8FDB\u3001\u9017\u53F7\u7B49\u7B49\uFF0C\u4E0D\u6539\u53D8\u4EE3\u7801\u903B\u8F91" },
12
+ { value: "refactor", title: "refactor: \u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug" },
13
+ { value: "perf", title: "perf: \u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C" },
14
+ { value: "test", title: "test: \u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B" },
15
+ { value: "build", title: "build: \u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9" },
16
+ { value: "ci", title: "ci: CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539" },
17
+ { value: "chore", title: "chore: \u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49" },
18
+ { value: "revert", title: "revert: \u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C" }
19
+ ];
20
+ var scopes = [
21
+ ["projects", "\u9879\u76EE\u642D\u5EFA"],
22
+ ["components", "\u7EC4\u4EF6\u76F8\u5173"],
23
+ ["hooks", "hook \u76F8\u5173"],
24
+ ["utils", "utils \u76F8\u5173"],
25
+ ["types", "ts\u7C7B\u578B\u76F8\u5173"],
26
+ ["styles", "\u6837\u5F0F\u76F8\u5173"],
27
+ ["deps", "\u9879\u76EE\u4F9D\u8D56"],
28
+ ["auth", "\u5BF9 auth \u4FEE\u6539"],
29
+ ["other", "\u5176\u4ED6\u4FEE\u6539"]
30
+ ].map(([value, description]) => {
31
+ return {
32
+ value,
33
+ title: `${value.padEnd(30)} (${description})`
34
+ };
35
+ });
36
+
37
+ // src/verify-commit.ts
38
+ var gitMsgPath = "./.git/COMMIT_EDITMSG";
39
+ var commitMsg = readFileSync(gitMsgPath, "utf-8").trim();
40
+ var RELEASE_MSG = "chore: release";
41
+ var REG_EXP = new RegExp(
42
+ `(${types.map((item) => item.value).join("|")})\\((${scopes.map((item) => item.value).join("|")})\\):\\s.{1,50}`
43
+ );
44
+ if (!REG_EXP.test(commitMsg) && !commitMsg.includes(RELEASE_MSG)) {
45
+ throw new Error(red("\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303"));
46
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@soybeanjs/cli",
3
+ "version": "0.0.1",
4
+ "description": "SoybeanJS's command lint tools",
5
+ "author": "Soybean <honghuangdc@gmail.com> (https://github.com/honghuangdc)",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "soybean": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "dependencies": {
14
+ "commander": "^9.4.1",
15
+ "execa": "5.1.1",
16
+ "kolorist": "^1.6.0",
17
+ "minimist": "^1.2.7",
18
+ "prompts": "^2.4.2"
19
+ },
20
+ "devDependencies": {
21
+ "@types/prompts": "^2.4.1",
22
+ "bumpp": "^8.2.1",
23
+ "eslint": "^8.26.0",
24
+ "eslint-config-soybeanjs": "0.1.1",
25
+ "esno": "^0.16.3",
26
+ "husky": "^8.0.1",
27
+ "tsup": "^6.3.0",
28
+ "typescript": "^4.8.4",
29
+ "zx": "^7.1.1"
30
+ },
31
+ "scripts": {
32
+ "ipkg": "pnpm i --registry https://registry.npmmirror.com/",
33
+ "build": "tsup",
34
+ "esno": "esno",
35
+ "lint": "eslint . --fix",
36
+ "update-version": "bumpp package.json",
37
+ "publish-pkg": "pnpm -r publish --access public",
38
+ "release": "pnpm update-version && pnpm publish-pkg",
39
+ "soybean": "dist/index.js",
40
+ "commit": "pnpm soybean git-commit"
41
+ }
42
+ }