@nx/devkit 23.1.0 → 23.2.0-canary.20260717-dc22f7e

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.
@@ -1,4 +1,4 @@
1
- export { signalToCode, createProjectRootMappingsFromProjectConfigurations, PluginCache, safeWriteFileCache, emitPluginWorkerLog, resolveImplementation, resolveSchema, ImplementationResolutionError, SchemaResolutionError, resolvePrompt, PromptResolutionError, } from 'nx/src/devkit-internals';
1
+ export { signalToCode, createProjectRootMappingsFromProjectConfigurations, PluginCache, safeWriteFileCache, emitPluginWorkerLog, resolveImplementation, resolveSchema, ImplementationResolutionError, SchemaResolutionError, resolvePrompt, PromptResolutionError, acknowledgeBuildScripts, } from 'nx/src/devkit-internals';
2
2
  export { determineArtifactNameAndDirectoryOptions, getRelativeCwd, type FileExtensionType, } from './src/generators/artifact-name-and-directory-utils';
3
3
  export { getE2EWebServerInfo, type E2EWebServerDetails, } from './src/generators/e2e-web-server-info-utils';
4
4
  export { forEachExecutorOptions } from './src/generators/executor-options-utils';
@@ -13,7 +13,7 @@ export { getDeclaredPackageVersion, getInstalledPackageVersion, } from './src/ut
13
13
  export { assertSupportedInstalledPackageVersion, assertSupportedPackageVersion, } from './src/utils/version-floor';
14
14
  export { createAsyncIterable, combineAsyncIterables, mapAsyncIterable, } from './src/utils/async-iterable';
15
15
  export { calculateHashForCreateNodes, calculateHashesForCreateNodes, } from './src/utils/calculate-hash-for-create-nodes';
16
- export { getCatalogManager } from './src/utils/catalog';
16
+ export { getCatalogManager } from 'nx/src/utils/catalog';
17
17
  export { loadConfigFile, clearRequireCache } from './src/utils/config-utils';
18
18
  export { findPluginForConfigFile } from './src/utils/find-plugin-for-config-file';
19
19
  export { getNamedInputs } from './src/utils/get-named-inputs';
package/dist/internal.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkAndCleanWithSemver = exports.eachValueFrom = exports.logShowProjectCommand = exports.getNamedInputs = exports.findPluginForConfigFile = exports.clearRequireCache = exports.loadConfigFile = exports.getCatalogManager = exports.calculateHashesForCreateNodes = exports.calculateHashForCreateNodes = exports.mapAsyncIterable = exports.combineAsyncIterables = exports.createAsyncIterable = exports.assertSupportedPackageVersion = exports.assertSupportedInstalledPackageVersion = exports.getInstalledPackageVersion = exports.getDeclaredPackageVersion = exports.addPlugin = exports.upsertTargetDefault = exports.updateTargetDefault = exports.readTargetDefaultsForTarget = exports.findTargetDefault = exports.addE2eCiTargetDefaults = exports.addBuildTargetDefaults = exports.promptWhenInteractive = exports.resolveImportPath = exports.ensureRootProjectName = exports.determineProjectNameAndRootOptions = exports.toProjectRelativePath = exports.deleteMatchingProperties = exports.processTargetOutputs = exports.NoTargetsToMigrateError = exports.migrateProjectExecutorsToPluginV1 = exports.migrateProjectExecutorsToPlugin = exports.AggregatedLog = exports.forEachExecutorOptions = exports.getE2EWebServerInfo = exports.getRelativeCwd = exports.determineArtifactNameAndDirectoryOptions = exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.createProjectRootMappingsFromProjectConfigurations = exports.signalToCode = void 0;
4
- exports.dasherize = exports.classify = exports.capitalize = exports.camelize = void 0;
3
+ exports.eachValueFrom = exports.logShowProjectCommand = exports.getNamedInputs = exports.findPluginForConfigFile = exports.clearRequireCache = exports.loadConfigFile = exports.getCatalogManager = exports.calculateHashesForCreateNodes = exports.calculateHashForCreateNodes = exports.mapAsyncIterable = exports.combineAsyncIterables = exports.createAsyncIterable = exports.assertSupportedPackageVersion = exports.assertSupportedInstalledPackageVersion = exports.getInstalledPackageVersion = exports.getDeclaredPackageVersion = exports.addPlugin = exports.upsertTargetDefault = exports.updateTargetDefault = exports.readTargetDefaultsForTarget = exports.findTargetDefault = exports.addE2eCiTargetDefaults = exports.addBuildTargetDefaults = exports.promptWhenInteractive = exports.resolveImportPath = exports.ensureRootProjectName = exports.determineProjectNameAndRootOptions = exports.toProjectRelativePath = exports.deleteMatchingProperties = exports.processTargetOutputs = exports.NoTargetsToMigrateError = exports.migrateProjectExecutorsToPluginV1 = exports.migrateProjectExecutorsToPlugin = exports.AggregatedLog = exports.forEachExecutorOptions = exports.getE2EWebServerInfo = exports.getRelativeCwd = exports.determineArtifactNameAndDirectoryOptions = exports.acknowledgeBuildScripts = exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.createProjectRootMappingsFromProjectConfigurations = exports.signalToCode = void 0;
4
+ exports.dasherize = exports.classify = exports.capitalize = exports.camelize = exports.checkAndCleanWithSemver = void 0;
5
5
  var devkit_internals_1 = require("nx/src/devkit-internals");
6
6
  Object.defineProperty(exports, "signalToCode", { enumerable: true, get: function () { return devkit_internals_1.signalToCode; } });
7
7
  Object.defineProperty(exports, "createProjectRootMappingsFromProjectConfigurations", { enumerable: true, get: function () { return devkit_internals_1.createProjectRootMappingsFromProjectConfigurations; } });
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "ImplementationResolutionError", { enumerable: tr
14
14
  Object.defineProperty(exports, "SchemaResolutionError", { enumerable: true, get: function () { return devkit_internals_1.SchemaResolutionError; } });
15
15
  Object.defineProperty(exports, "resolvePrompt", { enumerable: true, get: function () { return devkit_internals_1.resolvePrompt; } });
16
16
  Object.defineProperty(exports, "PromptResolutionError", { enumerable: true, get: function () { return devkit_internals_1.PromptResolutionError; } });
17
+ Object.defineProperty(exports, "acknowledgeBuildScripts", { enumerable: true, get: function () { return devkit_internals_1.acknowledgeBuildScripts; } });
17
18
  // Generators
18
19
  var artifact_name_and_directory_utils_1 = require("./src/generators/artifact-name-and-directory-utils");
19
20
  Object.defineProperty(exports, "determineArtifactNameAndDirectoryOptions", { enumerable: true, get: function () { return artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions; } });
@@ -61,7 +62,8 @@ Object.defineProperty(exports, "mapAsyncIterable", { enumerable: true, get: func
61
62
  var calculate_hash_for_create_nodes_1 = require("./src/utils/calculate-hash-for-create-nodes");
62
63
  Object.defineProperty(exports, "calculateHashForCreateNodes", { enumerable: true, get: function () { return calculate_hash_for_create_nodes_1.calculateHashForCreateNodes; } });
63
64
  Object.defineProperty(exports, "calculateHashesForCreateNodes", { enumerable: true, get: function () { return calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes; } });
64
- var catalog_1 = require("./src/utils/catalog");
65
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports -- nx/src/utils/catalog exists since nx 22.0.0, the whole supported range; swap to the nx/src/devkit-internals re-export in v25
66
+ var catalog_1 = require("nx/src/utils/catalog");
65
67
  Object.defineProperty(exports, "getCatalogManager", { enumerable: true, get: function () { return catalog_1.getCatalogManager; } });
66
68
  var config_utils_1 = require("./src/utils/config-utils");
67
69
  Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return config_utils_1.loadConfigFile; } });
@@ -12,7 +12,8 @@ const devkit_internals_1 = require("nx/src/devkit-internals");
12
12
  const path_1 = require("path");
13
13
  const semver_1 = require("semver");
14
14
  const install_packages_task_1 = require("../tasks/install-packages-task");
15
- const catalog_1 = require("./catalog");
15
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports -- nx/src/utils/catalog exists since nx 22.0.0, the whole supported range; swap to the nx/src/devkit-internals re-export in v25
16
+ const catalog_1 = require("nx/src/utils/catalog");
16
17
  const UNIDENTIFIED_VERSION = 'UNIDENTIFIED_VERSION';
17
18
  const NON_SEMVER_TAGS = {
18
19
  '*': 2,
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkAndCleanWithSemver = checkAndCleanWithSemver;
4
4
  const devkit_exports_1 = require("nx/src/devkit-exports");
5
5
  const semver_1 = require("semver");
6
- const catalog_1 = require("./catalog");
6
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports -- nx/src/utils/catalog exists since nx 22.0.0, the whole supported range; swap to the nx/src/devkit-internals re-export in v25
7
+ const catalog_1 = require("nx/src/utils/catalog");
7
8
  function checkAndCleanWithSemver(treeOrPkgName, pkgNameOrVersion, version) {
8
9
  const tree = typeof treeOrPkgName === 'string' ? undefined : treeOrPkgName;
9
10
  const root = tree?.root ?? devkit_exports_1.workspaceRoot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/devkit",
3
- "version": "23.1.0",
3
+ "version": "23.2.0-canary.20260717-dc22f7e",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -50,18 +50,16 @@
50
50
  },
51
51
  "homepage": "https://nx.dev",
52
52
  "dependencies": {
53
- "@zkochan/js-yaml": "0.0.7",
54
53
  "ejs": "5.0.1",
55
54
  "tslib": "^2.3.0",
56
55
  "semver": "^7.6.3",
57
56
  "yargs-parser": "21.1.1",
58
57
  "minimatch": "10.2.5",
59
- "enquirer": "~2.3.6",
60
- "yaml": "^2.8.3"
58
+ "enquirer": "~2.3.6"
61
59
  },
62
60
  "devDependencies": {
63
61
  "jest": "30.3.0",
64
- "nx": "23.1.0"
62
+ "nx": "23.2.0-canary.20260717-dc22f7e"
65
63
  },
66
64
  "peerDependencies": {
67
65
  "nx": ">= 22 <= 24 || ^23.0.0-0"
@@ -1,9 +0,0 @@
1
- import { type Tree } from 'nx/src/devkit-exports';
2
- import { getCatalogManager } from './manager-factory';
3
- import type { CatalogManager } from './manager';
4
- export { type CatalogManager, getCatalogManager };
5
- /**
6
- * Detects which packages in a package.json use catalog references
7
- * Returns Map of package name -> catalog name (undefined for default catalog)
8
- */
9
- export declare function getCatalogDependenciesFromPackageJson(tree: Tree, packageJsonPath: string, manager: CatalogManager): Map<string, string | undefined>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCatalogManager = void 0;
4
- exports.getCatalogDependenciesFromPackageJson = getCatalogDependenciesFromPackageJson;
5
- const devkit_exports_1 = require("nx/src/devkit-exports");
6
- const manager_factory_1 = require("./manager-factory");
7
- Object.defineProperty(exports, "getCatalogManager", { enumerable: true, get: function () { return manager_factory_1.getCatalogManager; } });
8
- /**
9
- * Detects which packages in a package.json use catalog references
10
- * Returns Map of package name -> catalog name (undefined for default catalog)
11
- */
12
- function getCatalogDependenciesFromPackageJson(tree, packageJsonPath, manager) {
13
- const catalogDeps = new Map();
14
- if (!tree.exists(packageJsonPath)) {
15
- return catalogDeps;
16
- }
17
- try {
18
- const packageJson = (0, devkit_exports_1.readJson)(tree, packageJsonPath);
19
- const allDependencies = {
20
- ...packageJson.dependencies,
21
- ...packageJson.devDependencies,
22
- ...packageJson.peerDependencies,
23
- ...packageJson.optionalDependencies,
24
- };
25
- for (const [packageName, version] of Object.entries(allDependencies || {})) {
26
- if (manager.isCatalogReference(version)) {
27
- const catalogRef = manager.parseCatalogReference(version);
28
- if (catalogRef) {
29
- catalogDeps.set(packageName, catalogRef.catalogName);
30
- }
31
- }
32
- }
33
- }
34
- catch (error) {
35
- // If we can't read the package.json, return empty map
36
- }
37
- return catalogDeps;
38
- }
@@ -1,5 +0,0 @@
1
- import type { CatalogManager } from './manager';
2
- /**
3
- * Factory function to get the appropriate catalog manager based on the package manager
4
- */
5
- export declare function getCatalogManager(workspaceRoot: string): CatalogManager | null;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCatalogManager = getCatalogManager;
4
- const devkit_exports_1 = require("nx/src/devkit-exports");
5
- const pnpm_manager_1 = require("./pnpm-manager");
6
- const yarn_manager_1 = require("./yarn-manager");
7
- /**
8
- * Factory function to get the appropriate catalog manager based on the package manager
9
- */
10
- function getCatalogManager(workspaceRoot) {
11
- const packageManager = (0, devkit_exports_1.detectPackageManager)(workspaceRoot);
12
- switch (packageManager) {
13
- case 'pnpm':
14
- return new pnpm_manager_1.PnpmCatalogManager();
15
- case 'yarn':
16
- return new yarn_manager_1.YarnCatalogManager();
17
- default:
18
- return null;
19
- }
20
- }
@@ -1,9 +0,0 @@
1
- import { type Tree } from 'nx/src/devkit-exports';
2
- import type { CatalogDefinitions } from './types';
3
- export declare function readCatalogConfigFromFs(filename: string, fullPath: string): CatalogDefinitions | null;
4
- export declare function readCatalogConfigFromTree(filename: string, tree: Tree): CatalogDefinitions | null;
5
- export declare function updateCatalogVersionsInFile(filename: string, treeOrRoot: Tree | string, updates: Array<{
6
- packageName: string;
7
- version: string;
8
- catalogName?: string;
9
- }>): void;
@@ -1,215 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readCatalogConfigFromFs = readCatalogConfigFromFs;
4
- exports.readCatalogConfigFromTree = readCatalogConfigFromTree;
5
- exports.updateCatalogVersionsInFile = updateCatalogVersionsInFile;
6
- // Keep in sync with packages/nx/src/utils/catalog/manager-utils.ts; the body below
7
- // the imports is duplicated because @nx/devkit supports a range of nx majors and
8
- // this logic isn't part of the nx surface it can import across that range.
9
- const js_yaml_1 = require("@zkochan/js-yaml");
10
- const node_fs_1 = require("node:fs");
11
- const node_path_1 = require("node:path");
12
- const devkit_exports_1 = require("nx/src/devkit-exports");
13
- const devkit_internals_1 = require("nx/src/devkit-internals");
14
- const yaml_1 = require("yaml");
15
- // Walks `path` resolving aliases at every step so structural checks can
16
- // see through `key: *anchor` references. Neither `doc.getIn` nor
17
- // `doc.hasIn` traverse aliases on their own. Returns the resolved node, or
18
- // `undefined` if any ancestor isn't a map.
19
- function resolveAt(doc, path) {
20
- let node = doc.contents;
21
- for (let i = 0; i < path.length; i++) {
22
- if ((0, yaml_1.isAlias)(node))
23
- node = node.resolve(doc);
24
- if (!(0, yaml_1.isMap)(node))
25
- return undefined;
26
- node = node.get(path[i], true);
27
- }
28
- if ((0, yaml_1.isAlias)(node))
29
- node = node.resolve(doc);
30
- return node;
31
- }
32
- function isMapAt(doc, path) {
33
- return (0, yaml_1.isMap)(resolveAt(doc, path));
34
- }
35
- function existsAt(doc, path) {
36
- return resolveAt(doc, path) !== undefined;
37
- }
38
- // `doc.getIn` does not traverse aliases. For aliased paths it returns
39
- // undefined even when the resolved node has a value. Use the alias-aware
40
- // walk and unwrap scalar nodes to their JS value.
41
- function getValueAt(doc, path) {
42
- const node = resolveAt(doc, path);
43
- return (0, yaml_1.isScalar)(node) ? node.value : node;
44
- }
45
- // Walks `targetPath` resolving aliases at every step and mutates the
46
- // resolved map directly so anchors are preserved. When a step is missing
47
- // or holds a null placeholder (`key:` with no value), creates a fresh map
48
- // inside the current parent and carries over the placeholder's comments
49
- // and anchor so they aren't dropped. A dropped anchor would leave any
50
- // alias referencing it unresolved and make `String(doc)` throw. Falls back
51
- // to `doc.setIn` when the current parent isn't a map: an empty-document
52
- // root gets bootstrapped, while a non-map value where a catalog map was
53
- // expected makes `setIn` throw, surfacing the malformed config.
54
- function setThroughAliases(doc, targetPath, value) {
55
- let parent = doc.contents;
56
- if ((0, yaml_1.isAlias)(parent))
57
- parent = parent.resolve(doc);
58
- for (let i = 0; i < targetPath.length - 1; i++) {
59
- if (!(0, yaml_1.isMap)(parent)) {
60
- doc.setIn(targetPath, value);
61
- return;
62
- }
63
- let next = parent.get(targetPath[i], true);
64
- const nextWasAlias = (0, yaml_1.isAlias)(next);
65
- if ((0, yaml_1.isAlias)(next))
66
- next = next.resolve(doc);
67
- const placeholder = (0, yaml_1.isScalar)(next) && next.value === null ? next : undefined;
68
- if (next === undefined || placeholder) {
69
- let cur = parent;
70
- for (let j = i; j < targetPath.length - 1; j++) {
71
- const fresh = new yaml_1.YAMLMap();
72
- if (j === i && placeholder) {
73
- if (placeholder.comment)
74
- fresh.comment = placeholder.comment;
75
- if (placeholder.commentBefore)
76
- fresh.commentBefore = placeholder.commentBefore;
77
- // Copy the anchor only for a directly-held placeholder. When it
78
- // was reached through an alias, the anchor still lives on the
79
- // definition node, so re-emitting it here would duplicate it.
80
- if (!nextWasAlias && placeholder.anchor)
81
- fresh.anchor = placeholder.anchor;
82
- }
83
- cur.set(targetPath[j], fresh);
84
- cur = fresh;
85
- }
86
- cur.set(targetPath[targetPath.length - 1], value);
87
- return;
88
- }
89
- parent = next;
90
- }
91
- if (!(0, yaml_1.isMap)(parent)) {
92
- doc.setIn(targetPath, value);
93
- return;
94
- }
95
- parent.set(targetPath[targetPath.length - 1], value);
96
- }
97
- function readCatalogConfigFromFs(filename, fullPath) {
98
- try {
99
- return (0, devkit_internals_1.readYamlFile)(fullPath);
100
- }
101
- catch (error) {
102
- devkit_exports_1.output.warn({
103
- title: `Unable to parse ${filename}`,
104
- bodyLines: [error.toString()],
105
- });
106
- return null;
107
- }
108
- }
109
- function readCatalogConfigFromTree(filename, tree) {
110
- const content = tree.read(filename, 'utf-8');
111
- try {
112
- return (0, js_yaml_1.load)(content, { filename });
113
- }
114
- catch (error) {
115
- devkit_exports_1.output.warn({
116
- title: `Unable to parse ${filename}`,
117
- bodyLines: [error.toString()],
118
- });
119
- return null;
120
- }
121
- }
122
- function updateCatalogVersionsInFile(filename, treeOrRoot, updates) {
123
- let checkExists;
124
- let readYaml;
125
- let writeYaml;
126
- if (typeof treeOrRoot === 'string') {
127
- const configPath = (0, node_path_1.join)(treeOrRoot, filename);
128
- checkExists = () => (0, node_fs_1.existsSync)(configPath);
129
- readYaml = () => (0, node_fs_1.readFileSync)(configPath, 'utf-8');
130
- writeYaml = (content) => (0, node_fs_1.writeFileSync)(configPath, content, 'utf-8');
131
- }
132
- else {
133
- checkExists = () => treeOrRoot.exists(filename);
134
- readYaml = () => treeOrRoot.read(filename, 'utf-8');
135
- writeYaml = (content) => treeOrRoot.write(filename, content);
136
- }
137
- if (!checkExists()) {
138
- devkit_exports_1.output.warn({
139
- title: `No ${filename} found`,
140
- bodyLines: [
141
- `Cannot update catalog versions without a ${filename} file.`,
142
- `Create a ${filename} file to use catalogs.`,
143
- ],
144
- });
145
- return;
146
- }
147
- try {
148
- // parseDocument keeps comments and anchors so a catalog bump doesn't
149
- // rewrite the user's config file.
150
- const lineCounter = new yaml_1.LineCounter();
151
- const doc = (0, yaml_1.parseDocument)(readYaml(), { lineCounter });
152
- // parseDocument collects syntax errors instead of throwing; surface them
153
- // now, with their line/column detail, rather than failing later in
154
- // `String(doc)` with a generic message or skipping a no-op write on a
155
- // malformed file (the previous js-yaml `load()` threw here).
156
- if (doc.errors.length > 0) {
157
- throw new Error(doc.errors.map((e) => e.message).join('\n'));
158
- }
159
- // A dangling alias (`*ref` with no matching `&ref`) is not a syntax error,
160
- // so parseDocument leaves it out of doc.errors. Surface it here with the
161
- // same line/column detail the old js-yaml `load()` reported; otherwise a
162
- // broken reference is silently overwritten or written back untouched.
163
- const unresolvedAliases = [];
164
- (0, yaml_1.visit)(doc, {
165
- Alias(_key, node) {
166
- if (node.resolve(doc) !== undefined)
167
- return;
168
- const pos = node.range ? lineCounter.linePos(node.range[0]) : undefined;
169
- unresolvedAliases.push(pos
170
- ? `Unresolved alias "${node.source}" at line ${pos.line}, column ${pos.col}`
171
- : `Unresolved alias "${node.source}"`);
172
- },
173
- });
174
- if (unresolvedAliases.length > 0) {
175
- throw new Error(unresolvedAliases.join('\n'));
176
- }
177
- let hasChanges = false;
178
- for (const update of updates) {
179
- const { packageName, version, catalogName } = update;
180
- const normalizedCatalogName = catalogName === 'default' ? undefined : catalogName;
181
- let targetPath;
182
- if (!normalizedCatalogName) {
183
- // An empty `catalog:` placeholder must not claim the default route
184
- // when `catalogs.default` is populated; that would create a
185
- // duplicate-default config rejected by pnpm.
186
- if (isMapAt(doc, ['catalog'])) {
187
- targetPath = ['catalog', packageName];
188
- }
189
- else if (existsAt(doc, ['catalogs', 'default'])) {
190
- targetPath = ['catalogs', 'default', packageName];
191
- }
192
- else {
193
- targetPath = ['catalog', packageName];
194
- }
195
- }
196
- else {
197
- targetPath = ['catalogs', normalizedCatalogName, packageName];
198
- }
199
- if (getValueAt(doc, targetPath) !== version) {
200
- setThroughAliases(doc, targetPath, version);
201
- hasChanges = true;
202
- }
203
- }
204
- if (hasChanges) {
205
- writeYaml(String(doc));
206
- }
207
- }
208
- catch (error) {
209
- devkit_exports_1.output.error({
210
- title: 'Failed to update catalog versions',
211
- bodyLines: [error instanceof Error ? error.message : String(error)],
212
- });
213
- throw error;
214
- }
215
- }
@@ -1,40 +0,0 @@
1
- import type { Tree } from 'nx/src/devkit-exports';
2
- import type { CatalogDefinitions, CatalogReference } from './types';
3
- export declare function formatCatalogError(error: string, suggestions: string[]): string;
4
- /**
5
- * Interface for catalog managers that handle package manager-specific catalog implementations.
6
- */
7
- export interface CatalogManager {
8
- readonly name: string;
9
- isCatalogReference(version: string): boolean;
10
- parseCatalogReference(version: string): CatalogReference | null;
11
- getCatalogDefinitionFilePaths(): string[];
12
- /**
13
- * Get catalog definitions from the workspace.
14
- */
15
- getCatalogDefinitions(workspaceRoot: string): CatalogDefinitions | null;
16
- getCatalogDefinitions(tree: Tree): CatalogDefinitions | null;
17
- /**
18
- * Resolve a catalog reference to an actual version.
19
- */
20
- resolveCatalogReference(workspaceRoot: string, packageName: string, version: string): string | null;
21
- resolveCatalogReference(tree: Tree, packageName: string, version: string): string | null;
22
- /**
23
- * Check that a catalog reference is valid.
24
- */
25
- validateCatalogReference(workspaceRoot: string, packageName: string, version: string): void;
26
- validateCatalogReference(tree: Tree, packageName: string, version: string): void;
27
- /**
28
- * Updates catalog definitions for specified packages in their respective catalogs.
29
- */
30
- updateCatalogVersions(tree: Tree, updates: Array<{
31
- packageName: string;
32
- version: string;
33
- catalogName?: string;
34
- }>): void;
35
- updateCatalogVersions(workspaceRoot: string, updates: Array<{
36
- packageName: string;
37
- version: string;
38
- catalogName?: string;
39
- }>): void;
40
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatCatalogError = formatCatalogError;
4
- function formatCatalogError(error, suggestions) {
5
- let message = error;
6
- if (suggestions.length > 0) {
7
- message += '\n\nSuggestions:';
8
- suggestions.forEach((suggestion) => {
9
- message += `\n • ${suggestion}`;
10
- });
11
- }
12
- return message;
13
- }
@@ -1,21 +0,0 @@
1
- import { type Tree } from 'nx/src/devkit-exports';
2
- import { type CatalogManager } from './manager';
3
- import type { CatalogDefinitions, CatalogReference } from './types';
4
- /**
5
- * PNPM-specific catalog manager implementation
6
- */
7
- export declare class PnpmCatalogManager implements CatalogManager {
8
- readonly name = "pnpm";
9
- readonly catalogProtocol = "catalog:";
10
- isCatalogReference(version: string): boolean;
11
- parseCatalogReference(version: string): CatalogReference | null;
12
- getCatalogDefinitionFilePaths(): string[];
13
- getCatalogDefinitions(treeOrRoot: Tree | string): CatalogDefinitions | null;
14
- resolveCatalogReference(treeOrRoot: Tree | string, packageName: string, version: string): string | null;
15
- validateCatalogReference(treeOrRoot: Tree | string, packageName: string, version: string): void;
16
- updateCatalogVersions(treeOrRoot: Tree | string, updates: Array<{
17
- packageName: string;
18
- version: string;
19
- catalogName?: string;
20
- }>): void;
21
- }
@@ -1,151 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PnpmCatalogManager = void 0;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const manager_1 = require("./manager");
7
- const manager_utils_1 = require("./manager-utils");
8
- const PNPM_WORKSPACE_FILENAME = 'pnpm-workspace.yaml';
9
- /**
10
- * PNPM-specific catalog manager implementation
11
- */
12
- class PnpmCatalogManager {
13
- constructor() {
14
- this.name = 'pnpm';
15
- this.catalogProtocol = 'catalog:';
16
- }
17
- isCatalogReference(version) {
18
- return version.startsWith(this.catalogProtocol);
19
- }
20
- parseCatalogReference(version) {
21
- if (!this.isCatalogReference(version)) {
22
- return null;
23
- }
24
- const catalogName = version.substring(this.catalogProtocol.length);
25
- // Normalize both "catalog:" and "catalog:default" to the same representation
26
- const isDefault = !catalogName || catalogName === 'default';
27
- return {
28
- catalogName: isDefault ? undefined : catalogName,
29
- isDefaultCatalog: isDefault,
30
- };
31
- }
32
- getCatalogDefinitionFilePaths() {
33
- return [PNPM_WORKSPACE_FILENAME];
34
- }
35
- getCatalogDefinitions(treeOrRoot) {
36
- if (typeof treeOrRoot === 'string') {
37
- const configPath = (0, node_path_1.join)(treeOrRoot, PNPM_WORKSPACE_FILENAME);
38
- if (!(0, node_fs_1.existsSync)(configPath)) {
39
- return null;
40
- }
41
- return (0, manager_utils_1.readCatalogConfigFromFs)(PNPM_WORKSPACE_FILENAME, configPath);
42
- }
43
- else {
44
- if (!treeOrRoot.exists(PNPM_WORKSPACE_FILENAME)) {
45
- return null;
46
- }
47
- return (0, manager_utils_1.readCatalogConfigFromTree)(PNPM_WORKSPACE_FILENAME, treeOrRoot);
48
- }
49
- }
50
- resolveCatalogReference(treeOrRoot, packageName, version) {
51
- const catalogRef = this.parseCatalogReference(version);
52
- if (!catalogRef) {
53
- return null;
54
- }
55
- const catalogDefs = this.getCatalogDefinitions(treeOrRoot);
56
- if (!catalogDefs) {
57
- return null;
58
- }
59
- let catalogToUse;
60
- if (catalogRef.isDefaultCatalog) {
61
- // Check both locations for default catalog
62
- catalogToUse = catalogDefs.catalog ?? catalogDefs.catalogs?.default;
63
- }
64
- else if (catalogRef.catalogName) {
65
- catalogToUse = catalogDefs.catalogs?.[catalogRef.catalogName];
66
- }
67
- return catalogToUse?.[packageName] || null;
68
- }
69
- validateCatalogReference(treeOrRoot, packageName, version) {
70
- const catalogRef = this.parseCatalogReference(version);
71
- if (!catalogRef) {
72
- throw new Error(`Invalid catalog reference syntax: "${version}". Expected format: "catalog:" or "catalog:name"`);
73
- }
74
- const catalogDefs = this.getCatalogDefinitions(treeOrRoot);
75
- if (!catalogDefs) {
76
- throw new Error((0, manager_1.formatCatalogError)(`Cannot get Pnpm catalog definitions. No ${PNPM_WORKSPACE_FILENAME} found in workspace root.`, [`Create a ${PNPM_WORKSPACE_FILENAME} file in your workspace root`]));
77
- }
78
- let catalogToUse;
79
- if (catalogRef.isDefaultCatalog) {
80
- const hasCatalog = !!catalogDefs.catalog;
81
- const hasCatalogsDefault = !!catalogDefs.catalogs?.default;
82
- // Error if both defined (matches pnpm behavior)
83
- if (hasCatalog && hasCatalogsDefault) {
84
- throw new Error("The 'default' catalog was defined multiple times. Use the 'catalog' field or 'catalogs.default', but not both.");
85
- }
86
- catalogToUse = catalogDefs.catalog ?? catalogDefs.catalogs?.default;
87
- if (!catalogToUse) {
88
- const availableCatalogs = Object.keys(catalogDefs.catalogs || {});
89
- const suggestions = [
90
- `Define a default catalog in ${PNPM_WORKSPACE_FILENAME} under the "catalog" key`,
91
- ];
92
- if (availableCatalogs.length > 0) {
93
- suggestions.push(`Or select from the available named catalogs: ${availableCatalogs
94
- .map((c) => `"catalog:${c}"`)
95
- .join(', ')}`);
96
- }
97
- throw new Error((0, manager_1.formatCatalogError)(`No default catalog defined in ${PNPM_WORKSPACE_FILENAME}`, suggestions));
98
- }
99
- }
100
- else if (catalogRef.catalogName) {
101
- catalogToUse = catalogDefs.catalogs?.[catalogRef.catalogName];
102
- if (!catalogToUse) {
103
- const availableCatalogs = Object.keys(catalogDefs.catalogs || {}).filter((c) => c !== 'default');
104
- const defaultCatalog = !!catalogDefs.catalog
105
- ? 'catalog'
106
- : !catalogDefs.catalogs?.default
107
- ? 'catalogs.default'
108
- : null;
109
- const suggestions = [
110
- `Define the catalog in ${PNPM_WORKSPACE_FILENAME} under the "catalogs" key`,
111
- ];
112
- if (availableCatalogs.length > 0) {
113
- suggestions.push(`Or select from the available named catalogs: ${availableCatalogs
114
- .map((c) => `"catalog:${c}"`)
115
- .join(', ')}`);
116
- }
117
- if (defaultCatalog) {
118
- suggestions.push(`Or use the default catalog ("${defaultCatalog}")`);
119
- }
120
- throw new Error((0, manager_1.formatCatalogError)(`Catalog "${catalogRef.catalogName}" not found in ${PNPM_WORKSPACE_FILENAME}`, suggestions));
121
- }
122
- }
123
- if (!catalogToUse[packageName]) {
124
- let catalogName;
125
- if (catalogRef.isDefaultCatalog) {
126
- // Context-aware messaging based on which location exists
127
- const hasCatalog = !!catalogDefs.catalog;
128
- catalogName = hasCatalog
129
- ? 'default catalog ("catalog")'
130
- : 'default catalog ("catalogs.default")';
131
- }
132
- else {
133
- catalogName = `catalog '${catalogRef.catalogName}'`;
134
- }
135
- const availablePackages = Object.keys(catalogToUse);
136
- const suggestions = [
137
- `Add "${packageName}" to ${catalogName} in ${PNPM_WORKSPACE_FILENAME}`,
138
- ];
139
- if (availablePackages.length > 0) {
140
- suggestions.push(`Or select from the available packages in ${catalogName}: ${availablePackages
141
- .map((p) => `"${p}"`)
142
- .join(', ')}`);
143
- }
144
- throw new Error((0, manager_1.formatCatalogError)(`Package "${packageName}" not found in ${catalogName}`, suggestions));
145
- }
146
- }
147
- updateCatalogVersions(treeOrRoot, updates) {
148
- (0, manager_utils_1.updateCatalogVersionsInFile)(PNPM_WORKSPACE_FILENAME, treeOrRoot, updates);
149
- }
150
- }
151
- exports.PnpmCatalogManager = PnpmCatalogManager;
@@ -1,11 +0,0 @@
1
- export interface CatalogReference {
2
- catalogName?: string;
3
- isDefaultCatalog: boolean;
4
- }
5
- export interface CatalogEntry {
6
- [packageName: string]: string;
7
- }
8
- export interface CatalogDefinitions {
9
- catalog?: CatalogEntry;
10
- catalogs?: Record<string, CatalogEntry>;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,21 +0,0 @@
1
- import { type Tree } from 'nx/src/devkit-exports';
2
- import { type CatalogManager } from './manager';
3
- import type { CatalogDefinitions, CatalogReference } from './types';
4
- /**
5
- * Yarn Berry (v4+) catalog manager implementation
6
- */
7
- export declare class YarnCatalogManager implements CatalogManager {
8
- readonly name = "yarn";
9
- readonly catalogProtocol = "catalog:";
10
- isCatalogReference(version: string): boolean;
11
- parseCatalogReference(version: string): CatalogReference | null;
12
- getCatalogDefinitionFilePaths(): string[];
13
- getCatalogDefinitions(treeOrRoot: Tree | string): CatalogDefinitions | null;
14
- resolveCatalogReference(treeOrRoot: Tree | string, packageName: string, version: string): string | null;
15
- validateCatalogReference(treeOrRoot: Tree | string, packageName: string, version: string): void;
16
- updateCatalogVersions(treeOrRoot: Tree | string, updates: Array<{
17
- packageName: string;
18
- version: string;
19
- catalogName?: string;
20
- }>): void;
21
- }
@@ -1,151 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.YarnCatalogManager = void 0;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const manager_1 = require("./manager");
7
- const manager_utils_1 = require("./manager-utils");
8
- const YARNRC_FILENAME = '.yarnrc.yml';
9
- /**
10
- * Yarn Berry (v4+) catalog manager implementation
11
- */
12
- class YarnCatalogManager {
13
- constructor() {
14
- this.name = 'yarn';
15
- this.catalogProtocol = 'catalog:';
16
- }
17
- isCatalogReference(version) {
18
- return version.startsWith(this.catalogProtocol);
19
- }
20
- parseCatalogReference(version) {
21
- if (!this.isCatalogReference(version)) {
22
- return null;
23
- }
24
- const catalogName = version.substring(this.catalogProtocol.length);
25
- // Normalize both "catalog:" and "catalog:default" to the same representation
26
- const isDefault = !catalogName || catalogName === 'default';
27
- return {
28
- catalogName: isDefault ? undefined : catalogName,
29
- isDefaultCatalog: isDefault,
30
- };
31
- }
32
- getCatalogDefinitionFilePaths() {
33
- return [YARNRC_FILENAME];
34
- }
35
- getCatalogDefinitions(treeOrRoot) {
36
- if (typeof treeOrRoot === 'string') {
37
- const configPath = (0, node_path_1.join)(treeOrRoot, YARNRC_FILENAME);
38
- if (!(0, node_fs_1.existsSync)(configPath)) {
39
- return null;
40
- }
41
- return (0, manager_utils_1.readCatalogConfigFromFs)(YARNRC_FILENAME, configPath);
42
- }
43
- else {
44
- if (!treeOrRoot.exists(YARNRC_FILENAME)) {
45
- return null;
46
- }
47
- return (0, manager_utils_1.readCatalogConfigFromTree)(YARNRC_FILENAME, treeOrRoot);
48
- }
49
- }
50
- resolveCatalogReference(treeOrRoot, packageName, version) {
51
- const catalogRef = this.parseCatalogReference(version);
52
- if (!catalogRef) {
53
- return null;
54
- }
55
- const catalogDefs = this.getCatalogDefinitions(treeOrRoot);
56
- if (!catalogDefs) {
57
- return null;
58
- }
59
- let catalogToUse;
60
- if (catalogRef.isDefaultCatalog) {
61
- // Check both locations for default catalog
62
- catalogToUse = catalogDefs.catalog ?? catalogDefs.catalogs?.default;
63
- }
64
- else if (catalogRef.catalogName) {
65
- catalogToUse = catalogDefs.catalogs?.[catalogRef.catalogName];
66
- }
67
- return catalogToUse?.[packageName] || null;
68
- }
69
- validateCatalogReference(treeOrRoot, packageName, version) {
70
- const catalogRef = this.parseCatalogReference(version);
71
- if (!catalogRef) {
72
- throw new Error(`Invalid catalog reference syntax: "${version}". Expected format: "catalog:" or "catalog:name"`);
73
- }
74
- const catalogDefs = this.getCatalogDefinitions(treeOrRoot);
75
- if (!catalogDefs) {
76
- throw new Error((0, manager_1.formatCatalogError)(`Cannot get Yarn catalog definitions. No ${YARNRC_FILENAME} found in workspace root.`, [`Create a ${YARNRC_FILENAME} file in your workspace root`]));
77
- }
78
- let catalogToUse;
79
- if (catalogRef.isDefaultCatalog) {
80
- const hasCatalog = !!catalogDefs.catalog;
81
- const hasCatalogsDefault = !!catalogDefs.catalogs?.default;
82
- // Error if both defined
83
- if (hasCatalog && hasCatalogsDefault) {
84
- throw new Error("The 'default' catalog was defined multiple times. Use the 'catalog' field or 'catalogs.default', but not both.");
85
- }
86
- catalogToUse = catalogDefs.catalog ?? catalogDefs.catalogs?.default;
87
- if (!catalogToUse) {
88
- const availableCatalogs = Object.keys(catalogDefs.catalogs || {});
89
- const suggestions = [
90
- `Define a default catalog in ${YARNRC_FILENAME} under the "catalog" key`,
91
- ];
92
- if (availableCatalogs.length > 0) {
93
- suggestions.push(`Or select from the available named catalogs: ${availableCatalogs
94
- .map((c) => `"catalog:${c}"`)
95
- .join(', ')}`);
96
- }
97
- throw new Error((0, manager_1.formatCatalogError)(`No default catalog defined in ${YARNRC_FILENAME}`, suggestions));
98
- }
99
- }
100
- else if (catalogRef.catalogName) {
101
- catalogToUse = catalogDefs.catalogs?.[catalogRef.catalogName];
102
- if (!catalogToUse) {
103
- const availableCatalogs = Object.keys(catalogDefs.catalogs || {}).filter((c) => c !== 'default');
104
- const defaultCatalog = !!catalogDefs.catalog
105
- ? 'catalog'
106
- : !catalogDefs.catalogs?.default
107
- ? 'catalogs.default'
108
- : null;
109
- const suggestions = [
110
- `Define the catalog in ${YARNRC_FILENAME} under the "catalogs" key`,
111
- ];
112
- if (availableCatalogs.length > 0) {
113
- suggestions.push(`Or select from the available named catalogs: ${availableCatalogs
114
- .map((c) => `"catalog:${c}"`)
115
- .join(', ')}`);
116
- }
117
- if (defaultCatalog) {
118
- suggestions.push(`Or use the default catalog ("${defaultCatalog}")`);
119
- }
120
- throw new Error((0, manager_1.formatCatalogError)(`Catalog "${catalogRef.catalogName}" not found in ${YARNRC_FILENAME}`, suggestions));
121
- }
122
- }
123
- if (!catalogToUse[packageName]) {
124
- let catalogName;
125
- if (catalogRef.isDefaultCatalog) {
126
- // Context-aware messaging based on which location exists
127
- const hasCatalog = !!catalogDefs.catalog;
128
- catalogName = hasCatalog
129
- ? 'default catalog ("catalog")'
130
- : 'default catalog ("catalogs.default")';
131
- }
132
- else {
133
- catalogName = `catalog '${catalogRef.catalogName}'`;
134
- }
135
- const availablePackages = Object.keys(catalogToUse);
136
- const suggestions = [
137
- `Add "${packageName}" to ${catalogName} in ${YARNRC_FILENAME}`,
138
- ];
139
- if (availablePackages.length > 0) {
140
- suggestions.push(`Or select from the available packages in ${catalogName}: ${availablePackages
141
- .map((p) => `"${p}"`)
142
- .join(', ')}`);
143
- }
144
- throw new Error((0, manager_1.formatCatalogError)(`Package "${packageName}" not found in ${catalogName}`, suggestions));
145
- }
146
- }
147
- updateCatalogVersions(treeOrRoot, updates) {
148
- (0, manager_utils_1.updateCatalogVersionsInFile)(YARNRC_FILENAME, treeOrRoot, updates);
149
- }
150
- }
151
- exports.YarnCatalogManager = YarnCatalogManager;