@soybeanjs/cli 0.1.3 → 0.1.5
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.d.ts +1 -0
- package/dist/index.js +67 -25
- package/dist/index.mjs +70 -28
- package/package.json +31 -22
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var import_kolorist2 = require("kolorist");
|
|
|
26
26
|
// package.json
|
|
27
27
|
var package_default = {
|
|
28
28
|
name: "@soybeanjs/cli",
|
|
29
|
-
version: "0.1.
|
|
29
|
+
version: "0.1.4",
|
|
30
30
|
description: "SoybeanJS's command lint tools",
|
|
31
31
|
author: {
|
|
32
32
|
name: "Soybean",
|
|
@@ -42,47 +42,55 @@ var package_default = {
|
|
|
42
42
|
url: "https://github.com/honghuangdc/soybean-cli/issues"
|
|
43
43
|
},
|
|
44
44
|
bin: {
|
|
45
|
-
soybean: "dist/index.
|
|
45
|
+
soybean: "dist/index.mjs",
|
|
46
|
+
soy: "dist/index.mjs"
|
|
46
47
|
},
|
|
47
48
|
files: [
|
|
48
49
|
"dist"
|
|
49
50
|
],
|
|
50
|
-
publishConfig: {
|
|
51
|
-
registry: "https://registry.npmjs.org/"
|
|
52
|
-
},
|
|
53
51
|
scripts: {
|
|
54
52
|
build: "tsup",
|
|
55
53
|
lint: "eslint . --fix",
|
|
56
|
-
commit: "
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"update-pkg": "ncu --deep -u",
|
|
54
|
+
commit: "soy git-commit",
|
|
55
|
+
cleanup: "soy cleanup",
|
|
56
|
+
"update-pkg": "soy update-pkg",
|
|
60
57
|
"update-version": "bumpp package.json",
|
|
61
58
|
"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"
|
|
59
|
+
release: "pnpm update-version && pnpm publish-pkg"
|
|
65
60
|
},
|
|
66
61
|
dependencies: {
|
|
67
62
|
commander: "^9.4.1",
|
|
68
63
|
execa: "5.1.1",
|
|
69
64
|
kolorist: "^1.6.0",
|
|
70
65
|
minimist: "^1.2.7",
|
|
71
|
-
|
|
66
|
+
"npm-check-updates": "^16.6.2",
|
|
67
|
+
prompts: "^2.4.2",
|
|
68
|
+
rimraf: "^3.0.2",
|
|
69
|
+
zx: "^7.1.1"
|
|
72
70
|
},
|
|
73
71
|
devDependencies: {
|
|
74
72
|
"@soybeanjs/cli": "workspace:*",
|
|
75
|
-
"@types/prompts": "^2.4.
|
|
73
|
+
"@types/prompts": "^2.4.2",
|
|
76
74
|
bumpp: "^8.2.1",
|
|
77
|
-
eslint: "^8.
|
|
78
|
-
"eslint-config-soybeanjs": "0.1
|
|
75
|
+
eslint: "^8.31.0",
|
|
76
|
+
"eslint-config-soybeanjs": "0.2.1",
|
|
79
77
|
esno: "^0.16.3",
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
"lint-staged": "^13.1.0",
|
|
79
|
+
"simple-git-hooks": "^2.8.1",
|
|
80
|
+
tsup: "^6.5.0",
|
|
81
|
+
typescript: "^4.9.4"
|
|
82
|
+
},
|
|
83
|
+
"simple-git-hooks": {
|
|
84
|
+
"commit-msg": "pnpm soybean git-commit-verify",
|
|
85
|
+
"pre-commit": "pnpm exec lint-staged --concurrent false"
|
|
86
|
+
},
|
|
87
|
+
"lint-staged": {
|
|
88
|
+
"*": [
|
|
89
|
+
"eslint . --fix"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
publishConfig: {
|
|
93
|
+
registry: "https://registry.npmjs.org/"
|
|
86
94
|
}
|
|
87
95
|
};
|
|
88
96
|
|
|
@@ -145,7 +153,7 @@ async function gitCommit() {
|
|
|
145
153
|
}
|
|
146
154
|
]);
|
|
147
155
|
const commitMsg = `${result.types}(${result.scopes}): ${result.description}`;
|
|
148
|
-
|
|
156
|
+
(0, import_execa.default)("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
// src/command/git/verify-commit.ts
|
|
@@ -159,10 +167,35 @@ function verifyGitCommit() {
|
|
|
159
167
|
`(${types.map((item) => item.value).join("|")})\\((${scopes.map((item) => item.value).join("|")})\\):\\s.{1,50}`
|
|
160
168
|
);
|
|
161
169
|
if (!REG_EXP.test(commitMsg) && !commitMsg.includes(RELEASE_MSG)) {
|
|
162
|
-
throw new Error(
|
|
170
|
+
throw new Error(
|
|
171
|
+
`${(0, import_kolorist.bgRed)(" ERROR ")} ${(0, import_kolorist.red)("Git\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303!\n\n")}${(0, import_kolorist.green)(
|
|
172
|
+
"\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 pnpm commit \u751F\u6210\u7B26\u5408\u89C4\u8303\u7684Git\u63D0\u4EA4\u4FE1\u606F"
|
|
173
|
+
)}`
|
|
174
|
+
);
|
|
163
175
|
}
|
|
164
176
|
}
|
|
165
177
|
|
|
178
|
+
// src/scripts/cleanup.ts
|
|
179
|
+
var import_zx = require("zx");
|
|
180
|
+
async function cleanup() {
|
|
181
|
+
await import_zx.$`pnpm rimraf node_modules ./**/node_modules dist ./**/dist pnpm-lock.yaml ./**/pnpm-lock.yaml`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/scripts/git-hooks.ts
|
|
185
|
+
var import_zx2 = require("zx");
|
|
186
|
+
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`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/scripts/update-pkg.ts
|
|
194
|
+
var import_zx3 = require("zx");
|
|
195
|
+
async function updatePkg() {
|
|
196
|
+
await import_zx3.$`ncu --deep -u`;
|
|
197
|
+
}
|
|
198
|
+
|
|
166
199
|
// src/index.ts
|
|
167
200
|
import_commander.program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").action(() => {
|
|
168
201
|
gitCommit();
|
|
@@ -170,5 +203,14 @@ import_commander.program.command("git-commit").description("\u751F\u6210\u7B26\u
|
|
|
170
203
|
import_commander.program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303").action(() => {
|
|
171
204
|
verifyGitCommit();
|
|
172
205
|
});
|
|
173
|
-
import_commander.program.
|
|
206
|
+
import_commander.program.command("cleanup").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269").action(() => {
|
|
207
|
+
cleanup();
|
|
208
|
+
});
|
|
209
|
+
import_commander.program.command("init-git-hooks").description("\u521D\u59CB\u5316git\u94A9\u5B50").action(() => {
|
|
210
|
+
initSimpleGitHooks();
|
|
211
|
+
});
|
|
212
|
+
import_commander.program.command("update-pkg").description("\u5347\u7EA7\u4F9D\u8D56").action(() => {
|
|
213
|
+
updatePkg();
|
|
214
|
+
});
|
|
215
|
+
import_commander.program.version(package_default.version).description((0, import_kolorist2.blue)("soybean alias soy\n\nhttps://github.com/soybeanjs/cli"));
|
|
174
216
|
import_commander.program.parse(process.argv);
|
package/dist/index.mjs
CHANGED
|
@@ -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.
|
|
10
|
+
version: "0.1.4",
|
|
11
11
|
description: "SoybeanJS's command lint tools",
|
|
12
12
|
author: {
|
|
13
13
|
name: "Soybean",
|
|
@@ -23,52 +23,60 @@ var package_default = {
|
|
|
23
23
|
url: "https://github.com/honghuangdc/soybean-cli/issues"
|
|
24
24
|
},
|
|
25
25
|
bin: {
|
|
26
|
-
soybean: "dist/index.
|
|
26
|
+
soybean: "dist/index.mjs",
|
|
27
|
+
soy: "dist/index.mjs"
|
|
27
28
|
},
|
|
28
29
|
files: [
|
|
29
30
|
"dist"
|
|
30
31
|
],
|
|
31
|
-
publishConfig: {
|
|
32
|
-
registry: "https://registry.npmjs.org/"
|
|
33
|
-
},
|
|
34
32
|
scripts: {
|
|
35
33
|
build: "tsup",
|
|
36
34
|
lint: "eslint . --fix",
|
|
37
|
-
commit: "
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"update-pkg": "ncu --deep -u",
|
|
35
|
+
commit: "soy git-commit",
|
|
36
|
+
cleanup: "soy cleanup",
|
|
37
|
+
"update-pkg": "soy update-pkg",
|
|
41
38
|
"update-version": "bumpp package.json",
|
|
42
39
|
"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"
|
|
40
|
+
release: "pnpm update-version && pnpm publish-pkg"
|
|
46
41
|
},
|
|
47
42
|
dependencies: {
|
|
48
43
|
commander: "^9.4.1",
|
|
49
44
|
execa: "5.1.1",
|
|
50
45
|
kolorist: "^1.6.0",
|
|
51
46
|
minimist: "^1.2.7",
|
|
52
|
-
|
|
47
|
+
"npm-check-updates": "^16.6.2",
|
|
48
|
+
prompts: "^2.4.2",
|
|
49
|
+
rimraf: "^3.0.2",
|
|
50
|
+
zx: "^7.1.1"
|
|
53
51
|
},
|
|
54
52
|
devDependencies: {
|
|
55
53
|
"@soybeanjs/cli": "workspace:*",
|
|
56
|
-
"@types/prompts": "^2.4.
|
|
54
|
+
"@types/prompts": "^2.4.2",
|
|
57
55
|
bumpp: "^8.2.1",
|
|
58
|
-
eslint: "^8.
|
|
59
|
-
"eslint-config-soybeanjs": "0.1
|
|
56
|
+
eslint: "^8.31.0",
|
|
57
|
+
"eslint-config-soybeanjs": "0.2.1",
|
|
60
58
|
esno: "^0.16.3",
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
"lint-staged": "^13.1.0",
|
|
60
|
+
"simple-git-hooks": "^2.8.1",
|
|
61
|
+
tsup: "^6.5.0",
|
|
62
|
+
typescript: "^4.9.4"
|
|
63
|
+
},
|
|
64
|
+
"simple-git-hooks": {
|
|
65
|
+
"commit-msg": "pnpm soybean git-commit-verify",
|
|
66
|
+
"pre-commit": "pnpm exec lint-staged --concurrent false"
|
|
67
|
+
},
|
|
68
|
+
"lint-staged": {
|
|
69
|
+
"*": [
|
|
70
|
+
"eslint . --fix"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
publishConfig: {
|
|
74
|
+
registry: "https://registry.npmjs.org/"
|
|
67
75
|
}
|
|
68
76
|
};
|
|
69
77
|
|
|
70
78
|
// src/command/git/commit.ts
|
|
71
|
-
import
|
|
79
|
+
import prompts from "prompts";
|
|
72
80
|
import execa from "execa";
|
|
73
81
|
|
|
74
82
|
// src/command/git/config.ts
|
|
@@ -106,7 +114,7 @@ var scopes = [
|
|
|
106
114
|
|
|
107
115
|
// src/command/git/commit.ts
|
|
108
116
|
async function gitCommit() {
|
|
109
|
-
const result = await
|
|
117
|
+
const result = await prompts([
|
|
110
118
|
{
|
|
111
119
|
name: "types",
|
|
112
120
|
type: "select",
|
|
@@ -126,12 +134,12 @@ async function gitCommit() {
|
|
|
126
134
|
}
|
|
127
135
|
]);
|
|
128
136
|
const commitMsg = `${result.types}(${result.scopes}): ${result.description}`;
|
|
129
|
-
|
|
137
|
+
execa("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
// src/command/git/verify-commit.ts
|
|
133
141
|
import { readFileSync } from "fs";
|
|
134
|
-
import { red } from "kolorist";
|
|
142
|
+
import { bgRed, red, green } from "kolorist";
|
|
135
143
|
function verifyGitCommit() {
|
|
136
144
|
const gitMsgPath = "./.git/COMMIT_EDITMSG";
|
|
137
145
|
const commitMsg = readFileSync(gitMsgPath, "utf-8").trim();
|
|
@@ -140,10 +148,35 @@ function verifyGitCommit() {
|
|
|
140
148
|
`(${types.map((item) => item.value).join("|")})\\((${scopes.map((item) => item.value).join("|")})\\):\\s.{1,50}`
|
|
141
149
|
);
|
|
142
150
|
if (!REG_EXP.test(commitMsg) && !commitMsg.includes(RELEASE_MSG)) {
|
|
143
|
-
throw new Error(
|
|
151
|
+
throw new Error(
|
|
152
|
+
`${bgRed(" ERROR ")} ${red("Git\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303!\n\n")}${green(
|
|
153
|
+
"\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 pnpm commit \u751F\u6210\u7B26\u5408\u89C4\u8303\u7684Git\u63D0\u4EA4\u4FE1\u606F"
|
|
154
|
+
)}`
|
|
155
|
+
);
|
|
144
156
|
}
|
|
145
157
|
}
|
|
146
158
|
|
|
159
|
+
// src/scripts/cleanup.ts
|
|
160
|
+
import { $ } from "zx";
|
|
161
|
+
async function cleanup() {
|
|
162
|
+
await $`pnpm rimraf node_modules ./**/node_modules dist ./**/dist pnpm-lock.yaml ./**/pnpm-lock.yaml`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/scripts/git-hooks.ts
|
|
166
|
+
import { $ as $2 } from "zx";
|
|
167
|
+
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`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/scripts/update-pkg.ts
|
|
175
|
+
import { $ as $3 } from "zx";
|
|
176
|
+
async function updatePkg() {
|
|
177
|
+
await $3`ncu --deep -u`;
|
|
178
|
+
}
|
|
179
|
+
|
|
147
180
|
// src/index.ts
|
|
148
181
|
program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").action(() => {
|
|
149
182
|
gitCommit();
|
|
@@ -151,5 +184,14 @@ program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89
|
|
|
151
184
|
program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303").action(() => {
|
|
152
185
|
verifyGitCommit();
|
|
153
186
|
});
|
|
154
|
-
program.
|
|
187
|
+
program.command("cleanup").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269").action(() => {
|
|
188
|
+
cleanup();
|
|
189
|
+
});
|
|
190
|
+
program.command("init-git-hooks").description("\u521D\u59CB\u5316git\u94A9\u5B50").action(() => {
|
|
191
|
+
initSimpleGitHooks();
|
|
192
|
+
});
|
|
193
|
+
program.command("update-pkg").description("\u5347\u7EA7\u4F9D\u8D56").action(() => {
|
|
194
|
+
updatePkg();
|
|
195
|
+
});
|
|
196
|
+
program.version(package_default.version).description(blue("soybean alias soy\n\nhttps://github.com/soybeanjs/cli"));
|
|
155
197
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "SoybeanJS's command lint tools",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Soybean",
|
|
@@ -16,45 +16,54 @@
|
|
|
16
16
|
"url": "https://github.com/honghuangdc/soybean-cli/issues"
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
|
-
"soybean": "dist/index.
|
|
19
|
+
"soybean": "dist/index.mjs",
|
|
20
|
+
"soy": "dist/index.mjs"
|
|
20
21
|
},
|
|
21
22
|
"files": [
|
|
22
23
|
"dist"
|
|
23
24
|
],
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"registry": "https://registry.npmjs.org/"
|
|
26
|
-
},
|
|
27
25
|
"dependencies": {
|
|
28
26
|
"commander": "^9.4.1",
|
|
29
27
|
"execa": "5.1.1",
|
|
30
28
|
"kolorist": "^1.6.0",
|
|
31
29
|
"minimist": "^1.2.7",
|
|
32
|
-
"
|
|
30
|
+
"npm-check-updates": "^16.6.2",
|
|
31
|
+
"prompts": "^2.4.2",
|
|
32
|
+
"rimraf": "^3.0.2",
|
|
33
|
+
"zx": "^7.1.1"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"@types/prompts": "^2.4.1",
|
|
36
|
+
"@types/prompts": "^2.4.2",
|
|
37
37
|
"bumpp": "^8.2.1",
|
|
38
|
-
"eslint": "^8.
|
|
39
|
-
"eslint-config-soybeanjs": "0.1
|
|
38
|
+
"eslint": "^8.31.0",
|
|
39
|
+
"eslint-config-soybeanjs": "0.2.1",
|
|
40
40
|
"esno": "^0.16.3",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
41
|
+
"lint-staged": "^13.1.0",
|
|
42
|
+
"simple-git-hooks": "^2.8.1",
|
|
43
|
+
"tsup": "^6.5.0",
|
|
44
|
+
"typescript": "^4.9.4",
|
|
45
|
+
"@soybeanjs/cli": "0.1.5"
|
|
46
|
+
},
|
|
47
|
+
"simple-git-hooks": {
|
|
48
|
+
"commit-msg": "pnpm soybean git-commit-verify",
|
|
49
|
+
"pre-commit": "pnpm exec lint-staged --concurrent false"
|
|
50
|
+
},
|
|
51
|
+
"lint-staged": {
|
|
52
|
+
"*": [
|
|
53
|
+
"eslint . --fix"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
58
|
},
|
|
48
59
|
"scripts": {
|
|
49
60
|
"build": "tsup",
|
|
50
61
|
"lint": "eslint . --fix",
|
|
51
|
-
"commit": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"update-pkg": "ncu --deep -u",
|
|
62
|
+
"commit": "soy git-commit",
|
|
63
|
+
"cleanup": "soy cleanup",
|
|
64
|
+
"update-pkg": "soy update-pkg",
|
|
55
65
|
"update-version": "bumpp package.json",
|
|
56
66
|
"publish-pkg": "pnpm -r publish --access public",
|
|
57
|
-
"release": "pnpm update-version && pnpm publish-pkg"
|
|
58
|
-
"sync-pkg": "esno ./scripts/sync.ts"
|
|
67
|
+
"release": "pnpm update-version && pnpm publish-pkg"
|
|
59
68
|
}
|
|
60
69
|
}
|