mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-23 23:29:17 -05:00
feat: treat a project with no version as if it had v0.0.0
close #2648 PR #2678
This commit is contained in:
5
.changeset/healthy-cups-cross.md
Normal file
5
.changeset/healthy-cups-cross.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/find-workspace-packages": minor
|
||||
---
|
||||
|
||||
A project with no version field is treated as if it had version 0.0.0.
|
||||
@@ -13,7 +13,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "tslint -c ../../tslint.json src/**/*.ts test/**/*.ts",
|
||||
"test": "pnpm run compile",
|
||||
"_test": "cd ../.. && c8 --reporter lcov --reports-dir packages/find-workspace-packages/coverage ts-node packages/find-workspace-packages/test --type-check",
|
||||
"test": "pnpm run compile && pnpm run _test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build"
|
||||
},
|
||||
|
||||
@@ -47,14 +47,14 @@ async function requirePackagesManifest (dir: string): Promise<{packages?: string
|
||||
}
|
||||
|
||||
export function arrayOfWorkspacePackagesToMap (
|
||||
pkgs: Project[]
|
||||
pkgs: Array<Pick<Project, 'manifest'>>
|
||||
) {
|
||||
return pkgs.reduce((acc, pkg) => {
|
||||
if (!pkg.manifest.name || !pkg.manifest.version) return acc
|
||||
if (!pkg.manifest.name) return acc
|
||||
if (!acc[pkg.manifest.name]) {
|
||||
acc[pkg.manifest.name] = {}
|
||||
}
|
||||
acc[pkg.manifest.name][pkg.manifest.version] = pkg
|
||||
acc[pkg.manifest.name][pkg.manifest.version ?? '0.0.0'] = pkg
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
|
||||
18
packages/find-workspace-packages/test/index.ts
Normal file
18
packages/find-workspace-packages/test/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { arrayOfWorkspacePackagesToMap } from '@pnpm/find-workspace-packages'
|
||||
import test = require('tape')
|
||||
|
||||
// This is supported for compatibility with Yarn's implementation
|
||||
// see https://github.com/pnpm/pnpm/issues/2648
|
||||
test('arrayOfWorkspacePackagesToMap() treats private packages with no version as packages with 0.0.0 version', (t) => {
|
||||
const privateProject = {
|
||||
manifest: {
|
||||
name: 'private-pkg',
|
||||
},
|
||||
}
|
||||
t.deepEqual(arrayOfWorkspacePackagesToMap([privateProject]), {
|
||||
'private-pkg': {
|
||||
'0.0.0': privateProject,
|
||||
},
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
Reference in New Issue
Block a user