@pnpm/pkg-manifest.commands 1100.1.31 → 1100.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/lib/pkg.js +11 -4
- package/lib/reportKeys.d.ts +17 -0
- package/lib/reportKeys.js +44 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @pnpm/pkg-manifest.commands
|
|
2
2
|
|
|
3
|
+
## 1100.1.33
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies:
|
|
8
|
+
- @pnpm/cli.utils@1101.0.32
|
|
9
|
+
- @pnpm/config.reader@1102.3.4
|
|
10
|
+
- @pnpm/error@1100.2.2
|
|
11
|
+
- @pnpm/object.property-path@1100.1.9
|
|
12
|
+
|
|
13
|
+
## 1100.1.32
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- `pnpm -r pkg get` now reports every selected project when several share a package name. Projects with the same name are keyed by their directory relative to the workspace root. Before, only one of them appeared in the output.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies:
|
|
20
|
+
- @pnpm/cli.utils@1101.0.31
|
|
21
|
+
- @pnpm/config.reader@1102.3.3
|
|
22
|
+
|
|
3
23
|
## 1100.1.31
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/lib/pkg.js
CHANGED
|
@@ -4,6 +4,7 @@ import { types as allTypes } from '@pnpm/config.reader';
|
|
|
4
4
|
import { PnpmError } from '@pnpm/error';
|
|
5
5
|
import { deleteObjectValueByPropertyPathString, getObjectValueByPropertyPathString, setObjectValueByPropertyPathString, } from '@pnpm/object.property-path';
|
|
6
6
|
import { renderHelp } from 'render-help';
|
|
7
|
+
import { assignReportKeys } from './reportKeys.js';
|
|
7
8
|
export const rcOptionsTypes = cliOptionsTypes;
|
|
8
9
|
export function cliOptionsTypes() {
|
|
9
10
|
const types = allTypes;
|
|
@@ -57,12 +58,18 @@ async function handleRecursiveCommand(opts, subcmd, args) {
|
|
|
57
58
|
throw new PnpmError('PKG_RECURSIVE_NO_PACKAGES', 'No workspace packages were selected');
|
|
58
59
|
}
|
|
59
60
|
if (subcmd === 'get') {
|
|
60
|
-
const
|
|
61
|
+
const projects = await Promise.all(selectedProjects.map(async ({ package: pkg }) => {
|
|
61
62
|
const manifest = await readProjectManifestOnly(pkg.rootDir);
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
return {
|
|
64
|
+
identity: {
|
|
65
|
+
name: manifest.name == null ? undefined : String(manifest.name),
|
|
66
|
+
dirKey: path.relative(workspaceDir, pkg.rootDir),
|
|
67
|
+
},
|
|
68
|
+
value: selectFromManifest(manifest, args),
|
|
69
|
+
};
|
|
64
70
|
}));
|
|
65
|
-
|
|
71
|
+
const keys = assignReportKeys(projects.map(({ identity }) => identity));
|
|
72
|
+
return JSON.stringify(Object.fromEntries(projects.map(({ value }, index) => [keys[index], value])), undefined, 2);
|
|
66
73
|
}
|
|
67
74
|
await Promise.all(selectedProjects.map(({ package: pkg }) => runSubcommand({ ...opts, dir: pkg.rootDir }, subcmd, args)));
|
|
68
75
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ReportIdentity {
|
|
2
|
+
/** The manifest's `name`, when it declares one. */
|
|
3
|
+
name?: string;
|
|
4
|
+
/** The project's directory, relative to the workspace root. */
|
|
5
|
+
dirKey: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Chooses a distinct `pnpm -r pkg get` report key for every project, in input order.
|
|
9
|
+
*
|
|
10
|
+
* A project is keyed by its name unless that would hide another project:
|
|
11
|
+
* a project without a name, every project that shares its name with
|
|
12
|
+
* another selected project, and a project whose name equals the directory
|
|
13
|
+
* key another project is reported under are keyed by their directory instead. Directories
|
|
14
|
+
* are distinct, so the keys are too, and a workspace whose names are unique
|
|
15
|
+
* keeps its name keys.
|
|
16
|
+
*/
|
|
17
|
+
export declare function assignReportKeys(identities: ReportIdentity[]): string[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chooses a distinct `pnpm -r pkg get` report key for every project, in input order.
|
|
3
|
+
*
|
|
4
|
+
* A project is keyed by its name unless that would hide another project:
|
|
5
|
+
* a project without a name, every project that shares its name with
|
|
6
|
+
* another selected project, and a project whose name equals the directory
|
|
7
|
+
* key another project is reported under are keyed by their directory instead. Directories
|
|
8
|
+
* are distinct, so the keys are too, and a workspace whose names are unique
|
|
9
|
+
* keeps its name keys.
|
|
10
|
+
*/
|
|
11
|
+
export function assignReportKeys(identities) {
|
|
12
|
+
const keyedByDir = initiallyKeyedByDir(identities);
|
|
13
|
+
moveNamesShadowedByDirs(identities, keyedByDir);
|
|
14
|
+
return identities.map((identity, index) => identity.name == null || keyedByDir[index] ? identity.dirKey : identity.name);
|
|
15
|
+
}
|
|
16
|
+
function initiallyKeyedByDir(identities) {
|
|
17
|
+
const nameCounts = new Map();
|
|
18
|
+
for (const { name } of identities) {
|
|
19
|
+
if (name != null)
|
|
20
|
+
nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1);
|
|
21
|
+
}
|
|
22
|
+
return identities.map(({ name }) => name == null || nameCounts.get(name) > 1);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Moves every name-keyed project whose name equals a directory key in use
|
|
26
|
+
* to its own directory key. A moved project's directory key can in turn
|
|
27
|
+
* shadow another name, so each move is followed up the same way.
|
|
28
|
+
*/
|
|
29
|
+
function moveNamesShadowedByDirs(identities, keyedByDir) {
|
|
30
|
+
const nameKeyed = new Map();
|
|
31
|
+
for (const [index, { name }] of identities.entries()) {
|
|
32
|
+
if (name != null && !keyedByDir[index])
|
|
33
|
+
nameKeyed.set(name, index);
|
|
34
|
+
}
|
|
35
|
+
const pending = identities.flatMap((_, index) => keyedByDir[index] ? [index] : []);
|
|
36
|
+
for (let index = pending.pop(); index !== undefined; index = pending.pop()) {
|
|
37
|
+
const shadowed = nameKeyed.get(identities[index].dirKey);
|
|
38
|
+
if (shadowed !== undefined && !keyedByDir[shadowed]) {
|
|
39
|
+
keyedByDir[shadowed] = true;
|
|
40
|
+
pending.push(shadowed);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=reportKeys.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/pkg-manifest.commands",
|
|
3
|
-
"version": "1100.1.
|
|
3
|
+
"version": "1100.1.33",
|
|
4
4
|
"description": "Commands for managing package.json",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"!*.map"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@pnpm/cli.utils": "1101.0.
|
|
32
|
-
"@pnpm/config.reader": "1102.3.
|
|
33
|
-
"@pnpm/error": "1100.2.
|
|
34
|
-
"@pnpm/object.property-path": "1100.1.
|
|
31
|
+
"@pnpm/cli.utils": "1101.0.32",
|
|
32
|
+
"@pnpm/config.reader": "1102.3.4",
|
|
33
|
+
"@pnpm/error": "1100.2.2",
|
|
34
|
+
"@pnpm/object.property-path": "1100.1.9",
|
|
35
35
|
"@pnpm/types": "1102.1.1",
|
|
36
36
|
"render-help": "^2.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@jest/globals": "30.4.1",
|
|
40
|
-
"@pnpm/pkg-manifest.commands": "1100.1.
|
|
41
|
-
"@pnpm/prepare": "1100.0.
|
|
40
|
+
"@pnpm/pkg-manifest.commands": "1100.1.33",
|
|
41
|
+
"@pnpm/prepare": "1100.0.36"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=22.13"
|