@pnpm/global.packages 1100.0.10 → 1100.0.12

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 ADDED
@@ -0,0 +1,166 @@
1
+ # @pnpm/global.packages
2
+
3
+ ## 1100.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/bins.resolver@1100.0.10
9
+ - @pnpm/pkg-manifest.reader@1100.0.11
10
+ - @pnpm/types@1101.5.0
11
+
12
+ ## 1100.0.11
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies:
17
+ - @pnpm/bins.resolver@1100.0.9
18
+ - @pnpm/pkg-manifest.reader@1100.0.10
19
+ - @pnpm/types@1101.4.0
20
+
21
+ ## 1100.0.10
22
+
23
+ ### Patch Changes
24
+
25
+ - be6505a: Hardened global package management:
26
+
27
+ - On Windows, removing or updating a global package now also cleans up the `node.exe` flavor of a bin, so a stale `node.exe` no longer survives on `PATH` after uninstall, and a new global install no longer silently overwrites an existing `node.exe`.
28
+ - `pnpm add -g pnpm@<version>` (and `@pnpm/exe@<version>`) is now rejected like the bare `pnpm` form, pointing to `pnpm self-update`.
29
+ - Dependency aliases read from a global package's manifest are validated before being joined onto `node_modules` paths, preventing a tampered manifest from escaping the install directory.
30
+ - Each global install group is created in its own freshly-made directory (no longer reusing a colliding or pre-existing path).
31
+ - Removing or updating a global package no longer unlinks a bin that belongs to a different globally installed package.
32
+ - @pnpm/crypto.hash@1100.0.1
33
+
34
+ ## 1100.0.9
35
+
36
+ ### Patch Changes
37
+
38
+ - @pnpm/pkg-manifest.reader@1100.0.9
39
+ - @pnpm/crypto.hash@1100.0.1
40
+
41
+ ## 1100.0.8
42
+
43
+ ### Patch Changes
44
+
45
+ - a31faa7: Updated dependency ranges. Notably:
46
+
47
+ - `@pnpm/logger` peer dependency range moved to `^1100.0.0`.
48
+ - `msgpackr` 1.11.8 → 2.0.4 (store index files remain byte-compatible in both directions).
49
+ - `open` ^7.4.2 → ^11.0.0, `memoize` ^10 → ^11, `cli-truncate` ^5 → ^6, `pidtree` ^0.6 → ^1.
50
+ - `@yarnpkg/core` 4.5.0 → 4.8.0, `@rushstack/worker-pool` 0.7.7 → 0.7.18, `@cyclonedx/cyclonedx-library` 10.0.0 → 10.1.0, `@pnpm/config.nerf-dart` ^1 → ^2, `@pnpm/log.group` 3.0.2 → 4.0.1, `@pnpm/util.lex-comparator` ^3 → ^4.
51
+
52
+ - Updated dependencies [681b593]
53
+ - @pnpm/types@1101.3.2
54
+ - @pnpm/bins.resolver@1100.0.8
55
+ - @pnpm/pkg-manifest.reader@1100.0.8
56
+ - @pnpm/crypto.hash@1100.0.1
57
+
58
+ ## 1100.0.7
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [230df57]
63
+ - Updated dependencies [bf1b731]
64
+ - @pnpm/bins.resolver@1100.0.7
65
+ - @pnpm/types@1101.3.1
66
+ - @pnpm/pkg-manifest.reader@1100.0.7
67
+ - @pnpm/crypto.hash@1100.0.1
68
+
69
+ ## 1100.0.6
70
+
71
+ ### Patch Changes
72
+
73
+ - Updated dependencies [a017bf3]
74
+ - @pnpm/types@1101.3.0
75
+ - @pnpm/bins.resolver@1100.0.6
76
+ - @pnpm/pkg-manifest.reader@1100.0.6
77
+ - @pnpm/crypto.hash@1100.0.1
78
+
79
+ ## 1100.0.5
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [35d2355]
84
+ - @pnpm/types@1101.2.0
85
+ - @pnpm/bins.resolver@1100.0.5
86
+ - @pnpm/pkg-manifest.reader@1100.0.5
87
+ - @pnpm/crypto.hash@1100.0.1
88
+
89
+ ## 1100.0.4
90
+
91
+ ### Patch Changes
92
+
93
+ - Updated dependencies [64afc92]
94
+ - @pnpm/types@1101.1.1
95
+ - @pnpm/bins.resolver@1100.0.4
96
+ - @pnpm/pkg-manifest.reader@1100.0.4
97
+ - @pnpm/crypto.hash@1100.0.1
98
+
99
+ ## 1100.0.3
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies [b61e268]
104
+ - @pnpm/types@1101.1.0
105
+ - @pnpm/bins.resolver@1100.0.3
106
+ - @pnpm/pkg-manifest.reader@1100.0.3
107
+ - @pnpm/crypto.hash@1100.0.1
108
+
109
+ ## 1100.0.2
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies [184ce26]
114
+ - @pnpm/pkg-manifest.reader@1100.0.2
115
+ - @pnpm/bins.resolver@1100.0.2
116
+ - @pnpm/crypto.hash@1100.0.1
117
+
118
+ ## 1100.0.1
119
+
120
+ ### Patch Changes
121
+
122
+ - Updated dependencies [ff28085]
123
+ - @pnpm/types@1101.0.0
124
+ - @pnpm/bins.resolver@1100.0.1
125
+ - @pnpm/pkg-manifest.reader@1100.0.1
126
+ - @pnpm/crypto.hash@1100.0.0
127
+
128
+ ## 1000.0.0
129
+
130
+ ### Minor Changes
131
+
132
+ - fd511e4: Isolated global packages. Each globally installed package (or group of packages installed together) now gets its own isolated installation directory with its own `package.json`, `node_modules/`, and lockfile. This prevents global packages from interfering with each other through peer dependency conflicts, hoisting changes, or version resolution shifts.
133
+
134
+ Key changes:
135
+
136
+ - `pnpm add -g <pkg>` creates an isolated installation in `{pnpmHomeDir}/global/v11/{hash}/`
137
+ - `pnpm remove -g <pkg>` removes the entire installation group containing the package
138
+ - `pnpm update -g [pkg]` re-installs packages in new isolated directories
139
+ - `pnpm list -g` scans isolated directories to show all installed global packages
140
+ - `pnpm install -g` (no args) is no longer supported; use `pnpm add -g <pkg>` instead
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies [449dacf]
145
+ - Updated dependencies [76718b3]
146
+ - Updated dependencies [a8f016c]
147
+ - Updated dependencies [cc1b8e3]
148
+ - Updated dependencies [491a84f]
149
+ - Updated dependencies [13855ac]
150
+ - Updated dependencies [d7b8be4]
151
+ - Updated dependencies [7d2fd48]
152
+ - Updated dependencies [efb48dc]
153
+ - Updated dependencies [cb367b9]
154
+ - Updated dependencies [7b1c189]
155
+ - Updated dependencies [8ffb1a7]
156
+ - Updated dependencies [05fb1ae]
157
+ - Updated dependencies [71de2b3]
158
+ - Updated dependencies [10bc391]
159
+ - Updated dependencies [2df8b71]
160
+ - Updated dependencies [15549a9]
161
+ - Updated dependencies [cc7c0d2]
162
+ - Updated dependencies [efb48dc]
163
+ - @pnpm/bins.resolver@1001.0.0
164
+ - @pnpm/types@1001.0.0
165
+ - @pnpm/pkg-manifest.reader@1001.0.0
166
+ - @pnpm/crypto.hash@1001.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/global.packages",
3
- "version": "1100.0.10",
3
+ "version": "1100.0.12",
4
4
  "description": "Utilities for managing isolated global packages",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,14 +28,14 @@
28
28
  "!*.map"
29
29
  ],
30
30
  "dependencies": {
31
- "@pnpm/util.lex-comparator": "^4.0.1",
32
- "@pnpm/bins.resolver": "1100.0.8",
31
+ "@pnpm/bins.resolver": "1100.0.10",
33
32
  "@pnpm/crypto.hash": "1100.0.1",
34
- "@pnpm/pkg-manifest.reader": "1100.0.9",
35
- "@pnpm/types": "1101.3.2"
33
+ "@pnpm/pkg-manifest.reader": "1100.0.11",
34
+ "@pnpm/types": "1101.5.0",
35
+ "@pnpm/util.lex-comparator": "^4.0.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@pnpm/global.packages": "1100.0.10"
38
+ "@pnpm/global.packages": "1100.0.12"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=22.13"
package/lib/cacheKey.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare function createGlobalCacheKey(opts: {
2
- aliases: string[];
3
- registries: Record<string, string>;
4
- }): string;
package/lib/cacheKey.js DELETED
@@ -1,9 +0,0 @@
1
- import { createHexHash } from '@pnpm/crypto.hash';
2
- import { lexCompare } from '@pnpm/util.lex-comparator';
3
- export function createGlobalCacheKey(opts) {
4
- const sortedAliases = [...opts.aliases].sort(lexCompare);
5
- const sortedRegistries = Object.entries(opts.registries).sort(([k1], [k2]) => lexCompare(k1, k2));
6
- const hashStr = JSON.stringify([sortedAliases, sortedRegistries]);
7
- return createHexHash(hashStr);
8
- }
9
- //# sourceMappingURL=cacheKey.js.map
@@ -1,3 +0,0 @@
1
- export declare function getHashLink(globalDir: string, hash: string): string;
2
- export declare function resolveInstallDir(globalDir: string, hash: string): string | null;
3
- export declare function createInstallDir(globalDir: string): string;
@@ -1,44 +0,0 @@
1
- import crypto from 'node:crypto';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import util from 'node:util';
5
- export function getHashLink(globalDir, hash) {
6
- return path.join(globalDir, hash);
7
- }
8
- export function resolveInstallDir(globalDir, hash) {
9
- const linkPath = getHashLink(globalDir, hash);
10
- try {
11
- const stats = fs.lstatSync(linkPath);
12
- if (!stats.isSymbolicLink())
13
- return null;
14
- return fs.realpathSync(linkPath);
15
- }
16
- catch (err) {
17
- if (util.types.isNativeError(err) && 'code' in err && err.code === 'ENOENT') {
18
- return null;
19
- }
20
- throw err;
21
- }
22
- }
23
- export function createInstallDir(globalDir) {
24
- // Ensure the parent exists, then create the per-group dir *exclusively*
25
- // (no `recursive`, which would silently reuse an existing entry or follow
26
- // a pre-existing symlink). The name adds random bytes on top of pid+time
27
- // so it isn't predictable and can't collide within the same millisecond.
28
- fs.mkdirSync(globalDir, { recursive: true });
29
- for (let i = 0; i < 10; i++) {
30
- const name = `${process.pid.toString(16)}-${Date.now().toString(16)}-${crypto.randomBytes(8).toString('hex')}`;
31
- const dir = path.join(globalDir, name);
32
- try {
33
- fs.mkdirSync(dir);
34
- return dir;
35
- }
36
- catch (err) {
37
- if (util.types.isNativeError(err) && 'code' in err && err.code === 'EEXIST')
38
- continue;
39
- throw err;
40
- }
41
- }
42
- throw new Error('Could not create a unique global install directory');
43
- }
44
- //# sourceMappingURL=globalPackageDir.js.map
package/lib/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { createGlobalCacheKey } from './cacheKey.js';
2
- export { createInstallDir, getHashLink, resolveInstallDir, } from './globalPackageDir.js';
3
- export { cleanOrphanedInstallDirs, findGlobalPackage, getGlobalPackageDetails, getInstalledBinNames, type GlobalPackageInfo, type InstalledGlobalPackage, isValidGlobalDependencyAlias, scanGlobalPackages, } from './scanGlobalPackages.js';
@@ -1,17 +0,0 @@
1
- import type { PackageManifest } from '@pnpm/types';
2
- export declare function isValidGlobalDependencyAlias(alias: string): boolean;
3
- export interface GlobalPackageInfo {
4
- hash: string;
5
- installDir: string;
6
- dependencies: Record<string, string>;
7
- }
8
- export interface InstalledGlobalPackage {
9
- alias: string;
10
- version: string;
11
- manifest: PackageManifest;
12
- }
13
- export declare function scanGlobalPackages(globalDir: string): GlobalPackageInfo[];
14
- export declare function findGlobalPackage(globalDir: string, alias: string): GlobalPackageInfo | null;
15
- export declare function getGlobalPackageDetails(info: GlobalPackageInfo): Promise<InstalledGlobalPackage[]>;
16
- export declare function cleanOrphanedInstallDirs(globalDir: string): void;
17
- export declare function getInstalledBinNames(info: GlobalPackageInfo): Promise<string[]>;
@@ -1,158 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import util from 'node:util';
4
- import { getBinsFromPackageManifest } from '@pnpm/bins.resolver';
5
- import { readPackageJsonFromDirRawSync, safeReadPackageJsonFromDir } from '@pnpm/pkg-manifest.reader';
6
- const RESERVED_ALIASES = new Set(['node_modules', 'favicon.ico']);
7
- const isUrlFriendly = (segment) => encodeURIComponent(segment) === segment;
8
- // A dependency alias from a global group's package.json becomes a directory
9
- // name under `node_modules` at every join site (list, conflict-check,
10
- // remove, update). A tampered manifest could use an alias like `../x` or an
11
- // absolute path to escape the install dir, so only valid npm package names
12
- // are trusted. This applies the same `validForOldPackages` rules that
13
- // `validate-npm-package-name` (and `@pnpm/fs.symlink-dependency`'s
14
- // `safeJoinModulesDir`) enforce — implemented inline to avoid adding a
15
- // dependency to this low-level package.
16
- export function isValidGlobalDependencyAlias(alias) {
17
- if (alias.length === 0)
18
- return false;
19
- if (/^[._-]/.test(alias))
20
- return false;
21
- if (alias.trim() !== alias)
22
- return false;
23
- if (RESERVED_ALIASES.has(alias.toLowerCase()))
24
- return false;
25
- if (isUrlFriendly(alias))
26
- return true;
27
- const scoped = /^@([^/]+)\/([^/]+)$/.exec(alias);
28
- if (scoped) {
29
- const [, scope, name] = scoped;
30
- return !name.startsWith('.') && isUrlFriendly(scope) && isUrlFriendly(name);
31
- }
32
- return false;
33
- }
34
- function pickValidDependencies(dependencies) {
35
- const result = {};
36
- for (const [alias, spec] of Object.entries(dependencies)) {
37
- if (isValidGlobalDependencyAlias(alias)) {
38
- result[alias] = spec;
39
- }
40
- }
41
- return result;
42
- }
43
- export function scanGlobalPackages(globalDir) {
44
- let entries;
45
- try {
46
- entries = fs.readdirSync(globalDir, { withFileTypes: true });
47
- }
48
- catch (err) {
49
- if (util.types.isNativeError(err) && 'code' in err && err.code === 'ENOENT') {
50
- return [];
51
- }
52
- throw err;
53
- }
54
- const result = [];
55
- for (const entry of entries) {
56
- // Hash entries are symlinks pointing to install dirs
57
- if (!entry.isSymbolicLink())
58
- continue;
59
- const linkPath = path.join(globalDir, entry.name);
60
- let installDir;
61
- try {
62
- installDir = fs.realpathSync(linkPath);
63
- }
64
- catch {
65
- continue;
66
- }
67
- let pkgJson;
68
- try {
69
- pkgJson = readPackageJsonFromDirRawSync(installDir);
70
- }
71
- catch {
72
- continue;
73
- }
74
- if (!pkgJson.dependencies)
75
- continue;
76
- const dependencies = pickValidDependencies(pkgJson.dependencies);
77
- if (Object.keys(dependencies).length === 0)
78
- continue;
79
- result.push({
80
- hash: entry.name,
81
- installDir,
82
- dependencies,
83
- });
84
- }
85
- return result;
86
- }
87
- export function findGlobalPackage(globalDir, alias) {
88
- const packages = scanGlobalPackages(globalDir);
89
- return packages.find((pkg) => alias in pkg.dependencies) ?? null;
90
- }
91
- export async function getGlobalPackageDetails(info) {
92
- const aliases = Object.keys(info.dependencies);
93
- const installedPackages = await Promise.all(aliases.map(async (alias) => {
94
- const manifest = await safeReadPackageJsonFromDir(path.join(info.installDir, 'node_modules', alias));
95
- if (!manifest)
96
- return null;
97
- return { alias, version: manifest.version, manifest };
98
- }));
99
- return installedPackages.filter((pkg) => pkg !== null);
100
- }
101
- export function cleanOrphanedInstallDirs(globalDir) {
102
- globalDir = path.resolve(globalDir);
103
- let entries;
104
- try {
105
- entries = fs.readdirSync(globalDir, { withFileTypes: true });
106
- }
107
- catch {
108
- return;
109
- }
110
- // Collect real paths of all symlink targets
111
- const referenced = new Set();
112
- for (const entry of entries) {
113
- if (!entry.isSymbolicLink())
114
- continue;
115
- try {
116
- referenced.add(fs.realpathSync(path.join(globalDir, entry.name)));
117
- }
118
- catch { }
119
- }
120
- // Remove directories that no symlink points to.
121
- // Skip recently-created dirs to avoid racing with a concurrent install
122
- // that hasn't created its hash symlink yet.
123
- const now = Date.now();
124
- const SAFETY_WINDOW_MS = 5 * 60 * 1000;
125
- for (const entry of entries) {
126
- if (!entry.isDirectory())
127
- continue;
128
- const dirPath = path.join(globalDir, entry.name);
129
- if (referenced.has(dirPath))
130
- continue;
131
- try {
132
- const stat = fs.statSync(dirPath);
133
- if (now - Math.max(stat.birthtimeMs, stat.ctimeMs) < SAFETY_WINDOW_MS)
134
- continue;
135
- }
136
- catch {
137
- continue;
138
- }
139
- fs.rmSync(dirPath, { recursive: true, force: true });
140
- }
141
- }
142
- export async function getInstalledBinNames(info) {
143
- const bins = new Set();
144
- const aliases = Object.keys(info.dependencies);
145
- const modulesDir = path.join(info.installDir, 'node_modules');
146
- await Promise.all(aliases.map(async (alias) => {
147
- const depDir = path.join(modulesDir, alias);
148
- const manifest = await safeReadPackageJsonFromDir(depDir);
149
- if (!manifest)
150
- return;
151
- const binsOfPkg = await getBinsFromPackageManifest(manifest, depDir);
152
- for (const bin of binsOfPkg) {
153
- bins.add(bin.name);
154
- }
155
- }));
156
- return [...bins];
157
- }
158
- //# sourceMappingURL=scanGlobalPackages.js.map