feat: rename lockfile-directory to lockfile-dir

ref #2088
PR #2120
This commit is contained in:
Zoltan Kochan
2019-10-27 16:18:00 +02:00
committed by GitHub
parent 0b95d739ca
commit 4fc917ebbb
61 changed files with 311 additions and 305 deletions

View File

@@ -97,7 +97,7 @@ export interface Config {
sort: boolean,
strictPeerDependencies: boolean,
pending: boolean,
lockfileDirectory?: string,
lockfileDir?: string,
sharedWorkspaceLockfile?: boolean,
useLockfile: boolean,
resolutionStrategy: 'fast' | 'fewer-dependencies',
@@ -111,6 +111,7 @@ export interface Config {
export interface ConfigWithDeprecatedSettings extends Config {
frozenShrinkwrap?: boolean,
lockfileDirectory?: string,
shrinkwrapDirectory?: string,
shrinkwrapOnly?: boolean,
preferFrozenShrinkwrap?: boolean,

View File

@@ -44,7 +44,8 @@ export const types = Object.assign({
'lock': Boolean,
'lock-stale-duration': Number,
'lockfile': Boolean,
'lockfile-directory': path,
'lockfile-dir': String,
'lockfile-directory': path, // TODO: deprecate
'lockfile-only': Boolean,
'network-concurrency': Number,
'offline': Boolean,
@@ -217,9 +218,7 @@ export default async (
? npmGlobalPrefix
: path.resolve(npmGlobalPrefix, 'bin')
pnpmConfig.globalPrefix = path.join(npmGlobalPrefix, 'pnpm-global')
pnpmConfig.lockfileDirectory = typeof pnpmConfig['lockfileDirectory'] === 'undefined'
? pnpmConfig.shrinkwrapDirectory
: pnpmConfig['lockfileDirectory']
pnpmConfig.lockfileDir = pnpmConfig.lockfileDir ?? pnpmConfig.lockfileDirectory ?? pnpmConfig.shrinkwrapDirectory
pnpmConfig.useLockfile = (() => {
if (typeof pnpmConfig['lockfile'] === 'boolean') return pnpmConfig['lockfile']
if (typeof pnpmConfig['packageLock'] === 'boolean') return pnpmConfig['packageLock']
@@ -275,12 +274,12 @@ export default async (
}
pnpmConfig.sharedWorkspaceLockfile = false
}
if (pnpmConfig.lockfileDirectory) {
if (opts.cliArgs['lockfile-directory']) {
throw new PnpmError('CONFIG_CONFLICT_LOCKFILE_DIRECTORY_WITH_GLOBAL',
'Configuration conflict. "lockfile-directory" may not be used with "global"')
if (pnpmConfig.lockfileDir) {
if (opts.cliArgs['lockfile-dir']) {
throw new PnpmError('CONFIG_CONFLICT_LOCKFILE_DIR_WITH_GLOBAL',
'Configuration conflict. "lockfile-dir" may not be used with "global"')
}
delete pnpmConfig.lockfileDirectory
delete pnpmConfig.lockfileDir
}
if (opts.cliArgs['virtual-store-dir']) {
throw new PnpmError('CONFIG_CONFLICT_VIRTUAL_STORE_DIR_WITH_GLOBAL',
@@ -301,8 +300,8 @@ export default async (
}
pnpmConfig.saveDev = true
}
if (pnpmConfig.sharedWorkspaceLockfile && !pnpmConfig.lockfileDirectory) {
pnpmConfig.lockfileDirectory = pnpmConfig.workspacePrefix || undefined
if (pnpmConfig.sharedWorkspaceLockfile && !pnpmConfig.lockfileDir) {
pnpmConfig.lockfileDir = pnpmConfig.workspacePrefix || undefined
}
pnpmConfig.packageManager = packageManager

View File

@@ -71,12 +71,12 @@ test('throw error if --shared-workspace-lockfile is used with --global', async (
}
})
test('throw error if --lockfile-directory is used with --global', async (t) => {
test('throw error if --lockfile-dir is used with --global', async (t) => {
try {
await getConfig({
cliArgs: {
'global': true,
'lockfile-directory': '/home/src',
'lockfile-dir': '/home/src',
},
packageManager: {
name: 'pnpm',
@@ -84,8 +84,8 @@ test('throw error if --lockfile-directory is used with --global', async (t) => {
},
})
} catch (err) {
t.equal(err.message, 'Configuration conflict. "lockfile-directory" may not be used with "global"')
t.equal((err as PnpmError).code, 'ERR_PNPM_CONFIG_CONFLICT_LOCKFILE_DIRECTORY_WITH_GLOBAL')
t.equal(err.message, 'Configuration conflict. "lockfile-dir" may not be used with "global"')
t.equal((err as PnpmError).code, 'ERR_PNPM_CONFIG_CONFLICT_LOCKFILE_DIR_WITH_GLOBAL')
t.end()
}
})
@@ -172,7 +172,7 @@ test('when using --global, link-workspace-packages, shared-workspace-shrinwrap a
})
t.ok(config.linkWorkspacePackages)
t.ok(config.sharedWorkspaceLockfile)
t.ok(config.lockfileDirectory)
t.ok(config.lockfileDir)
}
{
@@ -187,7 +187,7 @@ test('when using --global, link-workspace-packages, shared-workspace-shrinwrap a
})
t.notOk(config.linkWorkspacePackages, 'link-workspace-packages is false')
t.notOk(config.sharedWorkspaceLockfile, 'shared-workspace-lockfile is false')
t.notOk(config.lockfileDirectory, 'lockfile-directory is null')
t.notOk(config.lockfileDir, 'lockfile-dir is null')
}
t.end()

View File

@@ -56,13 +56,13 @@ export default async function dependenciesHierarchy (
include?: { [dependenciesField in DependenciesField]: boolean },
registries?: Registries,
search?: SearchFunction,
lockfileDirectory: string,
lockfileDir: string,
},
): Promise<{ [prefix: string]: DependenciesHierarchy }> {
if (!maybeOpts || !maybeOpts.lockfileDirectory) {
throw new TypeError('opts.lockfileDirectory is required')
if (!maybeOpts || !maybeOpts.lockfileDir) {
throw new TypeError('opts.lockfileDir is required')
}
const modulesDir = await realNodeModulesDir(maybeOpts.lockfileDirectory)
const modulesDir = await realNodeModulesDir(maybeOpts.lockfileDir)
const modules = await readModulesYaml(modulesDir)
const registries = normalizeRegistries({
...maybeOpts && maybeOpts.registries,
@@ -86,7 +86,7 @@ export default async function dependenciesHierarchy (
devDependencies: true,
optionalDependencies: true,
},
lockfileDirectory: maybeOpts.lockfileDirectory,
lockfileDir: maybeOpts.lockfileDir,
registries,
search: maybeOpts.search,
skipped: new Set(modules && modules.skipped || []),
@@ -113,10 +113,10 @@ async function dependenciesHierarchyForPackage (
registries: Registries,
search?: SearchFunction,
skipped: Set<string>,
lockfileDirectory: string,
lockfileDir: string,
},
) {
const importerId = getLockfileImporterId(opts.lockfileDirectory, projectPath)
const importerId = getLockfileImporterId(opts.lockfileDir, projectPath)
if (!currentLockfile.importers[importerId]) return {}
@@ -125,7 +125,7 @@ async function dependenciesHierarchyForPackage (
const savedDeps = getAllDirectDependencies(currentLockfile.importers[importerId])
const allDirectDeps = await readModulesDir(modulesDir) || []
const unsavedDeps = allDirectDeps.filter((directDep) => !savedDeps[directDep])
const wantedLockfile = await readWantedLockfile(opts.lockfileDirectory, { ignoreIncompatible: false }) || { packages: {} }
const wantedLockfile = await readWantedLockfile(opts.lockfileDir, { ignoreIncompatible: false }) || { packages: {} }
const getChildrenTree = getTree.bind(null, {
currentDepth: 1,

View File

@@ -15,7 +15,7 @@ const fixtureMonorepo = path.join(__dirname, '..', 'fixtureMonorepo')
const withAliasedDepFixture = path.join(fixtures, 'with-aliased-dep')
test('one package depth 0', async t => {
const tree = await dh([generalFixture], { depth: 0, lockfileDirectory: generalFixture })
const tree = await dh([generalFixture], { depth: 0, lockfileDir: generalFixture })
const modulesDir = path.join(generalFixture, 'node_modules')
t.deepEqual(tree, {
@@ -78,7 +78,7 @@ test('one package depth 0', async t => {
})
test('one package depth 1', async t => {
const tree = await dh([generalFixture], { depth: 1, lockfileDirectory: generalFixture })
const tree = await dh([generalFixture], { depth: 1, lockfileDir: generalFixture })
const modulesDir = path.join(generalFixture, 'node_modules')
t.deepEqual(tree, {
@@ -178,7 +178,7 @@ test('only prod depth 0', async t => {
devDependencies: false,
optionalDependencies: false,
},
lockfileDirectory: generalFixture,
lockfileDir: generalFixture,
},
)
const modulesDir = path.join(generalFixture, 'node_modules')
@@ -225,7 +225,7 @@ test('only dev depth 0', async t => {
devDependencies: true,
optionalDependencies: false,
},
lockfileDirectory: generalFixture,
lockfileDir: generalFixture,
},
)
const modulesDir = path.join(generalFixture, 'node_modules')
@@ -254,7 +254,7 @@ test('only dev depth 0', async t => {
test('hierarchy for no packages', async t => {
const tree = await dh([generalFixture], {
depth: 100,
lockfileDirectory: generalFixture,
lockfileDir: generalFixture,
search: () => false,
})
@@ -274,7 +274,7 @@ test('filter 1 package with depth 0', async t => {
[generalFixture],
{
depth: 0,
lockfileDirectory: generalFixture,
lockfileDir: generalFixture,
search: ({ name }) => name === 'rimraf',
},
)
@@ -305,7 +305,7 @@ test('filter 1 package with depth 0', async t => {
})
test('circular dependency', async t => {
const tree = await dh([circularFixture], { depth: 1000, lockfileDirectory: circularFixture })
const tree = await dh([circularFixture], { depth: 1000, lockfileDir: circularFixture })
const modulesDir = path.join(circularFixture, 'node_modules')
t.deepEqual(tree, {
@@ -339,7 +339,7 @@ function resolvePaths (modulesDir: string, node: PackageNode): PackageNode {
}
test('local package depth 0', async t => {
const tree = await dh([withFileDepFixture], { depth: 1, lockfileDirectory: withFileDepFixture })
const tree = await dh([withFileDepFixture], { depth: 1, lockfileDir: withFileDepFixture })
const modulesDir = path.join(withFileDepFixture, 'node_modules')
t.deepEqual(tree, {
@@ -375,7 +375,7 @@ test('local package depth 0', async t => {
})
test('on a package that has only links', async t => {
const tree = await dh([withLinksOnlyFixture], { depth: 1000, lockfileDirectory: withLinksOnlyFixture })
const tree = await dh([withLinksOnlyFixture], { depth: 1000, lockfileDir: withLinksOnlyFixture })
t.deepEqual(tree, {
[withLinksOnlyFixture]: {
@@ -401,7 +401,7 @@ test('on a package that has only links', async t => {
test('unsaved dependencies are listed', async t => {
const modulesDir = path.join(withUnsavedDepsFixture, 'node_modules')
t.deepEqual(
await dh([withUnsavedDepsFixture], { depth: 0, lockfileDirectory: withUnsavedDepsFixture }),
await dh([withUnsavedDepsFixture], { depth: 0, lockfileDir: withUnsavedDepsFixture }),
{
[withUnsavedDepsFixture]: {
dependencies: [
@@ -452,7 +452,7 @@ test('unsaved dependencies are listed and filtered', async t => {
[withUnsavedDepsFixture],
{
depth: 0,
lockfileDirectory: withUnsavedDepsFixture,
lockfileDir: withUnsavedDepsFixture,
search: ({ name }) => name === 'symlink-dir',
},
),
@@ -482,14 +482,14 @@ test('unsaved dependencies are listed and filtered', async t => {
// Covers https://github.com/pnpm/pnpm/issues/1549
test(`do not fail on importers that are not in current ${WANTED_LOCKFILE}`, async t => {
t.deepEqual(await dh([fixtureMonorepo], { depth: 0, lockfileDirectory: fixtureMonorepo }), { [fixtureMonorepo]: {} })
t.deepEqual(await dh([fixtureMonorepo], { depth: 0, lockfileDir: fixtureMonorepo }), { [fixtureMonorepo]: {} })
t.end()
})
test('dependency with an alias', async t => {
const modulesDir = path.join(withAliasedDepFixture, 'node_modules')
t.deepEqual(
await dh([withAliasedDepFixture], { depth: 0, lockfileDirectory: withAliasedDepFixture }),
await dh([withAliasedDepFixture], { depth: 0, lockfileDir: withAliasedDepFixture }),
{
[withAliasedDepFixture]: {
dependencies: [
@@ -514,7 +514,7 @@ test('dependency with an alias', async t => {
})
test('peer dependencies', async t => {
const hierarchy = await dh([withPeerFixture], { depth: 1, lockfileDirectory: withPeerFixture })
const hierarchy = await dh([withPeerFixture], { depth: 1, lockfileDir: withPeerFixture })
t.equal(hierarchy[withPeerFixture].dependencies![1].dependencies![0].name, 'ajv')
t.equal(hierarchy[withPeerFixture].dependencies![1].dependencies![0].isPeer, true)
t.end()

View File

@@ -88,7 +88,7 @@ export interface HeadlessOptions {
}>,
hoistedAliases: {[depPath: string]: string[]}
hoistPattern?: string[],
lockfileDirectory: string,
lockfileDir: string,
virtualStoreDir?: string,
shamefullyHoist: boolean,
storeController: StoreController,
@@ -118,7 +118,7 @@ export default async (opts: HeadlessOptions) => {
streamParser.on('data', reporter)
}
const lockfileDir = opts.lockfileDirectory
const lockfileDir = opts.lockfileDir
const wantedLockfile = opts.wantedLockfile || await readWantedLockfile(lockfileDir, { ignoreIncompatible: false })
if (!wantedLockfile) {
@@ -245,14 +245,14 @@ export default async (opts: HeadlessOptions) => {
getIndependentPackageLocation: opts.independentLeaves
? async (packageId: string, packageName: string) => {
const { directory } = await opts.storeController.getPackageLocation(packageId, packageName, {
lockfileDirectory: lockfileDir,
lockfileDir,
targetEngine: opts.sideEffectsCacheRead && ENGINE_NAME || undefined,
})
return directory
}
: undefined,
lockfile: filteredLockfile,
lockfileDirectory: lockfileDir,
lockfileDir,
modulesDir: hoistedModulesDir,
registries: opts.registries,
virtualStoreDir,
@@ -496,7 +496,7 @@ async function lockfileToDepGraph (
const modules = path.join(opts.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDir), 'node_modules')
const packageId = packageIdFromSnapshot(relDepPath, pkgSnapshot, opts.registries)
const pkgLocation = await opts.storeController.getPackageLocation(packageId, pkgName, {
lockfileDirectory: opts.lockfileDir,
lockfileDir: opts.lockfileDir,
targetEngine: opts.sideEffectsCacheRead && !opts.force && ENGINE_NAME || undefined,
})
@@ -632,7 +632,7 @@ async function getChildrenPaths (
const pkgId = childPkgSnapshot.id || childDepPath
const pkgName = nameVerFromPkgSnapshot(childRelDepPath, childPkgSnapshot).name
const pkgLocation = await ctx.storeController.getPackageLocation(pkgId, pkgName, {
lockfileDirectory: ctx.lockfileDir,
lockfileDir: ctx.lockfileDir,
targetEngine: ctx.sideEffectsCacheRead && !ctx.force && ENGINE_NAME || undefined,
})
children[alias] = pkgLocation.directory

View File

@@ -29,7 +29,7 @@ test('installing a simple project', async (t) => {
const reporter = sinon.spy()
await headless(await testDefaults({
lockfileDirectory: prefix,
lockfileDir: prefix,
reporter,
}))
@@ -90,7 +90,7 @@ test('installing only prod deps', async (t) => {
devDependencies: false,
optionalDependencies: false,
},
lockfileDirectory: prefix,
lockfileDir: prefix,
}))
const project = assertProject(t, prefix)
@@ -114,7 +114,7 @@ test('installing only dev deps', async (t) => {
devDependencies: true,
optionalDependencies: false,
},
lockfileDirectory: prefix,
lockfileDir: prefix,
}))
const project = assertProject(t, prefix)
@@ -135,7 +135,7 @@ test('installing non-prod deps then all deps', async (t) => {
devDependencies: true,
optionalDependencies: true,
},
lockfileDirectory: prefix,
lockfileDir: prefix,
}))
const project = assertProject(t, prefix)
@@ -163,7 +163,7 @@ test('installing non-prod deps then all deps', async (t) => {
devDependencies: true,
optionalDependencies: true,
},
lockfileDirectory: prefix,
lockfileDir: prefix,
reporter,
}))
@@ -207,7 +207,7 @@ test('installing only optional deps', async (t) => {
devDependencies: false,
optionalDependencies: true,
},
lockfileDirectory: prefix,
lockfileDir: prefix,
optional: true,
production: false,
}))
@@ -232,7 +232,7 @@ test('not installing optional deps', async (t) => {
devDependencies: true,
optionalDependencies: false,
},
lockfileDirectory: prefix,
lockfileDir: prefix,
}))
const project = assertProject(t, prefix)
@@ -262,7 +262,7 @@ test('installing with independent-leaves and hoistPattern=*', async (t) => {
importers.map(async (importer) => ({ ...importer, manifest: await readPackageJsonFromDir(importer.prefix), })),
),
independentLeaves: true,
lockfileDirectory: prefix,
lockfileDir: prefix,
}))
const project = assertProject(t, prefix)
@@ -287,7 +287,7 @@ test('installing with independent-leaves when an optional subdep is skipped', as
await headless(await testDefaults({
independentLeaves: true,
lockfileDirectory: prefix,
lockfileDir: prefix,
}))
const modulesInfo = await readYamlFile<{ skipped: string[] }>(path.join(prefix, 'node_modules', '.modules.yaml'))
@@ -311,7 +311,7 @@ test('run pre/postinstall scripts', async (t) => {
const outputJsonPath = path.join(prefix, 'output.json')
await rimraf(outputJsonPath)
await headless(await testDefaults({ lockfileDirectory: prefix }))
await headless(await testDefaults({ lockfileDir: prefix }))
const project = assertProject(t, prefix)
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
@@ -325,7 +325,7 @@ test('run pre/postinstall scripts', async (t) => {
await rimraf(outputJsonPath)
await rimraf(path.join(prefix, 'node_modules'))
await headless(await testDefaults({ lockfileDirectory: prefix, ignoreScripts: true }))
await headless(await testDefaults({ lockfileDir: prefix, ignoreScripts: true }))
t.notOk(await exists(outputJsonPath))
@@ -353,7 +353,7 @@ test('orphan packages are removed', async (t) => {
fse.copySync(path.join(simpleWithMoreDepsDir, WANTED_LOCKFILE), destLockfileYamlPath)
await headless(await testDefaults({
lockfileDirectory: projectDir,
lockfileDir: projectDir,
}))
fse.copySync(path.join(simpleDir, 'package.json'), destPackageJsonPath)
@@ -361,7 +361,7 @@ test('orphan packages are removed', async (t) => {
const reporter = sinon.spy()
await headless(await testDefaults({
lockfileDirectory: projectDir,
lockfileDir: projectDir,
reporter,
}))
@@ -393,13 +393,13 @@ test('available packages are used when node_modules is not clean', async (t) =>
fse.copySync(path.join(hasGlobDir, 'package.json'), destPackageJsonPath)
fse.copySync(path.join(hasGlobDir, WANTED_LOCKFILE), destLockfileYamlPath)
await headless(await testDefaults({ lockfileDirectory: projectDir }))
await headless(await testDefaults({ lockfileDir: projectDir }))
fse.copySync(path.join(hasGlobAndRimrafDir, 'package.json'), destPackageJsonPath)
fse.copySync(path.join(hasGlobAndRimrafDir, WANTED_LOCKFILE), destLockfileYamlPath)
const reporter = sinon.spy()
await headless(await testDefaults({ lockfileDirectory: projectDir, reporter }))
await headless(await testDefaults({ lockfileDir: projectDir, reporter }))
const project = assertProject(t, projectDir)
await project.has('rimraf')
@@ -433,13 +433,13 @@ test('available packages are relinked during forced install', async (t) => {
fse.copySync(path.join(hasGlobDir, 'package.json'), destPackageJsonPath)
fse.copySync(path.join(hasGlobDir, WANTED_LOCKFILE), destLockfileYamlPath)
await headless(await testDefaults({ lockfileDirectory: projectDir }))
await headless(await testDefaults({ lockfileDir: projectDir }))
fse.copySync(path.join(hasGlobAndRimrafDir, 'package.json'), destPackageJsonPath)
fse.copySync(path.join(hasGlobAndRimrafDir, WANTED_LOCKFILE), destLockfileYamlPath)
const reporter = sinon.spy()
await headless(await testDefaults({ lockfileDirectory: projectDir, reporter, force: true }))
await headless(await testDefaults({ lockfileDir: projectDir, reporter, force: true }))
const project = assertProject(t, projectDir)
await project.has('rimraf')
@@ -472,7 +472,7 @@ test(`fail when ${WANTED_LOCKFILE} is not up-to-date with package.json`, async (
fse.copySync(path.join(simpleWithMoreDepsDir, WANTED_LOCKFILE), path.join(projectDir, WANTED_LOCKFILE))
try {
await headless(await testDefaults({ lockfileDirectory: projectDir }))
await headless(await testDefaults({ lockfileDir: projectDir }))
t.fail()
} catch (err) {
t.equal(err.message, `Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up-to-date with package.json`)
@@ -485,7 +485,7 @@ test('installing local dependency', async (t) => {
const prefix = path.join(fixtures, 'has-local-dep')
const reporter = sinon.spy()
await headless(await testDefaults({ lockfileDirectory: prefix, reporter }))
await headless(await testDefaults({ lockfileDir: prefix, reporter }))
const project = assertProject(t, prefix)
t.ok(project.requireModule('tar-pkg'), 'prod dep installed')
@@ -497,7 +497,7 @@ test('installing local directory dependency', async (t) => {
const prefix = path.join(fixtures, 'has-local-dir-dep')
const reporter = sinon.spy()
await headless(await testDefaults({ lockfileDirectory: prefix, reporter }))
await headless(await testDefaults({ lockfileDir: prefix, reporter }))
const project = assertProject(t, prefix)
t.ok(project.requireModule('example/package.json'), 'prod dep installed')
@@ -516,7 +516,7 @@ test('installing using passed in lockfile files', async (t) => {
const wantedLockfile = await readWantedLockfile(simplePkgPath, { ignoreIncompatible: false })
await headless(await testDefaults({
lockfileDirectory: prefix,
lockfileDir: prefix,
wantedLockfile,
}))
@@ -533,7 +533,7 @@ test('installing using passed in lockfile files', async (t) => {
test('installation of a dependency that has a resolved peer in subdeps', async (t) => {
const prefix = path.join(fixtures, 'resolved-peer-deps-in-subdeps')
await headless(await testDefaults({ lockfileDirectory: prefix }))
await headless(await testDefaults({ lockfileDir: prefix }))
const project = assertProject(t, prefix)
t.ok(project.requireModule('pnpm-default-reporter'), 'prod dep installed')
@@ -546,7 +546,7 @@ test('independent-leaves: installing a simple project', async (t) => {
await rimraf(path.join(prefix, 'node_modules'))
const reporter = sinon.spy()
await headless(await testDefaults({ lockfileDirectory: prefix, reporter, independentLeaves: true }))
await headless(await testDefaults({ lockfileDir: prefix, reporter, independentLeaves: true }))
const project = assertProject(t, prefix)
t.ok(project.requireModule('is-positive'), 'prod dep installed')
@@ -592,7 +592,7 @@ test('installing with hoistPattern=*', async (t) => {
const prefix = path.join(fixtures, 'simple-shamefully-flatten')
const reporter = sinon.spy()
await headless(await testDefaults({ lockfileDirectory: prefix, reporter, hoistPattern: '*' }))
await headless(await testDefaults({ lockfileDir: prefix, reporter, hoistPattern: '*' }))
const project = assertProject(t, prefix)
t.ok(project.requireModule('is-positive'), 'prod dep installed')
@@ -652,7 +652,7 @@ test('installing with hoistPattern=* and shamefullyHoist=true', async (t) => {
await rimraf(path.join(prefix, 'node_modules'))
const reporter = sinon.spy()
await headless(await testDefaults({ lockfileDirectory: prefix, reporter, hoistPattern: '*', shamefullyHoist: true }))
await headless(await testDefaults({ lockfileDir: prefix, reporter, hoistPattern: '*', shamefullyHoist: true }))
const project = assertProject(t, prefix)
t.ok(project.requireModule('is-positive'), 'prod dep installed')
@@ -715,7 +715,7 @@ test('using side effects cache', async (t) => {
// Right now, hardlink does not work with side effects, so we specify copy as the packageImportMethod
// We disable verifyStoreIntegrity because we are going to change the cache
const opts = await testDefaults({
lockfileDirectory: prefix,
lockfileDir: prefix,
sideEffectsCacheRead: true,
sideEffectsCacheWrite: true,
verifyStoreIntegrity: false,
@@ -752,7 +752,7 @@ test('using side effects cache and hoistPattern=*', async (t) => {
importers: await Promise.all(
importers.map(async (importer) => ({ ...importer, manifest: await readPackageJsonFromDir(importer.prefix), })),
),
lockfileDirectory: prefix,
lockfileDir: prefix,
sideEffectsCacheRead: true,
sideEffectsCacheWrite: true,
verifyStoreIntegrity: false,
@@ -796,7 +796,7 @@ test('installing in a workspace', async (t) => {
await headless(await testDefaults({
importers,
lockfileDirectory: workspaceFixture,
lockfileDir: workspaceFixture,
}))
const projectBar = assertProject(t, path.join(workspaceFixture, 'bar'))
@@ -805,7 +805,7 @@ test('installing in a workspace', async (t) => {
await headless(await testDefaults({
importers: [importers[0]],
lockfileDirectory: workspaceFixture,
lockfileDir: workspaceFixture,
}))
const rootNodeModules = assertProject(t, workspaceFixture)
@@ -838,7 +838,7 @@ test('independent-leaves: installing in a workspace', async (t) => {
importers.map(async (importer) => ({ ...importer, manifest: await readPackageJsonFromDir(importer.prefix), })),
),
independentLeaves: true,
lockfileDirectory: workspaceFixture,
lockfileDir: workspaceFixture,
}))
const projectBar = assertProject(t, path.join(workspaceFixture, 'bar'))

View File

@@ -24,16 +24,16 @@ export default async function testDefaults (
storeOpts?: any, // tslint:disable-line
): Promise<HeadlessOptions> {
let storeDir = opts && opts.storeDir || tempy.directory()
const lockfileDirectory = opts && opts.lockfileDirectory || process.cwd()
const lockfileDir = opts && opts.lockfileDir || process.cwd()
const { importers, include, pendingBuilds, registries } = await readImportersContext(
[
{
prefix: lockfileDirectory,
prefix: lockfileDir,
},
],
lockfileDirectory,
lockfileDir,
)
storeDir = await storePath(lockfileDirectory, storeDir)
storeDir = await storePath(lockfileDir, storeDir)
const rawConfig = { registry }
const storeController = await createStore(
createResolver({
@@ -69,7 +69,7 @@ export default async function testDefaults (
),
include,
independentLeaves: false,
lockfileDirectory,
lockfileDir,
packageManager: {
name: 'pnpm',
version: '1.0.0',

View File

@@ -19,7 +19,7 @@ export default async function hoistByLockfile (
opts: {
getIndependentPackageLocation?: (packageId: string, packageName: string) => Promise<string>,
lockfile: Lockfile,
lockfileDirectory: string,
lockfileDir: string,
modulesDir: string,
registries: Registries,
virtualStoreDir: string,
@@ -43,7 +43,7 @@ export default async function hoistByLockfile (
const deps = await getDependencies(opts.lockfile.packages, Array.from(entryNodes.values()), new Set(), 0, {
getIndependentPackageLocation: opts.getIndependentPackageLocation,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
registries: opts.registries,
virtualStoreDir: opts.virtualStoreDir,
})
@@ -76,7 +76,7 @@ async function getDependencies (
opts: {
getIndependentPackageLocation?: (packageId: string, packageName: string) => Promise<string>,
registries: Registries,
lockfileDirectory: string,
lockfileDir: string,
virtualStoreDir: string,
},
): Promise<Dependency[]> {
@@ -100,7 +100,7 @@ async function getDependencies (
const absolutePath = dp.resolve(opts.registries, depRelPath)
const pkgName = nameVerFromPkgSnapshot(depRelPath, pkgSnapshot).name
const modules = path.join(opts.virtualStoreDir, pkgIdToFilename(absolutePath, opts.lockfileDirectory), 'node_modules')
const modules = path.join(opts.virtualStoreDir, pkgIdToFilename(absolutePath, opts.lockfileDir), 'node_modules')
const independent = opts.getIndependentPackageLocation && packageIsIndependent(pkgSnapshot)
const allDeps = {
...pkgSnapshot.dependencies,

View File

@@ -22,7 +22,7 @@ export async function forPackages (
maybeOpts: {
alwaysPrintRootPackage?: boolean,
depth?: number,
lockfileDirectory: string,
lockfileDir: string,
long?: boolean,
include?: { [dependenciesField in DependenciesField]: boolean },
reportAs?: 'parseable' | 'tree' | 'json',
@@ -37,7 +37,7 @@ export async function forPackages (
R.toPairs(await dh(projectPaths, {
depth: opts.depth,
include: maybeOpts?.include,
lockfileDirectory: maybeOpts?.lockfileDirectory,
lockfileDir: maybeOpts?.lockfileDir,
registries: opts.registries,
search,
}))
@@ -67,7 +67,7 @@ export default async function (
maybeOpts: {
alwaysPrintRootPackage?: boolean,
depth?: number,
lockfileDirectory: string,
lockfileDir: string,
long?: boolean,
include?: { [dependenciesField in DependenciesField]: boolean },
reportAs?: 'parseable' | 'tree' | 'json',
@@ -86,7 +86,7 @@ export default async function (
: await dh(projectPaths, {
depth: opts.depth,
include: maybeOpts && maybeOpts.include,
lockfileDirectory: maybeOpts && maybeOpts.lockfileDirectory,
lockfileDir: maybeOpts && maybeOpts.lockfileDir,
registries: opts.registries,
})
)

View File

@@ -31,7 +31,7 @@ const fixtureWithAliasedDep = path.join(__dirname, 'with-aliased-dep')
test('list all deps of a package that has an external lockfile', async (t) => {
t.equal(await list([fixtureWithExternalLockfile], {
lockfileDirectory: path.join(fixtureWithExternalLockfile, '..'),
lockfileDir: path.join(fixtureWithExternalLockfile, '..'),
}), stripIndent`
${LEGEND}
@@ -45,7 +45,7 @@ test('list all deps of a package that has an external lockfile', async (t) => {
})
test('list with default parameters', async t => {
t.equal(await list([fixture], { lockfileDirectory: fixture }), stripIndent`
t.equal(await list([fixture], { lockfileDir: fixture }), stripIndent`
${LEGEND}
fixture@1.0.0 ${fixture}
@@ -64,7 +64,7 @@ test('list with default parameters', async t => {
})
test('list with default parameters in pkg that has no name and version', async t => {
t.equal(await list([fixtureWithNoPkgNameAndNoVersion], { lockfileDirectory: fixtureWithNoPkgNameAndNoVersion }), stripIndent`
t.equal(await list([fixtureWithNoPkgNameAndNoVersion], { lockfileDir: fixtureWithNoPkgNameAndNoVersion }), stripIndent`
${LEGEND}
${fixtureWithNoPkgNameAndNoVersion}
@@ -83,7 +83,7 @@ test('list with default parameters in pkg that has no name and version', async t
})
test('list with default parameters in pkg that has no version', async t => {
t.equal(await list([fixtureWithNoPkgVersion], { lockfileDirectory: fixtureWithNoPkgVersion }), stripIndent`
t.equal(await list([fixtureWithNoPkgVersion], { lockfileDir: fixtureWithNoPkgVersion }), stripIndent`
${LEGEND}
fixture ${fixtureWithNoPkgVersion}
@@ -105,7 +105,7 @@ test('list dev only', async t => {
t.equal(
await list([fixture], {
include: { dependencies: false, devDependencies: true, optionalDependencies: false },
lockfileDirectory: fixture,
lockfileDir: fixture,
}),
stripIndent`
${LEGEND}
@@ -124,7 +124,7 @@ test('list prod only', async t => {
t.equal(
await list([fixture], {
include: { dependencies: true, devDependencies: false, optionalDependencies: false },
lockfileDirectory: fixture,
lockfileDir: fixture,
}),
stripIndent`
${LEGEND}
@@ -144,7 +144,7 @@ test('list prod only with depth 2', async t => {
await list([fixture], {
depth: 2,
include: { dependencies: true, devDependencies: false, optionalDependencies: false },
lockfileDirectory: fixture,
lockfileDir: fixture,
}),
stripIndent`
${LEGEND}
@@ -171,7 +171,7 @@ test('list prod only with depth 2', async t => {
})
test('list with depth 1', async t => {
t.equal(await list([fixture], { depth: 1, lockfileDirectory: fixture }), stripIndent`
t.equal(await list([fixture], { depth: 1, lockfileDir: fixture }), stripIndent`
${LEGEND}
fixture@1.0.0 ${fixture}
@@ -196,14 +196,14 @@ test('list with depth 1', async t => {
})
test('list with depth -1', async t => {
t.equal(await list([fixture], { depth: -1, lockfileDirectory: fixture }), `fixture@1.0.0 ${fixture}`)
t.equal(await list([fixture], { depth: -1, lockfileDir: fixture }), `fixture@1.0.0 ${fixture}`)
t.end()
})
test('list with depth 1 and selected packages', async t => {
t.equal(
await listForPackages(['make-dir', 'pify@2', 'sort-keys@2', 'is-negative'], [fixture], { depth: 1, lockfileDirectory: fixture }),
await listForPackages(['make-dir', 'pify@2', 'sort-keys@2', 'is-negative'], [fixture], { depth: 1, lockfileDir: fixture }),
stripIndent`
${LEGEND}
@@ -233,7 +233,7 @@ function compareOutputs (t: test.Test, actual: string, expected: string) {
}
test('list in long format', async t => {
compareOutputs(t, await list([fixture], { long: true, lockfileDirectory: fixture }), stripIndent`
compareOutputs(t, await list([fixture], { long: true, lockfileDir: fixture }), stripIndent`
${LEGEND}
fixture@1.0.0 ${fixture}
@@ -256,7 +256,7 @@ test('list in long format', async t => {
})
test('parseable list with depth 1', async t => {
t.equal(await list([fixture], { reportAs: 'parseable', depth: 1, lockfileDirectory: fixture }), stripIndent`
t.equal(await list([fixture], { reportAs: 'parseable', depth: 1, lockfileDir: fixture }), stripIndent`
${fixture}
${path.join(fixture, 'node_modules/.pnpm/registry.npmjs.org/detect-indent/5.0.0')}
${path.join(fixture, 'node_modules/.pnpm/registry.npmjs.org/graceful-fs/4.2.2')}
@@ -273,7 +273,7 @@ test('parseable list with depth 1', async t => {
})
test('JSON list with depth 1', async t => {
t.equal(await list([fixture], { reportAs: 'json', depth: 1, lockfileDirectory: fixture }), JSON.stringify([{
t.equal(await list([fixture], { reportAs: 'json', depth: 1, lockfileDir: fixture }), JSON.stringify([{
name: 'fixture',
version: '1.0.0',
@@ -346,7 +346,7 @@ test('JSON list with depth 1', async t => {
test('JSON list with aliased dep', async t => {
t.equal(
await list([fixtureWithAliasedDep], { reportAs: 'json', lockfileDirectory: fixtureWithAliasedDep }),
await list([fixtureWithAliasedDep], { reportAs: 'json', lockfileDir: fixtureWithAliasedDep }),
JSON.stringify([
{
name: 'with-aliased-dep',
@@ -364,7 +364,7 @@ test('JSON list with aliased dep', async t => {
], null, 2),
)
t.equal(
await list([fixtureWithAliasedDep], { lockfileDirectory: fixtureWithAliasedDep, long: true, reportAs: 'json' }),
await list([fixtureWithAliasedDep], { lockfileDir: fixtureWithAliasedDep, long: true, reportAs: 'json' }),
JSON.stringify([{
name: 'with-aliased-dep',
version: '1.0.0',
@@ -392,7 +392,7 @@ test('parseable list with depth 1 and dev only', async t => {
await list([fixture], {
depth: 1,
include: { dependencies: false, devDependencies: true, optionalDependencies: false },
lockfileDirectory: fixture,
lockfileDir: fixture,
reportAs: 'parseable',
}),
stripIndent`
@@ -405,7 +405,7 @@ test('parseable list with depth 1 and dev only', async t => {
})
test('long parseable list with depth 1', async t => {
t.equal(await list([fixture], { reportAs: 'parseable', depth: 1, lockfileDirectory: fixture, long: true }), stripIndent`
t.equal(await list([fixture], { reportAs: 'parseable', depth: 1, lockfileDir: fixture, long: true }), stripIndent`
${fixture}:fixture@1.0.0
${path.join(fixture, 'node_modules/.pnpm/registry.npmjs.org/detect-indent/5.0.0')}:detect-indent@5.0.0
${path.join(fixture, 'node_modules/.pnpm/registry.npmjs.org/graceful-fs/4.2.2')}:graceful-fs@4.2.2
@@ -422,7 +422,7 @@ test('long parseable list with depth 1', async t => {
})
test('long parseable list with depth 1 when package has no version', async t => {
t.equal(await list([fixtureWithNoPkgVersion], { reportAs: 'parseable', depth: 1, lockfileDirectory: fixtureWithNoPkgVersion, long: true }), stripIndent`
t.equal(await list([fixtureWithNoPkgVersion], { reportAs: 'parseable', depth: 1, lockfileDir: fixtureWithNoPkgVersion, long: true }), stripIndent`
${fixtureWithNoPkgVersion}:fixture
${path.join(fixtureWithNoPkgVersion, 'node_modules/.pnpm/registry.npmjs.org/detect-indent/5.0.0')}:detect-indent@5.0.0
${path.join(fixtureWithNoPkgVersion, 'node_modules/.pnpm/registry.npmjs.org/graceful-fs/4.2.2')}:graceful-fs@4.2.2
@@ -442,7 +442,7 @@ test('long parseable list with depth 1 when package has no name and no version',
t.equal(
await list(
[fixtureWithNoPkgNameAndNoVersion],
{ reportAs: 'parseable', depth: 1, lockfileDirectory: fixtureWithNoPkgNameAndNoVersion, long: true },
{ reportAs: 'parseable', depth: 1, lockfileDir: fixtureWithNoPkgNameAndNoVersion, long: true },
),
stripIndent`
${fixtureWithNoPkgNameAndNoVersion}
@@ -462,12 +462,12 @@ test('long parseable list with depth 1 when package has no name and no version',
})
test('print empty', async t => {
t.equal(await list([emptyFixture], { lockfileDirectory: emptyFixture }), `${LEGEND}\n\nempty@1.0.0 ${emptyFixture}`)
t.equal(await list([emptyFixture], { lockfileDir: emptyFixture }), `${LEGEND}\n\nempty@1.0.0 ${emptyFixture}`)
t.end()
})
test("don't print empty", async t => {
t.equal(await list([emptyFixture], { alwaysPrintRootPackage: false, lockfileDirectory: emptyFixture }), '')
t.equal(await list([emptyFixture], { alwaysPrintRootPackage: false, lockfileDir: emptyFixture }), '')
t.end()
})
@@ -711,7 +711,7 @@ test('sort list items', async (t) => {
test('peer dependencies are marked', async (t) => {
const fixture = path.join(__dirname, '../../dependencies-hierarchy/fixtures/with-peer')
const output = await list([fixture], { depth: 1, lockfileDirectory: fixture })
const output = await list([fixture], { depth: 1, lockfileDir: fixture })
compareOutputs(t, output, stripIndent`
${LEGEND}
@@ -731,7 +731,7 @@ test('peer dependencies are marked', async (t) => {
test('peer dependencies are marked when searching', async (t) => {
const fixture = path.join(__dirname, '../../dependencies-hierarchy/fixtures/with-peer')
const output = await listForPackages(['ajv'], [fixture], { depth: 1, lockfileDirectory: fixture })
const output = await listForPackages(['ajv'], [fixture], { depth: 1, lockfileDir: fixture })
compareOutputs(t, output, stripIndent`
${LEGEND}

View File

@@ -17,7 +17,7 @@ export default async function resolveLocal (
wantedDependency: {pref: string},
opts: {
prefix: string,
lockfileDirectory?: string,
lockfileDir?: string,
},
): Promise<(ResolveResult & ({
id: string,
@@ -29,7 +29,7 @@ export default async function resolveLocal (
package: DependencyManifest,
resolution: DirectoryResolution,
})) | null> {
const spec = parsePref(wantedDependency.pref, opts.prefix, opts.lockfileDirectory || opts.prefix)
const spec = parsePref(wantedDependency.pref, opts.prefix, opts.lockfileDir || opts.prefix)
if (!spec) return null
if (spec.type === 'file') {

View File

@@ -20,10 +20,10 @@ export interface LocalPackageSpec {
export default function parsePref (
pref: string,
importerPrefix: string,
lockfileDirectory: string,
lockfileDir: string,
): LocalPackageSpec | null {
if (pref.startsWith('link:')) {
return fromLocal(pref, importerPrefix, lockfileDirectory, 'directory')
return fromLocal(pref, importerPrefix, lockfileDir, 'directory')
}
if (pref.endsWith('.tgz')
|| pref.endsWith('.tar.gz')
@@ -33,7 +33,7 @@ export default function parsePref (
|| isFilespec.test(pref)
) {
const type = isFilename.test(pref) ? 'file' : 'directory'
return fromLocal(pref, importerPrefix, lockfileDirectory, type)
return fromLocal(pref, importerPrefix, lockfileDir, type)
}
if (pref.startsWith('path:')) {
const err = new PnpmError('PATH_IS_UNSUPPORTED_PROTOCOL', 'Local dependencies via `path:` protocol are not supported. ' +
@@ -50,7 +50,7 @@ export default function parsePref (
function fromLocal (
pref: string,
importerPrefix: string,
lockfileDirectory: string,
lockfileDir: string,
type: 'file' | 'directory',
): LocalPackageSpec {
if (!importerPrefix) importerPrefix = process.cwd()
@@ -76,9 +76,9 @@ function fromLocal (
}
const dependencyPath = normalize(path.relative(importerPrefix, fetchSpec))
const id = type === 'directory' || importerPrefix === lockfileDirectory
const id = type === 'directory' || importerPrefix === lockfileDir
? `${protocol}${dependencyPath}`
: `${protocol}${normalize(path.relative(lockfileDirectory, fetchSpec))}`
: `${protocol}${normalize(path.relative(lockfileDir, fetchSpec))}`
return {
dependencyPath,

View File

@@ -53,7 +53,7 @@ test('resolve file', async t => {
test("resolve file when lockfile directory differs from the package's dir", async t => {
const wantedDependency = { pref: './pnpm-local-resolver-0.1.1.tgz' }
const resolveResult = await resolveFromLocal(wantedDependency, {
lockfileDirectory: path.join(__dirname, '..'),
lockfileDir: path.join(__dirname, '..'),
prefix: __dirname,
})

View File

@@ -1,4 +1,4 @@
import normalize = require('normalize-path')
import path = require('path')
export default (lockfileDirectory: string, prefix: string): string => normalize(path.relative(lockfileDirectory, prefix)) || '.'
export default (lockfileDir: string, prefix: string): string => normalize(path.relative(lockfileDir, prefix)) || '.'

View File

@@ -30,12 +30,12 @@ export default async function outdated (
manifest: ImporterManifest,
prefix: string,
getLatestManifest: GetLatestManifestFunction,
lockfileDirectory: string,
lockfileDir: string,
wantedLockfile: Lockfile,
},
): Promise<OutdatedPackage[]> {
if (packageHasNoDeps(opts.manifest)) return []
const importerId = getLockfileImporterId(opts.lockfileDirectory, opts.prefix)
const importerId = getLockfileImporterId(opts.lockfileDir, opts.prefix)
const currentLockfile = opts.currentLockfile || { importers: { [importerId]: {} } }
const outdated: OutdatedPackage[] = []

View File

@@ -72,7 +72,7 @@ test('outdated()', async (t) => {
},
},
getLatestManifest,
lockfileDirectory: 'project',
lockfileDir: 'project',
manifest: {
name: 'wanted-shrinkwrap',
version: '1.0.0',
@@ -203,7 +203,7 @@ test('outdated() should return deprecated package even if its current version is
const outdatedPkgs = await outdated({
currentLockfile: lockfile,
getLatestManifest,
lockfileDirectory: 'project',
lockfileDir: 'project',
manifest: {
name: 'wanted-shrinkwrap',
version: '1.0.0',
@@ -273,7 +273,7 @@ test('using a matcher', async (t) => {
},
},
getLatestManifest,
lockfileDirectory: 'wanted-shrinkwrap',
lockfileDir: 'wanted-shrinkwrap',
manifest: {
name: 'wanted-shrinkwrap',
version: '1.0.0',
@@ -372,7 +372,7 @@ test('outdated() aliased dependency', async (t) => {
},
},
getLatestManifest,
lockfileDirectory: 'project',
lockfileDir: 'project',
manifest: {
name: 'wanted-shrinkwrap',
version: '1.0.0',

View File

@@ -133,7 +133,7 @@ async function resolveAndFetch (
const resolveResult = await ctx.requestsQueue.add<ResolveResult>(() => ctx.resolve(wantedDependency, {
defaultTag: options.defaultTag,
localPackages: options.localPackages,
lockfileDirectory: options.lockfileDirectory,
lockfileDir: options.lockfileDir,
preferredVersions: options.preferredVersions,
prefix: options.prefix,
registry: options.registry,
@@ -189,7 +189,7 @@ async function resolveAndFetch (
body: {
cacheByEngine: options.sideEffectsCache ? await getCacheByEngine(ctx.storeDir, id) : new Map(),
id,
inStoreLocation: path.join(ctx.storeDir, pkgIdToFilename(id, options.lockfileDirectory)),
inStoreLocation: path.join(ctx.storeDir, pkgIdToFilename(id, options.lockfileDir)),
isLocal: false as const,
latest,
manifest: pkg,
@@ -206,7 +206,7 @@ async function resolveAndFetch (
force: forceFetch,
pkgId: id,
pkgName: pkg && pkg.name,
prefix: options.lockfileDirectory,
prefix: options.lockfileDir,
resolution: resolution,
})

View File

@@ -50,7 +50,7 @@ test('request package', async t => {
const prefix = tempy.directory()
const pkgResponse = await requestPackage({ alias: 'is-positive', pref: '1.0.0' }, {
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,
@@ -101,7 +101,7 @@ test('request package but skip fetching', async t => {
const prefix = tempy.directory()
const pkgResponse = await requestPackage({ alias: 'is-positive', pref: '1.0.0' }, {
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,
@@ -151,7 +151,7 @@ test('request package but skip fetching, when resolution is already available',
tarball: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
},
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,
@@ -200,7 +200,7 @@ test('refetch local tarball if its integrity has changed', async t => {
const requestPackageOpts = {
currentPackageId: pkgId,
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,
@@ -296,7 +296,7 @@ test('refetch local tarball if its integrity has changed. The requester does not
const storeDir = path.join(__dirname, '..', '.store')
const requestPackageOpts = {
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,
@@ -573,7 +573,7 @@ test('always return a package manifest in the response', async t => {
{
const pkgResponse = await requestPackage({ alias: 'is-positive', pref: '1.0.0' }, {
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,
@@ -592,7 +592,7 @@ test('always return a package manifest in the response', async t => {
tarball: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
},
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,

View File

@@ -73,7 +73,7 @@ export default async function (
packageId: string,
packageName: string,
opts: {
lockfileDirectory: string,
lockfileDir: string,
targetEngine?: string,
}
) {
@@ -88,7 +88,7 @@ export default async function (
}
return {
directory: path.join(initOpts.storeDir, pkgIdToFilename(packageId, opts.lockfileDirectory), 'node_modules', packageName),
directory: path.join(initOpts.storeDir, pkgIdToFilename(packageId, opts.lockfileDir), 'node_modules', packageName),
isBuilt: false,
}
}

View File

@@ -126,7 +126,7 @@ function getHelpText (command: string) {
},
{
description: `The directory in which the ${WANTED_LOCKFILE} of the package will be created. Several projects may share a single lockfile`,
name: '--lockfile-directory <dir>',
name: '--lockfile-dir <dir>',
},
{
description: 'Dependencies inside node_modules have access only to their listed dependencies',

View File

@@ -45,7 +45,7 @@ export default async function installCmd (
: undefined
if (!opts.ignorePnpmfile) {
opts.hooks = requireHooks(opts.lockfileDirectory || workingDir, opts)
opts.hooks = requireHooks(opts.lockfileDir || workingDir, opts)
}
const store = await createStoreController(opts)
const installOpts = {

View File

@@ -7,7 +7,7 @@ export default async function (
opts: Config & {
alwaysPrintRootPackage?: boolean,
depth?: number,
lockfileDirectory?: string,
lockfileDir?: string,
long?: boolean,
parseable?: boolean,
},
@@ -15,7 +15,7 @@ export default async function (
) {
const output = await render([opts.workingDir], args, {
...opts,
lockfileDirectory: opts.lockfileDirectory || opts.workingDir,
lockfileDir: opts.lockfileDir || opts.workingDir,
}, command)
if (output) console.log(output)
@@ -27,7 +27,7 @@ export async function render (
opts: Config & {
alwaysPrintRootPackage?: boolean,
depth?: number,
lockfileDirectory: string,
lockfileDir: string,
long?: boolean,
json?: boolean,
parseable?: boolean,
@@ -43,7 +43,7 @@ export async function render (
alwaysPrintRootPackage: opts.alwaysPrintRootPackage,
depth: isWhy ? Infinity : opts.depth || 0,
include: opts.include,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
long: opts.long,
// tslint:disable-next-line: no-unnecessary-type-assertion
reportAs: (opts.parseable ? 'parseable' : (opts.json ? 'json' : 'tree')) as ('parseable' | 'json' | 'tree'),

View File

@@ -79,7 +79,7 @@ export interface OutdatedOptions {
proxy?: string
rawConfig: object
registries: Registries
lockfileDirectory?: string
lockfileDir?: string
store?: string
strictSsl: boolean
table?: boolean
@@ -271,18 +271,18 @@ export async function outdatedDependenciesOfWorkspacePackages (
args: string[],
opts: OutdatedOptions,
) {
const lockfileDirectory = opts.lockfileDirectory || opts.workingDir
const modules = await readModulesManifest(path.join(lockfileDirectory, 'node_modules'))
const virtualStoreDir = modules?.virtualStoreDir || path.join(lockfileDirectory, 'node_modules/.pnpm')
const lockfileDir = opts.lockfileDir || opts.workingDir
const modules = await readModulesManifest(path.join(lockfileDir, 'node_modules'))
const virtualStoreDir = modules?.virtualStoreDir || path.join(lockfileDir, 'node_modules/.pnpm')
const currentLockfile = await readCurrentLockfile(virtualStoreDir, { ignoreIncompatible: false })
const wantedLockfile = await readWantedLockfile(lockfileDirectory, { ignoreIncompatible: false }) || currentLockfile
const wantedLockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: false }) || currentLockfile
if (!wantedLockfile) {
throw new PnpmError('OUTDATED_NO_LOCKFILE', 'No lockfile in this directory. Run `pnpm install` to generate one.')
}
const storeDir = await storePath(opts.workingDir, opts.store)
const getLatestManifest = createLatestManifestGetter({
...opts,
lockfileDirectory,
lockfileDir,
storeDir,
})
return Promise.all(pkgs.map(async ({ manifest, path }) => {
@@ -292,13 +292,13 @@ export async function outdatedDependenciesOfWorkspacePackages (
outdatedPackages: await outdated({
currentLockfile,
getLatestManifest,
lockfileDirectory,
lockfileDir,
manifest,
match,
prefix: path,
wantedLockfile,
}),
prefix: getLockfileImporterId(lockfileDirectory, path),
prefix: getLockfileImporterId(lockfileDir, path),
}
}))
}

View File

@@ -241,15 +241,15 @@ export async function recursive (
if (cmdFullName !== 'rebuild') {
// For a workspace with shared lockfile
if (opts.lockfileDirectory && ['add', 'install', 'remove', 'update'].includes(cmdFullName)) {
if (opts.lockfileDir && ['add', 'install', 'remove', 'update'].includes(cmdFullName)) {
if (opts.hoistPattern) {
logger.info({ message: 'Only the root workspace package is going to have hoisted dependencies in node_modules', prefix: opts.lockfileDirectory })
logger.info({ message: 'Only the root workspace package is going to have hoisted dependencies in node_modules', prefix: opts.lockfileDir })
}
let importers = await getImporters()
const isFromWorkspace = isSubdir.bind(null, opts.lockfileDirectory)
const isFromWorkspace = isSubdir.bind(null, opts.lockfileDir)
importers = await pFilter(importers, async ({ prefix }: { prefix: string }) => isFromWorkspace(await fs.realpath(prefix)))
if (importers.length === 0) return true
const hooks = opts.ignorePnpmfile ? {} : requireHooks(opts.lockfileDirectory, opts)
const hooks = opts.ignorePnpmfile ? {} : requireHooks(opts.lockfileDir, opts)
const mutation = cmdFullName === 'remove' ? 'uninstallSome' : (input.length === 0 && !updateToLatest ? 'install' : 'installSome')
const writeImporterManifests = [] as Array<(manifest: ImporterManifest) => Promise<void>>
const mutatedImporters = [] as MutatedImporter[]
@@ -423,7 +423,7 @@ export async function recursive (
? rebuild
: (importers: any, opts: any) => rebuildPkgs(importers, input, opts) // tslint:disable-line
)
if (opts.lockfileDirectory) {
if (opts.lockfileDir) {
const importers = await getImporters()
await action(
importers,

View File

@@ -11,14 +11,14 @@ export default async (
depth?: number,
long?: boolean,
parseable?: boolean,
lockfileDirectory?: string,
lockfileDir?: string,
},
) => {
if (opts.lockfileDirectory) {
if (opts.lockfileDir) {
console.log(await renderList(pkgs.map((pkg) => pkg.path), args, {
...opts,
alwaysPrintRootPackage: opts.depth === -1,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
}, cmd))
return
}
@@ -28,7 +28,7 @@ export default async (
const output = await renderList([path], args, {
...opts,
alwaysPrintRootPackage: opts.depth === -1,
lockfileDirectory: opts.lockfileDirectory || path,
lockfileDir: opts.lockfileDir || path,
}, cmd)
if (!output) continue
outputs.push(output)

View File

@@ -45,7 +45,7 @@ export default async (
opts: OutdatedOptions,
) => {
const outdatedByNameAndType = {} as Record<string, OutdatedInWorkspace>
if (opts.lockfileDirectory) {
if (opts.lockfileDir) {
const outdatedPackagesByProject = await outdatedDependenciesOfWorkspacePackages(pkgs, args, opts)
for (let { prefix, outdatedPackages, manifest } of outdatedPackagesByProject) {
outdatedPackages.forEach((outdatedPkg) => {
@@ -59,7 +59,7 @@ export default async (
} else {
await Promise.all(pkgs.map(async ({ manifest, path }) => {
const { outdatedPackages } = (
await outdatedDependenciesOfWorkspacePackages([{ manifest, path }], args, { ...opts, lockfileDirectory: path })
await outdatedDependenciesOfWorkspacePackages([{ manifest, path }], args, { ...opts, lockfileDir: path })
)[0]
outdatedPackages.forEach((outdatedPkg) => {
const key = JSON.stringify([outdatedPkg.packageName, outdatedPkg.belongsTo])

View File

@@ -17,7 +17,7 @@ export default async function removeCmd (
storeDir: store.dir,
})
if (!opts.ignorePnpmfile) {
opts.hooks = requireHooks(opts.lockfileDirectory || opts.workingDir, opts)
opts.hooks = requireHooks(opts.lockfileDir || opts.workingDir, opts)
}
removeOpts['localPackages'] = opts.linkWorkspacePackages && opts.workspacePrefix
? arrayOfLocalPackagesToMap(await findWorkspacePackages(opts.workspacePrefix, opts))

View File

@@ -15,7 +15,7 @@ export default function (
httpsProxy?: string,
key?: string,
localAddress?: string,
lockfileDirectory: string,
lockfileDir: string,
offline?: boolean,
workingDir: string,
proxy?: string,
@@ -40,14 +40,14 @@ export default function (
export async function getLatestManifest (
resolve: ResolveFunction,
opts: {
lockfileDirectory: string,
lockfileDir: string,
workingDir: string,
registries: Registries,
},
packageName: string,
) {
const resolution = await resolve({ alias: packageName, pref: 'latest' }, {
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
preferredVersions: {},
prefix: opts.workingDir,
registry: pickRegistryForPackage(opts.registries, packageName),

View File

@@ -83,7 +83,8 @@ type CLI_OPTIONS = 'access'
| 'latest'
| 'link-workspace-packages'
| 'lock'
| 'lockfile-directory'
| 'lockfile-dir'
| 'lockfile-directory' // TODO: deprecate this flag
| 'lockfile-only'
| 'lockfile'
| 'long'
@@ -148,6 +149,7 @@ const INSTALL_CLI_OPTIONS = new Set<CLI_OPTIONS>([
'independent-leaves',
'link-workspace-packages',
'lock',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
'lockfile',
@@ -194,6 +196,7 @@ const SUPPORTED_CLI_OPTIONS: Record<CANONICAL_COMMAND_NAMES, Set<CLI_OPTIONS>> =
'independent-leaves',
'link-workspace-packages',
'lock',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
'lockfile',
@@ -286,6 +289,7 @@ const SUPPORTED_CLI_OPTIONS: Record<CANONICAL_COMMAND_NAMES, Set<CLI_OPTIONS>> =
'force',
'global-pnpmfile',
'global',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
'lockfile',
@@ -336,6 +340,7 @@ const SUPPORTED_CLI_OPTIONS: Record<CANONICAL_COMMAND_NAMES, Set<CLI_OPTIONS>> =
'ignore-pnpmfile',
'ignore-scripts',
'latest',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
'lockfile',
@@ -451,7 +456,8 @@ export default async function run (inputArgv: string[]) {
'C': ['--working-dir'],
'prefix': ['--working-dir'],
'store': ['--store-dir'],
'shrinkwrap-directory': ['--lockfile-directory'],
'lockfile-directory': ['--lockfile-dir'],
'shrinkwrap-directory': ['--lockfile-dir'],
'shrinkwrap-only': ['--lockfile-only'],
'shared-workspace-shrinkwrap': ['--shared-workspace-lockfile'],
'frozen-shrinkwrap': ['--frozen-lockfile'],

View File

@@ -10,7 +10,7 @@ test('getLatestManifest()', async (t: tape.Test) => {
t.plan(4)
const opts = {
lockfileDirectory: '',
lockfileDir: '',
registries: {
'@scope': 'https://pnpm.js.org/',
'default': 'https://registry.npmjs.org/',

View File

@@ -14,7 +14,7 @@ export interface ImporterOptions {
export default async function <T>(
importers: (ImporterOptions & T)[],
lockfileDirectory: string,
lockfileDir: string,
): Promise<{
currentHoistPattern?: string[],
hoist?: boolean,
@@ -32,7 +32,7 @@ export default async function <T>(
shamefullyHoist?: boolean,
skipped: Set<string>,
}> {
const rootModulesDir = await realNodeModulesDir(lockfileDirectory)
const rootModulesDir = await realNodeModulesDir(lockfileDir)
const modules = await readModulesYaml(rootModulesDir)
return {
currentHoistPattern: modules?.hoistPattern || undefined,
@@ -41,7 +41,7 @@ export default async function <T>(
importers: await Promise.all(
importers.map(async (importer) => {
const modulesDir = await realNodeModulesDir(importer.prefix)
const importerId = getLockfileImporterId(lockfileDirectory, importer.prefix)
const importerId = getLockfileImporterId(lockfileDir, importer.prefix)
return {
...importer,

View File

@@ -49,7 +49,7 @@ export default async function (
resolutionStrategy?: 'fast' | 'fewer-dependencies',
pnpmVersion: string,
sideEffectsCache: boolean,
lockfileDirectory: string,
lockfileDir: string,
storeController: StoreController,
tag: string,
virtualStoreDir: string,
@@ -70,7 +70,7 @@ export default async function (
dryRun: opts.dryRun,
engineStrict: opts.engineStrict,
force: opts.force,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
nodeVersion: opts.nodeVersion,
outdatedDependencies: {} as {[pkgId: string]: string},
pendingNodes: [] as PendingNode[],

View File

@@ -121,7 +121,7 @@ export interface ResolutionContext {
wantedLockfile: Lockfile,
updateLockfile: boolean,
currentLockfile: Lockfile,
lockfileDirectory: string,
lockfileDir: string,
sideEffectsCache: boolean,
storeController: StoreController,
// the IDs of packages that are not installable
@@ -535,7 +535,7 @@ async function resolveDependency (
defaultTag: ctx.defaultTag,
downloadPriority: -options.currentDepth,
localPackages: options.localPackages,
lockfileDirectory: ctx.lockfileDirectory,
lockfileDir: ctx.lockfileDir,
preferredVersions: options.preferredVersions,
prefix: ctx.prefix,
registry: wantedDependency.alias && pickRegistryForPackage(ctx.registries, wantedDependency.alias) || ctx.registries.default,
@@ -689,7 +689,7 @@ async function resolveDependency (
if (isNew) {
progressLogger.debug({
packageId: pkgResponse.body.id,
requester: ctx.lockfileDirectory,
requester: ctx.lockfileDir,
status: 'resolved',
})
if (pkgResponse.files) {
@@ -697,7 +697,7 @@ async function resolveDependency (
.then((fetchResult: PackageFilesResponse) => {
progressLogger.debug({
packageId: pkgResponse.body.id,
requester: ctx.lockfileDirectory,
requester: ctx.lockfileDir,
status: fetchResult.fromStore
? 'found_in_store' : 'fetched',
})

View File

@@ -47,7 +47,7 @@ export interface LocalPackages {
export interface ResolveOptions {
defaultTag?: string,
localPackages?: LocalPackages,
lockfileDirectory: string,
lockfileDir: string,
preferredVersions: {
[packageName: string]: {
selector: string,

View File

@@ -38,7 +38,7 @@ export default function (
packageId: string,
packageName: string,
opts: {
lockfileDirectory: string,
lockfileDir: string,
targetEngine?: string,
},
): Promise<{ directory: string, isBuilt: boolean }> => {

View File

@@ -52,7 +52,7 @@ test('server', async t => {
{ alias: 'is-positive', pref: '1.0.0' },
{
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,
@@ -116,7 +116,7 @@ test('fetchPackage', async t => {
t.deepEqual(
await storeCtrl.getPackageLocation(pkgId, 'is-positive', {
lockfileDirectory: process.cwd(),
lockfileDir: process.cwd(),
}),
{
directory: path.join(storeDir, pkgId, 'node_modules', 'is-positive'),
@@ -146,7 +146,7 @@ test('server errors should arrive to the client', async t => {
{ alias: 'not-an-existing-package', pref: '1.0.0' },
{
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,
@@ -315,7 +315,7 @@ test('find package usages', async t => {
dependency,
{
downloadPriority: 0,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry,

View File

@@ -32,7 +32,7 @@ export interface StoreController {
packageId: string,
packageName: string,
opts: {
lockfileDirectory: string,
lockfileDir: string,
targetEngine?: string,
},
): Promise<{ directory: string, isBuilt: boolean }>,
@@ -98,7 +98,7 @@ export interface RequestPackageOptions {
currentResolution?: Resolution,
defaultTag?: string,
downloadPriority: number,
lockfileDirectory: string,
lockfileDir: string,
localPackages?: LocalPackages,
prefix: string,
preferredVersions: {

View File

@@ -38,7 +38,7 @@ export interface PnpmContext<T> {
rootModulesDir: string,
hoistPattern: string[] | undefined,
hoistedModulesDir: string,
lockfileDirectory: string,
lockfileDir: string,
virtualStoreDir: string,
shamefullyHoist: boolean,
skipped: Set<string>,
@@ -59,7 +59,7 @@ export default async function getContext<T> (
force: boolean,
forceSharedLockfile: boolean,
extraBinPaths: string[],
lockfileDirectory: string,
lockfileDir: string,
hooks?: {
readPackage?: ReadPackageHook,
},
@@ -79,15 +79,15 @@ export default async function getContext<T> (
forceShamefullyHoist?: boolean,
},
): Promise<PnpmContext<T>> {
const importersContext = await readImportersContext(importers, opts.lockfileDirectory)
const virtualStoreDir = pathAbsolute(opts.virtualStoreDir ?? 'node_modules/.pnpm', opts.lockfileDirectory)
const importersContext = await readImportersContext(importers, opts.lockfileDir)
const virtualStoreDir = pathAbsolute(opts.virtualStoreDir ?? 'node_modules/.pnpm', opts.lockfileDir)
if (importersContext.modules) {
await validateNodeModules(importersContext.modules, importersContext.importers, {
currentHoistPattern: importersContext.currentHoistPattern,
force: opts.force,
include: opts.include,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
storeDir: opts.storeDir,
virtualStoreDir,
@@ -135,7 +135,7 @@ export default async function getContext<T> (
importers: importersContext.importers,
include: opts.include || importersContext.include,
independentLeaves: Boolean(typeof importersContext.independentLeaves === 'undefined' ? opts.independentLeaves : importersContext.independentLeaves),
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
modulesFile: importersContext.modules,
pendingBuilds: importersContext.pendingBuilds,
registries: {
@@ -151,7 +151,7 @@ export default async function getContext<T> (
force: opts.force,
forceSharedLockfile: opts.forceSharedLockfile,
importers: importersContext.importers,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
registry: opts.registries.default,
useLockfile: opts.useLockfile,
virtualStoreDir,
@@ -172,7 +172,7 @@ async function validateNodeModules (
currentHoistPattern?: string[],
force: boolean,
include?: IncludedDependencies,
lockfileDirectory: string,
lockfileDir: string,
storeDir: string,
virtualStoreDir: string,
@@ -252,11 +252,11 @@ async function validateNodeModules (
storeDir: opts.storeDir,
virtualStoreDir: opts.virtualStoreDir,
})
if (opts.lockfileDirectory !== importer.prefix && opts.include && modules.included) {
if (opts.lockfileDir !== importer.prefix && opts.include && modules.included) {
for (const depsField of DEPENDENCIES_FIELDS) {
if (opts.include[depsField] !== modules.included[depsField]) {
throw new PnpmError('INCLUDED_DEPS_CONFLICT',
`node_modules (at "${opts.lockfileDirectory}") was installed with ${stringifyIncludedDeps(modules.included)}. ` +
`node_modules (at "${opts.lockfileDir}") was installed with ${stringifyIncludedDeps(modules.included)}. ` +
`Current install wants ${stringifyIncludedDeps(opts.include)}.`,
)
}
@@ -308,7 +308,7 @@ export interface PnpmSingleContext {
pendingBuilds: string[],
registries: Registries,
rootModulesDir: string,
lockfileDirectory: string,
lockfileDir: string,
virtualStoreDir: string,
shamefullyHoist: boolean,
skipped: Set<string>,
@@ -322,7 +322,7 @@ export async function getContextForSingleImporter (
force: boolean,
forceSharedLockfile: boolean,
extraBinPaths: string[],
lockfileDirectory: string,
lockfileDir: string,
hooks?: {
readPackage?: ReadPackageHook,
},
@@ -362,7 +362,7 @@ export async function getContextForSingleImporter (
prefix: opts.workingDir,
},
],
opts.lockfileDirectory,
opts.lockfileDir,
)
const storeDir = opts.storeDir
@@ -370,14 +370,14 @@ export async function getContextForSingleImporter (
const importer = importers[0]
const modulesDir = importer.modulesDir
const importerId = importer.id
const virtualStoreDir = pathAbsolute(opts.virtualStoreDir ?? 'node_modules/.pnpm', opts.lockfileDirectory)
const virtualStoreDir = pathAbsolute(opts.virtualStoreDir ?? 'node_modules/.pnpm', opts.lockfileDir)
if (modules) {
await validateNodeModules(modules, importers, {
currentHoistPattern,
force: opts.force,
include: opts.include,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
storeDir: opts.storeDir,
virtualStoreDir,
@@ -410,7 +410,7 @@ export async function getContextForSingleImporter (
importerId,
include: opts.include || include,
independentLeaves: Boolean(typeof independentLeaves === 'undefined' ? opts.independentLeaves : independentLeaves),
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
manifest: opts.hooks?.readPackage?.(manifest) ?? manifest,
modulesDir,
modulesFile: modules,
@@ -429,7 +429,7 @@ export async function getContextForSingleImporter (
force: opts.force,
forceSharedLockfile: opts.forceSharedLockfile,
importers: [{ id: importerId, prefix: opts.workingDir }],
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
registry: opts.registries.default,
useLockfile: opts.useLockfile,
virtualStoreDir,

View File

@@ -28,7 +28,7 @@ export default async function (
id: string,
prefix: string,
}>,
lockfileDirectory: string,
lockfileDir: string,
registry: string,
useLockfile: boolean,
virtualStoreDir: string,
@@ -46,11 +46,11 @@ export default async function (
wantedVersion: LOCKFILE_VERSION,
}
const files = await Promise.all<Lockfile | null | void>([
opts.useLockfile && readWantedLockfile(opts.lockfileDirectory, lockfileOpts)
|| await existsWantedLockfile(opts.lockfileDirectory) &&
opts.useLockfile && readWantedLockfile(opts.lockfileDir, lockfileOpts)
|| await existsWantedLockfile(opts.lockfileDir) &&
logger.warn({
message: `A ${WANTED_LOCKFILE} file exists. The current configuration prohibits to read or write a lockfile`,
prefix: opts.lockfileDirectory,
prefix: opts.lockfileDir,
}),
readCurrentLockfile(opts.virtualStoreDir, lockfileOpts),
])

View File

@@ -28,7 +28,7 @@ export interface StrictInstallOptions {
update: boolean,
depth: number,
resolutionStrategy: 'fast' | 'fewer-dependencies',
lockfileDirectory: string,
lockfileDir: string,
rawConfig: object,
verifyStoreIntegrity: boolean,
engineStrict: boolean,
@@ -100,7 +100,7 @@ const defaults = async (opts: InstallOptions) => {
independentLeaves: false,
localPackages: {},
lock: true,
lockfileDirectory: opts.lockfileDirectory || opts.workingDir || process.cwd(),
lockfileDir: opts.lockfileDir || opts.workingDir || process.cwd(),
lockfileOnly: false,
locks: path.join(opts.storeDir, '_locks'),
lockStaleDuration: 5 * 60 * 1000, // 5 minutes

View File

@@ -166,9 +166,9 @@ export async function mutateModules (
let result!: Array<{ prefix: string, manifest: ImporterManifest }>
try {
if (opts.lock) {
result = await lock(ctx.lockfileDirectory, _install, {
result = await lock(ctx.lockfileDir, _install, {
locks: opts.locks,
prefix: ctx.lockfileDirectory,
prefix: ctx.lockfileDir,
stale: opts.lockStaleDuration,
storeController: opts.storeController,
})
@@ -209,7 +209,7 @@ export async function mutateModules (
throw new Error(`Headless installation requires a ${WANTED_LOCKFILE} file`)
}
} else {
logger.info({ message: 'Lockfile is up-to-date, resolution step is skipped', prefix: opts.lockfileDirectory })
logger.info({ message: 'Lockfile is up-to-date, resolution step is skipped', prefix: opts.lockfileDir })
await headless({
currentEngine: {
nodeVersion: opts.nodeVersion,
@@ -233,7 +233,7 @@ export async function mutateModules (
}>,
include: opts.include,
independentLeaves: opts.independentLeaves,
lockfileDirectory: ctx.lockfileDirectory,
lockfileDir: ctx.lockfileDir,
ownLifecycleHooksStdio: opts.ownLifecycleHooksStdio,
packageManager: opts.packageManager,
pendingBuilds: ctx.pendingBuilds,
@@ -579,7 +579,7 @@ export async function addDependenciesToPackage (
],
{
...opts,
lockfileDirectory: opts.lockfileDirectory || opts.workingDir,
lockfileDir: opts.lockfileDir || opts.workingDir,
})
return importers[0].manifest
}
@@ -615,7 +615,7 @@ async function installInContext (
if (opts.lockfileOnly && ctx.existsCurrentLockfile) {
logger.warn({
message: '`node_modules` is present. Lockfile only installation will make it out-of-date',
prefix: ctx.lockfileDirectory,
prefix: ctx.lockfileDir,
})
}
@@ -646,7 +646,7 @@ async function installInContext (
)
stageLogger.debug({
prefix: ctx.lockfileDirectory,
prefix: ctx.lockfileDir,
stage: 'resolution_started',
})
@@ -680,7 +680,7 @@ async function installInContext (
force: opts.force,
hooks: opts.hooks,
localPackages: opts.localPackages,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
nodeVersion: opts.nodeVersion,
pnpmVersion: opts.packageManager.name === 'pnpm' ? opts.packageManager.version : '',
registries: opts.registries,
@@ -695,7 +695,7 @@ async function installInContext (
)
stageLogger.debug({
prefix: ctx.lockfileDirectory,
prefix: ctx.lockfileDir,
stage: 'resolution_done',
})
@@ -800,7 +800,7 @@ async function installInContext (
hoistPattern: ctx.hoistPattern,
include: opts.include,
independentLeaves: opts.independentLeaves,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
makePartialCurrentLockfile: opts.makePartialCurrentLockfile,
outdatedDependencies,
pruneStore: opts.pruneStore,
@@ -840,7 +840,7 @@ async function installInContext (
depsToBuild: new Set(result.newDepPaths),
extraBinPaths: ctx.extraBinPaths,
optional: opts.include.optionalDependencies,
prefix: ctx.lockfileDirectory,
prefix: ctx.lockfileDir,
rawConfig: opts.rawConfig,
rootNodeModulesDir: ctx.virtualStoreDir,
sideEffectsCacheWrite: opts.sideEffectsCacheWrite,
@@ -854,7 +854,7 @@ async function installInContext (
const newPkgs = R.props<string, DependenciesGraphNode>(result.newDepPaths, result.depGraph)
await linkAllBins(newPkgs, result.depGraph, {
optional: opts.include.optionalDependencies,
warn: (message: string) => logger.warn({ message, prefix: opts.lockfileDirectory }),
warn: (message: string) => logger.warn({ message, prefix: opts.lockfileDir }),
})
}
@@ -877,7 +877,7 @@ async function installInContext (
const lockfileOpts = { forceSharedFormat: opts.forceSharedLockfile }
if (opts.lockfileOnly) {
await writeWantedLockfile(ctx.lockfileDirectory, result.wantedLockfile, lockfileOpts)
await writeWantedLockfile(ctx.lockfileDir, result.wantedLockfile, lockfileOpts)
} else {
await Promise.all([
opts.useLockfile
@@ -885,7 +885,7 @@ async function installInContext (
currentLockfile: result.currentLockfile,
currentLockfileDir: ctx.virtualStoreDir,
wantedLockfile: result.wantedLockfile,
wantedLockfileDir: ctx.lockfileDirectory,
wantedLockfileDir: ctx.lockfileDir,
...lockfileOpts,
})
: writeCurrentLockfile(ctx.virtualStoreDir, result.currentLockfile, lockfileOpts),
@@ -912,7 +912,7 @@ async function installInContext (
])
}
summaryLogger.debug({ prefix: opts.lockfileDirectory })
summaryLogger.debug({ prefix: opts.lockfileDir })
await opts.storeController.close()

View File

@@ -66,7 +66,7 @@ export default async function linkPackages (
hoistPattern?: string[],
include: IncludedDependencies,
independentLeaves: boolean,
lockfileDirectory: string,
lockfileDir: string,
makePartialCurrentLockfile: boolean,
outdatedDependencies: {[pkgId: string]: string},
pruneStore: boolean,
@@ -97,7 +97,7 @@ export default async function linkPackages (
dependenciesTree,
importers,
independentLeaves: opts.independentLeaves,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
strictPeerDependencies: opts.strictPeerDependencies,
virtualStoreDir: opts.virtualStoreDir,
})
@@ -155,7 +155,7 @@ export default async function linkPackages (
hoistedAliases: opts.hoistedAliases,
hoistedModulesDir: opts.hoistPattern && opts.hoistedModulesDir || undefined,
include: opts.include,
lockfileDir: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
pruneStore: opts.pruneStore,
registries: opts.registries,
skipped: opts.skipped,
@@ -165,7 +165,7 @@ export default async function linkPackages (
})
stageLogger.debug({
prefix: opts.lockfileDirectory,
prefix: opts.lockfileDir,
stage: 'importing_started',
})
@@ -189,7 +189,7 @@ export default async function linkPackages (
{
dryRun: opts.dryRun,
force: opts.force,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
optional: opts.include.optionalDependencies,
registries: opts.registries,
storeController: opts.storeController,
@@ -198,7 +198,7 @@ export default async function linkPackages (
)
stageLogger.debug({
prefix: opts.lockfileDirectory,
prefix: opts.lockfileDir,
stage: 'importing_done',
})
@@ -314,14 +314,14 @@ export default async function linkPackages (
getIndependentPackageLocation: opts.independentLeaves
? async (packageId: string, packageName: string) => {
const { directory } = await opts.storeController.getPackageLocation(packageId, packageName, {
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
targetEngine: opts.sideEffectsCacheRead && ENGINE_NAME || undefined,
})
return directory
}
: undefined,
lockfile: currentLockfile,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
modulesDir: opts.hoistedModulesDir,
registries: opts.registries,
virtualStoreDir: opts.virtualStoreDir,
@@ -371,7 +371,7 @@ async function linkNewPackages (
force: boolean,
optional: boolean,
registries: Registries,
lockfileDirectory: string,
lockfileDir: string,
storeController: StoreController,
virtualStoreDir: string,
},
@@ -393,7 +393,7 @@ async function linkNewPackages (
statsLogger.debug({
added: newDepPathsSet.size,
prefix: opts.lockfileDirectory,
prefix: opts.lockfileDir,
})
const existingWithUpdatedDeps = []
@@ -425,11 +425,11 @@ async function linkNewPackages (
await Promise.all([
linkAllModules(newPkgs, depGraph, {
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
optional: opts.optional,
}),
linkAllModules(existingWithUpdatedDeps, depGraph, {
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
optional: opts.optional,
}),
linkAllPkgs(opts.storeController, newPkgs, opts),
@@ -496,7 +496,7 @@ async function linkAllModules (
depNodes: DependenciesGraphNode[],
depGraph: DependenciesGraph,
opts: {
lockfileDirectory: string,
lockfileDir: string,
optional: boolean,
},
) {
@@ -522,7 +522,7 @@ async function linkAllModules (
if (childAlias === name) {
logger.warn({
message: `Cannot link dependency with name ${childAlias} to ${modules}. Dependency's name should differ from the parent's name.`,
prefix: opts.lockfileDirectory,
prefix: opts.lockfileDir,
})
return
}

View File

@@ -78,7 +78,7 @@ export default function (
dependenciesTree: DependenciesTree,
independentLeaves: boolean,
virtualStoreDir: string,
lockfileDirectory: string,
lockfileDir: string,
strictPeerDependencies: boolean,
},
): {
@@ -115,7 +115,7 @@ export default function (
dependenciesTree: opts.dependenciesTree,
depGraph,
independentLeaves: opts.independentLeaves,
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
prefix,
purePkgs: new Set(),
strictPeerDependencies: opts.strictPeerDependencies,
@@ -154,7 +154,7 @@ function resolvePeersOfNode (
virtualStoreDir: string,
purePkgs: Set<string>, // pure packages are those that don't rely on externally resolved peers
prefix: string,
lockfileDirectory: string,
lockfileDir: string,
strictPeerDependencies: boolean,
},
): {[alias: string]: string} {
@@ -188,7 +188,7 @@ function resolvePeersOfNode (
let modules: string
let absolutePath: string
const localLocation = path.join(ctx.virtualStoreDir, pkgIdToFilename(node.resolvedPackage.id, ctx.lockfileDirectory))
const localLocation = path.join(ctx.virtualStoreDir, pkgIdToFilename(node.resolvedPackage.id, ctx.lockfileDir))
const isPure = R.isEmpty(allResolvedPeers)
if (isPure) {
modules = path.join(localLocation, 'node_modules')
@@ -269,7 +269,7 @@ function resolvePeersOfChildren (
depGraph: DependenciesGraph,
dependenciesTree: DependenciesTree,
prefix: string,
lockfileDirectory: string,
lockfileDir: string,
strictPeerDependencies: boolean,
},
): {[alias: string]: string} {

View File

@@ -50,7 +50,7 @@ export default async function link (
extraBinPaths: [], // ctx.extraBinPaths is not needed, so this is fine
})
const importerId = getLockfileImporterId(ctx.lockfileDirectory, opts.workingDir)
const importerId = getLockfileImporterId(ctx.lockfileDir, opts.workingDir)
const currentLockfile = R.clone(ctx.currentLockfile)
const linkedPkgs: Array<{path: string, manifest: DependencyManifest, alias: string}> = []
const specsToUpsert = [] as Array<{name: string, pref: string, saveType: DependenciesField}>
@@ -108,7 +108,7 @@ export default async function link (
hoistedAliases: ctx.hoistedAliases,
hoistedModulesDir: opts.hoistPattern && ctx.hoistedModulesDir || undefined,
include: ctx.include,
lockfileDir: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
registries: ctx.registries,
skipped: ctx.skipped,
storeController: opts.storeController,
@@ -149,7 +149,7 @@ export default async function link (
currentLockfile: updatedCurrentLockfile,
currentLockfileDir: ctx.virtualStoreDir,
wantedLockfile: updatedWantedLockfile,
wantedLockfileDir: ctx.lockfileDirectory,
wantedLockfileDir: ctx.lockfileDir,
...lockfileOpts,
})
} else {
@@ -228,7 +228,7 @@ export async function linkToGlobal (
if (reporter) {
streamParser.on('data', reporter)
}
maybeOpts.lockfileDirectory = maybeOpts.lockfileDirectory || maybeOpts.globalPrefix
maybeOpts.lockfileDir = maybeOpts.lockfileDir || maybeOpts.globalPrefix
const opts = await extendOptions(maybeOpts)
const globalPkgPath = pathAbsolute(maybeOpts.globalPrefix)
const newManifest = await link([linkFrom], path.join(globalPkgPath, 'node_modules'), {

View File

@@ -13,7 +13,7 @@ interface StrictLinkOptions {
force: boolean,
forceSharedLockfile: boolean,
useLockfile: boolean,
lockfileDirectory: string,
lockfileDir: string,
pinnedVersion: 'major' | 'minor' | 'patch',
storeController: StoreController,
manifest: ImporterManifest,
@@ -58,7 +58,7 @@ async function defaults (opts: LinkOptions) {
forceSharedLockfile: false,
hoistPattern: undefined,
independentLeaves: false,
lockfileDirectory: opts.lockfileDirectory || workingDir,
lockfileDir: opts.lockfileDir || workingDir,
registries: DEFAULT_REGISTRIES,
shamefullyHoist: false,
storeController: opts.storeController,

View File

@@ -8,7 +8,7 @@ import { ReporterFunction } from '../types'
export interface StrictRebuildOptions {
childConcurrency: number,
extraBinPaths: string[],
lockfileDirectory: string,
lockfileDir: string,
sideEffectsCacheRead: boolean,
storeDir: string, // TODO: remove this property
storeController: StoreController,
@@ -43,14 +43,14 @@ const defaults = async (opts: RebuildOptions) => {
version: pnpmPkgJson.version,
}
const workingDir = opts.workingDir || process.cwd()
const lockfileDirectory = opts.lockfileDirectory || workingDir
const lockfileDir = opts.lockfileDir || workingDir
return {
bin: path.join(workingDir, 'node_modules', '.bin'),
childConcurrency: 5,
development: true,
force: false,
forceSharedLockfile: false,
lockfileDirectory,
lockfileDir,
optional: true,
packageManager,
pending: false,

View File

@@ -287,11 +287,11 @@ async function _rebuild (
const pkgInfo = nameVerFromPkgSnapshot(relDepPath, pkgSnapshot)
const independent = ctx.independentLeaves && packageIsIndependent(pkgSnapshot)
const pkgRoot = !independent
? path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDirectory), 'node_modules', pkgInfo.name)
? path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDir), 'node_modules', pkgInfo.name)
: await (
async () => {
const { directory } = await opts.storeController.getPackageLocation(pkgSnapshot.id || depPath, pkgInfo.name, {
lockfileDirectory: opts.lockfileDirectory,
lockfileDir: opts.lockfileDir,
targetEngine: opts.sideEffectsCacheRead && !opts.force && ENGINE_NAME || undefined,
})
return directory
@@ -299,7 +299,7 @@ async function _rebuild (
)()
try {
if (!independent) {
const modules = path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDirectory), 'node_modules')
const modules = path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDir), 'node_modules')
const binPath = path.join(pkgRoot, 'node_modules', '.bin')
await linkBins(modules, binPath, { warn })
}
@@ -345,7 +345,7 @@ async function _rebuild (
const depPath = dp.resolve(opts.registries, relDepPath)
const pkgSnapshot = pkgSnapshots[relDepPath]
const pkgInfo = nameVerFromPkgSnapshot(relDepPath, pkgSnapshot)
const modules = path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDirectory), 'node_modules')
const modules = path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDir), 'node_modules')
const binPath = path.join(modules, pkgInfo.name, 'node_modules', '.bin')
return linkBins(modules, binPath, { warn })
})),

View File

@@ -40,7 +40,7 @@ export default async function (
try {
const pkgResponse = await opts.storeController.requestPackage(dep, {
downloadPriority: 1,
lockfileDirectory: prefix,
lockfileDir: prefix,
preferredVersions: {},
prefix,
registry: dep.alias && pickRegistryForPackage(registries, dep.alias) || registries.default,

View File

@@ -4,7 +4,7 @@ import path = require('path')
import { ReporterFunction } from '../types'
export interface StrictStoreStatusOptions {
lockfileDirectory: string,
lockfileDir: string,
workingDir: string,
storeDir: string,
independentLeaves: boolean,
@@ -26,13 +26,13 @@ export type StoreStatusOptions = Partial<StrictStoreStatusOptions> &
const defaults = async (opts: StoreStatusOptions) => {
const workingDir = opts.workingDir || process.cwd()
const lockfileDirectory = opts.lockfileDirectory || workingDir
const lockfileDir = opts.lockfileDir || workingDir
return {
bin: path.join(workingDir, 'node_modules', '.bin'),
force: false,
forceSharedLockfile: false,
independentLeaves: false,
lockfileDirectory,
lockfileDir,
registries: DEFAULT_REGISTRIES,
shamefullyHoist: false,
storeDir: opts.storeDir,

View File

@@ -48,14 +48,14 @@ test("don't fail on non-compatible node_modules when forced in a workspace", asy
const opts = await testDefaults({ force: true })
process.chdir('pkg')
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], await testDefaults({ lockfileDirectory: path.resolve('..') }))
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], await testDefaults({ lockfileDir: path.resolve('..') }))
await rimraf('node_modules')
process.chdir('..')
await fs.writeFile('node_modules/.modules.yaml', `packageManager: pnpm@${3}\nstore: ${opts.storeDir}\nindependentLeaves: false\nlayoutVersion: 1`)
await install(manifest, { ...opts, workingDir: path.resolve('pkg'), lockfileDirectory: process.cwd() })
await install(manifest, { ...opts, workingDir: path.resolve('pkg'), lockfileDir: process.cwd() })
t.pass('install did not fail')
})

View File

@@ -10,7 +10,7 @@ import './independentLeaves'
import './installationChecks'
import './lifecycleScripts'
import './local'
import './lockfileDirectory'
import './lockfileDir'
import './lockfileOnly'
import './misc'
import './multipleImporters'

View File

@@ -19,7 +19,7 @@ const testSkip = promisifyTape(tape.skip)
testSkip('subsequent installation uses same lockfile directory by default', async (t: tape.Test) => {
prepareEmpty(t)
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], await testDefaults({ lockfileDirectory: path.resolve('..') }))
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], await testDefaults({ lockfileDir: path.resolve('..') }))
await addDependenciesToPackage(manifest, ['is-negative@1.0.0'], await testDefaults())
@@ -31,12 +31,12 @@ testSkip('subsequent installation uses same lockfile directory by default', asyn
testSkip('subsequent installation fails if a different lockfile directory is specified', async (t: tape.Test) => {
prepareEmpty(t)
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], await testDefaults({ lockfileDirectory: path.resolve('..') }))
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], await testDefaults({ lockfileDir: path.resolve('..') }))
let err!: Error & {code: string}
try {
await addDependenciesToPackage(manifest, ['is-negative@1.0.0'], await testDefaults({ lockfileDirectory: process.cwd() }))
await addDependenciesToPackage(manifest, ['is-negative@1.0.0'], await testDefaults({ lockfileDir: process.cwd() }))
} catch (_) {
err = _
}
@@ -50,7 +50,7 @@ test(`tarball location is correctly saved to ${WANTED_LOCKFILE} when a shared ${
await ncp(path.join(pathToLocalPkg('tar-pkg-with-dep-2'), 'tar-pkg-with-dep-1.0.0.tgz'), 'pkg.tgz')
const lockfileDirectory = path.resolve('..')
const lockfileDir = path.resolve('..')
let [{ manifest }] = await mutateModules(
[
{
@@ -61,7 +61,7 @@ test(`tarball location is correctly saved to ${WANTED_LOCKFILE} when a shared ${
prefix: process.cwd(),
},
],
await testDefaults({ lockfileDirectory }),
await testDefaults({ lockfileDir }),
)
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
@@ -79,12 +79,12 @@ test(`tarball location is correctly saved to ${WANTED_LOCKFILE} when a shared ${
prefix: process.cwd(),
}
],
await testDefaults({ frozenLockfile: true, lockfileDirectory }),
await testDefaults({ frozenLockfile: true, lockfileDir }),
)
await project.has('tar-pkg-with-dep')
await rebuild([{ buildIndex: 0, manifest, prefix: process.cwd() }], await testDefaults({ lockfileDirectory }))
await rebuild([{ buildIndex: 0, manifest, prefix: process.cwd() }], await testDefaults({ lockfileDir }))
t.pass('rebuild did not fail')
})

View File

@@ -112,7 +112,7 @@ test('dependencies of other importers are not pruned when installing for a subse
], await testDefaults())
await addDependenciesToPackage(manifest, ['is-positive@2'], await testDefaults({
lockfileDirectory: process.cwd(),
lockfileDir: process.cwd(),
workingDir: path.resolve('project-1'),
}))
@@ -175,7 +175,7 @@ test('dependencies of other importers are not pruned when (headless) installing
const [{ manifest }] = await mutateModules(importers, await testDefaults())
await addDependenciesToPackage(manifest, ['is-positive@2'], await testDefaults({
lockfileDirectory: process.cwd(),
lockfileDir: process.cwd(),
lockfileOnly: true,
workingDir: path.resolve('project-1'),
}))

View File

@@ -78,7 +78,7 @@ test('install dev dependencies only', async (t: tape.Test) => {
test('fail if installing different types of dependencies in a project that uses an external lockfile', async (t: tape.Test) => {
const project = prepareEmpty(t)
const lockfileDirectory = path.resolve('..')
const lockfileDir = path.resolve('..')
const manifest = await install({
dependencies: {
@@ -94,7 +94,7 @@ test('fail if installing different types of dependencies in a project that uses
devDependencies: true,
optionalDependencies: false,
},
lockfileDirectory,
lockfileDir,
}))
await project.has('inflight')
@@ -109,7 +109,7 @@ test('fail if installing different types of dependencies in a project that uses
devDependencies: true,
optionalDependencies: true,
},
lockfileDirectory,
lockfileDir,
}))
} catch (_) {
err = _

View File

@@ -421,7 +421,7 @@ test('skip optional dependency that does not support the current OS, when doing
},
],
await testDefaults({
lockfileDirectory: process.cwd(),
lockfileDir: process.cwd(),
lockfileOnly: true,
}),
)
@@ -437,7 +437,7 @@ test('skip optional dependency that does not support the current OS, when doing
],
await testDefaults({
frozenLockfile: false,
lockfileDirectory: process.cwd(),
lockfileDir: process.cwd(),
preferFrozenLockfile: false,
}),
)

View File

@@ -442,7 +442,7 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
const reporter = sinon.spy()
await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.5.0'], await testDefaults({ reporter, lockfileDirectory: path.resolve('..') }))
await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.5.0'], await testDefaults({ reporter, lockfileDir: path.resolve('..') }))
t.notOk(reporter.calledWithMatch({
message: 'localhost+4873/ajv-keywords/1.5.0 requires a peer of ajv@>=4.10.0 but none was installed.',
@@ -469,14 +469,14 @@ test('peer dependency is grouped correctly with peer installed via separate inst
prepareEmpty(t)
const reporter = sinon.spy()
const lockfileDirectory = path.resolve('..')
const lockfileDir = path.resolve('..')
const manifest = await install({
dependencies: {
'abc': '1.0.0',
},
}, await testDefaults({ reporter, lockfileDirectory }))
await addDependenciesToPackage(manifest, ['peer-c@2.0.0'], await testDefaults({ reporter, lockfileDirectory }))
}, await testDefaults({ reporter, lockfileDir }))
await addDependenciesToPackage(manifest, ['peer-c@2.0.0'], await testDefaults({ reporter, lockfileDir }))
t.ok(await exists(path.join('../node_modules/.pnpm/localhost+4873', 'abc', '1.0.0_peer-c@2.0.0/node_modules/dep-of-pkg-with-1-dep')))
})
@@ -485,9 +485,9 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
prepareEmpty(t)
await makeDir('_')
process.chdir('_')
const lockfileDirectory = path.resolve('..')
const lockfileDir = path.resolve('..')
let manifest = await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.5.0'], await testDefaults({ lockfileDirectory }))
let manifest = await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.5.0'], await testDefaults({ lockfileDir }))
{
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
@@ -503,7 +503,7 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
})
}
manifest = await install(manifest, await testDefaults({ lockfileDirectory }))
manifest = await install(manifest, await testDefaults({ lockfileDir }))
{
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
@@ -530,7 +530,7 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
},
],
await testDefaults({
lockfileDirectory,
lockfileDir,
}),
)
@@ -551,9 +551,9 @@ test('external lockfile: peer dependency is grouped with dependent even after a
prepareEmpty(t)
await makeDir('_')
process.chdir('_')
const lockfileDirectory = path.resolve('..')
const lockfileDir = path.resolve('..')
const manifest = await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.4.0'], await testDefaults({ lockfileDirectory }))
const manifest = await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.4.0'], await testDefaults({ lockfileDir }))
{
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
@@ -569,7 +569,7 @@ test('external lockfile: peer dependency is grouped with dependent even after a
})
}
await addDependenciesToPackage(manifest, ['ajv-keywords@1.5.0'], await testDefaults({ lockfileDirectory }))
await addDependenciesToPackage(manifest, ['ajv-keywords@1.5.0'], await testDefaults({ lockfileDir }))
{
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
@@ -590,9 +590,9 @@ test('external lockfile: peer dependency is grouped with dependent even after a
prepareEmpty(t)
await makeDir('_')
process.chdir('_')
const lockfileDirectory = path.resolve('..')
const lockfileDir = path.resolve('..')
const manifest = await addDependenciesToPackage({}, ['peer-c@1.0.0', 'abc-parent-with-ab@1.0.0'], await testDefaults({ lockfileDirectory }))
const manifest = await addDependenciesToPackage({}, ['peer-c@1.0.0', 'abc-parent-with-ab@1.0.0'], await testDefaults({ lockfileDir }))
{
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
@@ -608,7 +608,7 @@ test('external lockfile: peer dependency is grouped with dependent even after a
})
}
await addDependenciesToPackage(manifest, ['peer-c@2.0.0'], await testDefaults({ lockfileDirectory }))
await addDependenciesToPackage(manifest, ['peer-c@2.0.0'], await testDefaults({ lockfileDir }))
{
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
@@ -631,14 +631,14 @@ test('regular dependencies are not removed on update from transitive packages th
prepareEmpty(t)
await makeDir('_')
process.chdir('_')
const lockfileDirectory = path.resolve('..')
const lockfileDir = path.resolve('..')
await addDistTag({ package: 'abc-parent-with-ab', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent-with-c@1.0.0'], await testDefaults({ lockfileDirectory }))
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent-with-c@1.0.0'], await testDefaults({ lockfileDir }))
await addDistTag({ package: 'peer-c', version: '1.0.1', distTag: 'latest' })
await install(manifest, await testDefaults({ lockfileDirectory, update: true, depth: 2 }))
await install(manifest, await testDefaults({ lockfileDir, update: true, depth: 2 }))
t.ok(await exists(path.join('../node_modules/.pnpm/localhost+4873', 'abc-parent-with-ab', '1.0.1_peer-c@1.0.1/node_modules/is-positive')))
})

View File

@@ -76,12 +76,12 @@ test('update dependency when external lockfile directory is used', async (t: tap
await addDistTag('foo', '100.0.0', 'latest')
const lockfileDirectory = path.resolve('..')
const manifest = await addDependenciesToPackage({}, ['foo'], await testDefaults({ lockfileDirectory }))
const lockfileDir = path.resolve('..')
const manifest = await addDependenciesToPackage({}, ['foo'], await testDefaults({ lockfileDir }))
await addDistTag('foo', '100.1.0', 'latest')
await install(manifest, await testDefaults({ update: true, depth: 0, lockfileDirectory }))
await install(manifest, await testDefaults({ update: true, depth: 0, lockfileDir }))
const lockfile = await readYamlFile<Lockfile>(path.join('..', WANTED_LOCKFILE))

View File

@@ -271,7 +271,7 @@ test('relative link uses realpath when contained in a symlinked dir', async (t:
// },
// ])
// const opts = await testDefaults({ lockfileDirectory: path.join('..') })
// const opts = await testDefaults({ lockfileDir: path.join('..') })
// await link([process.cwd()], path.resolve(process.cwd(), 'node_modules'), opts)
// const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))

View File

@@ -890,7 +890,7 @@ test('lockfile file has correct format when lockfile directory does not equal th
'@zkochan/foo@1.0.0',
'kevva/is-negative#1d7e288222b53a0cab90a331f1865220ec29560c',
],
await testDefaults({ save: true, lockfileDirectory: path.resolve('..'), storeDir }),
await testDefaults({ save: true, lockfileDir: path.resolve('..'), storeDir }),
)
t.ok(!await exists('node_modules/.modules.yaml'), ".modules.yaml in importer's node_modules not created")
@@ -932,7 +932,7 @@ test('lockfile file has correct format when lockfile directory does not equal th
process.chdir('project-2')
await addDependenciesToPackage(manifest, ['is-positive'], await testDefaults({ save: true, lockfileDirectory: path.resolve('..'), storeDir }))
await addDependenciesToPackage(manifest, ['is-positive'], await testDefaults({ save: true, lockfileDir: path.resolve('..'), storeDir }))
{
const lockfile = await readYamlFile<Lockfile>(path.join('..', WANTED_LOCKFILE))
@@ -1025,7 +1025,7 @@ test(`doing named installation when shared ${WANTED_LOCKFILE} exists already`, a
pkg2,
['is-positive'],
await testDefaults({
lockfileDirectory: process.cwd(),
lockfileDir: process.cwd(),
workingDir: path.resolve('pkg2'),
}),
)

View File

@@ -324,7 +324,7 @@ test('uninstalling a dependency from package that uses shared lockfile', async (
prefix: path.resolve('project-1'),
},
], await testDefaults({
lockfileDirectory: process.cwd(),
lockfileDir: process.cwd(),
store,
}))