From 0ebd99a3cf14d680678aa3e7a71b1e27ee357c50 Mon Sep 17 00:00:00 2001 From: nobkd <44443899+nobkd@users.noreply.github.com> Date: Sat, 2 Nov 2024 03:04:12 +0100 Subject: [PATCH] feat: use "workspace:" protocol, for auto replace on "bun publish" --- .github/workflows/test.yaml | 1 + CONTRIBUTING.md | 1 + packages/nuekit/package.json | 6 +++--- packages/nuemark/package.json | 2 +- setup-npm.js | 7 +++++++ 5 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 setup-npm.js diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 18886f24..d2f5f377 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -45,6 +45,7 @@ jobs: - name: Install and test with Node run: | node -v && npm -v + node setup-npm.js npm install npm install --no-save jest jest-extended esbuild npm test -- --coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36d44089..88651bac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,7 @@ nue nue build --production # if using node +node setup-npm.js # prepare local dev env npm install cd packages/nuekit npm link diff --git a/packages/nuekit/package.json b/packages/nuekit/package.json index ebcf6b54..4c90d38a 100644 --- a/packages/nuekit/package.json +++ b/packages/nuekit/package.json @@ -26,9 +26,9 @@ "import-meta-resolve": "^4.1.0", "js-yaml": "^4.1.0", "lightningcss": "^1.27.0", - "nue-glow": "*", - "nuejs-core": "*", - "nuemark": "*" + "nue-glow": "workspace:*", + "nuejs-core": "workspace:*", + "nuemark": "workspace:*" }, "jest": { "setupFilesAfterEnv": [ diff --git a/packages/nuemark/package.json b/packages/nuemark/package.json index 419b1d72..0b7dc166 100644 --- a/packages/nuemark/package.json +++ b/packages/nuemark/package.json @@ -16,7 +16,7 @@ }, "dependencies": { "js-yaml": "^4.1.0", - "nue-glow": "*" + "nue-glow": "workspace:*" }, "jest": { "setupFilesAfterEnv": [ diff --git a/setup-npm.js b/setup-npm.js new file mode 100644 index 00000000..6d29c0ac --- /dev/null +++ b/setup-npm.js @@ -0,0 +1,7 @@ +import { readdirSync, existsSync, readFileSync, writeFileSync } from 'node:fs' +import { join } from 'node:path' + +for (const pkg of readdirSync('packages').map(d => join('packages', d, 'package.json'))) { + if (!existsSync(pkg)) continue + writeFileSync(pkg, readFileSync(pkg, 'utf8').replaceAll('workspace:*', '*')) +}