@soybeanjs/cli 1.8.0 → 1.8.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.d.ts +1 -1
- package/dist/index.js +26 -65
- package/package.json +8 -12
package/dist/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ interface CliOption {
|
|
|
67
67
|
*/
|
|
68
68
|
cleanupDirs: string[];
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* npm-check-updates command args
|
|
71
71
|
*
|
|
72
72
|
* If not set, soybean-cli will resolve workspace package.json files automatically and fall back to package.json in single-package repos.
|
|
73
73
|
*/
|
package/dist/index.js
CHANGED
|
@@ -4,18 +4,16 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
4
4
|
import process$1 from "node:process";
|
|
5
5
|
import { loadConfig } from "c12";
|
|
6
6
|
import { bgRed, green, red, yellow } from "kolorist";
|
|
7
|
-
import path, { join
|
|
7
|
+
import path, { join } from "node:path";
|
|
8
8
|
import enquirer from "enquirer";
|
|
9
9
|
import { rimraf } from "rimraf";
|
|
10
|
-
import { readFile } from "node:fs/promises";
|
|
11
|
-
import { glob } from "tinyglobby";
|
|
12
10
|
import { existsSync as existsSync$1 } from "fs";
|
|
13
11
|
import { join as join$1 } from "path";
|
|
14
12
|
import { generateChangelog, generateTotalChangelog } from "@soybeanjs/changelog";
|
|
15
13
|
import { versionBump } from "bumpp";
|
|
16
14
|
import { consola } from "consola";
|
|
17
15
|
//#region package.json
|
|
18
|
-
var version = "1.8.
|
|
16
|
+
var version = "1.8.2";
|
|
19
17
|
//#endregion
|
|
20
18
|
//#region src/locales/index.ts
|
|
21
19
|
const locales = {
|
|
@@ -255,68 +253,31 @@ async function cleanup(paths) {
|
|
|
255
253
|
}
|
|
256
254
|
//#endregion
|
|
257
255
|
//#region src/command/ncu.ts
|
|
258
|
-
async function ncu(args
|
|
259
|
-
await execCommand("pnpm", ["npm-check-updates", ...args.length ? args :
|
|
256
|
+
async function ncu(args) {
|
|
257
|
+
await execCommand("pnpm", ["npm-check-updates", ...args && args.length > 0 ? args : hasWorkspaces() ? ["-u", "-w"] : ["-u"]], { stdio: "inherit" });
|
|
260
258
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
function toPackageFilePattern(pattern) {
|
|
284
|
-
const normalizedPattern = pattern.trim();
|
|
285
|
-
if (!normalizedPattern) return "";
|
|
286
|
-
const isNegated = normalizedPattern.startsWith("!");
|
|
287
|
-
const cleanPattern = (isNegated ? normalizedPattern.slice(1) : normalizedPattern).replace(/\/$/u, "");
|
|
288
|
-
const packageFilePattern = cleanPattern.endsWith("package.json") ? cleanPattern : posix.join(cleanPattern, "package.json");
|
|
289
|
-
return isNegated ? `!${packageFilePattern}` : packageFilePattern;
|
|
290
|
-
}
|
|
291
|
-
async function resolveDefaultNcuArgs(cwd = process$1.cwd()) {
|
|
292
|
-
const [packageJsonContent, pnpmWorkspaceContent] = await Promise.all([readFile(join(cwd, "package.json"), "utf8").catch(() => null), readFile(join(cwd, "pnpm-workspace.yaml"), "utf8").catch(() => null)]);
|
|
293
|
-
const workspacePatterns = resolveWorkspacePatterns(packageJsonContent ? JSON.parse(packageJsonContent) : null, pnpmWorkspaceContent).map(toPackageFilePattern).filter(Boolean);
|
|
294
|
-
if (!workspacePatterns.length) return [
|
|
295
|
-
"-u",
|
|
296
|
-
"--packageFile",
|
|
297
|
-
"package.json"
|
|
298
|
-
];
|
|
299
|
-
const packageFiles = await glob(["package.json", ...workspacePatterns], {
|
|
300
|
-
cwd,
|
|
301
|
-
followSymbolicLinks: false,
|
|
302
|
-
onlyFiles: true
|
|
303
|
-
});
|
|
304
|
-
const uniquePackageFiles = [...new Set(packageFiles)].sort((left, right) => {
|
|
305
|
-
if (left === "package.json") return -1;
|
|
306
|
-
if (right === "package.json") return 1;
|
|
307
|
-
return left.localeCompare(right);
|
|
308
|
-
});
|
|
309
|
-
if (!uniquePackageFiles.length) return [
|
|
310
|
-
"-u",
|
|
311
|
-
"--packageFile",
|
|
312
|
-
"package.json"
|
|
313
|
-
];
|
|
314
|
-
if (uniquePackageFiles.length === 1) return [
|
|
315
|
-
"-u",
|
|
316
|
-
"--packageFile",
|
|
317
|
-
uniquePackageFiles[0]
|
|
318
|
-
];
|
|
319
|
-
return ["-u", ...uniquePackageFiles.flatMap((file) => ["--packageFile", file])];
|
|
259
|
+
/**
|
|
260
|
+
* Detect whether the current project is a workspace/monorepo.
|
|
261
|
+
*
|
|
262
|
+
* npm-check-updates' `-w` flag recognizes workspaces from either:
|
|
263
|
+
* 1. the `workspaces` field in package.json (npm/yarn format), or
|
|
264
|
+
* 2. the `packages` field in pnpm-workspace.yaml (pnpm format, used as
|
|
265
|
+
* fallback when `workspaces` is absent from package.json).
|
|
266
|
+
*
|
|
267
|
+
* Applying `-w` to a non-workspace project causes ncu to fail with:
|
|
268
|
+
* "workspaces property missing from package.json".
|
|
269
|
+
*/
|
|
270
|
+
function hasWorkspaces(cwd = process$1.cwd()) {
|
|
271
|
+
const pkgPath = join(cwd, "package.json");
|
|
272
|
+
if (existsSync(pkgPath)) try {
|
|
273
|
+
if (JSON.parse(readFileSync(pkgPath, "utf8")).workspaces) return true;
|
|
274
|
+
} catch {}
|
|
275
|
+
const wsPath = join(cwd, "pnpm-workspace.yaml");
|
|
276
|
+
if (existsSync(wsPath)) try {
|
|
277
|
+
const content = readFileSync(wsPath, "utf8");
|
|
278
|
+
if (/^packages\s*:/m.test(content)) return true;
|
|
279
|
+
} catch {}
|
|
280
|
+
return false;
|
|
320
281
|
}
|
|
321
282
|
//#endregion
|
|
322
283
|
//#region src/command/changelog.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/cli",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "SoybeanJS's command line tools",
|
|
5
5
|
"homepage": "https://github.com/soybeanjs/cli",
|
|
6
6
|
"bugs": {
|
|
@@ -38,34 +38,30 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@soybeanjs/changelog": "^0.5.2",
|
|
41
|
-
"bumpp": "^12.
|
|
41
|
+
"bumpp": "^12.1.1",
|
|
42
42
|
"c12": "^3.3.4",
|
|
43
43
|
"cac": "^7.0.0",
|
|
44
44
|
"consola": "^3.4.2",
|
|
45
45
|
"enquirer": "^2.4.1",
|
|
46
|
-
"execa": "^10.0.
|
|
46
|
+
"execa": "^10.0.1",
|
|
47
47
|
"kolorist": "^1.8.0",
|
|
48
|
-
"npm-check-updates": "^
|
|
48
|
+
"npm-check-updates": "^23.0.1",
|
|
49
49
|
"rimraf": "^6.1.3",
|
|
50
50
|
"tinyglobby": "^0.2.17"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@soybeanjs/cli": "link:",
|
|
54
54
|
"@soybeanjs/oxc-config": "^0.2.3",
|
|
55
|
-
"@types/node": "^26.1.
|
|
56
|
-
"
|
|
57
|
-
"oxlint": "^1.75.0",
|
|
58
|
-
"tsdown": "^0.22.14",
|
|
59
|
-
"tsx": "^4.23.1",
|
|
55
|
+
"@types/node": "^26.1.2",
|
|
56
|
+
"tsx": "^4.23.5",
|
|
60
57
|
"typescript": "^7.0.2",
|
|
61
|
-
"vite-plus": "0.2.
|
|
58
|
+
"vite-plus": "0.2.7"
|
|
62
59
|
},
|
|
63
60
|
"scripts": {
|
|
64
61
|
"build": "vp pack",
|
|
65
62
|
"commit": "soy git-commit",
|
|
66
|
-
"commit:zh": "soy git-commit -l=zh-cn",
|
|
67
63
|
"fmt": "vp fmt",
|
|
68
|
-
"lint": "vp lint",
|
|
64
|
+
"lint": "vp lint --fix",
|
|
69
65
|
"publish-pkg": "pnpm -r publish --access public",
|
|
70
66
|
"release": "soy release",
|
|
71
67
|
"typecheck": "tsc --noEmit --skipLibCheck",
|