@nx/devkit 0.0.0-pr-32978-2f0e271 → 0.0.0-pr-32869-39cffae

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 (44) hide show
  1. package/package.json +3 -4
  2. package/public-api.d.ts +1 -1
  3. package/public-api.d.ts.map +1 -1
  4. package/public-api.js +1 -2
  5. package/src/generators/plugin-migrations/executor-to-plugin-migrator.d.ts +2 -2
  6. package/src/generators/plugin-migrations/executor-to-plugin-migrator.d.ts.map +1 -1
  7. package/src/generators/target-defaults-utils.d.ts.map +1 -1
  8. package/src/utils/add-plugin.d.ts +2 -2
  9. package/src/utils/add-plugin.d.ts.map +1 -1
  10. package/src/utils/calculate-hash-for-create-nodes.d.ts +3 -3
  11. package/src/utils/calculate-hash-for-create-nodes.d.ts.map +1 -1
  12. package/src/utils/find-plugin-for-config-file.d.ts.map +1 -1
  13. package/src/utils/get-named-inputs.d.ts +2 -2
  14. package/src/utils/get-named-inputs.d.ts.map +1 -1
  15. package/src/utils/package-json.d.ts +1 -55
  16. package/src/utils/package-json.d.ts.map +1 -1
  17. package/src/utils/package-json.js +42 -225
  18. package/src/utils/replace-project-configuration-with-plugin.d.ts +2 -2
  19. package/src/utils/replace-project-configuration-with-plugin.d.ts.map +1 -1
  20. package/src/utils/replace-project-configuration-with-plugin.js +8 -8
  21. package/src/utils/semver.d.ts +0 -2
  22. package/src/utils/semver.d.ts.map +1 -1
  23. package/src/utils/semver.js +5 -27
  24. package/src/utils/catalog/errors.d.ts +0 -10
  25. package/src/utils/catalog/errors.d.ts.map +0 -1
  26. package/src/utils/catalog/errors.js +0 -19
  27. package/src/utils/catalog/index.d.ts +0 -12
  28. package/src/utils/catalog/index.d.ts.map +0 -1
  29. package/src/utils/catalog/index.js +0 -52
  30. package/src/utils/catalog/manager-factory.d.ts +0 -6
  31. package/src/utils/catalog/manager-factory.d.ts.map +0 -1
  32. package/src/utils/catalog/manager-factory.js +0 -24
  33. package/src/utils/catalog/manager.d.ts +0 -50
  34. package/src/utils/catalog/manager.d.ts.map +0 -1
  35. package/src/utils/catalog/manager.js +0 -2
  36. package/src/utils/catalog/pnpm-manager.d.ts +0 -26
  37. package/src/utils/catalog/pnpm-manager.d.ts.map +0 -1
  38. package/src/utils/catalog/pnpm-manager.js +0 -258
  39. package/src/utils/catalog/types.d.ts +0 -18
  40. package/src/utils/catalog/types.d.ts.map +0 -1
  41. package/src/utils/catalog/types.js +0 -10
  42. package/src/utils/catalog/unsupported-manager.d.ts +0 -38
  43. package/src/utils/catalog/unsupported-manager.d.ts.map +0 -1
  44. package/src/utils/catalog/unsupported-manager.js +0 -58
@@ -17,19 +17,19 @@ async function replaceProjectConfigurationsWithPlugin(tree, rootMappings, plugin
17
17
  (0, devkit_exports_1.updateNxJson)(tree, nxJson);
18
18
  const [pluginGlob, createNodesFunction] = createNodes;
19
19
  const configFiles = (0, devkit_exports_1.glob)(tree, [pluginGlob]);
20
- for (const configFile of configFiles) {
20
+ const results = await createNodesFunction(configFiles, pluginOptions, {
21
+ workspaceRoot: tree.root,
22
+ nxJsonConfiguration: (0, devkit_exports_1.readNxJson)(tree),
23
+ });
24
+ for (const [configFile, nodes] of results) {
21
25
  try {
22
26
  const projectName = (0, devkit_internals_1.findProjectForPath)(configFile, rootMappings);
23
27
  const projectConfig = (0, devkit_exports_1.readProjectConfiguration)(tree, projectName);
24
- const nodes = await createNodesFunction(configFile, pluginOptions, {
25
- workspaceRoot: tree.root,
26
- nxJsonConfiguration: (0, devkit_exports_1.readNxJson)(tree),
27
- configFiles,
28
- });
29
28
  const node = nodes.projects[Object.keys(nodes.projects)[0]];
30
- for (const [targetName, targetConfig] of Object.entries(node.targets)) {
29
+ for (const [targetName, targetConfig] of Object.entries(node.targets ?? {})) {
31
30
  const targetFromProjectConfig = projectConfig.targets[targetName];
32
- if (targetFromProjectConfig?.executor !== targetConfig.executor) {
31
+ if (targetFromProjectConfig?.executor !==
32
+ targetConfig.executor) {
33
33
  continue;
34
34
  }
35
35
  const targetFromCreateNodes = node.targets[targetName];
@@ -1,4 +1,2 @@
1
- import { type Tree } from 'nx/src/devkit-exports';
2
1
  export declare function checkAndCleanWithSemver(pkgName: string, version: string): string;
3
- export declare function checkAndCleanWithSemver(tree: Tree, pkgName: string, version: string): string;
4
2
  //# sourceMappingURL=semver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"semver.d.ts","sourceRoot":"","sources":["../../../../../packages/devkit/src/utils/semver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAIjE,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,MAAM,CAAC;AACV,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,MAAM,CAAC"}
1
+ {"version":3,"file":"semver.d.ts","sourceRoot":"","sources":["../../../../../packages/devkit/src/utils/semver.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,MAAM,CAkBR"}
@@ -1,39 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkAndCleanWithSemver = checkAndCleanWithSemver;
4
- const devkit_exports_1 = require("nx/src/devkit-exports");
5
4
  const semver_1 = require("semver");
6
- const catalog_1 = require("./catalog");
7
- function checkAndCleanWithSemver(treeOrPkgName, pkgNameOrVersion, version) {
8
- const tree = typeof treeOrPkgName === 'string' ? undefined : treeOrPkgName;
9
- const root = tree?.root ?? devkit_exports_1.workspaceRoot;
10
- const pkgName = typeof treeOrPkgName === 'string' ? treeOrPkgName : pkgNameOrVersion;
11
- const actualVersion = typeof treeOrPkgName === 'string' ? pkgNameOrVersion : version;
12
- let newVersion = actualVersion;
13
- const manager = (0, catalog_1.getCatalogManager)(root);
14
- if (manager.isCatalogReference(actualVersion)) {
15
- const validation = tree
16
- ? manager.validateCatalogReference(tree, pkgName, actualVersion)
17
- : manager.validateCatalogReference(root, pkgName, actualVersion);
18
- if (!validation.isValid) {
19
- throw new Error(`The catalog reference for ${pkgName} is invalid - (${actualVersion})\n${(0, catalog_1.formatCatalogError)(validation.error)}`);
20
- }
21
- const resolvedVersion = tree
22
- ? manager.resolveCatalogReference(tree, pkgName, actualVersion)
23
- : manager.resolveCatalogReference(root, pkgName, actualVersion);
24
- if (!resolvedVersion) {
25
- throw new Error(`Could not resolve catalog reference for package ${pkgName}@${actualVersion}.`);
26
- }
27
- newVersion = resolvedVersion;
28
- }
5
+ function checkAndCleanWithSemver(pkgName, version) {
6
+ let newVersion = version;
29
7
  if ((0, semver_1.valid)(newVersion)) {
30
8
  return newVersion;
31
9
  }
32
- if (actualVersion.startsWith('~') || actualVersion.startsWith('^')) {
33
- newVersion = actualVersion.substring(1);
10
+ if (version.startsWith('~') || version.startsWith('^')) {
11
+ newVersion = version.substring(1);
34
12
  }
35
13
  if (!(0, semver_1.valid)(newVersion)) {
36
- throw new Error(`The package.json lists a version of ${pkgName} that Nx is unable to validate - (${actualVersion})`);
14
+ throw new Error(`The package.json lists a version of ${pkgName} that Nx is unable to validate - (${version})`);
37
15
  }
38
16
  return newVersion;
39
17
  }
@@ -1,10 +0,0 @@
1
- import type { CatalogError } from './types';
2
- export declare class CatalogValidationError extends Error {
3
- readonly catalogError: CatalogError;
4
- constructor(catalogError: CatalogError, message?: string);
5
- }
6
- export declare class CatalogUnsupportedError extends Error {
7
- readonly packageManager: string;
8
- constructor(packageManager: string, operation: string);
9
- }
10
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../../packages/devkit/src/utils/catalog/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,sBAAuB,SAAQ,KAAK;aACnB,YAAY,EAAE,YAAY;gBAA1B,YAAY,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM;CAIzE;AAED,qBAAa,uBAAwB,SAAQ,KAAK;aACpB,cAAc,EAAE,MAAM;gBAAtB,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAMtE"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatalogUnsupportedError = exports.CatalogValidationError = void 0;
4
- class CatalogValidationError extends Error {
5
- constructor(catalogError, message) {
6
- super(message || catalogError.message);
7
- this.catalogError = catalogError;
8
- this.name = 'CatalogValidationError';
9
- }
10
- }
11
- exports.CatalogValidationError = CatalogValidationError;
12
- class CatalogUnsupportedError extends Error {
13
- constructor(packageManager, operation) {
14
- super(`Tried to ${operation} but Nx doesn't support catalogs for the current package manager (${packageManager})`);
15
- this.packageManager = packageManager;
16
- this.name = 'CatalogUnsupportedError';
17
- }
18
- }
19
- exports.CatalogUnsupportedError = CatalogUnsupportedError;
@@ -1,12 +0,0 @@
1
- import { type Tree } from 'nx/src/devkit-exports';
2
- import { getCatalogManager } from './manager-factory';
3
- import type { CatalogError } from './types';
4
- import type { CatalogManager } from './manager';
5
- export { getCatalogManager };
6
- /**
7
- * Detects which packages in a package.json use catalog references
8
- * Returns Map of package name -> catalog name (undefined for default catalog)
9
- */
10
- export declare function getCatalogDependenciesFromPackageJson(tree: Tree, packageJsonPath: string, manager: CatalogManager): Map<string, string | undefined>;
11
- export declare function formatCatalogError(error: CatalogError): string;
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/devkit/src/utils/catalog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;;GAGG;AACH,wBAAgB,qCAAqC,CACnD,IAAI,EAAE,IAAI,EACV,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,cAAc,GACtB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAmCjC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAW9D"}
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCatalogManager = void 0;
4
- exports.getCatalogDependenciesFromPackageJson = getCatalogDependenciesFromPackageJson;
5
- exports.formatCatalogError = formatCatalogError;
6
- const devkit_exports_1 = require("nx/src/devkit-exports");
7
- const manager_factory_1 = require("./manager-factory");
8
- Object.defineProperty(exports, "getCatalogManager", { enumerable: true, get: function () { return manager_factory_1.getCatalogManager; } });
9
- /**
10
- * Detects which packages in a package.json use catalog references
11
- * Returns Map of package name -> catalog name (undefined for default catalog)
12
- */
13
- function getCatalogDependenciesFromPackageJson(tree, packageJsonPath, manager) {
14
- const catalogDeps = new Map();
15
- if (!tree.exists(packageJsonPath)) {
16
- return catalogDeps;
17
- }
18
- if (!manager.supportsCatalogs()) {
19
- return catalogDeps;
20
- }
21
- try {
22
- const packageJson = (0, devkit_exports_1.readJson)(tree, packageJsonPath);
23
- const allDependencies = {
24
- ...packageJson.dependencies,
25
- ...packageJson.devDependencies,
26
- ...packageJson.peerDependencies,
27
- ...packageJson.optionalDependencies,
28
- };
29
- for (const [packageName, version] of Object.entries(allDependencies || {})) {
30
- if (manager.isCatalogReference(version)) {
31
- const catalogRef = manager.parseCatalogReference(version);
32
- if (catalogRef) {
33
- catalogDeps.set(packageName, catalogRef.catalogName);
34
- }
35
- }
36
- }
37
- }
38
- catch (error) {
39
- // If we can't read the package.json, return empty map
40
- }
41
- return catalogDeps;
42
- }
43
- function formatCatalogError(error) {
44
- let message = error.message;
45
- if (error.suggestions && error.suggestions.length > 0) {
46
- message += '\n\nSuggestions:';
47
- error.suggestions.forEach((suggestion) => {
48
- message += `\n • ${suggestion}`;
49
- });
50
- }
51
- return message;
52
- }
@@ -1,6 +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;
6
- //# sourceMappingURL=manager-factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager-factory.d.ts","sourceRoot":"","sources":["../../../../../../packages/devkit/src/utils/catalog/manager-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAShD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,CAevE"}
@@ -1,24 +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 unsupported_manager_1 = require("./unsupported-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 'npm':
16
- return new unsupported_manager_1.NpmCatalogManager();
17
- case 'yarn':
18
- return new unsupported_manager_1.YarnCatalogManager();
19
- case 'bun':
20
- return new unsupported_manager_1.BunCatalogManager();
21
- default:
22
- return new unsupported_manager_1.UnknownCatalogManager();
23
- }
24
- }
@@ -1,50 +0,0 @@
1
- import type { Tree } from 'nx/src/devkit-exports';
2
- import type { PnpmWorkspaceYaml } from 'nx/src/utils/pnpm-workspace';
3
- import type { CatalogError, CatalogReference } from './types';
4
- /**
5
- * Interface for catalog managers that handle package manager-specific catalog implementations.
6
- */
7
- export interface CatalogManager {
8
- readonly name: string;
9
- /**
10
- * Check if this package manager supports catalogs.
11
- */
12
- supportsCatalogs(): boolean;
13
- isCatalogReference(version: string): boolean;
14
- parseCatalogReference(version: string): CatalogReference | null;
15
- /**
16
- * Get catalog definitions from the workspace.
17
- */
18
- getCatalogDefinitions(workspaceRoot: string): PnpmWorkspaceYaml | null;
19
- getCatalogDefinitions(tree: Tree): PnpmWorkspaceYaml | null;
20
- /**
21
- * Resolve a catalog reference to an actual version.
22
- */
23
- resolveCatalogReference(workspaceRoot: string, packageName: string, version: string): string | null;
24
- resolveCatalogReference(tree: Tree, packageName: string, version: string): string | null;
25
- /**
26
- * Check that a catalog reference is valid.
27
- */
28
- validateCatalogReference(workspaceRoot: string, packageName: string, version: string): {
29
- isValid: boolean;
30
- error?: CatalogError;
31
- };
32
- validateCatalogReference(tree: Tree, packageName: string, version: string): {
33
- isValid: boolean;
34
- error?: CatalogError;
35
- };
36
- /**
37
- * Updates catalog definitions for specified packages in their respective catalogs.
38
- */
39
- updateCatalogVersions(tree: Tree, updates: Array<{
40
- packageName: string;
41
- version: string;
42
- catalogName?: string;
43
- }>): void;
44
- updateCatalogVersions(workspaceRoot: string, updates: Array<{
45
- packageName: string;
46
- version: string;
47
- catalogName?: string;
48
- }>): void;
49
- }
50
- //# sourceMappingURL=manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../../../packages/devkit/src/utils/catalog/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,gBAAgB,IAAI,OAAO,CAAC;IAE5B,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAE7C,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAEhE;;OAEG;IACH,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAAC;IACvE,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,GAAG,IAAI,CAAC;IAE5D;;OAEG;IACH,uBAAuB,CACrB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAAC;IACjB,uBAAuB,CACrB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAAC;IAEjB;;OAEG;IACH,wBAAwB,CACtB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC;IAC9C,wBAAwB,CACtB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC;IAE9C;;OAEG;IACH,qBAAqB,CACnB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,KAAK,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,GACD,IAAI,CAAC;IACR,qBAAqB,CACnB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,KAAK,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,GACD,IAAI,CAAC;CACT"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,26 +0,0 @@
1
- import { type Tree } from 'nx/src/devkit-exports';
2
- import type { PnpmWorkspaceYaml } from 'nx/src/utils/pnpm-workspace';
3
- import type { CatalogManager } from './manager';
4
- import { type CatalogError, type CatalogReference } from './types';
5
- /**
6
- * PNPM-specific catalog manager implementation
7
- */
8
- export declare class PnpmCatalogManager implements CatalogManager {
9
- readonly name = "pnpm";
10
- readonly catalogProtocol = "catalog:";
11
- supportsCatalogs(): boolean;
12
- isCatalogReference(version: string): boolean;
13
- parseCatalogReference(version: string): CatalogReference | null;
14
- getCatalogDefinitions(treeOrRoot: Tree | string): PnpmWorkspaceYaml | null;
15
- resolveCatalogReference(treeOrRoot: Tree | string, packageName: string, version: string): string | null;
16
- validateCatalogReference(treeOrRoot: Tree | string, packageName: string, version: string): {
17
- isValid: boolean;
18
- error?: CatalogError;
19
- };
20
- updateCatalogVersions(treeOrRoot: Tree | string, updates: Array<{
21
- packageName: string;
22
- version: string;
23
- catalogName?: string;
24
- }>): void;
25
- }
26
- //# sourceMappingURL=pnpm-manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pnpm-manager.d.ts","sourceRoot":"","sources":["../../../../../../packages/devkit/src/utils/catalog/pnpm-manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EACtB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACvD,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,eAAe,cAAc;IAEtC,gBAAgB,IAAI,OAAO;IAI3B,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAI5C,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAa/D,qBAAqB,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAe1E,uBAAuB,CACrB,UAAU,EAAE,IAAI,GAAG,MAAM,EACzB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI;IAqBhB,wBAAwB,CACtB,UAAU,EAAE,IAAI,GAAG,MAAM,EACzB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,YAAY,CAAA;KAAE;IAqH7C,qBAAqB,CACnB,UAAU,EAAE,IAAI,GAAG,MAAM,EACzB,OAAO,EAAE,KAAK,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,GACD,IAAI;CAuER"}
@@ -1,258 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PnpmCatalogManager = void 0;
4
- const js_yaml_1 = require("@zkochan/js-yaml");
5
- const node_fs_1 = require("node:fs");
6
- const node_path_1 = require("node:path");
7
- const devkit_exports_1 = require("nx/src/devkit-exports");
8
- const devkit_internals_1 = require("nx/src/devkit-internals");
9
- const types_1 = require("./types");
10
- /**
11
- * PNPM-specific catalog manager implementation
12
- */
13
- class PnpmCatalogManager {
14
- constructor() {
15
- this.name = 'pnpm';
16
- this.catalogProtocol = 'catalog:';
17
- }
18
- supportsCatalogs() {
19
- return true;
20
- }
21
- isCatalogReference(version) {
22
- return version.startsWith(this.catalogProtocol);
23
- }
24
- parseCatalogReference(version) {
25
- if (!this.isCatalogReference(version)) {
26
- return null;
27
- }
28
- const catalogName = version.substring(this.catalogProtocol.length);
29
- return {
30
- catalogName: catalogName || undefined,
31
- isDefaultCatalog: catalogName === '',
32
- };
33
- }
34
- getCatalogDefinitions(treeOrRoot) {
35
- if (typeof treeOrRoot === 'string') {
36
- const pnpmWorkspacePath = (0, node_path_1.join)(treeOrRoot, 'pnpm-workspace.yaml');
37
- if (!(0, node_fs_1.existsSync)(pnpmWorkspacePath)) {
38
- return null;
39
- }
40
- return readYamlFileFromFs(pnpmWorkspacePath);
41
- }
42
- else {
43
- if (!treeOrRoot.exists('pnpm-workspace.yaml')) {
44
- return null;
45
- }
46
- return readYamlFileFromTree(treeOrRoot, 'pnpm-workspace.yaml');
47
- }
48
- }
49
- resolveCatalogReference(treeOrRoot, packageName, version) {
50
- const catalogRef = this.parseCatalogReference(version);
51
- if (!catalogRef) {
52
- return null;
53
- }
54
- const workspaceConfig = this.getCatalogDefinitions(treeOrRoot);
55
- if (!workspaceConfig) {
56
- return null;
57
- }
58
- let catalogToUse;
59
- if (catalogRef.isDefaultCatalog) {
60
- catalogToUse = workspaceConfig.catalog;
61
- }
62
- else if (catalogRef.catalogName) {
63
- catalogToUse = workspaceConfig.catalogs?.[catalogRef.catalogName];
64
- }
65
- return catalogToUse?.[packageName] || null;
66
- }
67
- validateCatalogReference(treeOrRoot, packageName, version) {
68
- const catalogRef = this.parseCatalogReference(version);
69
- if (!catalogRef) {
70
- return {
71
- isValid: false,
72
- error: {
73
- type: types_1.CatalogErrorType.INVALID_SYNTAX,
74
- message: `Invalid catalog reference syntax: "${version}". Expected format: "catalog:" or "catalog:name"`,
75
- },
76
- };
77
- }
78
- const workspaceConfig = this.getCatalogDefinitions(treeOrRoot);
79
- if (!workspaceConfig) {
80
- return {
81
- isValid: false,
82
- error: {
83
- type: types_1.CatalogErrorType.WORKSPACE_NOT_FOUND,
84
- message: 'No pnpm-workspace.yaml found in workspace root',
85
- suggestions: [
86
- 'Create a pnpm-workspace.yaml file in your workspace root',
87
- ],
88
- },
89
- };
90
- }
91
- let catalogToUse;
92
- if (catalogRef.isDefaultCatalog) {
93
- catalogToUse = workspaceConfig.catalog;
94
- if (!catalogToUse) {
95
- const availableCatalogs = Object.keys(workspaceConfig.catalogs || {});
96
- const suggestions = [
97
- 'Define a default catalog in pnpm-workspace.yaml under the "catalog" key',
98
- ];
99
- if (availableCatalogs.length > 0) {
100
- suggestions.push(`Or select from the available named catalogs: ${availableCatalogs
101
- .map((c) => `"catalog:${c}"`)
102
- .join(', ')}`);
103
- }
104
- return {
105
- isValid: false,
106
- error: {
107
- type: types_1.CatalogErrorType.CATALOG_NOT_FOUND,
108
- message: 'No default catalog defined in pnpm-workspace.yaml',
109
- suggestions,
110
- },
111
- };
112
- }
113
- }
114
- else if (catalogRef.catalogName) {
115
- catalogToUse = workspaceConfig.catalogs?.[catalogRef.catalogName];
116
- if (!catalogToUse) {
117
- const availableCatalogs = Object.keys(workspaceConfig.catalogs || {});
118
- const hasDefaultCatalog = !!workspaceConfig.catalog;
119
- const suggestions = [
120
- 'Define the catalog in pnpm-workspace.yaml under the "catalogs" key',
121
- ];
122
- if (availableCatalogs.length > 0) {
123
- suggestions.push(`Or select from the available named catalogs: ${availableCatalogs
124
- .map((c) => `"catalog:${c}"`)
125
- .join(', ')}`);
126
- }
127
- if (hasDefaultCatalog) {
128
- suggestions.push('Or use the default catalog: "catalog:"');
129
- }
130
- return {
131
- isValid: false,
132
- error: {
133
- type: types_1.CatalogErrorType.CATALOG_NOT_FOUND,
134
- message: `Catalog "${catalogRef.catalogName}" not found in pnpm-workspace.yaml`,
135
- catalogName: catalogRef.catalogName,
136
- suggestions,
137
- },
138
- };
139
- }
140
- }
141
- if (!catalogToUse[packageName]) {
142
- const catalogName = catalogRef.isDefaultCatalog
143
- ? 'default catalog'
144
- : `catalog '${catalogRef.catalogName}'`;
145
- const availablePackages = Object.keys(catalogToUse);
146
- const suggestions = [
147
- `Add "${packageName}" to ${catalogName} in pnpm-workspace.yaml`,
148
- ];
149
- if (availablePackages.length > 0) {
150
- suggestions.push(`Or select from the available packages in ${catalogName}: ${availablePackages
151
- .map((p) => `"${p}"`)
152
- .join(', ')}`);
153
- }
154
- return {
155
- isValid: false,
156
- error: {
157
- type: types_1.CatalogErrorType.PACKAGE_NOT_FOUND,
158
- message: `Package "${packageName}" not found in ${catalogName}`,
159
- packageName,
160
- catalogName: catalogRef.catalogName,
161
- suggestions,
162
- },
163
- };
164
- }
165
- return { isValid: true };
166
- }
167
- updateCatalogVersions(treeOrRoot, updates) {
168
- let checkExists;
169
- let readYaml;
170
- let writeYaml;
171
- if (typeof treeOrRoot === 'string') {
172
- const workspaceYamlPath = (0, node_path_1.join)(treeOrRoot, 'pnpm-workspace.yaml');
173
- checkExists = () => (0, node_fs_1.existsSync)(workspaceYamlPath);
174
- readYaml = () => (0, node_fs_1.readFileSync)(workspaceYamlPath, 'utf-8');
175
- writeYaml = (content) => (0, node_fs_1.writeFileSync)(workspaceYamlPath, content, 'utf-8');
176
- }
177
- else {
178
- checkExists = () => treeOrRoot.exists('pnpm-workspace.yaml');
179
- readYaml = () => treeOrRoot.read('pnpm-workspace.yaml', 'utf-8');
180
- writeYaml = (content) => treeOrRoot.write('pnpm-workspace.yaml', content);
181
- }
182
- if (!checkExists()) {
183
- devkit_exports_1.output.warn({
184
- title: 'No pnpm-workspace.yaml found',
185
- bodyLines: [
186
- 'Cannot update catalog versions without a pnpm-workspace.yaml file.',
187
- 'Create a pnpm-workspace.yaml file to use catalogs.',
188
- ],
189
- });
190
- return;
191
- }
192
- try {
193
- const workspaceContent = readYaml();
194
- const workspaceData = (0, js_yaml_1.load)(workspaceContent) || {};
195
- let hasChanges = false;
196
- for (const update of updates) {
197
- const { packageName, version, catalogName } = update;
198
- let targetCatalog;
199
- if (catalogName) {
200
- // Named catalog
201
- workspaceData.catalogs ??= {};
202
- workspaceData.catalogs[catalogName] ??= {};
203
- targetCatalog = workspaceData.catalogs[catalogName];
204
- }
205
- else {
206
- // Default catalog
207
- workspaceData.catalog ??= {};
208
- targetCatalog = workspaceData.catalog;
209
- }
210
- if (targetCatalog[packageName] !== version) {
211
- targetCatalog[packageName] = version;
212
- hasChanges = true;
213
- }
214
- }
215
- if (hasChanges) {
216
- writeYaml((0, js_yaml_1.dump)(workspaceData, {
217
- indent: 2,
218
- quotingType: '"',
219
- forceQuotes: true,
220
- }));
221
- }
222
- }
223
- catch (error) {
224
- devkit_exports_1.output.error({
225
- title: 'Failed to update catalog versions',
226
- bodyLines: [error instanceof Error ? error.message : String(error)],
227
- });
228
- throw error;
229
- }
230
- }
231
- }
232
- exports.PnpmCatalogManager = PnpmCatalogManager;
233
- function readYamlFileFromFs(path) {
234
- try {
235
- return (0, devkit_internals_1.readYamlFile)(path);
236
- }
237
- catch (error) {
238
- devkit_exports_1.output.warn({
239
- title: 'Unable to parse pnpm-workspace.yaml',
240
- bodyLines: [error.toString()],
241
- });
242
- return null;
243
- }
244
- }
245
- function readYamlFileFromTree(tree, path) {
246
- const content = tree.read(path, 'utf-8');
247
- const { load } = require('@zkochan/js-yaml');
248
- try {
249
- return load(content, { filename: path });
250
- }
251
- catch (error) {
252
- devkit_exports_1.output.warn({
253
- title: 'Unable to parse pnpm-workspace.yaml',
254
- bodyLines: [error.toString()],
255
- });
256
- return null;
257
- }
258
- }
@@ -1,18 +0,0 @@
1
- export interface CatalogReference {
2
- catalogName?: string;
3
- isDefaultCatalog: boolean;
4
- }
5
- export declare enum CatalogErrorType {
6
- INVALID_SYNTAX = "INVALID_SYNTAX",
7
- WORKSPACE_NOT_FOUND = "WORKSPACE_NOT_FOUND",
8
- CATALOG_NOT_FOUND = "CATALOG_NOT_FOUND",
9
- PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND"
10
- }
11
- export interface CatalogError {
12
- type: CatalogErrorType;
13
- message: string;
14
- catalogName?: string;
15
- packageName?: string;
16
- suggestions?: string[];
17
- }
18
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/devkit/src/utils/catalog/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,oBAAY,gBAAgB;IAC1B,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatalogErrorType = void 0;
4
- var CatalogErrorType;
5
- (function (CatalogErrorType) {
6
- CatalogErrorType["INVALID_SYNTAX"] = "INVALID_SYNTAX";
7
- CatalogErrorType["WORKSPACE_NOT_FOUND"] = "WORKSPACE_NOT_FOUND";
8
- CatalogErrorType["CATALOG_NOT_FOUND"] = "CATALOG_NOT_FOUND";
9
- CatalogErrorType["PACKAGE_NOT_FOUND"] = "PACKAGE_NOT_FOUND";
10
- })(CatalogErrorType || (exports.CatalogErrorType = CatalogErrorType = {}));
@@ -1,38 +0,0 @@
1
- import type { Tree } from 'nx/src/devkit-exports';
2
- import type { PnpmWorkspaceYaml } from 'nx/src/utils/pnpm-workspace';
3
- import type { CatalogManager } from './manager';
4
- import type { CatalogError, CatalogReference } from './types';
5
- /**
6
- * Base catalog manager for package managers that don't support catalogs
7
- */
8
- declare abstract class UnsupportedCatalogManager implements CatalogManager {
9
- abstract readonly name: string;
10
- supportsCatalogs(): boolean;
11
- isCatalogReference(_version: string): boolean;
12
- parseCatalogReference(_version: string): CatalogReference | null;
13
- getCatalogDefinitions(_treeOrRoot: Tree | string): PnpmWorkspaceYaml | null;
14
- resolveCatalogReference(_treeOrRoot: Tree | string, _packageName: string, _version: string): string | null;
15
- validateCatalogReference(_treeOrRoot: Tree | string, _packageName: string, _version: string): {
16
- isValid: boolean;
17
- error?: CatalogError;
18
- };
19
- updateCatalogVersions(_treeOrRoot: Tree | string, _updates: Array<{
20
- packageName: string;
21
- version: string;
22
- catalogName?: string;
23
- }>): void;
24
- }
25
- export declare class YarnCatalogManager extends UnsupportedCatalogManager {
26
- readonly name = "yarn";
27
- }
28
- export declare class BunCatalogManager extends UnsupportedCatalogManager {
29
- readonly name = "bun";
30
- }
31
- export declare class NpmCatalogManager extends UnsupportedCatalogManager {
32
- readonly name = "npm";
33
- }
34
- export declare class UnknownCatalogManager extends UnsupportedCatalogManager {
35
- readonly name = "unknown";
36
- }
37
- export {};
38
- //# sourceMappingURL=unsupported-manager.d.ts.map