@soybeanjs/cli 0.6.1 → 0.6.3
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.cjs +21 -9
- package/dist/index.d.ts +0 -4
- package/dist/index.mjs +21 -9
- package/package.json +14 -21
package/dist/index.cjs
CHANGED
|
@@ -10,6 +10,7 @@ const rimraf = require('rimraf');
|
|
|
10
10
|
const changelog = require('@soybeanjs/changelog');
|
|
11
11
|
const versionBump = require('bumpp');
|
|
12
12
|
const c12 = require('c12');
|
|
13
|
+
const promises = require('fs/promises');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
15
16
|
|
|
@@ -18,7 +19,7 @@ const enquirer__default = /*#__PURE__*/_interopDefaultCompat(enquirer);
|
|
|
18
19
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
19
20
|
const versionBump__default = /*#__PURE__*/_interopDefaultCompat(versionBump);
|
|
20
21
|
|
|
21
|
-
const version = "0.6.
|
|
22
|
+
const version = "0.6.3";
|
|
22
23
|
|
|
23
24
|
async function execCommand(cmd, args, options) {
|
|
24
25
|
const { execa } = await import('execa');
|
|
@@ -102,7 +103,7 @@ async function prettierWrite(writeGlob) {
|
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
async function
|
|
106
|
+
async function eslintPrettier() {
|
|
106
107
|
await execCommand("npx", ["eslint", ".", "--fix"], {
|
|
107
108
|
stdio: "inherit"
|
|
108
109
|
});
|
|
@@ -194,10 +195,9 @@ const defaultOptions = {
|
|
|
194
195
|
lintStagedConfig: {
|
|
195
196
|
[eslintExt]: "eslint --fix",
|
|
196
197
|
"*": "soy prettier-write"
|
|
197
|
-
}
|
|
198
|
-
useSoybeanToken: false
|
|
198
|
+
}
|
|
199
199
|
};
|
|
200
|
-
const SOYBEAN_GITHUB_TOKEN = "
|
|
200
|
+
const SOYBEAN_GITHUB_TOKEN = "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";
|
|
201
201
|
async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
202
202
|
const { config } = await c12.loadConfig({
|
|
203
203
|
name: "soybean",
|
|
@@ -206,11 +206,23 @@ async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
|
206
206
|
cwd,
|
|
207
207
|
packageJson: true
|
|
208
208
|
});
|
|
209
|
-
|
|
209
|
+
const has = await hasSoybeanInfoFromPkgJson(cwd);
|
|
210
|
+
if (config && has) {
|
|
210
211
|
config.changelogOptions = { ...config.changelogOptions, github: { repo: "", token: SOYBEAN_GITHUB_TOKEN } };
|
|
211
212
|
}
|
|
212
213
|
return config;
|
|
213
214
|
}
|
|
215
|
+
async function hasSoybeanInfoFromPkgJson(cwd) {
|
|
216
|
+
let hasSoybeanInfo = false;
|
|
217
|
+
const REG = "soybean";
|
|
218
|
+
try {
|
|
219
|
+
const pkgJson = await promises.readFile(`${cwd}/package.json`, "utf-8");
|
|
220
|
+
const pkg = JSON.parse(pkgJson);
|
|
221
|
+
hasSoybeanInfo = pkg.name?.includes(REG) || pkg.repository?.url?.includes(REG) || pkg.author?.includes(REG) || pkg.author?.name?.includes(REG) || pkg.author?.url?.includes(REG);
|
|
222
|
+
} catch {
|
|
223
|
+
}
|
|
224
|
+
return hasSoybeanInfo;
|
|
225
|
+
}
|
|
214
226
|
|
|
215
227
|
async function setupCli() {
|
|
216
228
|
const cliOptions = await loadCliOptions();
|
|
@@ -218,13 +230,13 @@ async function setupCli() {
|
|
|
218
230
|
cli.version(version).option("--total", "Generate changelog by total tags").help();
|
|
219
231
|
const commands = {
|
|
220
232
|
"git-commit": {
|
|
221
|
-
desc: "\u751F\u6210\u7B26\u5408
|
|
233
|
+
desc: "\u751F\u6210\u7B26\u5408 Conventional Commits \u89C4\u8303\u7684\u63D0\u4EA4\u4FE1\u606F",
|
|
222
234
|
action: () => {
|
|
223
235
|
gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes);
|
|
224
236
|
}
|
|
225
237
|
},
|
|
226
238
|
"git-commit-verify": {
|
|
227
|
-
desc: "\u6821\u9A8C git \
|
|
239
|
+
desc: "\u6821\u9A8C git \u63D0\u4EA4\u4FE1\u606F\u662F\u5426\u7B26\u5408 Conventional Commits \u89C4\u8303",
|
|
228
240
|
action: () => {
|
|
229
241
|
gitCommitVerify();
|
|
230
242
|
}
|
|
@@ -304,7 +316,7 @@ async function setupCli() {
|
|
|
304
316
|
*/
|
|
305
317
|
"eslint-prettier": {
|
|
306
318
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03",
|
|
307
|
-
action:
|
|
319
|
+
action: eslintPrettier
|
|
308
320
|
}
|
|
309
321
|
};
|
|
310
322
|
for await (const [command, { desc, action }] of Object.entries(commands)) {
|
package/dist/index.d.ts
CHANGED
|
@@ -41,10 +41,6 @@ interface CliOption {
|
|
|
41
41
|
* lint-staged config
|
|
42
42
|
*/
|
|
43
43
|
lintStagedConfig: Record<string, string | string[]>;
|
|
44
|
-
/**
|
|
45
|
-
* use soybean token
|
|
46
|
-
*/
|
|
47
|
-
useSoybeanToken: boolean;
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
declare function defineConfig(config?: Partial<CliOption>): Partial<CliOption> | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -8,8 +8,9 @@ import { rimraf } from 'rimraf';
|
|
|
8
8
|
import { generateTotalChangelog, generateChangelog } from '@soybeanjs/changelog';
|
|
9
9
|
import versionBump from 'bumpp';
|
|
10
10
|
import { loadConfig } from 'c12';
|
|
11
|
+
import { readFile } from 'fs/promises';
|
|
11
12
|
|
|
12
|
-
const version = "0.6.
|
|
13
|
+
const version = "0.6.3";
|
|
13
14
|
|
|
14
15
|
async function execCommand(cmd, args, options) {
|
|
15
16
|
const { execa } = await import('execa');
|
|
@@ -93,7 +94,7 @@ async function prettierWrite(writeGlob) {
|
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
async function
|
|
97
|
+
async function eslintPrettier() {
|
|
97
98
|
await execCommand("npx", ["eslint", ".", "--fix"], {
|
|
98
99
|
stdio: "inherit"
|
|
99
100
|
});
|
|
@@ -185,10 +186,9 @@ const defaultOptions = {
|
|
|
185
186
|
lintStagedConfig: {
|
|
186
187
|
[eslintExt]: "eslint --fix",
|
|
187
188
|
"*": "soy prettier-write"
|
|
188
|
-
}
|
|
189
|
-
useSoybeanToken: false
|
|
189
|
+
}
|
|
190
190
|
};
|
|
191
|
-
const SOYBEAN_GITHUB_TOKEN = "
|
|
191
|
+
const SOYBEAN_GITHUB_TOKEN = "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";
|
|
192
192
|
async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
193
193
|
const { config } = await loadConfig({
|
|
194
194
|
name: "soybean",
|
|
@@ -197,11 +197,23 @@ async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
|
197
197
|
cwd,
|
|
198
198
|
packageJson: true
|
|
199
199
|
});
|
|
200
|
-
|
|
200
|
+
const has = await hasSoybeanInfoFromPkgJson(cwd);
|
|
201
|
+
if (config && has) {
|
|
201
202
|
config.changelogOptions = { ...config.changelogOptions, github: { repo: "", token: SOYBEAN_GITHUB_TOKEN } };
|
|
202
203
|
}
|
|
203
204
|
return config;
|
|
204
205
|
}
|
|
206
|
+
async function hasSoybeanInfoFromPkgJson(cwd) {
|
|
207
|
+
let hasSoybeanInfo = false;
|
|
208
|
+
const REG = "soybean";
|
|
209
|
+
try {
|
|
210
|
+
const pkgJson = await readFile(`${cwd}/package.json`, "utf-8");
|
|
211
|
+
const pkg = JSON.parse(pkgJson);
|
|
212
|
+
hasSoybeanInfo = pkg.name?.includes(REG) || pkg.repository?.url?.includes(REG) || pkg.author?.includes(REG) || pkg.author?.name?.includes(REG) || pkg.author?.url?.includes(REG);
|
|
213
|
+
} catch {
|
|
214
|
+
}
|
|
215
|
+
return hasSoybeanInfo;
|
|
216
|
+
}
|
|
205
217
|
|
|
206
218
|
async function setupCli() {
|
|
207
219
|
const cliOptions = await loadCliOptions();
|
|
@@ -209,13 +221,13 @@ async function setupCli() {
|
|
|
209
221
|
cli.version(version).option("--total", "Generate changelog by total tags").help();
|
|
210
222
|
const commands = {
|
|
211
223
|
"git-commit": {
|
|
212
|
-
desc: "\u751F\u6210\u7B26\u5408
|
|
224
|
+
desc: "\u751F\u6210\u7B26\u5408 Conventional Commits \u89C4\u8303\u7684\u63D0\u4EA4\u4FE1\u606F",
|
|
213
225
|
action: () => {
|
|
214
226
|
gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes);
|
|
215
227
|
}
|
|
216
228
|
},
|
|
217
229
|
"git-commit-verify": {
|
|
218
|
-
desc: "\u6821\u9A8C git \
|
|
230
|
+
desc: "\u6821\u9A8C git \u63D0\u4EA4\u4FE1\u606F\u662F\u5426\u7B26\u5408 Conventional Commits \u89C4\u8303",
|
|
219
231
|
action: () => {
|
|
220
232
|
gitCommitVerify();
|
|
221
233
|
}
|
|
@@ -295,7 +307,7 @@ async function setupCli() {
|
|
|
295
307
|
*/
|
|
296
308
|
"eslint-prettier": {
|
|
297
309
|
desc: "\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03",
|
|
298
|
-
action:
|
|
310
|
+
action: eslintPrettier
|
|
299
311
|
}
|
|
300
312
|
};
|
|
301
313
|
for await (const [command, { desc, action }] of Object.entries(commands)) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "SoybeanJS's command line tools",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Soybean",
|
|
7
|
-
"email": "
|
|
8
|
-
"url": "https://github.com/
|
|
7
|
+
"email": "soybeanjs@outlook.com",
|
|
8
|
+
"url": "https://github.com/soybeanjs"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"homepage": "https://github.com/soybeanjs/cli",
|
|
@@ -36,35 +36,28 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@soybeanjs/changelog": "0.0.
|
|
39
|
+
"@soybeanjs/changelog": "0.0.7",
|
|
40
40
|
"bumpp": "9.1.1",
|
|
41
|
-
"c12": "1.4.
|
|
41
|
+
"c12": "1.4.2",
|
|
42
42
|
"cac": "6.7.14",
|
|
43
|
-
"enquirer": "2.
|
|
44
|
-
"execa": "7.
|
|
43
|
+
"enquirer": "2.4.0",
|
|
44
|
+
"execa": "7.2.0",
|
|
45
45
|
"kolorist": "1.8.0",
|
|
46
|
-
"lint-staged": "13.2.
|
|
46
|
+
"lint-staged": "13.2.3",
|
|
47
47
|
"minimist": "1.2.8",
|
|
48
|
-
"npm-check-updates": "16.10.
|
|
48
|
+
"npm-check-updates": "16.10.17",
|
|
49
49
|
"rimraf": "5.0.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@soybeanjs/cli": "link:",
|
|
53
|
-
"@types/node": "20.
|
|
54
|
-
"eslint": "8.
|
|
55
|
-
"eslint-config-soybeanjs": "0.
|
|
56
|
-
"simple-git-hooks": "2.
|
|
53
|
+
"@types/node": "20.4.5",
|
|
54
|
+
"eslint": "8.45.0",
|
|
55
|
+
"eslint-config-soybeanjs": "0.5.3",
|
|
56
|
+
"simple-git-hooks": "2.9.0",
|
|
57
57
|
"tsx": "3.12.7",
|
|
58
|
-
"typescript": "5.1.
|
|
58
|
+
"typescript": "5.1.6",
|
|
59
59
|
"unbuild": "1.2.1"
|
|
60
60
|
},
|
|
61
|
-
"simple-git-hooks": {
|
|
62
|
-
"commit-msg": "pnpm soy git-commit-verify",
|
|
63
|
-
"pre-commit": "pnpm typecheck && pnpm soy lint-staged"
|
|
64
|
-
},
|
|
65
|
-
"soybean": {
|
|
66
|
-
"useSoybeanToken": true
|
|
67
|
-
},
|
|
68
61
|
"scripts": {
|
|
69
62
|
"build": "pnpm typecheck && unbuild",
|
|
70
63
|
"lint": "eslint . --fix",
|