From fcafcc9add5baac6fc006708ebc15ed35cec6cea Mon Sep 17 00:00:00 2001 From: Anton Molleda Date: Mon, 11 Sep 2017 17:02:32 -0700 Subject: [PATCH] Fix: Make npm package not include devDependencies Up until now the package added `devDependencies` increasing not only the size of the package but also triggering some `postinstall` scripts that are not needed and break in Windows machines. --- package.json | 3 +-- scripts/release.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d3ecaa77a89..fb9ba272b68 100644 --- a/package.json +++ b/package.json @@ -175,8 +175,7 @@ "lint:js": "eslint --ext md --ext ts --ignore-pattern dist .", "lint:md": "markdownlint docs", "preparecommitmsg": "node scripts/prepare-commit-message.js", - "prepublishOnly": "npm i && npm run build", - "release": "npm run test && node dist/scripts/release.js", + "release": "npm i && npm run test && node dist/scripts/release.js", "site": "node dist/src/bin/sonar", "test": "npm run lint && npm run commitmsg && npm run build && nyc ava", "test-on-travis": "npm run lint && npm run commitmsg && npm run build && nyc ava \"dist/tests/**/*.js\" --concurrency=2 --timeout=2m", diff --git a/scripts/release.ts b/scripts/release.ts index 30fd1437883..81f1684a2af 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -332,6 +332,10 @@ const main = async () => { // Create new release. await createRelease(version, releaseNotes); + // Remove devDependencies, this will update `package-lock.json`. + // Need to do so they aren't published on the `npm` package. + exec('Remove devDependencies', 'npm prune --production'); + // Create shrinkwrap file. // (This is done because `npm` doesn't // publish the `package-lock` file) @@ -340,8 +344,9 @@ const main = async () => { // Publish on `npm`. exec('Publish on `npm`.', 'npm publish'); - // Restore the package lock file. - shell.mv(SHRINKWRAP_FILE, PACKAGE_LOCK_FILE); + // Restore the package lock file and delete shrinkwrap + shell.rm(SHRINKWRAP_FILE); + exec(`Restore ${PACKAGE_LOCK_FILE}`, `git checkout ${PACKAGE_LOCK_FILE}`); }; main();