@aws/nx-plugin-mcp 1.0.0-rc.53 → 1.0.0-rc.54
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.
|
@@ -77,117 +77,11 @@ For TypeScript, check out [Smithy TypeScript](https://github.com/smithy-lang/smi
|
|
|
77
77
|
|
|
78
78
|
Type Safe API provided a Projen project type named `SmithyShapeLibraryProject` which configured a project which contained Smithy models which could be reused by multiple Smithy-based APIs.
|
|
79
79
|
|
|
80
|
-
The
|
|
80
|
+
The equivalent is the <Link path="/guides/smithy-project">`smithy#project` generator</Link> with `type` set to `shapes`:
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
<RunGenerator generator="smithy#project" requiredParameters={{ name: 'my-shapes', type: 'shapes' }} />
|
|
83
83
|
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
1. Create your shape library using the `smithy#project` generator:
|
|
87
|
-
|
|
88
|
-
<RunGenerator generator="smithy#project" />
|
|
89
|
-
|
|
90
|
-
Specify any name for the `serviceName` option, as we will remove the `service` shape.
|
|
91
|
-
|
|
92
|
-
:::note
|
|
93
|
-
This generator is hidden at the time of writing and so you will need to execute it via the CLI.
|
|
94
|
-
:::
|
|
95
|
-
|
|
96
|
-
1. Replace the default model in `src` with the shapes you wish to define
|
|
97
|
-
|
|
98
|
-
1. Update `smithy-build.json` to remove the `plugins` and any unused maven dependencies
|
|
99
|
-
|
|
100
|
-
1. Replace `build.Dockerfile` with minimal build steps:
|
|
101
|
-
|
|
102
|
-
```docker
|
|
103
|
-
// build.Dockerfile
|
|
104
|
-
FROM public.ecr.aws/docker/library/node:24 AS builder
|
|
105
|
-
|
|
106
|
-
# Output directory
|
|
107
|
-
RUN mkdir /out
|
|
108
|
-
|
|
109
|
-
# Install Smithy CLI
|
|
110
|
-
# https://smithy.io/2.0/guides/smithy-cli/cli_installation.html
|
|
111
|
-
WORKDIR /smithy
|
|
112
|
-
ARG TARGETPLATFORM
|
|
113
|
-
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH="aarch64"; else ARCH="x86_64"; fi && \
|
|
114
|
-
mkdir -p smithy-install/smithy && \
|
|
115
|
-
curl -L https://github.com/smithy-lang/smithy/releases/download/1.61.0/smithy-cli-linux-$ARCH.zip -o smithy-install/smithy-cli-linux-$ARCH.zip && \
|
|
116
|
-
unzip -qo smithy-install/smithy-cli-linux-$ARCH.zip -d smithy-install && \
|
|
117
|
-
mv smithy-install/smithy-cli-linux-$ARCH/* smithy-install/smithy
|
|
118
|
-
RUN smithy-install/smithy/install
|
|
119
|
-
|
|
120
|
-
# Copy project files
|
|
121
|
-
COPY smithy-build.json .
|
|
122
|
-
COPY src src
|
|
123
|
-
|
|
124
|
-
# Smithy build with Maven cache mount
|
|
125
|
-
RUN --mount=type=cache,target=/root/.m2/repository,id=maven-cache \
|
|
126
|
-
smithy build
|
|
127
|
-
|
|
128
|
-
RUN cp -r build/* /out/
|
|
129
|
-
|
|
130
|
-
# Export the /out directory
|
|
131
|
-
FROM scratch AS export
|
|
132
|
-
COPY --from=builder /out /
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
</Steps>
|
|
136
|
-
|
|
137
|
-
###### Consume the Shape Library
|
|
138
|
-
|
|
139
|
-
In your service model project(s), make the following changes to consume the shape library:
|
|
140
|
-
|
|
141
|
-
<Steps>
|
|
142
|
-
|
|
143
|
-
1. Update the `compile` target in `project.json` to add the workspace as build context, and a dependency on the shape library's `build` target
|
|
144
|
-
|
|
145
|
-
```json {10,15} "--build-context workspace=." "@my-project/shapes:build"
|
|
146
|
-
// project.json
|
|
147
|
-
{
|
|
148
|
-
"cache": true,
|
|
149
|
-
"outputs": ["{workspaceRoot}/dist/{projectRoot}/build"],
|
|
150
|
-
"executor": "nx:run-commands",
|
|
151
|
-
"options": {
|
|
152
|
-
"commands": [
|
|
153
|
-
"rimraf dist/packages/api/model/build",
|
|
154
|
-
"make-dir dist/packages/api/model/build",
|
|
155
|
-
"docker build --build-context workspace=. -f packages/api/model/build.Dockerfile --target export --output type=local,dest=dist/packages/api/model/build packages/api/model"
|
|
156
|
-
],
|
|
157
|
-
"parallel": false,
|
|
158
|
-
"cwd": "{workspaceRoot}"
|
|
159
|
-
},
|
|
160
|
-
"dependsOn": ["@my-project/shapes:build"]
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
1. Update the `build.Dockerfile` to copy the `src` directory from your shape library. For example, assuming the shape library is located in `packages/shapes`:
|
|
165
|
-
|
|
166
|
-
```docker {5}
|
|
167
|
-
// build.Dockerfile
|
|
168
|
-
# Copy project files
|
|
169
|
-
COPY smithy-build.json .
|
|
170
|
-
COPY src src
|
|
171
|
-
COPY --from=workspace packages/shapes/src shapes
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
1. Update `smithy-build.json` to add the shapes directory to its `sources`:
|
|
175
|
-
|
|
176
|
-
```json {4} "shapes/"
|
|
177
|
-
// smithy-build.json
|
|
178
|
-
{
|
|
179
|
-
"version": "1.0",
|
|
180
|
-
"sources": ["src/", "shapes/"],
|
|
181
|
-
"plugins": {
|
|
182
|
-
...
|
|
183
|
-
}
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
</Steps>
|
|
187
|
-
|
|
188
|
-
:::note
|
|
189
|
-
Please express your interest on the [GitHub issue here](https://github.com/awslabs/nx-plugin-for-aws/issues/304) if you have a use case for a dedicated Smithy shape library generator.
|
|
190
|
-
:::
|
|
84
|
+
Move the shapes from your `SmithyShapeLibraryProject` into the generated project's `src` folder, then refer to the <Link path="/guides/smithy-project#depending-on-a-shape-library">Smithy project guide</Link> for how to wire the library up as a dependency of your API's model.
|
|
191
85
|
|
|
192
86
|
#### Interceptors
|
|
193
87
|
|