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