-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: publish shrinkwrap with production dependencies only (#5547)
- Loading branch information
Showing
16 changed files
with
93 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { readFile, writeFile } from 'fs/promises' | ||
import { dirname, join } from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
import execa from 'execa' | ||
import ora from 'ora' | ||
|
||
// These scripts from package.json need to be preserved on publish | ||
const preserveScripts = new Set(['postinstall', 'postpack', 'preinstall', 'prepack', 'prepublish', 'prepublishOnly']) | ||
|
||
let spinner = ora({ | ||
spinner: 'star', | ||
text: 'Patching package.json (removing devDependencies, scripts, etc)', | ||
}).start() | ||
|
||
const dir = dirname(fileURLToPath(import.meta.url)) | ||
const packageJsonPath = join(dir, '../package.json') | ||
|
||
const pkgJson = JSON.parse(await readFile(packageJsonPath)) | ||
|
||
delete pkgJson.devDependencies | ||
delete pkgJson.ava | ||
delete pkgJson.config | ||
|
||
// eslint-disable-next-line fp/no-loops | ||
for (const scriptName in pkgJson.scripts) { | ||
if (preserveScripts.has(scriptName)) continue | ||
|
||
delete pkgJson.scripts[scriptName] | ||
} | ||
await writeFile(packageJsonPath, JSON.stringify(pkgJson, null, 2)) | ||
spinner.succeed() | ||
|
||
spinner = ora({ | ||
spinner: 'star', | ||
text: 'Running `npm install --no-audit`', | ||
}).start() | ||
await execa('npm', ['install', '--no-audit']) | ||
spinner.succeed() | ||
|
||
spinner = ora({ | ||
spinner: 'star', | ||
text: 'Running `npm shrinkwrap`', | ||
}).start() | ||
await execa('npm', ['shrinkwrap']) | ||
spinner.succeed() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fc38644
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📊 Benchmark results