@aws/nx-plugin 1.0.0-rc.63 → 1.0.0-rc.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/migrations.json +7 -2
  2. package/package.json +1 -1
  3. package/src/{smithy/project/files/service/build.Dockerfile.template → migrations/latest/smithy-build-without-docker/legacy-service.Dockerfile.fixture} +2 -2
  4. package/src/migrations/latest/smithy-build-without-docker/metadata.json +3 -0
  5. package/src/migrations/latest/smithy-build-without-docker/migration.d.ts +6 -0
  6. package/src/migrations/latest/smithy-build-without-docker/migration.js +154 -0
  7. package/src/migrations/latest/smithy-build-without-docker/migration.js.map +1 -0
  8. package/src/migrations/latest/smithy-ssdk-bundle-pins/rc57-service.Dockerfile.fixture +95 -0
  9. package/src/py/agent/a2a-connection/generator.d.ts +1 -1
  10. package/src/py/agent/gateway-connection/generator.d.ts +1 -1
  11. package/src/py/agent/generator.d.ts +8 -0
  12. package/src/py/agent/mcp-connection/generator.d.ts +1 -1
  13. package/src/py/fast-api/generator.d.ts +4 -0
  14. package/src/py/mcp-server/generator.d.ts +8 -0
  15. package/src/py/rdb/generator.d.ts +8 -0
  16. package/src/smithy/project/__snapshots__/generator.spec.ts.snap +163 -260
  17. package/src/smithy/project/files/service/smithy-build.json.template +5 -5
  18. package/src/smithy/project/files/shapes/smithy-build.json.template +1 -1
  19. package/src/smithy/project/files/ssdk-bundle/ssdk.rolldown.config.mjs.template +52 -0
  20. package/src/smithy/project/generator.d.ts +76 -18
  21. package/src/smithy/project/generator.js +160 -38
  22. package/src/smithy/project/generator.js.map +1 -1
  23. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +22 -3
  24. package/src/smithy/ts/api/generator.d.ts +4 -0
  25. package/src/ts/agent/generator.d.ts +8 -0
  26. package/src/ts/mcp-server/generator.d.ts +8 -0
  27. package/src/ts/rdb/generator.d.ts +8 -0
  28. package/src/utils/docker.d.ts +2 -0
  29. package/src/utils/fs.d.ts +8 -0
  30. package/src/utils/fs.js +11 -0
  31. package/src/utils/fs.js.map +1 -1
  32. package/src/utils/smithy.d.ts +59 -0
  33. package/src/utils/smithy.js +73 -0
  34. package/src/utils/smithy.js.map +1 -0
  35. package/src/utils/version-upgrade-migration/sync-embedded-versions.d.ts +2 -2
  36. package/src/utils/version-upgrade-migration/sync-embedded-versions.js +53 -5
  37. package/src/utils/version-upgrade-migration/sync-embedded-versions.js.map +1 -1
  38. package/src/utils/versions.d.ts +33 -1
  39. package/src/utils/versions.js +26 -1
  40. package/src/utils/versions.js.map +1 -1
  41. package/src/smithy/project/files/shapes/build.Dockerfile.template +0 -33
@@ -3,40 +3,98 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type GeneratorCallback, type Tree } from '@nx/devkit';
6
+ import { FsCommands } from '../../utils/fs';
6
7
  import { type NxGeneratorInfo } from '../../utils/nx';
7
8
  import type { SmithyProjectGeneratorSchema } from './schema';
9
+ /** The metadata this generator records, which its predicates read. */
10
+ export interface SmithyProjectMetadata {
11
+ readonly smithyType: NonNullable<SmithyProjectGeneratorSchema['type']>;
12
+ readonly namespace: string;
13
+ }
8
14
  /**
9
- * Packages `build.Dockerfile` installs into the build image to bundle the Smithy
10
- * SSDK. Pinned in the file body rather than declared in a manifest, so declaring
11
- * them here — never installed into the workspace — is what keeps the version sync
12
- * moving them forward.
15
+ * Everything a Smithy build runs, all of it workspace tooling in the root
16
+ * manifest rather than anything the model itself imports.
17
+ *
18
+ * Neither the Smithy CLI nor `mise` is among them: the compile target fetches mise
19
+ * with `npx` and mise resolves the CLI, so neither is a workspace dependency — see
20
+ * `utils/smithy.ts`.
13
21
  */
14
- export declare const SSDK_BUNDLE_DEPENDENCIES: readonly [{
15
- readonly name: "rolldown";
16
- }, {
17
- readonly name: "rolldown-plugin-dts";
18
- }, {
19
- readonly name: "@rollup/plugin-esm-shim";
20
- }];
21
22
  export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
22
23
  readonly name: "ncp";
24
+ } & {
25
+ versionOnly: true;
23
26
  }, {
24
27
  readonly name: "rimraf";
25
- }, {
26
- readonly name: "make-dir-cli";
27
- }, {
28
- readonly name: "rolldown";
29
28
  } & {
30
29
  versionOnly: true;
31
30
  }, {
32
- readonly name: "rolldown-plugin-dts";
31
+ readonly name: "make-dir-cli";
33
32
  } & {
34
33
  versionOnly: true;
35
34
  }, {
36
- readonly name: "@rollup/plugin-esm-shim";
35
+ readonly name: "cpy-cli";
37
36
  } & {
38
37
  versionOnly: true;
39
- }], readonly import("../../utils/declared-dependencies").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "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" | "mcp" | "pip-check-updates" | "pip-licenses" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
38
+ }, {
39
+ readonly name: "rolldown";
40
+ readonly dev: true;
41
+ readonly root: true;
42
+ readonly when: (metadata: SmithyProjectMetadata) => boolean;
43
+ }, {
44
+ readonly name: "rolldown-plugin-dts";
45
+ readonly dev: true;
46
+ readonly root: true;
47
+ readonly when: (metadata: SmithyProjectMetadata) => boolean;
48
+ }, {
49
+ readonly name: "typescript";
50
+ readonly dev: true;
51
+ readonly root: true;
52
+ readonly when: (metadata: SmithyProjectMetadata) => boolean;
53
+ }], readonly import("../../utils/declared-dependencies").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "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" | "mcp" | "pip-check-updates" | "pip-licenses" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", SmithyProjectMetadata>[]>;
40
54
  export declare const SMITHY_PROJECT_GENERATOR_INFO: NxGeneratorInfo;
55
+ /**
56
+ * The commands that build a Smithy project's model, run from the workspace root.
57
+ *
58
+ * This is the whole of a shape library's build. A service's Server SDK is built
59
+ * separately by {@link smithyGenerateSsdkCommands}, from the codegen output this
60
+ * leaves under {@link SMITHY_OUT_DIR}.
61
+ */
62
+ export declare const smithyCompileCommands: (cmd: FsCommands<typeof DEPENDENCIES>, type: SmithyProjectGeneratorSchema["type"]) => string[];
63
+ /**
64
+ * The commands that turn a service's generated TypeScript Server SDK into the
65
+ * single module its consumer imports, run from the workspace root.
66
+ *
67
+ * Only a service has one, and it reads what the model build left behind, so this
68
+ * runs after `compile`.
69
+ */
70
+ export declare const smithyGenerateSsdkCommands: () => string[];
71
+ /**
72
+ * What the model build publishes, listed per artifact rather than as the whole
73
+ * `build` directory: a service's `generate-ssdk` writes into that directory too, and
74
+ * restoring `compile` from cache would otherwise discard the Server SDK beside it.
75
+ */
76
+ export declare const smithyCompileOutputs: (type: SmithyProjectGeneratorSchema["type"]) => string[];
77
+ /**
78
+ * The target that builds a service's Server SDK, shared with the migration moving
79
+ * an existing project onto it.
80
+ */
81
+ export declare const smithyGenerateSsdkTarget: () => {
82
+ cache: boolean;
83
+ outputs: string[];
84
+ executor: string;
85
+ dependsOn: string[];
86
+ options: {
87
+ commands: string[];
88
+ parallel: boolean;
89
+ cwd: string;
90
+ };
91
+ };
92
+ /**
93
+ * Write the rolldown config that bundles a service's generated Server SDK.
94
+ *
95
+ * Shared with the migration moving an existing project off the container build,
96
+ * so a migrated project's config cannot drift from a freshly generated one.
97
+ */
98
+ export declare const writeSsdkBundleConfig: (tree: Tree, projectRoot: string) => void;
41
99
  export declare const smithyProjectGenerator: (tree: Tree, options: SmithyProjectGeneratorSchema) => Promise<GeneratorCallback>;
42
100
  export default smithyProjectGenerator;
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */ import { addProjectConfiguration, generateFiles, joinPathFragments, OverwriteStrategy } from "@nx/devkit";
5
5
  import { getTsLibDetails } from "../../ts/lib/generator.js";
6
- import { resolveContainers } from "../../utils/containers.js";
6
+ import { addTsDependencies } from "../../utils/add-dependencies.js";
7
7
  import { declareDependencies, ownedElsewhere } from "../../utils/declared-dependencies.js";
8
8
  import { formatFilesInSubtree } from "../../utils/format.js";
9
9
  import { FS_DEPENDENCIES, FsCommands } from "../../utils/fs.js";
@@ -12,33 +12,139 @@ import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
12
12
  import { toClassName, toKebabCase } from "../../utils/names.js";
13
13
  import { getNpmScope } from "../../utils/npm-scope.js";
14
14
  import { addGeneratorMetadata, getGeneratorInfo, projectExists } from "../../utils/nx.js";
15
- import { TS_VERSIONS } from "../../utils/versions.js";
15
+ import { getRelativePathToRootByDirectory } from "../../utils/paths.js";
16
+ import { smithyCliCommand, smithyMavenVersions, warnIfSmithyMissing } from "../../utils/smithy.js";
16
17
  /**
17
- * Packages `build.Dockerfile` installs into the build image to bundle the Smithy
18
- * SSDK. Pinned in the file body rather than declared in a manifest, so declaring
19
- * them here never installed into the workspace — is what keeps the version sync
20
- * moving them forward.
21
- */ export const SSDK_BUNDLE_DEPENDENCIES = [
22
- {
23
- name: 'rolldown'
24
- },
25
- {
26
- name: 'rolldown-plugin-dts'
27
- },
28
- {
29
- name: '@rollup/plugin-esm-shim'
30
- }
31
- ];
32
- export const DEPENDENCIES = declareDependencies()({
18
+ * Only a service project generates a Server SDK, so only a service needs the
19
+ * bundler that turns it into the single module its backend imports. A shape
20
+ * library assembles a model and stops.
21
+ */ const isService = (metadata)=>metadata.smithyType === 'service';
22
+ /**
23
+ * Everything a Smithy build runs, all of it workspace tooling in the root
24
+ * manifest rather than anything the model itself imports.
25
+ *
26
+ * Neither the Smithy CLI nor `mise` is among them: the compile target fetches mise
27
+ * with `npx` and mise resolves the CLI, so neither is a workspace dependency — see
28
+ * `utils/smithy.ts`.
29
+ */ export const DEPENDENCIES = declareDependencies()({
33
30
  ts: [
34
- ...FS_DEPENDENCIES,
35
- ...ownedElsewhere(SSDK_BUNDLE_DEPENDENCIES)
31
+ // Added to the root by `FsCommands` as it builds each command.
32
+ ...ownedElsewhere(FS_DEPENDENCIES),
33
+ {
34
+ name: 'rolldown',
35
+ dev: true,
36
+ root: true,
37
+ when: isService
38
+ },
39
+ {
40
+ name: 'rolldown-plugin-dts',
41
+ dev: true,
42
+ root: true,
43
+ when: isService
44
+ },
45
+ // Resolved by `rolldown-plugin-dts` to emit the bundled declaration.
46
+ {
47
+ name: 'typescript',
48
+ dev: true,
49
+ root: true,
50
+ when: isService
51
+ }
36
52
  ]
37
53
  });
38
54
  export const SMITHY_PROJECT_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
55
+ /**
56
+ * Where the Smithy CLI writes its artifacts, and where the build publishes the
57
+ * ones consumers read. Both sit under `dist` so a build writes nothing into the
58
+ * project, keeping the source tree clean and the target's outputs cacheable.
59
+ *
60
+ * The CLI's own output is kept beside the published tree rather than inside it:
61
+ * it holds the generated SSDK package and its installed `node_modules`, which
62
+ * must not be mistaken for a build artifact.
63
+ */ const SMITHY_OUT_DIR = 'dist/{projectRoot}/smithy';
64
+ const BUILD_DIR = 'dist/{projectRoot}/build';
65
+ /** The projection every generated `smithy-build.json` builds. */ const SOURCE_PROJECTION = `${SMITHY_OUT_DIR}/source`;
66
+ /** Where the generated TypeScript Server SDK lands before it is bundled. */ const SSDK_CODEGEN_DIR = `${SOURCE_PROJECTION}/typescript-ssdk-codegen`;
67
+ /**
68
+ * The commands that build a Smithy project's model, run from the workspace root.
69
+ *
70
+ * This is the whole of a shape library's build. A service's Server SDK is built
71
+ * separately by {@link smithyGenerateSsdkCommands}, from the codegen output this
72
+ * leaves under {@link SMITHY_OUT_DIR}.
73
+ */ export const smithyCompileCommands = (cmd, type)=>[
74
+ cmd.rm(BUILD_DIR),
75
+ cmd.rm(SMITHY_OUT_DIR),
76
+ cmd.mkdir(BUILD_DIR),
77
+ // `imports` in smithy-build.json resolve relative to that file, so a shape
78
+ // library is referenced by its path from the consuming project.
79
+ `${smithyCliCommand()} build -c {projectRoot}/smithy-build.json --output ${SMITHY_OUT_DIR}`,
80
+ ...type === 'shapes' ? [
81
+ cmd.cp(`${SOURCE_PROJECTION}/model/model.json`, `${BUILD_DIR}/model.json`)
82
+ ] : [
83
+ // Named after the service shape by the OpenAPI plugin, so it is matched
84
+ // rather than named, and published under a stable name.
85
+ cmd.cpGlobToFile(`${SOURCE_PROJECTION}/openapi/*.openapi.json`, `${BUILD_DIR}/openapi`, 'openapi.json')
86
+ ]
87
+ ];
88
+ /**
89
+ * The commands that turn a service's generated TypeScript Server SDK into the
90
+ * single module its consumer imports, run from the workspace root.
91
+ *
92
+ * Only a service has one, and it reads what the model build left behind, so this
93
+ * runs after `compile`.
94
+ */ export const smithyGenerateSsdkCommands = ()=>[
95
+ // `npm` regardless of the workspace's package manager: this installs a generated
96
+ // package under `dist` that is not a workspace member, and npm ships with Node so
97
+ // it is always present. It reads the user's `.npmrc`, so a private registry still
98
+ // applies. `--include=dev` because the bundler resolves types from the generated
99
+ // package's devDependencies, which `NODE_ENV=production` would otherwise omit.
100
+ `npm install --prefix ${SSDK_CODEGEN_DIR} --include=dev --ignore-scripts --no-audit --no-fund`,
101
+ // Bundled straight from the generated TypeScript sources, emitting the module and
102
+ // its declarations together — see ssdk.rolldown.config.mjs for why the sources
103
+ // rather than a `tsc` pre-pass.
104
+ `rolldown -c {projectRoot}/ssdk.rolldown.config.mjs`
105
+ ];
106
+ /**
107
+ * What the model build publishes, listed per artifact rather than as the whole
108
+ * `build` directory: a service's `generate-ssdk` writes into that directory too, and
109
+ * restoring `compile` from cache would otherwise discard the Server SDK beside it.
110
+ */ export const smithyCompileOutputs = (type)=>[
111
+ `{workspaceRoot}/${SMITHY_OUT_DIR}`,
112
+ type === 'shapes' ? `{workspaceRoot}/${BUILD_DIR}/model.json` : `{workspaceRoot}/${BUILD_DIR}/openapi`
113
+ ];
114
+ /**
115
+ * The target that builds a service's Server SDK, shared with the migration moving
116
+ * an existing project onto it.
117
+ */ export const smithyGenerateSsdkTarget = ()=>({
118
+ cache: true,
119
+ outputs: [
120
+ `{workspaceRoot}/${BUILD_DIR}/ssdk`
121
+ ],
122
+ executor: 'nx:run-commands',
123
+ dependsOn: [
124
+ 'compile'
125
+ ],
126
+ options: {
127
+ commands: smithyGenerateSsdkCommands(),
128
+ parallel: false,
129
+ cwd: '{workspaceRoot}'
130
+ }
131
+ });
132
+ /**
133
+ * Write the rolldown config that bundles a service's generated Server SDK.
134
+ *
135
+ * Shared with the migration moving an existing project off the container build,
136
+ * so a migrated project's config cannot drift from a freshly generated one.
137
+ */ export const writeSsdkBundleConfig = (tree, projectRoot)=>generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'ssdk-bundle'), projectRoot, // The config's paths are workspace-root relative, so it needs only the
138
+ // project's root — the compile target runs from the workspace root.
139
+ {
140
+ projectRoot
141
+ }, // Generated configuration rather than anything the user edits, so a re-run
142
+ // refreshes it — unlike the models beside it.
143
+ {
144
+ overwriteStrategy: OverwriteStrategy.Overwrite
145
+ });
39
146
  export const smithyProjectGenerator = async (tree, options)=>{
40
147
  const cmd = new FsCommands(tree, DEPENDENCIES);
41
- const containers = await resolveContainers(tree, 'inherit');
42
148
  const type = options.type ?? 'service';
43
149
  // Create project.json
44
150
  const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);
@@ -50,28 +156,27 @@ export const smithyProjectGenerator = async (tree, options)=>{
50
156
  projectType: 'library',
51
157
  targets: {
52
158
  build: {
53
- dependsOn: [
159
+ dependsOn: type === 'shapes' ? [
54
160
  'compile'
161
+ ] : [
162
+ 'compile',
163
+ 'generate-ssdk'
55
164
  ]
56
165
  },
57
166
  compile: {
58
167
  cache: true,
59
- outputs: [
60
- '{workspaceRoot}/dist/{projectRoot}/build'
61
- ],
168
+ outputs: smithyCompileOutputs(type),
62
169
  executor: 'nx:run-commands',
63
170
  options: {
64
- commands: [
65
- cmd.rm('dist/{projectRoot}/build'),
66
- cmd.mkdir('dist/{projectRoot}/build'),
67
- // The workspace build context lets a project's Dockerfile copy in
68
- // the built models of shape libraries it depends on. Commands run
69
- // from the workspace root, so it is the current directory.
70
- `${containers} build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}`
71
- ],
171
+ commands: smithyCompileCommands(cmd, type),
72
172
  parallel: false,
73
173
  cwd: '{workspaceRoot}'
74
174
  }
175
+ },
176
+ // Only a service generates a Server SDK, and it is built from what the
177
+ // model build leaves behind.
178
+ ...type === 'shapes' ? {} : {
179
+ 'generate-ssdk': smithyGenerateSsdkTarget()
75
180
  }
76
181
  }
77
182
  });
@@ -86,23 +191,40 @@ export const smithyProjectGenerator = async (tree, options)=>{
86
191
  serviceNameClassName,
87
192
  serviceNameKebabCase,
88
193
  scope,
89
- rolldownVersion: TS_VERSIONS.rolldown,
90
- rolldownDtsVersion: TS_VERSIONS['rolldown-plugin-dts'],
91
- esmShimVersion: TS_VERSIONS['@rollup/plugin-esm-shim']
194
+ projectRoot: dir,
195
+ relativePathToWorkspaceRoot: getRelativePathToRootByDirectory(dir),
196
+ ...smithyMavenVersions()
92
197
  }, {
93
198
  // Smithy models are user-owned — a re-run must not discard edits
94
199
  overwriteStrategy: OverwriteStrategy.KeepExisting
95
200
  });
96
- addGeneratorMetadata(tree, fullyQualifiedName, SMITHY_PROJECT_GENERATOR_INFO, {
201
+ if (type === 'service') {
202
+ writeSsdkBundleConfig(tree, dir);
203
+ }
204
+ // Recorded here and read by the declaration's predicates, so the packages
205
+ // added below are exactly the ones the version sync will own.
206
+ const metadata = {
97
207
  smithyType: type,
98
- namespace,
208
+ namespace
209
+ };
210
+ addGeneratorMetadata(tree, fullyQualifiedName, SMITHY_PROJECT_GENERATOR_INFO, {
211
+ ...metadata,
99
212
  ...type === 'service' ? {
100
213
  apiName: options.name
101
214
  } : {}
102
215
  });
216
+ // No projectRoot: a Smithy model project has no manifest of its own, and every
217
+ // dependency here is workspace tooling the build runs rather than anything the
218
+ // model imports.
219
+ addTsDependencies(tree, DEPENDENCIES, {
220
+ metadata
221
+ });
103
222
  await addGeneratorMetricsIfApplicable(tree, [
104
223
  SMITHY_PROJECT_GENERATOR_INFO
105
224
  ]);
225
+ // On Windows the build runs the Smithy CLI from the PATH rather than through
226
+ // mise, so flag a missing prerequisite while the project is still being set up.
227
+ warnIfSmithyMissing();
106
228
  await formatFilesInSubtree(tree);
107
229
  return ()=>installDependencies(tree, options.preferInstallDependencies, {
108
230
  languages: [
@@ -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';\nimport { resolveContainers } from '../../utils/containers';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { toClassName, toKebabCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport { type ITsDepVersion, TS_VERSIONS } from '../../utils/versions';\nimport type { SmithyProjectGeneratorSchema } from './schema';\n\n/**\n * Packages `build.Dockerfile` installs into the build image to bundle the Smithy\n * SSDK. Pinned in the file body rather than declared in a manifest, so declaring\n * them here — never installed into the workspace — is what keeps the version sync\n * moving them forward.\n */\nexport const SSDK_BUNDLE_DEPENDENCIES = [\n { name: 'rolldown' },\n { name: 'rolldown-plugin-dts' },\n { name: '@rollup/plugin-esm-shim' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...FS_DEPENDENCIES, ...ownedElsewhere(SSDK_BUNDLE_DEPENDENCIES)],\n});\n\nexport const SMITHY_PROJECT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const smithyProjectGenerator = async (\n tree: Tree,\n options: SmithyProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const cmd = new FsCommands(tree, DEPENDENCIES);\n const containers = await resolveContainers(tree, 'inherit');\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: ['compile'],\n },\n compile: {\n cache: true,\n outputs: ['{workspaceRoot}/dist/{projectRoot}/build'],\n executor: 'nx:run-commands',\n options: {\n commands: [\n cmd.rm('dist/{projectRoot}/build'),\n cmd.mkdir('dist/{projectRoot}/build'),\n // The workspace build context lets a project's Dockerfile copy in\n // the built models of shape libraries it depends on. Commands run\n // from the workspace root, so it is the current directory.\n `${containers} build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}`,\n ],\n parallel: false,\n cwd: '{workspaceRoot}',\n },\n },\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 rolldownVersion: TS_VERSIONS.rolldown,\n rolldownDtsVersion: TS_VERSIONS['rolldown-plugin-dts'],\n esmShimVersion: TS_VERSIONS['@rollup/plugin-esm-shim'],\n },\n {\n // Smithy models are user-owned — a re-run must not discard edits\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n SMITHY_PROJECT_GENERATOR_INFO,\n {\n smithyType: type,\n namespace,\n ...(type === 'service' ? { apiName: options.name } : {}),\n },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [SMITHY_PROJECT_GENERATOR_INFO]);\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","resolveContainers","declareDependencies","ownedElsewhere","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","getNpmScope","addGeneratorMetadata","getGeneratorInfo","projectExists","TS_VERSIONS","SSDK_BUNDLE_DEPENDENCIES","name","DEPENDENCIES","ts","SMITHY_PROJECT_GENERATOR_INFO","filename","smithyProjectGenerator","tree","options","cmd","containers","type","fullyQualifiedName","dir","root","sourceRoot","projectType","targets","build","dependsOn","compile","cache","outputs","executor","commands","rm","mkdir","parallel","cwd","serviceName","serviceNameClassName","serviceNameKebabCase","scope","namespace","replace","dirname","rolldownVersion","rolldown","rolldownDtsVersion","esmShimVersion","overwriteStrategy","KeepExisting","smithyType","apiName","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAEZ,aAAa;AACpB,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAiB;AAC7D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,WAAW,EAAEC,WAAW,QAAQ,uBAAoB;AAC7D,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAiB;AACxB,SAA6BC,WAAW,QAAQ,0BAAuB;AAGvE;;;;;CAKC,GACD,OAAO,MAAMC,2BAA2B;IACtC;QAAEC,MAAM;IAAW;IACnB;QAAEA,MAAM;IAAsB;IAC9B;QAAEA,MAAM;IAA0B;CACnC,CAAuD;AAExD,OAAO,MAAMC,eAAehB,sBAAsB;IAChDiB,IAAI;WAAId;WAAoBF,eAAea;KAA0B;AACvE,GAAG;AAEH,OAAO,MAAMI,gCAAiDP,iBAC5D,YAAYQ,QAAQ,EACpB;AAEF,OAAO,MAAMC,yBAAyB,OACpCC,MACAC;IAEA,MAAMC,MAAM,IAAInB,WAAWiB,MAAML;IACjC,MAAMQ,aAAa,MAAMzB,kBAAkBsB,MAAM;IACjD,MAAMI,OAAOH,QAAQG,IAAI,IAAI;IAE7B,sBAAsB;IACtB,MAAM,EAAEC,kBAAkB,EAAEC,GAAG,EAAE,GAAG7B,gBAAgBuB,MAAMC;IAE1D,IAAI,CAACV,cAAcS,MAAMK,qBAAq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BAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAevC,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';\nimport { addTsDependencies } from '../../utils/add-dependencies';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { toClassName, toKebabCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport {\n smithyCliCommand,\n smithyMavenVersions,\n warnIfSmithyMissing,\n} from '../../utils/smithy';\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.cp(\n `${SOURCE_PROJECTION}/model/model.json`,\n `${BUILD_DIR}/model.json`,\n ),\n ]\n : [\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 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","cp","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","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,4BAAyB;AACzD,SAASC,iBAAiB,QAAQ,kCAA+B;AACjE,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAiB;AAC7D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,WAAW,EAAEC,WAAW,QAAQ,uBAAoB;AAC7D,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAiB;AACxB,SAASC,gCAAgC,QAAQ,uBAAoB;AACrE,SACEC,gBAAgB,EAChBC,mBAAmB,EACnBC,mBAAmB,QACd,wBAAqB;AAS5B;;;;CAIC,GACD,MAAMC,YAAY,CAACC,WACjBA,SAASC,UAAU,KAAK;AAE1B;;;;;;;CAOC,GACD,OAAO,MAAMC,eAAepB,sBAA6C;IACvEqB,IAAI;QACF,+DAA+D;WAC5DpB,eAAeE;QAClB;YAAEmB,MAAM;YAAYC,KAAK;YAAMC,MAAM;YAAMC,MAAMR;QAAU;QAC3D;YAAEK,MAAM;YAAuBC,KAAK;YAAMC,MAAM;YAAMC,MAAMR;QAAU;QACtE,qEAA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AE,iBAAiBO;gBAA2B,CAAC;YACrD;QACF;IACF;IAEA,MAAMuB,cAAclB,QAAQkB,WAAW,IAAIlB,QAAQxB,IAAI;IACvD,MAAM2C,uBAAuB1D,YAAYyD;IACzC,MAAME,uBAAuB1D,YAAYwD;IACzC,MAAMG,QAAQ1D,YAAY0C;IAC1B,MAAMiB,YAAYtB,QAAQsB,SAAS,IAAI5D,YAAY2D,OAAOE,OAAO,CAAC,MAAM;IAExE1E,cACEwD,MACAvD,kBAAkB,YAAYyD,OAAO,EAAE,SAASnB,OAChDwB,KACA;QACEU;QACAH;QACAC;QACAC;QACAf,aAAaM;QACbY,6BAA6BzD,iCAAiC6C;QAC9D,GAAG3C,qBAAqB;IAC1B,GACA;QACE,iEAAiE;QACjEuC,mBAAmBzD,kBAAkB0E,YAAY;IACnD;IAGF,IAAIrC,SAAS,WAAW;QACtBgB,sBAAsBC,MAAMO;IAC9B;IAEA,0EAA0E;IAC1E,8DAA8D;IAC9D,MAAMxC,WAAkC;QAAEC,YAAYe;QAAMkC;IAAU;IAEtE1D,qBACEyC,MACAM,oBACA/B,+BACA;QACE,GAAGR,QAAQ;QACX,GAAIgB,SAAS,YAAY;YAAEsC,SAAS1B,QAAQxB,IAAI;QAAC,IAAI,CAAC,CAAC;IACzD;IAGF,+EAA+E;IAC/E,+EAA+E;IAC/E,iBAAiB;IACjBvB,kBAAkBoD,MAAM/B,cAAc;QAAEF;IAAS;IAEjD,MAAMZ,gCAAgC6C,MAAM;QAACzB;KAA8B;IAE3E,6EAA6E;IAC7E,gFAAgF;IAChFV;IAEA,MAAMd,qBAAqBiD;IAC3B,OAAO,IACL9C,oBAAoB8C,MAAML,QAAQ2B,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAelB,uBAAuB"}
@@ -1751,17 +1751,36 @@ exports[`tsSmithyApiGenerator > should generate smithy ts api with default optio
1751
1751
  },
1752
1752
  "targets": {
1753
1753
  "build": {
1754
- "dependsOn": ["compile"]
1754
+ "dependsOn": ["compile", "generate-ssdk"]
1755
1755
  },
1756
1756
  "compile": {
1757
1757
  "cache": true,
1758
- "outputs": ["{workspaceRoot}/dist/{projectRoot}/build"],
1758
+ "outputs": [
1759
+ "{workspaceRoot}/dist/{projectRoot}/smithy",
1760
+ "{workspaceRoot}/dist/{projectRoot}/build/openapi"
1761
+ ],
1759
1762
  "executor": "nx:run-commands",
1760
1763
  "options": {
1761
1764
  "commands": [
1762
1765
  "rimraf dist/{projectRoot}/build",
1766
+ "rimraf dist/{projectRoot}/smithy",
1763
1767
  "make-dir dist/{projectRoot}/build",
1764
- "docker build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
1768
+ "npx -y mise@2026.8.3 exec smithy@1.72.1 -- smithy build -c {projectRoot}/smithy-build.json --output dist/{projectRoot}/smithy",
1769
+ "cpy \\"dist/{projectRoot}/smithy/source/openapi/*.openapi.json\\" dist/{projectRoot}/build/openapi --flat --rename=openapi.json"
1770
+ ],
1771
+ "parallel": false,
1772
+ "cwd": "{workspaceRoot}"
1773
+ }
1774
+ },
1775
+ "generate-ssdk": {
1776
+ "cache": true,
1777
+ "outputs": ["{workspaceRoot}/dist/{projectRoot}/build/ssdk"],
1778
+ "executor": "nx:run-commands",
1779
+ "dependsOn": ["compile"],
1780
+ "options": {
1781
+ "commands": [
1782
+ "npm install --prefix dist/{projectRoot}/smithy/source/typescript-ssdk-codegen --include=dev --ignore-scripts --no-audit --no-fund",
1783
+ "rolldown -c {projectRoot}/ssdk.rolldown.config.mjs"
1765
1784
  ],
1766
1785
  "parallel": false,
1767
1786
  "cwd": "{workspaceRoot}"
@@ -50,6 +50,10 @@ export declare const DEPENDENCIES: import("../../../utils/declared-dependencies"
50
50
  readonly name: "make-dir-cli";
51
51
  } & {
52
52
  versionOnly: true;
53
+ }, {
54
+ readonly name: "cpy-cli";
55
+ } & {
56
+ versionOnly: true;
53
57
  }, {
54
58
  readonly name: "@aws-sdk/client-api-gateway";
55
59
  readonly when: (m: IacMetadata) => boolean;
@@ -144,6 +144,10 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
144
144
  readonly name: "make-dir-cli";
145
145
  } & {
146
146
  versionOnly: true;
147
+ }, {
148
+ readonly name: "cpy-cli";
149
+ } & {
150
+ versionOnly: true;
147
151
  }, {
148
152
  readonly name: "ncp";
149
153
  } & {
@@ -156,6 +160,10 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
156
160
  readonly name: "make-dir-cli";
157
161
  } & {
158
162
  versionOnly: true;
163
+ }, {
164
+ readonly name: "cpy-cli";
165
+ } & {
166
+ versionOnly: true;
159
167
  }, {
160
168
  readonly name: "constructs";
161
169
  readonly when: (m: IacMetadata) => boolean;
@@ -45,6 +45,10 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
45
45
  readonly name: "make-dir-cli";
46
46
  } & {
47
47
  versionOnly: true;
48
+ }, {
49
+ readonly name: "cpy-cli";
50
+ } & {
51
+ versionOnly: true;
48
52
  }, {
49
53
  readonly name: "rolldown";
50
54
  } & {
@@ -61,6 +65,10 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
61
65
  readonly name: "make-dir-cli";
62
66
  } & {
63
67
  versionOnly: true;
68
+ }, {
69
+ readonly name: "cpy-cli";
70
+ } & {
71
+ versionOnly: true;
64
72
  }, {
65
73
  readonly name: "constructs";
66
74
  readonly when: (m: IacMetadata) => boolean;
@@ -59,6 +59,10 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
59
59
  readonly name: "make-dir-cli";
60
60
  } & {
61
61
  versionOnly: true;
62
+ }, {
63
+ readonly name: "cpy-cli";
64
+ } & {
65
+ versionOnly: true;
62
66
  }, {
63
67
  readonly name: "ncp";
64
68
  } & {
@@ -71,6 +75,10 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
71
75
  readonly name: "make-dir-cli";
72
76
  } & {
73
77
  versionOnly: true;
78
+ }, {
79
+ readonly name: "cpy-cli";
80
+ } & {
81
+ versionOnly: true;
74
82
  }, {
75
83
  readonly name: "constructs";
76
84
  readonly when: (m: IacMetadata) => boolean;
@@ -11,6 +11,8 @@ export declare const DOCKER_DEPENDENCIES: readonly [{
11
11
  readonly name: "rimraf";
12
12
  }, {
13
13
  readonly name: "make-dir-cli";
14
+ }, {
15
+ readonly name: "cpy-cli";
14
16
  }];
15
17
  /**
16
18
  * Substitution variables for the vended Node `Dockerfile` templates: the npm
package/src/utils/fs.d.ts CHANGED
@@ -11,6 +11,8 @@ export declare const FS_DEPENDENCIES: readonly [{
11
11
  readonly name: "rimraf";
12
12
  }, {
13
13
  readonly name: "make-dir-cli";
14
+ }, {
15
+ readonly name: "cpy-cli";
14
16
  }];
15
17
  /**
16
18
  * Platform agnostic commands for filesystem operations, adding the CLIs they
@@ -23,5 +25,11 @@ export declare class FsCommands<D extends DependencyDeclaration> {
23
25
  cp(src: string, dst: string): string;
24
26
  rm(dir: string): string;
25
27
  mkdir(dir: string): string;
28
+ /**
29
+ * Copy the single file a glob matches to `dst`, for an artifact whose producer
30
+ * names it — the Smithy OpenAPI plugin writes `<ServiceShape>.openapi.json`.
31
+ * Fails rather than silently doing nothing when the glob matches nothing.
32
+ */
33
+ cpGlobToFile(srcGlob: string, dstDir: string, dstFileName: string): string;
26
34
  private add;
27
35
  }
package/src/utils/fs.js CHANGED
@@ -13,6 +13,9 @@ import { withVersions } from "./versions.js";
13
13
  },
14
14
  {
15
15
  name: 'make-dir-cli'
16
+ },
17
+ {
18
+ name: 'cpy-cli'
16
19
  }
17
20
  ];
18
21
  /**
@@ -37,6 +40,14 @@ import { withVersions } from "./versions.js";
37
40
  this.add('make-dir-cli');
38
41
  return `make-dir ${dir}`;
39
42
  }
43
+ /**
44
+ * Copy the single file a glob matches to `dst`, for an artifact whose producer
45
+ * names it — the Smithy OpenAPI plugin writes `<ServiceShape>.openapi.json`.
46
+ * Fails rather than silently doing nothing when the glob matches nothing.
47
+ */ cpGlobToFile(srcGlob, dstDir, dstFileName) {
48
+ this.add('cpy-cli');
49
+ return `cpy "${srcGlob}" ${dstDir} --flat --rename=${dstFileName}`;
50
+ }
40
51
  add(dep) {
41
52
  addDependenciesToPackageJson(this.tree, {}, withVersions(forDependencies(this.declaration), [
42
53
  dep
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/fs.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Tree } from '@nx/devkit';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies';\nimport { addDependenciesToPackageJson } from './dependencies';\nimport { type ITsDepVersion, withVersions } from './versions';\n\n/** Dependencies a caller must declare to use `FsCommands`. */\nexport const FS_DEPENDENCIES = [\n { name: 'ncp' },\n { name: 'rimraf' },\n { name: 'make-dir-cli' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\n/**\n * Platform agnostic commands for filesystem operations, adding the CLIs they\n * need to the root package.json.\n */\nexport class FsCommands<D extends DependencyDeclaration> {\n private tree: Tree;\n private declaration: D;\n\n constructor(\n tree: Tree,\n declaration: D & MustDeclare<typeof FS_DEPENDENCIES, D>,\n ) {\n this.tree = tree;\n this.declaration = declaration;\n }\n\n public cp(src: string, dst: string) {\n this.add('ncp');\n return `ncp ${src} ${dst}`;\n }\n\n public rm(dir: string) {\n this.add('rimraf');\n return `rimraf ${dir}`;\n }\n\n public mkdir(dir: string) {\n this.add('make-dir-cli');\n return `make-dir ${dir}`;\n }\n\n private add(dep: (typeof FS_DEPENDENCIES)[number]['name']) {\n addDependenciesToPackageJson(\n this.tree,\n {},\n withVersions(forDependencies<typeof FS_DEPENDENCIES>(this.declaration), [\n dep,\n ]),\n );\n }\n}\n"],"names":["forDependencies","addDependenciesToPackageJson","withVersions","FS_DEPENDENCIES","name","FsCommands","tree","declaration","cp","src","dst","add","rm","dir","mkdir","dep"],"mappings":"AAAA;;;CAGC,GAED,SAEEA,eAAe,QAEV,6BAA0B;AACjC,SAASC,4BAA4B,QAAQ,oBAAiB;AAC9D,SAA6BC,YAAY,QAAQ,gBAAa;AAE9D,4DAA4D,GAC5D,OAAO,MAAMC,kBAAkB;IAC7B;QAAEC,MAAM;IAAM;IACd;QAAEA,MAAM;IAAS;IACjB;QAAEA,MAAM;IAAe;CACxB,CAAuD;AAExD;;;CAGC,GACD,OAAO,MAAMC;IACHC,KAAW;IACXC,YAAe;IAEvB,YACED,IAAU,EACVC,WAAuD,CACvD;QACA,IAAI,CAACD,IAAI,GAAGA;QACZ,IAAI,CAACC,WAAW,GAAGA;IACrB;IAEOC,GAAGC,GAAW,EAAEC,GAAW,EAAE;QAClC,IAAI,CAACC,GAAG,CAAC;QACT,OAAO,CAAC,IAAI,EAAEF,IAAI,CAAC,EAAEC,KAAK;IAC5B;IAEOE,GAAGC,GAAW,EAAE;QACrB,IAAI,CAACF,GAAG,CAAC;QACT,OAAO,CAAC,OAAO,EAAEE,KAAK;IACxB;IAEOC,MAAMD,GAAW,EAAE;QACxB,IAAI,CAACF,GAAG,CAAC;QACT,OAAO,CAAC,SAAS,EAAEE,KAAK;IAC1B;IAEQF,IAAII,GAA6C,EAAE;QACzDd,6BACE,IAAI,CAACK,IAAI,EACT,CAAC,GACDJ,aAAaF,gBAAwC,IAAI,CAACO,WAAW,GAAG;YACtEQ;SACD;IAEL;AACF"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/fs.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Tree } from '@nx/devkit';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies';\nimport { addDependenciesToPackageJson } from './dependencies';\nimport { type ITsDepVersion, withVersions } from './versions';\n\n/** Dependencies a caller must declare to use `FsCommands`. */\nexport const FS_DEPENDENCIES = [\n { name: 'ncp' },\n { name: 'rimraf' },\n { name: 'make-dir-cli' },\n { name: 'cpy-cli' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\n/**\n * Platform agnostic commands for filesystem operations, adding the CLIs they\n * need to the root package.json.\n */\nexport class FsCommands<D extends DependencyDeclaration> {\n private tree: Tree;\n private declaration: D;\n\n constructor(\n tree: Tree,\n declaration: D & MustDeclare<typeof FS_DEPENDENCIES, D>,\n ) {\n this.tree = tree;\n this.declaration = declaration;\n }\n\n public cp(src: string, dst: string) {\n this.add('ncp');\n return `ncp ${src} ${dst}`;\n }\n\n public rm(dir: string) {\n this.add('rimraf');\n return `rimraf ${dir}`;\n }\n\n public mkdir(dir: string) {\n this.add('make-dir-cli');\n return `make-dir ${dir}`;\n }\n\n /**\n * Copy the single file a glob matches to `dst`, for an artifact whose producer\n * names it — the Smithy OpenAPI plugin writes `<ServiceShape>.openapi.json`.\n * Fails rather than silently doing nothing when the glob matches nothing.\n */\n public cpGlobToFile(srcGlob: string, dstDir: string, dstFileName: string) {\n this.add('cpy-cli');\n return `cpy \"${srcGlob}\" ${dstDir} --flat --rename=${dstFileName}`;\n }\n\n private add(dep: (typeof FS_DEPENDENCIES)[number]['name']) {\n addDependenciesToPackageJson(\n this.tree,\n {},\n withVersions(forDependencies<typeof FS_DEPENDENCIES>(this.declaration), [\n dep,\n ]),\n );\n }\n}\n"],"names":["forDependencies","addDependenciesToPackageJson","withVersions","FS_DEPENDENCIES","name","FsCommands","tree","declaration","cp","src","dst","add","rm","dir","mkdir","cpGlobToFile","srcGlob","dstDir","dstFileName","dep"],"mappings":"AAAA;;;CAGC,GAED,SAEEA,eAAe,QAEV,6BAA0B;AACjC,SAASC,4BAA4B,QAAQ,oBAAiB;AAC9D,SAA6BC,YAAY,QAAQ,gBAAa;AAE9D,4DAA4D,GAC5D,OAAO,MAAMC,kBAAkB;IAC7B;QAAEC,MAAM;IAAM;IACd;QAAEA,MAAM;IAAS;IACjB;QAAEA,MAAM;IAAe;IACvB;QAAEA,MAAM;IAAU;CACnB,CAAuD;AAExD;;;CAGC,GACD,OAAO,MAAMC;IACHC,KAAW;IACXC,YAAe;IAEvB,YACED,IAAU,EACVC,WAAuD,CACvD;QACA,IAAI,CAACD,IAAI,GAAGA;QACZ,IAAI,CAACC,WAAW,GAAGA;IACrB;IAEOC,GAAGC,GAAW,EAAEC,GAAW,EAAE;QAClC,IAAI,CAACC,GAAG,CAAC;QACT,OAAO,CAAC,IAAI,EAAEF,IAAI,CAAC,EAAEC,KAAK;IAC5B;IAEOE,GAAGC,GAAW,EAAE;QACrB,IAAI,CAACF,GAAG,CAAC;QACT,OAAO,CAAC,OAAO,EAAEE,KAAK;IACxB;IAEOC,MAAMD,GAAW,EAAE;QACxB,IAAI,CAACF,GAAG,CAAC;QACT,OAAO,CAAC,SAAS,EAAEE,KAAK;IAC1B;IAEA;;;;GAIC,GACD,AAAOE,aAAaC,OAAe,EAAEC,MAAc,EAAEC,WAAmB,EAAE;QACxE,IAAI,CAACP,GAAG,CAAC;QACT,OAAO,CAAC,KAAK,EAAEK,QAAQ,EAAE,EAAEC,OAAO,iBAAiB,EAAEC,aAAa;IACpE;IAEQP,IAAIQ,GAA6C,EAAE;QACzDlB,6BACE,IAAI,CAACK,IAAI,EACT,CAAC,GACDJ,aAAaF,gBAAwC,IAAI,CAACO,WAAW,GAAG;YACtEY;SACD;IAEL;AACF"}