refactor: normalize dir field names across project objects (#8262)

This commit is contained in:
Zoltan Kochan
2024-07-01 11:27:04 +02:00
committed by GitHub
parent 6efda2ea03
commit dd00eeb18c
32 changed files with 219 additions and 208 deletions

View File

@@ -0,0 +1,22 @@
---
"@pnpm/plugin-commands-installation": major
"@pnpm/plugin-commands-publishing": major
"@pnpm/plugin-commands-script-runners": major
"@pnpm/filter-workspace-packages": major
"@pnpm/plugin-commands-outdated": major
"@pnpm/plugin-commands-listing": major
"@pnpm/resolve-dependencies": major
"@pnpm/plugin-commands-rebuild": major
"@pnpm/get-context": major
"@pnpm/resolver-base": major
"@pnpm/workspace.find-packages": major
"@pnpm/npm-resolver": major
"@pnpm/workspace.pkgs-graph": major
"@pnpm/outdated": major
"@pnpm/fs.find-packages": major
"@pnpm/core": major
"@pnpm/types": major
"pnpm": patch
---
Renamed dir to rootDir in the Project object.

View File

@@ -50,9 +50,9 @@ export async function recursiveRebuild (
if (pkgs.length === 0) {
return
}
const manifestsByPath: { [dir: string]: Omit<Project, 'dir' | 'dirRealPath'> } = {}
for (const { dir, manifest, writeProjectManifest } of pkgs) {
manifestsByPath[dir] = { manifest, writeProjectManifest }
const manifestsByPath: { [dir: string]: Omit<Project, 'rootDir' | 'rootDirRealPath'> } = {}
for (const { rootDir, manifest, writeProjectManifest } of pkgs) {
manifestsByPath[rootDir] = { manifest, writeProjectManifest }
}
const throwOnFail = throwOnCommandFail.bind(null, 'pnpm recursive rebuild')

View File

@@ -162,8 +162,8 @@ export async function handler (
dependencies: [],
package: {
...project,
dir: opts.dir,
dirRealPath: opts.dir,
rootDir: opts.dir,
rootDirRealPath: opts.dir,
} as Project,
},
}

View File

@@ -75,7 +75,7 @@ export async function runRecursive (
.flat()
.map((prefix) => opts.selectedProjectsGraph[prefix])
.filter((pkg) => getSpecifiedScripts(pkg.package.manifest.scripts ?? {}, scriptName).length < 1)
.map((pkg) => pkg.package.manifest.name ?? pkg.package.dir)
.map((pkg) => pkg.package.manifest.name ?? pkg.package.rootDir)
if (missingScriptPackages.length) {
throw new PnpmError('RECURSIVE_RUN_NO_SCRIPT', `Missing script "${scriptName}" in packages: ${missingScriptPackages.join(', ')}`)
}

View File

@@ -444,8 +444,8 @@ test('pnpm exec shell mode', async () => {
[process.cwd()]: {
dependencies: [],
package: {
dir: process.cwd(),
dirRealPath: process.cwd(),
rootDir: process.cwd(),
rootDirRealPath: process.cwd(),
writeProjectManifest: async () => {},
manifest: {
name: 'test_shell_mode',

View File

@@ -21,8 +21,8 @@ export interface Options {
}
export interface Project {
dir: string
dirRealPath: string
rootDir: string
rootDirRealPath: string
manifest: ProjectManifest
writeProjectManifest: (manifest: ProjectManifest, force?: boolean | undefined) => Promise<void>
@@ -57,10 +57,10 @@ export async function findPackages (root: string, opts?: Options): Promise<Proje
),
async manifestPath => {
try {
const dir = path.dirname(manifestPath)
const rootDir = path.dirname(manifestPath)
return {
dir,
dirRealPath: await fs.realpath(dir),
rootDir,
rootDirRealPath: await fs.realpath(rootDir),
...await readExactProjectManifest(manifestPath),
} as Project
} catch (err: unknown) {

View File

@@ -15,7 +15,7 @@ test('finds package', async () => {
const pkgs = await findPackages(root)
expect(pkgs).toHaveLength(1)
expect(pkgs[0].dir).toBeDefined()
expect(pkgs[0].rootDir).toBeDefined()
expect(pkgs[0].manifest).toBeDefined()
})
@@ -24,9 +24,9 @@ test('finds packages by patterns', async () => {
const pkgs = await findPackages(root, { patterns: ['components/**'] })
expect(pkgs).toHaveLength(2)
expect(pkgs[0].dir).toBeDefined()
expect(pkgs[0].rootDir).toBeDefined()
expect(pkgs[0].manifest).toBeDefined()
expect(pkgs[1].dir).toBeDefined()
expect(pkgs[1].rootDir).toBeDefined()
expect(pkgs[1].manifest).toBeDefined()
expect([pkgs[0].manifest.name, pkgs[1].manifest.name].sort(compare)).toStrictEqual(['component-1', 'component-2'])
})
@@ -52,9 +52,9 @@ test('ignore packages by patterns', async () => {
const pkgs = await findPackages(root, { patterns: ['**', '!libs/**'] })
expect(pkgs).toHaveLength(2)
expect(pkgs[0].dir).toBeDefined()
expect(pkgs[0].rootDir).toBeDefined()
expect(pkgs[0].manifest).toBeDefined()
expect(pkgs[1].dir).toBeDefined()
expect(pkgs[1].rootDir).toBeDefined()
expect(pkgs[1].manifest).toBeDefined()
expect([pkgs[0].manifest.name, pkgs[1].manifest.name].sort(compare)).toStrictEqual(['component-1', 'component-2'])
})
@@ -64,10 +64,10 @@ test('json and yaml manifests are also found', async () => {
const pkgs = await findPackages(root)
expect(pkgs).toHaveLength(3)
expect(pkgs[0].dir).toBeDefined()
expect(pkgs[0].rootDir).toBeDefined()
expect(pkgs[0].manifest.name).toEqual('component-1')
expect(pkgs[1].dir).toBeDefined()
expect(pkgs[1].rootDir).toBeDefined()
expect(pkgs[1].manifest.name).toEqual('component-2')
expect(pkgs[2].dir).toBeDefined()
expect(pkgs[2].rootDir).toBeDefined()
expect(pkgs[2].manifest.name).toEqual('foo')
})

View File

@@ -1,8 +1,8 @@
import { type ProjectManifest } from './package'
export interface Project {
dir: string
dirRealPath: string
rootDir: string
rootDirRealPath: string
manifest: ProjectManifest
writeProjectManifest: (manifest: ProjectManifest, force?: boolean | undefined) => Promise<void>
}

View File

@@ -71,7 +71,7 @@ function getWorkspacePackagesByDirectory (workspacePackages: WorkspacePackages):
const workspacePackagesByDirectory: Record<string, DependencyManifest> = {}
Object.keys(workspacePackages || {}).forEach((pkgName) => {
Object.keys(workspacePackages[pkgName] || {}).forEach((pkgVersion) => {
workspacePackagesByDirectory[workspacePackages[pkgName][pkgVersion].dir] = workspacePackages[pkgName][pkgVersion].manifest
workspacePackagesByDirectory[workspacePackages[pkgName][pkgVersion].rootDir] = workspacePackages[pkgName][pkgVersion].manifest
})
})
return workspacePackagesByDirectory
@@ -132,7 +132,7 @@ async function linkedPackagesAreUpToDate (
}
const linkedDir = isLinked
? path.join(project.dir, lockfileRef.slice(5))
: workspacePackages?.[depName]?.[lockfileRef]?.dir
: workspacePackages?.[depName]?.[lockfileRef]?.rootDir
if (!linkedDir) return true
if (!linkWorkspacePackages && !currentSpec.startsWith('workspace:')) {
// we found a linked dir, but we don't want to use it, because it's not specified as a

View File

@@ -12,7 +12,7 @@ const fooManifest = {
const workspacePackages = {
foo: {
'1.0.0': {
dir: 'foo',
rootDir: 'foo',
manifest: fooManifest,
},
},

View File

@@ -338,13 +338,13 @@ test('some projects were removed from the workspace and the ones that are left d
const workspacePackages = {
'project-1': {
'1.0.0': {
dir: path.resolve('project-1'),
rootDir: path.resolve('project-1'),
manifest: project1Manifest,
},
},
'project-2': {
'1.0.0': {
dir: path.resolve('project-2'),
rootDir: path.resolve('project-2'),
manifest: project2Manifest,
},
},

View File

@@ -598,7 +598,7 @@ function arrayOfWorkspacePackagesToMap (
}
acc[pkg.manifest.name][pkg.manifest.version ?? '0.0.0'] = {
manifest: pkg.manifest as DependencyManifest,
dir: pkg.rootDir,
rootDir: pkg.rootDir,
}
return acc
}, {} as WorkspacePackages)

View File

@@ -332,7 +332,7 @@ function getAllVersionsFromYarnLockFile (
}
function selectProjectByDir (projects: Project[], searchedDir: string): ProjectsGraph | undefined {
const project = projects.find(({ dir }) => path.relative(dir, searchedDir) === '')
const project = projects.find(({ rootDir }) => path.relative(rootDir, searchedDir) === '')
if (project == null) return undefined
return { [searchedDir]: { dependencies: [], package: project } }
}

View File

@@ -342,7 +342,7 @@ when running add/update with the --workspace option')
}
function selectProjectByDir (projects: Project[], searchedDir: string): ProjectsGraph | undefined {
const project = projects.find(({ dir }) => path.relative(dir, searchedDir) === '')
const project = projects.find(({ rootDir }) => path.relative(rootDir, searchedDir) === '')
if (project == null) return undefined
return { [searchedDir]: { dependencies: [], package: project } }
}

View File

@@ -202,7 +202,7 @@ export async function handler (
const pkgsFoundInWorkspace = workspacePackagesArr
.filter(({ manifest }) => manifest.name && pkgNames.includes(manifest.name))
pkgsFoundInWorkspace.forEach((pkgFromWorkspace) => pkgPaths.push(pkgFromWorkspace.dir))
pkgsFoundInWorkspace.forEach((pkgFromWorkspace) => pkgPaths.push(pkgFromWorkspace.rootDir))
if ((pkgsFoundInWorkspace.length > 0) && !linkOpts.targetDependenciesField) {
linkOpts.targetDependenciesField = 'dependencies'

View File

@@ -519,17 +519,17 @@ function getAllProjects (manifestsByPath: ManifestsByPath, allProjectsGraph: Pro
buildIndex,
manifest: manifestsByPath[rootDir].manifest,
rootDir,
rootDirRealPath: allProjectsGraph[rootDir].package.dirRealPath,
rootDirRealPath: allProjectsGraph[rootDir].package.rootDirRealPath,
}))).flat()
}
interface ManifestsByPath { [dir: string]: Omit<Project, 'dir' | 'dirRealPath'> }
interface ManifestsByPath { [dir: string]: Omit<Project, 'rootDir' | 'rootDirRealPath'> }
function getManifestsByPath (projects: Project[]): Record<string, Omit<Project, 'dir' | 'dirRealPath'>> {
return projects.reduce((manifestsByPath, { dir, manifest, writeProjectManifest }) => {
manifestsByPath[dir] = { manifest, writeProjectManifest }
function getManifestsByPath (projects: Project[]): Record<string, Omit<Project, 'rootDir' | 'rootDirRealPath'>> {
return projects.reduce((manifestsByPath, { rootDir, manifest, writeProjectManifest }) => {
manifestsByPath[rootDir] = { manifest, writeProjectManifest }
return manifestsByPath
}, {} as Record<string, Omit<Project, 'dir' | 'dirRealPath'>>)
}, {} as Record<string, Omit<Project, 'rootDir' | 'rootDirRealPath'>>)
}
function getImporters (opts: Pick<RecursiveOptions, 'selectedProjectsGraph' | 'ignoredPackages'>): Array<{ rootDir: string, rootDirRealPath: string }> {
@@ -537,5 +537,5 @@ function getImporters (opts: Pick<RecursiveOptions, 'selectedProjectsGraph' | 'i
if (opts.ignoredPackages != null) {
rootDirs = rootDirs.filter((rootDir) => !opts.ignoredPackages!.has(rootDir))
}
return rootDirs.map((rootDir) => ({ rootDir, rootDirRealPath: opts.selectedProjectsGraph[rootDir].package.dirRealPath }))
return rootDirs.map((rootDir) => ({ rootDir, rootDirRealPath: opts.selectedProjectsGraph[rootDir].package.rootDirRealPath }))
}

View File

@@ -185,12 +185,12 @@ async function interactiveUpdate (
? Object.values(opts.selectedProjectsGraph).map((wsPkg) => wsPkg.package)
: [
{
dir: opts.dir,
rootDir: opts.dir,
manifest: await readProjectManifestOnly(opts.dir, opts),
},
]
const rootDir = opts.workspaceDir ?? opts.dir
const rootProject = projects.find((project) => project.dir === rootDir)
const rootProject = projects.find((project) => project.rootDir === rootDir)
const outdatedPkgsOfProjects = await outdatedDepsOfProjects(projects, input, {
...opts,
compatible: opts.latest !== true,

View File

@@ -13,7 +13,7 @@ const INCLUDE_ALL = {
const WORKSPACE_PACKAGES = {
bar: {
'100.0.0': {
dir: '',
rootDir: '',
manifest: {
name: 'foo',
version: '100.0.0',
@@ -22,7 +22,7 @@ const WORKSPACE_PACKAGES = {
},
foo: {
'100.0.0': {
dir: '',
rootDir: '',
manifest: {
name: 'foo',
version: '100.0.0',
@@ -31,7 +31,7 @@ const WORKSPACE_PACKAGES = {
},
qar: {
'100.0.0': {
dir: '',
rootDir: '',
manifest: {
name: 'foo',
version: '100.0.0',

View File

@@ -1,6 +1,5 @@
import { parsePref, type RegistryPackageSpec } from '@pnpm/npm-resolver'
import { type WorkspacePackages } from '@pnpm/resolver-base'
import { type PackageManifest } from '@pnpm/types'
import { type WorkspacePackagesByVersion, type WorkspacePackages } from '@pnpm/resolver-base'
import semver from 'semver'
import { type WantedDependency } from './getNonDevWantedDependencies'
@@ -19,12 +18,7 @@ export function wantedDepIsLocallyAvailable (
// TODO: move this function to separate package or import from @pnpm/npm-resolver
function pickMatchingLocalVersionOrNull (
versions: {
[version: string]: {
dir: string
manifest: PackageManifest
}
},
versions: WorkspacePackagesByVersion,
spec: RegistryPackageSpec
): string | null {
const localVersions = Object.keys(versions)

View File

@@ -1402,7 +1402,7 @@ test('root package is included when not specified', async () => {
const workspacePackages = await findWorkspacePackages(tempDir, { engineStrict: false, patterns: workspacePackagePatterns })
expect(workspacePackages.some(project => {
const relativePath = path.join('.', path.relative(tempDir, project.dir))
const relativePath = path.join('.', path.relative(tempDir, project.rootDir))
return relativePath === '.' && project.manifest.name === 'project'
})).toBeTruthy() // root project is present even if not specified
})
@@ -1440,7 +1440,7 @@ test("root package can't be ignored using '!.' (or any other such glob)", async
const workspacePackages = await findWorkspacePackages(tempDir, { engineStrict: false, patterns: workspacePackagePatterns })
expect(workspacePackages.some(project => {
const relativePath = path.join('.', path.relative(tempDir, project.dir))
const relativePath = path.join('.', path.relative(tempDir, project.rootDir))
return relativePath === '.' && project.manifest.name === 'project'
})).toBeTruthy() // root project is present even when explicitly ignored
})

View File

@@ -76,13 +76,13 @@ export async function recursivePublish (
if (!pkg.manifest.name || !pkg.manifest.version || pkg.manifest.private) return false
if (opts.force) return true
return !(await isAlreadyPublished({
dir: pkg.dir,
lockfileDir: opts.lockfileDir ?? pkg.dir,
dir: pkg.rootDir,
lockfileDir: opts.lockfileDir ?? pkg.rootDir,
registries: opts.registries,
resolve,
}, pkg.manifest.name, pkg.manifest.version))
})
const publishedPkgDirs = new Set(pkgsToPublish.map(({ dir }) => dir))
const publishedPkgDirs = new Set(pkgsToPublish.map(({ rootDir }) => rootDir))
const publishedPackages: Array<{ name?: string, version?: string }> = []
if (publishedPkgDirs.size === 0) {
logger.info({
@@ -113,7 +113,7 @@ export async function recursivePublish (
// eslint-disable-next-line no-await-in-loop
const publishResult = await publish({
...opts,
dir: pkg.dir,
dir: pkg.rootDir,
argv: {
original: [
'publish',
@@ -126,7 +126,7 @@ export async function recursivePublish (
},
gitChecks: false,
recursive: false,
}, [pkg.dir])
}, [pkg.rootDir])
if (publishResult?.manifest != null) {
publishedPackages.push(pick(['name', 'version'], publishResult.manifest))
} else if (publishResult?.exitCode) {

View File

@@ -13,8 +13,8 @@ import {
type WantedDependency,
type WorkspacePackage,
type WorkspacePackages,
type WorkspacePackagesByVersion,
} from '@pnpm/resolver-base'
import { type DependencyManifest } from '@pnpm/types'
import { LRUCache } from 'lru-cache'
import normalize from 'normalize-path'
import pMemoize from 'p-memoize'
@@ -306,12 +306,7 @@ function tryResolveFromWorkspacePackages (
}
function pickMatchingLocalVersionOrNull (
versions: {
[version: string]: {
dir: string
manifest: DependencyManifest
}
},
versions: WorkspacePackagesByVersion,
spec: RegistryPackageSpec
): string | null {
const localVersions = Object.keys(versions)
@@ -364,8 +359,8 @@ function resolveLocalPackageDir (localPackage: WorkspacePackage): string {
if (
localPackage.manifest.publishConfig?.directory == null ||
localPackage.manifest.publishConfig?.linkDirectory === false
) return localPackage.dir
return path.join(localPackage.dir, localPackage.manifest.publishConfig.directory)
) return localPackage.rootDir
return path.join(localPackage.rootDir, localPackage.manifest.publishConfig.directory)
}
function defaultTagForAlias (alias: string, defaultTag: string): RegistryPackageSpec {

View File

@@ -981,7 +981,7 @@ test('resolve from local directory when it matches the latest version of the pac
workspacePackages: {
'is-positive': {
'1.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '1.0.0',
@@ -1019,7 +1019,7 @@ test('resolve injected dependency from local directory when it matches the lates
workspacePackages: {
'is-positive': {
'1.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '1.0.0',
@@ -1057,7 +1057,7 @@ test('do not resolve from local directory when alwaysTryWorkspacePackages is fal
workspacePackages: {
'is-positive': {
'1.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '1.0.0',
@@ -1091,7 +1091,7 @@ test('resolve from local directory when alwaysTryWorkspacePackages is false but
workspacePackages: {
'is-positive': {
'1.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '1.0.0',
@@ -1124,7 +1124,7 @@ test('resolve from local directory when alwaysTryWorkspacePackages is false but
workspacePackages: {
'is-positive': {
'1.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '1.0.0',
@@ -1165,7 +1165,7 @@ test('use version from the registry if it is newer than the local one', async ()
workspacePackages: {
'is-positive': {
'3.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '3.0.0',
@@ -1208,7 +1208,7 @@ test('preferWorkspacePackages: use version from the workspace even if there is n
workspacePackages: {
'is-positive': {
'3.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '3.0.0',
@@ -1247,7 +1247,7 @@ test('use local version if it is newer than the latest in the registry', async (
workspacePackages: {
'is-positive': {
'3.2.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '3.2.0',
@@ -1284,21 +1284,21 @@ test('resolve from local directory when package is not found in the registry', a
workspacePackages: {
'is-positive': {
'1.0.0': {
dir: '/home/istvan/src/is-positive-1.0.0',
rootDir: '/home/istvan/src/is-positive-1.0.0',
manifest: {
name: 'is-positive',
version: '1.0.0',
},
},
'1.1.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '1.1.0',
},
},
'2.0.0': {
dir: '/home/istvan/src/is-positive-2.0.0',
rootDir: '/home/istvan/src/is-positive-2.0.0',
manifest: {
name: 'is-positive',
version: '2.0.0',
@@ -1335,21 +1335,21 @@ test('resolve from local directory when package is not found in the registry and
workspacePackages: {
'is-positive': {
'1.0.0': {
dir: '/home/istvan/src/is-positive-1.0.0',
rootDir: '/home/istvan/src/is-positive-1.0.0',
manifest: {
name: 'is-positive',
version: '1.0.0',
},
},
'1.1.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '1.1.0',
},
},
'2.0.0': {
dir: '/home/istvan/src/is-positive-2.0.0',
rootDir: '/home/istvan/src/is-positive-2.0.0',
manifest: {
name: 'is-positive',
version: '2.0.0',
@@ -1386,7 +1386,7 @@ test('resolve from local directory when package is not found in the registry and
workspacePackages: {
'is-positive': {
'3.0.0-alpha.1.2.3': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '3.0.0-alpha.1.2.3',
@@ -1423,21 +1423,21 @@ test('resolve from local directory when package is not found in the registry and
workspacePackages: {
'is-positive': {
'1.0.0': {
dir: '/home/istvan/src/is-positive-1.0.0',
rootDir: '/home/istvan/src/is-positive-1.0.0',
manifest: {
name: 'is-positive',
version: '1.0.0',
},
},
'1.1.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '1.1.0',
},
},
'2.0.0': {
dir: '/home/istvan/src/is-positive-2.0.0',
rootDir: '/home/istvan/src/is-positive-2.0.0',
manifest: {
name: 'is-positive',
version: '2.0.0',
@@ -1474,7 +1474,7 @@ test('resolve from local directory when the requested version is not found in th
workspacePackages: {
'is-positive': {
'100.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '100.0.0',
@@ -1507,7 +1507,7 @@ test('workspace protocol: resolve from local directory even when it does not mat
workspacePackages: {
'is-positive': {
'3.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '3.0.0',
@@ -1544,7 +1544,7 @@ test('workspace protocol: resolve from local package that has a pre-release vers
workspacePackages: {
'is-positive': {
'3.0.0-alpha.1.2.3': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '3.0.0-alpha.1.2.3',
@@ -1581,7 +1581,7 @@ test("workspace protocol: don't resolve from local package that has a pre-releas
workspacePackages: {
'is-positive': {
'3.0.0-alpha.1.2.3': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '3.0.0-alpha.1.2.3',
@@ -1637,7 +1637,7 @@ test('workspace protocol: resolution fails if there is no matching local package
workspacePackages: {
'is-positive': {
'2.0.0': {
dir: '/home/istvan/src/is-positive',
rootDir: '/home/istvan/src/is-positive',
manifest: {
name: 'is-positive',
version: '2.0.0',

View File

@@ -44,14 +44,14 @@ export interface ResolveResult {
}
export interface WorkspacePackage {
dir: string
rootDir: string
manifest: DependencyManifest
}
export type WorkspacePackagesByVersion = Record<string, WorkspacePackage>
export interface WorkspacePackages {
[name: string]: {
[version: string]: WorkspacePackage
}
[name: string]: WorkspacePackagesByVersion
}
// This weight is set for selectors that are used on direct dependencies.

View File

@@ -14,7 +14,7 @@ import { createManifestGetter, type ManifestGetterOptions } from './createManife
import { outdated, type OutdatedPackage } from './outdated'
export async function outdatedDepsOfProjects (
pkgs: Array<{ dir: string, manifest: ProjectManifest }>,
pkgs: Array<{ rootDir: string, manifest: ProjectManifest }>,
args: string[],
opts: Omit<ManifestGetterOptions, 'fullMetadata' | 'lockfileDir'> & {
compatible?: boolean
@@ -25,7 +25,7 @@ export async function outdatedDepsOfProjects (
if (!opts.lockfileDir) {
return unnest(await Promise.all(
pkgs.map(async (pkg) =>
outdatedDepsOfProjects([pkg], args, { ...opts, lockfileDir: pkg.dir })
outdatedDepsOfProjects([pkg], args, { ...opts, lockfileDir: pkg.rootDir })
)
))
}
@@ -39,7 +39,7 @@ export async function outdatedDepsOfProjects (
fullMetadata: opts.fullMetadata === true,
lockfileDir,
})
return Promise.all(pkgs.map(async ({ dir, manifest }): Promise<OutdatedPackage[]> => {
return Promise.all(pkgs.map(async ({ rootDir, manifest }): Promise<OutdatedPackage[]> => {
const match = (args.length > 0) && createMatcher(args) || undefined
return outdated({
compatible: opts.compatible,
@@ -50,7 +50,7 @@ export async function outdatedDepsOfProjects (
lockfileDir,
manifest,
match,
prefix: dir,
prefix: rootDir,
registries: opts.registries,
wantedLockfile,
})

View File

@@ -18,23 +18,23 @@ export async function listRecursive (
): Promise<string> {
const depth = opts.depth ?? 0
if (opts.lockfileDir) {
return render(pkgs.map((pkg) => pkg.dir), params, {
return render(pkgs.map((pkg) => pkg.rootDir), params, {
...opts,
alwaysPrintRootPackage: depth === -1,
lockfileDir: opts.lockfileDir,
})
}
const outputs = (await Promise.all(pkgs.map(async ({ dir }) => {
const outputs = (await Promise.all(pkgs.map(async ({ rootDir }) => {
try {
return await render([dir], params, {
return await render([rootDir], params, {
...opts,
alwaysPrintRootPackage: depth === -1,
lockfileDir: opts.lockfileDir ?? dir,
lockfileDir: opts.lockfileDir ?? rootDir,
})
} catch (err: unknown) {
assert(util.types.isNativeError(err))
const errWithPrefix = Object.assign(err, {
prefix: dir,
prefix: rootDir,
})
logger.info(errWithPrefix)
throw errWithPrefix

View File

@@ -173,7 +173,7 @@ export async function handler (
const manifest = await readProjectManifestOnly(opts.dir, opts)
const packages = [
{
dir: opts.dir,
rootDir: opts.dir,
manifest,
},
]

View File

@@ -47,12 +47,12 @@ interface OutdatedInWorkspace extends OutdatedPackage {
}
export async function outdatedRecursive (
pkgs: Array<{ dir: string, manifest: ProjectManifest }>,
pkgs: Array<{ rootDir: string, manifest: ProjectManifest }>,
params: string[],
opts: OutdatedCommandOptions & { include: IncludedDependencies }
): Promise<{ output: string, exitCode: number }> {
const outdatedMap = {} as Record<string, OutdatedInWorkspace>
const rootManifest = pkgs.find(({ dir }) => dir === opts.lockfileDir)
const rootManifest = pkgs.find(({ rootDir }) => rootDir === opts.lockfileDir)
const outdatedPackagesByProject = await outdatedDepsOfProjects(pkgs, params, {
...opts,
fullMetadata: opts.long,
@@ -66,13 +66,13 @@ export async function outdatedRecursive (
timeout: opts.fetchTimeout,
})
for (let i = 0; i < outdatedPackagesByProject.length; i++) {
const { dir, manifest } = pkgs[i]
const { rootDir, manifest } = pkgs[i]
outdatedPackagesByProject[i].forEach((outdatedPkg) => {
const key = JSON.stringify([outdatedPkg.packageName, outdatedPkg.current, outdatedPkg.belongsTo])
if (!outdatedMap[key]) {
outdatedMap[key] = { ...outdatedPkg, dependentPkgs: [] }
}
outdatedMap[key].dependentPkgs.push({ location: dir, manifest })
outdatedMap[key].dependentPkgs.push({ location: rootDir, manifest })
})
}

View File

@@ -19,7 +19,7 @@ const PKGS_GRAPH: PackageGraph<Package> = {
'/packages/project-0': {
dependencies: ['/packages/project-1', '/project-5'],
package: {
dir: '/packages/project-0',
rootDir: '/packages/project-0',
manifest: {
name: 'project-0',
version: '1.0.0',
@@ -34,7 +34,7 @@ const PKGS_GRAPH: PackageGraph<Package> = {
'/packages/project-1': {
dependencies: ['/project-2', '/project-4'],
package: {
dir: '/packages/project-1',
rootDir: '/packages/project-1',
manifest: {
name: 'project-1',
version: '1.0.0',
@@ -50,7 +50,7 @@ const PKGS_GRAPH: PackageGraph<Package> = {
'/project-2': {
dependencies: [],
package: {
dir: '/project-2',
rootDir: '/project-2',
manifest: {
name: 'project-2',
version: '1.0.0',
@@ -64,7 +64,7 @@ const PKGS_GRAPH: PackageGraph<Package> = {
'/project-3': {
dependencies: [],
package: {
dir: '/project-3',
rootDir: '/project-3',
manifest: {
name: 'project-3',
version: '1.0.0',
@@ -78,7 +78,7 @@ const PKGS_GRAPH: PackageGraph<Package> = {
'/project-4': {
dependencies: [],
package: {
dir: '/project-4',
rootDir: '/project-4',
manifest: {
name: 'project-4',
version: '1.0.0',
@@ -92,7 +92,7 @@ const PKGS_GRAPH: PackageGraph<Package> = {
'/project-5': {
dependencies: [],
package: {
dir: '/project-5',
rootDir: '/project-5',
manifest: {
name: 'project-5',
version: '1.0.0',
@@ -106,7 +106,7 @@ const PKGS_GRAPH: PackageGraph<Package> = {
'/project-5/packages/project-6': {
dependencies: [],
package: {
dir: '/project-5/packages/project-6',
rootDir: '/project-5/packages/project-6',
manifest: {
name: 'project-6',
version: '1.0.0',
@@ -213,7 +213,7 @@ test('select package without specifying its scope', async () => {
'/packages/bar': {
dependencies: [],
package: {
dir: '/packages/bar',
rootDir: '/packages/bar',
manifest: {
name: '@foo/bar',
version: '1.0.0',
@@ -236,7 +236,7 @@ test('when a scoped package with the same name exists, only pick the exact match
'/packages/@foo/bar': {
dependencies: [],
package: {
dir: '/packages/@foo/bar',
rootDir: '/packages/@foo/bar',
manifest: {
name: '@foo/bar',
version: '1.0.0',
@@ -246,7 +246,7 @@ test('when a scoped package with the same name exists, only pick the exact match
'/packages/bar': {
dependencies: [],
package: {
dir: '/packages/bar',
rootDir: '/packages/bar',
manifest: {
name: 'bar',
version: '1.0.0',
@@ -269,7 +269,7 @@ test('when two scoped packages match the searched name, don\'t select any', asyn
'/packages/@foo/bar': {
dependencies: [],
package: {
dir: '/packages/@foo/bar',
rootDir: '/packages/@foo/bar',
manifest: {
name: '@foo/bar',
version: '1.0.0',
@@ -279,7 +279,7 @@ test('when two scoped packages match the searched name, don\'t select any', asyn
'/packages/@types/bar': {
dependencies: [],
package: {
dir: '/packages/@types/bar',
rootDir: '/packages/@types/bar',
manifest: {
name: '@types/bar',
version: '1.0.0',
@@ -381,7 +381,7 @@ test('select changed packages', async () => {
[workspaceDir]: {
dependencies: [],
package: {
dir: workspaceDir,
rootDir: workspaceDir,
manifest: {
name: 'root',
version: '0.0.0',
@@ -391,7 +391,7 @@ test('select changed packages', async () => {
[pkg1Dir]: {
dependencies: [],
package: {
dir: pkg1Dir,
rootDir: pkg1Dir,
manifest: {
name: 'package-1',
version: '0.0.0',
@@ -401,7 +401,7 @@ test('select changed packages', async () => {
[pkg2Dir]: {
dependencies: [],
package: {
dir: pkg2Dir,
rootDir: pkg2Dir,
manifest: {
name: 'package-2',
version: '0.0.0',
@@ -411,7 +411,7 @@ test('select changed packages', async () => {
[pkg3Dir]: {
dependencies: [pkg2Dir],
package: {
dir: pkg3Dir,
rootDir: pkg3Dir,
manifest: {
name: 'package-3',
version: '0.0.0',
@@ -421,7 +421,7 @@ test('select changed packages', async () => {
[pkgKorDir]: {
dependencies: [],
package: {
dir: pkgKorDir,
rootDir: pkgKorDir,
manifest: {
name: 'package-kor',
version: '0.0.0',
@@ -431,7 +431,7 @@ test('select changed packages', async () => {
[pkg20Dir]: {
dependencies: [],
package: {
dir: pkg20Dir,
rootDir: pkg20Dir,
manifest: {
name: 'package-20',
version: '0.0.0',

View File

@@ -31,7 +31,7 @@ export async function findWorkspacePackages (
): Promise<Project[]> {
const pkgs = await findWorkspacePackagesNoCheck(workspaceRoot, opts)
for (const pkg of pkgs) {
packageIsInstallable(pkg.dir, pkg.manifest, {
packageIsInstallable(pkg.rootDir, pkg.manifest, {
...opts,
supportedArchitectures: opts?.supportedArchitectures ?? {
os: ['current'],
@@ -40,7 +40,7 @@ export async function findWorkspacePackages (
},
})
// When setting shared-workspace-lockfile=false, `pnpm` can be set in sub-project's package.json.
if (opts?.sharedWorkspaceLockfile && pkg.dir !== workspaceRoot) {
if (opts?.sharedWorkspaceLockfile && pkg.rootDir !== workspaceRoot) {
checkNonRootProjectManifest(pkg)
}
}
@@ -57,7 +57,7 @@ export async function findWorkspacePackagesNoCheck (workspaceRoot: string, opts?
includeRoot: true,
patterns: opts?.patterns,
})
pkgs.sort((pkg1: { dir: string }, pkg2: { dir: string }) => lexCompare(pkg1.dir, pkg2.dir))
pkgs.sort((pkg1: { rootDir: string }, pkg2: { rootDir: string }) => lexCompare(pkg1.rootDir, pkg2.rootDir))
return pkgs
}
@@ -76,12 +76,12 @@ export function arrayOfWorkspacePackagesToMap (
}, {} as ArrayOfWorkspacePackagesToMapResult)
}
function checkNonRootProjectManifest ({ manifest, dir }: Project): void {
function checkNonRootProjectManifest ({ manifest, rootDir }: Project): void {
for (const rootOnlyField of ['pnpm', 'resolutions']) {
if (manifest?.[rootOnlyField as keyof ProjectManifest]) {
logger.warn({
message: `The field "${rootOnlyField}" was found in ${dir}/package.json. This will not take effect. You should configure "${rootOnlyField}" at the root of the workspace instead.`,
prefix: dir,
message: `The field "${rootOnlyField}" was found in ${rootDir}/package.json. This will not take effect. You should configure "${rootOnlyField}" at the root of the workspace instead.`,
prefix: rootDir,
})
}
}

View File

@@ -7,7 +7,7 @@ import mapValues from 'ramda/src/map'
export interface Package {
manifest: BaseManifest
dir: string
rootDir: string
}
export interface PackageNode<Pkg extends Package> {
@@ -51,26 +51,26 @@ export function createPkgGraph<Pkg extends Package> (pkgs: Pkg[], opts?: {
rawSpec = fetchSpec
depName = name
}
spec = npa.resolve(depName, rawSpec, pkg.dir)
spec = npa.resolve(depName, rawSpec, pkg.rootDir)
} catch {
return ''
}
if (spec.type === 'directory') {
pkgMapByDir ??= getPkgMapByDir(pkgMapValues)
const resolvedPath = path.resolve(pkg.dir, spec.fetchSpec)
const resolvedPath = path.resolve(pkg.rootDir, spec.fetchSpec)
const found = pkgMapByDir[resolvedPath]
if (found) {
return found.dir
return found.rootDir
}
// Slow path; only needed when there are case mismatches on case-insensitive filesystems.
const matchedPkg = pkgMapValues.find(pkg => path.relative(pkg.dir, spec.fetchSpec) === '')
const matchedPkg = pkgMapValues.find(pkg => path.relative(pkg.rootDir, spec.fetchSpec) === '')
if (matchedPkg == null) {
return ''
}
pkgMapByDir[resolvedPath] = matchedPkg
return matchedPkg.dir
return matchedPkg.rootDir
}
if (spec.type !== 'version' && spec.type !== 'range') return ''
@@ -89,11 +89,11 @@ export function createPkgGraph<Pkg extends Package> (pkgs: Pkg[], opts?: {
}
if (isWorkspaceSpec && versions.length === 0) {
const matchedPkg = pkgs.find(pkg => pkg.manifest.name === depName)
return matchedPkg!.dir
return matchedPkg!.rootDir
}
if (versions.includes(rawSpec)) {
const matchedPkg = pkgs.find(pkg => pkg.manifest.name === depName && pkg.manifest.version === rawSpec)
return matchedPkg!.dir
return matchedPkg!.rootDir
}
const matched = resolveWorkspaceRange(rawSpec, versions)
if (!matched) {
@@ -101,7 +101,7 @@ export function createPkgGraph<Pkg extends Package> (pkgs: Pkg[], opts?: {
return ''
}
const matchedPkg = pkgs.find(pkg => pkg.manifest.name === depName && pkg.manifest.version === matched)
return matchedPkg!.dir
return matchedPkg!.rootDir
})
.filter(Boolean)
}
@@ -110,7 +110,7 @@ export function createPkgGraph<Pkg extends Package> (pkgs: Pkg[], opts?: {
function createPkgMap (pkgs: Package[]): Record<string, Package> {
const pkgMap: Record<string, Package> = {}
for (const pkg of pkgs) {
pkgMap[pkg.dir] = pkg
pkgMap[pkg.rootDir] = pkg
}
return pkgMap
}
@@ -128,7 +128,7 @@ function getPkgMapByManifestName (pkgMapValues: Package[]): Record<string, Packa
function getPkgMapByDir (pkgMapValues: Package[]): Record<string, Package | undefined> {
const pkgMapByDir: Record<string, Package | undefined> = {}
for (const pkg of pkgMapValues) {
pkgMapByDir[path.resolve(pkg.dir)] = pkg
pkgMapByDir[path.resolve(pkg.rootDir)] = pkg
}
return pkgMapByDir
}

View File

@@ -13,7 +13,7 @@ const BAR5_PATH = pathResolve('/zkochan/src/bar@5')
test('create package graph', () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -25,7 +25,7 @@ test('create package graph', () => {
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -36,7 +36,7 @@ test('create package graph', () => {
},
},
{
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
name: 'bar',
version: '2.0.0',
@@ -47,7 +47,7 @@ test('create package graph', () => {
},
},
{
dir: FOO2_PATH,
rootDir: FOO2_PATH,
manifest: {
name: 'foo',
version: '2.0.0',
@@ -59,7 +59,7 @@ test('create package graph', () => {
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -74,7 +74,7 @@ test('create package graph', () => {
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -88,7 +88,7 @@ test('create package graph', () => {
[BAR2_PATH]: {
dependencies: [FOO2_PATH],
package: {
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
name: 'bar',
version: '2.0.0',
@@ -102,7 +102,7 @@ test('create package graph', () => {
[FOO2_PATH]: {
dependencies: [],
package: {
dir: FOO2_PATH,
rootDir: FOO2_PATH,
manifest: {
name: 'foo',
version: '2.0.0',
@@ -115,7 +115,7 @@ test('create package graph', () => {
test('create package graph using peer dependencies', () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -127,7 +127,7 @@ test('create package graph using peer dependencies', () => {
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -139,7 +139,7 @@ test('create package graph using peer dependencies', () => {
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -154,7 +154,7 @@ test('create package graph using peer dependencies', () => {
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -167,7 +167,7 @@ test('create package graph using peer dependencies', () => {
test('create package graph for local directory dependencies', () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -180,7 +180,7 @@ test('create package graph for local directory dependencies', () => {
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -191,7 +191,7 @@ test('create package graph for local directory dependencies', () => {
},
},
{
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
name: 'bar',
version: '2.0.0',
@@ -202,7 +202,7 @@ test('create package graph for local directory dependencies', () => {
},
},
{
dir: FOO2_PATH,
rootDir: FOO2_PATH,
manifest: {
name: 'foo',
version: '2.0.0',
@@ -214,7 +214,7 @@ test('create package graph for local directory dependencies', () => {
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -230,7 +230,7 @@ test('create package graph for local directory dependencies', () => {
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -244,7 +244,7 @@ test('create package graph for local directory dependencies', () => {
[BAR2_PATH]: {
dependencies: [FOO2_PATH],
package: {
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
name: 'bar',
version: '2.0.0',
@@ -258,7 +258,7 @@ test('create package graph for local directory dependencies', () => {
[FOO2_PATH]: {
dependencies: [],
package: {
dir: FOO2_PATH,
rootDir: FOO2_PATH,
manifest: {
name: 'foo',
version: '2.0.0',
@@ -271,7 +271,7 @@ test('create package graph for local directory dependencies', () => {
test('create package graph ignoring the workspace protocol', () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -283,7 +283,7 @@ test('create package graph ignoring the workspace protocol', () => {
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -294,7 +294,7 @@ test('create package graph ignoring the workspace protocol', () => {
},
},
{
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
name: 'bar',
version: '2.0.0',
@@ -305,14 +305,14 @@ test('create package graph ignoring the workspace protocol', () => {
},
},
{
dir: FOO2_PATH,
rootDir: FOO2_PATH,
manifest: {
name: 'foo',
version: '2.0.0',
},
},
{
dir: BAR3_PATH,
rootDir: BAR3_PATH,
manifest: {
name: 'bar',
version: '3.0.0',
@@ -323,7 +323,7 @@ test('create package graph ignoring the workspace protocol', () => {
},
},
{
dir: BAR4_PATH,
rootDir: BAR4_PATH,
manifest: {
name: 'bar',
version: '4.0.0',
@@ -339,7 +339,7 @@ test('create package graph ignoring the workspace protocol', () => {
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -354,7 +354,7 @@ test('create package graph ignoring the workspace protocol', () => {
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -368,7 +368,7 @@ test('create package graph ignoring the workspace protocol', () => {
[BAR2_PATH]: {
dependencies: [FOO2_PATH],
package: {
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
name: 'bar',
version: '2.0.0',
@@ -382,7 +382,7 @@ test('create package graph ignoring the workspace protocol', () => {
[FOO2_PATH]: {
dependencies: [],
package: {
dir: FOO2_PATH,
rootDir: FOO2_PATH,
manifest: {
name: 'foo',
version: '2.0.0',
@@ -392,7 +392,7 @@ test('create package graph ignoring the workspace protocol', () => {
[BAR3_PATH]: {
dependencies: [FOO2_PATH],
package: {
dir: BAR3_PATH,
rootDir: BAR3_PATH,
manifest: {
name: 'bar',
version: '3.0.0',
@@ -406,7 +406,7 @@ test('create package graph ignoring the workspace protocol', () => {
[BAR4_PATH]: {
dependencies: [FOO2_PATH],
package: {
dir: BAR4_PATH,
rootDir: BAR4_PATH,
manifest: {
name: 'bar',
version: '4.0.0',
@@ -423,7 +423,7 @@ test('create package graph ignoring the workspace protocol', () => {
test('create package graph respects linked-workspace-packages = false', () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
dependencies: {
foo: 'workspace:*',
@@ -433,7 +433,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
dependencies: {
bar: '^10.0.0',
@@ -443,7 +443,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
},
},
{
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
dependencies: {
foo: '1.0.1',
@@ -453,7 +453,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
},
},
{
dir: BAR3_PATH,
rootDir: BAR3_PATH,
manifest: {
dependencies: {
foo: 'workspace:~1.0.0',
@@ -463,7 +463,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
},
},
{
dir: BAR4_PATH,
rootDir: BAR4_PATH,
manifest: {
dependencies: {
foo: 'workspace:^',
@@ -473,7 +473,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
},
},
{
dir: BAR5_PATH,
rootDir: BAR5_PATH,
manifest: {
dependencies: {
foo: 'workspace:~',
@@ -488,7 +488,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
dependencies: {
foo: 'workspace:*',
@@ -501,7 +501,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
dependencies: {
bar: '^10.0.0',
@@ -516,7 +516,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
// workspace dependencies
dependencies: [],
package: {
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
dependencies: {
foo: '1.0.1',
@@ -529,7 +529,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
[BAR3_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR3_PATH,
rootDir: BAR3_PATH,
manifest: {
dependencies: {
foo: 'workspace:~1.0.0',
@@ -542,7 +542,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
[BAR4_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR4_PATH,
rootDir: BAR4_PATH,
manifest: {
dependencies: {
foo: 'workspace:^',
@@ -555,7 +555,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
[BAR5_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR5_PATH,
rootDir: BAR5_PATH,
manifest: {
dependencies: {
foo: 'workspace:~',
@@ -571,7 +571,7 @@ test('create package graph respects linked-workspace-packages = false', () => {
test('create package graph respects ignoreDevDeps = true', () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -585,7 +585,7 @@ test('create package graph respects ignoreDevDeps = true', () => {
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -596,7 +596,7 @@ test('create package graph respects ignoreDevDeps = true', () => {
},
},
{
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
name: 'bar',
version: '2.0.0',
@@ -607,7 +607,7 @@ test('create package graph respects ignoreDevDeps = true', () => {
},
},
{
dir: FOO2_PATH,
rootDir: FOO2_PATH,
manifest: {
name: 'foo',
version: '2.0.0',
@@ -619,7 +619,7 @@ test('create package graph respects ignoreDevDeps = true', () => {
[BAR1_PATH]: {
dependencies: [],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',
@@ -636,7 +636,7 @@ test('create package graph respects ignoreDevDeps = true', () => {
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0',
@@ -650,7 +650,7 @@ test('create package graph respects ignoreDevDeps = true', () => {
[BAR2_PATH]: {
dependencies: [FOO2_PATH],
package: {
dir: BAR2_PATH,
rootDir: BAR2_PATH,
manifest: {
name: 'bar',
version: '2.0.0',
@@ -664,7 +664,7 @@ test('create package graph respects ignoreDevDeps = true', () => {
[FOO2_PATH]: {
dependencies: [],
package: {
dir: FOO2_PATH,
rootDir: FOO2_PATH,
manifest: {
name: 'foo',
version: '2.0.0',
@@ -677,7 +677,7 @@ test('create package graph respects ignoreDevDeps = true', () => {
test('* matches prerelease versions', () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
dependencies: {
foo: '*',
@@ -687,7 +687,7 @@ test('* matches prerelease versions', () => {
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0-0',
@@ -699,7 +699,7 @@ test('* matches prerelease versions', () => {
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
dependencies: {
foo: '*',
@@ -712,7 +712,7 @@ test('* matches prerelease versions', () => {
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0-0',
@@ -726,7 +726,7 @@ test('* matches prerelease versions', () => {
test('successfully create a package graph even when a workspace package has no version', async () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
dependencies: {
foo: 'workspace:*',
@@ -736,7 +736,7 @@ test('successfully create a package graph even when a workspace package has no v
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
},
@@ -748,7 +748,7 @@ test('successfully create a package graph even when a workspace package has no v
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
dependencies: {
foo: 'workspace:*',
@@ -761,7 +761,7 @@ test('successfully create a package graph even when a workspace package has no v
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
},
@@ -773,7 +773,7 @@ test('successfully create a package graph even when a workspace package has no v
test('create package graph respects workspace alias syntax', async () => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
dependencies: {
'foo-alias': 'workspace:foo@*',
@@ -783,7 +783,7 @@ test('create package graph respects workspace alias syntax', async () => {
},
},
{
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
},
@@ -794,7 +794,7 @@ test('create package graph respects workspace alias syntax', async () => {
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
rootDir: BAR1_PATH,
manifest: {
dependencies: {
'foo-alias': 'workspace:foo@*',
@@ -807,7 +807,7 @@ test('create package graph respects workspace alias syntax', async () => {
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
rootDir: FOO1_PATH,
manifest: {
name: 'foo',
},