@iyowei/sweep-node-modules 0.3.0 → 0.5.0

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/package.json CHANGED
@@ -1,53 +1,40 @@
1
1
  {
2
2
  "name": "@iyowei/sweep-node-modules",
3
- "version": "0.3.0",
4
- "description": "工作区级 node_modules 清理工具: 一次扫描多个根目录, 跨项目列出体积, 确认后批量删除。",
5
- "keywords": [
6
- "cli",
7
- "bun",
8
- "nodejs",
9
- "node-modules",
10
- "disk-usage",
11
- "cleanup"
12
- ],
13
- "author": "iYoWei",
3
+ "version": "0.5.0",
4
+ "description": "Programmable API to sweep node_modules across workspace roots: scan, measure, and safely remove them from your own scripts and tools. 工作区级 node_modules 清理能力的可编程 API。",
5
+ "author": "iTonyYo (https://github.com/iTonyYo)",
14
6
  "license": "MIT",
15
7
  "repository": {
16
8
  "type": "git",
17
9
  "url": "git+https://github.com/iyowei/sweep-node-modules.git"
18
10
  },
11
+ "homepage": "https://github.com/iyowei/sweep-node-modules#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/iyowei/sweep-node-modules/issues"
14
+ },
19
15
  "type": "module",
20
- "bin": {
21
- "sweep-nm": "bin/sweep-nm.mjs"
16
+ "sideEffects": false,
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
22
  },
23
23
  "files": [
24
- "bin/sweep-nm.mjs",
25
24
  "dist"
26
25
  ],
27
26
  "engines": {
28
27
  "node": ">=22.18.0"
29
28
  },
30
29
  "publishConfig": {
31
- "access": "public"
30
+ "access": "public",
31
+ "registry": "https://registry.npmjs.org/"
32
32
  },
33
33
  "scripts": {
34
- "prepare": "[ -z \"$CI\" ] && lefthook install || true",
35
- "build": "bun build src/cli.ts --target=node --outfile=dist/cli.js",
36
- "prepublishOnly": "npm run build",
34
+ "build": "bun scripts/build.ts",
37
35
  "typecheck": "tsc --noEmit",
38
- "lint": "oxlint",
39
- "lint:fix": "oxlint --fix",
40
- "format": "prettier --write .",
41
36
  "test": "bun test",
42
- "bench": "bun bench/run.ts",
43
- "conformance": "bun scripts/transcription/run-conformance.ts"
44
- },
45
- "devDependencies": {
46
- "@trivago/prettier-plugin-sort-imports": "6.0.2",
47
- "@types/bun": "1.4.2",
48
- "lefthook": "2.1.14",
49
- "oxlint": "1.85.0",
50
- "prettier": "3.9.8",
51
- "typescript": "7.0.2"
37
+ "verify:release": "bun scripts/verify-release.ts",
38
+ "prepublishOnly": "npm run build && npm run verify:release"
52
39
  }
53
40
  }
package/bin/sweep-nm.mjs DELETED
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * npm 安装场景的启动器: 挑选运行时 (Bun 优先, 其次 Node) 后启动真实入口。
4
- * 与 bin/sweep-nm (sh) / bin/sweep-nm.cmd (cmd) 职责同逻辑 (挑选运行时: Bun 优先, Node 回退),
5
- * 差异在宿主与本文件多加的入口选择 (优先跑编译产物 dist/cli.js, 无产物则回退源码 src/cli.ts;
6
- * 包内只有产物, 开发态通常无产物):
7
- * 本文件同时承担 Unix 与 Windows 的 npm shim 目标 (shebang 必须是 node, 否则
8
- * npm 的 cmd-shim 会按 shebang 解释器生成 Windows 上不存在的调用)。
9
- * 退出码原样透传; 两个运行时都缺席时给出可操作提示并非零退出。
10
- */
11
- import { spawnSync } from 'node:child_process';
12
- import { existsSync } from 'node:fs';
13
- import { dirname, join } from 'node:path';
14
- import { fileURLToPath } from 'node:url';
15
-
16
- /** 探测命令是否可执行 (以 --version 的实际退出码为准, 不依赖 shell 内建) */
17
- const available = (command) =>
18
- spawnSync(command, ['--version'], { stdio: 'ignore' }).status === 0;
19
-
20
- /** 挑选运行时: Bun 优先, 其次 Node; 皆无则 null (由调用处报错退出) */
21
- const pickRuntime = () => {
22
- if (available('bun')) return 'bun';
23
- if (available('node')) return 'node';
24
- return null;
25
- };
26
-
27
- const root = dirname(dirname(fileURLToPath(import.meta.url)));
28
- // npm 包内是编译产物 (node 拒绝对 node_modules 内的 TS 做类型剥离, 见 package.json 的 build 脚本);
29
- // 仓库开发态无 dist, 回退直跑源码 (bun / node 皆可)
30
- const built = join(root, 'dist', 'cli.js');
31
- const entry = existsSync(built) ? built : join(root, 'src', 'cli.ts');
32
- const runtime = pickRuntime();
33
-
34
- if (runtime === null) {
35
- process.stderr.write('sweep-nm: 未找到 bun 或 node, 请至少安装其一\n');
36
- process.exit(1);
37
- }
38
-
39
- const { status } = spawnSync(runtime, [entry, ...process.argv.slice(2)], {
40
- stdio: 'inherit',
41
- });
42
-
43
- process.exit(status ?? 1);