@nx/devkit 23.1.0 → 23.1.2

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 (36) hide show
  1. package/dist/internal.d.ts +3 -2
  2. package/dist/internal.js +139 -4
  3. package/dist/ngcli-adapter.d.ts +1 -1
  4. package/dist/ngcli-adapter.js +2 -1
  5. package/dist/src/generators/format-files.d.ts +3 -1
  6. package/dist/src/generators/format-files.js +14 -2
  7. package/dist/src/generators/plugin-migrations/executor-to-plugin-migrator.d.ts +1 -2
  8. package/dist/src/generators/plugin-migrations/executor-to-plugin-migrator.js +1 -2
  9. package/dist/src/generators/project-name-and-root-utils.js +13 -0
  10. package/dist/src/generators/visit-not-ignored-files.d.ts +7 -0
  11. package/dist/src/generators/visit-not-ignored-files.js +35 -10
  12. package/dist/src/utils/add-plugin.js +11 -4
  13. package/dist/src/utils/installed-version.d.ts +16 -3
  14. package/dist/src/utils/installed-version.js +29 -4
  15. package/dist/src/utils/invoke-nx-generator.js +7 -3
  16. package/dist/src/utils/nx-ignore-internals.d.ts +23 -0
  17. package/dist/src/utils/nx-ignore-internals.js +36 -0
  18. package/dist/src/utils/package-json.js +7 -2
  19. package/dist/src/utils/semver.js +2 -1
  20. package/dist/src/utils/version-floor.d.ts +16 -4
  21. package/dist/src/utils/version-floor.js +71 -5
  22. package/package.json +27 -5
  23. package/dist/src/utils/catalog/index.d.ts +0 -9
  24. package/dist/src/utils/catalog/index.js +0 -38
  25. package/dist/src/utils/catalog/manager-factory.d.ts +0 -5
  26. package/dist/src/utils/catalog/manager-factory.js +0 -20
  27. package/dist/src/utils/catalog/manager-utils.d.ts +0 -9
  28. package/dist/src/utils/catalog/manager-utils.js +0 -215
  29. package/dist/src/utils/catalog/manager.d.ts +0 -40
  30. package/dist/src/utils/catalog/manager.js +0 -13
  31. package/dist/src/utils/catalog/pnpm-manager.d.ts +0 -21
  32. package/dist/src/utils/catalog/pnpm-manager.js +0 -151
  33. package/dist/src/utils/catalog/types.d.ts +0 -11
  34. package/dist/src/utils/catalog/types.js +0 -2
  35. package/dist/src/utils/catalog/yarn-manager.d.ts +0 -21
  36. package/dist/src/utils/catalog/yarn-manager.js +0 -151
@@ -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;