Skip to content

Commit

Permalink
build: add script to prune package before publish
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Nov 20, 2024
1 parent 256333a commit b31c71f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- name: Prune package.json
run: bun run build:prune-package

- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "module",
"svelte": "./src/index.js",
"main": "./src/index.js",
"types": "./index.d.ts",
"types": "./src/index.d.ts",
"exports": {
"./*.svelte": {
"types": "./src/*.svelte.d.ts",
Expand All @@ -25,6 +25,7 @@
},
"scripts": {
"dev": "rollup -cw",
"build:prune-package": "bun scripts/prune-package.ts",
"test": "svelte-check --workspace tests"
},
"dependencies": {
Expand All @@ -33,6 +34,7 @@
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.2",
"@types/bun": "^1.1.13",
"svelte": "^3.59.1",
"svelte-check": "^3.6.2",
"svelte-readme": "^3.6.3",
Expand Down
9 changes: 9 additions & 0 deletions scripts/prune-package.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const pkgJson = await Bun.file("./package.json").json();

// Remove unrelated metadata from package.json for publishing.
delete pkgJson.scripts;
delete pkgJson.devDependencies;

await Bun.write("./package.json", JSON.stringify(pkgJson, null, 2) + "\n");

export {};

0 comments on commit b31c71f

Please sign in to comment.