Skip to content

Commit 9cb713b

Browse files
committed
refactor: extract package.json scripts to .mjs files
Replace inline shell scripts with Node.js .mjs files for better customization, maintainability, and cross-platform compatibility. New scripts: - scripts/build.mjs: Build orchestration with --src-only, --types-only, --ink-only flags - scripts/clean.mjs: Clean artifacts with granular --cache, --dist flags - scripts/check.mjs: Run quality checks (lint fix, ESLint, TypeScript) - scripts/lint-fix.mjs: Sequential linter execution with --dist, --external flags - scripts/coverage.mjs: Coverage collection with --code-only, --type-only, --percent flags - scripts/utils/: Shared command execution and utility functions Benefits: - Easier to add conditional logic and custom flags - Better error handling with proper exit codes - Cross-platform compatibility (no shell-specific syntax) - Improved maintainability and testability Updated lint-staged to call tools directly instead of through removed pnpm script aliases. Integrated minify into build:pkg via MINIFY env var instead of separate script. Pattern follows socket-sdk-js implementation and docs/SCRIPTS.md guide.
1 parent bee4b46 commit 9cb713b

File tree

14 files changed

+1254
-41
lines changed

14 files changed

+1254
-41
lines changed

package.json

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,41 @@
3333
"./translations.json": "./translations.json"
3434
},
3535
"scripts": {
36-
"build": "pnpm run build:dist",
37-
"build:dist": "pnpm run build:dist:src && pnpm run build:dist:types",
38-
"build:dist:src": "pnpm run clean:dist && rollup -c .config/rollup.dist.config.mjs && pnpm run build:ink",
39-
"build:dist:types": "pnpm run clean:dist:types && tsgo --project tsconfig.dts.json",
40-
"build:ink": "rollup -c .config/rollup.ink.config.mjs",
36+
"build": "node scripts/build.mjs",
37+
"build:dist": "node scripts/build.mjs",
38+
"build:dist:src": "node scripts/build.mjs --src-only",
39+
"build:dist:types": "node scripts/build.mjs --types-only",
40+
"build:ink": "node scripts/build.mjs --ink-only",
4141
"build:sea": "node scripts/build-sea.mjs",
4242
"build:sea:internal:bootstrap": "rollup -c .config/rollup.sea.config.mjs",
4343
"publish:sea": "node scripts/publish-sea.mjs",
4444
"publish:sea:github": "node scripts/publish-sea.mjs --skip-npm",
4545
"publish:sea:npm": "node scripts/publish-sea.mjs --skip-github",
46-
"check": "pnpm run fix && pnpm run check:lint && pnpm run check:tsc",
46+
"build:pkg": "MINIFY=1 pnpm run build:dist:src && pkg .",
47+
"build:pkg:one": "MINIFY=1 pnpm run build:dist:src && pkg . --targets",
48+
"check": "node scripts/check.mjs",
4749
"check:lint": "eslint --config .config/eslint.config.mjs --report-unused-disable-directives .",
4850
"check:tsc": "tsgo --noEmit",
4951
"check-ci": "pnpm run check:lint",
5052
"lint-ci": "pnpm run check:lint",
5153
"type-ci": "pnpm run check:tsc",
52-
"coverage": "run-s coverage:*",
53-
"coverage:test": "run-s pretest:unit test:unit:coverage",
54-
"coverage:percent": "node scripts/get-coverage-percentage.mjs",
54+
"coverage": "node scripts/coverage.mjs",
55+
"coverage:test": "node scripts/coverage.mjs --code-only",
56+
"coverage:percent": "node scripts/coverage.mjs --percent",
5557
"coverage:type": "type-coverage",
5658
"coverage:type:verbose": "type-coverage --detail",
57-
"clean": "run-p -c --aggregate-output clean:*",
58-
"clean:cache": "del-cli '**/.cache'",
59-
"clean:dist": "del-cli 'dist' '**/*.tsbuildinfo'",
60-
"clean:dist:types": "del-cli 'dist/types'",
61-
"clean:node_modules": "del-cli '**/node_modules'",
62-
"fix": "pnpm run lint:fix",
59+
"clean": "node scripts/clean.mjs",
60+
"clean:cache": "node scripts/clean.mjs --cache",
61+
"clean:dist": "node scripts/clean.mjs --dist",
62+
"clean:dist:types": "node scripts/clean.mjs --dist-types",
63+
"clean:node_modules": "node scripts/clean.mjs --node-modules",
64+
"fix": "node scripts/lint-fix.mjs",
6365
"knip:dependencies": "knip --config .config/knip.json --dependencies",
6466
"knip:exports": "knip --config .config/knip.json --include exports,duplicates",
6567
"lint": "oxlint -c=.config/oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json .",
66-
"lint:dist:fix": "run-s -c lint:dist:fix:*",
67-
"lint:dist:fix:oxlint": "oxlint -c=.config/oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json --silent --fix ./dist | dev-null",
68-
"lint:dist:fix:biome": "biome format --log-level=none --fix ./dist | dev-null",
69-
"lint:external:fix": "run-s -c lint:external:fix:*",
70-
"lint:external:fix:oxlint": "oxlint -c=.config/oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json --silent --fix ./external | dev-null",
71-
"lint:external:fix:biome": "biome format --log-level=none --fix ./external | dev-null",
72-
"lint:fix": "run-s -c lint:fix:*",
73-
"lint:fix:oxlint": "oxlint -c=.config/oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json --quiet --fix . | dev-null",
74-
"lint:fix:biome": "biome format --log-level=none --fix . | dev-null",
75-
"lint:fix:eslint": "eslint --config .config/eslint.config.mjs --report-unused-disable-directives --fix . | dev-null",
68+
"lint:dist:fix": "node scripts/lint-fix.mjs --dist",
69+
"lint:external:fix": "node scripts/lint-fix.mjs --external",
70+
"lint:fix": "node scripts/lint-fix.mjs",
7671
"lint-staged": "lint-staged",
7772
"precommit": "lint-staged",
7873
"prepare": "husky",
@@ -191,6 +186,7 @@
191186
"trash": "10.0.0",
192187
"type-coverage": "2.29.7",
193188
"typescript-eslint": "8.44.1",
189+
"unplugin-oxc": "0.5.2",
194190
"unplugin-purge-polyfills": "0.1.0",
195191
"vitest": "3.2.4",
196192
"yaml": "2.8.1",
@@ -214,8 +210,8 @@
214210
],
215211
"lint-staged": {
216212
"*.{cjs,cts,js,json,md,mjs,mts,ts}": [
217-
"pnpm run lint:fix:oxlint",
218-
"pnpm run lint:fix:biome -- --no-errors-on-unmatched --files-ignore-unknown=true --colors=off"
213+
"oxlint -c=.config/oxlintrc.json --ignore-path=.oxlintignore --tsconfig=tsconfig.json --quiet --fix",
214+
"biome format --log-level=none --fix --no-errors-on-unmatched --files-ignore-unknown=true --colors=off"
219215
]
220216
},
221217
"pnpm": {

0 commit comments

Comments
 (0)