nx 23.2.0-beta.7 → 23.2.0-beta.8

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.
Files changed (130) hide show
  1. package/dist/bin/init-local.js +3 -5
  2. package/dist/release/changelog-renderer/index.js +4 -5
  3. package/dist/src/adapter/ngcli-adapter.js +60 -1
  4. package/dist/src/command-line/completion/command-object.js +7 -12
  5. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +17 -23
  6. package/dist/src/command-line/generate/generate.js +35 -35
  7. package/dist/src/command-line/import/import.js +18 -40
  8. package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
  9. package/dist/src/command-line/init/command-object.js +4 -2
  10. package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
  11. package/dist/src/command-line/init/implementation/add-nx-to-nest.js +8 -21
  12. package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
  13. package/dist/src/command-line/init/implementation/angular/index.js +6 -15
  14. package/dist/src/command-line/init/init-v1.js +8 -18
  15. package/dist/src/command-line/init/init-v2.js +26 -56
  16. package/dist/src/command-line/migrate/agentic/definitions.js +35 -8
  17. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +22 -3
  18. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +13 -10
  19. package/dist/src/command-line/migrate/agentic/handoff.d.ts +3 -1
  20. package/dist/src/command-line/migrate/agentic/handoff.js +4 -2
  21. package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
  22. package/dist/src/command-line/migrate/agentic/runner.js +24 -24
  23. package/dist/src/command-line/migrate/agentic/select.js +20 -30
  24. package/dist/src/command-line/migrate/agentic/types.d.ts +19 -3
  25. package/dist/src/command-line/migrate/agentic/types.js +13 -4
  26. package/dist/src/command-line/migrate/command-object.d.ts +3 -0
  27. package/dist/src/command-line/migrate/command-object.js +13 -0
  28. package/dist/src/command-line/migrate/execute-migration.d.ts +14 -0
  29. package/dist/src/command-line/migrate/execute-migration.js +30 -9
  30. package/dist/src/command-line/migrate/migrate-analytics.d.ts +28 -0
  31. package/dist/src/command-line/migrate/migrate-analytics.js +51 -1
  32. package/dist/src/command-line/migrate/migrate-commits.d.ts +8 -2
  33. package/dist/src/command-line/migrate/migrate-commits.js +66 -19
  34. package/dist/src/command-line/migrate/migrate-config.d.ts +4 -2
  35. package/dist/src/command-line/migrate/migrate-config.js +12 -4
  36. package/dist/src/command-line/migrate/migrate.d.ts +9 -2
  37. package/dist/src/command-line/migrate/migrate.js +179 -56
  38. package/dist/src/command-line/migrate/multi-major.js +7 -10
  39. package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
  40. package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
  41. package/dist/src/command-line/migrate/run/agent-output.js +65 -0
  42. package/dist/src/command-line/migrate/run/index.d.ts +7 -0
  43. package/dist/src/command-line/migrate/run/index.js +19 -1
  44. package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
  45. package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
  46. package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
  47. package/dist/src/command-line/migrate/run/run-id.js +56 -0
  48. package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
  49. package/dist/src/command-line/migrate/run/run-state.js +438 -0
  50. package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
  51. package/dist/src/command-line/migrate/run/state-lock.js +76 -0
  52. package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
  53. package/dist/src/command-line/migrate/run/state-machine.js +315 -0
  54. package/dist/src/command-line/migrate/run/util.d.ts +58 -0
  55. package/dist/src/command-line/migrate/run/util.js +139 -7
  56. package/dist/src/command-line/migrate/run/worker.d.ts +1 -0
  57. package/dist/src/command-line/migrate/run/worker.js +308 -45
  58. package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
  59. package/dist/src/command-line/migrate/safe-prompt.js +32 -43
  60. package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
  61. package/dist/src/command-line/migrate/step-actions.js +12 -0
  62. package/dist/src/command-line/migrate/text.d.ts +18 -0
  63. package/dist/src/command-line/migrate/text.js +26 -0
  64. package/dist/src/command-line/migrate/version-skew-guard.d.ts +6 -4
  65. package/dist/src/command-line/migrate/version-skew-guard.js +34 -14
  66. package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
  67. package/dist/src/command-line/release/changelog.js +6 -17
  68. package/dist/src/command-line/release/plan.js +15 -28
  69. package/dist/src/command-line/release/release.js +6 -17
  70. package/dist/src/command-line/release/utils/remote-release-clients/github.js +16 -22
  71. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
  72. package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
  73. package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
  74. package/dist/src/core/graph/main.js +1 -1
  75. package/dist/src/devkit-internals.d.ts +2 -0
  76. package/dist/src/devkit-internals.js +12 -4
  77. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
  78. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
  79. package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
  80. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  81. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  82. package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
  83. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +128 -2
  84. package/dist/src/tasks-runner/run-command.js +17 -32
  85. package/dist/src/tasks-runner/task-env.js +5 -2
  86. package/dist/src/tasks-runner/utils.js +2 -6
  87. package/dist/src/utils/analytics-prompt.js +4 -7
  88. package/dist/src/utils/exit-codes.d.ts +9 -0
  89. package/dist/src/utils/exit-codes.js +19 -0
  90. package/dist/src/utils/fileutils.d.ts +5 -0
  91. package/dist/src/utils/fileutils.js +7 -2
  92. package/dist/src/utils/git-utils.d.ts +33 -2
  93. package/dist/src/utils/git-utils.js +156 -8
  94. package/dist/src/utils/long-running-target.d.ts +10 -0
  95. package/dist/src/utils/long-running-target.js +19 -0
  96. package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
  97. package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
  98. package/dist/src/utils/min-release-age/packument.js +1 -1
  99. package/dist/src/utils/nx-console-prompt.js +3 -6
  100. package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
  101. package/dist/src/utils/package-manager-config/bunfig.js +49 -0
  102. package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
  103. package/dist/src/utils/package-manager-config/npmrc.js +124 -0
  104. package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
  105. package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
  106. package/dist/src/utils/package-manager.d.ts +21 -2
  107. package/dist/src/utils/package-manager.js +244 -47
  108. package/dist/src/utils/params.d.ts +7 -1
  109. package/dist/src/utils/params.js +64 -6
  110. package/dist/src/utils/prompt-helpers.d.ts +53 -0
  111. package/dist/src/utils/prompt-helpers.js +111 -0
  112. package/dist/src/utils/provenance.js +6 -14
  113. package/dist/src/utils/registry-config/bun.d.ts +2 -0
  114. package/dist/src/utils/registry-config/bun.js +257 -0
  115. package/dist/src/utils/registry-config/index.d.ts +13 -0
  116. package/dist/src/utils/registry-config/index.js +102 -0
  117. package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
  118. package/dist/src/utils/registry-config/pnpm.js +1551 -0
  119. package/dist/src/utils/registry-config/utils.d.ts +195 -0
  120. package/dist/src/utils/registry-config/utils.js +496 -0
  121. package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
  122. package/dist/src/utils/registry-config/yarn-berry.js +612 -0
  123. package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
  124. package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
  125. package/dist/src/utils/safe-spawn.d.ts +24 -0
  126. package/dist/src/utils/safe-spawn.js +104 -0
  127. package/migrations.json +6 -0
  128. package/package.json +17 -13
  129. package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
  130. package/dist/src/utils/min-release-age/npmrc.js +0 -45
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Target names the pre-23 `longRunningTask` guard excluded from caching. Shared
3
+ * between that guard and the deprecated target-name cache fallback so the two
4
+ * cannot drift apart.
5
+ *
6
+ * The copy in `migrations/update-23-2-0/set-cache-on-executor-target-defaults.ts`
7
+ * deliberately does not use this: a migration's decision has to freeze at the
8
+ * semantics it shipped with.
9
+ */
10
+ export declare function isLongRunningTargetName(targetName: string): boolean;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLongRunningTargetName = isLongRunningTargetName;
4
+ /**
5
+ * Target names the pre-23 `longRunningTask` guard excluded from caching. Shared
6
+ * between that guard and the deprecated target-name cache fallback so the two
7
+ * cannot drift apart.
8
+ *
9
+ * The copy in `migrations/update-23-2-0/set-cache-on-executor-target-defaults.ts`
10
+ * deliberately does not use this: a migration's decision has to freeze at the
11
+ * semantics it shipped with.
12
+ */
13
+ function isLongRunningTargetName(targetName) {
14
+ return (targetName.endsWith(':watch') ||
15
+ targetName.endsWith('-watch') ||
16
+ targetName === 'serve' ||
17
+ targetName === 'dev' ||
18
+ targetName === 'start');
19
+ }
@@ -2,10 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readBunPolicy = readBunPolicy;
4
4
  exports.pickBunVersion = pickBunVersion;
5
- const fs_1 = require("fs");
6
5
  const path_1 = require("path");
7
6
  const semver_1 = require("semver");
8
- const smol_toml_1 = require("smol-toml");
7
+ const bunfig_1 = require("../../package-manager-config/bunfig");
9
8
  const constants_1 = require("../constants");
10
9
  const errors_1 = require("../errors");
11
10
  const pick_1 = require("../pick");
@@ -82,23 +81,20 @@ function readLocalBunInstall(root) {
82
81
  return readBunInstall((0, path_1.join)(root, 'bunfig.toml'));
83
82
  }
84
83
  function readGlobalBunInstall() {
85
- const xdg = process.env.XDG_CONFIG_HOME;
86
- const base = xdg || process.env.HOME;
84
+ const base = (0, bunfig_1.getBunGlobalConfigBase)(process.env);
87
85
  if (!base) {
88
86
  return {};
89
87
  }
90
88
  return readBunInstall((0, path_1.join)(base, '.bunfig.toml'));
91
89
  }
92
90
  function readBunInstall(path) {
93
- if (!(0, fs_1.existsSync)(path)) {
91
+ const parsed = (0, bunfig_1.readBunfigRaw)(path);
92
+ // bun skips a bunfig it cannot read and resolves on, so its settings do not
93
+ // apply. Only a parse failure kills the install.
94
+ if (parsed === null || parsed === 'unreadable') {
94
95
  return {};
95
96
  }
96
- let parsed;
97
- try {
98
- parsed = (0, smol_toml_1.parse)((0, fs_1.readFileSync)(path, 'utf-8'));
99
- }
100
- catch {
101
- // Unparseable bunfig makes bun's install die; treat as a hard error.
97
+ if (parsed === 'invalid') {
102
98
  return 'error';
103
99
  }
104
100
  const install = parsed.install;
@@ -8,7 +8,7 @@ const path_1 = require("path");
8
8
  const semver_1 = require("semver");
9
9
  const constants_1 = require("../constants");
10
10
  const errors_1 = require("../errors");
11
- const npmrc_1 = require("../npmrc");
11
+ const npmrc_1 = require("../../package-manager-config/npmrc");
12
12
  const pick_1 = require("../pick");
13
13
  const RANK_UNKNOWN = 0; // global/builtin/default - not detectable here
14
14
  const RANK_USER = 1;
@@ -116,7 +116,10 @@ function detectSurfaces(root, env) {
116
116
  }
117
117
  function readNpmrcKeys(override, fallback) {
118
118
  const present = { minReleaseAge: false, before: false };
119
- for (const { key } of (0, npmrc_1.readNpmrcEntries)(override ?? fallback) ?? []) {
119
+ // npm silently treats an .npmrc it cannot read as absent, so both non-array
120
+ // states scan nothing.
121
+ const entries = (0, npmrc_1.readNpmrcEntries)(override ?? fallback);
122
+ for (const { key } of Array.isArray(entries) ? entries : []) {
120
123
  if (key === 'min-release-age') {
121
124
  present.minReleaseAge = true;
122
125
  }
@@ -16,7 +16,7 @@ function toArray(value) {
16
16
  * `dist-tags` carries a hyphen.
17
17
  */
18
18
  async function fetchRegistryMetadata(pkg) {
19
- const raw = await (0, package_manager_1.packageRegistryView)(pkg, '', '--json');
19
+ const raw = await (0, package_manager_1.packageRegistryView)(pkg, '', ['--json']);
20
20
  const parsed = JSON.parse(raw);
21
21
  const time = parsed.time ?? null;
22
22
  if (time) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureNxConsoleInstalled = ensureNxConsoleInstalled;
4
- const enquirer_1 = require("enquirer");
4
+ const prompt_helpers_1 = require("./prompt-helpers");
5
5
  const os_1 = require("os");
6
6
  const output_1 = require("./output");
7
7
  const native_1 = require("../native");
@@ -50,13 +50,10 @@ async function promptForNxConsoleInstallation() {
50
50
  '- Explore your workspace visually',
51
51
  ],
52
52
  });
53
- const { shouldInstallNxConsole } = await (0, enquirer_1.prompt)({
54
- type: 'confirm',
55
- name: 'shouldInstallNxConsole',
53
+ return await (0, prompt_helpers_1.confirmationPrompt)({
56
54
  message: 'Install Nx Console? (you can uninstall anytime)',
57
- initial: true,
55
+ onCancel: () => false,
58
56
  });
59
- return shouldInstallNxConsole;
60
57
  }
61
58
  catch (error) {
62
59
  return false;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The directory holding bun's global config files (.bunfig.toml and, for bun's
3
+ * npmrc support, .npmrc): $XDG_CONFIG_HOME when set, else the home dir (bun's
4
+ * getHomeConfigPath). Null when neither is set, where bun reads no global
5
+ * config.
6
+ */
7
+ export declare function getBunGlobalConfigBase(env: NodeJS.ProcessEnv): string | null;
8
+ /**
9
+ * Parses a bunfig.toml: null when absent, 'unreadable' when it cannot be read
10
+ * (bun skips it and resolves on, so most callers collapse the two), 'invalid'
11
+ * when bun's own TOML parser would reject it (bun hard-errors there, so no
12
+ * resolution is left for a caller to reproduce).
13
+ */
14
+ export declare function readBunfigRaw(path: string): Record<string, unknown> | 'unreadable' | 'invalid' | null;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBunGlobalConfigBase = getBunGlobalConfigBase;
4
+ exports.readBunfigRaw = readBunfigRaw;
5
+ const fs_1 = require("fs");
6
+ /**
7
+ * The directory holding bun's global config files (.bunfig.toml and, for bun's
8
+ * npmrc support, .npmrc): $XDG_CONFIG_HOME when set, else the home dir (bun's
9
+ * getHomeConfigPath). Null when neither is set, where bun reads no global
10
+ * config.
11
+ */
12
+ function getBunGlobalConfigBase(env) {
13
+ // bun's getenvZ treats a set-but-empty var as present, so an exported empty
14
+ // XDG_CONFIG_HOME still short-circuits HOME (bun: `XDG_CONFIG_HOME orelse HOME`).
15
+ if (env.XDG_CONFIG_HOME !== undefined) {
16
+ return env.XDG_CONFIG_HOME;
17
+ }
18
+ // Mirrors bun's platform-specific HOME accessor (env_var.zig).
19
+ const home = process.platform === 'win32' ? env.USERPROFILE : env.HOME;
20
+ return home ?? null;
21
+ }
22
+ /**
23
+ * Parses a bunfig.toml: null when absent, 'unreadable' when it cannot be read
24
+ * (bun skips it and resolves on, so most callers collapse the two), 'invalid'
25
+ * when bun's own TOML parser would reject it (bun hard-errors there, so no
26
+ * resolution is left for a caller to reproduce).
27
+ */
28
+ function readBunfigRaw(path) {
29
+ // Outside the try because a parser that will not load is a broken
30
+ // installation, not a corrupt bunfig.
31
+ const { parse } = require('smol-toml');
32
+ let raw;
33
+ try {
34
+ raw = (0, fs_1.readFileSync)(path, 'utf-8');
35
+ }
36
+ catch (error) {
37
+ // ENOTDIR (a path through a non-directory) is another shape of absent, the
38
+ // same way the .npmrc reader classifies it.
39
+ return error?.code === 'ENOENT' || error?.code === 'ENOTDIR'
40
+ ? null
41
+ : 'unreadable';
42
+ }
43
+ try {
44
+ return parse(raw);
45
+ }
46
+ catch {
47
+ return 'invalid';
48
+ }
49
+ }
@@ -0,0 +1,23 @@
1
+ export interface NpmrcEntry {
2
+ key: string;
3
+ value: string;
4
+ /** True when the source used ini's `key[]` array-append syntax. */
5
+ array?: boolean;
6
+ }
7
+ /**
8
+ * Parses an .npmrc file into its `key = value` entries the way npm/yarn/pnpm do
9
+ * (via the `ini` package). Returns null when the file is missing, and
10
+ * 'unreadable' when it exists but cannot be read (permissions, a directory):
11
+ * package managers diverge on that state, so each caller decides whether to
12
+ * skip, warn, or abort rather than having it collapsed into "absent" here.
13
+ */
14
+ export declare function readNpmrcEntries(path: string): NpmrcEntry[] | 'unreadable' | null;
15
+ export declare function parseNpmrcContent(raw: string): NpmrcEntry[];
16
+ /**
17
+ * Reads an .npmrc-format file into a map with ini's semantics for repeated
18
+ * keys: scalars last-write-wins, `key[]` values joined. Null and 'unreadable'
19
+ * pass through from {@link readNpmrcEntries}.
20
+ */
21
+ export declare function readNpmrcMap(path: string): Map<string, string> | 'unreadable' | null;
22
+ /** Those entries under ini's semantics for repeated keys. */
23
+ export declare function npmrcEntriesToMap(entries: NpmrcEntry[]): Map<string, string>;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readNpmrcEntries = readNpmrcEntries;
4
+ exports.parseNpmrcContent = parseNpmrcContent;
5
+ exports.readNpmrcMap = readNpmrcMap;
6
+ exports.npmrcEntriesToMap = npmrcEntriesToMap;
7
+ const fs_1 = require("fs");
8
+ /**
9
+ * Parses an .npmrc file into its `key = value` entries the way npm/yarn/pnpm do
10
+ * (via the `ini` package). Returns null when the file is missing, and
11
+ * 'unreadable' when it exists but cannot be read (permissions, a directory):
12
+ * package managers diverge on that state, so each caller decides whether to
13
+ * skip, warn, or abort rather than having it collapsed into "absent" here.
14
+ */
15
+ function readNpmrcEntries(path) {
16
+ let raw;
17
+ try {
18
+ raw = (0, fs_1.readFileSync)(path, 'utf-8');
19
+ }
20
+ catch (e) {
21
+ // ENOTDIR (a path through a non-directory) is another shape of absent, not an
22
+ // unreadable file.
23
+ return e?.code === 'ENOENT' || e?.code === 'ENOTDIR' ? null : 'unreadable';
24
+ }
25
+ return parseNpmrcContent(raw);
26
+ }
27
+ function parseNpmrcContent(raw) {
28
+ const entries = [];
29
+ // ini breaks lines on any run of CR/LF, so splitting on `\r?\n` here would
30
+ // hide everything after a bare CR that npm still reads.
31
+ for (const line of raw.split(/[\r\n]+/)) {
32
+ const trimmed = line.trim();
33
+ if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith(';')) {
34
+ continue;
35
+ }
36
+ // ini matches the header on the raw line, so an indented one stays a literal
37
+ // bare-flag key. Everything after a header nests under it, out of npm's flat
38
+ // lookup, so stop here.
39
+ if (/^\[[^\]]*\]\s*$/.test(line)) {
40
+ break;
41
+ }
42
+ // ini reads a valueless line as the flag `true`; dropping it would lose a bare
43
+ // `always-auth`/`strict-ssl` and flip the credential/TLS decision built on it.
44
+ const eq = trimmed.indexOf('=');
45
+ const rawKey = iniUnsafe(eq === -1 ? trimmed : trimmed.slice(0, eq));
46
+ const value = eq === -1 ? 'true' : iniUnsafe(trimmed.slice(eq + 1));
47
+ // ini enables bracketedArray by default, so a `key[]` suffix appends under the
48
+ // bare key instead of making a literal `key[]` entry.
49
+ if (rawKey.length > 2 && rawKey.endsWith('[]')) {
50
+ entries.push({ key: rawKey.slice(0, -2), value, array: true });
51
+ }
52
+ else {
53
+ entries.push({ key: rawKey, value });
54
+ }
55
+ }
56
+ return entries;
57
+ }
58
+ /**
59
+ * Reads an .npmrc-format file into a map with ini's semantics for repeated
60
+ * keys: scalars last-write-wins, `key[]` values joined. Null and 'unreadable'
61
+ * pass through from {@link readNpmrcEntries}.
62
+ */
63
+ function readNpmrcMap(path) {
64
+ const entries = readNpmrcEntries(path);
65
+ return Array.isArray(entries) ? npmrcEntriesToMap(entries) : entries;
66
+ }
67
+ /** Those entries under ini's semantics for repeated keys. */
68
+ function npmrcEntriesToMap(entries) {
69
+ const map = new Map();
70
+ for (const { key, value, array } of entries) {
71
+ // ini collects repeated `key[]` values into an array under the bare key, and
72
+ // npm rebuilds a config array from the env by splitting on a blank line, so
73
+ // join them that way.
74
+ const existing = map.get(key);
75
+ map.set(key, array && existing !== undefined ? `${existing}\n\n${value}` : value);
76
+ }
77
+ return map;
78
+ }
79
+ function isQuoted(val) {
80
+ return (val.length >= 2 &&
81
+ ((val.startsWith('"') && val.endsWith('"')) ||
82
+ (val.startsWith("'") && val.endsWith("'"))));
83
+ }
84
+ /**
85
+ * Mirrors the `ini` package's `unsafe()`, except that ini JSON-decodes a
86
+ * single-quoted value's contents and we keep them verbatim; that only differs
87
+ * when the contents are valid JSON, never true for a registry, token, or path.
88
+ * See https://github.com/isaacs/ini/blob/a0c72fe9e335a3f949d734fb5ef13371a850bbe3/lib/ini.js#L230
89
+ */
90
+ function iniUnsafe(raw) {
91
+ const val = raw.trim();
92
+ if (isQuoted(val)) {
93
+ if (val.startsWith("'")) {
94
+ return val.slice(1, -1);
95
+ }
96
+ try {
97
+ return JSON.parse(val);
98
+ }
99
+ catch {
100
+ return val;
101
+ }
102
+ }
103
+ let esc = false;
104
+ let unesc = '';
105
+ for (const c of val) {
106
+ if (esc) {
107
+ unesc += '\\;#'.includes(c) ? c : `\\${c}`;
108
+ esc = false;
109
+ }
110
+ else if (c === ';' || c === '#') {
111
+ break;
112
+ }
113
+ else if (c === '\\') {
114
+ esc = true;
115
+ }
116
+ else {
117
+ unesc += c;
118
+ }
119
+ }
120
+ if (esc) {
121
+ unesc += '\\';
122
+ }
123
+ return unesc.trim();
124
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Mirrors pnpm's getConfigDir. Hosts pnpm's global config.yaml and (v11+)
3
+ * auth.ini.
4
+ * See https://github.com/pnpm/pnpm/blob/b7195db5c8469c80908d625c648302b26c2f9977/config/reader/src/dirs.ts#L73-L92
5
+ */
6
+ export declare function getPnpmConfigDir(env: NodeJS.ProcessEnv): string;
7
+ /**
8
+ * Reads a pnpm YAML config file (pnpm-workspace.yaml or the global
9
+ * config.yaml). An absent file returns null so callers can fall through to
10
+ * lower surfaces; everything else returns 'unusable', which every caller turns
11
+ * into a throw. pnpm's own reader tolerates ENOENT alone and rethrows the rest,
12
+ * and it dies the same way on a document it cannot parse or that is not a
13
+ * mapping, so the two failures need no separate states. Requiring an object
14
+ * also keeps the sentinel out of the success domain: a returned string can only
15
+ * ever mean unusable.
16
+ */
17
+ export declare function readPnpmYamlConfig(path: string): Record<string, unknown> | 'unusable' | null;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPnpmConfigDir = getPnpmConfigDir;
4
+ exports.readPnpmYamlConfig = readPnpmYamlConfig;
5
+ const os_1 = require("os");
6
+ const path_1 = require("path");
7
+ const fileutils_1 = require("../fileutils");
8
+ /**
9
+ * Mirrors pnpm's getConfigDir. Hosts pnpm's global config.yaml and (v11+)
10
+ * auth.ini.
11
+ * See https://github.com/pnpm/pnpm/blob/b7195db5c8469c80908d625c648302b26c2f9977/config/reader/src/dirs.ts#L73-L92
12
+ */
13
+ function getPnpmConfigDir(env) {
14
+ if (env.XDG_CONFIG_HOME) {
15
+ return (0, path_1.join)(env.XDG_CONFIG_HOME, 'pnpm');
16
+ }
17
+ if (process.platform === 'darwin') {
18
+ return (0, path_1.join)((0, os_1.homedir)(), 'Library/Preferences/pnpm');
19
+ }
20
+ if (process.platform !== 'win32') {
21
+ return (0, path_1.join)((0, os_1.homedir)(), '.config/pnpm');
22
+ }
23
+ if (env.LOCALAPPDATA) {
24
+ return (0, path_1.join)(env.LOCALAPPDATA, 'pnpm/config');
25
+ }
26
+ return (0, path_1.join)((0, os_1.homedir)(), '.config/pnpm');
27
+ }
28
+ /**
29
+ * Reads a pnpm YAML config file (pnpm-workspace.yaml or the global
30
+ * config.yaml). An absent file returns null so callers can fall through to
31
+ * lower surfaces; everything else returns 'unusable', which every caller turns
32
+ * into a throw. pnpm's own reader tolerates ENOENT alone and rethrows the rest,
33
+ * and it dies the same way on a document it cannot parse or that is not a
34
+ * mapping, so the two failures need no separate states. Requiring an object
35
+ * also keeps the sentinel out of the success domain: a returned string can only
36
+ * ever mean unusable.
37
+ */
38
+ function readPnpmYamlConfig(path) {
39
+ let doc;
40
+ try {
41
+ doc = (0, fileutils_1.readYamlFile)(path);
42
+ }
43
+ catch (e) {
44
+ // Only ENOENT resolves on, so a path through a non-directory or a file that
45
+ // will not open is fatal here. Callers whose pnpm counterpart looks the file
46
+ // up before reading it widen "absent" themselves.
47
+ if (e?.code === 'ENOENT') {
48
+ return null;
49
+ }
50
+ return 'unusable';
51
+ }
52
+ // An empty file declares nothing; pnpm accepts it.
53
+ if (doc === null || doc === undefined) {
54
+ return {};
55
+ }
56
+ if (typeof doc !== 'object' || Array.isArray(doc)) {
57
+ return 'unusable';
58
+ }
59
+ return doc;
60
+ }
@@ -118,14 +118,33 @@ export declare function resolvePackageVersionUsingRegistry(packageName: string,
118
118
  * package.json.
119
119
  */
120
120
  export declare function resolvePackageVersionUsingInstallation(packageName: string, version: string): Promise<string>;
121
- export declare function packageRegistryView(pkg: string, version: string, args: string, options?: {
121
+ /**
122
+ * The registry the fetch for `pkg` went to, with its userinfo masked because a
123
+ * registry URL can carry a bare token. The lookup is spawned the way
124
+ * `packageRegistryView` spawns the fetch this describes (same manager, same
125
+ * environment), so a registry the package manager keeps outside the .npmrc
126
+ * chain and a scope resolved for itself both land on the value that fetch used.
127
+ * Null where the manager yields no usable registry URL; throws where it cannot be run.
128
+ */
129
+ export declare function getWorkspaceRegistryUrlForDisplay(pkg: string): string | null;
130
+ export declare function packageRegistryView(pkg: string, version: string, args: string[], options?: {
122
131
  forceNpm?: boolean;
123
132
  }): Promise<string>;
124
- export declare function packageRegistryPack(cwd: string, pkg: string, version: string, options?: {
133
+ /**
134
+ * Only `npm pack` supports downloading a tarball of a specified remote
135
+ * package. `yarn` packs the active workspace, `pnpm pack` only packs
136
+ * the local project, and `bun` doesn't support pack.
137
+ *
138
+ * @param packDestination Directory passed to npm's `--pack-destination`, where
139
+ * the `.tgz` is written.
140
+ * @see https://github.com/nrwl/nx/pull/9667#discussion_r842553994
141
+ */
142
+ export declare function packageRegistryPack(packDestination: string, pkg: string, version: string, options?: {
125
143
  bypassMinReleaseAge?: boolean;
126
144
  }): Promise<{
127
145
  tarballPath: string;
128
146
  }>;
147
+ export declare function clearPackageManagerVersionCache(): void;
129
148
  /**
130
149
  * Gets the workspaces defined in the package manager configuration.
131
150
  * @returns workspaces defined in the package manager configuration, empty array if none are defined