@pnpm/installing.deps-resolver 1100.0.2 → 1100.0.3

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/lib/index.js CHANGED
@@ -323,7 +323,7 @@ function extendGraph(graph, opts) {
323
323
  const pkgMetaIter = iterateGraphPkgMetaEntries(graph, !opts.enableGlobalVirtualStore);
324
324
  // Only use allowBuild for engine-agnostic hash optimization when GVS is on
325
325
  const allowBuild = opts.enableGlobalVirtualStore ? opts.allowBuild : undefined;
326
- for (const { pkgMeta: { depPath }, hash } of iterateHashedGraphNodes(graph, pkgMetaIter, allowBuild)) {
326
+ for (const { pkgMeta: { depPath }, hash } of iterateHashedGraphNodes(graph, pkgMetaIter, allowBuild, opts.supportedArchitectures)) {
327
327
  const modules = path.join(opts.globalVirtualStoreDir, hash, 'node_modules');
328
328
  const node = graph[depPath];
329
329
  Object.assign(node, {
@@ -0,0 +1 @@
1
+ export declare function linkPathToPeerVersion(relPath: string): string;
@@ -0,0 +1,54 @@
1
+ // Converts a link: path into a stable, filename-safe token used as the
2
+ // peer's "version" inside peer-suffix hashes. The output must stay stable
3
+ // across pnpm versions so that lockfiles don't churn; it replicates what
4
+ // filenamify v4 produced for these paths in pnpm <= 10.
5
+ //
6
+ // Note: this encoding is lossy and can collide. Any leading run of `.`
7
+ // characters is dropped, and `/`, `\`, and literal `+` all collapse into
8
+ // a single `+`. For example, `packages/b`, `./packages/b`, and
9
+ // `../packages/b` all produce `packages+b`, and `.hidden/pkg` produces
10
+ // `hidden+pkg`. The only way to make this collision-free is to hash the
11
+ // normalized link target (or switch to a lossless escape encoding),
12
+ // either of which would change every link-path peer suffix in existing
13
+ // lockfiles. We accept the (extremely rare in practice) collision for
14
+ // lockfile stability; see https://github.com/pnpm/pnpm/issues/11272.
15
+ export function linkPathToPeerVersion(relPath) {
16
+ // Drop leading dots: v4 replaced `^\.+` with '+' and then stripOuter removed it.
17
+ let i = 0;
18
+ while (i < relPath.length && relPath[i] === '.')
19
+ i++;
20
+ let out = '';
21
+ let lastWasPlus = true; // pretend we just emitted '+' so leading '+' chars are suppressed
22
+ for (; i < relPath.length; i++) {
23
+ const c = relPath.charCodeAt(i);
24
+ // Reserved filename chars, C0 controls, and literal '+' all collapse into a single '+'.
25
+ const replace = c < 32 ||
26
+ c === 34 /* " */ || c === 42 /* * */ || c === 43 /* + */ ||
27
+ c === 47 /* / */ || c === 58 /* : */ || c === 60 /* < */ ||
28
+ c === 62 /* > */ || c === 63 /* ? */ || c === 92 /* \ */ ||
29
+ c === 124; /* | */
30
+ if (replace) {
31
+ if (!lastWasPlus) {
32
+ out += '+';
33
+ lastWasPlus = true;
34
+ }
35
+ }
36
+ else {
37
+ out += relPath[i];
38
+ lastWasPlus = false;
39
+ }
40
+ }
41
+ // Trim trailing '+' and '.' (v4 stripped trailing periods and outer replacement).
42
+ let end = out.length;
43
+ while (end > 0) {
44
+ const ch = out.charCodeAt(end - 1);
45
+ if (ch !== 43 /* + */ && ch !== 46 /* . */)
46
+ break;
47
+ end--;
48
+ }
49
+ if (end > 0)
50
+ return out.slice(0, end);
51
+ // Empty result with something consumed collapses to a single '+'.
52
+ return relPath.length === 0 ? '' : '+';
53
+ }
54
+ //# sourceMappingURL=linkPathToPeerVersion.js.map
@@ -1,12 +1,12 @@
1
1
  import path from 'node:path';
2
2
  import { createPeerDepGraphHash, depPathToFilename } from '@pnpm/deps.path';
3
3
  import * as semverUtils from '@yarnpkg/core/semverUtils';
4
- import filenamify from 'filenamify';
5
4
  import { analyzeGraph } from 'graph-cycles';
6
5
  import pDefer, {} from 'p-defer';
7
6
  import { partition, pick } from 'ramda';
8
7
  import semver from 'semver';
9
8
  import { dedupeInjectedDeps } from './dedupeInjectedDeps.js';
9
+ import { linkPathToPeerVersion } from './linkPathToPeerVersion.js';
10
10
  import { mergePeers } from './mergePeers.js';
11
11
  export async function resolvePeers(opts) {
12
12
  const depGraph = {};
@@ -672,7 +672,7 @@ function peerNodeIdToPeerId(alias, peerNodeId, ctx) {
672
672
  if (typeof peerNodeId === 'string' && peerNodeId.startsWith('link:')) {
673
673
  return {
674
674
  name: alias,
675
- version: filenamify(peerNodeId.slice(5), { replacement: '+' }),
675
+ version: linkPathToPeerVersion(peerNodeId.slice(5)),
676
676
  };
677
677
  }
678
678
  if (ctx.dedupePeers) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/installing.deps-resolver",
3
- "version": "1100.0.2",
3
+ "version": "1100.0.3",
4
4
  "description": "Resolves dependency graph of a package",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -26,7 +26,6 @@
26
26
  "dependencies": {
27
27
  "@pnpm/util.lex-comparator": "^3.0.2",
28
28
  "@yarnpkg/core": "4.5.0",
29
- "filenamify": "^7.0.1",
30
29
  "graph-cycles": "3.0.0",
31
30
  "is-inner-link": "^5.0.0",
32
31
  "is-subdir": "^2.0.0",
@@ -41,27 +40,27 @@
41
40
  "semver-range-intersect": "^0.3.1",
42
41
  "version-selector-type": "^3.0.0",
43
42
  "@pnpm/catalogs.resolver": "1100.0.0",
44
- "@pnpm/constants": "1100.0.0",
45
- "@pnpm/catalogs.types": "1100.0.0",
46
- "@pnpm/core-loggers": "1100.0.1",
47
- "@pnpm/deps.graph-hasher": "1100.0.1",
48
43
  "@pnpm/config.version-policy": "1100.0.1",
44
+ "@pnpm/catalogs.types": "1100.0.0",
45
+ "@pnpm/constants": "1100.0.0",
49
46
  "@pnpm/deps.path": "1100.0.1",
50
- "@pnpm/error": "1100.0.0",
51
- "@pnpm/fetching.pick-fetcher": "1100.0.1",
47
+ "@pnpm/deps.graph-hasher": "1100.1.0",
52
48
  "@pnpm/deps.peer-range": "1100.0.0",
53
- "@pnpm/lockfile.preferred-versions": "1100.0.2",
54
- "@pnpm/lockfile.pruner": "1100.0.1",
55
- "@pnpm/lockfile.types": "1100.0.1",
56
- "@pnpm/hooks.types": "1100.0.1",
49
+ "@pnpm/core-loggers": "1100.0.1",
50
+ "@pnpm/fetching.pick-fetcher": "1100.0.2",
51
+ "@pnpm/hooks.types": "1100.0.2",
52
+ "@pnpm/lockfile.preferred-versions": "1100.0.3",
53
+ "@pnpm/lockfile.pruner": "1100.0.2",
54
+ "@pnpm/lockfile.types": "1100.0.2",
57
55
  "@pnpm/patching.config": "1100.0.1",
58
56
  "@pnpm/patching.types": "1100.0.0",
59
- "@pnpm/lockfile.utils": "1100.0.1",
60
57
  "@pnpm/pkg-manifest.reader": "1100.0.1",
61
58
  "@pnpm/pkg-manifest.utils": "1100.1.0",
62
- "@pnpm/resolving.npm-resolver": "1100.0.1",
63
- "@pnpm/resolving.resolver-base": "1100.0.1",
64
- "@pnpm/store.controller-types": "1100.0.1",
59
+ "@pnpm/lockfile.utils": "1100.0.2",
60
+ "@pnpm/error": "1100.0.0",
61
+ "@pnpm/resolving.npm-resolver": "1100.1.0",
62
+ "@pnpm/resolving.resolver-base": "1100.1.0",
63
+ "@pnpm/store.controller-types": "1100.0.2",
65
64
  "@pnpm/types": "1101.0.0",
66
65
  "@pnpm/workspace.spec-parser": "1100.0.0"
67
66
  },
@@ -72,7 +71,7 @@
72
71
  "@types/normalize-path": "^3.0.2",
73
72
  "@types/ramda": "0.31.1",
74
73
  "@types/semver": "7.7.1",
75
- "@pnpm/installing.deps-resolver": "1100.0.2",
74
+ "@pnpm/installing.deps-resolver": "1100.0.3",
76
75
  "@pnpm/logger": "1100.0.0"
77
76
  },
78
77
  "engines": {