diff --git a/package.json b/package.json index adf6a53d2..ef8efca76 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,8 @@ "lint:js": "cross-env NODE_ENV=production eslint --fix --cache --cache-location=.cache/eslint --ext .js,.json,.mjs,.ts,.cjs --report-unused-disable-directives", "lint:package": "sort-package-json", "release": "yarn run build && auto shipit", + "prepack": "clean-package", + "postpack": "clean-package restore", "publish-action": "./scripts/publish-action.mjs", "trace": "./dist/bin.js trace", "trim-stats": "./dist/bin.js trim-stats-file", @@ -143,6 +145,7 @@ "auto": "^11.0.5", "boxen": "^7.1.1", "chalk": "^4.1.2", + "clean-package": "^2.2.0", "cpy": "^8.1.2", "cross-env": "^7.0.3", "cross-spawn": "^7.0.2", @@ -248,6 +251,16 @@ ] ] }, + "clean-package": { + "indent": 2, + "remove": [ + "auto", + "clean-package", + "lint-staged", + "packageManager", + "scripts" + ] + }, "docs": "https://www.chromatic.com/docs/cli", "packageManager": "yarn@4.2.2", "storybook": { diff --git a/scripts/publish-action.mjs b/scripts/publish-action.mjs index 232363812..6443cdb00 100755 --- a/scripts/publish-action.mjs +++ b/scripts/publish-action.mjs @@ -17,10 +17,12 @@ const publishAction = async ({ major, version, repo }) => { const { path, cleanup } = await tmp.dir({ unsafeCleanup: true, prefix: `chromatic-action-` }); + await $`yarn clean-package`; await copy(['action/*.js', 'action/*.json', 'action.yml', 'package.json'], path, { parents: true, // keep directory structure (i.e. action dir) }); await copy(['action-src/CHANGELOG.md', 'action-src/LICENSE', 'action-src/README.md'], path); + await $`yarn clean-package restore`; const $$ = (strings, ...args) => { console.info(strings.reduce((acc, s, i) => `${acc}${s}${args[i] || ''}`, '🏃 ')); diff --git a/yarn.lock b/yarn.lock index e79512e47..f278ee78f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6545,6 +6545,7 @@ __metadata: auto: "npm:^11.0.5" boxen: "npm:^7.1.1" chalk: "npm:^4.1.2" + clean-package: "npm:^2.2.0" cpy: "npm:^8.1.2" cross-env: "npm:^7.0.3" cross-spawn: "npm:^7.0.2" @@ -6683,6 +6684,17 @@ __metadata: languageName: node linkType: hard +"clean-package@npm:^2.2.0": + version: 2.2.0 + resolution: "clean-package@npm:2.2.0" + dependencies: + dot-prop: "npm:^6.0.1" + bin: + clean-package: bin/main.js + checksum: 10c0/014192ddd9ccb48288e934f9b4378ed86c57fdf7b65e38c1a61069e73d79845135d2645142f565ed4ff835a8660fa70387e5cd2a26348253cae699d4d3cedd26 + languageName: node + linkType: hard + "clean-stack@npm:^2.0.0": version: 2.2.0 resolution: "clean-stack@npm:2.2.0" @@ -7736,6 +7748,15 @@ __metadata: languageName: node linkType: hard +"dot-prop@npm:^6.0.1": + version: 6.0.1 + resolution: "dot-prop@npm:6.0.1" + dependencies: + is-obj: "npm:^2.0.0" + checksum: 10c0/30e51ec6408978a6951b21e7bc4938aad01a86f2fdf779efe52330205c6bb8a8ea12f35925c2029d6dc9d1df22f916f32f828ce1e9b259b1371c580541c22b5a + languageName: node + linkType: hard + "dotenv-expand@npm:^10.0.0": version: 10.0.0 resolution: "dotenv-expand@npm:10.0.0" @@ -10673,6 +10694,13 @@ __metadata: languageName: node linkType: hard +"is-obj@npm:^2.0.0": + version: 2.0.0 + resolution: "is-obj@npm:2.0.0" + checksum: 10c0/85044ed7ba8bd169e2c2af3a178cacb92a97aa75de9569d02efef7f443a824b5e153eba72b9ae3aca6f8ce81955271aa2dc7da67a8b720575d3e38104208cb4e + languageName: node + linkType: hard + "is-observable@npm:^1.1.0": version: 1.1.0 resolution: "is-observable@npm:1.1.0"