@aws/nx-plugin 1.0.6 → 1.0.8
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 +3 -3
- package/migrations.json +26 -1
- package/package.json +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/infra/app/files/app/README.md.template +12 -0
- package/src/infra/app/generator.js +8 -0
- package/src/infra/app/generator.js.map +1 -1
- package/src/migrations/latest/cache-inputs-outputs/metadata.json +3 -0
- package/src/migrations/latest/cache-inputs-outputs/migration.d.ts +6 -0
- package/src/migrations/latest/cache-inputs-outputs/migration.js +176 -0
- package/src/migrations/latest/cache-inputs-outputs/migration.js.map +1 -0
- package/src/migrations/latest/infra-test-loop/metadata.json +3 -0
- package/src/migrations/latest/infra-test-loop/migration.d.ts +6 -0
- package/src/migrations/latest/infra-test-loop/migration.js +110 -0
- package/src/migrations/latest/infra-test-loop/migration.js.map +1 -0
- package/src/migrations/latest/pin-strands-express-peer/metadata.json +3 -0
- package/src/migrations/latest/pin-strands-express-peer/migration.d.ts +29 -0
- package/src/migrations/latest/pin-strands-express-peer/migration.js +58 -0
- package/src/migrations/latest/pin-strands-express-peer/migration.js.map +1 -0
- package/src/migrations/latest/py-dynamodb-type-base-model-meta/metadata.json +3 -0
- package/src/migrations/latest/py-dynamodb-type-base-model-meta/migration.d.ts +6 -0
- package/src/migrations/latest/py-dynamodb-type-base-model-meta/migration.js +87 -0
- package/src/migrations/latest/py-dynamodb-type-base-model-meta/migration.js.map +1 -0
- package/src/migrations/latest/rdb-drop-lambda-rie/metadata.json +3 -0
- package/src/migrations/latest/rdb-drop-lambda-rie/migration.d.ts +6 -0
- package/src/migrations/latest/rdb-drop-lambda-rie/migration.js +105 -0
- package/src/migrations/latest/rdb-drop-lambda-rie/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0004-python-test-input-scoping/migration.js +8 -2
- package/src/migrations/v1.0.0-rc.90/0004-python-test-input-scoping/migration.js.map +1 -1
- package/src/open-api/py-client/files/client/__clientModuleName__.py.template +17 -6
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/py/dynamodb/files/__name__/entities/base.py.template +2 -2
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +20 -8
- package/src/py/rdb/files/Dockerfile.create-db-user.template +5 -2
- package/src/py/rdb/files/Dockerfile.migration.template +5 -2
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/smithy/project/generator.d.ts +9 -0
- package/src/smithy/project/generator.js +15 -0
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/terraform/project/generator.js +2 -4
- package/src/terraform/project/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +26 -30
- package/src/ts/agent/a2a-connection/generator.js +9 -5
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +5 -7
- package/src/ts/agent/gateway-connection/generator.js +12 -0
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.d.ts +3 -8
- package/src/ts/agent/generator.js +16 -2
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +5 -7
- package/src/ts/agent/mcp-connection/generator.js +12 -0
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/astro-docs/generator.d.ts +4 -4
- package/src/ts/astro-docs/generator.js +10 -4
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/lib/generator.d.ts +14 -3
- package/src/ts/lib/generator.js +18 -7
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +4 -2
- package/src/ts/rdb/files/Dockerfile.template +4 -2
- package/src/ts/rdb/generator.js +4 -0
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +102 -2
- package/src/utils/__snapshots__/cdk-test-setup.spec.ts.snap +25 -0
- package/src/utils/agent-connection/agent-connection.d.ts +28 -5
- package/src/utils/agent-connection/agent-connection.js +39 -14
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/cdk-test-setup.d.ts +22 -0
- package/src/utils/cdk-test-setup.js +38 -0
- package/src/utils/cdk-test-setup.js.map +1 -0
- package/src/utils/files/cdk-test-setup/tests/global-setup.ts.template +45 -0
- package/src/utils/shared-constructs.js +2 -0
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/test/python-dependencies.d.ts +6 -0
- package/src/utils/test/python-dependencies.js +9 -0
- package/src/utils/test/python-dependencies.js.map +1 -1
- package/src/utils/test/warm-python-cache.js +40 -21
- package/src/utils/test/warm-python-cache.js.map +1 -1
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
- package/src/utils/versions.js.map +1 -1
|
@@ -173,10 +173,13 @@ exports[`py#rdb generator > should generate MySQL dependencies and templates 4`]
|
|
|
173
173
|
# Patch OS packages beyond the base image's pinned release, and drop pip, whose
|
|
174
174
|
# vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
|
|
175
175
|
# The handler's dependencies are already installed in the image, so nothing
|
|
176
|
-
# installs packages at runtime.
|
|
176
|
+
# installs packages at runtime. Also drop the Lambda Runtime Interface
|
|
177
|
+
# Emulator: it is only used for local \`docker run\` emulation outside Lambda,
|
|
178
|
+
# never by the deployed function, and carries known HIGH vulnerabilities.
|
|
177
179
|
RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
|
|
178
180
|
&& rm -rf /var/lang/lib/python*/site-packages/pip \\
|
|
179
|
-
/var/lang/lib/python*/site-packages/pip-*.dist-info
|
|
181
|
+
/var/lang/lib/python*/site-packages/pip-*.dist-info \\
|
|
182
|
+
/usr/local/bin/aws-lambda-rie
|
|
180
183
|
|
|
181
184
|
WORKDIR \${LAMBDA_TASK_ROOT}
|
|
182
185
|
|
|
@@ -195,10 +198,13 @@ exports[`py#rdb generator > should generate MySQL dependencies and templates 5`]
|
|
|
195
198
|
# Patch OS packages beyond the base image's pinned release, and drop pip, whose
|
|
196
199
|
# vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
|
|
197
200
|
# The handler's dependencies are already installed in the image, so nothing
|
|
198
|
-
# installs packages at runtime.
|
|
201
|
+
# installs packages at runtime. Also drop the Lambda Runtime Interface
|
|
202
|
+
# Emulator: it is only used for local \`docker run\` emulation outside Lambda,
|
|
203
|
+
# never by the deployed function, and carries known HIGH vulnerabilities.
|
|
199
204
|
RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
|
|
200
205
|
&& rm -rf /var/lang/lib/python*/site-packages/pip \\
|
|
201
|
-
/var/lang/lib/python*/site-packages/pip-*.dist-info
|
|
206
|
+
/var/lang/lib/python*/site-packages/pip-*.dist-info \\
|
|
207
|
+
/usr/local/bin/aws-lambda-rie
|
|
202
208
|
|
|
203
209
|
WORKDIR \${LAMBDA_TASK_ROOT}
|
|
204
210
|
|
|
@@ -1393,10 +1399,13 @@ exports[`py#rdb generator > should generate a PostgreSQL SQLModel project with A
|
|
|
1393
1399
|
# Patch OS packages beyond the base image's pinned release, and drop pip, whose
|
|
1394
1400
|
# vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
|
|
1395
1401
|
# The handler's dependencies are already installed in the image, so nothing
|
|
1396
|
-
# installs packages at runtime.
|
|
1402
|
+
# installs packages at runtime. Also drop the Lambda Runtime Interface
|
|
1403
|
+
# Emulator: it is only used for local \`docker run\` emulation outside Lambda,
|
|
1404
|
+
# never by the deployed function, and carries known HIGH vulnerabilities.
|
|
1397
1405
|
RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
|
|
1398
1406
|
&& rm -rf /var/lang/lib/python*/site-packages/pip \\
|
|
1399
|
-
/var/lang/lib/python*/site-packages/pip-*.dist-info
|
|
1407
|
+
/var/lang/lib/python*/site-packages/pip-*.dist-info \\
|
|
1408
|
+
/usr/local/bin/aws-lambda-rie
|
|
1400
1409
|
|
|
1401
1410
|
WORKDIR \${LAMBDA_TASK_ROOT}
|
|
1402
1411
|
|
|
@@ -1415,10 +1424,13 @@ exports[`py#rdb generator > should generate a PostgreSQL SQLModel project with A
|
|
|
1415
1424
|
# Patch OS packages beyond the base image's pinned release, and drop pip, whose
|
|
1416
1425
|
# vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
|
|
1417
1426
|
# The handler's dependencies are already installed in the image, so nothing
|
|
1418
|
-
# installs packages at runtime.
|
|
1427
|
+
# installs packages at runtime. Also drop the Lambda Runtime Interface
|
|
1428
|
+
# Emulator: it is only used for local \`docker run\` emulation outside Lambda,
|
|
1429
|
+
# never by the deployed function, and carries known HIGH vulnerabilities.
|
|
1419
1430
|
RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
|
|
1420
1431
|
&& rm -rf /var/lang/lib/python*/site-packages/pip \\
|
|
1421
|
-
/var/lang/lib/python*/site-packages/pip-*.dist-info
|
|
1432
|
+
/var/lang/lib/python*/site-packages/pip-*.dist-info \\
|
|
1433
|
+
/usr/local/bin/aws-lambda-rie
|
|
1422
1434
|
|
|
1423
1435
|
WORKDIR \${LAMBDA_TASK_ROOT}
|
|
1424
1436
|
|
|
@@ -3,10 +3,13 @@ FROM public.ecr.aws/lambda/python:3.14
|
|
|
3
3
|
# Patch OS packages beyond the base image's pinned release, and drop pip, whose
|
|
4
4
|
# vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
|
|
5
5
|
# The handler's dependencies are already installed in the image, so nothing
|
|
6
|
-
# installs packages at runtime.
|
|
6
|
+
# installs packages at runtime. Also drop the Lambda Runtime Interface
|
|
7
|
+
# Emulator: it is only used for local `docker run` emulation outside Lambda,
|
|
8
|
+
# never by the deployed function, and carries known HIGH vulnerabilities.
|
|
7
9
|
RUN microdnf upgrade -y --releasever latest && microdnf clean all \
|
|
8
10
|
&& rm -rf /var/lang/lib/python*/site-packages/pip \
|
|
9
|
-
/var/lang/lib/python*/site-packages/pip-*.dist-info
|
|
11
|
+
/var/lang/lib/python*/site-packages/pip-*.dist-info \
|
|
12
|
+
/usr/local/bin/aws-lambda-rie
|
|
10
13
|
|
|
11
14
|
WORKDIR ${LAMBDA_TASK_ROOT}
|
|
12
15
|
|
|
@@ -3,10 +3,13 @@ FROM public.ecr.aws/lambda/python:3.14
|
|
|
3
3
|
# Patch OS packages beyond the base image's pinned release, and drop pip, whose
|
|
4
4
|
# vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
|
|
5
5
|
# The handler's dependencies are already installed in the image, so nothing
|
|
6
|
-
# installs packages at runtime.
|
|
6
|
+
# installs packages at runtime. Also drop the Lambda Runtime Interface
|
|
7
|
+
# Emulator: it is only used for local `docker run` emulation outside Lambda,
|
|
8
|
+
# never by the deployed function, and carries known HIGH vulnerabilities.
|
|
7
9
|
RUN microdnf upgrade -y --releasever latest && microdnf clean all \
|
|
8
10
|
&& rm -rf /var/lang/lib/python*/site-packages/pip \
|
|
9
|
-
/var/lang/lib/python*/site-packages/pip-*.dist-info
|
|
11
|
+
/var/lang/lib/python*/site-packages/pip-*.dist-info \
|
|
12
|
+
/usr/local/bin/aws-lambda-rie
|
|
10
13
|
|
|
11
14
|
WORKDIR ${LAMBDA_TASK_ROOT}
|
|
12
15
|
|
|
@@ -35,6 +35,7 @@ exports[`smithyProjectGenerator > shape libraries > should generate a shape libr
|
|
|
35
35
|
},
|
|
36
36
|
"compile": {
|
|
37
37
|
"cache": true,
|
|
38
|
+
"inputs": ["default"],
|
|
38
39
|
"outputs": [
|
|
39
40
|
"{workspaceRoot}/dist/{projectRoot}/smithy",
|
|
40
41
|
"{workspaceRoot}/dist/{projectRoot}/build/model.json"
|
|
@@ -112,6 +113,7 @@ exports[`smithyProjectGenerator > should generate smithy project with all custom
|
|
|
112
113
|
},
|
|
113
114
|
"compile": {
|
|
114
115
|
"cache": true,
|
|
116
|
+
"inputs": ["default"],
|
|
115
117
|
"outputs": [
|
|
116
118
|
"{workspaceRoot}/dist/{projectRoot}/smithy",
|
|
117
119
|
"{workspaceRoot}/dist/{projectRoot}/build/openapi"
|
|
@@ -132,6 +134,7 @@ exports[`smithyProjectGenerator > should generate smithy project with all custom
|
|
|
132
134
|
},
|
|
133
135
|
"generate-ssdk": {
|
|
134
136
|
"cache": true,
|
|
137
|
+
"inputs": ["default"],
|
|
135
138
|
"outputs": ["{workspaceRoot}/dist/{projectRoot}/build/ssdk"],
|
|
136
139
|
"executor": "nx:run-commands",
|
|
137
140
|
"dependsOn": ["compile"],
|
|
@@ -170,6 +173,7 @@ exports[`smithyProjectGenerator > should generate smithy project with custom dir
|
|
|
170
173
|
},
|
|
171
174
|
"compile": {
|
|
172
175
|
"cache": true,
|
|
176
|
+
"inputs": ["default"],
|
|
173
177
|
"outputs": [
|
|
174
178
|
"{workspaceRoot}/dist/{projectRoot}/smithy",
|
|
175
179
|
"{workspaceRoot}/dist/{projectRoot}/build/openapi"
|
|
@@ -190,6 +194,7 @@ exports[`smithyProjectGenerator > should generate smithy project with custom dir
|
|
|
190
194
|
},
|
|
191
195
|
"generate-ssdk": {
|
|
192
196
|
"cache": true,
|
|
197
|
+
"inputs": ["default"],
|
|
193
198
|
"outputs": ["{workspaceRoot}/dist/{projectRoot}/build/ssdk"],
|
|
194
199
|
"executor": "nx:run-commands",
|
|
195
200
|
"dependsOn": ["compile"],
|
|
@@ -320,6 +325,7 @@ exports[`smithyProjectGenerator > should generate smithy project with default op
|
|
|
320
325
|
},
|
|
321
326
|
"compile": {
|
|
322
327
|
"cache": true,
|
|
328
|
+
"inputs": ["default"],
|
|
323
329
|
"outputs": [
|
|
324
330
|
"{workspaceRoot}/dist/{projectRoot}/smithy",
|
|
325
331
|
"{workspaceRoot}/dist/{projectRoot}/build/openapi"
|
|
@@ -340,6 +346,7 @@ exports[`smithyProjectGenerator > should generate smithy project with default op
|
|
|
340
346
|
},
|
|
341
347
|
"generate-ssdk": {
|
|
342
348
|
"cache": true,
|
|
349
|
+
"inputs": ["default"],
|
|
343
350
|
"outputs": ["{workspaceRoot}/dist/{projectRoot}/build/ssdk"],
|
|
344
351
|
"executor": "nx:run-commands",
|
|
345
352
|
"dependsOn": ["compile"],
|
|
@@ -464,6 +471,7 @@ exports[`smithyProjectGenerator > should generate smithy project with subdirecto
|
|
|
464
471
|
},
|
|
465
472
|
"compile": {
|
|
466
473
|
"cache": true,
|
|
474
|
+
"inputs": ["default"],
|
|
467
475
|
"outputs": [
|
|
468
476
|
"{workspaceRoot}/dist/{projectRoot}/smithy",
|
|
469
477
|
"{workspaceRoot}/dist/{projectRoot}/build/openapi"
|
|
@@ -484,6 +492,7 @@ exports[`smithyProjectGenerator > should generate smithy project with subdirecto
|
|
|
484
492
|
},
|
|
485
493
|
"generate-ssdk": {
|
|
486
494
|
"cache": true,
|
|
495
|
+
"inputs": ["default"],
|
|
487
496
|
"outputs": ["{workspaceRoot}/dist/{projectRoot}/build/ssdk"],
|
|
488
497
|
"executor": "nx:run-commands",
|
|
489
498
|
"dependsOn": ["compile"],
|
|
@@ -62,12 +62,21 @@ export declare const smithyGenerateSsdkCommands: () => string[];
|
|
|
62
62
|
* restoring `compile` from cache would otherwise discard the Server SDK beside it.
|
|
63
63
|
*/
|
|
64
64
|
export declare const smithyCompileOutputs: (type: SmithyProjectGeneratorSchema["type"]) => string[];
|
|
65
|
+
/**
|
|
66
|
+
* What a Smithy build target hashes: its own sources plus the outputs of the
|
|
67
|
+
* tasks it depends on. That covers a consumed shape library's output only
|
|
68
|
+
* when nx.json's `default` named input carries the `dependentTasksOutputFiles`
|
|
69
|
+
* entry, which only ts/lib/generator.ts writes - a Smithy-only workspace has
|
|
70
|
+
* no such entry, so `default` falls back to Nx's `{projectRoot}/**\/*`.
|
|
71
|
+
*/
|
|
72
|
+
export declare const SMITHY_TARGET_INPUTS: string[];
|
|
65
73
|
/**
|
|
66
74
|
* The target that builds a service's Server SDK, shared with the migration moving
|
|
67
75
|
* an existing project onto it.
|
|
68
76
|
*/
|
|
69
77
|
export declare const smithyGenerateSsdkTarget: () => {
|
|
70
78
|
cache: boolean;
|
|
79
|
+
inputs: string[];
|
|
71
80
|
outputs: string[];
|
|
72
81
|
executor: string;
|
|
73
82
|
dependsOn: string[];
|
|
@@ -112,11 +112,23 @@ const BUILD_DIR = 'dist/{projectRoot}/build';
|
|
|
112
112
|
`{workspaceRoot}/${SMITHY_OUT_DIR}`,
|
|
113
113
|
type === 'shapes' ? `{workspaceRoot}/${BUILD_DIR}/model.json` : `{workspaceRoot}/${BUILD_DIR}/openapi`
|
|
114
114
|
];
|
|
115
|
+
/**
|
|
116
|
+
* What a Smithy build target hashes: its own sources plus the outputs of the
|
|
117
|
+
* tasks it depends on. That covers a consumed shape library's output only
|
|
118
|
+
* when nx.json's `default` named input carries the `dependentTasksOutputFiles`
|
|
119
|
+
* entry, which only ts/lib/generator.ts writes - a Smithy-only workspace has
|
|
120
|
+
* no such entry, so `default` falls back to Nx's `{projectRoot}/**\/*`.
|
|
121
|
+
*/ export const SMITHY_TARGET_INPUTS = [
|
|
122
|
+
'default'
|
|
123
|
+
];
|
|
115
124
|
/**
|
|
116
125
|
* The target that builds a service's Server SDK, shared with the migration moving
|
|
117
126
|
* an existing project onto it.
|
|
118
127
|
*/ export const smithyGenerateSsdkTarget = ()=>({
|
|
119
128
|
cache: true,
|
|
129
|
+
inputs: [
|
|
130
|
+
...SMITHY_TARGET_INPUTS
|
|
131
|
+
],
|
|
120
132
|
outputs: [
|
|
121
133
|
`{workspaceRoot}/${BUILD_DIR}/ssdk`
|
|
122
134
|
],
|
|
@@ -176,6 +188,9 @@ export const smithyProjectGenerator = async (tree, options)=>{
|
|
|
176
188
|
},
|
|
177
189
|
compile: {
|
|
178
190
|
cache: true,
|
|
191
|
+
inputs: [
|
|
192
|
+
...SMITHY_TARGET_INPUTS
|
|
193
|
+
],
|
|
179
194
|
outputs: smithyCompileOutputs(type),
|
|
180
195
|
executor: 'nx:run-commands',
|
|
181
196
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/project/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n} from '@nx/devkit';\nimport { getTsLibDetails } from '../../ts/lib/generator.js';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { toClassName, toKebabCase } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths.js';\nimport {\n smithyCliCommand,\n smithyMavenVersions,\n warnIfSmithyMissing,\n} from '../../utils/smithy.js';\nimport type { SmithyProjectGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface SmithyProjectMetadata {\n readonly smithyType: NonNullable<SmithyProjectGeneratorSchema['type']>;\n readonly namespace: string;\n}\n\n/**\n * Only a service project generates a Server SDK, so only a service needs the\n * bundler that turns it into the single module its backend imports. A shape\n * library assembles a model and stops.\n */\nconst isService = (metadata: SmithyProjectMetadata) =>\n metadata.smithyType === 'service';\n\n/**\n * Everything a Smithy build runs, all of it workspace tooling in the root\n * manifest rather than anything the model itself imports.\n *\n * Neither the Smithy CLI nor `mise` is among them: the compile target fetches mise\n * with `npx` and mise resolves the CLI, so neither is a workspace dependency — see\n * `utils/smithy.ts`.\n */\nexport const DEPENDENCIES = declareDependencies<SmithyProjectMetadata>()({\n ts: [\n // Added to the root by `FsCommands` as it builds each command.\n ...ownedElsewhere(FS_DEPENDENCIES),\n { name: 'rolldown', dev: true, root: true, when: isService },\n { name: 'rolldown-plugin-dts', dev: true, root: true, when: isService },\n // Resolved by `rolldown-plugin-dts` to emit the bundled declaration.\n { name: 'typescript', dev: true, root: true, when: isService },\n ],\n});\n\nexport const SMITHY_PROJECT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Where the Smithy CLI writes its artifacts, and where the build publishes the\n * ones consumers read. Both sit under `dist` so a build writes nothing into the\n * project, keeping the source tree clean and the target's outputs cacheable.\n *\n * The CLI's own output is kept beside the published tree rather than inside it:\n * it holds the generated SSDK package and its installed `node_modules`, which\n * must not be mistaken for a build artifact.\n */\nconst SMITHY_OUT_DIR = 'dist/{projectRoot}/smithy';\nconst BUILD_DIR = 'dist/{projectRoot}/build';\n\n/** The projection every generated `smithy-build.json` builds. */\nconst SOURCE_PROJECTION = `${SMITHY_OUT_DIR}/source`;\n\n/** Where the generated TypeScript Server SDK lands before it is bundled. */\nconst SSDK_CODEGEN_DIR = `${SOURCE_PROJECTION}/typescript-ssdk-codegen`;\n\n/**\n * The commands that build a Smithy project's model, run from the workspace root.\n *\n * This is the whole of a shape library's build. A service's Server SDK is built\n * separately by {@link smithyGenerateSsdkCommands}, from the codegen output this\n * leaves under {@link SMITHY_OUT_DIR}.\n */\nexport const smithyCompileCommands = (\n cmd: FsCommands<typeof DEPENDENCIES>,\n type: SmithyProjectGeneratorSchema['type'],\n): string[] => [\n cmd.rm(BUILD_DIR),\n cmd.rm(SMITHY_OUT_DIR),\n cmd.mkdir(BUILD_DIR),\n // `imports` in smithy-build.json resolve relative to that file, so a shape\n // library is referenced by its path from the consuming project.\n `${smithyCliCommand()} build -c {projectRoot}/smithy-build.json --output ${SMITHY_OUT_DIR}`,\n ...(type === 'shapes'\n ? [\n cmd.cpFile(\n `${SOURCE_PROJECTION}/model/model.json`,\n `${BUILD_DIR}/model.json`,\n ),\n ]\n : [\n cmd.mkdir(`${BUILD_DIR}/openapi`),\n // Named after the service shape by the OpenAPI plugin, so it is matched\n // rather than named, and published under a stable name.\n cmd.cpGlobToFile(\n `${SOURCE_PROJECTION}/openapi/*.openapi.json`,\n `${BUILD_DIR}/openapi`,\n 'openapi.json',\n ),\n ]),\n];\n\n/**\n * The commands that turn a service's generated TypeScript Server SDK into the\n * single module its consumer imports, run from the workspace root.\n *\n * Only a service has one, and it reads what the model build left behind, so this\n * runs after `compile`.\n */\nexport const smithyGenerateSsdkCommands = (): string[] => [\n // `npm` regardless of the workspace's package manager: this installs a generated\n // package under `dist` that is not a workspace member, and npm ships with Node so\n // it is always present. It reads the user's `.npmrc`, so a private registry still\n // applies. `--include=dev` because the bundler resolves types from the generated\n // package's devDependencies, which `NODE_ENV=production` would otherwise omit.\n `npm install --prefix ${SSDK_CODEGEN_DIR} --include=dev --ignore-scripts --no-audit --no-fund`,\n // Bundled straight from the generated TypeScript sources, emitting the module and\n // its declarations together — see ssdk.rolldown.config.mjs for why the sources\n // rather than a `tsc` pre-pass.\n `rolldown -c {projectRoot}/ssdk.rolldown.config.mjs`,\n];\n\n/**\n * What the model build publishes, listed per artifact rather than as the whole\n * `build` directory: a service's `generate-ssdk` writes into that directory too, and\n * restoring `compile` from cache would otherwise discard the Server SDK beside it.\n */\nexport const smithyCompileOutputs = (\n type: SmithyProjectGeneratorSchema['type'],\n): string[] => [\n `{workspaceRoot}/${SMITHY_OUT_DIR}`,\n type === 'shapes'\n ? `{workspaceRoot}/${BUILD_DIR}/model.json`\n : `{workspaceRoot}/${BUILD_DIR}/openapi`,\n];\n\n/**\n * The target that builds a service's Server SDK, shared with the migration moving\n * an existing project onto it.\n */\nexport const smithyGenerateSsdkTarget = () => ({\n cache: true,\n outputs: [`{workspaceRoot}/${BUILD_DIR}/ssdk`],\n executor: 'nx:run-commands',\n dependsOn: ['compile'],\n options: {\n commands: smithyGenerateSsdkCommands(),\n parallel: false,\n cwd: '{workspaceRoot}',\n },\n});\n\n/**\n * Write the rolldown config that bundles a service's generated Server SDK.\n *\n * Shared with the migration moving an existing project off the container build,\n * so a migrated project's config cannot drift from a freshly generated one.\n */\nexport const writeSsdkBundleConfig = (tree: Tree, projectRoot: string): void =>\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'ssdk-bundle'),\n projectRoot,\n // The config's paths are workspace-root relative, so it needs only the\n // project's root — the compile target runs from the workspace root.\n { projectRoot },\n // Generated configuration rather than anything the user edits, so a re-run\n // refreshes it — unlike the models beside it.\n { overwriteStrategy: OverwriteStrategy.Overwrite },\n );\n\nexport const smithyProjectGenerator = async (\n tree: Tree,\n options: SmithyProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const cmd = new FsCommands(tree, DEPENDENCIES);\n const type = options.type ?? 'service';\n\n // Create project.json\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);\n\n if (!projectExists(tree, fullyQualifiedName)) {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: dir,\n sourceRoot: joinPathFragments(dir, 'src'),\n projectType: 'library',\n targets: {\n build: {\n dependsOn:\n type === 'shapes' ? ['compile'] : ['compile', 'generate-ssdk'],\n },\n // Everything this project's build does is artifact production, so\n // `assemble` carries the same dependencies.\n assemble: {\n dependsOn:\n type === 'shapes' ? ['compile'] : ['compile', 'generate-ssdk'],\n },\n compile: {\n cache: true,\n outputs: smithyCompileOutputs(type),\n executor: 'nx:run-commands',\n options: {\n commands: smithyCompileCommands(cmd, type),\n parallel: false,\n cwd: '{workspaceRoot}',\n },\n },\n // Only a service generates a Server SDK, and it is built from what the\n // model build leaves behind.\n ...(type === 'shapes'\n ? {}\n : { 'generate-ssdk': smithyGenerateSsdkTarget() }),\n },\n });\n }\n\n const serviceName = options.serviceName ?? options.name;\n const serviceNameClassName = toClassName(serviceName);\n const serviceNameKebabCase = toKebabCase(serviceName);\n const scope = getNpmScope(tree);\n const namespace = options.namespace ?? toKebabCase(scope).replace(/-/g, '.');\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', type),\n dir,\n {\n namespace,\n serviceNameClassName,\n serviceNameKebabCase,\n scope,\n projectRoot: dir,\n relativePathToWorkspaceRoot: getRelativePathToRootByDirectory(dir),\n ...smithyMavenVersions(),\n },\n {\n // Smithy models are user-owned — a re-run must not discard edits\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n if (type === 'service') {\n writeSsdkBundleConfig(tree, dir);\n }\n\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: SmithyProjectMetadata = { smithyType: type, namespace };\n\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n SMITHY_PROJECT_GENERATOR_INFO,\n {\n ...metadata,\n ...(type === 'service' ? { apiName: options.name } : {}),\n },\n );\n\n // No projectRoot: a Smithy model project has no manifest of its own, and every\n // dependency here is workspace tooling the build runs rather than anything the\n // model imports.\n addTsDependencies(tree, DEPENDENCIES, { metadata });\n\n await addGeneratorMetricsIfApplicable(tree, [SMITHY_PROJECT_GENERATOR_INFO]);\n\n // On Windows the build runs the Smithy CLI from the PATH rather than through\n // mise, so flag a missing prerequisite while the project is still being set up.\n warnIfSmithyMissing();\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default smithyProjectGenerator;\n"],"names":["addProjectConfiguration","generateFiles","joinPathFragments","OverwriteStrategy","getTsLibDetails","addTsDependencies","declareDependencies","ownedElsewhere","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","getNpmScope","addGeneratorMetadata","getGeneratorInfo","projectExists","getRelativePathToRootByDirectory","smithyCliCommand","smithyMavenVersions","warnIfSmithyMissing","isService","metadata","smithyType","DEPENDENCIES","ts","name","dev","root","when","SMITHY_PROJECT_GENERATOR_INFO","filename","SMITHY_OUT_DIR","BUILD_DIR","SOURCE_PROJECTION","SSDK_CODEGEN_DIR","smithyCompileCommands","cmd","type","rm","mkdir","cpFile","cpGlobToFile","smithyGenerateSsdkCommands","smithyCompileOutputs","smithyGenerateSsdkTarget","cache","outputs","executor","dependsOn","options","commands","parallel","cwd","writeSsdkBundleConfig","tree","projectRoot","dirname","overwriteStrategy","Overwrite","smithyProjectGenerator","fullyQualifiedName","dir","sourceRoot","projectType","targets","build","assemble","compile","serviceName","serviceNameClassName","serviceNameKebabCase","scope","namespace","replace","relativePathToWorkspaceRoot","KeepExisting","apiName","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAEZ,aAAa;AACpB,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAoB;AAChE,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,WAAW,EAAEC,WAAW,QAAQ,uBAAuB;AAChE,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAoB;AAC3B,SAASC,gCAAgC,QAAQ,uBAAuB;AACxE,SACEC,gBAAgB,EAChBC,mBAAmB,EACnBC,mBAAmB,QACd,wBAAwB;AAS/B;;;;CAIC,GACD,MAAMC,YAAY,CAACC,WACjBA,SAASC,UAAU,KAAK;AAE1B;;;;;;;CAOC,GACD,OAAO,MAAMC,eAAepB,sBAA6C;IACvEqB,IAAI;QACF,+DAA+D;WAC5DpB,eAA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C6C,MAAM;QAACzB;KAA8B;IAE3E,6EAA6E;IAC7E,gFAAgF;IAChFV;IAEA,MAAMd,qBAAqBiD;IAC3B,OAAO,IACL9C,oBAAoB8C,MAAML,QAAQ4B,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAenB,uBAAuB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/project/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n} from '@nx/devkit';\nimport { getTsLibDetails } from '../../ts/lib/generator.js';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { toClassName, toKebabCase } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths.js';\nimport {\n smithyCliCommand,\n smithyMavenVersions,\n warnIfSmithyMissing,\n} from '../../utils/smithy.js';\nimport type { SmithyProjectGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface SmithyProjectMetadata {\n readonly smithyType: NonNullable<SmithyProjectGeneratorSchema['type']>;\n readonly namespace: string;\n}\n\n/**\n * Only a service project generates a Server SDK, so only a service needs the\n * bundler that turns it into the single module its backend imports. A shape\n * library assembles a model and stops.\n */\nconst isService = (metadata: SmithyProjectMetadata) =>\n metadata.smithyType === 'service';\n\n/**\n * Everything a Smithy build runs, all of it workspace tooling in the root\n * manifest rather than anything the model itself imports.\n *\n * Neither the Smithy CLI nor `mise` is among them: the compile target fetches mise\n * with `npx` and mise resolves the CLI, so neither is a workspace dependency — see\n * `utils/smithy.ts`.\n */\nexport const DEPENDENCIES = declareDependencies<SmithyProjectMetadata>()({\n ts: [\n // Added to the root by `FsCommands` as it builds each command.\n ...ownedElsewhere(FS_DEPENDENCIES),\n { name: 'rolldown', dev: true, root: true, when: isService },\n { name: 'rolldown-plugin-dts', dev: true, root: true, when: isService },\n // Resolved by `rolldown-plugin-dts` to emit the bundled declaration.\n { name: 'typescript', dev: true, root: true, when: isService },\n ],\n});\n\nexport const SMITHY_PROJECT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Where the Smithy CLI writes its artifacts, and where the build publishes the\n * ones consumers read. Both sit under `dist` so a build writes nothing into the\n * project, keeping the source tree clean and the target's outputs cacheable.\n *\n * The CLI's own output is kept beside the published tree rather than inside it:\n * it holds the generated SSDK package and its installed `node_modules`, which\n * must not be mistaken for a build artifact.\n */\nconst SMITHY_OUT_DIR = 'dist/{projectRoot}/smithy';\nconst BUILD_DIR = 'dist/{projectRoot}/build';\n\n/** The projection every generated `smithy-build.json` builds. */\nconst SOURCE_PROJECTION = `${SMITHY_OUT_DIR}/source`;\n\n/** Where the generated TypeScript Server SDK lands before it is bundled. */\nconst SSDK_CODEGEN_DIR = `${SOURCE_PROJECTION}/typescript-ssdk-codegen`;\n\n/**\n * The commands that build a Smithy project's model, run from the workspace root.\n *\n * This is the whole of a shape library's build. A service's Server SDK is built\n * separately by {@link smithyGenerateSsdkCommands}, from the codegen output this\n * leaves under {@link SMITHY_OUT_DIR}.\n */\nexport const smithyCompileCommands = (\n cmd: FsCommands<typeof DEPENDENCIES>,\n type: SmithyProjectGeneratorSchema['type'],\n): string[] => [\n cmd.rm(BUILD_DIR),\n cmd.rm(SMITHY_OUT_DIR),\n cmd.mkdir(BUILD_DIR),\n // `imports` in smithy-build.json resolve relative to that file, so a shape\n // library is referenced by its path from the consuming project.\n `${smithyCliCommand()} build -c {projectRoot}/smithy-build.json --output ${SMITHY_OUT_DIR}`,\n ...(type === 'shapes'\n ? [\n cmd.cpFile(\n `${SOURCE_PROJECTION}/model/model.json`,\n `${BUILD_DIR}/model.json`,\n ),\n ]\n : [\n cmd.mkdir(`${BUILD_DIR}/openapi`),\n // Named after the service shape by the OpenAPI plugin, so it is matched\n // rather than named, and published under a stable name.\n cmd.cpGlobToFile(\n `${SOURCE_PROJECTION}/openapi/*.openapi.json`,\n `${BUILD_DIR}/openapi`,\n 'openapi.json',\n ),\n ]),\n];\n\n/**\n * The commands that turn a service's generated TypeScript Server SDK into the\n * single module its consumer imports, run from the workspace root.\n *\n * Only a service has one, and it reads what the model build left behind, so this\n * runs after `compile`.\n */\nexport const smithyGenerateSsdkCommands = (): string[] => [\n // `npm` regardless of the workspace's package manager: this installs a generated\n // package under `dist` that is not a workspace member, and npm ships with Node so\n // it is always present. It reads the user's `.npmrc`, so a private registry still\n // applies. `--include=dev` because the bundler resolves types from the generated\n // package's devDependencies, which `NODE_ENV=production` would otherwise omit.\n `npm install --prefix ${SSDK_CODEGEN_DIR} --include=dev --ignore-scripts --no-audit --no-fund`,\n // Bundled straight from the generated TypeScript sources, emitting the module and\n // its declarations together — see ssdk.rolldown.config.mjs for why the sources\n // rather than a `tsc` pre-pass.\n `rolldown -c {projectRoot}/ssdk.rolldown.config.mjs`,\n];\n\n/**\n * What the model build publishes, listed per artifact rather than as the whole\n * `build` directory: a service's `generate-ssdk` writes into that directory too, and\n * restoring `compile` from cache would otherwise discard the Server SDK beside it.\n */\nexport const smithyCompileOutputs = (\n type: SmithyProjectGeneratorSchema['type'],\n): string[] => [\n `{workspaceRoot}/${SMITHY_OUT_DIR}`,\n type === 'shapes'\n ? `{workspaceRoot}/${BUILD_DIR}/model.json`\n : `{workspaceRoot}/${BUILD_DIR}/openapi`,\n];\n\n/**\n * What a Smithy build target hashes: its own sources plus the outputs of the\n * tasks it depends on. That covers a consumed shape library's output only\n * when nx.json's `default` named input carries the `dependentTasksOutputFiles`\n * entry, which only ts/lib/generator.ts writes - a Smithy-only workspace has\n * no such entry, so `default` falls back to Nx's `{projectRoot}/**\\/*`.\n */\nexport const SMITHY_TARGET_INPUTS = ['default'];\n\n/**\n * The target that builds a service's Server SDK, shared with the migration moving\n * an existing project onto it.\n */\nexport const smithyGenerateSsdkTarget = () => ({\n cache: true,\n inputs: [...SMITHY_TARGET_INPUTS],\n outputs: [`{workspaceRoot}/${BUILD_DIR}/ssdk`],\n executor: 'nx:run-commands',\n dependsOn: ['compile'],\n options: {\n commands: smithyGenerateSsdkCommands(),\n parallel: false,\n cwd: '{workspaceRoot}',\n },\n});\n\n/**\n * Write the rolldown config that bundles a service's generated Server SDK.\n *\n * Shared with the migration moving an existing project off the container build,\n * so a migrated project's config cannot drift from a freshly generated one.\n */\nexport const writeSsdkBundleConfig = (tree: Tree, projectRoot: string): void =>\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'ssdk-bundle'),\n projectRoot,\n // The config's paths are workspace-root relative, so it needs only the\n // project's root — the compile target runs from the workspace root.\n { projectRoot },\n // Generated configuration rather than anything the user edits, so a re-run\n // refreshes it — unlike the models beside it.\n { overwriteStrategy: OverwriteStrategy.Overwrite },\n );\n\nexport const smithyProjectGenerator = async (\n tree: Tree,\n options: SmithyProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const cmd = new FsCommands(tree, DEPENDENCIES);\n const type = options.type ?? 'service';\n\n // Create project.json\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);\n\n if (!projectExists(tree, fullyQualifiedName)) {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: dir,\n sourceRoot: joinPathFragments(dir, 'src'),\n projectType: 'library',\n targets: {\n build: {\n dependsOn:\n type === 'shapes' ? ['compile'] : ['compile', 'generate-ssdk'],\n },\n // Everything this project's build does is artifact production, so\n // `assemble` carries the same dependencies.\n assemble: {\n dependsOn:\n type === 'shapes' ? ['compile'] : ['compile', 'generate-ssdk'],\n },\n compile: {\n cache: true,\n inputs: [...SMITHY_TARGET_INPUTS],\n outputs: smithyCompileOutputs(type),\n executor: 'nx:run-commands',\n options: {\n commands: smithyCompileCommands(cmd, type),\n parallel: false,\n cwd: '{workspaceRoot}',\n },\n },\n // Only a service generates a Server SDK, and it is built from what the\n // model build leaves behind.\n ...(type === 'shapes'\n ? {}\n : { 'generate-ssdk': smithyGenerateSsdkTarget() }),\n },\n });\n }\n\n const serviceName = options.serviceName ?? options.name;\n const serviceNameClassName = toClassName(serviceName);\n const serviceNameKebabCase = toKebabCase(serviceName);\n const scope = getNpmScope(tree);\n const namespace = options.namespace ?? toKebabCase(scope).replace(/-/g, '.');\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', type),\n dir,\n {\n namespace,\n serviceNameClassName,\n serviceNameKebabCase,\n scope,\n projectRoot: dir,\n relativePathToWorkspaceRoot: getRelativePathToRootByDirectory(dir),\n ...smithyMavenVersions(),\n },\n {\n // Smithy models are user-owned — a re-run must not discard edits\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n if (type === 'service') {\n writeSsdkBundleConfig(tree, dir);\n }\n\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: SmithyProjectMetadata = { smithyType: type, namespace };\n\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n SMITHY_PROJECT_GENERATOR_INFO,\n {\n ...metadata,\n ...(type === 'service' ? { apiName: options.name } : {}),\n },\n );\n\n // No projectRoot: a Smithy model project has no manifest of its own, and every\n // dependency here is workspace tooling the build runs rather than anything the\n // model imports.\n addTsDependencies(tree, DEPENDENCIES, { metadata });\n\n await addGeneratorMetricsIfApplicable(tree, [SMITHY_PROJECT_GENERATOR_INFO]);\n\n // On Windows the build runs the Smithy CLI from the PATH rather than through\n // mise, so flag a missing prerequisite while the project is still being set up.\n warnIfSmithyMissing();\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default smithyProjectGenerator;\n"],"names":["addProjectConfiguration","generateFiles","joinPathFragments","OverwriteStrategy","getTsLibDetails","addTsDependencies","declareDependencies","ownedElsewhere","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","getNpmScope","addGeneratorMetadata","getGeneratorInfo","projectExists","getRelativePathToRootByDirectory","smithyCliCommand","smithyMavenVersions","warnIfSmithyMissing","isService","metadata","smithyType","DEPENDENCIES","ts","name","dev","root","when","SMITHY_PROJECT_GENERATOR_INFO","filename","SMITHY_OUT_DIR","BUILD_DIR","SOURCE_PROJECTION","SSDK_CODEGEN_DIR","smithyCompileCommands","cmd","type","rm","mkdir","cpFile","cpGlobToFile","smithyGenerateSsdkCommands","smithyCompileOutputs","SMITHY_TARGET_INPUTS","smithyGenerateSsdkTarget","cache","inputs","outputs","executor","dependsOn","options","commands","parallel","cwd","writeSsdkBundleConfig","tree","projectRoot","dirname","overwriteStrategy","Overwrite","smithyProjectGenerator","fullyQualifiedName","dir","sourceRoot","projectType","targets","build","assemble","compile","serviceName","serviceNameClassName","serviceNameKebabCase","scope","namespace","replace","relativePathToWorkspaceRoot","KeepExisting","apiName","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAEZ,aAAa;AACpB,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAoB;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D,MACAzD,kBAAkB,YAAY2D,OAAO,EAAE,SAASrB,OAChD0B,KACA;QACEW;QACAH;QACAC;QACAC;QACAhB,aAAaM;QACba,6BAA6B5D,iCAAiC+C;QAC9D,GAAG7C,qBAAqB;IAC1B,GACA;QACE,iEAAiE;QACjEyC,mBAAmB3D,kBAAkB6E,YAAY;IACnD;IAGF,IAAIxC,SAAS,WAAW;QACtBkB,sBAAsBC,MAAMO;IAC9B;IAEA,0EAA0E;IAC1E,8DAA8D;IAC9D,MAAM1C,WAAkC;QAAEC,YAAYe;QAAMqC;IAAU;IAEtE7D,qBACE2C,MACAM,oBACAjC,+BACA;QACE,GAAGR,QAAQ;QACX,GAAIgB,SAAS,YAAY;YAAEyC,SAAS3B,QAAQ1B,IAAI;QAAC,IAAI,CAAC,CAAC;IACzD;IAGF,+EAA+E;IAC/E,+EAA+E;IAC/E,iBAAiB;IACjBvB,kBAAkBsD,MAAMjC,cAAc;QAAEF;IAAS;IAEjD,MAAMZ,gCAAgC+C,MAAM;QAAC3B;KAA8B;IAE3E,6EAA6E;IAC7E,gFAAgF;IAChFV;IAEA,MAAMd,qBAAqBmD;IAC3B,OAAO,IACLhD,oBAAoBgD,MAAML,QAAQ4B,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAenB,uBAAuB"}
|
|
@@ -2165,6 +2165,7 @@ exports[`tsSmithyApiGenerator > should generate smithy ts api with default optio
|
|
|
2165
2165
|
},
|
|
2166
2166
|
"compile": {
|
|
2167
2167
|
"cache": true,
|
|
2168
|
+
"inputs": ["default"],
|
|
2168
2169
|
"outputs": [
|
|
2169
2170
|
"{workspaceRoot}/dist/{projectRoot}/smithy",
|
|
2170
2171
|
"{workspaceRoot}/dist/{projectRoot}/build/openapi"
|
|
@@ -2185,6 +2186,7 @@ exports[`tsSmithyApiGenerator > should generate smithy ts api with default optio
|
|
|
2185
2186
|
},
|
|
2186
2187
|
"generate-ssdk": {
|
|
2187
2188
|
"cache": true,
|
|
2189
|
+
"inputs": ["default"],
|
|
2188
2190
|
"outputs": ["{workspaceRoot}/dist/{projectRoot}/build/ssdk"],
|
|
2189
2191
|
"executor": "nx:run-commands",
|
|
2190
2192
|
"dependsOn": ["compile"],
|
|
@@ -231,12 +231,10 @@ export async function terraformProjectGenerator(tree, schema) {
|
|
|
231
231
|
'^init'
|
|
232
232
|
]
|
|
233
233
|
},
|
|
234
|
+
// Reads remote state, which no input can hash.
|
|
234
235
|
output: {
|
|
235
236
|
executor: 'nx:run-commands',
|
|
236
|
-
cache:
|
|
237
|
-
inputs: [
|
|
238
|
-
'default'
|
|
239
|
-
],
|
|
237
|
+
cache: false,
|
|
240
238
|
options: {
|
|
241
239
|
command: 'terraform output -json',
|
|
242
240
|
forwardAllArgs: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/terraform/project/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readNxJson,\n type TargetConfiguration,\n type Tree,\n updateJson,\n updateNxJson,\n} from '@nx/devkit';\nimport { join, relative } from 'path';\nimport { addLicenseCheckToLintTarget } from '../../license/config.js';\nimport { getTsLibDetails } from '../../ts/lib/generator.js';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { updateGitIgnore } from '../../utils/git.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { kebabCase } from '../../utils/names.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { uvxCommand } from '../../utils/py.js';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n SHARED_TERRAFORM_DIR,\n SHARED_TERRAFORM_NAME,\n} from '../../utils/shared-constructs-constants.js';\nimport {\n terraformProviderVersions,\n withVersions,\n} from '../../utils/versions.js';\nimport type { TerraformProjectGeneratorSchema } from './schema';\n\n// Terraform projects carry no package.json, so their build tooling and the AWS\n// SDK the vended deploy scripts import are declared at the workspace root. This\n// generator records no metadata, so nothing a predicate could read.\nexport const DEPENDENCIES = declareDependencies()({\n ts: [\n { name: '@nx-extend/terraform', dev: true, root: true },\n { name: 'shx', dev: true, root: true },\n { name: 'tsx', dev: true, root: true },\n { name: '@aws-sdk/client-s3', dev: true, root: true },\n { name: '@aws-sdk/client-sts', dev: true, root: true },\n { name: '@aws-sdk/credential-providers', dev: true, root: true },\n { name: '@smithy/config-resolver', dev: true, root: true },\n { name: '@smithy/node-config-provider', dev: true, root: true },\n // Declared for its pinned version, which goes into npm's `overrides` below.\n { name: '@nx/devkit', versionOnly: true },\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n});\n\nconst NX_EXTEND_PLUGIN = '@nx-extend/terraform';\nexport const TERRAFORM_PROJECT_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\n/**\n * Checks formatting, mirroring the TypeScript and Python `format` targets: the\n * base target fails on an unformatted file and the `fix` configuration rewrites\n * it. Writing from the base target would rewrite the `default` input the hash is\n * computed over, so the target could never cache-hit.\n *\n * Scoped to the project's own `src` rather than `-recursive`, so it checks the\n * files the vended templates cover. `-diff` names what to fix when it fails.\n */\nexport const TERRAFORM_FORMAT_TARGET: TargetConfiguration = {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default'],\n options: {\n command: 'terraform fmt -check -diff',\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n configurations: {\n fix: {\n command: 'terraform fmt',\n },\n 'skip-lint': {\n // Cross-platform no-op (`true` is not available on Windows cmd).\n command: 'node -e \"\"',\n },\n },\n};\n\nexport async function terraformProjectGenerator(\n tree: Tree,\n schema: TerraformProjectGeneratorSchema,\n): Promise<GeneratorCallback> {\n // Just use getTsLibDetails as it isn't specific to TS\n const lib = getTsLibDetails(tree, schema);\n const { fullyQualifiedName: sharedTfProjectName } = getTsLibDetails(tree, {\n name: SHARED_TERRAFORM_NAME,\n });\n\n const outDirToRootRelativePath = relative(\n join(tree.root, lib.dir, 'src'),\n tree.root,\n ).replace(/\\\\/g, '/');\n const distDir = joinPathFragments(\n outDirToRootRelativePath,\n 'dist',\n '{projectRoot}',\n );\n const tfDistDir = joinPathFragments(distDir, 'terraform');\n const checkovReportJsonPath = joinPathFragments(\n distDir,\n 'checkov',\n 'checkov_report.json',\n );\n // `terraform-init` keeps its `.terraform` here rather than in `src`, so it\n // never races the backend-configured targets over the shared one. `test` and\n // `validate` read this same directory rather than initialising their own.\n const initDataDir = joinPathFragments(distDir, 'terraform-init');\n\n // Provider downloads persist here, so a target whose `.terraform` was cleaned\n // links the providers it already has rather than re-downloading them. Nx does\n // not interpolate `{workspaceRoot}` inside `env`, so this is relative to the\n // target's `cwd`. It sits under `.terraform`, which this generator gitignores\n // — that is also what keeps the providers out of Nx's file walk — and unlike\n // `.nx/cache` it survives `nx reset`.\n //\n // One cache per project rather than one for the workspace: two `terraform\n // init` runs filling a shared cache concurrently each compute a different hash\n // for the same provider, because the hash covers a directory the other is\n // still writing, and terraform then rejects the mismatch against the lock\n // file. `terraform-init` is the only target that fills it, and the targets that\n // need the providers depend on that one, so no two writers ever meet.\n const pluginCacheDir = joinPathFragments(\n outDirToRootRelativePath,\n '.terraform',\n 'plugin-cache',\n '{projectRoot}',\n );\n\n // Calculate relative path from current project to common/terraform/metrics\n // Use forward slashes for terraform module source paths (even on Windows)\n const metricsModulePath = relative(\n join(tree.root, lib.dir, 'src'),\n join(tree.root, 'packages', SHARED_TERRAFORM_DIR, 'src', 'metrics'),\n ).replace(/\\\\/g, '/');\n\n updateGitIgnore(tree, '.', (patterns) => [...patterns, '.terraform']);\n\n const applicationTargets: {\n [targetName: string]: TargetConfiguration;\n } = {\n apply: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n command: `terraform apply ${tfDistDir}/dev.tfplan`,\n },\n },\n options: {\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n dependsOn: ['plan'],\n },\n bootstrap: {\n executor: 'nx:run-commands',\n options: {\n forwardAllArgs: true,\n commands: ['tsx {projectRoot}/scripts/bootstrap.ts {projectRoot}'],\n cwd: '{workspaceRoot}',\n },\n },\n 'bootstrap-destroy': {\n executor: 'nx:run-commands',\n options: {\n forwardAllArgs: true,\n commands: [\n 'tsx {projectRoot}/scripts/bootstrap-destroy.ts {projectRoot}',\n ],\n cwd: '{workspaceRoot}',\n },\n },\n build: {\n dependsOn: ['format', 'checkov', 'test', `${sharedTfProjectName}:build`],\n },\n deploy: {\n dependsOn: ['apply'],\n },\n // The artifact-only sibling of build, which `plan` depends on.\n assemble: {\n dependsOn: [`${sharedTfProjectName}:assemble`],\n },\n destroy: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n command: 'terraform destroy -var-file=env/dev.tfvars',\n },\n },\n options: {\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n dependsOn: ['init'],\n },\n init: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n env: { TF_ENV: 'dev' },\n },\n },\n options: {\n forwardAllArgs: true,\n commands: ['tsx {projectRoot}/scripts/init.ts {projectRoot}'],\n cwd: '{workspaceRoot}',\n },\n dependsOn: ['terraform-init', '^init'],\n },\n output: {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default'],\n options: {\n command: 'terraform output -json',\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n },\n plan: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n commands: [\n `shx mkdir -p ${tfDistDir}`,\n `terraform plan -var-file=env/dev.tfvars -out=${tfDistDir}/dev.tfplan`,\n ],\n },\n },\n options: {\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n parallel: false,\n },\n dependsOn: ['init', 'validate', '^validate', 'assemble'],\n },\n };\n\n const libTargets: {\n [targetName: string]: TargetConfiguration;\n } = {\n build: {\n dependsOn: ['format', 'checkov', 'test'],\n },\n // A Terraform library vends modules rather than a deployable artifact, so\n // its `assemble` carries only whatever the consuming projects register on it.\n assemble: {\n executor: 'nx:noop',\n },\n format: TERRAFORM_FORMAT_TARGET,\n // Terraform has no linter of its own, so `lint` orchestrates the format\n // check. It exists so `nx run-many --target lint` reaches terraform\n // projects, and so `--configuration=fix` and `--configuration=skip-lint`\n // propagate to `format` the way they do for TypeScript and Python projects.\n lint: {\n dependsOn: ['format'],\n },\n init: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n commands: [\n {\n command: `shx mkdir -p ${pluginCacheDir}`,\n forwardAllArgs: false,\n },\n 'terraform init',\n ],\n },\n },\n options: {\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n parallel: false,\n env: { TF_PLUGIN_CACHE_DIR: pluginCacheDir },\n },\n dependsOn: ['terraform-init'],\n },\n // `-backend=false` installs the modules and providers without configuring\n // the S3 backend, so this needs no credentials and runs on a fresh\n // workspace before `bootstrap`. Uncached: a cache hit on another machine\n // would report success over an empty `TF_DATA_DIR` and plugin cache.\n 'terraform-init': {\n executor: 'nx:run-commands',\n options: {\n commands: [\n { command: `shx mkdir -p ${pluginCacheDir}`, forwardAllArgs: false },\n 'terraform init -backend=false',\n ],\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n parallel: false,\n env: {\n TF_DATA_DIR: initDataDir,\n TF_PLUGIN_CACHE_DIR: pluginCacheDir,\n },\n },\n },\n // `^production` mirrors `test`: checkov resolves the relative modules a\n // project consumes, so a change in one must invalidate the scan.\n checkov: {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default', '^production'],\n outputs: ['{workspaceRoot}/dist/{projectRoot}/checkov'],\n options: {\n command: uvxCommand(\n 'checkov',\n `--config-file ../checkov.yml --directory . -o cli -o json --output-file-path console,${checkovReportJsonPath}`,\n ),\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n },\n // Terraform's native test framework, which runs any `.tftest.hcl` files.\n // A project with none is a no-op success. Runs against the `TF_DATA_DIR`\n // `terraform-init` prepared, so it needs no credentials and works on a fresh\n // workspace before `bootstrap`. `^production` is what invalidates the cache\n // when a consumed module changes; `{projectRoot}/**/*` alone would serve a\n // stale pass.\n //\n // `TF_DATA_DIR` is terraform's working directory, not an artifact: its\n // provider entries are symlinks into the shared plugin cache, so restoring\n // it on another machine would yield dangling links while the commands that\n // repopulate them are skipped. Declaring no outputs keeps a cache hit to\n // what it actually asserts — that the tests passed for these inputs.\n test: {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default', '^production'],\n outputs: [],\n options: {\n command: 'terraform test',\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n env: { TF_DATA_DIR: initDataDir },\n },\n dependsOn: ['terraform-init'],\n },\n // Mirrors `test`: validates against the `TF_DATA_DIR` `terraform-init`\n // prepared, and declares no outputs for the same reason (see `test` above).\n validate: {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default', '^production'],\n outputs: [],\n options: {\n command: 'terraform validate',\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n env: { TF_DATA_DIR: initDataDir },\n },\n dependsOn: ['terraform-init'],\n },\n };\n\n const projectConfiguration = {\n root: lib.dir,\n projectType: schema.type,\n sourceRoot: joinPathFragments(lib.dir, 'src'),\n targets: sortObjectKeys({\n ...libTargets,\n ...(schema.type === 'application' ? applicationTargets : {}),\n }),\n };\n\n // Only create the project configuration on first run; skip it on re-run so\n // existing project.json customisations are preserved.\n if (!projectExists(tree, lib.fullyQualifiedName)) {\n addProjectConfiguration(tree, lib.fullyQualifiedName, projectConfiguration);\n }\n\n // The `lint` target checks licenses alongside formatting, as it does for\n // TypeScript and Python projects.\n addLicenseCheckToLintTarget(tree, lib.fullyQualifiedName);\n\n // This generator IS the Terraform project, so the provider is fixed.\n addGeneratorMetadata(\n tree,\n lib.fullyQualifiedName,\n TERRAFORM_PROJECT_GENERATOR_INFO,\n { iac: 'terraform' },\n );\n\n // The guides tell the reader to declare resources in `main.tf`, add variables\n // and outputs, and configure environments in `env/*.tfvars`, so everything\n // here is scaffolded once and then left alone. Provider version bumps reach\n // `providers.tf` through the vended version sync, which rewrites the pin in\n // place rather than the whole file.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, `./files/${schema.type}`),\n lib.dir,\n {\n metricsModulePath,\n stateKeyPrefix: kebabCase(lib.fullyQualifiedName),\n ...terraformProviderVersions(),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Checkov skips are the user's to curate, so preserve any they have added.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, './files/checkov'),\n lib.dir,\n {},\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n const nxJson = readNxJson(tree);\n\n if (\n !nxJson.plugins?.find((p) =>\n typeof p === 'string'\n ? p === NX_EXTEND_PLUGIN\n : p.plugin === NX_EXTEND_PLUGIN,\n )\n ) {\n nxJson.plugins = [...(nxJson.plugins ?? []), NX_EXTEND_PLUGIN];\n updateNxJson(tree, nxJson);\n }\n\n // Ensure shared constructs for Terraform are created\n await sharedConstructsGenerator(tree, { iac: 'terraform' }, DEPENDENCIES);\n\n // Add Terraform metrics\n await addGeneratorMetricsIfApplicable(tree, [\n TERRAFORM_PROJECT_GENERATOR_INFO,\n ]);\n\n addTsDependencies(tree, DEPENDENCIES);\n\n // @nx-extend/terraform has a peer dependency on @nx/devkit ^21.0.0 which causes\n // npm install to fail, so for NPM we add a resolution\n // Can remove when https://github.com/TriPSs/nx-extend/issues/407 is addressed\n if (detectPackageManager() === 'npm') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.overrides = {\n ...packageJson.overrides,\n ...withVersions(DEPENDENCIES, ['@nx/devkit']),\n };\n return packageJson;\n });\n }\n\n // `updateProjectConfiguration` re-serialises project.json with every inline\n // array expanded, which the vended `format` target rejects.\n await formatFilesInSubtree(tree);\n\n // `@nx-extend/terraform` is registered as an Nx plugin in nx.json, so Nx\n // loads it when computing the project graph — it must resolve even if the\n // caller would otherwise prefer to defer installing.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: [NX_EXTEND_PLUGIN],\n });\n}\nexport default terraformProjectGenerator;\n"],"names":["addProjectConfiguration","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readNxJson","updateJson","updateNxJson","join","relative","addLicenseCheckToLintTarget","getTsLibDetails","addTsDependencies","declareDependencies","ownedElsewhere","formatFilesInSubtree","updateGitIgnore","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","addGeneratorMetadata","getGeneratorInfo","projectExists","sortObjectKeys","uvxCommand","sharedConstructsGenerator","SHARED_CONSTRUCTS_DEPENDENCIES","SHARED_TERRAFORM_DIR","SHARED_TERRAFORM_NAME","terraformProviderVersions","withVersions","DEPENDENCIES","ts","name","dev","root","versionOnly","NX_EXTEND_PLUGIN","TERRAFORM_PROJECT_GENERATOR_INFO","filename","TERRAFORM_FORMAT_TARGET","executor","cache","inputs","options","command","forwardAllArgs","cwd","configurations","fix","terraformProjectGenerator","tree","schema","lib","fullyQualifiedName","sharedTfProjectName","outDirToRootRelativePath","dir","replace","distDir","tfDistDir","checkovReportJsonPath","initDataDir","pluginCacheDir","metricsModulePath","patterns","applicationTargets","apply","defaultConfiguration","dependsOn","bootstrap","commands","build","deploy","assemble","destroy","init","env","TF_ENV","output","plan","parallel","libTargets","format","lint","TF_PLUGIN_CACHE_DIR","TF_DATA_DIR","checkov","outputs","test","validate","projectConfiguration","projectType","type","sourceRoot","targets","iac","dirname","stateKeyPrefix","overwriteStrategy","KeepExisting","nxJson","plugins","find","p","plugin","packageJson","overrides","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EACvBC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EAGVC,UAAU,EACVC,YAAY,QACP,aAAa;AACpB,SAASC,IAAI,EAAEC,QAAQ,QAAQ,OAAO;AACtC,SAASC,2BAA2B,QAAQ,0BAA0B;AACtE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAoB;AAC3B,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,yBAAyB,QAAQ,mCAAmC;AAC7E,SACEC,8BAA8B,EAC9BC,oBAAoB,EACpBC,qBAAqB,QAChB,6CAA6C;AACpD,SACEC,yBAAyB,EACzBC,YAAY,QACP,0BAA0B;AAGjC,+EAA+E;AAC/E,gFAAgF;AAChF,oEAAoE;AACpE,OAAO,MAAMC,eAAelB,sBAAsB;IAChDmB,IAAI;QACF;YAAEC,MAAM;YAAwBC,KAAK;YAAMC,MAAM;QAAK;QACtD;YAAEF,MAAM;YAAOC,KAAK;YAAMC,MAAM;QAAK;QACrC;YAAEF,MAAM;YAAOC,KAAK;YAAMC,MAAM;QAAK;QACrC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,OAAOA,MAAM,WACTA,MAAMnE,mBACNmE,EAAEC,MAAM,KAAKpE,mBAEnB;QACAgE,OAAOC,OAAO,GAAG;eAAKD,OAAOC,OAAO,IAAI,EAAE;YAAGjE;SAAiB;QAC9D9B,aAAa4C,MAAMkD;IACrB;IAEA,qDAAqD;IACrD,MAAM5E,0BAA0B0B,MAAM;QAAE6C,KAAK;IAAY,GAAGjE;IAE5D,wBAAwB;IACxB,MAAMb,gCAAgCiC,MAAM;QAC1Cb;KACD;IAED1B,kBAAkBuC,MAAMpB;IAExB,gFAAgF;IAChF,sDAAsD;IACtD,8EAA8E;IAC9E,IAAI9B,2BAA2B,OAAO;QACpCK,WAAW6C,MAAM,gBAAgB,CAACuD;YAChCA,YAAYC,SAAS,GAAG;gBACtB,GAAGD,YAAYC,SAAS;gBACxB,GAAG7E,aAAaC,cAAc;oBAAC;iBAAa,CAAC;YAC/C;YACA,OAAO2E;QACT;IACF;IAEA,4EAA4E;IAC5E,4DAA4D;IAC5D,MAAM3F,qBAAqBoC;IAE3B,yEAAyE;IACzE,0EAA0E;IAC1E,qDAAqD;IACrD,OAAO,IACLlC,oBAAoBkC,MAAMC,OAAOwD,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;YACzBC,kBAAkB;gBAACzE;aAAiB;QACtC;AACJ;AACA,eAAea,0BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/terraform/project/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readNxJson,\n type TargetConfiguration,\n type Tree,\n updateJson,\n updateNxJson,\n} from '@nx/devkit';\nimport { join, relative } from 'path';\nimport { addLicenseCheckToLintTarget } from '../../license/config.js';\nimport { getTsLibDetails } from '../../ts/lib/generator.js';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { updateGitIgnore } from '../../utils/git.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { kebabCase } from '../../utils/names.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { uvxCommand } from '../../utils/py.js';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n SHARED_TERRAFORM_DIR,\n SHARED_TERRAFORM_NAME,\n} from '../../utils/shared-constructs-constants.js';\nimport {\n terraformProviderVersions,\n withVersions,\n} from '../../utils/versions.js';\nimport type { TerraformProjectGeneratorSchema } from './schema';\n\n// Terraform projects carry no package.json, so their build tooling and the AWS\n// SDK the vended deploy scripts import are declared at the workspace root. This\n// generator records no metadata, so nothing a predicate could read.\nexport const DEPENDENCIES = declareDependencies()({\n ts: [\n { name: '@nx-extend/terraform', dev: true, root: true },\n { name: 'shx', dev: true, root: true },\n { name: 'tsx', dev: true, root: true },\n { name: '@aws-sdk/client-s3', dev: true, root: true },\n { name: '@aws-sdk/client-sts', dev: true, root: true },\n { name: '@aws-sdk/credential-providers', dev: true, root: true },\n { name: '@smithy/config-resolver', dev: true, root: true },\n { name: '@smithy/node-config-provider', dev: true, root: true },\n // Declared for its pinned version, which goes into npm's `overrides` below.\n { name: '@nx/devkit', versionOnly: true },\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n});\n\nconst NX_EXTEND_PLUGIN = '@nx-extend/terraform';\nexport const TERRAFORM_PROJECT_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\n/**\n * Checks formatting, mirroring the TypeScript and Python `format` targets: the\n * base target fails on an unformatted file and the `fix` configuration rewrites\n * it. Writing from the base target would rewrite the `default` input the hash is\n * computed over, so the target could never cache-hit.\n *\n * Scoped to the project's own `src` rather than `-recursive`, so it checks the\n * files the vended templates cover. `-diff` names what to fix when it fails.\n */\nexport const TERRAFORM_FORMAT_TARGET: TargetConfiguration = {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default'],\n options: {\n command: 'terraform fmt -check -diff',\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n configurations: {\n fix: {\n command: 'terraform fmt',\n },\n 'skip-lint': {\n // Cross-platform no-op (`true` is not available on Windows cmd).\n command: 'node -e \"\"',\n },\n },\n};\n\nexport async function terraformProjectGenerator(\n tree: Tree,\n schema: TerraformProjectGeneratorSchema,\n): Promise<GeneratorCallback> {\n // Just use getTsLibDetails as it isn't specific to TS\n const lib = getTsLibDetails(tree, schema);\n const { fullyQualifiedName: sharedTfProjectName } = getTsLibDetails(tree, {\n name: SHARED_TERRAFORM_NAME,\n });\n\n const outDirToRootRelativePath = relative(\n join(tree.root, lib.dir, 'src'),\n tree.root,\n ).replace(/\\\\/g, '/');\n const distDir = joinPathFragments(\n outDirToRootRelativePath,\n 'dist',\n '{projectRoot}',\n );\n const tfDistDir = joinPathFragments(distDir, 'terraform');\n const checkovReportJsonPath = joinPathFragments(\n distDir,\n 'checkov',\n 'checkov_report.json',\n );\n // `terraform-init` keeps its `.terraform` here rather than in `src`, so it\n // never races the backend-configured targets over the shared one. `test` and\n // `validate` read this same directory rather than initialising their own.\n const initDataDir = joinPathFragments(distDir, 'terraform-init');\n\n // Provider downloads persist here, so a target whose `.terraform` was cleaned\n // links the providers it already has rather than re-downloading them. Nx does\n // not interpolate `{workspaceRoot}` inside `env`, so this is relative to the\n // target's `cwd`. It sits under `.terraform`, which this generator gitignores\n // — that is also what keeps the providers out of Nx's file walk — and unlike\n // `.nx/cache` it survives `nx reset`.\n //\n // One cache per project rather than one for the workspace: two `terraform\n // init` runs filling a shared cache concurrently each compute a different hash\n // for the same provider, because the hash covers a directory the other is\n // still writing, and terraform then rejects the mismatch against the lock\n // file. `terraform-init` is the only target that fills it, and the targets that\n // need the providers depend on that one, so no two writers ever meet.\n const pluginCacheDir = joinPathFragments(\n outDirToRootRelativePath,\n '.terraform',\n 'plugin-cache',\n '{projectRoot}',\n );\n\n // Calculate relative path from current project to common/terraform/metrics\n // Use forward slashes for terraform module source paths (even on Windows)\n const metricsModulePath = relative(\n join(tree.root, lib.dir, 'src'),\n join(tree.root, 'packages', SHARED_TERRAFORM_DIR, 'src', 'metrics'),\n ).replace(/\\\\/g, '/');\n\n updateGitIgnore(tree, '.', (patterns) => [...patterns, '.terraform']);\n\n const applicationTargets: {\n [targetName: string]: TargetConfiguration;\n } = {\n apply: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n command: `terraform apply ${tfDistDir}/dev.tfplan`,\n },\n },\n options: {\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n dependsOn: ['plan'],\n },\n bootstrap: {\n executor: 'nx:run-commands',\n options: {\n forwardAllArgs: true,\n commands: ['tsx {projectRoot}/scripts/bootstrap.ts {projectRoot}'],\n cwd: '{workspaceRoot}',\n },\n },\n 'bootstrap-destroy': {\n executor: 'nx:run-commands',\n options: {\n forwardAllArgs: true,\n commands: [\n 'tsx {projectRoot}/scripts/bootstrap-destroy.ts {projectRoot}',\n ],\n cwd: '{workspaceRoot}',\n },\n },\n build: {\n dependsOn: ['format', 'checkov', 'test', `${sharedTfProjectName}:build`],\n },\n deploy: {\n dependsOn: ['apply'],\n },\n // The artifact-only sibling of build, which `plan` depends on.\n assemble: {\n dependsOn: [`${sharedTfProjectName}:assemble`],\n },\n destroy: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n command: 'terraform destroy -var-file=env/dev.tfvars',\n },\n },\n options: {\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n dependsOn: ['init'],\n },\n init: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n env: { TF_ENV: 'dev' },\n },\n },\n options: {\n forwardAllArgs: true,\n commands: ['tsx {projectRoot}/scripts/init.ts {projectRoot}'],\n cwd: '{workspaceRoot}',\n },\n dependsOn: ['terraform-init', '^init'],\n },\n // Reads remote state, which no input can hash.\n output: {\n executor: 'nx:run-commands',\n cache: false,\n options: {\n command: 'terraform output -json',\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n },\n plan: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n commands: [\n `shx mkdir -p ${tfDistDir}`,\n `terraform plan -var-file=env/dev.tfvars -out=${tfDistDir}/dev.tfplan`,\n ],\n },\n },\n options: {\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n parallel: false,\n },\n dependsOn: ['init', 'validate', '^validate', 'assemble'],\n },\n };\n\n const libTargets: {\n [targetName: string]: TargetConfiguration;\n } = {\n build: {\n dependsOn: ['format', 'checkov', 'test'],\n },\n // A Terraform library vends modules rather than a deployable artifact, so\n // its `assemble` carries only whatever the consuming projects register on it.\n assemble: {\n executor: 'nx:noop',\n },\n format: TERRAFORM_FORMAT_TARGET,\n // Terraform has no linter of its own, so `lint` orchestrates the format\n // check. It exists so `nx run-many --target lint` reaches terraform\n // projects, and so `--configuration=fix` and `--configuration=skip-lint`\n // propagate to `format` the way they do for TypeScript and Python projects.\n lint: {\n dependsOn: ['format'],\n },\n init: {\n executor: 'nx:run-commands',\n defaultConfiguration: 'dev',\n configurations: {\n dev: {\n commands: [\n {\n command: `shx mkdir -p ${pluginCacheDir}`,\n forwardAllArgs: false,\n },\n 'terraform init',\n ],\n },\n },\n options: {\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n parallel: false,\n env: { TF_PLUGIN_CACHE_DIR: pluginCacheDir },\n },\n dependsOn: ['terraform-init'],\n },\n // `-backend=false` installs the modules and providers without configuring\n // the S3 backend, so this needs no credentials and runs on a fresh\n // workspace before `bootstrap`. Uncached: a cache hit on another machine\n // would report success over an empty `TF_DATA_DIR` and plugin cache.\n 'terraform-init': {\n executor: 'nx:run-commands',\n options: {\n commands: [\n { command: `shx mkdir -p ${pluginCacheDir}`, forwardAllArgs: false },\n 'terraform init -backend=false',\n ],\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n parallel: false,\n env: {\n TF_DATA_DIR: initDataDir,\n TF_PLUGIN_CACHE_DIR: pluginCacheDir,\n },\n },\n },\n // `^production` mirrors `test`: checkov resolves the relative modules a\n // project consumes, so a change in one must invalidate the scan.\n checkov: {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default', '^production'],\n outputs: ['{workspaceRoot}/dist/{projectRoot}/checkov'],\n options: {\n command: uvxCommand(\n 'checkov',\n `--config-file ../checkov.yml --directory . -o cli -o json --output-file-path console,${checkovReportJsonPath}`,\n ),\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n },\n },\n // Terraform's native test framework, which runs any `.tftest.hcl` files.\n // A project with none is a no-op success. Runs against the `TF_DATA_DIR`\n // `terraform-init` prepared, so it needs no credentials and works on a fresh\n // workspace before `bootstrap`. `^production` is what invalidates the cache\n // when a consumed module changes; `{projectRoot}/**/*` alone would serve a\n // stale pass.\n //\n // `TF_DATA_DIR` is terraform's working directory, not an artifact: its\n // provider entries are symlinks into the shared plugin cache, so restoring\n // it on another machine would yield dangling links while the commands that\n // repopulate them are skipped. Declaring no outputs keeps a cache hit to\n // what it actually asserts — that the tests passed for these inputs.\n test: {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default', '^production'],\n outputs: [],\n options: {\n command: 'terraform test',\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n env: { TF_DATA_DIR: initDataDir },\n },\n dependsOn: ['terraform-init'],\n },\n // Mirrors `test`: validates against the `TF_DATA_DIR` `terraform-init`\n // prepared, and declares no outputs for the same reason (see `test` above).\n validate: {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default', '^production'],\n outputs: [],\n options: {\n command: 'terraform validate',\n forwardAllArgs: true,\n cwd: '{projectRoot}/src',\n env: { TF_DATA_DIR: initDataDir },\n },\n dependsOn: ['terraform-init'],\n },\n };\n\n const projectConfiguration = {\n root: lib.dir,\n projectType: schema.type,\n sourceRoot: joinPathFragments(lib.dir, 'src'),\n targets: sortObjectKeys({\n ...libTargets,\n ...(schema.type === 'application' ? applicationTargets : {}),\n }),\n };\n\n // Only create the project configuration on first run; skip it on re-run so\n // existing project.json customisations are preserved.\n if (!projectExists(tree, lib.fullyQualifiedName)) {\n addProjectConfiguration(tree, lib.fullyQualifiedName, projectConfiguration);\n }\n\n // The `lint` target checks licenses alongside formatting, as it does for\n // TypeScript and Python projects.\n addLicenseCheckToLintTarget(tree, lib.fullyQualifiedName);\n\n // This generator IS the Terraform project, so the provider is fixed.\n addGeneratorMetadata(\n tree,\n lib.fullyQualifiedName,\n TERRAFORM_PROJECT_GENERATOR_INFO,\n { iac: 'terraform' },\n );\n\n // The guides tell the reader to declare resources in `main.tf`, add variables\n // and outputs, and configure environments in `env/*.tfvars`, so everything\n // here is scaffolded once and then left alone. Provider version bumps reach\n // `providers.tf` through the vended version sync, which rewrites the pin in\n // place rather than the whole file.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, `./files/${schema.type}`),\n lib.dir,\n {\n metricsModulePath,\n stateKeyPrefix: kebabCase(lib.fullyQualifiedName),\n ...terraformProviderVersions(),\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // Checkov skips are the user's to curate, so preserve any they have added.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, './files/checkov'),\n lib.dir,\n {},\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n const nxJson = readNxJson(tree);\n\n if (\n !nxJson.plugins?.find((p) =>\n typeof p === 'string'\n ? p === NX_EXTEND_PLUGIN\n : p.plugin === NX_EXTEND_PLUGIN,\n )\n ) {\n nxJson.plugins = [...(nxJson.plugins ?? []), NX_EXTEND_PLUGIN];\n updateNxJson(tree, nxJson);\n }\n\n // Ensure shared constructs for Terraform are created\n await sharedConstructsGenerator(tree, { iac: 'terraform' }, DEPENDENCIES);\n\n // Add Terraform metrics\n await addGeneratorMetricsIfApplicable(tree, [\n TERRAFORM_PROJECT_GENERATOR_INFO,\n ]);\n\n addTsDependencies(tree, DEPENDENCIES);\n\n // @nx-extend/terraform has a peer dependency on @nx/devkit ^21.0.0 which causes\n // npm install to fail, so for NPM we add a resolution\n // Can remove when https://github.com/TriPSs/nx-extend/issues/407 is addressed\n if (detectPackageManager() === 'npm') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.overrides = {\n ...packageJson.overrides,\n ...withVersions(DEPENDENCIES, ['@nx/devkit']),\n };\n return packageJson;\n });\n }\n\n // `updateProjectConfiguration` re-serialises project.json with every inline\n // array expanded, which the vended `format` target rejects.\n await formatFilesInSubtree(tree);\n\n // `@nx-extend/terraform` is registered as an Nx plugin in nx.json, so Nx\n // loads it when computing the project graph — it must resolve even if the\n // caller would otherwise prefer to defer installing.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: [NX_EXTEND_PLUGIN],\n });\n}\nexport default terraformProjectGenerator;\n"],"names":["addProjectConfiguration","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readNxJson","updateJson","updateNxJson","join","relative","addLicenseCheckToLintTarget","getTsLibDetails","addTsDependencies","declareDependencies","ownedElsewhere","formatFilesInSubtree","updateGitIgnore","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","addGeneratorMetadata","getGeneratorInfo","projectExists","sortObjectKeys","uvxCommand","sharedConstructsGenerator","SHARED_CONSTRUCTS_DEPENDENCIES","SHARED_TERRAFORM_DIR","SHARED_TERRAFORM_NAME","terraformProviderVersions","withVersions","DEPENDENCIES","ts","name","dev","root","versionOnly","NX_EXTEND_PLUGIN","TERRAFORM_PROJECT_GENERATOR_INFO","filename","TERRAFORM_FORMAT_TARGET","executor","cache","inputs","options","command","forwardAllArgs","cwd","configurations","fix","terraformProjectGenerator","tree","schema","lib","fullyQualifiedName","sharedTfProjectName","outDirToRootRelativePath","dir","replace","distDir","tfDistDir","checkovReportJsonPath","initDataDir","pluginCacheDir","metricsModulePath","patterns","applicationTargets","apply","defaultConfiguration","dependsOn","bootstrap","commands","build","deploy","assemble","destroy","init","env","TF_ENV","output","plan","parallel","libTargets","format","lint","TF_PLUGIN_CACHE_DIR","TF_DATA_DIR","checkov","outputs","test","validate","projectConfiguration","projectType","type","sourceRoot","targets","iac","dirname","stateKeyPrefix","overwriteStrategy","KeepExisting","nxJson","plugins","find","p","plugin","packageJson","overrides","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EACvBC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EAGVC,UAAU,EACVC,YAAY,QACP,aAAa;AACpB,SAASC,IAAI,EAAEC,QAAQ,QAAQ,OAAO;AACtC,SAASC,2BAA2B,QAAQ,0BAA0B;AACtE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAoB;AAC3B,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,yBAAyB,QAAQ,mCAAmC;AAC7E,SACEC,8BAA8B,EAC9BC,oBAAoB,EACpB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PENDENCIES: import("../../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
|
|
9
9
|
readonly name: "@a2a-js/sdk";
|
|
10
10
|
readonly root: true;
|
|
11
|
-
}, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
readonly name: "@aws-lambda-powertools/parameters";
|
|
16
|
-
readonly root: true;
|
|
17
|
-
}, {
|
|
18
|
-
readonly name: "@aws-sdk/client-appconfigdata";
|
|
19
|
-
readonly root: true;
|
|
20
|
-
}, {
|
|
21
|
-
readonly name: "aws4fetch";
|
|
22
|
-
readonly root: true;
|
|
23
|
-
}, {
|
|
24
|
-
readonly name: "@aws-sdk/credential-providers";
|
|
25
|
-
readonly root: true;
|
|
26
|
-
}, {
|
|
27
|
-
readonly name: "zod";
|
|
28
|
-
readonly root: true;
|
|
29
|
-
}, {
|
|
11
|
+
}, ...({
|
|
12
|
+
name: "@aws-sdk/client-s3" | "@strands-agents/sdk" | "express";
|
|
13
|
+
root: boolean;
|
|
14
|
+
} | ({
|
|
30
15
|
readonly name: "@aws-lambda-powertools/parameters";
|
|
31
16
|
} & {
|
|
32
17
|
versionOnly: true;
|
|
33
|
-
}
|
|
18
|
+
}) | ({
|
|
34
19
|
readonly name: "@aws-sdk/credential-providers";
|
|
35
20
|
} & {
|
|
36
21
|
versionOnly: true;
|
|
37
|
-
}
|
|
22
|
+
}) | ({
|
|
38
23
|
readonly name: "aws4fetch";
|
|
39
24
|
} & {
|
|
40
25
|
versionOnly: true;
|
|
41
|
-
}
|
|
26
|
+
}) | ({
|
|
42
27
|
readonly name: "@modelcontextprotocol/sdk";
|
|
43
28
|
} & {
|
|
44
29
|
versionOnly: true;
|
|
45
|
-
}
|
|
30
|
+
}) | ({
|
|
46
31
|
readonly name: "@a2a-js/sdk";
|
|
47
32
|
} & {
|
|
48
33
|
versionOnly: true;
|
|
49
|
-
}
|
|
50
|
-
|
|
34
|
+
}) | ({
|
|
35
|
+
name: "@aws-sdk/client-s3" | "@strands-agents/sdk" | "express";
|
|
51
36
|
} & {
|
|
52
37
|
versionOnly: true;
|
|
53
|
-
}
|
|
54
|
-
readonly name: "@aws-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
38
|
+
}) | {
|
|
39
|
+
readonly name: "@aws-lambda-powertools/parameters";
|
|
40
|
+
readonly root: true;
|
|
41
|
+
} | {
|
|
42
|
+
readonly name: "@aws-sdk/client-appconfigdata";
|
|
43
|
+
readonly root: true;
|
|
44
|
+
} | {
|
|
45
|
+
readonly name: "aws4fetch";
|
|
46
|
+
readonly root: true;
|
|
47
|
+
} | {
|
|
48
|
+
readonly name: "@aws-sdk/credential-providers";
|
|
49
|
+
readonly root: true;
|
|
50
|
+
} | {
|
|
51
|
+
readonly name: "zod";
|
|
52
|
+
readonly root: true;
|
|
53
|
+
})[]], readonly import("../../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "pydantic" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
|
|
58
54
|
export declare const TS_AGENT_A2A_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
59
55
|
export declare const tsAgentA2aConnectionGenerator: (tree: Tree, options: TsAgentA2aConnectionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
60
56
|
export default tsAgentA2aConnectionGenerator;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/ import { generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
|
|
5
5
|
import { addTsDependencies } from "../../../utils/add-dependencies.js";
|
|
6
|
-
import { AGENT_CONNECTION_DEPENDENCIES, AGENT_CONNECTION_PROJECT_DIR, addTypeScriptCoreClient, ensureTypeScriptAgentConnectionProject } from "../../../utils/agent-connection/agent-connection.js";
|
|
6
|
+
import { AGENT_CONNECTION_DEPENDENCIES, AGENT_CONNECTION_PROJECT_DIR, addTypeScriptCoreClient, ensureTypeScriptAgentConnectionProject, STRANDS_PEER_DEPENDENCY_NAMES } from "../../../utils/agent-connection/agent-connection.js";
|
|
7
7
|
import { addDestructuredImport, addStarExport, appendToArrayViaGritQL, applyGritQL } from "../../../utils/ast.js";
|
|
8
8
|
import { declareDependencies, ownedElsewhere } from "../../../utils/declared-dependencies.js";
|
|
9
9
|
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
@@ -25,10 +25,14 @@ export const DEPENDENCIES = declareDependencies()({
|
|
|
25
25
|
name: '@a2a-js/sdk',
|
|
26
26
|
root: true
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
// @strands-agents/sdk and its peers (STRANDS_PEER_DEPENDENCY_NAMES),
|
|
29
|
+
// pinned at the root so the root strands copy resolves the same peers as
|
|
30
|
+
// every other importer (see agent-connection.ts's TS_TEMPLATE_DEPS for
|
|
31
|
+
// the same reasoning).
|
|
32
|
+
...STRANDS_PEER_DEPENDENCY_NAMES.map((name)=>({
|
|
33
|
+
name,
|
|
34
|
+
root: true
|
|
35
|
+
})),
|
|
32
36
|
{
|
|
33
37
|
name: '@aws-lambda-powertools/parameters',
|
|
34
38
|
root: true
|