@johnlwin-test/create-repro 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,175 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # Create minimal reproduction for AWS SDKs
2
+
3
+ [![Apache 2 licensed][apache-badge]][apache-url]
4
+
5
+ [apache-badge]: https://img.shields.io/badge/license-APACHE2-blue.svg
6
+ [apache-url]: https://github.com/awslabs/create-aws-sdk-repro/blob/main/LICENSE
7
+
8
+ `@aws-sdk/repro` is a CLI tool that generates ready-to-run project environments for AWS SDK for JavaScript v3. It supports Node.js, Browser (Vite + Cognito), and React Native environments across AWS services with autocomplete, operation validation, and typo detection.
9
+
10
+ ## Prerequisites
11
+
12
+ - [Node.js](https://nodejs.org/)
13
+ - AWS credentials configured on your machine (for Node.js projects)
14
+ - See [Configuring the AWS SDK for JavaScript](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/configuring-the-jssdk.html)
15
+
16
+ ## Installation & Usage
17
+
18
+ ```bash
19
+ npx @aws-sdk/repro
20
+ ```
21
+
22
+ ## Interactive Prompts
23
+
24
+ The CLI guides you through the following steps:
25
+
26
+ ```console
27
+ AWS SDK Reproduction Project Generator
28
+
29
+ ? Select JavaScript environment: (Node.js / Browser / React Native)
30
+ ? Enter project name: aws-sdk-repro-a1b2c3d4
31
+ ? Select or search for AWS service: (autocomplete)
32
+
33
+ Fetching available operations for S3...
34
+ Found 128 operations
35
+
36
+ ? Select or search for operation (kebab-case): list-buckets
37
+ ? Select or enter AWS region: us-east-1 - US East (N. Virginia)
38
+
39
+ Successfully created JS project at:
40
+ /path/to/aws-sdk-repro-a1b2c3d4
41
+
42
+ To get started:
43
+ cd aws-sdk-repro-a1b2c3d4
44
+ npm install
45
+ npm start
46
+ ```
47
+
48
+ ## Environments
49
+
50
+ ### Node.js
51
+
52
+ Generates a project using the default AWS credential chain. Run with `npm start`.
53
+
54
+ ### Browser
55
+
56
+ Generates a Vite-based project with Amazon Cognito Identity Pool for browser-safe credentials. A `COGNITO_SETUP.md` guide is included with setup instructions. Run with `npm start` (opens browser via Vite dev server).
57
+
58
+ ### React Native
59
+
60
+ Generates a full React Native project via `@react-native-community/cli` (pinned to RN 0.76.6 for Xcode 15 compatibility). Includes required polyfills (`react-native-get-random-values`, `react-native-url-polyfill`, `web-streams-polyfill`) and Cognito authentication.
61
+
62
+ ## Features
63
+
64
+ - **Service autocomplete**: Search across `@aws-sdk/client-*` packages with fuzzy matching
65
+ - **Typo detection**: Levenshtein distance (max 2 edits) suggests corrections for mistyped services and regions
66
+ - **Dynamic operation discovery**: Temporarily installs the selected SDK package to discover available operations and extract the correct client name (e.g., `DynamoDBClient` not `DynamodbClient`)
67
+ - **Region validation**: AWS regions with display names, format validation, and underscore-to-hyphen correction
68
+ - **Kebab-case input**: Operations entered as `list-buckets` are automatically converted to `ListBucketsCommand`
69
+
70
+ ## Testing Locally
71
+
72
+ To test the CLI end-to-end:
73
+
74
+ ```bash
75
+ # Run the CLI and generate a project
76
+ node src/cli.js
77
+
78
+ # Navigate to the generated project
79
+ cd <your-project-name>
80
+
81
+ # Install dependencies and run
82
+ npm install
83
+ npm start
84
+ ```
85
+
86
+ For Node.js projects, ensure your AWS credentials are configured (`aws configure` or environment variables). For Browser and React Native projects, follow the generated `COGNITO_SETUP.md` to configure an Identity Pool before running.
87
+
88
+ ### Quick smoke test
89
+
90
+ ```bash
91
+ # Generate a Node.js project for S3 ListBuckets
92
+ node src/cli.js
93
+ # Select: Node.js → any project name → @aws-sdk/client-s3 → list-buckets → us-east-1
94
+
95
+ # Verify the generated project runs
96
+ cd <project-name>
97
+ npm install
98
+ npm start
99
+ ```
100
+
101
+ Operations like `ListBuckets`, `DescribeInstances`, and `ListTables` work with an empty input object, so the generated project runs out of the box. For operations that require parameters, modify the `input` object in the generated `index.js`:
102
+
103
+ ```javascript
104
+ const input = {
105
+ // Add your input parameters here
106
+ // IDE autocomplete will show available fields since types are already imported
107
+ };
108
+ ```
109
+
110
+ ## Security
111
+
112
+ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
113
+
114
+ ## License
115
+
116
+ This project is licensed under the Apache-2.0 License.
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@johnlwin-test/create-repro",
3
+ "version": "0.1.0",
4
+ "description": "Create reproducible env for AWS SDK",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "files": [
8
+ "src/"
9
+ ],
10
+ "bin": {
11
+ "aws-sdk-repro": "./src/cli.js"
12
+ },
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1",
15
+ "release": "changeset publish"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/awslabs/create-aws-sdk-repro.git"
20
+ },
21
+ "author": "AWS SDK JavaScript Team",
22
+ "license": "Apache-2.0",
23
+ "bugs": {
24
+ "url": "https://github.com/awslabs/create-aws-sdk-repro/issues"
25
+ },
26
+ "homepage": "https://github.com/awslabs/create-aws-sdk-repro#readme",
27
+ "dependencies": {
28
+ "prompts": "^2.4.2"
29
+ },
30
+ "devDependencies": {
31
+ "@changesets/cli": "^2.29.4"
32
+ }
33
+ }
package/src/cli.js ADDED
@@ -0,0 +1,308 @@
1
+ #!/usr/bin/env node
2
+
3
+ import prompts from "prompts";
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import { fileURLToPath } from "url";
7
+ import { generateBrowserProject } from "./sdks/javascript/environments/browser/generate.js";
8
+ import { generateNodeProject } from "./sdks/javascript/environments/node/generate.js";
9
+ import { generateReactNativeProject } from "./sdks/javascript/environments/react-native/generate.js";
10
+ import { generateJavaProject } from "./sdks/java/generate.js";
11
+ import { AWS_SERVICES, isValidService, getServiceSuggestions, getServiceDisplayName, getServiceErrorMessage, findSimilarServices } from "./services.js";
12
+ import {
13
+ getServiceOperations,
14
+ isValidOperation,
15
+ getOperationSuggestions,
16
+ getOperationErrorMessage
17
+ } from "./operations.js";
18
+ import { randomUUID } from "crypto";
19
+ import {
20
+ AWS_REGIONS,
21
+ isValidRegion,
22
+ getRegionSuggestions,
23
+ getRegionDisplayName,
24
+ getRegionErrorMessage,
25
+ standardRegionToJava
26
+ } from "./regions.js";
27
+
28
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
29
+
30
+ // Utility functions for operation name conversion
31
+ function kebabToPascalCase(str) {
32
+ return str
33
+ .split("-")
34
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
35
+ .join("");
36
+ }
37
+
38
+ function kebabToCamelCase(str) {
39
+ const pascal = kebabToPascalCase(str);
40
+ return pascal.charAt(0).toLowerCase() + pascal.slice(1);
41
+ }
42
+
43
+ // Service lists for different SDKs
44
+ export const JS_SERVICES = AWS_SERVICES.map(service => ({
45
+ title: getServiceDisplayName(service),
46
+ value: service
47
+ }));
48
+
49
+ const JAVA_SERVICES = [
50
+ { title: "S3", value: "s3" },
51
+ { title: "DynamoDB", value: "dynamodb" },
52
+ { title: "EC2", value: "ec2" },
53
+ { title: "IAM", value: "iam" },
54
+ { title: "Lambda", value: "lambda" },
55
+ ];
56
+
57
+ async function main() {
58
+ console.log("AWS SDK Reproduction Project Generator\n");
59
+
60
+ // Step 1: SDK Selection
61
+ const sdkAnswer = { sdk: "js" }; // Default to JavaScript only
62
+
63
+ // Uncomment below to re-enable Java option:
64
+ // const sdkAnswer = await prompts({
65
+ // type: "select",
66
+ // name: "sdk",
67
+ // message: "Select AWS SDK language:",
68
+ // choices: [
69
+ // { title: "JavaScript", value: "js" },
70
+ // { title: "Java", value: "java" },
71
+ // ],
72
+ // initial: 0,
73
+ // }, { onCancel: () => process.exit(0) });
74
+ // if (!sdkAnswer.sdk) process.exit(0);
75
+
76
+ // Step 2: Environment
77
+ const environmentAnswer = await prompts({
78
+ type: "select",
79
+ name: "environment",
80
+ message: "Select JavaScript environment:",
81
+ choices: [
82
+ { title: "Node.js", value: "node" },
83
+ { title: "Browser", value: "browser" },
84
+ { title: "React Native", value: "react-native" },
85
+ ],
86
+ }, { onCancel: () => process.exit(0) });
87
+
88
+ // Step 3: Project Name
89
+ const projectAnswer = await prompts({
90
+ type: "text",
91
+ name: "projectName",
92
+ message: "Enter project name:",
93
+ validate: (value) => !!value.trim() || "Project name is required",
94
+ initial: `aws-sdk-repro-${randomUUID().split('-')[0]}`,
95
+ }, { onCancel: () => process.exit(0) });
96
+
97
+ // Step 4: Service Selection
98
+ const serviceAnswer = await prompts({
99
+ type: "autocomplete",
100
+ name: "service",
101
+ message: "Select or search for AWS service:",
102
+ choices: JS_SERVICES,
103
+ suggest: (input, choices) => {
104
+ const suggestions = getServiceSuggestions(input);
105
+ return choices.filter(choice => suggestions.includes(choice.value));
106
+ },
107
+ validate: (value) => {
108
+ if (!value) return "Service is required";
109
+ // Basic format validation only - actual package existence checked during operation fetch
110
+ if (!value.startsWith("@aws-sdk/client-")) {
111
+ return 'Service must start with "@aws-sdk/client-"';
112
+ }
113
+ return true;
114
+ },
115
+ initial: 0,
116
+ }, { onCancel: () => process.exit(0) });
117
+
118
+ // Step 5: Fetch available operations for the selected service
119
+ console.log(`\nFetching available operations for ${getServiceDisplayName(serviceAnswer.service)}...`);
120
+ const { operations: availableOperations, clientName: actualClientName, error } = await getServiceOperations(serviceAnswer.service);
121
+
122
+ if (error) {
123
+ console.error(`\nError: Could not fetch operations for ${serviceAnswer.service}`);
124
+ console.error(`Reason: ${error}`);
125
+
126
+ // Check if it's a known service and suggest alternatives
127
+ if (!isValidService(serviceAnswer.service)) {
128
+ const similar = findSimilarServices(serviceAnswer.service);
129
+ if (similar.length > 0) {
130
+ const suggestions = similar.map(s => getServiceDisplayName(s)).join(", ");
131
+ console.error(`\nDid you mean one of these? ${suggestions}`);
132
+ }
133
+ }
134
+
135
+ console.error('\nPlease verify the service package exists on npm:');
136
+ console.error(`https://www.npmjs.com/package/${serviceAnswer.service}`);
137
+ process.exit(1);
138
+ }
139
+
140
+ if (availableOperations.length > 0) {
141
+ console.log(`Found ${availableOperations.length} operations\n`);
142
+ } else {
143
+ console.log(`Could not fetch operations list. Format validation only.\n`);
144
+ }
145
+
146
+ // Step 6: Operation Selection
147
+ const operationAnswer = await prompts({
148
+ type: availableOperations.length > 0 ? "autocomplete" : "text",
149
+ name: "operation",
150
+ message: availableOperations.length > 0
151
+ ? "Select or search for operation (kebab-case):"
152
+ : "Enter AWS service operation (kebab-case, e.g., list-buckets):",
153
+ choices: availableOperations.length > 0
154
+ ? availableOperations.map(op => ({ title: op, value: op }))
155
+ : undefined,
156
+ suggest: availableOperations.length > 0
157
+ ? (input, choices) => {
158
+ const suggestions = getOperationSuggestions(input, availableOperations);
159
+ return choices.filter(choice => suggestions.includes(choice.value));
160
+ }
161
+ : undefined,
162
+ validate: (value) => {
163
+ if (!value || !value.trim()) return "Operation is required";
164
+ if (!isValidOperation(value, availableOperations)) {
165
+ return getOperationErrorMessage(value, availableOperations);
166
+ }
167
+ return true;
168
+ },
169
+ initial: availableOperations.length > 0 ? 0 : "list-buckets",
170
+ }, { onCancel: () => process.exit(0) });
171
+
172
+ // Step 7: Region
173
+ const regionAnswer = await prompts({
174
+ type: "autocomplete",
175
+ name: "region",
176
+ message: "Select or enter AWS region:",
177
+ choices: AWS_REGIONS.map(region => ({
178
+ title: `${region} - ${getRegionDisplayName(region)}`,
179
+ value: region
180
+ })),
181
+ suggest: (input, choices) => {
182
+ const suggestions = getRegionSuggestions(input);
183
+ return choices.filter(choice => suggestions.includes(choice.value));
184
+ },
185
+ validate: (value) => {
186
+ if (!value || !value.trim()) return "Region is required";
187
+ if (!isValidRegion(value)) {
188
+ return getRegionErrorMessage(value);
189
+ }
190
+ return true;
191
+ },
192
+ initial: "us-west-1",
193
+ }, { onCancel: () => process.exit(0) });
194
+
195
+ // Combine all answers
196
+ const answers = {
197
+ ...sdkAnswer,
198
+ ...environmentAnswer,
199
+ ...projectAnswer,
200
+ ...serviceAnswer,
201
+ ...operationAnswer,
202
+ ...regionAnswer,
203
+ clientName: actualClientName, // Actual client import from SDK package
204
+ };
205
+
206
+ const projectDir = path.join(process.cwd(), answers.projectName);
207
+
208
+ try {
209
+ if (fs.existsSync(projectDir)) {
210
+ console.error(`Error: Directory ${projectDir} already exists`);
211
+ process.exit(1);
212
+ }
213
+
214
+ // React Native creates its own directory, so skip creation for it
215
+ if (answers.environment !== "react-native") {
216
+ fs.mkdirSync(projectDir, { recursive: true });
217
+ }
218
+
219
+ // JavaScript project generation
220
+ await handleJavascriptProject(answers, projectDir);
221
+
222
+ // Java support preserved
223
+ // switch (answers.sdk) {
224
+ // case "js":
225
+ // await handleJavascriptProject(answers, projectDir);
226
+ // break;
227
+ // case "java":
228
+ // await handleJavaProject(answers, projectDir);
229
+ // break;
230
+ // default:
231
+ // throw new Error(`Unsupported SDK: ${answers.sdk}`);
232
+ // }
233
+
234
+ showSuccessMessage(answers, projectDir);
235
+ } catch (error) {
236
+ console.error(`Error creating project: ${error.message}`);
237
+ cleanupOnError(projectDir);
238
+ process.exit(1);
239
+ }
240
+ }
241
+
242
+ async function handleJavascriptProject(answers, projectDir) {
243
+ // Convert kebab-case operation to PascalCase + Command suffix for JS SDK
244
+ const operationPascal = kebabToPascalCase(answers.operation);
245
+ answers.operationCommand = `${operationPascal}Command`;
246
+
247
+ switch (answers.environment) {
248
+ case "node":
249
+ await generateNodeProject(answers, projectDir);
250
+ break;
251
+ case "browser":
252
+ await generateBrowserProject(answers, projectDir);
253
+ break;
254
+ case "react-native":
255
+ await generateReactNativeProject(answers, projectDir);
256
+ break;
257
+ default:
258
+ throw new Error(`Invalid environment: ${answers.environment}`);
259
+ }
260
+ }
261
+
262
+ async function handleJavaProject(answers, projectDir) {
263
+ // Convert service name to Java format
264
+ answers.service = answers.service
265
+ .replace(/@aws-sdk\/client-/i, "")
266
+ .toLowerCase();
267
+ // Convert kebab-case operation to camelCase for Java
268
+ answers.operation = kebabToCamelCase(answers.operation);
269
+ // Convert standard region format to Java format (us-west-1 -> US_WEST_1)
270
+ answers.region = standardRegionToJava(answers.region);
271
+ await generateJavaProject(answers, projectDir);
272
+ }
273
+
274
+ function showSuccessMessage(answers, projectDir) {
275
+ const instructions = {
276
+ js: `
277
+ To get started:
278
+ cd ${answers.projectName}
279
+ npm install
280
+ npm start
281
+ `,
282
+ java: `
283
+ To build and run:
284
+ cd ${answers.projectName}
285
+ mvn clean package
286
+ java -jar target/*.jar
287
+
288
+ First-time setup:
289
+ chmod +x mvnw # Make Maven wrapper executable
290
+ `,
291
+ };
292
+
293
+ console.log(`
294
+ Successfully created ${answers.sdk.toUpperCase()} project at:
295
+ ${path.resolve(projectDir)}
296
+ ${instructions[answers.sdk]}`);
297
+ }
298
+
299
+ function cleanupOnError(projectDir) {
300
+ if (fs.existsSync(projectDir)) {
301
+ fs.rmSync(projectDir, { recursive: true, force: true });
302
+ }
303
+ }
304
+
305
+ main().catch((error) => {
306
+ console.error("Unexpected error:", error);
307
+ process.exit(1);
308
+ });