@aws/nx-plugin 1.0.0-rc.47 → 1.0.0-rc.49
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/LICENSE-THIRD-PARTY +15 -0
- package/generators.json +7 -0
- package/migrations.json +5 -0
- package/package.json +4 -4
- package/src/mcp-server/dev-server.d.ts +1 -0
- package/src/mcp-server/dev-server.js +18 -0
- package/src/mcp-server/dev-server.js.map +1 -0
- package/src/mcp-server/guide-pipeline.js +1 -1
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/server.js +2 -0
- package/src/mcp-server/server.js.map +1 -1
- package/src/mcp-server/tools/general-guidance.d.ts +1 -1
- package/src/mcp-server/tools/general-guidance.js +1 -0
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/mcp-server/tools/upgrade-workspace.d.ts +11 -0
- package/src/mcp-server/tools/upgrade-workspace.js +32 -0
- package/src/mcp-server/tools/upgrade-workspace.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +6 -0
- package/src/sdk/ts.d.ts +4 -2
- package/src/sdk/ts.js +4 -2
- package/src/sdk/ts.js.map +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +9 -4
- package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/agent/files/ag-ui/index.ts.template +25 -9
- package/src/ts/agent/files/common/agent.ts.template +2 -1
- package/src/ts/agent/files/deploy/Dockerfile.template +7 -3
- package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/agent/generator.js +2 -2
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/mcp-server/files/Dockerfile.template +7 -3
- package/src/ts/mcp-server/generator.js +2 -2
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-migration/files/migration.spec.ts.template +26 -0
- package/src/ts/nx-migration/files/migration.ts.template +55 -0
- package/src/ts/nx-migration/files/prompt.md.template +46 -0
- package/src/ts/nx-migration/generator.d.ts +24 -0
- package/src/ts/nx-migration/generator.js +122 -0
- package/src/ts/nx-migration/generator.js.map +1 -0
- package/src/ts/nx-migration/schema.d.js +6 -0
- package/src/ts/nx-migration/schema.d.js.map +1 -0
- package/src/ts/nx-migration/schema.d.ts +13 -0
- package/src/ts/nx-migration/schema.json +63 -0
- package/src/ts/nx-plugin/utils.d.ts +21 -1
- package/src/ts/nx-plugin/utils.js +46 -35
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +11 -3
- package/src/ts/rdb/files/Dockerfile.template +5 -1
- package/src/ts/rdb/files/src/migration-handler.ts.template +3 -1
- package/src/ts/rdb/generator.js +2 -2
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/utils/agent-connection/agent-connection.js +4 -0
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-strands/base/tool-errors-strands.ts.template +22 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +19 -1
- package/src/utils/commands.d.ts +4 -3
- package/src/utils/commands.js +6 -2
- package/src/utils/commands.js.map +1 -1
- package/src/utils/docker.d.ts +8 -0
- package/src/utils/docker.js +8 -1
- package/src/utils/docker.js.map +1 -1
- package/src/utils/format.js +54 -25
- package/src/utils/format.js.map +1 -1
- package/src/utils/init.js +7 -2
- package/src/utils/init.js.map +1 -1
- package/src/utils/mcp.d.ts +9 -0
- package/src/utils/mcp.js +9 -1
- package/src/utils/mcp.js.map +1 -1
- package/src/utils/migration-versions.d.ts +95 -0
- package/src/utils/migration-versions.js +128 -0
- package/src/utils/migration-versions.js.map +1 -0
- package/src/utils/nx.d.ts +18 -0
- package/src/utils/nx.js +24 -1
- package/src/utils/nx.js.map +1 -1
- package/src/utils/test-git.d.ts +39 -0
- package/src/utils/test-git.js +117 -0
- package/src/utils/test-git.js.map +1 -0
- package/src/utils/versions.d.ts +4 -1
- package/src/utils/versions.js +10 -2
- package/src/utils/versions.js.map +1 -1
- package/src/bin/aws-nx-mcp.d.ts +0 -2
- package/src/bin/aws-nx-mcp.js +0 -14
- package/src/bin/aws-nx-mcp.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-migration/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport type NxMigrationKind = 'deterministic' | 'agentic' | 'hybrid';\n\nexport interface TsNxMigrationGeneratorSchema {\n project: string;\n name: string;\n description?: string;\n kind?: NxMigrationKind;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD,WAMC"}
|
|
@@ -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
|
+
export type NxMigrationKind = 'deterministic' | 'agentic' | 'hybrid';
|
|
6
|
+
|
|
7
|
+
export interface TsNxMigrationGeneratorSchema {
|
|
8
|
+
project: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
kind?: NxMigrationKind;
|
|
12
|
+
preferInstallDependencies?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "TsNxMigration",
|
|
4
|
+
"title": "Create an Nx Migration",
|
|
5
|
+
"description": "Scaffold a migration for an Nx Plugin, applied by nx migrate when users upgrade",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"project": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The Nx Plugin project to add the migration to. We recommend using the ts#nx-plugin generator to create this.",
|
|
11
|
+
"x-priority": "important",
|
|
12
|
+
"x-prompt": "Choose the Nx Plugin project to add the migration to",
|
|
13
|
+
"x-dropdown": "projects",
|
|
14
|
+
"$default": {
|
|
15
|
+
"$source": "argv",
|
|
16
|
+
"index": 0
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"name": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Migration name, in kebab-case (e.g. rename-foo-target)",
|
|
22
|
+
"x-priority": "important",
|
|
23
|
+
"x-prompt": "What is the name of the migration? (kebab-case, e.g. rename-foo-target)"
|
|
24
|
+
},
|
|
25
|
+
"description": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "A description of what the migration does, shown by nx migrate",
|
|
28
|
+
"x-priority": "important",
|
|
29
|
+
"x-prompt": "Describe what the migration does"
|
|
30
|
+
},
|
|
31
|
+
"kind": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "The kind of migration: deterministic (a codemod), agentic (an AI-applied prompt for user-owned code), or hybrid (a codemod that does the mechanical part then hands off to an agent)",
|
|
34
|
+
"enum": ["deterministic", "agentic", "hybrid"],
|
|
35
|
+
"default": "deterministic",
|
|
36
|
+
"x-priority": "important",
|
|
37
|
+
"x-prompt": {
|
|
38
|
+
"message": "What kind of migration is this?",
|
|
39
|
+
"type": "list",
|
|
40
|
+
"items": [
|
|
41
|
+
{
|
|
42
|
+
"value": "deterministic",
|
|
43
|
+
"label": "Deterministic — a codemod with an exact before/after (runs unattended, incl. CI)"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"value": "agentic",
|
|
47
|
+
"label": "Agentic — an AI-applied prompt for changes to user-owned code"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"value": "hybrid",
|
|
51
|
+
"label": "Hybrid — a codemod for the mechanical part that hands off to an agent for the rest"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"preferInstallDependencies": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
|
59
|
+
"default": true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"required": ["project", "name"]
|
|
63
|
+
}
|
|
@@ -2,8 +2,28 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import { type Tree } from '@nx/devkit';
|
|
5
|
+
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
6
|
+
import type { PackageJson } from 'nx/src/utils/package-json';
|
|
7
|
+
/**
|
|
8
|
+
* Read the configuration of a project which can host Nx Plugin generators or
|
|
9
|
+
* migrations, ie a TypeScript project.
|
|
10
|
+
*/
|
|
11
|
+
export declare const readNxPluginProject: (tree: Tree, projectName: string) => ProjectConfiguration;
|
|
12
|
+
/** `package.json` field pointing Nx at one of a plugin's manifests. */
|
|
13
|
+
type NxPluginManifestField = 'generators' | 'nx-migrations';
|
|
14
|
+
/**
|
|
15
|
+
* Create the plugin project's package.json if absent and point it at the given
|
|
16
|
+
* manifest, returning its path.
|
|
17
|
+
*/
|
|
18
|
+
export declare const configureNxPluginPackageJson: <TField extends NxPluginManifestField>(tree: Tree, project: ProjectConfiguration, manifestField: TField, manifestValue: PackageJson[TField]) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Declare the dependencies the plugin's `.ts` files import on both the
|
|
21
|
+
* workspace and the plugin, since both must resolve for Nx to load them. A
|
|
22
|
+
* no-op inside the plugin's own monorepo, where they are already present.
|
|
23
|
+
*/
|
|
24
|
+
export declare const addNxPluginDependencies: (tree: Tree, pluginPackageJsonPath: string) => void;
|
|
6
25
|
/**
|
|
7
26
|
* Configures a TypeScript project as an Nx Plugin
|
|
8
27
|
*/
|
|
9
28
|
export declare const configureTsProjectAsNxPlugin: (tree: Tree, projectName: string) => void;
|
|
29
|
+
export {};
|
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import { joinPathFragments,
|
|
5
|
-
import PackageJson from "../../../package.json" with {
|
|
6
|
-
type: 'json'
|
|
7
|
-
};
|
|
4
|
+
*/ import { joinPathFragments, updateJson, writeJson } from "@nx/devkit";
|
|
8
5
|
import { addDependenciesToPackageJson } from "../../utils/dependencies.js";
|
|
9
6
|
import { isEsmWorkspace } from "../../utils/module-format.js";
|
|
10
|
-
import { readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
7
|
+
import { nxPluginSelfDependency, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
11
8
|
import { withVersions } from "../../utils/versions.js";
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
|
|
10
|
+
* Read the configuration of a project which can host Nx Plugin generators or
|
|
11
|
+
* migrations, ie a TypeScript project.
|
|
12
|
+
*/ export const readNxPluginProject = (tree, projectName)=>{
|
|
15
13
|
const project = readProjectConfigurationUnqualified(tree, projectName);
|
|
16
14
|
const tsConfigPath = joinPathFragments(project.root, 'tsconfig.json');
|
|
17
15
|
if (!tree.exists(tsConfigPath)) {
|
|
18
16
|
throw new Error(`Selected plugin project ${projectName} is not a TypeScript project`);
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
// Create a package.json if one doesn't exist, and configure "type", "main"
|
|
28
|
-
// and "generators"
|
|
18
|
+
return project;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Create the plugin project's package.json if absent and point it at the given
|
|
22
|
+
* manifest, returning its path.
|
|
23
|
+
*/ export const configureNxPluginPackageJson = (tree, project, manifestField, manifestValue)=>{
|
|
29
24
|
const pluginPackageJsonPath = joinPathFragments(project.root, 'package.json');
|
|
30
25
|
if (!tree.exists(pluginPackageJsonPath)) {
|
|
31
26
|
writeJson(tree, pluginPackageJsonPath, {
|
|
@@ -34,31 +29,47 @@ import { withVersions } from "../../utils/versions.js";
|
|
|
34
29
|
}
|
|
35
30
|
const esm = isEsmWorkspace(tree);
|
|
36
31
|
updateJson(tree, pluginPackageJsonPath, (pkg)=>{
|
|
37
|
-
// Match the plugin's module system to the workspace. Nx loads `.ts`
|
|
38
|
-
//
|
|
32
|
+
// Match the plugin's module system to the workspace. Nx loads `.ts` files
|
|
33
|
+
// via Node's native type stripping, as ESM (workspace root is
|
|
39
34
|
// `type: module`) or CommonJS accordingly.
|
|
40
35
|
pkg.type ??= esm ? 'module' : 'commonjs';
|
|
41
36
|
pkg.main ??= esm ? './src/index.js' : './src/index';
|
|
42
|
-
pkg
|
|
37
|
+
pkg[manifestField] ??= manifestValue;
|
|
43
38
|
return pkg;
|
|
44
39
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
return pluginPackageJsonPath;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Declare the dependencies the plugin's `.ts` files import on both the
|
|
44
|
+
* workspace and the plugin, since both must resolve for Nx to load them. A
|
|
45
|
+
* no-op inside the plugin's own monorepo, where they are already present.
|
|
46
|
+
*/ export const addNxPluginDependencies = (tree, pluginPackageJsonPath)=>{
|
|
47
|
+
const selfDependency = nxPluginSelfDependency(tree);
|
|
48
|
+
if (Object.keys(selfDependency).length === 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const deps = {
|
|
52
|
+
...withVersions([
|
|
53
|
+
'@nx/devkit'
|
|
54
|
+
]),
|
|
55
|
+
...selfDependency
|
|
56
|
+
};
|
|
57
|
+
addDependenciesToPackageJson(tree, {}, deps);
|
|
58
|
+
addDependenciesToPackageJson(tree, deps, {}, pluginPackageJsonPath);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Configures a TypeScript project as an Nx Plugin
|
|
62
|
+
*/ export const configureTsProjectAsNxPlugin = (tree, projectName)=>{
|
|
63
|
+
const project = readNxPluginProject(tree, projectName);
|
|
64
|
+
// Create an empty generators.json if one dosn't exist
|
|
65
|
+
const generatorsJsonPath = joinPathFragments(project.root, 'generators.json');
|
|
66
|
+
if (!tree.exists(generatorsJsonPath)) {
|
|
67
|
+
writeJson(tree, generatorsJsonPath, {
|
|
68
|
+
generators: {}
|
|
69
|
+
});
|
|
61
70
|
}
|
|
71
|
+
const pluginPackageJsonPath = configureNxPluginPackageJson(tree, project, 'generators', './generators.json');
|
|
72
|
+
addNxPluginDependencies(tree, pluginPackageJsonPath);
|
|
62
73
|
};
|
|
63
74
|
|
|
64
75
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n type ProjectConfiguration,\n type Tree,\n updateJson,\n writeJson,\n} from '@nx/devkit';\nimport type { PackageJson } from 'nx/src/utils/package-json';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport {\n nxPluginSelfDependency,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { withVersions } from '../../utils/versions';\n\n/**\n * Read the configuration of a project which can host Nx Plugin generators or\n * migrations, ie a TypeScript project.\n */\nexport const readNxPluginProject = (\n tree: Tree,\n projectName: string,\n): ProjectConfiguration => {\n const project = readProjectConfigurationUnqualified(tree, projectName);\n\n const tsConfigPath = joinPathFragments(project.root, 'tsconfig.json');\n if (!tree.exists(tsConfigPath)) {\n throw new Error(\n `Selected plugin project ${projectName} is not a TypeScript project`,\n );\n }\n\n return project;\n};\n\n/** `package.json` field pointing Nx at one of a plugin's manifests. */\ntype NxPluginManifestField = 'generators' | 'nx-migrations';\n\n/**\n * Create the plugin project's package.json if absent and point it at the given\n * manifest, returning its path.\n */\nexport const configureNxPluginPackageJson = <\n TField extends NxPluginManifestField,\n>(\n tree: Tree,\n project: ProjectConfiguration,\n manifestField: TField,\n manifestValue: PackageJson[TField],\n): string => {\n const pluginPackageJsonPath = joinPathFragments(project.root, 'package.json');\n if (!tree.exists(pluginPackageJsonPath)) {\n writeJson(tree, pluginPackageJsonPath, {\n name: project.name,\n });\n }\n const esm = isEsmWorkspace(tree);\n updateJson(tree, pluginPackageJsonPath, (pkg) => {\n // Match the plugin's module system to the workspace. Nx loads `.ts` files\n // via Node's native type stripping, as ESM (workspace root is\n // `type: module`) or CommonJS accordingly.\n pkg.type ??= esm ? 'module' : 'commonjs';\n pkg.main ??= esm ? './src/index.js' : './src/index';\n pkg[manifestField] ??= manifestValue;\n return pkg;\n });\n return pluginPackageJsonPath;\n};\n\n/**\n * Declare the dependencies the plugin's `.ts` files import on both the\n * workspace and the plugin, since both must resolve for Nx to load them. A\n * no-op inside the plugin's own monorepo, where they are already present.\n */\nexport const addNxPluginDependencies = (\n tree: Tree,\n pluginPackageJsonPath: string,\n): void => {\n const selfDependency = nxPluginSelfDependency(tree);\n if (Object.keys(selfDependency).length === 0) {\n return;\n }\n const deps = {\n ...withVersions(['@nx/devkit']),\n ...selfDependency,\n };\n addDependenciesToPackageJson(tree, {}, deps);\n addDependenciesToPackageJson(tree, deps, {}, pluginPackageJsonPath);\n};\n\n/**\n * Configures a TypeScript project as an Nx Plugin\n */\nexport const configureTsProjectAsNxPlugin = (\n tree: Tree,\n projectName: string,\n) => {\n const project = readNxPluginProject(tree, projectName);\n\n // Create an empty generators.json if one dosn't exist\n const generatorsJsonPath = joinPathFragments(project.root, 'generators.json');\n if (!tree.exists(generatorsJsonPath)) {\n writeJson(tree, generatorsJsonPath, {\n generators: {},\n });\n }\n\n const pluginPackageJsonPath = configureNxPluginPackageJson(\n tree,\n project,\n 'generators',\n './generators.json',\n );\n\n addNxPluginDependencies(tree, pluginPackageJsonPath);\n};\n"],"names":["joinPathFragments","updateJson","writeJson","addDependenciesToPackageJson","isEsmWorkspace","nxPluginSelfDependency","readProjectConfigurationUnqualified","withVersions","readNxPluginProject","tree","projectName","project","tsConfigPath","root","exists","Error","configureNxPluginPackageJson","manifestField","manifestValue","pluginPackageJsonPath","name","esm","pkg","type","main","addNxPluginDependencies","selfDependency","Object","keys","length","deps","configureTsProjectAsNxPlugin","generatorsJsonPath","generators"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,EAGjBC,UAAU,EACVC,SAAS,QACJ,aAAa;AAEpB,SAASC,4BAA4B,QAAQ,8BAA2B;AACxE,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SACEC,sBAAsB,EACtBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,YAAY,QAAQ,0BAAuB;AAEpD;;;CAGC,GACD,OAAO,MAAMC,sBAAsB,CACjCC,MACAC;IAEA,MAAMC,UAAUL,oCAAoCG,MAAMC;IAE1D,MAAME,eAAeZ,kBAAkBW,QAAQE,IAAI,EAAE;IACrD,IAAI,CAACJ,KAAKK,MAAM,CAACF,eAAe;QAC9B,MAAM,IAAIG,MACR,CAAC,wBAAwB,EAAEL,YAAY,4BAA4B,CAAC;I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EAAE"}
|
|
@@ -105,6 +105,7 @@ exports[`ts#rdb generator > should add mysql prisma dependencies when engine is
|
|
|
105
105
|
|
|
106
106
|
exports[`ts#rdb generator > should add mysql prisma dependencies when engine is MySQL > packages/db/src/migration-handler.ts 1`] = `
|
|
107
107
|
"import { execFile } from 'node:child_process';
|
|
108
|
+
import { join } from 'node:path';
|
|
108
109
|
import { promisify } from 'node:util';
|
|
109
110
|
import { getDatabaseSecret, withConnectionRetry } from './utils.js';
|
|
110
111
|
|
|
@@ -122,7 +123,8 @@ const buildDatabaseUrl = async (): Promise<string> => {
|
|
|
122
123
|
export const handler = async () => {
|
|
123
124
|
await withConnectionRetry(async () => {
|
|
124
125
|
const databaseUrl = await buildDatabaseUrl();
|
|
125
|
-
|
|
126
|
+
const prisma = join(__dirname, 'node_modules', '.bin', 'prisma');
|
|
127
|
+
await promisify(execFile)(prisma, ['migrate', 'deploy'], {
|
|
126
128
|
cwd: __dirname,
|
|
127
129
|
env: {
|
|
128
130
|
...process.env,
|
|
@@ -3882,6 +3884,7 @@ exports[`ts#rdb generator > should generate the aurora shared construct > packag
|
|
|
3882
3884
|
|
|
3883
3885
|
exports[`ts#rdb generator > should generate the aurora shared construct > packages/db/src/migration-handler.ts 1`] = `
|
|
3884
3886
|
"import { execFile } from 'node:child_process';
|
|
3887
|
+
import { join } from 'node:path';
|
|
3885
3888
|
import { promisify } from 'node:util';
|
|
3886
3889
|
import { getDatabaseSecret, withConnectionRetry } from './utils.js';
|
|
3887
3890
|
|
|
@@ -3899,7 +3902,8 @@ const buildDatabaseUrl = async (): Promise<string> => {
|
|
|
3899
3902
|
export const handler = async () => {
|
|
3900
3903
|
await withConnectionRetry(async () => {
|
|
3901
3904
|
const databaseUrl = await buildDatabaseUrl();
|
|
3902
|
-
|
|
3905
|
+
const prisma = join(__dirname, 'node_modules', '.bin', 'prisma');
|
|
3906
|
+
await promisify(execFile)(prisma, ['migrate', 'deploy'], {
|
|
3903
3907
|
cwd: __dirname,
|
|
3904
3908
|
env: {
|
|
3905
3909
|
...process.env,
|
|
@@ -4680,9 +4684,13 @@ WORKDIR \${LAMBDA_TASK_ROOT}
|
|
|
4680
4684
|
|
|
4681
4685
|
# npm blocks dependency install scripts by default; allow prisma's so its
|
|
4682
4686
|
# postinstall downloads the schema-engine binary needed to run migrations.
|
|
4687
|
+
# npm is removed once prisma is installed — the handler runs prisma's own
|
|
4688
|
+
# binary directly, and npm's bundled dependencies would otherwise carry known
|
|
4689
|
+
# HIGH/CRITICAL vulnerabilities into the image.
|
|
4683
4690
|
RUN printf 'allow-scripts[]=prisma\\nallow-scripts[]=@prisma/engines\\n' > .npmrc \\
|
|
4684
4691
|
&& npm install prisma@7.8.0 \\
|
|
4685
|
-
&& rm .npmrc
|
|
4692
|
+
&& rm .npmrc \\
|
|
4693
|
+
&& npm uninstall -g npm
|
|
4686
4694
|
|
|
4687
4695
|
COPY index.js ./index.js
|
|
4688
4696
|
COPY prisma ./prisma
|
|
@@ -14,9 +14,13 @@ WORKDIR ${LAMBDA_TASK_ROOT}
|
|
|
14
14
|
|
|
15
15
|
# npm blocks dependency install scripts by default; allow prisma's so its
|
|
16
16
|
# postinstall downloads the schema-engine binary needed to run migrations.
|
|
17
|
+
# npm is removed once prisma is installed — the handler runs prisma's own
|
|
18
|
+
# binary directly, and npm's bundled dependencies would otherwise carry known
|
|
19
|
+
# HIGH/CRITICAL vulnerabilities into the image.
|
|
17
20
|
RUN printf 'allow-scripts[]=prisma\nallow-scripts[]=@prisma/engines\n' > .npmrc \
|
|
18
21
|
&& npm install prisma@<%= prismaVersion %> \
|
|
19
|
-
&& rm .npmrc
|
|
22
|
+
&& rm .npmrc \
|
|
23
|
+
&& npm uninstall -g npm
|
|
20
24
|
|
|
21
25
|
COPY index.js ./index.js
|
|
22
26
|
COPY prisma ./prisma
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
import { promisify } from 'node:util';
|
|
3
4
|
import { getDatabaseSecret, withConnectionRetry } from './utils<% if (esm) { %>.js<% } %>';
|
|
4
5
|
|
|
@@ -16,7 +17,8 @@ const buildDatabaseUrl = async (): Promise<string> => {
|
|
|
16
17
|
export const handler = async () => {
|
|
17
18
|
await withConnectionRetry(async () => {
|
|
18
19
|
const databaseUrl = await buildDatabaseUrl();
|
|
19
|
-
|
|
20
|
+
const prisma = join(__dirname, 'node_modules', '.bin', 'prisma');
|
|
21
|
+
await promisify(execFile)(prisma, ['migrate', 'deploy'], {
|
|
20
22
|
cwd: __dirname,
|
|
21
23
|
env: {
|
|
22
24
|
...process.env,
|
package/src/ts/rdb/generator.js
CHANGED
|
@@ -6,7 +6,7 @@ import { generateFiles, joinPathFragments, readProjectConfiguration, updateJson,
|
|
|
6
6
|
import { addTypeScriptBundleTarget } from "../../utils/bundle/bundle.js";
|
|
7
7
|
import { resolveContainers } from "../../utils/containers.js";
|
|
8
8
|
import { addDependenciesToPackageJson } from "../../utils/dependencies.js";
|
|
9
|
-
import { addDockerScanTarget } from "../../utils/docker.js";
|
|
9
|
+
import { addDockerScanTarget, nodeImageVersions } from "../../utils/docker.js";
|
|
10
10
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
11
11
|
import { FsCommands } from "../../utils/fs.js";
|
|
12
12
|
import { updateGitIgnore } from "../../utils/git.js";
|
|
@@ -72,7 +72,7 @@ export const tsRdbGenerator = async (tree, options)=>{
|
|
|
72
72
|
databasePackageAlias: fullyQualifiedName,
|
|
73
73
|
databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',
|
|
74
74
|
prismaVersion: TS_VERSIONS.prisma,
|
|
75
|
-
|
|
75
|
+
...nodeImageVersions(),
|
|
76
76
|
prismaAdapterPackage: options.engine === 'mysql' ? '@prisma/adapter-mariadb' : '@prisma/adapter-pg',
|
|
77
77
|
prismaAdapterClassName: options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',
|
|
78
78
|
localDbPort,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { addDockerScanTarget } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { updateGitIgnore } from '../../utils/git';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace';\nimport { assignPort } from '../../utils/port';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport { sharedRdbScriptsGenerator } from '../../utils/shared-rdb-scripts';\nimport { TS_VERSIONS, withVersions } from '../../utils/versions';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport type { TsRdbGeneratorSchema } from './schema';\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: fullyQualifiedName,\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n npmVersion: TS_VERSIONS.npm,\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n ...esmVars(tree),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const migrationDockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n });\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n });\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cp(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cp(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cp(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n if (iac === 'terraform') {\n projectConfig.targets['docker'] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${migrationDockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'docker');\n\n addDockerScanTarget(tree, {\n project: projectConfig,\n containerEngine,\n trivyTargetName: 'trivy',\n dockerTargetName: 'docker',\n imageTags: [migrationDockerImageTag],\n });\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n addGeneratorMetadata(tree, fullyQualifiedName, TS_RDB_GENERATOR_INFO, {\n engine: options.engine,\n });\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: fullyQualifiedName,\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n framework: options.framework,\n migrationDockerImageTag,\n containerEngine,\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n '@aws-sdk/client-secrets-manager',\n '@aws-sdk/rds-signer',\n '@prisma/client',\n ...(options.engine === 'mysql'\n ? (['@prisma/adapter-mariadb', 'mariadb'] as const)\n : (['@prisma/adapter-pg', 'pg'] as const)),\n ]),\n withVersions([\n '@types/aws-lambda',\n ...(options.engine === 'mysql'\n ? ([] as const)\n : (['@types/pg'] as const)),\n ]),\n joinPathFragments(projectConfig.root, 'package.json'),\n );\n // The prisma CLI and tsx run migration/seed scripts from the root.\n addDependenciesToPackageJson(tree, {}, withVersions(['prisma', 'tsx']));\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","generateFiles","joinPathFragments","readProjectConfiguration","updateJson","updateProjectConfiguration","addTypeScriptBundleTarget","resolveContainers","addDependenciesToPackageJson","addDockerScanTarget","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","sharedRdbScriptsGenerator","TS_VERSIONS","withVersions","tsProjectGenerator","getTsLibDetails","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","name","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","engine","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","npmVersion","npm","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","patterns","waitForDbScript","scriptsDir","relativePathToRoot","root","fs","migrationBundleDir","migrationDockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","continuous","dependsOn","env","LOCAL_DEV","iac","cache","project","trivyTargetName","dockerTargetName","imageTags","projectName","projectRoot","adminUser","createDbUserBundleDir","framework","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SAEEC,aAAa,EACbC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,yBAAyB,QAAQ,+BAA4B;AACtE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,4BAA4B,QAAQ,8BAA2B;AACxE,SAASC,mBAAmB,QAAQ,wBAAqB;AACzD,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SA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Q,oBAAoBQ;IACrDjC,qBAAqBiB,MAAMQ,oBAAoBX,uBAAuB;QACpEqB,QAAQjB,QAAQiB,MAAM;IACxB;IAEA,IAAIjB,QAAQ2C,KAAK,KAAK,QAAQ;QAC5B,MAAMoB,MAAM,MAAM1F,WAAW0B,MAAMC,QAAQ+D,GAAG;QAC9C,MAAM3E,0BAA0BW,MAAM;YAAEgE;QAAI;QAC5C,MAAM5E,YAAYY,MAAM;YACtBgE;YACAM,aAAa9D;YACb+D,aAAa9D;YACbL;YACAF;YACAwB,sBAAsBlB;YACtBF;YACAkE,WAAWnE;YACXa,QAAQjB,QAAQiB,MAAM;YACtBwB;YACA+B,uBAAuB9G,kBACrB,QACAqD,cAAcwB,IAAI,EAClB,UACA;YAEFkC,WAAWzE,QAAQyE,SAAS;YAC5B/B;YACApC;QACF;IACF;IAEAtC,6BACE+B,MACAN,aAAa;QACX;QACA;QACA;QACA;QACA;WACIO,QAAQiB,MAAM,KAAK,UAClB;YAAC;YAA2B;SAAU,GACtC;YAAC;YAAsB;SAAK;KAClC,GACDxB,aAAa;QACX;WACIO,QAAQiB,MAAM,KAAK,UAClB,EAAE,GACF;YAAC;SAAY;KACnB,GACDvD,kBAAkBqD,cAAcwB,IAAI,EAAE;IAExC,mEAAmE;IACnEvE,6BAA6B+B,MAAM,CAAC,GAAGN,aAAa;QAAC;QAAU;KAAM;IAErER,8BAA8Bc,MAAM;QAClC,mBAAmB;QACnB6B,QAAQ;IACV;IAEA,MAAMrD,gCAAgCwB,MAAM;QAACH;KAAsB;IAEnE,MAAM1B,qBAAqB6B;IAC3B,OAAO,IACLzB,oBAAoByB,MAAMC,QAAQY,yBAAyB,EAAE;YAC3D8D,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe5E,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { addDockerScanTarget, nodeImageVersions } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { updateGitIgnore } from '../../utils/git';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace';\nimport { assignPort } from '../../utils/port';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport {\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport { sharedRdbScriptsGenerator } from '../../utils/shared-rdb-scripts';\nimport { TS_VERSIONS, withVersions } from '../../utils/versions';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport type { TsRdbGeneratorSchema } from './schema';\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: fullyQualifiedName,\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n ...nodeImageVersions(),\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n ...esmVars(tree),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const migrationDockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n });\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n });\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cp(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cp(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cp(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n if (iac === 'terraform') {\n projectConfig.targets['docker'] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${migrationDockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'docker');\n\n addDockerScanTarget(tree, {\n project: projectConfig,\n containerEngine,\n trivyTargetName: 'trivy',\n dockerTargetName: 'docker',\n imageTags: [migrationDockerImageTag],\n });\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'build', 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n addGeneratorMetadata(tree, fullyQualifiedName, TS_RDB_GENERATOR_INFO, {\n engine: options.engine,\n });\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: fullyQualifiedName,\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n framework: options.framework,\n migrationDockerImageTag,\n containerEngine,\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n '@aws-sdk/client-secrets-manager',\n '@aws-sdk/rds-signer',\n '@prisma/client',\n ...(options.engine === 'mysql'\n ? (['@prisma/adapter-mariadb', 'mariadb'] as const)\n : (['@prisma/adapter-pg', 'pg'] as const)),\n ]),\n withVersions([\n '@types/aws-lambda',\n ...(options.engine === 'mysql'\n ? ([] as const)\n : (['@types/pg'] as const)),\n ]),\n joinPathFragments(projectConfig.root, 'package.json'),\n );\n // The prisma CLI and tsx run migration/seed scripts from the root.\n addDependenciesToPackageJson(tree, {}, withVersions(['prisma', 'tsx']));\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","generateFiles","joinPathFragments","readProjectConfiguration","updateJson","updateProjectConfiguration","addTypeScriptBundleTarget","resolveContainers","addDependenciesToPackageJson","addDockerScanTarget","nodeImageVersions","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","sharedRdbScriptsGenerator","TS_VERSIONS","withVersions","tsProjectGenerator","getTsLibDetails","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","name","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","engine","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","patterns","waitForDbScript","scriptsDir","relativePathToRoot","root","fs","migrationBundleDir","migrationDockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cp","parallel","generate","executor","outputs","cwd","continuous","dependsOn","env","LOCAL_DEV","iac","cache","project","trivyTargetName","dockerTargetName","imageTags","projectName","projectRoot","adminUser","createDbUserBundleDir","framework","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SAEEC,aAAa,EACbC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,yBAAyB,QAAQ,+BAA4B;AACtE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,4BAA4B,QAAQ,8BAA2B;AACxE,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,wBAAqB;AAC5E,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,OAAO,QAAQ,+BAA4B;AACpD,SAASC,SAAS,EAAEC,SAAS,EAAEC,WAAW,QAAQ,uBAAoB;AACtE,SAASC,WAAW,QAAQ,2BAAwB;A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