nx 22.0.0-beta.4 → 22.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +5 -0
- package/package.json +11 -11
- package/release/changelog-renderer/index.d.ts +1 -0
- package/release/changelog-renderer/index.d.ts.map +1 -1
- package/release/changelog-renderer/index.js +46 -15
- package/schemas/nx-schema.json +165 -10
- package/src/command-line/init/implementation/angular/index.d.ts.map +1 -1
- package/src/command-line/init/implementation/angular/index.js +4 -6
- package/src/command-line/migrate/migrate.d.ts.map +1 -1
- package/src/command-line/migrate/migrate.js +25 -12
- package/src/command-line/nx-commands.js +1 -1
- package/src/command-line/release/changelog.d.ts.map +1 -1
- package/src/command-line/release/changelog.js +18 -18
- package/src/command-line/release/config/config.d.ts +6 -2
- package/src/command-line/release/config/config.d.ts.map +1 -1
- package/src/command-line/release/config/config.js +119 -70
- package/src/command-line/release/utils/git.d.ts +2 -2
- package/src/command-line/release/utils/git.d.ts.map +1 -1
- package/src/command-line/release/utils/git.js +5 -5
- package/src/command-line/release/utils/release-graph.d.ts +1 -1
- package/src/command-line/release/utils/release-graph.d.ts.map +1 -1
- package/src/command-line/release/utils/release-graph.js +6 -6
- package/src/command-line/release/utils/shared.js +11 -11
- package/src/command-line/release/version/release-group-processor.d.ts.map +1 -1
- package/src/command-line/release/version/release-group-processor.js +9 -1
- package/src/config/nx-json.d.ts +129 -70
- package/src/config/nx-json.d.ts.map +1 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.d.ts +4 -0
- package/src/daemon/client/client.d.ts.map +1 -1
- package/src/daemon/client/client.js +23 -0
- package/src/daemon/message-types/register-project-graph-listener.d.ts +6 -0
- package/src/daemon/message-types/register-project-graph-listener.d.ts.map +1 -0
- package/src/daemon/message-types/register-project-graph-listener.js +11 -0
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts +3 -1
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts.map +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +13 -5
- package/src/daemon/server/project-graph-listener-sockets.d.ts +8 -0
- package/src/daemon/server/project-graph-listener-sockets.d.ts.map +1 -0
- package/src/daemon/server/project-graph-listener-sockets.js +24 -0
- package/src/daemon/server/server.d.ts.map +1 -1
- package/src/daemon/server/server.js +9 -2
- package/src/devkit-internals.d.ts +1 -0
- package/src/devkit-internals.d.ts.map +1 -1
- package/src/devkit-internals.js +3 -1
- package/src/migrations/update-22-0-0/consolidate-release-tag-config.d.ts +3 -0
- package/src/migrations/update-22-0-0/consolidate-release-tag-config.d.ts.map +1 -0
- package/src/migrations/update-22-0-0/consolidate-release-tag-config.js +100 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/lock-file/lock-file.d.ts.map +1 -1
- package/src/plugins/js/lock-file/lock-file.js +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts.map +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.js +12 -4
- package/src/plugins/js/lock-file/project-graph-pruning.d.ts +2 -2
- package/src/plugins/js/lock-file/project-graph-pruning.d.ts.map +1 -1
- package/src/plugins/js/lock-file/project-graph-pruning.js +22 -9
- package/src/plugins/js/package-json/create-package-json.d.ts.map +1 -1
- package/src/plugins/js/package-json/create-package-json.js +17 -5
- package/src/tasks-runner/is-tui-enabled.d.ts.map +1 -1
- package/src/tasks-runner/is-tui-enabled.js +0 -1
- package/src/tasks-runner/run-command.d.ts.map +1 -1
- package/src/tasks-runner/run-command.js +3 -0
- package/src/utils/catalog/index.d.ts +10 -0
- package/src/utils/catalog/index.d.ts.map +1 -0
- package/src/utils/catalog/index.js +38 -0
- package/src/utils/catalog/manager-factory.d.ts +6 -0
- package/src/utils/catalog/manager-factory.d.ts.map +1 -0
- package/src/utils/catalog/manager-factory.js +17 -0
- package/src/utils/catalog/manager.d.ts +40 -0
- package/src/utils/catalog/manager.d.ts.map +1 -0
- package/src/utils/catalog/manager.js +2 -0
- package/src/utils/catalog/pnpm-manager.d.ts +22 -0
- package/src/utils/catalog/pnpm-manager.d.ts.map +1 -0
- package/src/utils/catalog/pnpm-manager.js +257 -0
- package/src/utils/catalog/types.d.ts +5 -0
- package/src/utils/catalog/types.d.ts.map +1 -0
- package/src/utils/catalog/types.js +2 -0
- package/src/utils/package-json.d.ts +79 -0
- package/src/utils/package-json.d.ts.map +1 -1
- package/src/utils/package-json.js +81 -2
- package/src/utils/package-manager.d.ts.map +1 -1
- package/src/utils/package-manager.js +24 -9
- package/src/utils/pnpm-workspace.d.ts +9 -0
- package/src/utils/pnpm-workspace.d.ts.map +1 -0
- package/src/utils/pnpm-workspace.js +2 -0
|
@@ -5,17 +5,19 @@ exports.findNodeMatchingVersion = findNodeMatchingVersion;
|
|
|
5
5
|
exports.addNodesAndDependencies = addNodesAndDependencies;
|
|
6
6
|
exports.rehoistNodes = rehoistNodes;
|
|
7
7
|
const semver_1 = require("semver");
|
|
8
|
-
const project_graph_builder_1 = require("../../../project-graph/project-graph-builder");
|
|
9
8
|
const operators_1 = require("../../../project-graph/operators");
|
|
9
|
+
const project_graph_builder_1 = require("../../../project-graph/project-graph-builder");
|
|
10
|
+
const catalog_1 = require("../../../utils/catalog");
|
|
11
|
+
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
10
12
|
const get_workspace_packages_from_graph_1 = require("../utils/get-workspace-packages-from-graph");
|
|
11
13
|
/**
|
|
12
14
|
* Prune project graph's external nodes and their dependencies
|
|
13
15
|
* based on the pruned package.json
|
|
14
16
|
*/
|
|
15
|
-
function pruneProjectGraph(graph, prunedPackageJson) {
|
|
17
|
+
function pruneProjectGraph(graph, prunedPackageJson, workspaceRootPath = workspace_root_1.workspaceRoot) {
|
|
16
18
|
const builder = new project_graph_builder_1.ProjectGraphBuilder();
|
|
17
19
|
const workspacePackages = (0, get_workspace_packages_from_graph_1.getWorkspacePackagesFromGraph)(graph);
|
|
18
|
-
const combinedDependencies = normalizeDependencies(prunedPackageJson, graph, workspacePackages);
|
|
20
|
+
const combinedDependencies = normalizeDependencies(prunedPackageJson, graph, workspacePackages, workspaceRootPath);
|
|
19
21
|
addNodesAndDependencies(graph, combinedDependencies, workspacePackages, builder);
|
|
20
22
|
for (const project of workspacePackages.values()) {
|
|
21
23
|
const node = graph.nodes[project.name];
|
|
@@ -28,7 +30,7 @@ function pruneProjectGraph(graph, prunedPackageJson) {
|
|
|
28
30
|
}
|
|
29
31
|
// ensure that dependency ranges from package.json (e.g. ^1.0.0)
|
|
30
32
|
// are replaced with the actual version based on the available nodes (e.g. 1.0.1)
|
|
31
|
-
function normalizeDependencies(packageJson, graph, workspacePackages) {
|
|
33
|
+
function normalizeDependencies(packageJson, graph, workspacePackages, workspaceRootPath) {
|
|
32
34
|
const { dependencies, devDependencies, optionalDependencies, peerDependencies, } = packageJson;
|
|
33
35
|
const combinedDependencies = {
|
|
34
36
|
...dependencies,
|
|
@@ -37,24 +39,35 @@ function normalizeDependencies(packageJson, graph, workspacePackages) {
|
|
|
37
39
|
...peerDependencies,
|
|
38
40
|
};
|
|
39
41
|
Object.entries(combinedDependencies).forEach(([packageName, versionRange]) => {
|
|
40
|
-
|
|
42
|
+
let resolvedVersionRange = versionRange;
|
|
43
|
+
const manager = (0, catalog_1.getCatalogManager)(workspaceRootPath);
|
|
44
|
+
if (manager?.isCatalogReference(versionRange)) {
|
|
45
|
+
const resolvedVersionRange = manager.resolveCatalogReference(packageName, versionRange, workspaceRootPath);
|
|
46
|
+
if (!resolvedVersionRange) {
|
|
47
|
+
throw new Error(`Could not resolve catalog reference for ${packageName}@${versionRange}.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (graph.externalNodes[`npm:${packageName}@${resolvedVersionRange}`]) {
|
|
51
|
+
combinedDependencies[packageName] = resolvedVersionRange;
|
|
41
52
|
return;
|
|
42
53
|
}
|
|
43
54
|
if (graph.externalNodes[`npm:${packageName}`] &&
|
|
44
|
-
graph.externalNodes[`npm:${packageName}`].data.version ===
|
|
55
|
+
graph.externalNodes[`npm:${packageName}`].data.version ===
|
|
56
|
+
resolvedVersionRange) {
|
|
57
|
+
combinedDependencies[packageName] = resolvedVersionRange;
|
|
45
58
|
return;
|
|
46
59
|
}
|
|
47
60
|
// otherwise we need to find the correct version
|
|
48
|
-
const node = findNodeMatchingVersion(graph, packageName,
|
|
61
|
+
const node = findNodeMatchingVersion(graph, packageName, resolvedVersionRange);
|
|
49
62
|
if (node) {
|
|
50
63
|
combinedDependencies[packageName] = node.data.version;
|
|
51
64
|
}
|
|
52
65
|
else if (workspacePackages.has(packageName)) {
|
|
53
66
|
// workspace module, leave as is
|
|
54
|
-
combinedDependencies[packageName] =
|
|
67
|
+
combinedDependencies[packageName] = resolvedVersionRange;
|
|
55
68
|
}
|
|
56
69
|
else {
|
|
57
|
-
throw new Error(`Pruned lock file creation failed. The following package was not found in the root lock file: ${packageName}@${
|
|
70
|
+
throw new Error(`Pruned lock file creation failed. The following package was not found in the root lock file: ${packageName}@${resolvedVersionRange}`);
|
|
58
71
|
}
|
|
59
72
|
});
|
|
60
73
|
return combinedDependencies;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-package-json.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/package-json/create-package-json.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"create-package-json.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/plugins/js/package-json/create-package-json.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,WAAW,EACZ,MAAM,6BAA6B,CAAC;AAYrC,UAAU,OAAO;IACf,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACtE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACpB,EACN,OAAO,GAAE,cAAqB,GAC7B,WAAW,CA6Mb;AAED,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,uBAAuB,EACpC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,WAAW,EAC5B,OAAO,EAAE;IACP,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,EACD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CA8CT"}
|
|
@@ -5,6 +5,7 @@ exports.findProjectsNpmDependencies = findProjectsNpmDependencies;
|
|
|
5
5
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
6
6
|
const object_sort_1 = require("../../../utils/object-sort");
|
|
7
7
|
const project_graph_1 = require("../../../config/project-graph");
|
|
8
|
+
const package_json_1 = require("../../../utils/package-json");
|
|
8
9
|
const fs_1 = require("fs");
|
|
9
10
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
10
11
|
const configuration_1 = require("../../../config/configuration");
|
|
@@ -21,7 +22,8 @@ const output_1 = require("../../../utils/output");
|
|
|
21
22
|
function createPackageJson(projectName, graph, options = {}, fileMap = null) {
|
|
22
23
|
const projectNode = graph.nodes[projectName];
|
|
23
24
|
const isLibrary = projectNode.type === 'lib';
|
|
24
|
-
const
|
|
25
|
+
const root = options.root ?? workspace_root_1.workspaceRoot;
|
|
26
|
+
const rootPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
|
|
25
27
|
const npmDeps = findProjectsNpmDependencies(projectNode, graph, options.target, rootPackageJson, {
|
|
26
28
|
helperDependencies: options.helperDependencies,
|
|
27
29
|
isProduction: options.isProduction,
|
|
@@ -31,7 +33,7 @@ function createPackageJson(projectName, graph, options = {}, fileMap = null) {
|
|
|
31
33
|
name: projectName,
|
|
32
34
|
version: '0.0.1',
|
|
33
35
|
};
|
|
34
|
-
const projectPackageJsonPath = (0, path_1.join)(
|
|
36
|
+
const projectPackageJsonPath = (0, path_1.join)(root, projectNode.data.root, 'package.json');
|
|
35
37
|
if ((0, fs_1.existsSync)(projectPackageJsonPath)) {
|
|
36
38
|
try {
|
|
37
39
|
packageJson = (0, fileutils_1.readJsonFile)(projectPackageJsonPath);
|
|
@@ -55,9 +57,19 @@ function createPackageJson(projectName, graph, options = {}, fileMap = null) {
|
|
|
55
57
|
catch (e) { }
|
|
56
58
|
}
|
|
57
59
|
const getVersion = (packageName, version, section) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
// Try project package.json first (single section)
|
|
61
|
+
const projectVersion = (0, package_json_1.getDependencyVersionFromPackageJson)(packageName, root, packageJson, [section]);
|
|
62
|
+
if (projectVersion) {
|
|
63
|
+
return projectVersion;
|
|
64
|
+
}
|
|
65
|
+
// For libraries, fall back to root package.json (single section)
|
|
66
|
+
if (isLibrary) {
|
|
67
|
+
const rootVersion = (0, package_json_1.getDependencyVersionFromPackageJson)(packageName, root, rootPackageJson, [section]);
|
|
68
|
+
if (rootVersion) {
|
|
69
|
+
return rootVersion;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return version;
|
|
61
73
|
};
|
|
62
74
|
Object.entries(npmDeps.dependencies).forEach(([packageName, version]) => {
|
|
63
75
|
if (rootPackageJson.devDependencies?.[packageName] &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-tui-enabled.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/tasks-runner/is-tui-enabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"is-tui-enabled.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/tasks-runner/is-tui-enabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAIrD;;GAEG;AACH,wBAAgB,YAAY,YAE3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,mBAAmB,UAAsD,WA8D1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/tasks-runner/run-command.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EAGpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAa/E,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAkBrD,OAAO,EA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AAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,EAC3C,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,OAAO,GACtB,GAAG,CAsDL"}
|
|
@@ -50,6 +50,9 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
|
50
50
|
const overridesWithoutHidden = { ...overrides };
|
|
51
51
|
delete overridesWithoutHidden['__overrides_unparsed__'];
|
|
52
52
|
const isRunOne = initiatingProject != null;
|
|
53
|
+
if (tasks.length === 1) {
|
|
54
|
+
process.env.NX_TUI = 'false';
|
|
55
|
+
}
|
|
53
56
|
if ((0, is_tui_enabled_1.isTuiEnabled)()) {
|
|
54
57
|
const interceptedNxCloudLogs = [];
|
|
55
58
|
const createPatchedConsoleMethod = (originalMethod) => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Tree } from '../../generators/tree';
|
|
2
|
+
import type { CatalogManager } from './manager';
|
|
3
|
+
import { getCatalogManager } from './manager-factory';
|
|
4
|
+
export { 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>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/utils/catalog/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,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,CA+BjC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCatalogManager = void 0;
|
|
4
|
+
exports.getCatalogDependenciesFromPackageJson = getCatalogDependenciesFromPackageJson;
|
|
5
|
+
const json_1 = require("../../generators/utils/json");
|
|
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, json_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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
6
|
+
//# sourceMappingURL=manager-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager-factory.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/utils/catalog/manager-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGhD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,GACpB,cAAc,GAAG,IAAI,CASvB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCatalogManager = getCatalogManager;
|
|
4
|
+
const package_manager_1 = require("../package-manager");
|
|
5
|
+
const pnpm_manager_1 = require("./pnpm-manager");
|
|
6
|
+
/**
|
|
7
|
+
* Factory function to get the appropriate catalog manager based on the package manager
|
|
8
|
+
*/
|
|
9
|
+
function getCatalogManager(workspaceRoot) {
|
|
10
|
+
const packageManager = (0, package_manager_1.detectPackageManager)(workspaceRoot);
|
|
11
|
+
switch (packageManager) {
|
|
12
|
+
case 'pnpm':
|
|
13
|
+
return new pnpm_manager_1.PnpmCatalogManager();
|
|
14
|
+
default:
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Tree } from '../../generators/tree';
|
|
2
|
+
import type { PnpmWorkspaceYaml } from '../pnpm-workspace';
|
|
3
|
+
import type { 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
|
+
isCatalogReference(version: string): boolean;
|
|
10
|
+
parseCatalogReference(version: string): CatalogReference | null;
|
|
11
|
+
/**
|
|
12
|
+
* Get catalog definitions from the workspace.
|
|
13
|
+
*/
|
|
14
|
+
getCatalogDefinitions(workspaceRoot: string): PnpmWorkspaceYaml | null;
|
|
15
|
+
getCatalogDefinitions(tree: Tree): PnpmWorkspaceYaml | null;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a catalog reference to an actual version.
|
|
18
|
+
*/
|
|
19
|
+
resolveCatalogReference(workspaceRoot: string, packageName: string, version: string): string | null;
|
|
20
|
+
resolveCatalogReference(tree: Tree, packageName: string, version: string): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Check that a catalog reference is valid.
|
|
23
|
+
*/
|
|
24
|
+
validateCatalogReference(workspaceRoot: string, packageName: string, version: string): void;
|
|
25
|
+
validateCatalogReference(tree: Tree, packageName: string, version: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Updates catalog definitions for specified packages in their respective catalogs.
|
|
28
|
+
*/
|
|
29
|
+
updateCatalogVersions(tree: Tree, updates: Array<{
|
|
30
|
+
packageName: string;
|
|
31
|
+
version: string;
|
|
32
|
+
catalogName?: string;
|
|
33
|
+
}>): void;
|
|
34
|
+
updateCatalogVersions(workspaceRoot: string, updates: Array<{
|
|
35
|
+
packageName: string;
|
|
36
|
+
version: string;
|
|
37
|
+
catalogName?: string;
|
|
38
|
+
}>): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/utils/catalog/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EA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CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,GACD,IAAI,CAAC;CACT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Tree } from '../../generators/tree';
|
|
2
|
+
import type { PnpmWorkspaceYaml } from '../pnpm-workspace';
|
|
3
|
+
import type { CatalogManager } from './manager';
|
|
4
|
+
import 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
|
+
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): void;
|
|
16
|
+
updateCatalogVersions(treeOrRoot: Tree | string, updates: Array<{
|
|
17
|
+
packageName: string;
|
|
18
|
+
version: string;
|
|
19
|
+
catalogName?: string;
|
|
20
|
+
}>): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=pnpm-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnpm-manager.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/utils/catalog/pnpm-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACvD,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,eAAe,cAAc;IAEtC,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAI5C,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAe/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;IAuBhB,wBAAwB,CACtB,UAAU,EAAE,IAAI,GAAG,MAAM,EACzB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,IAAI;IA0HP,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;CAgFR"}
|
|
@@ -0,0 +1,257 @@
|
|
|
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 fileutils_1 = require("../fileutils");
|
|
8
|
+
const output_1 = require("../output");
|
|
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
|
+
getCatalogDefinitions(treeOrRoot) {
|
|
33
|
+
if (typeof treeOrRoot === 'string') {
|
|
34
|
+
const pnpmWorkspacePath = (0, node_path_1.join)(treeOrRoot, 'pnpm-workspace.yaml');
|
|
35
|
+
if (!(0, node_fs_1.existsSync)(pnpmWorkspacePath)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return readYamlFileFromFs(pnpmWorkspacePath);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (!treeOrRoot.exists('pnpm-workspace.yaml')) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return readYamlFileFromTree(treeOrRoot, 'pnpm-workspace.yaml');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
resolveCatalogReference(treeOrRoot, packageName, version) {
|
|
48
|
+
const catalogRef = this.parseCatalogReference(version);
|
|
49
|
+
if (!catalogRef) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const workspaceConfig = this.getCatalogDefinitions(treeOrRoot);
|
|
53
|
+
if (!workspaceConfig) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
let catalogToUse;
|
|
57
|
+
if (catalogRef.isDefaultCatalog) {
|
|
58
|
+
// Check both locations for default catalog
|
|
59
|
+
catalogToUse =
|
|
60
|
+
workspaceConfig.catalog ?? workspaceConfig.catalogs?.default;
|
|
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
|
+
throw new Error(`Invalid catalog reference syntax: "${version}". Expected format: "catalog:" or "catalog:name"`);
|
|
71
|
+
}
|
|
72
|
+
const workspaceConfig = this.getCatalogDefinitions(treeOrRoot);
|
|
73
|
+
if (!workspaceConfig) {
|
|
74
|
+
throw new Error(formatCatalogError('Cannot get Pnpm catalog definitions. No pnpm-workspace.yaml found in workspace root.', ['Create a pnpm-workspace.yaml file in your workspace root']));
|
|
75
|
+
}
|
|
76
|
+
let catalogToUse;
|
|
77
|
+
if (catalogRef.isDefaultCatalog) {
|
|
78
|
+
const hasCatalog = !!workspaceConfig.catalog;
|
|
79
|
+
const hasCatalogsDefault = !!workspaceConfig.catalogs?.default;
|
|
80
|
+
// Error if both defined (matches pnpm behavior)
|
|
81
|
+
if (hasCatalog && hasCatalogsDefault) {
|
|
82
|
+
throw new Error("The 'default' catalog was defined multiple times. Use the 'catalog' field or 'catalogs.default', but not both.");
|
|
83
|
+
}
|
|
84
|
+
catalogToUse =
|
|
85
|
+
workspaceConfig.catalog ?? workspaceConfig.catalogs?.default;
|
|
86
|
+
if (!catalogToUse) {
|
|
87
|
+
const availableCatalogs = Object.keys(workspaceConfig.catalogs || {});
|
|
88
|
+
const suggestions = [
|
|
89
|
+
'Define a default catalog in pnpm-workspace.yaml under the "catalog" key',
|
|
90
|
+
];
|
|
91
|
+
if (availableCatalogs.length > 0) {
|
|
92
|
+
suggestions.push(`Or select from the available named catalogs: ${availableCatalogs
|
|
93
|
+
.map((c) => `"catalog:${c}"`)
|
|
94
|
+
.join(', ')}`);
|
|
95
|
+
}
|
|
96
|
+
throw new Error(formatCatalogError('No default catalog defined in pnpm-workspace.yaml', suggestions));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (catalogRef.catalogName) {
|
|
100
|
+
catalogToUse = workspaceConfig.catalogs?.[catalogRef.catalogName];
|
|
101
|
+
if (!catalogToUse) {
|
|
102
|
+
const availableCatalogs = Object.keys(workspaceConfig.catalogs || {}).filter((c) => c !== 'default');
|
|
103
|
+
const defaultCatalog = !!workspaceConfig.catalog
|
|
104
|
+
? 'catalog'
|
|
105
|
+
: !workspaceConfig.catalogs?.default
|
|
106
|
+
? 'catalogs.default'
|
|
107
|
+
: null;
|
|
108
|
+
const suggestions = [
|
|
109
|
+
'Define the catalog in pnpm-workspace.yaml under the "catalogs" key',
|
|
110
|
+
];
|
|
111
|
+
if (availableCatalogs.length > 0) {
|
|
112
|
+
suggestions.push(`Or select from the available named catalogs: ${availableCatalogs
|
|
113
|
+
.map((c) => `"catalog:${c}"`)
|
|
114
|
+
.join(', ')}`);
|
|
115
|
+
}
|
|
116
|
+
if (defaultCatalog) {
|
|
117
|
+
suggestions.push(`Or use the default catalog ("${defaultCatalog}")`);
|
|
118
|
+
}
|
|
119
|
+
throw new Error(formatCatalogError(`Catalog "${catalogRef.catalogName}" not found in pnpm-workspace.yaml`, suggestions));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!catalogToUse[packageName]) {
|
|
123
|
+
let catalogName;
|
|
124
|
+
if (catalogRef.isDefaultCatalog) {
|
|
125
|
+
// Context-aware messaging based on which location exists
|
|
126
|
+
const hasCatalog = !!workspaceConfig.catalog;
|
|
127
|
+
catalogName = hasCatalog
|
|
128
|
+
? 'default catalog ("catalog")'
|
|
129
|
+
: 'default catalog ("catalogs.default")';
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
catalogName = `catalog '${catalogRef.catalogName}'`;
|
|
133
|
+
}
|
|
134
|
+
const availablePackages = Object.keys(catalogToUse);
|
|
135
|
+
const suggestions = [
|
|
136
|
+
`Add "${packageName}" to ${catalogName} in pnpm-workspace.yaml`,
|
|
137
|
+
];
|
|
138
|
+
if (availablePackages.length > 0) {
|
|
139
|
+
suggestions.push(`Or select from the available packages in ${catalogName}: ${availablePackages
|
|
140
|
+
.map((p) => `"${p}"`)
|
|
141
|
+
.join(', ')}`);
|
|
142
|
+
}
|
|
143
|
+
throw new Error(formatCatalogError(`Package "${packageName}" not found in ${catalogName}`, suggestions));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
updateCatalogVersions(treeOrRoot, updates) {
|
|
147
|
+
let checkExists;
|
|
148
|
+
let readYaml;
|
|
149
|
+
let writeYaml;
|
|
150
|
+
if (typeof treeOrRoot === 'string') {
|
|
151
|
+
const workspaceYamlPath = (0, node_path_1.join)(treeOrRoot, 'pnpm-workspace.yaml');
|
|
152
|
+
checkExists = () => (0, node_fs_1.existsSync)(workspaceYamlPath);
|
|
153
|
+
readYaml = () => (0, node_fs_1.readFileSync)(workspaceYamlPath, 'utf-8');
|
|
154
|
+
writeYaml = (content) => (0, node_fs_1.writeFileSync)(workspaceYamlPath, content, 'utf-8');
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
checkExists = () => treeOrRoot.exists('pnpm-workspace.yaml');
|
|
158
|
+
readYaml = () => treeOrRoot.read('pnpm-workspace.yaml', 'utf-8');
|
|
159
|
+
writeYaml = (content) => treeOrRoot.write('pnpm-workspace.yaml', content);
|
|
160
|
+
}
|
|
161
|
+
if (!checkExists()) {
|
|
162
|
+
output_1.output.warn({
|
|
163
|
+
title: 'No pnpm-workspace.yaml found',
|
|
164
|
+
bodyLines: [
|
|
165
|
+
'Cannot update catalog versions without a pnpm-workspace.yaml file.',
|
|
166
|
+
'Create a pnpm-workspace.yaml file to use catalogs.',
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const workspaceContent = readYaml();
|
|
173
|
+
const workspaceData = (0, js_yaml_1.load)(workspaceContent) || {};
|
|
174
|
+
let hasChanges = false;
|
|
175
|
+
for (const update of updates) {
|
|
176
|
+
const { packageName, version, catalogName } = update;
|
|
177
|
+
const normalizedCatalogName = catalogName === 'default' ? undefined : catalogName;
|
|
178
|
+
let targetCatalog;
|
|
179
|
+
if (!normalizedCatalogName) {
|
|
180
|
+
// Default catalog - update whichever exists, prefer catalog over catalogs.default
|
|
181
|
+
if (workspaceData.catalog) {
|
|
182
|
+
targetCatalog = workspaceData.catalog;
|
|
183
|
+
}
|
|
184
|
+
else if (workspaceData.catalogs?.default) {
|
|
185
|
+
targetCatalog = workspaceData.catalogs.default;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// Neither exists, create catalog (shorthand syntax)
|
|
189
|
+
workspaceData.catalog ??= {};
|
|
190
|
+
targetCatalog = workspaceData.catalog;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// Named catalog
|
|
195
|
+
workspaceData.catalogs ??= {};
|
|
196
|
+
workspaceData.catalogs[normalizedCatalogName] ??= {};
|
|
197
|
+
targetCatalog = workspaceData.catalogs[normalizedCatalogName];
|
|
198
|
+
}
|
|
199
|
+
if (targetCatalog[packageName] !== version) {
|
|
200
|
+
targetCatalog[packageName] = version;
|
|
201
|
+
hasChanges = true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (hasChanges) {
|
|
205
|
+
writeYaml((0, js_yaml_1.dump)(workspaceData, {
|
|
206
|
+
indent: 2,
|
|
207
|
+
quotingType: '"',
|
|
208
|
+
forceQuotes: true,
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
output_1.output.error({
|
|
214
|
+
title: 'Failed to update catalog versions',
|
|
215
|
+
bodyLines: [error instanceof Error ? error.message : String(error)],
|
|
216
|
+
});
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.PnpmCatalogManager = PnpmCatalogManager;
|
|
222
|
+
function readYamlFileFromFs(path) {
|
|
223
|
+
try {
|
|
224
|
+
return (0, fileutils_1.readYamlFile)(path);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
output_1.output.warn({
|
|
228
|
+
title: 'Unable to parse pnpm-workspace.yaml',
|
|
229
|
+
bodyLines: [error.toString()],
|
|
230
|
+
});
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function readYamlFileFromTree(tree, path) {
|
|
235
|
+
const content = tree.read(path, 'utf-8');
|
|
236
|
+
const { load } = require('@zkochan/js-yaml');
|
|
237
|
+
try {
|
|
238
|
+
return load(content, { filename: path });
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
output_1.output.warn({
|
|
242
|
+
title: 'Unable to parse pnpm-workspace.yaml',
|
|
243
|
+
bodyLines: [error.toString()],
|
|
244
|
+
});
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function formatCatalogError(error, suggestions) {
|
|
249
|
+
let message = error;
|
|
250
|
+
if (suggestions && suggestions.length > 0) {
|
|
251
|
+
message += '\n\nSuggestions:';
|
|
252
|
+
suggestions.forEach((suggestion) => {
|
|
253
|
+
message += `\n • ${suggestion}`;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
return message;
|
|
257
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/utils/catalog/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;CAC3B"}
|