@soybeanjs/cli 1.8.1 → 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.
Files changed (2) hide show
  1. package/dist/index.js +29 -6
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -4,16 +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 from "node:path";
7
+ import path, { join } from "node:path";
8
8
  import enquirer from "enquirer";
9
9
  import { rimraf } from "rimraf";
10
10
  import { existsSync as existsSync$1 } from "fs";
11
- import { join } from "path";
11
+ import { join as join$1 } from "path";
12
12
  import { generateChangelog, generateTotalChangelog } from "@soybeanjs/changelog";
13
13
  import { versionBump } from "bumpp";
14
14
  import { consola } from "consola";
15
15
  //#region package.json
16
- var version = "1.8.1";
16
+ var version = "1.8.2";
17
17
  //#endregion
18
18
  //#region src/locales/index.ts
19
19
  const locales = {
@@ -253,13 +253,36 @@ async function cleanup(paths) {
253
253
  }
254
254
  //#endregion
255
255
  //#region src/command/ncu.ts
256
- async function ncu(args = ["-u", "-w"]) {
257
- await execCommand("pnpm", ["npm-check-updates", ...args], { stdio: "inherit" });
256
+ async function ncu(args) {
257
+ await execCommand("pnpm", ["npm-check-updates", ...args && args.length > 0 ? args : hasWorkspaces() ? ["-u", "-w"] : ["-u"]], { stdio: "inherit" });
258
+ }
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;
258
281
  }
259
282
  //#endregion
260
283
  //#region src/command/changelog.ts
261
284
  async function genChangelog(options, total = false) {
262
- const hasChangelog = existsSync$1(join(process.cwd(), "CHANGELOG.md"));
285
+ const hasChangelog = existsSync$1(join$1(process.cwd(), "CHANGELOG.md"));
263
286
  if (total) await generateTotalChangelog(options);
264
287
  else await generateChangelog(options);
265
288
  if (!hasChangelog) await execCommand("git", ["add", "CHANGELOG.md"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soybeanjs/cli",
3
- "version": "1.8.1",
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,30 +38,30 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@soybeanjs/changelog": "^0.5.2",
41
- "bumpp": "^12.0.0",
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.0",
46
+ "execa": "^10.0.1",
47
47
  "kolorist": "^1.8.0",
48
- "npm-check-updates": "^22.2.9",
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.1",
56
- "tsx": "^4.23.1",
55
+ "@types/node": "^26.1.2",
56
+ "tsx": "^4.23.5",
57
57
  "typescript": "^7.0.2",
58
- "vite-plus": "0.2.6"
58
+ "vite-plus": "0.2.7"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "vp pack",
62
62
  "commit": "soy git-commit",
63
63
  "fmt": "vp fmt",
64
- "lint": "vp lint",
64
+ "lint": "vp lint --fix",
65
65
  "publish-pkg": "pnpm -r publish --access public",
66
66
  "release": "soy release",
67
67
  "typecheck": "tsc --noEmit --skipLibCheck",