@aws/nx-plugin 1.0.0-rc.52 → 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.
- package/README.md +1 -0
- package/generators.json +2 -2
- package/migrations.json +5 -0
- package/package.json +1 -1
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.d.ts +6 -0
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js +94 -0
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +109 -4
- package/src/smithy/project/files/shapes/build.Dockerfile.template +33 -0
- package/src/smithy/project/files/shapes/smithy-build.json.template +7 -0
- package/src/smithy/project/files/shapes/src/main.smithy.template +11 -0
- package/src/smithy/project/generator.js +15 -4
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/project/schema.d.js.map +1 -1
- package/src/smithy/project/schema.d.ts +1 -0
- package/src/smithy/project/schema.json +23 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +3 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +12 -0
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +4 -0
- /package/src/smithy/project/files/{build.Dockerfile.template → service/build.Dockerfile.template} +0 -0
- /package/src/smithy/project/files/{smithy-build.json.template → service/smithy-build.json.template} +0 -0
- /package/src/smithy/project/files/{src → service/src}/main.smithy.template +0 -0
- /package/src/smithy/project/files/{src → service/src}/operations/echo.smithy.template +0 -0
package/README.md
CHANGED
|
@@ -171,6 +171,7 @@ pnpm nx g @aws/nx-plugin:ts#infra
|
|
|
171
171
|
| `ts#mcp-server` | MCP server (TypeScript) |
|
|
172
172
|
| `ts#agent` | [Strands Agent](https://strandsagents.com/) (TypeScript) |
|
|
173
173
|
| `ts#nx-generator` | Nx generator scaffold |
|
|
174
|
+
| `smithy#project` | Smithy model project — a service model, or a shape library shared between Smithy projects |
|
|
174
175
|
| `py#project` | Python project (uv) |
|
|
175
176
|
| `py#api` | Python API (FastAPI) with API Gateway + Lambda + [Powertools](https://github.com/aws-powertools/powertools-lambda-python) |
|
|
176
177
|
| `py#lambda-function` | Python Lambda with type-safe event sources |
|
package/generators.json
CHANGED
|
@@ -165,9 +165,9 @@
|
|
|
165
165
|
"smithy#project": {
|
|
166
166
|
"factory": "./src/smithy/project/generator",
|
|
167
167
|
"schema": "./src/smithy/project/schema.json",
|
|
168
|
-
"description": "Generate a Smithy model project",
|
|
168
|
+
"description": "Generate a Smithy model project, either defining a service or a library of reusable shapes",
|
|
169
169
|
"metric": "g27",
|
|
170
|
-
"
|
|
170
|
+
"guidePages": ["smithy-project"]
|
|
171
171
|
},
|
|
172
172
|
"smithy#react-connection": {
|
|
173
173
|
"factory": "./src/smithy/react-connection/generator",
|
package/migrations.json
CHANGED
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"version": "1.0.0-rc.52",
|
|
22
22
|
"description": "Count the EC2MetaDataSSRF_QUERYARGUMENTS WAF rule on the UserIdentity Web ACL so sign-in from a local dev server is not blocked",
|
|
23
23
|
"implementation": "./src/migrations/latest/user-identity-waf-allow-localhost-callback/migration"
|
|
24
|
+
},
|
|
25
|
+
"latest-order-access-log-delivery-after-bucket-policy": {
|
|
26
|
+
"version": "1.0.0-rc.54",
|
|
27
|
+
"description": "Order the S3 server access log delivery source after the bucket policy to avoid a 409 from concurrent bucket configuration writes",
|
|
28
|
+
"implementation": "./src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration"
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { addDestructuredImport, applyGritQL, captureGritQL, matchGritQL } from "../../../utils/ast.js";
|
|
5
|
+
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
6
|
+
import { PACKAGES_DIR, SHARED_CONSTRUCTS_DIR } from "../../../utils/shared-constructs-constants.js";
|
|
7
|
+
/**
|
|
8
|
+
* Order the S3 server access log delivery source after the bucket policy.
|
|
9
|
+
*
|
|
10
|
+
* S3 rejects concurrent configuration writes against the same bucket with a 409
|
|
11
|
+
* (OperationAborted). The generated StaticWebsite construct left the delivery
|
|
12
|
+
* source and the bucket policy unordered, so CloudFormation could submit both at
|
|
13
|
+
* once and fail the stack.
|
|
14
|
+
*/ const STATIC_WEBSITE_FILE = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src/core/static-website.ts`;
|
|
15
|
+
const BUCKET_ARN_SUFFIX = '.bucketArn';
|
|
16
|
+
/**
|
|
17
|
+
* The bucket whose policy the delivery source must be ordered after is the one
|
|
18
|
+
* the delivery source itself targets, so read it off `resourceArn` rather than
|
|
19
|
+
* assuming the generated parameter name. Returns undefined unless exactly one
|
|
20
|
+
* simple identifier is found, so a diverged helper is left alone.
|
|
21
|
+
*/ const findDeliverySourceBucket = async (tree, filePath)=>{
|
|
22
|
+
const captured = await captureGritQL(tree, filePath, '`resourceArn: $bucket.bucketArn`');
|
|
23
|
+
if (!captured) return undefined;
|
|
24
|
+
const bucket = captured.slice(captured.indexOf(':') + 1).replace(BUCKET_ARN_SUFFIX, '').trim();
|
|
25
|
+
// Only a plain identifier can be cast and dereferenced safely in the
|
|
26
|
+
// statement this migration writes.
|
|
27
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(bucket) ? bucket : undefined;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Confirm the bucket the delivery source targets is declared as a parameter of
|
|
31
|
+
* the enclosing helper, so the statement this migration writes references a
|
|
32
|
+
* variable that is actually in scope.
|
|
33
|
+
*/ const isBucketDeclaredParameter = async (tree, filePath, bucket)=>await matchGritQL(tree, filePath, `\`private deliverAccessLogsToCloudWatch($params) { $_ }\` where {
|
|
34
|
+
$params <: contains \`${bucket}: $bucketType\`,
|
|
35
|
+
$bucketType <: or { \`IBucket\`, \`Bucket\` }
|
|
36
|
+
}`);
|
|
37
|
+
// Inserts the bucket policy dependency between the delivery source and the
|
|
38
|
+
// delivery destination, matching the shape generators produced prior to this
|
|
39
|
+
// fix. Anchored on the destination declaration so the source's own (multi-line,
|
|
40
|
+
// Lazy-valued) arguments don't need to be matched.
|
|
41
|
+
const addDependencyPattern = (bucket)=>`\`const $dest: CfnDeliveryDestination = new CfnDeliveryDestination($destArgs)\` as $decl where {
|
|
42
|
+
$dest <: \`destination\`
|
|
43
|
+
} => \`const bucketPolicy = (${bucket} as Bucket).policy;
|
|
44
|
+
if (bucketPolicy) {
|
|
45
|
+
source.node.addDependency(bucketPolicy);
|
|
46
|
+
}
|
|
47
|
+
$decl\``;
|
|
48
|
+
export default async function migration(tree) {
|
|
49
|
+
const nextSteps = [];
|
|
50
|
+
if (!tree.exists(STATIC_WEBSITE_FILE)) {
|
|
51
|
+
// No vended StaticWebsite construct in this workspace - nothing to migrate.
|
|
52
|
+
return {
|
|
53
|
+
nextSteps
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const contents = tree.read(STATIC_WEBSITE_FILE, 'utf-8') ?? '';
|
|
57
|
+
if (contents.includes('source.node.addDependency(bucketPolicy)')) {
|
|
58
|
+
// Already migrated.
|
|
59
|
+
return {
|
|
60
|
+
nextSteps
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const divergedMessage = `${STATIC_WEBSITE_FILE}: deliverAccessLogsToCloudWatch has diverged from the generated shape - left untouched. Manually order the S3 server access log delivery source after the bucket policy of the bucket it targets (\`source.node.addDependency(bucketPolicy)\`), avoiding a 409 (OperationAborted) from concurrent bucket configuration writes.`;
|
|
64
|
+
// The rewrite is anchored on the delivery destination but references the
|
|
65
|
+
// `source` variable, so only apply it when the delivery source still has the
|
|
66
|
+
// generated shape.
|
|
67
|
+
const hasGeneratedSource = await matchGritQL(tree, STATIC_WEBSITE_FILE, '`const source: CfnDeliverySource = new CfnDeliverySource($_)`');
|
|
68
|
+
const bucket = hasGeneratedSource ? await findDeliverySourceBucket(tree, STATIC_WEBSITE_FILE) : undefined;
|
|
69
|
+
if (!bucket || !await isBucketDeclaredParameter(tree, STATIC_WEBSITE_FILE, bucket)) {
|
|
70
|
+
nextSteps.push(divergedMessage);
|
|
71
|
+
return {
|
|
72
|
+
nextSteps
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const rewrote = await applyGritQL(tree, STATIC_WEBSITE_FILE, addDependencyPattern(bucket));
|
|
76
|
+
if (!rewrote) {
|
|
77
|
+
nextSteps.push(divergedMessage);
|
|
78
|
+
return {
|
|
79
|
+
nextSteps
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// The inserted statement casts to the concrete Bucket to reach its policy,
|
|
83
|
+
// which the helper's own `IBucket` parameter type does not expose.
|
|
84
|
+
await addDestructuredImport(tree, STATIC_WEBSITE_FILE, [
|
|
85
|
+
'Bucket'
|
|
86
|
+
], 'aws-cdk-lib/aws-s3');
|
|
87
|
+
nextSteps.push(`${STATIC_WEBSITE_FILE}: the S3 server access log delivery source is now created after the policy of the bucket it targets, avoiding a 409 (OperationAborted) from concurrent bucket configuration writes.`);
|
|
88
|
+
await formatFilesInSubtree(tree);
|
|
89
|
+
return {
|
|
90
|
+
nextSteps
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationReturnObject, Tree } from '@nx/devkit';\nimport {\n addDestructuredImport,\n applyGritQL,\n captureGritQL,\n matchGritQL,\n} from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n} from '../../../utils/shared-constructs-constants';\n\n/**\n * Order the S3 server access log delivery source after the bucket policy.\n *\n * S3 rejects concurrent configuration writes against the same bucket with a 409\n * (OperationAborted). The generated StaticWebsite construct left the delivery\n * source and the bucket policy unordered, so CloudFormation could submit both at\n * once and fail the stack.\n */\n\nconst STATIC_WEBSITE_FILE = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src/core/static-website.ts`;\n\nconst BUCKET_ARN_SUFFIX = '.bucketArn';\n\n/**\n * The bucket whose policy the delivery source must be ordered after is the one\n * the delivery source itself targets, so read it off `resourceArn` rather than\n * assuming the generated parameter name. Returns undefined unless exactly one\n * simple identifier is found, so a diverged helper is left alone.\n */\nconst findDeliverySourceBucket = async (\n tree: Tree,\n filePath: string,\n): Promise<string | undefined> => {\n const captured = await captureGritQL(\n tree,\n filePath,\n '`resourceArn: $bucket.bucketArn`',\n );\n if (!captured) return undefined;\n\n const bucket = captured\n .slice(captured.indexOf(':') + 1)\n .replace(BUCKET_ARN_SUFFIX, '')\n .trim();\n\n // Only a plain identifier can be cast and dereferenced safely in the\n // statement this migration writes.\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(bucket) ? bucket : undefined;\n};\n\n/**\n * Confirm the bucket the delivery source targets is declared as a parameter of\n * the enclosing helper, so the statement this migration writes references a\n * variable that is actually in scope.\n */\nconst isBucketDeclaredParameter = async (\n tree: Tree,\n filePath: string,\n bucket: string,\n): Promise<boolean> =>\n await matchGritQL(\n tree,\n filePath,\n `\\`private deliverAccessLogsToCloudWatch($params) { $_ }\\` where {\n $params <: contains \\`${bucket}: $bucketType\\`,\n $bucketType <: or { \\`IBucket\\`, \\`Bucket\\` }\n }`,\n );\n\n// Inserts the bucket policy dependency between the delivery source and the\n// delivery destination, matching the shape generators produced prior to this\n// fix. Anchored on the destination declaration so the source's own (multi-line,\n// Lazy-valued) arguments don't need to be matched.\nconst addDependencyPattern = (bucket: string) =>\n `\\`const $dest: CfnDeliveryDestination = new CfnDeliveryDestination($destArgs)\\` as $decl where {\n $dest <: \\`destination\\`\n} => \\`const bucketPolicy = (${bucket} as Bucket).policy;\n if (bucketPolicy) {\n source.node.addDependency(bucketPolicy);\n }\n $decl\\``;\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n if (!tree.exists(STATIC_WEBSITE_FILE)) {\n // No vended StaticWebsite construct in this workspace - nothing to migrate.\n return { nextSteps };\n }\n\n const contents = tree.read(STATIC_WEBSITE_FILE, 'utf-8') ?? '';\n if (contents.includes('source.node.addDependency(bucketPolicy)')) {\n // Already migrated.\n return { nextSteps };\n }\n\n const divergedMessage = `${STATIC_WEBSITE_FILE}: deliverAccessLogsToCloudWatch has diverged from the generated shape - left untouched. Manually order the S3 server access log delivery source after the bucket policy of the bucket it targets (\\`source.node.addDependency(bucketPolicy)\\`), avoiding a 409 (OperationAborted) from concurrent bucket configuration writes.`;\n\n // The rewrite is anchored on the delivery destination but references the\n // `source` variable, so only apply it when the delivery source still has the\n // generated shape.\n const hasGeneratedSource = await matchGritQL(\n tree,\n STATIC_WEBSITE_FILE,\n '`const source: CfnDeliverySource = new CfnDeliverySource($_)`',\n );\n\n const bucket = hasGeneratedSource\n ? await findDeliverySourceBucket(tree, STATIC_WEBSITE_FILE)\n : undefined;\n\n if (\n !bucket ||\n !(await isBucketDeclaredParameter(tree, STATIC_WEBSITE_FILE, bucket))\n ) {\n nextSteps.push(divergedMessage);\n return { nextSteps };\n }\n\n const rewrote = await applyGritQL(\n tree,\n STATIC_WEBSITE_FILE,\n addDependencyPattern(bucket),\n );\n\n if (!rewrote) {\n nextSteps.push(divergedMessage);\n return { nextSteps };\n }\n\n // The inserted statement casts to the concrete Bucket to reach its policy,\n // which the helper's own `IBucket` parameter type does not expose.\n await addDestructuredImport(\n tree,\n STATIC_WEBSITE_FILE,\n ['Bucket'],\n 'aws-cdk-lib/aws-s3',\n );\n\n nextSteps.push(\n `${STATIC_WEBSITE_FILE}: the S3 server access log delivery source is now created after the policy of the bucket it targets, avoiding a 409 (OperationAborted) from concurrent bucket configuration writes.`,\n );\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["addDestructuredImport","applyGritQL","captureGritQL","matchGritQL","formatFilesInSubtree","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","STATIC_WEBSITE_FILE","BUCKET_ARN_SUFFIX","findDeliverySourceBucket","tree","filePath","captured","undefined","bucket","slice","indexOf","replace","trim","test","isBucketDeclaredParameter","addDependencyPattern","migration","nextSteps","exists","contents","read","includes","divergedMessage","hasGeneratedSource","push","rewrote"],"mappings":"AAAA;;;CAGC,GAED,SACEA,qBAAqB,EACrBC,WAAW,EACXC,aAAa,EACbC,WAAW,QACN,wBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SACEC,YAAY,EACZC,qBAAqB,QAChB,gDAA6C;AAEpD;;;;;;;CAOC,GAED,MAAMC,sBAAsB,GAAGF,aAAa,CAAC,EAAEC,sBAAsB,2BAA2B,CAAC;AAEjG,MAAME,oBAAoB;AAE1B;;;;;CAKC,GACD,MAAMC,2BAA2B,OAC/BC,MACAC;IAEA,MAAMC,WAAW,MAAMV,cACrBQ,MACAC,UACA;IAEF,IAAI,CAACC,UAAU,OAAOC;IAEtB,MAAMC,SAASF,SACZG,KAAK,CAACH,SAASI,OAAO,CAAC,OAAO,GAC9BC,OAAO,CAACT,mBAAmB,IAC3BU,IAAI;IAEP,qEAAqE;IACrE,mCAAmC;IACnC,OAAO,6BAA6BC,IAAI,CAACL,UAAUA,SAASD;AAC9D;AAEA;;;;CAIC,GACD,MAAMO,4BAA4B,OAChCV,MACAC,UACAG,SAEA,MAAMX,YACJO,MACAC,UACA,CAAC;4BACuB,EAAEG,OAAO;;KAEhC,CAAC;AAGN,2EAA2E;AAC3E,6EAA6E;AAC7E,gFAAgF;AAChF,mDAAmD;AACnD,MAAMO,uBAAuB,CAACP,SAC5B,CAAC;;6BAE0B,EAAEA,OAAO;;;;WAI3B,CAAC;AAEZ,eAAe,eAAeQ,UAC5BZ,IAAU;IAEV,MAAMa,YAAsB,EAAE;IAE9B,IAAI,CAACb,KAAKc,MAAM,CAACjB,sBAAsB;QACrC,4EAA4E;QAC5E,OAAO;YAAEgB;QAAU;IACrB;IAEA,MAAME,WAAWf,KAAKgB,IAAI,CAACnB,qBAAqB,YAAY;IAC5D,IAAIkB,SAASE,QAAQ,CAAC,4CAA4C;QAChE,oBAAoB;QACpB,OAAO;YAAEJ;QAAU;IACrB;IAEA,MAAMK,kBAAkB,GAAGrB,oBAAoB,8TAA8T,CAAC;IAE9W,yEAAyE;IACzE,6EAA6E;IAC7E,mBAAmB;IACnB,MAAMsB,qBAAqB,MAAM1B,YAC/BO,MACAH,qBACA;IAGF,MAAMO,SAASe,qBACX,MAAMpB,yBAAyBC,MAAMH,uBACrCM;IAEJ,IACE,CAACC,UACD,CAAE,MAAMM,0BAA0BV,MAAMH,qBAAqBO,SAC7D;QACAS,UAAUO,IAAI,CAACF;QACf,OAAO;YAAEL;QAAU;IACrB;IAEA,MAAMQ,UAAU,MAAM9B,YACpBS,MACAH,qBACAc,qBAAqBP;IAGvB,IAAI,CAACiB,SAAS;QACZR,UAAUO,IAAI,CAACF;QACf,OAAO;YAAEL;QAAU;IACrB;IAEA,2EAA2E;IAC3E,mEAAmE;IACnE,MAAMvB,sBACJU,MACAH,qBACA;QAAC;KAAS,EACV;IAGFgB,UAAUO,IAAI,CACZ,GAAGvB,oBAAoB,mLAAmL,CAAC;IAG7M,MAAMH,qBAAqBM;IAE3B,OAAO;QAAEa;IAAU;AACrB"}
|
|
@@ -108,6 +108,8 @@ The following list of generators are what is currently available in the \`@aws/n
|
|
|
108
108
|
|
|
109
109
|
- **py#agent**: Add an AI Agent to a Python project
|
|
110
110
|
|
|
111
|
+
- **smithy#project**: Generate a Smithy model project, either defining a service or a library of reusable shapes
|
|
112
|
+
|
|
111
113
|
- **terraform#project**: Generates a Terraform project
|
|
112
114
|
|
|
113
115
|
- **ts#docs**: Generates a documentation site
|
|
@@ -1,5 +1,102 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`smithyProjectGenerator > shape libraries > should generate a shape library without a service > shapes-build.Dockerfile 1`] = `
|
|
4
|
+
"FROM public.ecr.aws/docker/library/node:24 AS builder
|
|
5
|
+
ENV CI=true
|
|
6
|
+
|
|
7
|
+
# Output directory
|
|
8
|
+
RUN mkdir /out
|
|
9
|
+
|
|
10
|
+
# Install Smithy CLI
|
|
11
|
+
# https://smithy.io/2.0/guides/smithy-cli/cli_installation.html
|
|
12
|
+
WORKDIR /smithy
|
|
13
|
+
ARG TARGETPLATFORM
|
|
14
|
+
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH="aarch64"; else ARCH="x86_64"; fi && \\
|
|
15
|
+
mkdir -p smithy-install/smithy && \\
|
|
16
|
+
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 && \\
|
|
17
|
+
unzip -qo smithy-install/smithy-cli-linux-$ARCH.zip -d smithy-install && \\
|
|
18
|
+
mv smithy-install/smithy-cli-linux-$ARCH/* smithy-install/smithy
|
|
19
|
+
RUN smithy-install/smithy/install
|
|
20
|
+
|
|
21
|
+
# Copy project files
|
|
22
|
+
WORKDIR /project
|
|
23
|
+
COPY smithy-build.json .
|
|
24
|
+
COPY src src
|
|
25
|
+
|
|
26
|
+
# Validate the model and assemble it into a single JSON model file
|
|
27
|
+
RUN --mount=type=cache,target=/root/.m2/repository,id=maven-cache \\
|
|
28
|
+
smithy build
|
|
29
|
+
|
|
30
|
+
# Copy the assembled model to the output location
|
|
31
|
+
RUN mkdir -p /out/model
|
|
32
|
+
RUN cp /project/build/smithy/source/model/model.json /out/model/model.json
|
|
33
|
+
|
|
34
|
+
# Export the /out directory
|
|
35
|
+
FROM scratch AS export
|
|
36
|
+
COPY --from=builder /out /
|
|
37
|
+
"
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
exports[`smithyProjectGenerator > shape libraries > should generate a shape library without a service > shapes-main.smithy 1`] = `
|
|
41
|
+
"$version: "2.0"
|
|
42
|
+
|
|
43
|
+
namespace proj
|
|
44
|
+
|
|
45
|
+
/// TODO: define the shapes you would like to share between your Smithy projects
|
|
46
|
+
structure ExampleShape {
|
|
47
|
+
@required
|
|
48
|
+
id: String
|
|
49
|
+
|
|
50
|
+
description: String
|
|
51
|
+
}
|
|
52
|
+
"
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
exports[`smithyProjectGenerator > shape libraries > should generate a shape library without a service > shapes-project.json 1`] = `
|
|
56
|
+
"{
|
|
57
|
+
"name": "@proj/test-shapes",
|
|
58
|
+
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
|
59
|
+
"sourceRoot": "test-shapes/src",
|
|
60
|
+
"projectType": "library",
|
|
61
|
+
"metadata": {
|
|
62
|
+
"generator": "smithy#project",
|
|
63
|
+
"smithyType": "shapes",
|
|
64
|
+
"namespace": "proj"
|
|
65
|
+
},
|
|
66
|
+
"targets": {
|
|
67
|
+
"build": {
|
|
68
|
+
"dependsOn": ["compile"]
|
|
69
|
+
},
|
|
70
|
+
"compile": {
|
|
71
|
+
"cache": true,
|
|
72
|
+
"outputs": ["{workspaceRoot}/dist/{projectRoot}/build"],
|
|
73
|
+
"executor": "nx:run-commands",
|
|
74
|
+
"options": {
|
|
75
|
+
"commands": [
|
|
76
|
+
"rimraf dist/{projectRoot}/build",
|
|
77
|
+
"make-dir dist/{projectRoot}/build",
|
|
78
|
+
"docker build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
79
|
+
],
|
|
80
|
+
"parallel": false,
|
|
81
|
+
"cwd": "{workspaceRoot}"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
"
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
exports[`smithyProjectGenerator > shape libraries > should generate a shape library without a service > shapes-smithy-build.json 1`] = `
|
|
90
|
+
"{
|
|
91
|
+
"version": "1.0",
|
|
92
|
+
"sources": ["src/"],
|
|
93
|
+
"maven": {
|
|
94
|
+
"dependencies": ["software.amazon.smithy:smithy-model:1.61.0"]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
"
|
|
98
|
+
`;
|
|
99
|
+
|
|
3
100
|
exports[`smithyProjectGenerator > should generate smithy project with all custom options > all-custom-main.smithy 1`] = `
|
|
4
101
|
"$version: "2.0"
|
|
5
102
|
|
|
@@ -31,6 +128,8 @@ exports[`smithyProjectGenerator > should generate smithy project with all custom
|
|
|
31
128
|
"projectType": "library",
|
|
32
129
|
"metadata": {
|
|
33
130
|
"generator": "smithy#project",
|
|
131
|
+
"smithyType": "service",
|
|
132
|
+
"namespace": "com.mycompany.api",
|
|
34
133
|
"apiName": "test-api"
|
|
35
134
|
},
|
|
36
135
|
"targets": {
|
|
@@ -45,7 +144,7 @@ exports[`smithyProjectGenerator > should generate smithy project with all custom
|
|
|
45
144
|
"commands": [
|
|
46
145
|
"rimraf dist/{projectRoot}/build",
|
|
47
146
|
"make-dir dist/{projectRoot}/build",
|
|
48
|
-
"docker build -f {projectRoot}/build.Dockerfile --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
147
|
+
"docker build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
49
148
|
],
|
|
50
149
|
"parallel": false,
|
|
51
150
|
"cwd": "{workspaceRoot}"
|
|
@@ -64,6 +163,8 @@ exports[`smithyProjectGenerator > should generate smithy project with custom dir
|
|
|
64
163
|
"projectType": "library",
|
|
65
164
|
"metadata": {
|
|
66
165
|
"generator": "smithy#project",
|
|
166
|
+
"smithyType": "service",
|
|
167
|
+
"namespace": "proj",
|
|
67
168
|
"apiName": "test-api"
|
|
68
169
|
},
|
|
69
170
|
"targets": {
|
|
@@ -78,7 +179,7 @@ exports[`smithyProjectGenerator > should generate smithy project with custom dir
|
|
|
78
179
|
"commands": [
|
|
79
180
|
"rimraf dist/{projectRoot}/build",
|
|
80
181
|
"make-dir dist/{projectRoot}/build",
|
|
81
|
-
"docker build -f {projectRoot}/build.Dockerfile --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
182
|
+
"docker build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
82
183
|
],
|
|
83
184
|
"parallel": false,
|
|
84
185
|
"cwd": "{workspaceRoot}"
|
|
@@ -288,6 +389,8 @@ exports[`smithyProjectGenerator > should generate smithy project with default op
|
|
|
288
389
|
"projectType": "library",
|
|
289
390
|
"metadata": {
|
|
290
391
|
"generator": "smithy#project",
|
|
392
|
+
"smithyType": "service",
|
|
393
|
+
"namespace": "proj",
|
|
291
394
|
"apiName": "test-api"
|
|
292
395
|
},
|
|
293
396
|
"targets": {
|
|
@@ -302,7 +405,7 @@ exports[`smithyProjectGenerator > should generate smithy project with default op
|
|
|
302
405
|
"commands": [
|
|
303
406
|
"rimraf dist/{projectRoot}/build",
|
|
304
407
|
"make-dir dist/{projectRoot}/build",
|
|
305
|
-
"docker build -f {projectRoot}/build.Dockerfile --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
408
|
+
"docker build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
306
409
|
],
|
|
307
410
|
"parallel": false,
|
|
308
411
|
"cwd": "{workspaceRoot}"
|
|
@@ -350,6 +453,8 @@ exports[`smithyProjectGenerator > should generate smithy project with subdirecto
|
|
|
350
453
|
"projectType": "library",
|
|
351
454
|
"metadata": {
|
|
352
455
|
"generator": "smithy#project",
|
|
456
|
+
"smithyType": "service",
|
|
457
|
+
"namespace": "proj",
|
|
353
458
|
"apiName": "test-api"
|
|
354
459
|
},
|
|
355
460
|
"targets": {
|
|
@@ -364,7 +469,7 @@ exports[`smithyProjectGenerator > should generate smithy project with subdirecto
|
|
|
364
469
|
"commands": [
|
|
365
470
|
"rimraf dist/{projectRoot}/build",
|
|
366
471
|
"make-dir dist/{projectRoot}/build",
|
|
367
|
-
"docker build -f {projectRoot}/build.Dockerfile --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
472
|
+
"docker build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
368
473
|
],
|
|
369
474
|
"parallel": false,
|
|
370
475
|
"cwd": "{workspaceRoot}"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
FROM public.ecr.aws/docker/library/node:24 AS builder
|
|
2
|
+
ENV CI=true
|
|
3
|
+
|
|
4
|
+
# Output directory
|
|
5
|
+
RUN mkdir /out
|
|
6
|
+
|
|
7
|
+
# Install Smithy CLI
|
|
8
|
+
# https://smithy.io/2.0/guides/smithy-cli/cli_installation.html
|
|
9
|
+
WORKDIR /smithy
|
|
10
|
+
ARG TARGETPLATFORM
|
|
11
|
+
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH="aarch64"; else ARCH="x86_64"; fi && \
|
|
12
|
+
mkdir -p smithy-install/smithy && \
|
|
13
|
+
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 && \
|
|
14
|
+
unzip -qo smithy-install/smithy-cli-linux-$ARCH.zip -d smithy-install && \
|
|
15
|
+
mv smithy-install/smithy-cli-linux-$ARCH/* smithy-install/smithy
|
|
16
|
+
RUN smithy-install/smithy/install
|
|
17
|
+
|
|
18
|
+
# Copy project files
|
|
19
|
+
WORKDIR /project
|
|
20
|
+
COPY smithy-build.json .
|
|
21
|
+
COPY src src
|
|
22
|
+
|
|
23
|
+
# Validate the model and assemble it into a single JSON model file
|
|
24
|
+
RUN --mount=type=cache,target=/root/.m2/repository,id=maven-cache \
|
|
25
|
+
smithy build
|
|
26
|
+
|
|
27
|
+
# Copy the assembled model to the output location
|
|
28
|
+
RUN mkdir -p /out/model
|
|
29
|
+
RUN cp /project/build/smithy/source/model/model.json /out/model/model.json
|
|
30
|
+
|
|
31
|
+
# Export the /out directory
|
|
32
|
+
FROM scratch AS export
|
|
33
|
+
COPY --from=builder /out /
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import { addProjectConfiguration, generateFiles, joinPathFragments } from "@nx/devkit";
|
|
4
|
+
*/ import { addProjectConfiguration, generateFiles, joinPathFragments, OverwriteStrategy } from "@nx/devkit";
|
|
5
5
|
import { getTsLibDetails } from "../../ts/lib/generator.js";
|
|
6
6
|
import { resolveContainers } from "../../utils/containers.js";
|
|
7
7
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
@@ -15,6 +15,7 @@ export const SMITHY_PROJECT_GENERATOR_INFO = getGeneratorInfo(import.meta.filena
|
|
|
15
15
|
export const smithyProjectGenerator = async (tree, options)=>{
|
|
16
16
|
const cmd = new FsCommands(tree);
|
|
17
17
|
const containers = await resolveContainers(tree, 'inherit');
|
|
18
|
+
const type = options.type ?? 'service';
|
|
18
19
|
// Create project.json
|
|
19
20
|
const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);
|
|
20
21
|
if (!projectExists(tree, fullyQualifiedName)) {
|
|
@@ -39,7 +40,10 @@ export const smithyProjectGenerator = async (tree, options)=>{
|
|
|
39
40
|
commands: [
|
|
40
41
|
cmd.rm('dist/{projectRoot}/build'),
|
|
41
42
|
cmd.mkdir('dist/{projectRoot}/build'),
|
|
42
|
-
|
|
43
|
+
// The workspace build context lets a project's Dockerfile copy in
|
|
44
|
+
// the built models of shape libraries it depends on. Commands run
|
|
45
|
+
// from the workspace root, so it is the current directory.
|
|
46
|
+
`${containers} build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}`
|
|
43
47
|
],
|
|
44
48
|
parallel: false,
|
|
45
49
|
cwd: '{workspaceRoot}'
|
|
@@ -53,14 +57,21 @@ export const smithyProjectGenerator = async (tree, options)=>{
|
|
|
53
57
|
const serviceNameKebabCase = toKebabCase(serviceName);
|
|
54
58
|
const scope = getNpmScope(tree);
|
|
55
59
|
const namespace = options.namespace ?? toKebabCase(scope).replace(/-/g, '.');
|
|
56
|
-
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files'), dir, {
|
|
60
|
+
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', type), dir, {
|
|
57
61
|
namespace,
|
|
58
62
|
serviceNameClassName,
|
|
59
63
|
serviceNameKebabCase,
|
|
60
64
|
scope
|
|
65
|
+
}, {
|
|
66
|
+
// Smithy models are user-owned — a re-run must not discard edits
|
|
67
|
+
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
61
68
|
});
|
|
62
69
|
addGeneratorMetadata(tree, fullyQualifiedName, SMITHY_PROJECT_GENERATOR_INFO, {
|
|
63
|
-
|
|
70
|
+
smithyType: type,
|
|
71
|
+
namespace,
|
|
72
|
+
...type === 'service' ? {
|
|
73
|
+
apiName: options.name
|
|
74
|
+
} : {}
|
|
64
75
|
});
|
|
65
76
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
66
77
|
SMITHY_PROJECT_GENERATOR_INFO
|
|
@@ -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 type Tree,\n} from '@nx/devkit';\nimport { getTsLibDetails } from '../../ts/lib/generator';\nimport { resolveContainers } from '../../utils/containers';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { 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 { SmithyProjectGeneratorSchema } from './schema';\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);\n const containers = await resolveContainers(tree, 'inherit');\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 `${containers} build -f {projectRoot}/build.Dockerfile --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(tree
|
|
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 { formatFilesInSubtree } from '../../utils/format';\nimport { 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 { SmithyProjectGeneratorSchema } from './schema';\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);\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 },\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","formatFilesInSubtree","FsCommands","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","getNpmScope","addGeneratorMetadata","getGeneratorInfo","projectExists","SMITHY_PROJECT_GENERATOR_INFO","filename","smithyProjectGenerator","tree","options","cmd","containers","type","fullyQualifiedName","dir","name","root","sourceRoot","projectType","targets","build","dependsOn","compile","cache","outputs","executor","commands","rm","mkdir","parallel","cwd","serviceName","serviceNameClassName","serviceNameKebabCase","scope","namespace","replace","dirname","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,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,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;AAGxB,OAAO,MAAMC,gCAAiDF,iBAC5D,YAAYG,QAAQ,EACpB;AAEF,OAAO,MAAMC,yBAAyB,OACpCC,MACAC;IAEA,MAAMC,MAAM,IAAId,WAAWY;IAC3B,MAAMG,aAAa,MAAMjB,kBAAkBc,MAAM;IACjD,MAAMI,OAAOH,QAAQG,IAAI,IAAI;IAE7B,sBAAsB;IACtB,MAAM,EAAEC,kBAAkB,EAAEC,GAAG,EAAE,GAAGrB,gBAAgBe,MAAMC;IAE1D,IAAI,CAACL,cAAcI,MAAMK,qBAAqB;QAC5CxB,wBAAwBmB,MAAMK,oBAAoB;YAChDE,MAAMF;YACNG,MAAMF;YACNG,YAAY1B,kBAAkBuB,KAAK;YACnCI,aAAa;YACbC,SAAS;gBACPC,OAAO;oBACLC,WAAW;wBAAC;qBAAU;gBACxB;gBACAC,SAAS;oBACPC,OAAO;oBACPC,SAAS;wBAAC;qBAA2C;oBACrDC,UAAU;oBACVhB,SAAS;wBACPiB,UAAU;4BACRhB,IAAIiB,EAAE,CAAC;4BACPjB,IAAIkB,KAAK,CAAC;4BACV,kEAAkE;4BAClE,kEAAkE;4BAClE,2DAA2D;4BAC3D,GAAGjB,WAAW,oJAAoJ,CAAC;yBACpK;wBACDkB,UAAU;wBACVC,KAAK;oBACP;gBACF;YACF;QACF;IACF;IAEA,MAAMC,cAActB,QAAQsB,WAAW,IAAItB,QAAQM,IAAI;IACvD,MAAMiB,uBAAuBjC,YAAYgC;IACzC,MAAME,uBAAuBjC,YAAY+B;IACzC,MAAMG,QAAQjC,YAAYO;IAC1B,MAAM2B,YAAY1B,QAAQ0B,SAAS,IAAInC,YAAYkC,OAAOE,OAAO,CAAC,MAAM;IAExE9C,cACEkB,MACAjB,kBAAkB,YAAY8C,OAAO,EAAE,SAASzB,OAChDE,KACA;QACEqB;QACAH;QACAC;QACAC;IACF,GACA;QACE,iEAAiE;QACjEI,mBAAmB9C,kBAAkB+C,YAAY;IACnD;IAGFrC,qBACEM,MACAK,oBACAR,+BACA;QACEmC,YAAY5B;QACZuB;QACA,GAAIvB,SAAS,YAAY;YAAE6B,SAAShC,QAAQM,IAAI;QAAC,IAAI,CAAC,CAAC;IACzD;IAGF,MAAMjB,gCAAgCU,MAAM;QAACH;KAA8B;IAE3E,MAAMV,qBAAqBa;IAC3B,OAAO,IACLX,oBAAoBW,MAAMC,QAAQiC,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAepC,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/project/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface SmithyProjectGeneratorSchema {\n name: string;\n serviceName?: string;\n namespace?: string;\n directory?: string;\n subDirectory?: string;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/project/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface SmithyProjectGeneratorSchema {\n name: string;\n type?: 'service' | 'shapes';\n serviceName?: string;\n namespace?: string;\n directory?: string;\n subDirectory?: string;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,WAQC"}
|
|
@@ -15,9 +15,31 @@
|
|
|
15
15
|
"x-priority": "important",
|
|
16
16
|
"x-prompt": "What would you like to call your Smithy project?"
|
|
17
17
|
},
|
|
18
|
+
"type": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The type of Smithy project to create. Choose between service (a model with a service shape, ready for an implementation) and shapes (a shape library of reusable shapes, shared between multiple Smithy projects).",
|
|
21
|
+
"default": "service",
|
|
22
|
+
"enum": ["service", "shapes"],
|
|
23
|
+
"x-priority": "important",
|
|
24
|
+
"x-prompt": {
|
|
25
|
+
"message": "What type of Smithy project would you like to create?",
|
|
26
|
+
"type": "list",
|
|
27
|
+
"items": [
|
|
28
|
+
{
|
|
29
|
+
"value": "service",
|
|
30
|
+
"label": "service (a model which defines a service and its operations)"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"value": "shapes",
|
|
34
|
+
"label": "shapes (a library of reusable shapes, shared between Smithy projects)"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"default": "service"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
18
40
|
"serviceName": {
|
|
19
41
|
"type": "string",
|
|
20
|
-
"description": "The name of your Smithy service. Uses the supplied name by default.",
|
|
42
|
+
"description": "The name of your Smithy service. Uses the supplied name by default. Not applicable to shape libraries.",
|
|
21
43
|
"x-prompt": "What name would you like your Smithy Service to have? i.e: MyService"
|
|
22
44
|
},
|
|
23
45
|
"namespace": {
|
|
@@ -1743,6 +1743,8 @@ exports[`tsSmithyApiGenerator > should generate smithy ts api with default optio
|
|
|
1743
1743
|
"projectType": "library",
|
|
1744
1744
|
"metadata": {
|
|
1745
1745
|
"generator": "smithy#project",
|
|
1746
|
+
"smithyType": "service",
|
|
1747
|
+
"namespace": "proj",
|
|
1746
1748
|
"apiName": "test-api-model",
|
|
1747
1749
|
"backendProject": "@proj/test-api"
|
|
1748
1750
|
},
|
|
@@ -1758,7 +1760,7 @@ exports[`tsSmithyApiGenerator > should generate smithy ts api with default optio
|
|
|
1758
1760
|
"commands": [
|
|
1759
1761
|
"rimraf dist/{projectRoot}/build",
|
|
1760
1762
|
"make-dir dist/{projectRoot}/build",
|
|
1761
|
-
"docker build -f {projectRoot}/build.Dockerfile --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
1763
|
+
"docker build -f {projectRoot}/build.Dockerfile --build-context workspace=. --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}"
|
|
1762
1764
|
],
|
|
1763
1765
|
"parallel": false,
|
|
1764
1766
|
"cwd": "{workspaceRoot}"
|
|
@@ -1940,6 +1940,10 @@ export class StaticWebsite extends Construct {
|
|
|
1940
1940
|
resourceArn: bucket.bucketArn,
|
|
1941
1941
|
},
|
|
1942
1942
|
);
|
|
1943
|
+
const bucketPolicy = (bucket as Bucket).policy;
|
|
1944
|
+
if (bucketPolicy) {
|
|
1945
|
+
source.node.addDependency(bucketPolicy);
|
|
1946
|
+
}
|
|
1943
1947
|
const destination: CfnDeliveryDestination = new CfnDeliveryDestination(
|
|
1944
1948
|
this,
|
|
1945
1949
|
\`\${id}AccessLogsDestination\`,
|
|
@@ -3750,6 +3754,10 @@ export class StaticWebsite extends Construct {
|
|
|
3750
3754
|
resourceArn: bucket.bucketArn,
|
|
3751
3755
|
},
|
|
3752
3756
|
);
|
|
3757
|
+
const bucketPolicy = (bucket as Bucket).policy;
|
|
3758
|
+
if (bucketPolicy) {
|
|
3759
|
+
source.node.addDependency(bucketPolicy);
|
|
3760
|
+
}
|
|
3753
3761
|
const destination: CfnDeliveryDestination = new CfnDeliveryDestination(
|
|
3754
3762
|
this,
|
|
3755
3763
|
\`\${id}AccessLogsDestination\`,
|
|
@@ -5420,6 +5428,10 @@ export class StaticWebsite extends Construct {
|
|
|
5420
5428
|
resourceArn: bucket.bucketArn,
|
|
5421
5429
|
},
|
|
5422
5430
|
);
|
|
5431
|
+
const bucketPolicy = (bucket as Bucket).policy;
|
|
5432
|
+
if (bucketPolicy) {
|
|
5433
|
+
source.node.addDependency(bucketPolicy);
|
|
5434
|
+
}
|
|
5423
5435
|
const destination: CfnDeliveryDestination = new CfnDeliveryDestination(
|
|
5424
5436
|
this,
|
|
5425
5437
|
\`\${id}AccessLogsDestination\`,
|
|
@@ -324,6 +324,10 @@ export class StaticWebsite extends Construct {
|
|
|
324
324
|
resourceArn: bucket.bucketArn,
|
|
325
325
|
},
|
|
326
326
|
);
|
|
327
|
+
const bucketPolicy = (bucket as Bucket).policy;
|
|
328
|
+
if (bucketPolicy) {
|
|
329
|
+
source.node.addDependency(bucketPolicy);
|
|
330
|
+
}
|
|
327
331
|
const destination: CfnDeliveryDestination = new CfnDeliveryDestination(
|
|
328
332
|
this,
|
|
329
333
|
`${id}AccessLogsDestination`,
|
/package/src/smithy/project/files/{build.Dockerfile.template → service/build.Dockerfile.template}
RENAMED
|
File without changes
|
/package/src/smithy/project/files/{smithy-build.json.template → service/smithy-build.json.template}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|