feat!: remove locking of node_modules

close #594
PR #2553
This commit is contained in:
Zoltan Kochan
2020-05-14 03:10:03 +03:00
committed by GitHub
parent 083d789689
commit 45fdcfde2e
17 changed files with 9 additions and 127 deletions

View File

@@ -0,0 +1,8 @@
---
"@pnpm/config": major
"@pnpm/plugin-commands-installation": major
"@pnpm/store-connection-manager": minor
"supi": minor
---
Locking is removed.

View File

@@ -91,8 +91,6 @@ export interface Config {
verifyStoreIntegrity?: boolean,
networkConcurrency?: number,
fetchingConcurrency?: number,
lockStaleDuration?: number,
lock: boolean,
lockfileOnly?: boolean, // like npm's --package-lock-only
childConcurrency?: number,
repeatInstallDepth?: number,

View File

@@ -46,8 +46,6 @@ export const types = Object.assign({
'ignore-workspace-root-check': Boolean,
'independent-leaves': Boolean,
'link-workspace-packages': Boolean,
'lock': Boolean,
'lock-stale-duration': Number,
'lockfile': Boolean,
'lockfile-dir': String,
'lockfile-directory': String, // TODO: deprecate
@@ -147,7 +145,6 @@ export default async (
'hoist-pattern': ['*'],
'ignore-workspace-root-check': false,
'link-workspace-packages': true,
'lock': true,
'package-lock': npmDefaults['package-lock'],
'pending': false,
'registry': npmDefaults.registry,

View File

@@ -53,7 +53,6 @@ export default async function testDefaults (
...fetchOpts,
}) as {},
{
locks: path.join(storeDir, '_locks'),
storeDir,
...storeOpts,
}

View File

@@ -23,7 +23,6 @@ export function rcOptionsTypes () {
'ignore-workspace-root-check',
'independent-leaves',
'link-workspace-packages',
'lock',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',

View File

@@ -24,7 +24,6 @@ export function rcOptionsTypes () {
'ignore-scripts',
'independent-leaves',
'link-workspace-packages',
'lock',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
@@ -166,9 +165,6 @@ export function help () {
description: "If false, doesn't check whether packages in the store were mutated",
name: '--[no-]verify-store-integrity',
},
{
name: '--[no-]lock',
},
{
description: 'Fail on missing or invalid peer dependencies',
name: '--strict-peer-dependencies',

View File

@@ -197,27 +197,6 @@ test('lockfile compatibility', async (t: tape.Test) => {
})
})
test('support installing and uninstalling from the same store simultaneously', async (t: tape.Test) => {
const project = prepare(t, {
dependencies: {
rimraf: '2.5.1',
},
})
await Promise.all([
execPnpm(['install', 'pkg-that-installs-slowly']),
(async () => {
await delay(500) // to be sure that lock was created
await project.storeHasNot('pkg-that-installs-slowly')
await execPnpm(['uninstall', 'rimraf'])
await project.hasNot('rimraf')
})(),
])
await project.has('pkg-that-installs-slowly')
})
test('top-level packages should find the plugins they use', async (t: tape.Test) => {
prepare(t, {
scripts: {

View File

@@ -18,7 +18,6 @@ export type CreateNewStoreControllerOptions = CreateResolverOptions & Pick<Confi
export default async (
opts: CreateNewStoreControllerOptions
) => {
// TODO: either print a warning or just log if --no-lock is used
const sopts = Object.assign(opts, {
registry: opts.registry || 'https://registry.npmjs.org/',
})

View File

@@ -13,7 +13,6 @@ export type CreateResolverOptions = Pick<Config,
'httpsProxy' |
'key' |
'localAddress' |
'lockStaleDuration' |
'offline' |
'proxy' |
'rawConfig' |

View File

@@ -22,7 +22,6 @@
"@pnpm/core-loggers": "workspace:4.0.2-alpha.0",
"@pnpm/error": "workspace:1.2.0",
"@pnpm/filter-lockfile": "workspace:3.2.3-alpha.1",
"@pnpm/fs-locker": "3.0.1",
"@pnpm/get-context": "workspace:2.0.0-alpha.1",
"@pnpm/headless": "workspace:13.0.0-alpha.4",
"@pnpm/hoist": "workspace:3.0.0-alpha.1",

View File

@@ -58,10 +58,7 @@ export interface StrictInstallOptions {
userAgent: string,
unsafePerm: boolean,
registries: Registries,
lock: boolean,
lockStaleDuration: number,
tag: string,
locks: string,
ownLifecycleHooksStdio: 'inherit' | 'pipe',
workspacePackages: WorkspacePackages,
pruneStore: boolean,
@@ -110,11 +107,8 @@ const defaults = async (opts: InstallOptions) => {
optionalDependencies: true,
},
independentLeaves: false,
lock: true,
lockfileDir: opts.lockfileDir || opts.dir || process.cwd(),
lockfileOnly: false,
locks: path.join(opts.storeDir, '_locks'),
lockStaleDuration: 5 * 60 * 1000, // 5 minutes
nodeVersion: process.version,
ownLifecycleHooksStdio: 'inherit',
packageManager,

View File

@@ -50,7 +50,6 @@ import pLimit from 'p-limit'
import path = require('path')
import R = require('ramda')
import getSpecFromPackageManifest from '../getSpecFromPackageManifest'
import lock from '../lock'
import parseWantedDependencies from '../parseWantedDependencies'
import safeIsInnerLink from '../safeIsInnerLink'
import removeDeps from '../uninstall/removeDeps'
@@ -151,17 +150,7 @@ export async function mutateModules (
}
}
let result!: Array<{ rootDir: string, manifest: ProjectManifest }>
if (opts.lock) {
result = await lock(ctx.lockfileDir, _install, {
locks: opts.locks,
prefix: ctx.lockfileDir,
stale: opts.lockStaleDuration,
storeController: opts.storeController,
})
} else {
result = await _install()
}
const result = await _install()
if (reporter) {
streamParser.removeListener('data', reporter)

View File

@@ -1,36 +0,0 @@
import lock from '@pnpm/fs-locker'
import logger from '@pnpm/logger'
import { StoreController } from '@pnpm/store-controller-types'
export default async function withLock<T> (
dir: string,
fn: () => Promise<T>,
opts: {
stale: number,
storeController: StoreController,
locks: string,
prefix: string,
}
): Promise<T> {
const unlock = await lock(dir, {
locks: opts.locks,
stale: opts.stale,
whenLocked () {
logger.warn({
message: 'waiting for another installation to complete...',
prefix: opts.prefix,
})
},
})
try {
const result = await fn()
await unlock()
return result
} catch (err) {
await unlock()
// TODO: revise how store locking works
// maybe it needs to happen outside of supi
await opts.storeController.close()
throw err
}
}

View File

@@ -43,7 +43,6 @@ test('--independent-leaves throws exception when executed on node_modules instal
...opts,
forceIndependentLeaves: false,
independentLeaves: true,
lock: false,
})
await project.has('is-negative')

View File

@@ -529,23 +529,6 @@ test('compiled modules (ursa@0.9.1)', async (t) => {
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
test('support installing into the same store simultaneously', async (t) => {
const project = prepareEmpty(t)
await Promise.all([
addDependenciesToPackage({}, ['pkg-that-installs-slowly'], await testDefaults({ fastUnpack: false })),
wait(500) // to be sure that lock was created
.then(async () => {
await project.storeHasNot('pkg-that-installs-slowly')
await addDependenciesToPackage({ dependencies: { 'pkg-that-installs-slowly': '*' } }, ['rimraf@2.5.1'], await testDefaults({ fastUnpack: false }))
})
.then(async () => {
await project.has('pkg-that-installs-slowly')
await project.has('rimraf')
})
.catch((err) => t.notOk(err)),
])
})
test('bin specified in the directories property linked to .bin folder', async (t) => {
const project = prepareEmpty(t)

View File

@@ -57,7 +57,6 @@ export default async function testDefaults<T> (
}) as {},
{
ignoreFile: opts?.fastUnpack === false ? undefined : (filename) => filename !== 'package.json',
locks: path.join(storeDir, '_locks'),
storeDir,
verifyStoreIntegrity: true,
...storeOpts,

19
pnpm-lock.yaml generated
View File

@@ -2558,7 +2558,6 @@ importers:
'@pnpm/core-loggers': 'link:../core-loggers'
'@pnpm/error': 'link:../error'
'@pnpm/filter-lockfile': 'link:../filter-lockfile'
'@pnpm/fs-locker': 3.0.1
'@pnpm/get-context': 'link:../get-context'
'@pnpm/headless': 'link:../headless'
'@pnpm/hoist': 'link:../hoist'
@@ -2661,7 +2660,6 @@ importers:
'@pnpm/default-resolver': 'workspace:*'
'@pnpm/error': 'workspace:1.2.0'
'@pnpm/filter-lockfile': 'workspace:3.2.3-alpha.1'
'@pnpm/fs-locker': 3.0.1
'@pnpm/get-context': 'workspace:2.0.0-alpha.1'
'@pnpm/headless': 'workspace:13.0.0-alpha.4'
'@pnpm/hoist': 'workspace:3.0.0-alpha.1'
@@ -3421,15 +3419,6 @@ packages:
node: '>=8.15'
resolution:
integrity: sha512-CMPclTpDRqgT241w6yKt/e3Mer/L5wFCAKTG5rGlhRz7f3BGhbuj4nblIVB/BTXhJty34Y57gKg4gbu3FVeQIA==
/@pnpm/fs-locker/3.0.1:
dependencies:
make-dir: 3.1.0
proper-lockfile: 3.2.0
dev: false
engines:
node: '>=8.15'
resolution:
integrity: sha512-o9d47i3E6XtVDIjxPjl9mg+phHnjScYtjhx5KiAZEcgV4nEjXCtnrQ8MjH8yjN8JVeCQH3FiioR1i+iD9DzkRw==
/@pnpm/logger/3.2.2:
dependencies:
bole: 3.0.2
@@ -10112,14 +10101,6 @@ packages:
node: '>= 8'
resolution:
integrity: sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==
/proper-lockfile/3.2.0:
dependencies:
graceful-fs: 4.2.1
retry: 0.12.0
signal-exit: 3.0.3
dev: false
resolution:
integrity: sha512-iMghHHXv2bsxl6NchhEaFck8tvX3F9cknEEh1SUpguUOBjN7PAAW9BLzmbc1g/mCD1gY3EE2EABBHPJfFdHFmA==
/proto-list/1.2.4:
dev: false
resolution: