@aws/nx-plugin 1.0.0-rc.54 → 1.0.0-rc.55
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 +45 -0
- package/package.json +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.js +3 -1
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/generator.d.ts +49 -1
- package/src/agentcore-gateway/generator.js +55 -22
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.js +3 -1
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/infra/app/generator.d.ts +43 -0
- package/src/infra/app/generator.js +47 -18
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +13 -0
- package/src/init/generator.js +14 -3
- package/src/init/generator.js.map +1 -1
- package/src/migrations/latest/backfill-generator-metadata/migration.d.ts +96 -0
- package/src/migrations/latest/backfill-generator-metadata/migration.js +670 -0
- package/src/migrations/latest/backfill-generator-metadata/migration.js.map +1 -0
- package/src/preset/generator.d.ts +13 -0
- package/src/preset/generator.js +12 -3
- package/src/preset/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/generator.d.ts +24 -0
- package/src/py/agent/a2a-connection/generator.js +49 -20
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +23 -0
- package/src/py/agent/gateway-connection/generator.js +45 -11
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/generator.d.ts +146 -1
- package/src/py/agent/generator.js +173 -76
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +23 -0
- package/src/py/agent/mcp-connection/generator.js +45 -11
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/generator.d.ts +146 -0
- package/src/py/agent/react-connection/generator.js +27 -4
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/dynamodb/agent-connection/generator.js +7 -1
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/fast-api-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/py/dynamodb/fast-api-connection/generator.js +3 -1
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/generator.d.ts +29 -0
- package/src/py/dynamodb/generator.js +32 -12
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/dynamodb/mcp-server-connection/generator.js +7 -1
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/fast-api/generator.d.ts +63 -0
- package/src/py/fast-api/generator.js +58 -23
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +16 -1
- package/src/py/fast-api/react/generator.js +15 -3
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/lambda-function/generator.d.ts +21 -0
- package/src/py/lambda-function/generator.js +29 -10
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/mcp-server/generator.d.ts +60 -0
- package/src/py/mcp-server/generator.js +62 -25
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/project/generator.d.ts +13 -0
- package/src/py/project/generator.js +29 -10
- package/src/py/project/generator.js.map +1 -1
- package/src/py/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +19 -0
- package/src/py/rdb/agent-connection/generator.js +7 -1
- package/src/py/rdb/agent-connection/generator.js.map +1 -1
- package/src/py/rdb/fast-api-connection/__snapshots__/generator.spec.ts.snap +7 -0
- package/src/py/rdb/fast-api-connection/generator.js +3 -1
- package/src/py/rdb/fast-api-connection/generator.js.map +1 -1
- package/src/py/rdb/generator.d.ts +89 -0
- package/src/py/rdb/generator.js +88 -40
- package/src/py/rdb/generator.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/rdb/mcp-server-connection/generator.js +7 -1
- package/src/py/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/smithy/project/generator.d.ts +7 -0
- package/src/smithy/project/generator.js +8 -2
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.d.ts +15 -0
- package/src/smithy/react-connection/generator.js +17 -3
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/smithy/ts/api/generator.d.ts +79 -0
- package/src/smithy/ts/api/generator.js +77 -33
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/terraform/project/generator.d.ts +50 -0
- package/src/terraform/project/generator.js +63 -17
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/generator.d.ts +84 -0
- package/src/trpc/backend/generator.js +98 -38
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/react/generator.d.ts +37 -0
- package/src/trpc/react/generator.js +63 -26
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +46 -0
- package/src/ts/agent/a2a-connection/generator.js +53 -16
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +37 -0
- package/src/ts/agent/gateway-connection/generator.js +41 -14
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.d.ts +162 -0
- package/src/ts/agent/generator.js +166 -75
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +37 -0
- package/src/ts/agent/mcp-connection/generator.js +41 -14
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +186 -0
- package/src/ts/agent/react-connection/generator.js +70 -21
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/astro-docs/generator.d.ts +38 -0
- package/src/ts/astro-docs/generator.js +58 -19
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +24 -0
- package/src/ts/dcr-proxy/generator.js +31 -14
- package/src/ts/dcr-proxy/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/ts/dynamodb/agent-connection/generator.js +7 -1
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/generator.d.ts +41 -0
- package/src/ts/dynamodb/generator.js +47 -20
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/ts/dynamodb/mcp-server-connection/generator.js +7 -1
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/smithy-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/dynamodb/smithy-connection/generator.js +3 -1
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/dynamodb/trpc-connection/generator.js +3 -1
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
- package/src/ts/lambda-function/generator.d.ts +38 -0
- package/src/ts/lambda-function/generator.js +49 -20
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lib/generator.d.ts +7 -0
- package/src/ts/lib/generator.js +8 -1
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.d.ts +3 -1
- package/src/ts/lib/ts-project-utils.js +3 -2
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +10 -1
- package/src/ts/lib/vitest.js +14 -2
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/generator.d.ts +71 -0
- package/src/ts/mcp-server/generator.js +73 -36
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/generator.d.ts +3 -0
- package/src/ts/nx-generator/generator.js +8 -2
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-migration/generator.d.ts +3 -0
- package/src/ts/nx-migration/generator.js +8 -2
- package/src/ts/nx-migration/generator.js.map +1 -1
- package/src/ts/nx-plugin/generator.d.ts +3 -0
- package/src/ts/nx-plugin/generator.js +8 -2
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.d.ts +7 -2
- package/src/ts/nx-plugin/utils.js +10 -4
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/ts/rdb/agent-connection/generator.js +8 -1
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/generator.d.ts +101 -0
- package/src/ts/rdb/generator.js +93 -41
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/ts/rdb/mcp-server-connection/generator.js +8 -1
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/smithy-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/rdb/smithy-connection/generator.js +4 -1
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/rdb/trpc-connection/generator.js +3 -1
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/react-website/agui/generator.d.ts +86 -0
- package/src/ts/react-website/agui/generator.js +63 -28
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +8 -2
- package/src/ts/react-website/app/generator.d.ts +136 -1
- package/src/ts/react-website/app/generator.js +109 -40
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/generator.d.ts +19 -0
- package/src/ts/react-website/cognito-auth/generator.js +21 -9
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/utils/add-dependencies.d.ts +38 -0
- package/src/utils/add-dependencies.js +83 -0
- package/src/utils/add-dependencies.js.map +1 -0
- package/src/utils/agent-connection/agent-connection.d.ts +27 -6
- package/src/utils/agent-connection/agent-connection.js +47 -18
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +19 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js +26 -6
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/api-constructs/api-constructs.d.ts +21 -2
- package/src/utils/api-constructs/api-constructs.js +26 -5
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/bundle/bundle.d.ts +6 -1
- package/src/utils/bundle/bundle.js +8 -2
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/commands.d.ts +5 -4
- package/src/utils/commands.js +2 -6
- package/src/utils/commands.js.map +1 -1
- package/src/utils/connection/open-api/react.d.ts +18 -1
- package/src/utils/connection/open-api/react.js +27 -3
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/declared-dependencies.d.ts +140 -0
- package/src/utils/declared-dependencies.js +64 -0
- package/src/utils/declared-dependencies.js.map +1 -0
- package/src/utils/docker.d.ts +10 -1
- package/src/utils/docker.js +7 -3
- package/src/utils/docker.js.map +1 -1
- package/src/utils/fs.d.ts +15 -4
- package/src/utils/fs.js +26 -13
- package/src/utils/fs.js.map +1 -1
- package/src/utils/init.d.ts +14 -1
- package/src/utils/init.js +25 -7
- package/src/utils/init.js.map +1 -1
- package/src/utils/migration-versions.d.ts +15 -1
- package/src/utils/migration-versions.js +53 -7
- package/src/utils/migration-versions.js.map +1 -1
- package/src/utils/nx.d.ts +18 -0
- package/src/utils/nx.js +4 -0
- package/src/utils/nx.js.map +1 -1
- package/src/utils/py.d.ts +3 -2
- package/src/utils/py.js +10 -10
- package/src/utils/py.js.map +1 -1
- package/src/utils/shared-constructs-constants.d.ts +39 -4
- package/src/utils/shared-constructs-constants.js +29 -0
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +4 -1
- package/src/utils/shared-constructs.js +5 -4
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.d.ts +8 -1
- package/src/utils/shared-dynamodb-scripts.js +11 -3
- package/src/utils/shared-dynamodb-scripts.js.map +1 -1
- package/src/utils/shared-infra-scripts.d.ts +16 -1
- package/src/utils/shared-infra-scripts.js +18 -3
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-rdb-scripts.d.ts +12 -1
- package/src/utils/shared-rdb-scripts.js +17 -3
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.d.ts +26 -1
- package/src/utils/shared-shadcn.js +31 -14
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/version-upgrade-migration/migration.d.ts +14 -0
- package/src/utils/version-upgrade-migration/migration.js +16 -0
- package/src/utils/version-upgrade-migration/migration.js.map +1 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.d.ts +35 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js +42 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +50 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js +98 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -0
- package/src/utils/version-upgrade-migration/register.d.ts +18 -0
- package/src/utils/version-upgrade-migration/register.js +33 -0
- package/src/utils/version-upgrade-migration/register.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.d.ts +13 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.js +33 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.d.ts +10 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js +504 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.d.ts +14 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.js +40 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.js.map +1 -0
- package/src/utils/versions.d.ts +25 -5
- package/src/utils/versions.js +46 -4
- package/src/utils/versions.js.map +1 -1
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { type Tree } from '@nx/devkit';
|
|
6
|
+
import type { DependencyDeclaration, MustDeclare } from './declared-dependencies';
|
|
7
|
+
/** Dependencies a caller must declare to use the shared RDB scripts. */
|
|
8
|
+
export declare const SHARED_RDB_SCRIPTS_DEPENDENCIES: readonly [{
|
|
9
|
+
readonly name: "pg";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "@types/pg";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "mariadb";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "tsx";
|
|
16
|
+
}];
|
|
6
17
|
/**
|
|
7
18
|
* Ensures the shared scripts package exists and adds RDB local-dev scripts
|
|
8
19
|
* to packages/common/scripts/src/rdb/. Used by ts#rdb.
|
|
@@ -13,4 +24,4 @@ import { type Tree } from '@nx/devkit';
|
|
|
13
24
|
* The engine-specific file names allow postgres and mysql projects to
|
|
14
25
|
* coexist in the same workspace.
|
|
15
26
|
*/
|
|
16
|
-
export declare function sharedRdbScriptsGenerator(tree: Tree, engine: 'postgres' | 'mysql'): Promise<void>;
|
|
27
|
+
export declare function sharedRdbScriptsGenerator<const D extends DependencyDeclaration>(tree: Tree, engine: 'postgres' | 'mysql', declaration: D & MustDeclare<typeof SHARED_RDB_SCRIPTS_DEPENDENCIES, D>): Promise<void>;
|
|
@@ -6,6 +6,20 @@ import { addDependenciesToPackageJson } from "./dependencies.js";
|
|
|
6
6
|
import { PACKAGES_DIR, SHARED_SCRIPTS_DIR } from "./shared-constructs-constants.js";
|
|
7
7
|
import { ensureSharedScriptsProject } from "./shared-scripts.js";
|
|
8
8
|
import { withVersions } from "./versions.js";
|
|
9
|
+
/** Dependencies a caller must declare to use the shared RDB scripts. */ export const SHARED_RDB_SCRIPTS_DEPENDENCIES = [
|
|
10
|
+
{
|
|
11
|
+
name: 'pg'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: '@types/pg'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'mariadb'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'tsx'
|
|
21
|
+
}
|
|
22
|
+
];
|
|
9
23
|
/**
|
|
10
24
|
* Ensures the shared scripts package exists and adds RDB local-dev scripts
|
|
11
25
|
* to packages/common/scripts/src/rdb/. Used by ts#rdb.
|
|
@@ -15,7 +29,7 @@ import { withVersions } from "./versions.js";
|
|
|
15
29
|
* projects do not reference database client packages they don't install.
|
|
16
30
|
* The engine-specific file names allow postgres and mysql projects to
|
|
17
31
|
* coexist in the same workspace.
|
|
18
|
-
*/ export async function sharedRdbScriptsGenerator(tree, engine) {
|
|
32
|
+
*/ export async function sharedRdbScriptsGenerator(tree, engine, declaration) {
|
|
19
33
|
await ensureSharedScriptsProject(tree);
|
|
20
34
|
const rdbScriptsDir = joinPathFragments(import.meta.dirname, 'files', SHARED_SCRIPTS_DIR, 'src', 'rdb');
|
|
21
35
|
const targetDir = joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb');
|
|
@@ -36,8 +50,8 @@ import { withVersions } from "./versions.js";
|
|
|
36
50
|
const clientDevDeps = engine === 'postgres' ? [
|
|
37
51
|
'@types/pg'
|
|
38
52
|
] : [];
|
|
39
|
-
addDependenciesToPackageJson(tree, withVersions(clientDeps), withVersions(clientDevDeps), joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'package.json'));
|
|
40
|
-
addDependenciesToPackageJson(tree, {}, withVersions([
|
|
53
|
+
addDependenciesToPackageJson(tree, withVersions(declaration, clientDeps), withVersions(declaration, clientDevDeps), joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'package.json'));
|
|
54
|
+
addDependenciesToPackageJson(tree, {}, withVersions(declaration, [
|
|
41
55
|
'tsx'
|
|
42
56
|
]));
|
|
43
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/shared-rdb-scripts.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n} from '@nx/devkit';\nimport { addDependenciesToPackageJson } from './dependencies';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from './shared-constructs-constants';\nimport { ensureSharedScriptsProject } from './shared-scripts';\nimport { type ITsDepVersion, withVersions } from './versions';\n\n/**\n * Ensures the shared scripts package exists and adds RDB local-dev scripts\n * to packages/common/scripts/src/rdb/. Used by ts#rdb.\n *\n * Engine-agnostic scripts (pull-image, start-container) are always vended.\n * Only the wait-for-db script for the requested engine is vended so that\n * projects do not reference database client packages they don't install.\n * The engine-specific file names allow postgres and mysql projects to\n * coexist in the same workspace.\n */\nexport async function sharedRdbScriptsGenerator(\n tree: Tree,\n engine: 'postgres' | 'mysql',\n): Promise<void> {\n await ensureSharedScriptsProject(tree);\n\n const rdbScriptsDir = joinPathFragments(\n import.meta.dirname,\n 'files',\n SHARED_SCRIPTS_DIR,\n 'src',\n 'rdb',\n );\n const targetDir = joinPathFragments(\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n 'src',\n 'rdb',\n );\n\n generateFiles(\n tree,\n joinPathFragments(rdbScriptsDir, 'shared'),\n targetDir,\n {},\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n generateFiles(\n tree,\n joinPathFragments(rdbScriptsDir, engine),\n targetDir,\n {},\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The engine's wait-for-db script imports the database client, so declare it\n // in the scripts project's own package.json (tsx runs the scripts and lives\n // in the workspace root devDependencies).\n const clientDeps:
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/shared-rdb-scripts.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n} from '@nx/devkit';\nimport type {\n DependencyDeclaration,\n MustDeclare,\n} from './declared-dependencies';\nimport { addDependenciesToPackageJson } from './dependencies';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from './shared-constructs-constants';\nimport { ensureSharedScriptsProject } from './shared-scripts';\nimport { type ITsDepVersion, withVersions } from './versions';\n\n/** Dependencies a caller must declare to use the shared RDB scripts. */\nexport const SHARED_RDB_SCRIPTS_DEPENDENCIES = [\n { name: 'pg' },\n { name: '@types/pg' },\n { name: 'mariadb' },\n { name: 'tsx' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\n/**\n * Ensures the shared scripts package exists and adds RDB local-dev scripts\n * to packages/common/scripts/src/rdb/. Used by ts#rdb.\n *\n * Engine-agnostic scripts (pull-image, start-container) are always vended.\n * Only the wait-for-db script for the requested engine is vended so that\n * projects do not reference database client packages they don't install.\n * The engine-specific file names allow postgres and mysql projects to\n * coexist in the same workspace.\n */\nexport async function sharedRdbScriptsGenerator<\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n engine: 'postgres' | 'mysql',\n declaration: D & MustDeclare<typeof SHARED_RDB_SCRIPTS_DEPENDENCIES, D>,\n): Promise<void> {\n await ensureSharedScriptsProject(tree);\n\n const rdbScriptsDir = joinPathFragments(\n import.meta.dirname,\n 'files',\n SHARED_SCRIPTS_DIR,\n 'src',\n 'rdb',\n );\n const targetDir = joinPathFragments(\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n 'src',\n 'rdb',\n );\n\n generateFiles(\n tree,\n joinPathFragments(rdbScriptsDir, 'shared'),\n targetDir,\n {},\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n generateFiles(\n tree,\n joinPathFragments(rdbScriptsDir, engine),\n targetDir,\n {},\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The engine's wait-for-db script imports the database client, so declare it\n // in the scripts project's own package.json (tsx runs the scripts and lives\n // in the workspace root devDependencies).\n const clientDeps: (typeof SHARED_RDB_SCRIPTS_DEPENDENCIES)[number]['name'][] =\n engine === 'postgres' ? ['pg'] : ['mariadb'];\n const clientDevDeps: (typeof SHARED_RDB_SCRIPTS_DEPENDENCIES)[number]['name'][] =\n engine === 'postgres' ? ['@types/pg'] : [];\n addDependenciesToPackageJson(\n tree,\n withVersions(\n declaration as DependencyDeclaration<\n typeof SHARED_RDB_SCRIPTS_DEPENDENCIES\n >,\n clientDeps,\n ),\n withVersions(\n declaration as DependencyDeclaration<\n typeof SHARED_RDB_SCRIPTS_DEPENDENCIES\n >,\n clientDevDeps,\n ),\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'package.json'),\n );\n addDependenciesToPackageJson(\n tree,\n {},\n withVersions(\n declaration as DependencyDeclaration<\n typeof SHARED_RDB_SCRIPTS_DEPENDENCIES\n >,\n ['tsx'],\n ),\n );\n}\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","addDependenciesToPackageJson","PACKAGES_DIR","SHARED_SCRIPTS_DIR","ensureSharedScriptsProject","withVersions","SHARED_RDB_SCRIPTS_DEPENDENCIES","name","sharedRdbScriptsGenerator","tree","engine","declaration","rdbScriptsDir","dirname","targetDir","overwriteStrategy","KeepExisting","clientDeps","clientDevDeps"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAEZ,aAAa;AAKpB,SAASC,4BAA4B,QAAQ,oBAAiB;AAC9D,SACEC,YAAY,EACZC,kBAAkB,QACb,mCAAgC;AACvC,SAASC,0BAA0B,QAAQ,sBAAmB;AAC9D,SAA6BC,YAAY,QAAQ,gBAAa;AAE9D,sEAAsE,GACtE,OAAO,MAAMC,kCAAkC;IAC7C;QAAEC,MAAM;IAAK;IACb;QAAEA,MAAM;IAAY;IACpB;QAAEA,MAAM;IAAU;IAClB;QAAEA,MAAM;IAAM;CACf,CAAuD;AAExD;;;;;;;;;CASC,GACD,OAAO,eAAeC,0BAGpBC,IAAU,EACVC,MAA4B,EAC5BC,WAAuE;IAEvE,MAAMP,2BAA2BK;IAEjC,MAAMG,gBAAgBb,kBACpB,YAAYc,OAAO,EACnB,SACAV,oBACA,OACA;IAEF,MAAMW,YAAYf,kBAChBG,cACAC,oBACA,OACA;IAGFL,cACEW,MACAV,kBAAkBa,eAAe,WACjCE,WACA,CAAC,GACD;QAAEC,mBAAmBf,kBAAkBgB,YAAY;IAAC;IAEtDlB,cACEW,MACAV,kBAAkBa,eAAeF,SACjCI,WACA,CAAC,GACD;QAAEC,mBAAmBf,kBAAkBgB,YAAY;IAAC;IAGtD,6EAA6E;IAC7E,4EAA4E;IAC5E,0CAA0C;IAC1C,MAAMC,aACJP,WAAW,aAAa;QAAC;KAAK,GAAG;QAAC;KAAU;IAC9C,MAAMQ,gBACJR,WAAW,aAAa;QAAC;KAAY,GAAG,EAAE;IAC5CT,6BACEQ,MACAJ,aACEM,aAGAM,aAEFZ,aACEM,aAGAO,gBAEFnB,kBAAkBG,cAAcC,oBAAoB;IAEtDF,6BACEQ,MACA,CAAC,GACDJ,aACEM,aAGA;QAAC;KAAM;AAGb"}
|
|
@@ -3,4 +3,29 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { type Tree } from '@nx/devkit';
|
|
6
|
-
|
|
6
|
+
import { type DependencyDeclaration, type MustDeclare } from './declared-dependencies';
|
|
7
|
+
/** Dependencies a caller must declare to use the shared shadcn project. */
|
|
8
|
+
export declare const SHADCN_DEPENDENCIES: readonly [{
|
|
9
|
+
readonly name: "react";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "react-dom";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "class-variance-authority";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "clsx";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "tailwind-merge";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "lucide-react";
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "tw-animate-css";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "radix-ui";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "vite";
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "vitest";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "@vitest/coverage-v8";
|
|
30
|
+
}];
|
|
31
|
+
export declare function sharedShadcnGenerator<const D extends DependencyDeclaration>(tree: Tree, declaration: D & MustDeclare<typeof SHADCN_DEPENDENCIES, D>): Promise<void>;
|
|
@@ -4,23 +4,42 @@
|
|
|
4
4
|
*/ import { generateFiles, joinPathFragments, OverwriteStrategy, updateJson } from "@nx/devkit";
|
|
5
5
|
import tsProjectGenerator from "../ts/lib/generator.js";
|
|
6
6
|
import { configureTsProject } from "../ts/lib/ts-project-utils.js";
|
|
7
|
+
import { VITEST_DEPENDENCIES } from "../ts/lib/vitest.js";
|
|
8
|
+
import { declaredNames, forDependencies } from "./declared-dependencies.js";
|
|
7
9
|
import { addDependenciesToPackageJson } from "./dependencies.js";
|
|
8
10
|
import { formatFilesInSubtree } from "./format.js";
|
|
9
11
|
import { esmVars } from "./module-format.js";
|
|
10
12
|
import { getNpmScopePrefix } from "./npm-scope.js";
|
|
11
13
|
import { PACKAGES_DIR, SHARED_SHADCN_DIR, SHARED_SHADCN_NAME } from "./shared-constructs-constants.js";
|
|
12
14
|
import { withVersions } from "./versions.js";
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
/** Dependencies a caller must declare to use the shared shadcn project. */ export const SHADCN_DEPENDENCIES = [
|
|
16
|
+
{
|
|
17
|
+
name: 'react'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'react-dom'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'class-variance-authority'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'clsx'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'tailwind-merge'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'lucide-react'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'tw-animate-css'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'radix-ui'
|
|
39
|
+
},
|
|
40
|
+
...VITEST_DEPENDENCIES
|
|
22
41
|
];
|
|
23
|
-
export async function sharedShadcnGenerator(tree) {
|
|
42
|
+
export async function sharedShadcnGenerator(tree, declaration) {
|
|
24
43
|
const npmScopePrefix = getNpmScopePrefix(tree);
|
|
25
44
|
const scopeAlias = npmScopePrefix;
|
|
26
45
|
const sharedShadcnAlias = `${scopeAlias}${SHARED_SHADCN_NAME}`;
|
|
@@ -49,7 +68,7 @@ export async function sharedShadcnGenerator(tree) {
|
|
|
49
68
|
await configureTsProject(tree, {
|
|
50
69
|
dir: libraryRoot,
|
|
51
70
|
fullyQualifiedName
|
|
52
|
-
});
|
|
71
|
+
}, forDependencies(declaration));
|
|
53
72
|
updateJson(tree, joinPathFragments(libraryRoot, 'tsconfig.lib.json'), (json)=>({
|
|
54
73
|
...json,
|
|
55
74
|
compilerOptions: {
|
|
@@ -67,9 +86,7 @@ export async function sharedShadcnGenerator(tree) {
|
|
|
67
86
|
'src/**/*.tsx'
|
|
68
87
|
]))
|
|
69
88
|
}));
|
|
70
|
-
addDependenciesToPackageJson(tree, withVersions(
|
|
71
|
-
...SHADCN_DEPS
|
|
72
|
-
]), {}, joinPathFragments(libraryRoot, 'package.json'));
|
|
89
|
+
addDependenciesToPackageJson(tree, withVersions(forDependencies(declaration), declaredNames(SHADCN_DEPENDENCIES)), {}, joinPathFragments(libraryRoot, 'package.json'));
|
|
73
90
|
}
|
|
74
91
|
updateJson(tree, 'tsconfig.base.json', (json)=>({
|
|
75
92
|
...json,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/shared-shadcn.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport tsProjectGenerator from '../ts/lib/generator';\nimport { configureTsProject } from '../ts/lib/ts-project-utils';\nimport { addDependenciesToPackageJson } from './dependencies';\nimport { formatFilesInSubtree } from './format';\nimport { esmVars } from './module-format';\nimport { getNpmScopePrefix } from './npm-scope';\nimport {\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n SHARED_SHADCN_NAME,\n} from './shared-constructs-constants';\nimport { type ITsDepVersion, withVersions } from './versions';\n\
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/shared-shadcn.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport tsProjectGenerator from '../ts/lib/generator';\nimport { configureTsProject } from '../ts/lib/ts-project-utils';\nimport { VITEST_DEPENDENCIES } from '../ts/lib/vitest';\nimport {\n type DependencyDeclaration,\n declaredNames,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies';\nimport { addDependenciesToPackageJson } from './dependencies';\nimport { formatFilesInSubtree } from './format';\nimport { esmVars } from './module-format';\nimport { getNpmScopePrefix } from './npm-scope';\nimport {\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n SHARED_SHADCN_NAME,\n} from './shared-constructs-constants';\nimport { type ITsDepVersion, withVersions } from './versions';\n\n/** Dependencies a caller must declare to use the shared shadcn project. */\nexport const SHADCN_DEPENDENCIES = [\n { name: 'react' },\n { name: 'react-dom' },\n { name: 'class-variance-authority' },\n { name: 'clsx' },\n { name: 'tailwind-merge' },\n { name: 'lucide-react' },\n { name: 'tw-animate-css' },\n { name: 'radix-ui' },\n ...VITEST_DEPENDENCIES,\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport async function sharedShadcnGenerator<\n const D extends DependencyDeclaration,\n>(tree: Tree, declaration: D & MustDeclare<typeof SHADCN_DEPENDENCIES, D>) {\n const npmScopePrefix = getNpmScopePrefix(tree);\n const scopeAlias = npmScopePrefix;\n const sharedShadcnAlias = `${scopeAlias}${SHARED_SHADCN_NAME}`;\n const fullyQualifiedName = `${npmScopePrefix}${SHARED_SHADCN_NAME}`;\n const libraryRoot = joinPathFragments(PACKAGES_DIR, SHARED_SHADCN_DIR);\n const shadcnSrcRoot = joinPathFragments(libraryRoot, 'src');\n\n if (!tree.exists(joinPathFragments(libraryRoot, 'project.json'))) {\n await tsProjectGenerator(tree, {\n name: SHARED_SHADCN_NAME,\n directory: PACKAGES_DIR,\n subDirectory: SHARED_SHADCN_DIR,\n });\n\n tree.delete(shadcnSrcRoot);\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', SHARED_SHADCN_DIR, 'src'),\n shadcnSrcRoot,\n {\n scopeAlias,\n ...esmVars(tree),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n SHARED_SHADCN_DIR,\n 'readme',\n ),\n libraryRoot,\n {\n fullyQualifiedName,\n scopeAlias,\n },\n {\n overwriteStrategy: OverwriteStrategy.Overwrite,\n },\n );\n\n await configureTsProject(\n tree,\n {\n dir: libraryRoot,\n fullyQualifiedName,\n },\n forDependencies<typeof SHADCN_DEPENDENCIES>(declaration),\n );\n\n updateJson(\n tree,\n joinPathFragments(libraryRoot, 'tsconfig.lib.json'),\n (json) => ({\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n jsx: 'react-jsx',\n module: 'preserve',\n moduleResolution: 'bundler',\n lib: Array.from(\n new Set([...(json.compilerOptions?.lib ?? []), 'DOM']),\n ),\n },\n include: Array.from(new Set([...(json.include ?? []), 'src/**/*.tsx'])),\n }),\n );\n\n addDependenciesToPackageJson(\n tree,\n withVersions(\n forDependencies<typeof SHADCN_DEPENDENCIES>(declaration),\n declaredNames(SHADCN_DEPENDENCIES),\n ),\n {},\n joinPathFragments(libraryRoot, 'package.json'),\n );\n }\n\n updateJson(tree, 'tsconfig.base.json', (json) => ({\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n paths: {\n ...(json.compilerOptions?.paths ?? {}),\n [`${sharedShadcnAlias}/*`]: [\n `./${joinPathFragments(libraryRoot, 'src', '*')}`,\n ],\n },\n },\n }));\n\n // components.json lives in the package so `shadcn add` runs there and\n // installs component dependencies into the package's own manifest.\n if (!tree.exists(joinPathFragments(libraryRoot, 'components.json'))) {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'shadcn'),\n libraryRoot,\n {\n sharedShadcnAlias,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n\n await formatFilesInSubtree(tree);\n}\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateJson","tsProjectGenerator","configureTsProject","VITEST_DEPENDENCIES","declaredNames","forDependencies","addDependenciesToPackageJson","formatFilesInSubtree","esmVars","getNpmScopePrefix","PACKAGES_DIR","SHARED_SHADCN_DIR","SHARED_SHADCN_NAME","withVersions","SHADCN_DEPENDENCIES","name","sharedShadcnGenerator","tree","declaration","npmScopePrefix","scopeAlias","sharedShadcnAlias","fullyQualifiedName","libraryRoot","shadcnSrcRoot","exists","directory","subDirectory","delete","dirname","overwriteStrategy","KeepExisting","Overwrite","dir","json","compilerOptions","jsx","module","moduleResolution","lib","Array","from","Set","include","paths"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,UAAU,QACL,aAAa;AACpB,OAAOC,wBAAwB,yBAAsB;AACrD,SAASC,kBAAkB,QAAQ,gCAA6B;AAChE,SAASC,mBAAmB,QAAQ,sBAAmB;AACvD,SAEEC,aAAa,EACbC,eAAe,QAEV,6BAA0B;AACjC,SAASC,4BAA4B,QAAQ,oBAAiB;AAC9D,SAASC,oBAAoB,QAAQ,cAAW;AAChD,SAASC,OAAO,QAAQ,qBAAkB;AAC1C,SAASC,iBAAiB,QAAQ,iBAAc;AAChD,SACEC,YAAY,EACZC,iBAAiB,EACjBC,kBAAkB,QACb,mCAAgC;AACvC,SAA6BC,YAAY,QAAQ,gBAAa;AAE9D,yEAAyE,GACzE,OAAO,MAAMC,sBAAsB;IACjC;QAAEC,MAAM;IAAQ;IAChB;QAAEA,MAAM;IAAY;IACpB;QAAEA,MAAM;IAA2B;IACnC;QAAEA,MAAM;IAAO;IACf;QAAEA,MAAM;IAAiB;IACzB;QAAEA,MAAM;IAAe;IACvB;QAAEA,MAAM;IAAiB;IACzB;QAAEA,MAAM;IAAW;OAChBZ;CACJ,CAAuD;AAExD,OAAO,eAAea,sBAEpBC,IAAU,EAAEC,WAA2D;IACvE,MAAMC,iBAAiBV,kBAAkBQ;IACzC,MAAMG,aAAaD;IACnB,MAAME,oBAAoB,GAAGD,aAAaR,oBAAoB;IAC9D,MAAMU,qBAAqB,GAAGH,iBAAiBP,oBAAoB;IACnE,MAAMW,cAAczB,kBAAkBY,cAAcC;IACpD,MAAMa,gBAAgB1B,kBAAkByB,aAAa;IAErD,IAAI,CAACN,KAAKQ,MAAM,CAAC3B,kBAAkByB,aAAa,kBAAkB;QAChE,MAAMtB,mBAAmBgB,MAAM;YAC7BF,MAAMH;YACNc,WAAWhB;YACXiB,cAAchB;QAChB;QAEAM,KAAKW,MAAM,CAACJ;QAEZ3B,cACEoB,MACAnB,kBAAkB,YAAY+B,OAAO,EAAE,SAASlB,mBAAmB,QACnEa,eACA;YACEJ;YACA,GAAGZ,QAAQS,KAAK;QAClB,GACA;YACEa,mBAAmB/B,kBAAkBgC,YAAY;QACnD;QAGFlC,cACEoB,MACAnB,kBACE,YAAY+B,OAAO,EACnB,SACAlB,mBACA,WAEFY,aACA;YACED;YACAF;QACF,GACA;YACEU,mBAAmB/B,kBAAkBiC,SAAS;QAChD;QAGF,MAAM9B,mBACJe,MACA;YACEgB,KAAKV;YACLD;QACF,GACAjB,gBAA4Ca;QAG9ClB,WACEiB,MACAnB,kBAAkByB,aAAa,sBAC/B,CAACW,OAAU,CAAA;gBACT,GAAGA,IAAI;gBACPC,iBAAiB;oBACf,GAAGD,KAAKC,eAAe;oBACvBC,KAAK;oBACLC,QAAQ;oBACRC,kBAAkB;oBAClBC,KAAKC,MAAMC,IAAI,CACb,IAAIC,IAAI;2BAAKR,KAAKC,eAAe,EAAEI,OAAO,EAAE;wBAAG;qBAAM;gBAEzD;gBACAI,SAASH,MAAMC,IAAI,CAAC,IAAIC,IAAI;uBAAKR,KAAKS,OAAO,IAAI,EAAE;oBAAG;iBAAe;YACvE,CAAA;QAGFrC,6BACEW,MACAJ,aACER,gBAA4Ca,cAC5Cd,cAAcU,uBAEhB,CAAC,GACDhB,kBAAkByB,aAAa;IAEnC;IAEAvB,WAAWiB,MAAM,sBAAsB,CAACiB,OAAU,CAAA;YAChD,GAAGA,IAAI;YACPC,iBAAiB;gBACf,GAAGD,KAAKC,eAAe;gBACvBS,OAAO;oBACL,GAAIV,KAAKC,eAAe,EAAES,SAAS,CAAC,CAAC;oBACrC,CAAC,GAAGvB,kBAAkB,EAAE,CAAC,CAAC,EAAE;wBAC1B,CAAC,EAAE,EAAEvB,kBAAkByB,aAAa,OAAO,MAAM;qBAClD;gBACH;YACF;QACF,CAAA;IAEA,sEAAsE;IACtE,mEAAmE;IACnE,IAAI,CAACN,KAAKQ,MAAM,CAAC3B,kBAAkByB,aAAa,qBAAqB;QACnE1B,cACEoB,MACAnB,kBAAkB,YAAY+B,OAAO,EAAE,SAAS,WAChDN,aACA;YACEF;QACF,GACA;YACES,mBAAmB/B,kBAAkBgC,YAAY;QACnD;IAEJ;IAEA,MAAMxB,qBAAqBU;AAC7B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { MigrationReturnObject, Tree } from '@nx/devkit';
|
|
6
|
+
/**
|
|
7
|
+
* Syncs the workspace's vended versions to those the installed plugin vends.
|
|
8
|
+
*
|
|
9
|
+
* Registered `everyMigration`, so it runs on every upgrade and last in the run:
|
|
10
|
+
* versions come from the installed plugin's own tables, so there is nothing
|
|
11
|
+
* release-specific to register, and running after the code migrations lets them
|
|
12
|
+
* add dependencies this then brings up to date.
|
|
13
|
+
*/
|
|
14
|
+
export default function migration(tree: Tree): Promise<MigrationReturnObject>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { syncVendedVersions } from "./sync-vended-versions.js";
|
|
5
|
+
/**
|
|
6
|
+
* Syncs the workspace's vended versions to those the installed plugin vends.
|
|
7
|
+
*
|
|
8
|
+
* Registered `everyMigration`, so it runs on every upgrade and last in the run:
|
|
9
|
+
* versions come from the installed plugin's own tables, so there is nothing
|
|
10
|
+
* release-specific to register, and running after the code migrations lets them
|
|
11
|
+
* add dependencies this then brings up to date.
|
|
12
|
+
*/ export default async function migration(tree) {
|
|
13
|
+
return syncVendedVersions(tree);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationReturnObject, Tree } from '@nx/devkit';\nimport { syncVendedVersions } from './sync-vended-versions';\n\n/**\n * Syncs the workspace's vended versions to those the installed plugin vends.\n *\n * Registered `everyMigration`, so it runs on every upgrade and last in the run:\n * versions come from the installed plugin's own tables, so there is nothing\n * release-specific to register, and running after the code migrations lets them\n * add dependencies this then brings up to date.\n */\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n return syncVendedVersions(tree);\n}\n"],"names":["syncVendedVersions","migration","tree"],"mappings":"AAAA;;;CAGC,GAED,SAASA,kBAAkB,QAAQ,4BAAyB;AAE5D;;;;;;;CAOC,GACD,eAAe,eAAeC,UAC5BC,IAAU;IAEV,OAAOF,mBAAmBE;AAC5B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `packageJsonUpdates` for the nx packages a generated workspace pins.
|
|
3
|
+
*
|
|
4
|
+
* A migration cannot bump these: `nx migrate` builds its migration list from the
|
|
5
|
+
* packages it is itself bumping, so an nx version only rewritten by our migration
|
|
6
|
+
* silently skips Nx's own migrations for that hop. Declaring the bump here pulls
|
|
7
|
+
* them in.
|
|
8
|
+
*
|
|
9
|
+
* It also keeps every nx pin moving together. A workspace nx even a patch apart
|
|
10
|
+
* from the plugin's `@nx/*` packages hoists a second nested nx, and the two
|
|
11
|
+
* deadlock `nx sync`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NX_PACKAGE_UPDATES_NAME = "nx-packages";
|
|
14
|
+
export declare const isNxPackage: (name: string) => boolean;
|
|
15
|
+
/** Indexed to satisfy the open shape `migrations.json` entries carry. */
|
|
16
|
+
export interface PackageJsonUpdate extends Record<string, unknown> {
|
|
17
|
+
version: string;
|
|
18
|
+
packages: Record<string, {
|
|
19
|
+
version: string;
|
|
20
|
+
alwaysAddToPackageJson: false;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
export type PackageJsonUpdates = Record<string, PackageJsonUpdate>;
|
|
24
|
+
/**
|
|
25
|
+
* `alwaysAddToPackageJson: false` so only packages already present are updated.
|
|
26
|
+
*
|
|
27
|
+
* Keyed by directory rather than version, because the key has to exist before
|
|
28
|
+
* the version does: an entry is written under `latest` and only re-keyed to
|
|
29
|
+
* `v<version>` once a release claims it. One release's entry stays behind as the
|
|
30
|
+
* next is written, so a workspace several releases behind gets each nx bump in
|
|
31
|
+
* turn — hence `<dir>-<name>`, which keeps every release's entry distinct.
|
|
32
|
+
*
|
|
33
|
+
* @param version version `nx migrate` gates the bump on
|
|
34
|
+
*/
|
|
35
|
+
export declare const nxPackageJsonUpdates: (dir: string, version: string, nxVersion?: string) => PackageJsonUpdates;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { migrationKey } from "../migration-versions.js";
|
|
5
|
+
import { NX_PACKAGES, NX_VERSION } from "../versions.js";
|
|
6
|
+
/**
|
|
7
|
+
* `packageJsonUpdates` for the nx packages a generated workspace pins.
|
|
8
|
+
*
|
|
9
|
+
* A migration cannot bump these: `nx migrate` builds its migration list from the
|
|
10
|
+
* packages it is itself bumping, so an nx version only rewritten by our migration
|
|
11
|
+
* silently skips Nx's own migrations for that hop. Declaring the bump here pulls
|
|
12
|
+
* them in.
|
|
13
|
+
*
|
|
14
|
+
* It also keeps every nx pin moving together. A workspace nx even a patch apart
|
|
15
|
+
* from the plugin's `@nx/*` packages hoists a second nested nx, and the two
|
|
16
|
+
* deadlock `nx sync`.
|
|
17
|
+
*/ export const NX_PACKAGE_UPDATES_NAME = 'nx-packages';
|
|
18
|
+
export const isNxPackage = (name)=>NX_PACKAGES.includes(name);
|
|
19
|
+
/**
|
|
20
|
+
* `alwaysAddToPackageJson: false` so only packages already present are updated.
|
|
21
|
+
*
|
|
22
|
+
* Keyed by directory rather than version, because the key has to exist before
|
|
23
|
+
* the version does: an entry is written under `latest` and only re-keyed to
|
|
24
|
+
* `v<version>` once a release claims it. One release's entry stays behind as the
|
|
25
|
+
* next is written, so a workspace several releases behind gets each nx bump in
|
|
26
|
+
* turn — hence `<dir>-<name>`, which keeps every release's entry distinct.
|
|
27
|
+
*
|
|
28
|
+
* @param version version `nx migrate` gates the bump on
|
|
29
|
+
*/ export const nxPackageJsonUpdates = (dir, version, nxVersion = NX_VERSION)=>({
|
|
30
|
+
[migrationKey(dir, NX_PACKAGE_UPDATES_NAME)]: {
|
|
31
|
+
version,
|
|
32
|
+
packages: Object.fromEntries(NX_PACKAGES.map((name)=>[
|
|
33
|
+
name,
|
|
34
|
+
{
|
|
35
|
+
version: nxVersion,
|
|
36
|
+
alwaysAddToPackageJson: false
|
|
37
|
+
}
|
|
38
|
+
]))
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=nx-package-updates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/nx-package-updates.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { migrationKey } from '../migration-versions';\nimport { NX_PACKAGES, NX_VERSION } from '../versions';\n\n/**\n * `packageJsonUpdates` for the nx packages a generated workspace pins.\n *\n * A migration cannot bump these: `nx migrate` builds its migration list from the\n * packages it is itself bumping, so an nx version only rewritten by our migration\n * silently skips Nx's own migrations for that hop. Declaring the bump here pulls\n * them in.\n *\n * It also keeps every nx pin moving together. A workspace nx even a patch apart\n * from the plugin's `@nx/*` packages hoists a second nested nx, and the two\n * deadlock `nx sync`.\n */\n\nexport const NX_PACKAGE_UPDATES_NAME = 'nx-packages';\n\nexport const isNxPackage = (name: string): boolean =>\n (NX_PACKAGES as readonly string[]).includes(name);\n\n/** Indexed to satisfy the open shape `migrations.json` entries carry. */\nexport interface PackageJsonUpdate extends Record<string, unknown> {\n version: string;\n packages: Record<string, { version: string; alwaysAddToPackageJson: false }>;\n}\n\nexport type PackageJsonUpdates = Record<string, PackageJsonUpdate>;\n\n/**\n * `alwaysAddToPackageJson: false` so only packages already present are updated.\n *\n * Keyed by directory rather than version, because the key has to exist before\n * the version does: an entry is written under `latest` and only re-keyed to\n * `v<version>` once a release claims it. One release's entry stays behind as the\n * next is written, so a workspace several releases behind gets each nx bump in\n * turn — hence `<dir>-<name>`, which keeps every release's entry distinct.\n *\n * @param version version `nx migrate` gates the bump on\n */\nexport const nxPackageJsonUpdates = (\n dir: string,\n version: string,\n nxVersion: string = NX_VERSION,\n): PackageJsonUpdates => ({\n [migrationKey(dir, NX_PACKAGE_UPDATES_NAME)]: {\n version,\n packages: Object.fromEntries(\n NX_PACKAGES.map((name) => [\n name,\n { version: nxVersion, alwaysAddToPackageJson: false as const },\n ]),\n ),\n },\n});\n"],"names":["migrationKey","NX_PACKAGES","NX_VERSION","NX_PACKAGE_UPDATES_NAME","isNxPackage","name","includes","nxPackageJsonUpdates","dir","version","nxVersion","packages","Object","fromEntries","map","alwaysAddToPackageJson"],"mappings":"AAAA;;;CAGC,GACD,SAASA,YAAY,QAAQ,2BAAwB;AACrD,SAASC,WAAW,EAAEC,UAAU,QAAQ,iBAAc;AAEtD;;;;;;;;;;;CAWC,GAED,OAAO,MAAMC,0BAA0B,cAAc;AAErD,OAAO,MAAMC,cAAc,CAACC,OAC1B,AAACJ,YAAkCK,QAAQ,CAACD,MAAM;AAUpD;;;;;;;;;;CAUC,GACD,OAAO,MAAME,uBAAuB,CAClCC,KACAC,SACAC,YAAoBR,UAAU,GACN,CAAA;QACxB,CAACF,aAAaQ,KAAKL,yBAAyB,EAAE;YAC5CM;YACAE,UAAUC,OAAOC,WAAW,CAC1BZ,YAAYa,GAAG,CAAC,CAACT,OAAS;oBACxBA;oBACA;wBAAEI,SAASC;wBAAWK,wBAAwB;oBAAe;iBAC9D;QAEL;IACF,CAAA,EAAG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { type DependencyMetadata } from '../declared-dependencies';
|
|
3
|
+
/** Directory holding `generators.json`, which maps ids to their modules. */
|
|
4
|
+
export declare const PLUGIN_ROOT: string;
|
|
5
|
+
/**
|
|
6
|
+
* Which vended dependencies this workspace's generators are responsible for.
|
|
7
|
+
*
|
|
8
|
+
* Only these are synced, so a package the user added themselves keeps the version
|
|
9
|
+
* they chose. Ownership is derived from the generators the workspace has run and
|
|
10
|
+
* the dependencies each declares — nothing extra is recorded in the workspace.
|
|
11
|
+
*/
|
|
12
|
+
export interface OwnedDependencies {
|
|
13
|
+
readonly ts: ReadonlySet<string>;
|
|
14
|
+
readonly py: ReadonlySet<string>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* One recorded run of a generator, with the metadata it wrote.
|
|
18
|
+
*
|
|
19
|
+
* The metadata carries the values the generator's dependency conditions read, so
|
|
20
|
+
* a declaration filters down to the branch this occurrence actually took.
|
|
21
|
+
*/
|
|
22
|
+
export interface GeneratorOccurrence {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly metadata: DependencyMetadata;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every recorded run of a generator in this workspace, from the metadata
|
|
28
|
+
* generators record on the projects (and components) they create.
|
|
29
|
+
*
|
|
30
|
+
* A generator appears once per project or component it created, since each may
|
|
31
|
+
* have been run with different options.
|
|
32
|
+
*
|
|
33
|
+
* `init` creates no project, so its config file stands in for it.
|
|
34
|
+
*/
|
|
35
|
+
export declare const generatorOccurrences: (tree: Tree) => readonly GeneratorOccurrence[];
|
|
36
|
+
/** Generator ids this workspace has run. */
|
|
37
|
+
export declare const generatorsRun: (tree: Tree) => ReadonlySet<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Union of the dependencies declared by the generators this workspace has run,
|
|
40
|
+
* narrowed per occurrence to those whose conditions its recorded metadata
|
|
41
|
+
* satisfies — a project generated with one protocol does not own another's
|
|
42
|
+
* packages.
|
|
43
|
+
*
|
|
44
|
+
* A `versionOnly` entry is owned like any other: it is declared precisely so the
|
|
45
|
+
* sync keeps its pinned version current wherever the workspace already holds it.
|
|
46
|
+
*
|
|
47
|
+
* Each generator module exports its declaration, so reading one is an import
|
|
48
|
+
* rather than a run — the generators themselves are never invoked.
|
|
49
|
+
*/
|
|
50
|
+
export declare const ownedDependencies: (tree: Tree) => Promise<OwnedDependencies>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import * as path from "node:path";
|
|
5
|
+
import { getProjects } from "@nx/devkit";
|
|
6
|
+
import { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from "../config/utils.js";
|
|
7
|
+
import { ownedDependencyEntries } from "../declared-dependencies.js";
|
|
8
|
+
import { buildGeneratorInfoList } from "../generators.js";
|
|
9
|
+
/** Directory holding `generators.json`, which maps ids to their modules. */ export const PLUGIN_ROOT = path.resolve(import.meta.dirname, '..', '..', '..');
|
|
10
|
+
/**
|
|
11
|
+
* Every recorded run of a generator in this workspace, from the metadata
|
|
12
|
+
* generators record on the projects (and components) they create.
|
|
13
|
+
*
|
|
14
|
+
* A generator appears once per project or component it created, since each may
|
|
15
|
+
* have been run with different options.
|
|
16
|
+
*
|
|
17
|
+
* `init` creates no project, so its config file stands in for it.
|
|
18
|
+
*/ export const generatorOccurrences = (tree)=>{
|
|
19
|
+
const occurrences = [];
|
|
20
|
+
if (tree.exists(AWS_NX_PLUGIN_CONFIG_FILE_NAME)) {
|
|
21
|
+
occurrences.push({
|
|
22
|
+
id: 'init',
|
|
23
|
+
metadata: {}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
for (const [, project] of getProjects(tree)){
|
|
27
|
+
const metadata = project.metadata;
|
|
28
|
+
if (metadata?.generator) {
|
|
29
|
+
const { components, ...ownMetadata } = metadata;
|
|
30
|
+
occurrences.push({
|
|
31
|
+
id: metadata.generator,
|
|
32
|
+
metadata: ownMetadata
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
for (const component of metadata?.components ?? []){
|
|
36
|
+
if (component.generator) {
|
|
37
|
+
occurrences.push({
|
|
38
|
+
id: component.generator,
|
|
39
|
+
metadata: component
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return occurrences;
|
|
45
|
+
};
|
|
46
|
+
/** Generator ids this workspace has run. */ export const generatorsRun = (tree)=>new Set(generatorOccurrences(tree).map((occurrence)=>occurrence.id));
|
|
47
|
+
/**
|
|
48
|
+
* Union of the dependencies declared by the generators this workspace has run,
|
|
49
|
+
* narrowed per occurrence to those whose conditions its recorded metadata
|
|
50
|
+
* satisfies — a project generated with one protocol does not own another's
|
|
51
|
+
* packages.
|
|
52
|
+
*
|
|
53
|
+
* A `versionOnly` entry is owned like any other: it is declared precisely so the
|
|
54
|
+
* sync keeps its pinned version current wherever the workspace already holds it.
|
|
55
|
+
*
|
|
56
|
+
* Each generator module exports its declaration, so reading one is an import
|
|
57
|
+
* rather than a run — the generators themselves are never invoked.
|
|
58
|
+
*/ export const ownedDependencies = async (tree)=>{
|
|
59
|
+
const occurrences = generatorOccurrences(tree);
|
|
60
|
+
const ts = new Set();
|
|
61
|
+
const py = new Set();
|
|
62
|
+
for (const info of buildGeneratorInfoList(PLUGIN_ROOT)){
|
|
63
|
+
const matching = occurrences.filter((occurrence)=>occurrence.id === info.id);
|
|
64
|
+
if (matching.length === 0) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const declaration = await readDeclaration(info.resolvedFactoryPath);
|
|
68
|
+
if (!declaration) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
for (const { metadata } of matching){
|
|
72
|
+
for (const entry of ownedDependencyEntries(declaration.ts, metadata)){
|
|
73
|
+
ts.add(entry.name);
|
|
74
|
+
}
|
|
75
|
+
for (const entry of ownedDependencyEntries(declaration.py, metadata)){
|
|
76
|
+
py.add(entry.name);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
ts,
|
|
82
|
+
py
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* A generator's `DEPENDENCIES`, or undefined when it declares none.
|
|
87
|
+
* A generator that fails to load must not fail the upgrade, so its dependencies
|
|
88
|
+
* are treated as unowned and left as they are.
|
|
89
|
+
*/ const readDeclaration = async (factoryPath)=>{
|
|
90
|
+
try {
|
|
91
|
+
const module = await import(`${factoryPath}.js`);
|
|
92
|
+
return module.DEPENDENCIES;
|
|
93
|
+
} catch {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=owned-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/owned-dependencies.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport * as path from 'node:path';\nimport { getProjects, type Tree } from '@nx/devkit';\nimport { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from '../config/utils';\nimport {\n type DependencyDeclaration,\n type DependencyMetadata,\n ownedDependencyEntries,\n} from '../declared-dependencies';\nimport { buildGeneratorInfoList } from '../generators';\n\n/** Directory holding `generators.json`, which maps ids to their modules. */\nexport const PLUGIN_ROOT = path.resolve(import.meta.dirname, '..', '..', '..');\n\n/**\n * Which vended dependencies this workspace's generators are responsible for.\n *\n * Only these are synced, so a package the user added themselves keeps the version\n * they chose. Ownership is derived from the generators the workspace has run and\n * the dependencies each declares — nothing extra is recorded in the workspace.\n */\nexport interface OwnedDependencies {\n readonly ts: ReadonlySet<string>;\n readonly py: ReadonlySet<string>;\n}\n\n/**\n * One recorded run of a generator, with the metadata it wrote.\n *\n * The metadata carries the values the generator's dependency conditions read, so\n * a declaration filters down to the branch this occurrence actually took.\n */\nexport interface GeneratorOccurrence {\n readonly id: string;\n readonly metadata: DependencyMetadata;\n}\n\n/**\n * Every recorded run of a generator in this workspace, from the metadata\n * generators record on the projects (and components) they create.\n *\n * A generator appears once per project or component it created, since each may\n * have been run with different options.\n *\n * `init` creates no project, so its config file stands in for it.\n */\nexport const generatorOccurrences = (\n tree: Tree,\n): readonly GeneratorOccurrence[] => {\n const occurrences: GeneratorOccurrence[] = [];\n if (tree.exists(AWS_NX_PLUGIN_CONFIG_FILE_NAME)) {\n occurrences.push({ id: 'init', metadata: {} });\n }\n for (const [, project] of getProjects(tree)) {\n const metadata = project.metadata as\n | {\n generator?: string;\n components?: ({ generator?: string } & DependencyMetadata)[];\n }\n | undefined;\n if (metadata?.generator) {\n const { components, ...ownMetadata } = metadata;\n occurrences.push({ id: metadata.generator, metadata: ownMetadata });\n }\n for (const component of metadata?.components ?? []) {\n if (component.generator) {\n occurrences.push({ id: component.generator, metadata: component });\n }\n }\n }\n return occurrences;\n};\n\n/** Generator ids this workspace has run. */\nexport const generatorsRun = (tree: Tree): ReadonlySet<string> =>\n new Set(generatorOccurrences(tree).map((occurrence) => occurrence.id));\n\n/**\n * Union of the dependencies declared by the generators this workspace has run,\n * narrowed per occurrence to those whose conditions its recorded metadata\n * satisfies — a project generated with one protocol does not own another's\n * packages.\n *\n * A `versionOnly` entry is owned like any other: it is declared precisely so the\n * sync keeps its pinned version current wherever the workspace already holds it.\n *\n * Each generator module exports its declaration, so reading one is an import\n * rather than a run — the generators themselves are never invoked.\n */\nexport const ownedDependencies = async (\n tree: Tree,\n): Promise<OwnedDependencies> => {\n const occurrences = generatorOccurrences(tree);\n const ts = new Set<string>();\n const py = new Set<string>();\n\n for (const info of buildGeneratorInfoList(PLUGIN_ROOT)) {\n const matching = occurrences.filter(\n (occurrence) => occurrence.id === info.id,\n );\n if (matching.length === 0) {\n continue;\n }\n const declaration = await readDeclaration(info.resolvedFactoryPath);\n if (!declaration) {\n continue;\n }\n for (const { metadata } of matching) {\n for (const entry of ownedDependencyEntries(declaration.ts, metadata)) {\n ts.add(entry.name as string);\n }\n for (const entry of ownedDependencyEntries(declaration.py, metadata)) {\n py.add(entry.name as string);\n }\n }\n }\n\n return { ts, py };\n};\n\n/**\n * A generator's `DEPENDENCIES`, or undefined when it declares none.\n * A generator that fails to load must not fail the upgrade, so its dependencies\n * are treated as unowned and left as they are.\n */\nconst readDeclaration = async (\n factoryPath: string,\n): Promise<DependencyDeclaration | undefined> => {\n try {\n const module = await import(`${factoryPath}.js`);\n return module.DEPENDENCIES;\n } catch {\n return undefined;\n }\n};\n"],"names":["path","getProjects","AWS_NX_PLUGIN_CONFIG_FILE_NAME","ownedDependencyEntries","buildGeneratorInfoList","PLUGIN_ROOT","resolve","dirname","generatorOccurrences","tree","occurrences","exists","push","id","metadata","project","generator","components","ownMetadata","component","generatorsRun","Set","map","occurrence","ownedDependencies","ts","py","info","matching","filter","length","declaration","readDeclaration","resolvedFactoryPath","entry","add","name","factoryPath","module","DEPENDENCIES","undefined"],"mappings":"AAAA;;;CAGC,GACD,YAAYA,UAAU,YAAY;AAClC,SAASC,WAAW,QAAmB,aAAa;AACpD,SAASC,8BAA8B,QAAQ,qBAAkB;AACjE,SAGEC,sBAAsB,QACjB,8BAA2B;AAClC,SAASC,sBAAsB,QAAQ,mBAAgB;AAEvD,0EAA0E,GAC1E,OAAO,MAAMC,cAAcL,KAAKM,OAAO,CAAC,YAAYC,OAAO,EAAE,MAAM,MAAM,MAAM;AAyB/E;;;;;;;;CAQC,GACD,OAAO,MAAMC,uBAAuB,CAClCC;IAEA,MAAMC,cAAqC,EAAE;IAC7C,IAAID,KAAKE,MAAM,CAACT,iCAAiC;QAC/CQ,YAAYE,IAAI,CAAC;YAAEC,IAAI;YAAQC,UAAU,CAAC;QAAE;IAC9C;IACA,KAAK,MAAM,GAAGC,QAAQ,IAAId,YAAYQ,MAAO;QAC3C,MAAMK,WAAWC,QAAQD,QAAQ;QAMjC,IAAIA,UAAUE,WAAW;YACvB,MAAM,EAAEC,UAAU,EAAE,GAAGC,aAAa,GAAGJ;YACvCJ,YAAYE,IAAI,CAAC;gBAAEC,IAAIC,SAASE,SAAS;gBAAEF,UAAUI;YAAY;QACnE;QACA,KAAK,MAAMC,aAAaL,UAAUG,cAAc,EAAE,CAAE;YAClD,IAAIE,UAAUH,SAAS,EAAE;gBACvBN,YAAYE,IAAI,CAAC;oBAAEC,IAAIM,UAAUH,SAAS;oBAAEF,UAAUK;gBAAU;YAClE;QACF;IACF;IACA,OAAOT;AACT,EAAE;AAEF,0CAA0C,GAC1C,OAAO,MAAMU,gBAAgB,CAACX,OAC5B,IAAIY,IAAIb,qBAAqBC,MAAMa,GAAG,CAAC,CAACC,aAAeA,WAAWV,EAAE,GAAG;AAEzE;;;;;;;;;;;CAWC,GACD,OAAO,MAAMW,oBAAoB,OAC/Bf;IAEA,MAAMC,cAAcF,qBAAqBC;IACzC,MAAMgB,KAAK,IAAIJ;IACf,MAAMK,KAAK,IAAIL;IAEf,KAAK,MAAMM,QAAQvB,uBAAuBC,aAAc;QACtD,MAAMuB,WAAWlB,YAAYmB,MAAM,CACjC,CAACN,aAAeA,WAAWV,EAAE,KAAKc,KAAKd,EAAE;QAE3C,IAAIe,SAASE,MAAM,KAAK,GAAG;YACzB;QACF;QACA,MAAMC,cAAc,MAAMC,gBAAgBL,KAAKM,mBAAmB;QAClE,IAAI,CAACF,aAAa;YAChB;QACF;QACA,KAAK,MAAM,EAAEjB,QAAQ,EAAE,IAAIc,SAAU;YACnC,KAAK,MAAMM,SAAS/B,uBAAuB4B,YAAYN,EAAE,EAAEX,UAAW;gBACpEW,GAAGU,GAAG,CAACD,MAAME,IAAI;YACnB;YACA,KAAK,MAAMF,SAAS/B,uBAAuB4B,YAAYL,EAAE,EAAEZ,UAAW;gBACpEY,GAAGS,GAAG,CAACD,MAAME,IAAI;YACnB;QACF;IACF;IAEA,OAAO;QAAEX;QAAIC;IAAG;AAClB,EAAE;AAEF;;;;CAIC,GACD,MAAMM,kBAAkB,OACtBK;IAEA,IAAI;QACF,MAAMC,SAAS,MAAM,MAAM,CAAC,GAAGD,YAAY,GAAG,CAAC;QAC/C,OAAOC,OAAOC,YAAY;IAC5B,EAAE,OAAM;QACN,OAAOC;IACT;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type Tree } from '@nx/devkit';
|
|
6
|
+
/**
|
|
7
|
+
* Register the nx bump a version update needs, in `migrations.json`. Call only
|
|
8
|
+
* when an nx package actually moved.
|
|
9
|
+
*
|
|
10
|
+
* The version sync migration itself is a committed `everyMigration` entry, so
|
|
11
|
+
* only the nx packages need registering per update: they go through
|
|
12
|
+
* `packageJsonUpdates` rather than a migration (see `nx-package-updates.ts`).
|
|
13
|
+
*
|
|
14
|
+
* Idempotent: re-running before a release claims the entry refreshes it in place.
|
|
15
|
+
*
|
|
16
|
+
* @returns paths written, for the update report
|
|
17
|
+
*/
|
|
18
|
+
export declare const registerNxPackageUpdates: (tree: Tree) => string[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { updateJson } from "@nx/devkit";
|
|
5
|
+
import { LATEST_MIGRATIONS_DIR } from "../migration-versions.js";
|
|
6
|
+
import { nxPackageJsonUpdates } from "./nx-package-updates.js";
|
|
7
|
+
const MIGRATIONS_JSON_PATH = 'packages/nx-plugin/migrations.json';
|
|
8
|
+
/**
|
|
9
|
+
* Register the nx bump a version update needs, in `migrations.json`. Call only
|
|
10
|
+
* when an nx package actually moved.
|
|
11
|
+
*
|
|
12
|
+
* The version sync migration itself is a committed `everyMigration` entry, so
|
|
13
|
+
* only the nx packages need registering per update: they go through
|
|
14
|
+
* `packageJsonUpdates` rather than a migration (see `nx-package-updates.ts`).
|
|
15
|
+
*
|
|
16
|
+
* Idempotent: re-running before a release claims the entry refreshes it in place.
|
|
17
|
+
*
|
|
18
|
+
* @returns paths written, for the update report
|
|
19
|
+
*/ export const registerNxPackageUpdates = (tree)=>{
|
|
20
|
+
updateJson(tree, MIGRATIONS_JSON_PATH, (migrations)=>({
|
|
21
|
+
...migrations,
|
|
22
|
+
// Recorded under `latest` until stamping resolves the version it ships with.
|
|
23
|
+
packageJsonUpdates: {
|
|
24
|
+
...migrations.packageJsonUpdates,
|
|
25
|
+
...nxPackageJsonUpdates(LATEST_MIGRATIONS_DIR, LATEST_MIGRATIONS_DIR)
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
return [
|
|
29
|
+
MIGRATIONS_JSON_PATH
|
|
30
|
+
];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/register.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { type Tree, updateJson } from '@nx/devkit';\nimport {\n LATEST_MIGRATIONS_DIR,\n type MigrationsJson,\n} from '../migration-versions';\nimport { nxPackageJsonUpdates } from './nx-package-updates';\n\nconst MIGRATIONS_JSON_PATH = 'packages/nx-plugin/migrations.json';\n\n/**\n * Register the nx bump a version update needs, in `migrations.json`. Call only\n * when an nx package actually moved.\n *\n * The version sync migration itself is a committed `everyMigration` entry, so\n * only the nx packages need registering per update: they go through\n * `packageJsonUpdates` rather than a migration (see `nx-package-updates.ts`).\n *\n * Idempotent: re-running before a release claims the entry refreshes it in place.\n *\n * @returns paths written, for the update report\n */\nexport const registerNxPackageUpdates = (tree: Tree): string[] => {\n updateJson<MigrationsJson>(tree, MIGRATIONS_JSON_PATH, (migrations) => ({\n ...migrations,\n // Recorded under `latest` until stamping resolves the version it ships with.\n packageJsonUpdates: {\n ...migrations.packageJsonUpdates,\n ...nxPackageJsonUpdates(LATEST_MIGRATIONS_DIR, LATEST_MIGRATIONS_DIR),\n },\n }));\n\n return [MIGRATIONS_JSON_PATH];\n};\n"],"names":["updateJson","LATEST_MIGRATIONS_DIR","nxPackageJsonUpdates","MIGRATIONS_JSON_PATH","registerNxPackageUpdates","tree","migrations","packageJsonUpdates"],"mappings":"AAAA;;;CAGC,GACD,SAAoBA,UAAU,QAAQ,aAAa;AACnD,SACEC,qBAAqB,QAEhB,2BAAwB;AAC/B,SAASC,oBAAoB,QAAQ,0BAAuB;AAE5D,MAAMC,uBAAuB;AAE7B;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvCL,WAA2BK,MAAMF,sBAAsB,CAACG,aAAgB,CAAA;YACtE,GAAGA,UAAU;YACb,6EAA6E;YAC7EC,oBAAoB;gBAClB,GAAGD,WAAWC,kBAAkB;gBAChC,GAAGL,qBAAqBD,uBAAuBA,sBAAsB;YACvE;QACF,CAAA;IAEA,OAAO;QAACE;KAAqB;AAC/B,EAAE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { Tree } from '@nx/devkit';
|
|
6
|
+
/**
|
|
7
|
+
* Sync the plugin version the metrics files report, so usage is attributed to
|
|
8
|
+
* the release the workspace actually runs. The metric id and tags are owned by
|
|
9
|
+
* the generators and left alone.
|
|
10
|
+
*
|
|
11
|
+
* @returns the metrics files that changed
|
|
12
|
+
*/
|
|
13
|
+
export declare const syncMetricsVersion: (tree: Tree) => Promise<string[]>;
|