feat!: do not execute prepublish during installation (#3306)

* feat!: do not execute `prepublish` during installation

* test: fix
This commit is contained in:
Zoltan Kochan
2021-04-04 02:38:53 +03:00
committed by GitHub
parent b220f69007
commit 9e30b9659a
3 changed files with 7 additions and 17 deletions

View File

@@ -0,0 +1,5 @@
---
"supi": minor
---
Do not execute prepublish during installation.

View File

@@ -633,11 +633,9 @@ test('recursive install with shared-workspace-lockfile builds workspace projects
expect(outputs1).toStrictEqual([
'project-999-install',
'project-999-postinstall',
'project-999-prepublish',
'project-999-prepare',
'project-1-install',
'project-1-postinstall',
'project-1-prepublish',
'project-1-prepare',
])
@@ -645,11 +643,9 @@ test('recursive install with shared-workspace-lockfile builds workspace projects
expect(outputs2).toStrictEqual([
'project-999-install',
'project-999-postinstall',
'project-999-prepublish',
'project-999-prepare',
'project-2-install',
'project-2-postinstall',
'project-2-prepublish',
'project-2-prepare',
])
}
@@ -666,11 +662,9 @@ test('recursive install with shared-workspace-lockfile builds workspace projects
expect(outputs1).toStrictEqual([
'project-999-install',
'project-999-postinstall',
'project-999-prepublish',
'project-999-prepare',
'project-1-install',
'project-1-postinstall',
'project-1-prepublish',
'project-1-prepare',
])
@@ -678,11 +672,9 @@ test('recursive install with shared-workspace-lockfile builds workspace projects
expect(outputs2).toStrictEqual([
'project-999-install',
'project-999-postinstall',
'project-999-prepublish',
'project-999-prepare',
'project-2-install',
'project-2-postinstall',
'project-2-prepublish',
'project-2-prepare',
])
}

View File

@@ -408,9 +408,8 @@ export async function mutateModules (
if (ctx.wantedLockfile?.importers) {
forgetResolutionsOfPrevWantedDeps(ctx.wantedLockfile.importers[project.id], wantedDependencies)
}
const scripts = opts.ignoreScripts ? {} : (project.manifest?.scripts ?? {})
if (opts.ignoreScripts && project.manifest?.scripts &&
(project.manifest.scripts.preinstall || project.manifest.scripts.prepublish ||
(project.manifest.scripts.preinstall ||
project.manifest.scripts.install ||
project.manifest.scripts.postinstall ||
project.manifest.scripts.prepare)
@@ -418,12 +417,6 @@ export async function mutateModules (
ctx.pendingBuilds.push(project.id)
}
if (scripts['prepublish']) { // eslint-disable-line @typescript-eslint/dot-notation
logger.warn({
message: '`prepublish` scripts are deprecated. Use `prepare` for build steps and `prepublishOnly` for upload-only.',
prefix: project.rootDir,
})
}
projectsToInstall.push({
pruneDirectDependencies: false,
...project,
@@ -474,7 +467,7 @@ export async function mutateModules (
if (opts.enablePnp) {
scriptsOpts.extraEnv = makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.cjs'))
}
await runLifecycleHooksConcurrently(['install', 'postinstall', 'prepublish', 'prepare'],
await runLifecycleHooksConcurrently(['install', 'postinstall', 'prepare'],
projectsToBeInstalled,
opts.childConcurrency,
scriptsOpts