├── .github └── workflows │ ├── main.yml │ └── release.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.txt ├── LICENSE.md ├── README.md ├── scripts └── generate-contributors-list.sh └── vscode-extension ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── .prettierignore ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── LICENSE.md ├── README.md ├── docs ├── .nojekyll ├── assets │ ├── highlight.css │ ├── icons.js │ ├── icons.svg │ ├── main.js │ ├── navigation.js │ ├── search.js │ └── style.css ├── classes │ └── panels_MainPanel.MainPanel.html ├── functions │ ├── commands_SamCommands.buildProject.html │ ├── commands_SamCommands.checkPrerequisites.html │ ├── commands_SamCommands.deleteStack.html │ ├── commands_SamCommands.deployProject.html │ ├── commands_SamCommands.getEvents.html │ ├── commands_SamCommands.getFunctions.html │ ├── commands_SamCommands.getReady.html │ ├── commands_SamCommands.initializeProject.html │ ├── commands_SamCommands.localInvoke.html │ ├── commands_SamCommands.remoteInvoke.html │ ├── commands_SamCommands.subscribeToConsole.html │ ├── extension.activate.html │ ├── utilities_getNonce.getNonce.html │ └── utilities_getUri.getUri.html ├── index.html └── modules │ ├── commands_SamCommands.html │ ├── extension.html │ ├── panels_MainPanel.html │ ├── utilities_getNonce.html │ └── utilities_getUri.html ├── media ├── logo.png └── swift.svg ├── package-lock.json ├── package.json ├── packages └── core-lib │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .npmignore │ ├── .nvmrc │ ├── README.md │ ├── docs │ ├── .nojekyll │ ├── assets │ │ ├── highlight.css │ │ ├── icons.js │ │ ├── icons.svg │ │ ├── main.js │ │ ├── navigation.js │ │ ├── search.js │ │ └── style.css │ ├── functions │ │ ├── buildProject.html │ │ ├── checkAWSCLI.html │ │ ├── checkAllRequirements.html │ │ ├── checkDocker.html │ │ ├── checkSAMCLI.html │ │ ├── deleteStack.html │ │ ├── deployProject.html │ │ ├── getEvents.html │ │ ├── getFunctions.html │ │ ├── getRegions.html │ │ ├── getTemplates.html │ │ ├── initializeProject.html │ │ ├── localInvoke.html │ │ ├── remoteInvoke.html │ │ ├── subscribeToStderr.html │ │ ├── subscribeToStdout.html │ │ ├── unsubscribeFromStderr.html │ │ └── unsubscribeFromStdout.html │ ├── index.html │ └── modules.html │ ├── jest.config.js │ ├── package.json │ ├── src │ ├── __tests__ │ │ ├── index.test.ts │ │ ├── integration │ │ │ └── integration.test.ts │ │ └── unit │ │ │ ├── checkRequirements.test.ts │ │ │ ├── initializeSamProject.test.ts │ │ │ └── templateService.test.ts │ ├── config │ │ └── config.ts │ ├── errors │ │ └── errors.ts │ ├── facade.ts │ ├── index.ts │ ├── logger.ts │ ├── sam │ │ └── sam.ts │ ├── services │ │ └── templateServices.ts │ └── utils │ │ ├── cleanUp.ts │ │ ├── commandRunner.ts │ │ ├── error-base.ts │ │ ├── initUtils.ts │ │ └── types.ts │ └── tsconfig.json ├── release.config.js ├── src ├── commands │ └── Commands.ts ├── extension.ts ├── panels │ └── MainPanel.ts └── utilities │ ├── getNonce.ts │ └── getUri.ts ├── tsconfig.json └── webview-ui ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── docs ├── .nojekyll ├── assets │ ├── highlight.css │ ├── icons.js │ ├── icons.svg │ ├── main.js │ ├── navigation.js │ ├── search.js │ └── style.css ├── functions │ ├── App.default.html │ ├── api_markdownApi.fetchMarkdownFile.html │ ├── components_Error.default.html │ ├── components_EventsDropdown.default.html │ ├── components_FunctionsDropdown.default.html │ ├── components_accordion_Accordion.default.html │ ├── components_buildProject_BuildProject.default.html │ ├── components_configuration_Configuration.default.html │ ├── components_console_Console.default.html │ ├── components_deleteConfirmation_DeleteConfirmation.default.html │ ├── components_deployProject_DeployProject.default.html │ ├── components_initialize_Initialize.default.html │ ├── components_localInvoke_LocalInvoke.default.html │ ├── components_navbar_Dropdown.default.html │ ├── components_navbar_Navbar.default.html │ ├── components_prerequisites_Prerequisites.default.html │ ├── components_remoteInvoke_RemoteInvoke.default.html │ ├── components_tooltip_Tooltip.default.html │ ├── context_ConfigurationProvider.ConfigurationProvider.html │ ├── context_ErrorProvider.ErrorProvider.html │ └── context_ErrorProvider.useError.html ├── index.html ├── modules │ ├── App.html │ ├── api_markdownApi.html │ ├── components_Error.html │ ├── components_EventsDropdown.html │ ├── components_FunctionsDropdown.html │ ├── components_accordion_Accordion.html │ ├── components_buildProject_BuildProject.html │ ├── components_configuration_Configuration.html │ ├── components_console_Console.html │ ├── components_deleteConfirmation_DeleteConfirmation.html │ ├── components_deployProject_DeployProject.html │ ├── components_initialize_Initialize.html │ ├── components_localInvoke_LocalInvoke.html │ ├── components_navbar_Dropdown.html │ ├── components_navbar_Navbar.html │ ├── components_prerequisites_Prerequisites.html │ ├── components_remoteInvoke_RemoteInvoke.html │ ├── components_tooltip_Tooltip.html │ ├── context_ConfigurationProvider.html │ ├── context_ErrorProvider.html │ ├── index.html │ ├── utilities_vscode.html │ └── vite_env.html └── variables │ ├── context_ConfigurationProvider.ConfigurationContext.html │ └── utilities_vscode.vscode.html ├── index.html ├── package-lock.json ├── package.json ├── src ├── App.css ├── App.tsx ├── api │ └── markdownApi.ts ├── components │ ├── Error.css │ ├── Error.tsx │ ├── EventsDropdown.tsx │ ├── FunctionsDropdown.tsx │ ├── accordion │ │ ├── Accordion.css │ │ └── Accordion.tsx │ ├── buildProject │ │ └── BuildProject.tsx │ ├── configuration │ │ ├── Configuration.css │ │ └── Configuration.tsx │ ├── console │ │ ├── Console.css │ │ └── Console.tsx │ ├── deleteConfirmation │ │ ├── DeleteConfirmation.css │ │ └── DeleteConfirmation.tsx │ ├── deployProject │ │ └── DeployProject.tsx │ ├── initialize │ │ ├── Initialize.css │ │ └── Initialize.tsx │ ├── localInvoke │ │ └── LocalInvoke.tsx │ ├── navbar │ │ ├── Dropdown.tsx │ │ ├── Navbar.css │ │ └── Navbar.tsx │ ├── prerequisites │ │ ├── Prerequisites.css │ │ └── Prerequisites.tsx │ ├── remoteInvoke │ │ └── RemoteInvoke.tsx │ └── tooltip │ │ ├── Tooltip.css │ │ └── Tooltip.tsx ├── context │ ├── ConfigurationProvider.tsx │ └── ErrorProvider.tsx ├── i18n │ └── en │ │ └── global.json ├── index.tsx ├── utilities │ └── vscode.ts └── vite-env.d.ts ├── tsconfig.json └── vite.config.ts /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Unit test core-lib 2 | on: 3 | push: 4 | branches: 5 | - "**" 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | defaults: 11 | run: 12 | working-directory: vscode-extension 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - uses: actions/setup-node@v4 17 | with: 18 | node-version: latest 19 | cache: "npm" 20 | cache-dependency-path: "vscode-extension/package-lock.json" 21 | 22 | - name: Install dependencies 23 | run: npm run install:all 24 | 25 | - name: Build all 26 | run: npm run build:all 27 | 28 | # remove because these are not real unit tests, they requires AWS CLI, SAM, and docker to be installed 29 | # - name: Run unit tests 30 | # run: npm run test:unit -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Semantic Release 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | release: 8 | permissions: 9 | contents: write 10 | issues: write 11 | pull-requests: write 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout Repository 15 | uses: actions/checkout@v4 16 | 17 | - name: Setup Node.js 18 | uses: actions/setup-node@v4 19 | with: 20 | node-version: latest 21 | cache: "npm" 22 | cache-dependency-path: "vscode-extension/package-lock.json" 23 | 24 | - name: Install Dependencies 25 | run: npm install 26 | working-directory: vscode-extension 27 | 28 | - name: Install VSCE 29 | run: npm install -g vsce 30 | 31 | - name: Semantic Release 32 | run: npx semantic-release 33 | env: 34 | VSCE_PAT: ${{ secrets.VSCE_TOKEN }} 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | working-directory: vscode-extension 37 | 38 | - name: Publish extension 39 | run: vsce package && vsce publish 40 | env: 41 | VSCE_PAT: ${{ secrets.VSCE_TOKEN }} 42 | working-directory: vscode-extension 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE.txt) file for our project's licensing. We will ask you to confirm the licensing of your contribution. -------------------------------------------------------------------------------- /CONTRIBUTORS.txt: -------------------------------------------------------------------------------- 1 | For the purpose of tracking copyright, this is the list of individuals and 2 | organizations who have contributed source code to SwiftOpenAPIGenerator. 3 | 4 | For employees of an organization/company where the copyright of work done 5 | by employees of that company is held by the company itself, only the company 6 | needs to be listed here. 7 | 8 | ## COPYRIGHT HOLDERS 9 | 10 | - Apple Inc. (all contributors with '@apple.com') 11 | 12 | ### Contributors 13 | 14 | - Marwane Koutar 15 | 16 | **Updating this list** 17 | 18 | Please do not edit this file manually. It is generated using `bash ./scripts/generate-contributors-list.sh`. If a name is misspelled or appearing multiple times: add an entry in `./.mailmap` 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Logo 2 | 3 | # vscode-aws-lambda-swift 4 | 5 | vscode-aws-lambda-swift is a Visual Studio Code extension that simplifies the process of creating, testing, and deploying AWS Lambda functions using Swift. With this extension, you can quickly set up Lambda projects, configure deployment options, and test your functions locally or remotely. 6 | 7 | ## Features 8 | 9 | - **Project Initialization:** Easily create new AWS Lambda projects with customizable settings such as project name, region, and deployment path. 10 | - **Template Selection:** Choose from a variety of templates to kickstart your Lambda project, each providing additional information. 11 | - **Build & Package:** Compile your Swift code and package it into a ZIP archive for deployment to AWS Lambda. 12 | - **Local Testing:** Test your Lambda functions locally using predefined events or custom JSON files to simulate various input scenarios. 13 | - **Deployment:** Deploy your Lambda project to AWS with ease, specifying parameters like stack name and deployment region directly from Visual Studio Code. 14 | - **Remote Testing:** After deployment, test your functions remotely against live AWS resources, ensuring they behave as expected in the cloud environment. 15 | 16 | ## Requirements 17 | 18 | - [Docker](https://www.docker.com/): Install Docker to build and test Swift projects in a containerized environment. 19 | - [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html): Install the AWS Command Line Interface to interact with AWS services. 20 | - [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html): Install the AWS Serverless Application Model CLI for building and deploying serverless applications. 21 | 22 | ## Getting Started 23 | 24 | 1. **Install the Extension:** Search for `VSCode AWS Lambda Swift` in the Visual Studio Code Extensions Marketplace and install it. Or click [here](https://marketplace.visualstudio.com/items?itemName=MarwaneKoutar.vscode-aws-lambda-swift) to download the extension. 25 | 2. **Configure AWS Credentials:** Set up your AWS credentials using the AWS CLI by running `aws configure` in your terminal. Make sure you have the necessary permissions to create and manage Lambda functions. 26 | 3. **Start the Extension:** Open Visual Studio Code, press `Command+Shift+P` to open the command palette, and select `AWS Lambda Swift: Open AWS Lambda Swift Dashboard`. This will open the main panel of the extension. 27 | 4. **You're Ready to Go!** Start creating, testing, and deploying AWS Lambda functions using Swift with the help of this extension. 28 | 29 | ## Feedback & Contributions 30 | 31 | If you encounter any issues or have suggestions for improvement, please feel free to [submit an issue](https://github.com/MarwaneKoutar/vscode-aws-lambda-swift/issues) on GitHub. Contributions are also welcome and appreciated! 32 | 33 | ## License 34 | 35 | This project is licensed under the MIT License. See the [LICENSE](./vscode-extension/LICENSE.md) file for more information. 36 | -------------------------------------------------------------------------------- /scripts/generate-contributors-list.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ##===----------------------------------------------------------------------===## 3 | ## 4 | ## This source file is part of the Swift OpenAPI Lambda open source project 5 | ## 6 | ## Copyright (c) 2023 Amazon.com, Inc. or its affiliates 7 | ## and the Swift OpenAPI Lambda project authors 8 | ## Licensed under Apache License v2.0 9 | ## 10 | ## See LICENSE.txt for license information 11 | ## See CONTRIBUTORS.txt for the list of Swift OpenAPI Lambda project authors 12 | ## 13 | ## SPDX-License-Identifier: Apache-2.0 14 | ## 15 | ##===----------------------------------------------------------------------===## 16 | ##===----------------------------------------------------------------------===## 17 | ## 18 | ## This source file is part of the SwiftNIO open source project 19 | ## 20 | ## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors 21 | ## Licensed under Apache License v2.0 22 | ## 23 | ## See LICENSE.txt for license information 24 | ## See CONTRIBUTORS.txt for the list of SwiftNIO project authors 25 | ## 26 | ## SPDX-License-Identifier: Apache-2.0 27 | ## 28 | ##===----------------------------------------------------------------------===## 29 | 30 | set -eu 31 | here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 32 | contributors=$( cd "$here"/.. && git shortlog -es | cut -f2 | sed 's/^/- /' ) 33 | 34 | cat > "$here/../CONTRIBUTORS.txt" <<- EOF 35 | For the purpose of tracking copyright, this is the list of individuals and 36 | organizations who have contributed source code to SwiftOpenAPIGenerator. 37 | 38 | For employees of an organization/company where the copyright of work done 39 | by employees of that company is held by the company itself, only the company 40 | needs to be listed here. 41 | 42 | ## COPYRIGHT HOLDERS 43 | 44 | - Apple Inc. (all contributors with '@apple.com') 45 | 46 | ### Contributors 47 | 48 | $contributors 49 | 50 | **Updating this list** 51 | 52 | Please do not edit this file manually. It is generated using \`bash ./scripts/generate-contributors-list.sh\`. If a name is misspelled or appearing multiple times: add an entry in \`./.mailmap\` 53 | EOF -------------------------------------------------------------------------------- /vscode-extension/.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | .github/ 3 | node_modules/ -------------------------------------------------------------------------------- /vscode-extension/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "extends": [ 4 | "eslint:recommended", 5 | "plugin:@typescript-eslint/recommended", 6 | "plugin:prettier/recommended" 7 | ], 8 | "plugins": ["@typescript-eslint", "prettier"], 9 | "rules": { 10 | "prettier/prettier": "error", 11 | "semi": ["error", "always"], 12 | "quotes": ["error", "double"], 13 | "indent": ["error", 2], 14 | "comma-dangle": ["error", "always-multiline"], 15 | "no-console": "off", 16 | "no-unused-vars": "warn", 17 | "no-undef": "error", 18 | "no-extra-semi": "error", 19 | "no-unreachable": "error", 20 | "@typescript-eslint/no-explicit-any": "off" 21 | }, 22 | "env": { 23 | "node": true 24 | }, 25 | "ignorePatterns": ["webview-ui/**", "MainPanel.ts"] 26 | } 27 | -------------------------------------------------------------------------------- /vscode-extension/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/node 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 3 | 4 | ### Node ### 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | .pnpm-debug.log* 13 | 14 | # Diagnostic reports (https://nodejs.org/api/report.html) 15 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | *.pid.lock 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | *.lcov 29 | 30 | # nyc test coverage 31 | .nyc_output 32 | 33 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 34 | .grunt 35 | 36 | # Bower dependency directory (https://bower.io/) 37 | bower_components 38 | 39 | # node-waf configuration 40 | .lock-wscript 41 | 42 | # Compiled binary addons (https://nodejs.org/api/addons.html) 43 | build/Release 44 | 45 | # Dependency directories 46 | node_modules/ 47 | jspm_packages/ 48 | 49 | # Snowpack dependency directory (https://snowpack.dev/) 50 | web_modules/ 51 | 52 | # TypeScript cache 53 | *.tsbuildinfo 54 | 55 | # Optional npm cache directory 56 | .npm 57 | 58 | # Optional eslint cache 59 | .eslintcache 60 | 61 | # Optional stylelint cache 62 | .stylelintcache 63 | 64 | # Microbundle cache 65 | .rpt2_cache/ 66 | .rts2_cache_cjs/ 67 | .rts2_cache_es/ 68 | .rts2_cache_umd/ 69 | 70 | # Optional REPL history 71 | .node_repl_history 72 | 73 | # Output of 'npm pack' 74 | *.tgz 75 | 76 | # Yarn Integrity file 77 | .yarn-integrity 78 | 79 | # dotenv environment variable files 80 | .env 81 | .env.development.local 82 | .env.test.local 83 | .env.production.local 84 | .env.local 85 | 86 | # parcel-bundler cache (https://parceljs.org/) 87 | .cache 88 | .parcel-cache 89 | 90 | # Next.js build output 91 | .next 92 | out 93 | 94 | # Nuxt.js build / generate output 95 | .nuxt 96 | dist 97 | 98 | # Gatsby files 99 | .cache/ 100 | # Comment in the public line in if your project uses Gatsby and not Next.js 101 | # https://nextjs.org/blog/next-9-1#public-directory-support 102 | # public 103 | 104 | # vuepress build output 105 | .vuepress/dist 106 | 107 | # vuepress v2.x temp and cache directory 108 | .temp 109 | 110 | # Docusaurus cache and generated files 111 | .docusaurus 112 | 113 | # Serverless directories 114 | .serverless/ 115 | 116 | # FuseBox cache 117 | .fusebox/ 118 | 119 | # DynamoDB Local files 120 | .dynamodb/ 121 | 122 | # TernJS port file 123 | .tern-port 124 | 125 | # Stores VSCode versions used for testing VSCode extensions 126 | .vscode-test 127 | 128 | # yarn v2 129 | .yarn/cache 130 | .yarn/unplugged 131 | .yarn/build-state.yml 132 | .yarn/install-state.gz 133 | .pnp.* 134 | 135 | ### Node Patch ### 136 | # Serverless Webpack directories 137 | .webpack/ 138 | 139 | # Optional stylelint cache 140 | 141 | # SvelteKit build / generate output 142 | .svelte-kit 143 | 144 | # End of https://www.toptal.com/developers/gitignore/api/node 145 | -------------------------------------------------------------------------------- /vscode-extension/.prettierignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | /.pnp 4 | .pnp.js 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | /dist 12 | 13 | # misc 14 | .DS_Store 15 | .env.local 16 | .env.development.local 17 | .env.test.local 18 | .env.production.local 19 | 20 | npm-debug.log* 21 | yarn-debug.log* 22 | yarn-error.log* -------------------------------------------------------------------------------- /vscode-extension/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /vscode-extension/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Run Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ], 15 | "outFiles": [ 16 | "${workspaceFolder}/out/**/*.js" 17 | ], 18 | "preLaunchTask": "${defaultBuildTask}" 19 | }, 20 | { 21 | "name": "Extension Tests", 22 | "type": "extensionHost", 23 | "request": "launch", 24 | "args": [ 25 | "--extensionDevelopmentPath=${workspaceFolder}", 26 | "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" 27 | ], 28 | "outFiles": [ 29 | "${workspaceFolder}/out/test/**/*.js" 30 | ], 31 | "preLaunchTask": "${defaultBuildTask}" 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /vscode-extension/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | }, 9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts 10 | "typescript.tsc.autoDetect": "off" 11 | } -------------------------------------------------------------------------------- /vscode-extension/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /vscode-extension/.vscodeignore: -------------------------------------------------------------------------------- 1 | # This file contains all the files/directories that should 2 | # be ignored (i.e. not included) in the final packaged extension. 3 | 4 | # Ignore extension configs 5 | .vscode/** 6 | 7 | # Ignore test files 8 | .vscode-test/** 9 | out/test/** 10 | 11 | # Ignore source code 12 | src/** 13 | 14 | # Ignore all webview-ui files except the build directory 15 | webview-ui/src/** 16 | webview-ui/public/** 17 | webview-ui/scripts/** 18 | webview-ui/index.html 19 | webview-ui/README.md 20 | webview-ui/package.json 21 | webview-ui/package-lock.json 22 | webview-ui/node_modules/** 23 | 24 | # Ignore Misc 25 | .yarnrc 26 | vsc-extension-quickstart.md 27 | **/.gitignore 28 | **/tsconfig.json 29 | **/vite.config.ts 30 | **/.eslintrc.json 31 | **/*.map 32 | **/*.ts 33 | -------------------------------------------------------------------------------- /vscode-extension/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Marwane Koutar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vscode-extension/README.md: -------------------------------------------------------------------------------- 1 | # vscode-aws-lambda-swift 2 | 3 | vscode-aws-lambda-swift is a Visual Studio Code extension that simplifies the process of creating, testing, and deploying AWS Lambda functions using Swift. With this extension, you can quickly set up Lambda projects, configure deployment options, and test your functions locally or remotely. 4 | 5 | ## Features 6 | 7 | - **Project Initialization:** Easily create new AWS Lambda projects with customizable settings such as project name, region, and deployment path. 8 | - **Template Selection:** Choose from a variety of templates to kickstart your Lambda project, each providing additional information. 9 | - **Build & Package:** Compile your Swift code and package it into a ZIP archive for deployment to AWS Lambda. 10 | - **Local Testing:** Test your Lambda functions locally using predefined events or custom JSON files to simulate various input scenarios. 11 | - **Deployment:** Deploy your Lambda project to AWS with ease, specifying parameters like stack name and deployment region directly from Visual Studio Code. 12 | - **Remote Testing:** After deployment, test your functions remotely against live AWS resources, ensuring they behave as expected in the cloud environment. 13 | 14 | ## Requirements 15 | 16 | - [Docker](https://www.docker.com/): Install Docker to build and test Swift projects in a containerized environment. 17 | - [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html): Install the AWS Command Line Interface to interact with AWS services. 18 | - [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html): Install the AWS Serverless Application Model CLI for building and deploying serverless applications. 19 | 20 | ## Getting Started 21 | 22 | 1. **Install the Extension:** Search for `VSCode AWS Lambda Swift` in the Visual Studio Code Extensions Marketplace and install it. Or click [here](https://marketplace.visualstudio.com/items?itemName=MarwaneKoutar.vscode-aws-lambda-swift) to download the extension. 23 | 2. **Configure AWS Credentials:** Set up your AWS credentials using the AWS CLI by running `aws configure` in your terminal. Make sure you have the necessary permissions to create and manage Lambda functions. 24 | 3. **Start the Extension:** Open Visual Studio Code, press `Command+Shift+P` to open the command palette, and select `AWS Lambda Swift: Open AWS Lambda Swift Dashboard`. This will open the main panel of the extension. 25 | 4. **You're Ready to Go!** Start creating, testing, and deploying AWS Lambda functions using Swift with the help of this extension. 26 | 27 | ## Feedback & Contributions 28 | 29 | If you encounter any issues or have suggestions for improvement, please feel free to [submit an issue](https://github.com/MarwaneKoutar/vscode-aws-lambda-swift/issues) on GitHub. Contributions are also welcome and appreciated! 30 | 31 | ## License 32 | 33 | This project is licensed under the MIT License. See the [LICENSE](./vscode-extension/LICENSE.md) file for more information. 34 | -------------------------------------------------------------------------------- /vscode-extension/docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /vscode-extension/docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-code-background: #FFFFFF; 3 | --dark-code-background: #1E1E1E; 4 | } 5 | 6 | @media (prefers-color-scheme: light) { :root { 7 | --code-background: var(--light-code-background); 8 | } } 9 | 10 | @media (prefers-color-scheme: dark) { :root { 11 | --code-background: var(--dark-code-background); 12 | } } 13 | 14 | :root[data-theme='light'] { 15 | --code-background: var(--light-code-background); 16 | } 17 | 18 | :root[data-theme='dark'] { 19 | --code-background: var(--dark-code-background); 20 | } 21 | 22 | pre, code { background: var(--code-background); } 23 | -------------------------------------------------------------------------------- /vscode-extension/docs/assets/navigation.js: -------------------------------------------------------------------------------- 1 | window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE5WUX0vDMBTFv0ueh8MhInsdCj44htOnISNLr/baNJnJ7XCK391s2n8miymFUppzfufk0mb1yQjeiU2Z0GXJVWbHS17Ofp/ZiG055W611FklwY5r1bqjOsuplE5aoMrYdDJiIkeZGVBsumrwm8q9Wxj9CoJa7HOlBKFWJ8BdUz/l8uJr1FbPQRQLAwbeKrRIYJMTfGskJwMJBEviokgO6Hii5K3U+6Hj6bki9Beg6x0oSh9L44hTb2rKEHBjirPvgWf7IdyjIcJEhYRc4gcMnbPnjKRILbi8VTtdQDK/44mQDZSaYCC6a4qwbbWxwuAGHvTMsbRMT/CtXs5TJ8ndQVmH88+WZinpQOGu1I5TsGhLqlXRTluuQNrxHUe1ODz61X4U60aR1DDAE5JbG+KdIJ9PrnpNK0LpvsXjAReKdL/BXCsB/g4a57rWJO3BB7ZTDiDD7D/jdqJHg/9UdIrUgj3YiXoHXIh6rOaub3GmCL4IBwAA" -------------------------------------------------------------------------------- /vscode-extension/docs/assets/search.js: -------------------------------------------------------------------------------- 1 | window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE7VZ227jNhD9F/XV62Tou1+DLrBAtwi62/bBMAxZYhJudKtIObs1/O8lJUsaRkPXyipvlj3nzOEcXkb00cvTF+mtN0fvWSSht2YjL/Fj7q29II1jPwnlzRc/vjt/9kZekUf6xzgNi4jLmzpoh4LGTyqOdGQQ+VJyTe55p1HNP582CR65+lgkgRJp0hI/1N/Q1BhD5Bl5mZ/zRLnku3T8etCgPiIqwIAK/uB++KOHgDJ+qPyy2MsgF3v+Nb3TSdOIX6ukixxKU/DEg+f7nOf8n0JIofjV9nSRQ2kSiVDCj8S//D5Pv/FAXSupAxxK0b4QUdhTDMYMpSNKAz/6lBzS56unDoIMpSLkWZT+6FkOCzSUkpzHqeL9CoIxw1Uk4op/UX7wfH09GshPqWhPEv5d8UTqjJ3jo/nl2jPD18oPvqJq2nLVQZflt6oozZmf8EjefPZFcm8+dqRXAbsm4OIIgC0b5i7lGdKlvESORtLRihLfMrSlFrlBvCn5L6/A1ykZU5rY7XSJFkoS8ry3mgb2EzpmgJudRKq8CFTaX4uNbQUpGX4Q8kOW1zO2nzzLul32JtMa2DupCoXMUunvI3Q6X63NBg+m0Jpeuye9K0X8Lo3S/OsTj/md/uKR9xfr5Hkf3VVt+utscUMt0J1uNv/m+4PgL7rDU4amd/EoinfyWzapPnMp/Uf+m5A64xu2mItUw6lvpBdKRLpL1Mp0uX5Pk4B3zpwmZFeH9HjXsinbc5MgvcCOxkcI/t9x/ZmLy6PSAT3GhOkcIzKETl7XaAzvaTvSDX/Iv3vro3fgedkqrD02noxXGvggeBSaN+dKzqhshwzV9vzbX9ycCCaiCrm59Uab2xFbjVezxXY72tSI8ofyizIM9BNQYWCFMf3EqDBmhU3004QKm1hhU/00pcKmVthMP82osJkVNtdPcypsboUt9NOCCltYYUv9tKTCllaYNmWzosJWdnlNtYH0AV4ZUTpBW2F7AabmQLoBth1gyg6kIWA7AqbyQHoCtilgig+kLWD7Aqb+QDoDtjVgLADSHLDdAeMCkP6AbRAYI4C0CGyPmDGCkR4x2yNmjGCkR+zVeikXDL1ibI+YMYKRHjHbI2aMYKRHzPaIGSMY6RGzPWLGCEZ6xGyPmDGCkR4x2yNmjGCkR6zyqNzr9CanePip2vP0rmV3aEdvd94OtTPnPfjoaT/Wx9Op3f7Mk0lg9t6X6vgM6kMfUUwQxcRFUTVdgWm6lGm6gnPThXgA8YCL59wFtzA9CxuYnnsOmGxGEFcNQNQ0AEjBFCmYOqja11akAZUAXCUo72qy+kKjBS9a7MIBLa/BMvsCrSWYtQQzF0H9fi/9uP6MKdAscE0C69UIDX2Jhr50YasXzq53cwSeO8DVJYas7j0QFk0XcE2X6kKIKDqaNK450/TfaIIwNEGYA4euSJBahAQXUi8zfr69RjlRSjfuob19R0lRTjc0qZpJlBG5wlyuaGBe3XO3QLQKXItAwwrT6KFsaAIx1wRqL10JL5Fcl9ryglKcr/BaJErtyhzrRr87b9GSA9eaO78z0ARopwHXTlNdInZVA1qt4Fqu9a0KgqGNBlw7TfMngEqD+u+DlgKpdom2eu/u1EKFY67CWRSvZwsaBCMHoY+/TGR6f0900GZ7Ov0HwXR/PhgbAAA="; -------------------------------------------------------------------------------- /vscode-extension/docs/index.html: -------------------------------------------------------------------------------- 1 | vscode-aws-lambda-swift

vscode-aws-lambda-swift

VSCODE AWS LAMBDA SWIFT

Description

This project is currently under construction.

2 |
-------------------------------------------------------------------------------- /vscode-extension/docs/modules/extension.html: -------------------------------------------------------------------------------- 1 | extension | vscode-aws-lambda-swift

Index

Functions

-------------------------------------------------------------------------------- /vscode-extension/docs/modules/panels_MainPanel.html: -------------------------------------------------------------------------------- 1 | panels/MainPanel | vscode-aws-lambda-swift

Index

Classes

-------------------------------------------------------------------------------- /vscode-extension/docs/modules/utilities_getUri.html: -------------------------------------------------------------------------------- 1 | utilities/getUri | vscode-aws-lambda-swift

Index

Functions

getUri 2 |
-------------------------------------------------------------------------------- /vscode-extension/media/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swift-server-community/vscode-aws-lambda-swift-sam/ba45e9db0d212109e192e2e96ce396cabc1bf24b/vscode-extension/media/logo.png -------------------------------------------------------------------------------- /vscode-extension/media/swift.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vscode-extension/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-aws-lambda-swift", 3 | "displayName": "VSCode AWS Lambda Swift", 4 | "publisher": "MarwaneKoutar", 5 | "description": "vscode-aws-lambda-swift is a VS Code extension for developing and deploying AWS Lambda functions in Swift. It allows you to create, test, deploy, and manage Lambda functions directly within VS Code.", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/swift-server-community/vscode-aws-lambda-swift-sam" 9 | }, 10 | "version": "1.2.1", 11 | "workspaces": [ 12 | "packages/*" 13 | ], 14 | "engines": { 15 | "vscode": "^1.98.1" 16 | }, 17 | "main": "./out/extension.js", 18 | "activationEvents": [], 19 | "contributes": { 20 | "commands": [ 21 | { 22 | "command": "vals.showMainPanel", 23 | "title": "Open AWS Lambda Swift Dashboard", 24 | "category": "AWS Lambda Swift" 25 | } 26 | ] 27 | }, 28 | "scripts": { 29 | "install:all": "npm install && cd webview-ui && npm install", 30 | "start:webview": "cd webview-ui && npm run start", 31 | "build:webview": "cd webview-ui && npm run build", 32 | "vscode:prepublish": "npm run build:all", 33 | "compile": "tsc -p ./", 34 | "build:core-lib": "cd packages/core-lib && npm run build", 35 | "build:all": "npm run build:core-lib && npm run build:webview && npm run compile", 36 | "watch": "tsc -watch -p ./", 37 | "pretest": "npm run compile && npm run lint", 38 | "lint": "ESLINT_USE_FLAT_CONFIG=false eslint ./src --ext .ts", 39 | "lint:fix": "ESLINT_USE_FLAT_CONFIG=false eslint ./src --ext .ts --fix", 40 | "docs": "typedoc --out docs --entryPointStrategy expand src --exclude webview-ui" 41 | }, 42 | "devDependencies": { 43 | "@semantic-release/git": "^10.0.1", 44 | "@semantic-release/github": "^11.0.1", 45 | "@types/node": "^22.13.10", 46 | "@types/vscode": "^1.98.0", 47 | "@typescript-eslint/eslint-plugin": "^8.26.1", 48 | "@typescript-eslint/parser": "^8.26.1", 49 | "@vscode/test-electron": "^2.4.1", 50 | "eslint": "^9.22.0", 51 | "glob": "^11.0.1", 52 | "prettier": "^3.5.3", 53 | "semantic-release": "^24.2.3", 54 | "semantic-release-vsce": "^6.0.6", 55 | "typedoc": "0.27.9", 56 | "typescript": "^5.8.2", 57 | "vsce": "^2.15.0" 58 | }, 59 | "dependencies": { 60 | "core-lib": "workspace:*", 61 | "winston": "^3.17.0" 62 | }, 63 | "badges": [ 64 | { 65 | "href": "https://marketplace.visualstudio.com/items?itemName=MarwaneKoutar.vscode-aws-lambda-swift", 66 | "url": "https://img.shields.io/badge/VS%20Code-compatible-brightgreen.svg", 67 | "description": "Compatible with VS Code" 68 | }, 69 | { 70 | "href": "https://github.com/swift-server-community/vscode-aws-lambda-swift-sam", 71 | "url": "https://img.shields.io/badge/Open%20Source-Yes-green.svg", 72 | "description": "Open Source" 73 | } 74 | ], 75 | "markdown": "github", 76 | "icon": "media/logo.png" 77 | } 78 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | .github/ 3 | node_modules/ 4 | src/playground.ts -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "extends": [ 4 | "eslint:recommended", 5 | "plugin:@typescript-eslint/recommended", 6 | "plugin:prettier/recommended" 7 | ], 8 | "plugins": ["@typescript-eslint", "prettier"], 9 | "rules": { 10 | "prettier/prettier": "error", 11 | "semi": ["error", "always"], 12 | "quotes": ["error", "double"], 13 | "indent": ["error", 2], 14 | "comma-dangle": ["error", "always-multiline"], 15 | "no-console": "warn", 16 | "no-unused-vars": "warn", 17 | "no-undef": "error", 18 | "no-extra-semi": "error", 19 | "no-unreachable": "error" 20 | }, 21 | "env": { 22 | "node": true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .env 4 | src/playground.ts -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | .changeset 3 | .github 4 | pnpm-lock.yaml 5 | tsconfig.json 6 | vitest.config.ts -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/.nvmrc: -------------------------------------------------------------------------------- 1 | v18.12.1 -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/README.md: -------------------------------------------------------------------------------- 1 | # Core-lib 2 | 3 | This library is a collection of utilities to help you build Swift-based AWS Lambda functions. It includes boilerplate templates for creating new Lambda functions. Each template has a different purpose, such as processing API Gateway requests, S3 events, or SQS messages. 4 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-hl-0: #795E26; 3 | --dark-hl-0: #DCDCAA; 4 | --light-hl-1: #000000; 5 | --dark-hl-1: #D4D4D4; 6 | --light-hl-2: #A31515; 7 | --dark-hl-2: #CE9178; 8 | --light-hl-3: #AF00DB; 9 | --dark-hl-3: #C586C0; 10 | --light-hl-4: #0000FF; 11 | --dark-hl-4: #569CD6; 12 | --light-hl-5: #0070C1; 13 | --dark-hl-5: #4FC1FF; 14 | --light-hl-6: #001080; 15 | --dark-hl-6: #9CDCFE; 16 | --light-code-background: #FFFFFF; 17 | --dark-code-background: #1E1E1E; 18 | } 19 | 20 | @media (prefers-color-scheme: light) { :root { 21 | --hl-0: var(--light-hl-0); 22 | --hl-1: var(--light-hl-1); 23 | --hl-2: var(--light-hl-2); 24 | --hl-3: var(--light-hl-3); 25 | --hl-4: var(--light-hl-4); 26 | --hl-5: var(--light-hl-5); 27 | --hl-6: var(--light-hl-6); 28 | --code-background: var(--light-code-background); 29 | } } 30 | 31 | @media (prefers-color-scheme: dark) { :root { 32 | --hl-0: var(--dark-hl-0); 33 | --hl-1: var(--dark-hl-1); 34 | --hl-2: var(--dark-hl-2); 35 | --hl-3: var(--dark-hl-3); 36 | --hl-4: var(--dark-hl-4); 37 | --hl-5: var(--dark-hl-5); 38 | --hl-6: var(--dark-hl-6); 39 | --code-background: var(--dark-code-background); 40 | } } 41 | 42 | :root[data-theme='light'] { 43 | --hl-0: var(--light-hl-0); 44 | --hl-1: var(--light-hl-1); 45 | --hl-2: var(--light-hl-2); 46 | --hl-3: var(--light-hl-3); 47 | --hl-4: var(--light-hl-4); 48 | --hl-5: var(--light-hl-5); 49 | --hl-6: var(--light-hl-6); 50 | --code-background: var(--light-code-background); 51 | } 52 | 53 | :root[data-theme='dark'] { 54 | --hl-0: var(--dark-hl-0); 55 | --hl-1: var(--dark-hl-1); 56 | --hl-2: var(--dark-hl-2); 57 | --hl-3: var(--dark-hl-3); 58 | --hl-4: var(--dark-hl-4); 59 | --hl-5: var(--dark-hl-5); 60 | --hl-6: var(--dark-hl-6); 61 | --code-background: var(--dark-code-background); 62 | } 63 | 64 | .hl-0 { color: var(--hl-0); } 65 | .hl-1 { color: var(--hl-1); } 66 | .hl-2 { color: var(--hl-2); } 67 | .hl-3 { color: var(--hl-3); } 68 | .hl-4 { color: var(--hl-4); } 69 | .hl-5 { color: var(--hl-5); } 70 | .hl-6 { color: var(--hl-6); } 71 | pre, code { background: var(--code-background); } 72 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/docs/assets/navigation.js: -------------------------------------------------------------------------------- 1 | window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE5XTTUvEMBAG4P+S86IX8bC3RV1YUJDtggfxkKbjNibN1HSy+IH/3cJqyNJkqte+bx6mk/bxUxC8kViKOmjb3Ht8AUViIXpJ7fj0OThFGt1wnuZnLXV2LBntGrG8vPhaREa1oMzqobq63eSUJJ5FrN3Ca9AeOnA0lLXT3hx7jcqAL2rHeA6pVnfcCx5jBmnAAkFFUpkcksQs0lt8Z67spMBAe6CbQ2nHMeSB9e+BghFzntnCnkF+Up7YQddbSVBCYs4w2mnS0uoPYNY7KTGgRSXtxh3QQI5KYgYZv3AkKCtpzjBDqAfldQ07rKgBn/0ZJqU/gxiy25qUGDC42F577MpTZov/ggvTZosT+Okbve3rAT8FAAA=" -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/docs/assets/search.js: -------------------------------------------------------------------------------- 1 | window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE51Wy27bMBD8F54FJ5T8vgVtAwRogSIO2oNhFLK0TlRToitRTlvD/96lZJtkvHTlXASQOzMUd7jk7lgpXys2ne/YOitSNh32A1bEObApewZ1XxeJymRRsYDVpcDJ1XHmxg73XlQuEJOIuKoA9RjbB7Tkpy0UyqPXxq4Qe4Rn/98dgl3lqnpZJWW2hCc5U6msFaF6hukqXhcn6n0pc+8CJO59O4Cy/O8OEPP+HdALkLgrLH2CfCNiBR5TT+GuklmRqSwW2V/4WsqfkFBZP8N0FV/WmUj9una4q2QKGyH/+DWdeFdRIZNYPBRbuQZC0op2FSwhlwq8ina4+8YFKJipOFmT2z5FuwomL5Cs74R4hF91hn/kuXco2HVLfJ99+PzgVW6iVwnO7r5cEGyjVwl+lMkaqGK1opTgIsDySeE3m+7YFsoKOTgf9qLeBJGrDESq3452LaTKXGePLQ6xb3hCZakRLeTmlgXz2yAc9KLJYhHMj4RmvploUBxHnEBxBxXiKCRQoYOKcBQRqMhB9XHUJ1B9BzXA0YBADRzUEEdDAjV0UCMcjQjUyEGNcTQmUGMHhV7MJwRq4mZVJ5lT2edv0t/knzTAdYDrVHPKA+6awHW2OWUDd33gOuGccoK7VnCdc06ZwV03uE47p/zgriFcZ55TlvDWk6YWsAgUpA9tTeCpbi74zfGu3rEfh3KZHOtvxyb42e9NcehRI69LLxaidG4nI8H7RgN3f0nktUpE5nAHFndwiZsebgaLO7K4o0vcKs7frju0uEMPt73Jq/aet7iRxY28XP34EQnHg23Ytx42tg+wPcuzRfTzVqYRNlRrzQtLlsce1RBDQwz9RGU6IUO13PGZY7oZIlFjwx97+E07kB2editRdqZ8qWoffoJsbZn79nxqHJWsDu2lUbCOtO9Eu/ymwTZ863j5TpfVuq6wdT3/B+t4+073ucab/7DKmqxqvGc22QbQAMTMF/v9P29N9JGjDQAA"; -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: "ts-jest", 4 | testEnvironment: "node", 5 | moduleDirectories: ["node_modules", "src"], 6 | }; 7 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "core-lib", 3 | "version": "0.1.3", 4 | "description": "", 5 | "main": "out/index.js", 6 | "types": "out/index.d.ts", 7 | "private": false, 8 | "scripts": { 9 | "test:integration": "jest --testPathPattern='integration' --testMatch='**/*.test.ts", 10 | "test:unit": "jest --testPathPattern='unit' --testMatch='**/*.test.ts'", 11 | "build": "tsc -p ./", 12 | "lint": "ESLINT_USE_FLAT_CONFIG=false eslint ./src --ext .ts", 13 | "lint:fix": "ESLINT_USE_FLAT_CONFIG=false eslint ./src --ext .ts --fix", 14 | "docs": "typedoc --out docs src --exclude playground.ts --includes src/utils --readme README.md", 15 | "playground": "ts-node src/playground.ts" 16 | }, 17 | "keywords": [], 18 | "author": "Marwane Koutar", 19 | "license": "ISC", 20 | "devDependencies": { 21 | "@changesets/cli": "^2.28.1", 22 | "@jest/globals": "^29.7.0", 23 | "@types/jest": "^29.5.14", 24 | "@types/node": "^22.13.10", 25 | "@typescript-eslint/eslint-plugin": "^8.26.1", 26 | "eslint": "^9.22.0", 27 | "eslint-config-prettier": "^10.1.1", 28 | "eslint-plugin-prettier": "^5.2.3", 29 | "jest": "^29.7.0", 30 | "prettier": "^3.5.3", 31 | "ts-jest": "^29.2.6", 32 | "ts-node": "^10.9.2", 33 | "tsup": "^8.4.0", 34 | "typedoc": "^0.27.9", 35 | "typescript": "^5.8.2" 36 | }, 37 | "publishConfig": { 38 | "access": "public" 39 | }, 40 | "dependencies": { 41 | "@aws-sdk/client-ec2": "^3.766.0", 42 | "@smithy/config-resolver": "^4.0.1", 43 | "@smithy/node-config-provider": "^4.0.1", 44 | "axios": "^1.8.3", 45 | "child_process": "^1.0.2", 46 | "fs": "0.0.1-security", 47 | "winston": "^3.17.0" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/__tests__/index.test.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { describe, expect, test } from "@jest/globals"; 17 | 18 | describe("index", () => { 19 | test("should pass", () => { 20 | expect(true).toBe(true); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/__tests__/integration/integration.test.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { 17 | getTemplates, 18 | initializeProject, 19 | buildProject, 20 | localInvoke, 21 | deployProject, 22 | remoteInvoke, 23 | deleteStack, 24 | subscribeToStdout, 25 | subscribeToStderr, 26 | } from "../../facade"; 27 | import { describe, it, expect, afterAll } from "@jest/globals"; 28 | import { promises as fs } from "fs"; 29 | 30 | describe("Integration test", () => { 31 | const projectPath = "/tmp"; 32 | const projectName = "api-to-lambda-test"; 33 | const functionName = "HelloWorld"; 34 | const eventPath = "./events/event.json"; 35 | const region = "eu-west-3"; 36 | 37 | afterAll(async () => { 38 | // Clean up 39 | await fs.rm(projectPath + "/" + projectName, { 40 | recursive: true, 41 | force: true, 42 | }); 43 | }); 44 | 45 | it("should perform end-to-end (init to localInvoke) project lifecycle successfully", async () => { 46 | subscribeToStderr((data) => { 47 | //do something with stderr 48 | data; 49 | }); 50 | subscribeToStdout((data) => { 51 | //do something with stdout 52 | data; 53 | }); 54 | 55 | const titles = await getTemplates(); 56 | expect(titles.list.length).toBeGreaterThan(0); 57 | 58 | const templateName = titles.list[0].name; 59 | 60 | await initializeProject(projectName, templateName, projectPath); 61 | 62 | await buildProject(projectPath + "/" + projectName); 63 | 64 | await localInvoke(functionName, eventPath, `${projectPath}/${projectName}`); 65 | 66 | await deployProject(projectName, `${projectPath}/${projectName}`, region); 67 | 68 | await remoteInvoke( 69 | projectName, 70 | functionName, 71 | region, 72 | eventPath, 73 | `${projectPath}/${projectName}`, 74 | ); 75 | 76 | await deleteStack(projectName, region); 77 | }, 2400000); 78 | }); 79 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/__tests__/unit/checkRequirements.test.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { checkAWSCLI, checkSAMCLI, checkDocker } from "../../facade"; 17 | import { describe, it, expect } from "@jest/globals"; 18 | 19 | describe("checkRequirements", () => { 20 | describe("checkAWSCLI", () => { 21 | it("should return true if AWS CLI is installed", async () => { 22 | const result = await checkAWSCLI(); 23 | expect(result).toBeDefined(); 24 | }); 25 | }); 26 | describe("checkSAMCLI", () => { 27 | it("should return true if SAM CLI is installed", async () => { 28 | const result = await checkSAMCLI(); 29 | expect(result).toBeDefined(); 30 | }); 31 | }); 32 | describe("checkDocker", () => { 33 | it("should return true if Docker is installed", async () => { 34 | const result = await checkDocker(); 35 | expect(result).toBeDefined(); 36 | }); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/__tests__/unit/initializeSamProject.test.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | /* eslint-disable @typescript-eslint/no-explicit-any */ 17 | import { cleanupTempDirectory } from "../../utils/cleanUp"; 18 | import { 19 | jest, 20 | describe, 21 | it, 22 | expect, 23 | beforeEach, 24 | afterEach, 25 | } from "@jest/globals"; 26 | import { config } from "../../config/config"; 27 | import { promises as fs } from "fs"; 28 | 29 | jest.mock("../../utils/commandRunner", () => { 30 | let instance: any; 31 | 32 | return { 33 | CommandRunner: { 34 | getInstance: jest.fn(() => { 35 | if (!instance) { 36 | instance = { 37 | runCommand: jest.fn(), 38 | }; 39 | } 40 | return instance; 41 | }), 42 | }, 43 | }; 44 | }); 45 | 46 | describe("initializeSamProject", () => { 47 | // The following tests are meant to test the cleanupTempDirectory function 48 | describe("cleanupTempDirectory", () => { 49 | beforeEach(async () => { 50 | try { 51 | await fs.access(config.CLONED_TEMPLATES_DIR); 52 | } catch (error: any) { 53 | if (error.code === "ENOENT") { 54 | await fs.mkdir(config.CLONED_TEMPLATES_DIR); 55 | } 56 | } 57 | }); 58 | 59 | afterEach(async () => { 60 | try { 61 | await fs.access(config.CLONED_TEMPLATES_DIR); 62 | } catch (error: any) { 63 | if (error.code === "ENOENT") { 64 | return; 65 | } 66 | } 67 | await fs.rmdir(config.CLONED_TEMPLATES_DIR); 68 | }); 69 | 70 | it("should clean up the temporary directory successfully", async () => { 71 | await cleanupTempDirectory(); 72 | 73 | try { 74 | await fs.access(config.CLONED_TEMPLATES_DIR); 75 | throw new Error("Directory still exists"); 76 | } catch (error: any) { 77 | expect(error.code).toBe("ENOENT"); 78 | } 79 | }); 80 | }); 81 | }); 82 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/__tests__/unit/templateService.test.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { TemplateFetchError } from "../../errors/errors"; 17 | import { getTemplateTitles } from "../../services/templateServices"; 18 | import axios from "axios"; 19 | import { jest, describe, afterEach, it, expect } from "@jest/globals"; 20 | 21 | jest.mock("axios"); 22 | 23 | describe("TemplateService", () => { 24 | describe("getTemplateTitles", () => { 25 | afterEach(() => { 26 | jest.resetAllMocks(); 27 | }); 28 | 29 | it("should fetch template titles successfully", async () => { 30 | const mockResponse = { 31 | data: { 32 | templates: { 33 | apiToLambda: { 34 | path: "some/path/to/api.png", 35 | }, 36 | sqsToLambda: { 37 | path: "some/path/to/sqs.png", 38 | }, 39 | }, 40 | }, 41 | }; 42 | const axiosGetSpy = jest 43 | .spyOn(axios, "get") 44 | .mockResolvedValueOnce(mockResponse); 45 | 46 | const data = await getTemplateTitles( 47 | "https://example.com/templates.json", 48 | "main", 49 | ); 50 | 51 | expect(data.list.length).toBe(2); 52 | expect(data.list[0].name).toBe("apiToLambda"); 53 | expect(data.list[0].path).toBe("some/path/to/api.png"); 54 | expect(data.list[1].name).toBe("sqsToLambda"); 55 | expect(data.list[1].path).toBe("some/path/to/sqs.png"); 56 | expect(axios.get).toHaveBeenCalledWith( 57 | "https://example.com/templates.json/main/cookiecutter.json", 58 | ); 59 | 60 | axiosGetSpy.mockRestore(); 61 | }); 62 | 63 | it("should throw TemplateFetchError when URL is not defined", async () => { 64 | await expect(getTemplateTitles("", "")).rejects.toThrow( 65 | TemplateFetchError, 66 | ); 67 | }); 68 | 69 | it("should throw TemplateFetchError when request fails", async () => { 70 | const errorMessage = "Network Error"; 71 | const axiosGetSpy = jest 72 | .spyOn(axios, "get") 73 | .mockRejectedValueOnce(new Error(errorMessage)); 74 | 75 | await expect( 76 | getTemplateTitles("https://example.com/templates.json", "main"), 77 | ).rejects.toThrow(TemplateFetchError); 78 | 79 | axiosGetSpy.mockRestore(); 80 | }); 81 | }); 82 | }); 83 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/config/config.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | export const config = { 17 | RAW_TEMPLATES_REPO_URL: 18 | process.env.RAW_TEMPLATES_REPO_URL || 19 | "https://raw.githubusercontent.com/swift-server-community/aws-lambda-swift-sam-template", 20 | TEMPLATES_REPO_URL: 21 | process.env.TEMPLATES_REPO_URL || 22 | "https://github.com/swift-server-community/aws-lambda-swift-sam-template", 23 | CLONED_TEMPLATES_DIR: 24 | process.env.CLONED_TEMPLATES_DIR || "/tmp/template-repo", 25 | EVENTS_DIR: process.env.EVENTS_DIR || "/events", 26 | SWIFT_PACKAGE_FILE: process.env.SWIFT_PACKAGE_FILE || "/Package.swift", 27 | SWIFT_PACKAGE_FUNCTIONS_REGEX: 28 | process.env.SWIFT_PACKAGE_REGEX || /\.executable\(name: "(.*?)"/g, 29 | }; 30 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/index.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | export * from "./facade"; 17 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/logger.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import winston from "winston"; 17 | 18 | /** 19 | * Logger 20 | * @description Winston logger 21 | * @example 22 | * logger.info("Hello, world!"); 23 | * @returns {winston.Logger} 24 | * @see 25 | * https://www.npmjs.com/package/winston 26 | */ 27 | const logger = winston.createLogger({ 28 | level: "debug", 29 | format: winston.format.simple(), 30 | transports: [new winston.transports.Console()], 31 | }); 32 | 33 | export default logger; 34 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/services/templateServices.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import axios from "axios"; 17 | import { TemplateFetchError } from "../errors/errors"; 18 | import { TemplatesResult } from "../utils/types"; 19 | 20 | /** Get the titles of the templates from the JSON file. 21 | * @param {string} URL The URL of the JSON file 22 | * @param {string} branch The branch of the repository 23 | * @throws {Error} If the URL is not defined in the environment 24 | * @async 25 | * @example 26 | * const titles = await getTemplateTitles("https://example.com/templates.json", "main"); 27 | * console.log("Template titles:", titles); 28 | * @returns {Promise} The titles of the templates with their images 29 | */ 30 | export async function getTemplateTitles( 31 | URL: string, 32 | branch: string, 33 | ): Promise { 34 | if (!URL || URL === "") { 35 | throw new TemplateFetchError( 36 | "TEMPLATES_JSON_URL is not defined in the environment.", 37 | ); 38 | } 39 | 40 | if (!branch || branch === "") { 41 | throw new TemplateFetchError("Branch is not defined."); 42 | } 43 | 44 | try { 45 | const response = await axios.get(`${URL}/${branch}/cookiecutter.json`); 46 | 47 | const result = Object.entries(response.data.templates).map( 48 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 49 | ([key, value]: [string, any]) => ({ 50 | name: key, 51 | path: value.path, 52 | }), 53 | ); 54 | 55 | return { list: result }; 56 | } catch (error) { 57 | throw new TemplateFetchError( 58 | `Error fetching template titles: ${error}`, 59 | error as Error, 60 | ); 61 | } 62 | } 63 | 64 | /** 65 | * Get the branches of the template repository. 66 | * @param {string} repoUrl The URL of the GitHub repository 67 | * @throws {Error} If the URL is not defined or if there's an error fetching the branches 68 | * @async 69 | * @example 70 | * const branches = await getTemplateBranches("https://github.com/username/repository"); 71 | * console.log("Branches:", branches); 72 | * @returns {Promise} The branches of the repository 73 | */ 74 | export async function getTemplateBranches(repoUrl: string): Promise { 75 | if (!repoUrl || repoUrl === "") { 76 | throw new TemplateFetchError("Repository URL is not defined."); 77 | } 78 | 79 | const apiUrl = `${repoUrl}/branches/all`; 80 | 81 | try { 82 | const response = await axios.get(apiUrl, { 83 | headers: { 84 | Accept: "application/json", 85 | }, 86 | }); 87 | return response.data.payload.branches.map( 88 | (branch: { name: string }) => branch.name, 89 | ); 90 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 91 | } catch (error: any) { 92 | throw new TemplateFetchError( 93 | `Error fetching template branches: ${error.message}`, 94 | error, 95 | ); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/utils/cleanUp.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { CleanupError } from "../errors/errors"; 17 | import { config } from "../config/config"; 18 | import { promises as fs } from "fs"; 19 | import logger from "../logger"; 20 | 21 | /** 22 | * Cleans up the temporary directory 23 | * @async 24 | * @example 25 | * await cleanupTempDirectory(); 26 | * @throws {Error} If the temporary directory cannot be cleaned up 27 | * @returns {Promise} 28 | */ 29 | export async function cleanupTempDirectory(): Promise { 30 | try { 31 | await fs.rm(config.CLONED_TEMPLATES_DIR, { recursive: true }); 32 | logger.debug("Temporary directory cleanup successful."); 33 | } catch (error) { 34 | const err = error as CleanupError; 35 | if (err.code === "ENOENT") { 36 | logger.debug("Temporary directory does not exist. No cleanup needed."); 37 | } else { 38 | throw new CleanupError( 39 | "Failed to clean up temporary directory", 40 | err, 41 | err.code, 42 | ); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/utils/commandRunner.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | /* eslint-disable no-unused-vars */ 17 | import { spawn, StdioOptions } from "child_process"; 18 | import { EventEmitter } from "events"; 19 | import { InvalidCommandError } from "../errors/errors"; 20 | import { CommandResult } from "./types"; 21 | 22 | /** 23 | * Options for running a command 24 | * @interface 25 | * @member args - The arguments to pass to the command 26 | * @member command - The command to run 27 | * @member cwd - The current working directory to run the command in 28 | * @member stdioOptions - The stdio options for the command 29 | * @example 30 | * const options = { 31 | * args: ["local", "invoke", "MyFunction", "--event", "event.json"], 32 | * command: "sam", 33 | * cwd: "/Users/my-user/Documents/my-project", 34 | * stdioOptions: ["pipe", "pipe", "pipe"], 35 | * }; 36 | */ 37 | export interface RunCommandOptions { 38 | args: string[]; 39 | command?: string; 40 | cwd?: string; 41 | stdioOptions?: StdioOptions; 42 | withOutput?: boolean; 43 | } 44 | 45 | /** 46 | * Represents a command runner utility. 47 | * @class 48 | */ 49 | export class CommandRunner { 50 | private static instance: CommandRunner; 51 | private eventEmitter = new EventEmitter(); 52 | 53 | private constructor() {} 54 | 55 | /** 56 | * Returns the singleton instance of the CommandRunner class. 57 | * @returns The singleton instance of CommandRunner. 58 | */ 59 | public static getInstance(): CommandRunner { 60 | if (!CommandRunner.instance) { 61 | CommandRunner.instance = new CommandRunner(); 62 | } 63 | return CommandRunner.instance; 64 | } 65 | 66 | /** 67 | * Runs a command 68 | * @param options - The options for running the command 69 | * @async 70 | * @example 71 | * await runCommand({ 72 | * args: ["local", "invoke", "MyFunction", "--event", "event.json"], 73 | * command: "sam", 74 | * cwd: "/Users/my-user/Documents/my-project", 75 | * }); 76 | * @throws {InvalidCommandError} If the command cannot be run 77 | * @returns {Promise} 78 | */ 79 | public async runCommand({ 80 | args, 81 | command = "sam", 82 | cwd = process.cwd(), 83 | stdioOptions = ["pipe", "pipe", "pipe"], 84 | withOutput = true, 85 | }: RunCommandOptions): Promise { 86 | return new Promise<{ 87 | exitCode: number; 88 | output: { stdout: string; stderr: string }; 89 | }>((resolve, reject) => { 90 | const childProcess = spawn(command, args, { stdio: stdioOptions, cwd }); 91 | const output: { stdout: string; stderr: string } = { 92 | stdout: "", 93 | stderr: "", 94 | }; 95 | 96 | if (childProcess.stdout) { 97 | childProcess.stdout.on("data", (data) => { 98 | const stdoutData = data.toString(); 99 | output.stdout += stdoutData; 100 | if (withOutput) this.eventEmitter.emit("stdout", stdoutData); 101 | }); 102 | } 103 | 104 | if (childProcess.stderr) { 105 | childProcess.stderr.on("data", (data) => { 106 | const stderrData = data.toString(); 107 | output.stderr += stderrData; 108 | if (withOutput) this.eventEmitter.emit("stderr", stderrData); 109 | }); 110 | } 111 | 112 | childProcess.on("error", (err) => { 113 | reject( 114 | new InvalidCommandError( 115 | `Error running command '${command} ${args[0]}'`, 116 | err, 117 | ), 118 | ); 119 | }); 120 | 121 | childProcess.on("exit", (code) => { 122 | resolve({ exitCode: code ?? 1, output }); 123 | }); 124 | }); 125 | } 126 | 127 | /** 128 | * Subscribes to events emitted by the command runner. 129 | * @param event - The event to subscribe to (`stdout` or `stderr`). 130 | * @param listener - The listener function to be called when the event is emitted. 131 | */ 132 | public subscribe( 133 | event: "stdout" | "stderr", 134 | listener: (data: string) => void, 135 | ) { 136 | this.eventEmitter.on(event, listener); 137 | } 138 | 139 | /** 140 | * Unsubscribes from events emitted by the command runner. 141 | * @param event - The event to unsubscribe from (`stdout` or `stderr`). 142 | * @param listener - The listener function to be removed. 143 | */ 144 | public unsubscribe( 145 | event: "stdout" | "stderr", 146 | listener: (data: string) => void, 147 | ) { 148 | this.eventEmitter.off(event, listener); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/utils/error-base.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | /** 17 | * Base class for all custom errors 18 | * @class 19 | * @extends Error 20 | * @template T 21 | * @param {T} name The name of the error 22 | * @param {string} message The error message 23 | * @param {Error | string | undefined} cause The cause of the error 24 | * @example 25 | * throw new CustomError("INVALID_COMMAND", "The command is invalid"); 26 | */ 27 | export class ErrorBase extends Error { 28 | name: T; 29 | message: string; 30 | cause: Error | string | undefined; 31 | 32 | constructor(name: T, message: string, cause: Error | string | undefined) { 33 | super(); 34 | this.name = name; 35 | this.message = message; 36 | this.cause = cause; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/utils/initUtils.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { CommandRunner } from "./commandRunner"; 17 | import { GitCloneFailedError, SamInitFailedError } from "../errors/errors"; 18 | import { config } from "../config/config"; 19 | import { CommandResult } from "./types"; 20 | 21 | const commandRunner = CommandRunner.getInstance(); 22 | 23 | /** 24 | * Clones the template repository 25 | * @async 26 | * @example 27 | * await cloneTemplate(); 28 | * @throws {GitCloneFailedError} If the template repository cannot be cloned 29 | * @returns {Promise} 30 | */ 31 | export async function cloneTemplate(branch: string): Promise { 32 | const cloneArgs: string[] = [ 33 | "clone", 34 | "--single-branch", 35 | "--branch", 36 | branch, 37 | "--depth", 38 | "1", 39 | config.TEMPLATES_REPO_URL, 40 | config.CLONED_TEMPLATES_DIR, 41 | ]; 42 | 43 | try { 44 | return await commandRunner.runCommand({ args: cloneArgs, command: "git" }); 45 | } catch (error) { 46 | throw new GitCloneFailedError( 47 | "Failed to clone the template repository", 48 | error as Error, 49 | ); 50 | } 51 | } 52 | 53 | /** 54 | * Initializes a new SAM project 55 | * @param {string} name The name of the project 56 | * @param {string} template The name of the template to use 57 | * @param {string} path The path to initialize the project in 58 | * @async 59 | * @example 60 | * await initializeSamProject("sqs", "sqs-to-lambda", "/Users/my-user/Documents/my-project"); 61 | * @throws {SamInitFailedError} If the project cannot be initialized 62 | * @returns {Promise} 63 | */ 64 | export async function initializeSamProject( 65 | name: string, 66 | template: string, 67 | path: string, 68 | ): Promise { 69 | const args: string[] = [ 70 | "init", 71 | "-l", 72 | `${config.CLONED_TEMPLATES_DIR}/templates/${template}`, 73 | "--name", 74 | name, 75 | "--no-interactive", 76 | "--no-input", 77 | ]; 78 | 79 | try { 80 | return await commandRunner.runCommand({ args, command: "sam", cwd: path }); 81 | } catch (error) { 82 | throw new SamInitFailedError( 83 | "Failed to initialize SAM project", 84 | error as Error, 85 | ); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /vscode-extension/packages/core-lib/src/utils/types.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | /** 17 | * Interface representing the result of a command execution. 18 | * Contains information about the command's exit code and output. 19 | * @interface 20 | * @member exitCode - The exit code returned by the command process. 21 | * @member output - An object containing the standard output (stdout) and standard error (stderr) of the command. 22 | */ 23 | export interface CommandResult { 24 | exitCode: number; 25 | output: { 26 | stdout: string; 27 | stderr: string; 28 | }; 29 | } 30 | 31 | /** 32 | * Interface representing the result of a CLI check. 33 | * Contains information about the success of the check, exit code, and output. 34 | * @interface 35 | * @member success - Indicates whether the CLI check was successful or not. 36 | * @member AWSCLI - Indicates whether the AWS CLI is installed. 37 | * @member Docker - Indicates whether Docker is installed. 38 | * @member SAMCLI - Indicates whether the SAM CLI is installed. 39 | * @member exitCode - The exit code returned by the CLI check process. 40 | * @member output - An object containing the standard output (stdout) and standard error (stderr) of the CLI check. 41 | */ 42 | export interface CLICheckResult { 43 | success: boolean; 44 | prerequisites?: Array<{ name: string; url: string; success: boolean }>; 45 | exitCode: number; 46 | output: { 47 | stdout: string; 48 | stderr: string; 49 | }; 50 | } 51 | 52 | /** 53 | * interface representing the result of all the regions 54 | * @interface 55 | * @member default - The default region. 56 | * @member regions - An array containing all the regions. 57 | */ 58 | export interface RegionsResult { 59 | default: string; 60 | list: Array; 61 | } 62 | 63 | /** 64 | * interface representing the result of all the templates 65 | * @interface 66 | * @member list - An array containing all the templates. 67 | */ 68 | export interface TemplatesResult { 69 | list: Array<{ name: string; path: string }>; 70 | } 71 | -------------------------------------------------------------------------------- /vscode-extension/release.config.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | branches: ["main"], 3 | plugins: [ 4 | "@semantic-release/commit-analyzer", 5 | "@semantic-release/release-notes-generator", 6 | [ 7 | "semantic-release-vsce", 8 | { 9 | packageVsix: true, 10 | publish: true, 11 | publishPackagePath: false, 12 | }, 13 | ], 14 | "@semantic-release/github", 15 | ], 16 | }; 17 | 18 | module.exports = config; 19 | -------------------------------------------------------------------------------- /vscode-extension/src/extension.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { commands, ExtensionContext } from "vscode"; 17 | import { MainPanel } from "./panels/MainPanel"; 18 | 19 | /** 20 | * Activates the extension. 21 | * @param {ExtensionContext} context - The extension context. 22 | */ 23 | export function activate(context: ExtensionContext) { 24 | /** 25 | * Registers the command to show the main panel. 26 | */ 27 | context.subscriptions.push( 28 | commands.registerCommand("vals.showMainPanel", () => { 29 | MainPanel.render(context.extensionUri); 30 | }), 31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /vscode-extension/src/utilities/getNonce.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | /** 17 | * A helper function that returns a unique alphanumeric identifier called a nonce. 18 | * 19 | * @remarks This function is primarily used to help enforce content security 20 | * policies for resources/scripts being executed in a webview context. 21 | * 22 | * @returns A nonce 23 | */ 24 | export function getNonce() { 25 | let text = ""; 26 | const possible = 27 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 28 | for (let i = 0; i < 32; i++) { 29 | text += possible.charAt(Math.floor(Math.random() * possible.length)); 30 | } 31 | return text; 32 | } 33 | -------------------------------------------------------------------------------- /vscode-extension/src/utilities/getUri.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { Uri, Webview } from "vscode"; 17 | 18 | /** 19 | * A helper function which will get the webview URI of a given file or resource. 20 | * 21 | * @remarks This URI can be used within a webview's HTML as a link to the 22 | * given file/resource. 23 | * 24 | * @param webview A reference to the extension webview 25 | * @param extensionUri The URI of the directory containing the extension 26 | * @param pathList An array of strings representing the path to a file/resource 27 | * @returns A URI pointing to the file/resource 28 | */ 29 | export function getUri( 30 | webview: Webview, 31 | extensionUri: Uri, 32 | pathList: string[], 33 | ) { 34 | return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList)); 35 | } 36 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | .github/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "extends": [ 5 | "eslint:recommended", 6 | "plugin:@typescript-eslint/recommended", 7 | "plugin:react/recommended", 8 | "plugin:react-hooks/recommended", 9 | "plugin:prettier/recommended" 10 | ], 11 | "plugins": ["@typescript-eslint", "react", "react-hooks", "prettier"], 12 | "rules": { 13 | "prettier/prettier": "error", 14 | "semi": ["error", "always"], 15 | "quotes": ["error", "double"], 16 | "indent": ["error", 2], 17 | "comma-dangle": ["error", "always-multiline"], 18 | "no-console": "off", 19 | "no-unused-vars": "warn", 20 | "no-undef": "error", 21 | "no-extra-semi": "error", 22 | "no-unreachable": "error", 23 | "@typescript-eslint/no-explicit-any": "off" 24 | }, 25 | "env": { 26 | "browser": true, 27 | "node": true 28 | }, 29 | "settings": { 30 | "react": { 31 | "version": "detect" 32 | } 33 | }, 34 | "ignorePatterns": ["vscode.ts"] 35 | } 36 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist 4 | dist-ssr 5 | build 6 | build-ssr 7 | *.local 8 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-code-background: #FFFFFF; 3 | --dark-code-background: #1E1E1E; 4 | } 5 | 6 | @media (prefers-color-scheme: light) { :root { 7 | --code-background: var(--light-code-background); 8 | } } 9 | 10 | @media (prefers-color-scheme: dark) { :root { 11 | --code-background: var(--dark-code-background); 12 | } } 13 | 14 | :root[data-theme='light'] { 15 | --code-background: var(--light-code-background); 16 | } 17 | 18 | :root[data-theme='dark'] { 19 | --code-background: var(--dark-code-background); 20 | } 21 | 22 | pre, code { background: var(--code-background); } 23 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/assets/navigation.js: -------------------------------------------------------------------------------- 1 | window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE7WXXY+UMBSG/wvXoySr8WLuxv1INlGzMd5tNg0DZ3bqlBZLwVWz/90yMNDSUk5ivYLCed/zPqV8Pf5JFLyoZJvsqirZJFWmjnpQiqJhUKf64NujKpk+c6K8SLZXmyQ/UlZI4Mn2cRQXcMgapiaDQ8NzRQXvLYbTttWH969Pr5vRIqtoWmbyVIiffFdRN4suIEYBKtcBVH78PIjuKANfwrmxIwrmzkVZCQ5c1Yk/w62UQro4k46cK/51nh0/zKTftp3gRoqqYw2HtEpjprWNMbHvLj6o5E51xPCuN2qt57mQhZalu8tekGCsJ2N9RAafO4Zi3+iOD1J8h1ylH41BkMVUEVMVkWi5B4YrF/xAnxuZdb7ptTkKklk6YukisoW6IOlqwaDj6rZrRF0NGWrjUljOmOQFMFBwJpZlf3FunENBHteBuA4RKXH9cOwVE78uN9uNOVohNiqJpYvKudwFQ0c5VTRj9Dek9+NukGtSkEkRkcjvj2FhIs/YPW/FCdJP036QxtAQQxORZ6kDhohn7T6TC183qDdw70D+w/t37ozh+XLhWQ3cV8aPO/guhzXjVhIk/GhoTZUO+WCOggyWjli6iEShLpiLIaEUCob75asxCLKZKmKqIpIt98BwKSGYolX6rd8GaYZaMtRGZJg741acfjmf9/ydrU8O/ZRvaQHeu+lsQrzlKERLeT1mGvq0maTZfr2Tz8Vu/+7KYF+hM2cZ3dVPPf8V637a1qfTKkNN44KxS2JbBxrp5FPupobZH+6a80Wxsgr1UXhxJ+J8eAZuxlGU6fe1LmzrXBSex8hYQfoK1CTOzabV59j5XPUSM9Fa/Xh8A7x1w3VniD4zB3z6C6TrmAWpEQAA" -------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/assets/search.js: -------------------------------------------------------------------------------- 1 | window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE7VaXXOjNhT9LzzTOJKwHectu+nOZKbt7HQ6fclkGAJylwYDxdi7bSb/vRLI5l5zBSLLvgTLnHuke44+8CWvXlV83Xu3j6/eS5on3i33vTzaSe/WuytLz/cOVaY+74rkkMn9Qn139aXeZepGnEX7vVShnvfmn6JXwTk8kdvokNVniu0hj+u0yFsSc5cg870yqmRemxF03N3IojJd7KLqJSm+5ndl2huluh+C+64j3so6/vKrifuUZpIY+yV1L2Y4o8uRU9nFxa4scoXfL36uqqLqpdcBwgbw/Y70GJ3s6Q10LJujvtxXRanTH0wLIefND1NPThTnMJLxp9MIXJLugWfNu88+NfV+MiPZR3FcVImKWNydPg3lf4aHZ/isClD8UzWgUhpR4fmQZsnnqvhbxvXiA2gMaQGDQhg0qyL2XqbqYk9yRJ24yLfpX4cq0oNbfIStIX1QWIjCZlVoqJ+pGg2lOq7SvsikDtLXEWU0JDTQudVA3O9QAKUxknUiM1nLRqhq16p23/tqSIs+QdgnmFUhtx6n6uYmxKiaZVb8e1qj97A1rCEAhihsZuXs/UzXy57qiEppntZplKX/ycXD+eOQPl1A2AXMqgzdw1RN6MRG1MiKOMoe8mPxIhe/dJ+H9AAhIQiZVRFbH1M1saU3okoeHZ+jauHyTNdCwx/yRHfJPTX7yzTcsv6tuTjk3AJ/RMaG+Z35mgRGsi0rWcl/Duk+rVV2n2FrKHcUFqKwWZUY6meqLkOpjqhUyV1RS7OCfgeNIY1gUAiDZlXI3stUfexJjqhTF0VWp+Xij/Y6pImBhgY6qxKX3FPzv0yDzjqv5bcaP9WqI/eYJpLaLBp0SKIHcxddlyj4Y8t47ukYVWn0PN4XRTImzFCmpEvDokDPnIc6INY7xtr3sannjPqHUK5zlqbuq4DJx7oissYdkWM57CUusY0N4xTwfSPo9FZN+a2nb/PtoJ4dw6FOM/U4p6KO+7hI+jvvGRC2ANf1dUHXrageoZUXSNIbJpXLUZ05P8n82MtB3wjVDWrsT75R8fbVO8pqr38K3Xr8SlxtFHKbyizR9e22D19vbDs9pCdz70/1o6CoNKKFLK49//HaF8HVOtg8PfmPp4jmRvNFA2OqxfzN1Wa1QiiGUFy1OEXGEUyolqBgAsEC1QooWIBgS8vQlgi1Uq0lRbZCsLWFbI1QN6q1oshuEGxjIdtgabXSa4qNXXhgNQG7wLTaNyQh9oEJGyE2gmnBNyQhtoLZvGDYDKZFZ+S0Y9gPZjOEYUeYVp4xkhGbwmyuMGwL1+IzejZjX7jNF36xOrT6jJz4HBvDbcZwbAzX8jNyjXDsDLc5w7EzvHGGXCgcO8NtznDsDG+cIVcLx85wmzMcOyMaZ8gVI7AzwuaMwM6IxhlyyYiLrcvmjMDOiMYZcs0I7IywOSOwM0LLz8k1I7AzQhvAybUgsDdCG8DJOS6wN0JbwOlNG7sTaAs4vW9jdwJtAifnWoD9CZqDhZxDAfYn0DZwcm4EF6eLtoGTngfYoUAbwTc+V8ilEuvafMIxrVvN8azO5VomD+0xrQ5a+Bo00i9wX73QHOLnp4FXj6s/b2/dka1buodIv5juIq67iGtLBPkGJ+peSnVk646MObA17z1KU2iEDch5AzhtOVnfE8T4lUjHugGsgRNrU3uPT68QOiYGFFSnzShVW46OYTm6/xXqgIEOblw60BXbk6yohWjhXHEwS7aP+h1B0MU7KCibV7/JuerX8Sw7Hgf5zr8xKKpVR+UgFCjqpqBaDSQSQCKHuddURNO21AE+I0qgGneQzZTdqGQZEI47KGeoclOCBERANu6gGy55lbi6B2jBbiAcJlhbKTLywQYiBduBcLDkVH6pT1UkQAX2AGG3Amwg8alOAjZcsDjVaehAUp5/vAMWsBaF3YH2d/E4G9iRhH1itGzNsiZZwORXZzLNci6hAVnBbqVxvrdsL+v2smkvzNxUvw3aq0ExA2MGxw2OGxw3OG5w3OCEwQmDE0vLkJtfyN1wBRArsMZYRYKboG2ON//ldDqwtyk+PqDKlnhT5gC9ggUb2BbBYS97WzYHW0bAbIG9mgggAGs6sI1X1xtQ0MZBYqIvsNQDcn2qp6MyLaXaZhXo8ent7X8w6i8tkCcAAA=="; -------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/index.html: -------------------------------------------------------------------------------- 1 | vscode-aws-lambda-swift

vscode-aws-lambda-swift

VSCODE AWS LAMBDA SWIFT

Description

This project is currently under construction.

2 |
-------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/modules/App.html: -------------------------------------------------------------------------------- 1 | App | vscode-aws-lambda-swift

Index

Functions

default 2 |
-------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/modules/index.html: -------------------------------------------------------------------------------- 1 | index | vscode-aws-lambda-swift
-------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/modules/vite_env.html: -------------------------------------------------------------------------------- 1 | vite-env | vscode-aws-lambda-swift
-------------------------------------------------------------------------------- /vscode-extension/webview-ui/docs/variables/utilities_vscode.vscode.html: -------------------------------------------------------------------------------- 1 | vscode | vscode-aws-lambda-swift
vscode: VSCodeAPIWrapper = ...
-------------------------------------------------------------------------------- /vscode-extension/webview-ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | VSCODE AWS LAMBDA SWIFT 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-aws-lambda-swift", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "vite", 7 | "build": "npm install && tsc && vite build", 8 | "preview": "vite preview", 9 | "docs": "typedoc --out docs --entryPointStrategy expand src", 10 | "lint": "ESLINT_USE_FLAT_CONFIG=false eslint ./src --ext .tsx,.ts", 11 | "lint:fix": "ESLINT_USE_FLAT_CONFIG=false eslint ./src --ext .tsx,.ts --fix" 12 | }, 13 | "dependencies": { 14 | "@vscode/webview-ui-toolkit": "^1.4.0", 15 | "i18next": "^24.2.2", 16 | "react": "^19.0.0", 17 | "react-dom": "^19.0.0", 18 | "react-i18next": "^15.4.1", 19 | "react-icons": "^5.5.0", 20 | "react-markdown": "^10.1.0" 21 | }, 22 | "devDependencies": { 23 | "@types/react": "^19.0.10", 24 | "@types/react-dom": "^19.0.4", 25 | "@types/vscode-webview": "^1.57.5", 26 | "@typescript-eslint/eslint-plugin": "^8.26.1", 27 | "@vitejs/plugin-react": "^4.3.4", 28 | "eslint": "^9.22.0", 29 | "eslint-config-prettier": "^10.1.1", 30 | "eslint-plugin-prettier": "^5.2.3", 31 | "eslint-plugin-react": "^7.37.4", 32 | "eslint-plugin-react-hooks": "^5.2.0", 33 | "prettier": "^3.5.3", 34 | "typedoc": "^0.27.9", 35 | "typescript": "^5.8.2", 36 | "vite": "^6.2.1" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/App.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | * { 18 | font-family: "Inter", sans-serif; 19 | } 20 | 21 | main { 22 | display: flex; 23 | flex-direction: column; 24 | justify-content: center; 25 | align-items: flex-start; 26 | height: 100%; 27 | width: 775px; 28 | margin: 0 auto; 29 | } 30 | 31 | h1 { 32 | font-size: 1.5rem; 33 | } 34 | 35 | .label-input { 36 | display: flex; 37 | flex-direction: column; 38 | gap: 0.5rem; 39 | } 40 | 41 | .init-container { 42 | background-color: var(--vscode-editorGroupHeader-tabsBackground); 43 | padding: 1.5rem; 44 | display: grid; 45 | grid-template-columns: repeat(3, 1fr); 46 | gap: 1rem; 47 | position: relative; 48 | } 49 | 50 | .button-container { 51 | grid-column: 3; 52 | margin-left: auto; 53 | width: 100%; 54 | } 55 | 56 | .button-container { 57 | margin-top: auto; 58 | } 59 | 60 | .button-container vscode-button { 61 | width: 100%; 62 | } 63 | 64 | .dropdown-container { 65 | display: flex; 66 | gap: 5px; 67 | } 68 | 69 | .dropdown-container vscode-dropdown { 70 | flex-grow: 1; 71 | } 72 | 73 | .app-loading-container { 74 | position: fixed; 75 | top: 0; 76 | left: 0; 77 | width: 100%; 78 | height: 100%; 79 | display: flex; 80 | justify-content: center; 81 | align-items: center; 82 | background-color: rgba(0, 0, 0, 0.5); 83 | z-index: 9999; 84 | } 85 | 86 | .app-loading-ring { 87 | width: 50px; 88 | height: 50px; 89 | } -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/api/markdownApi.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | // This file contains the API for fetching Markdown files from the specified template repository. 17 | const GITHUB_API_URL = 18 | process.env.GITHUB_API_URL || 19 | "https://raw.githubusercontent.com/swift-server-community/aws-lambda-swift-sam-template"; 20 | 21 | /** 22 | * Fetches a Markdown file from the specified template repository. 23 | * @param {string} template - The name of the template repository. 24 | * @returns {Promise} - A promise that resolves to the content of the Markdown file. 25 | * @throws {Error} - If fetching the Markdown file fails. 26 | */ 27 | export async function fetchMarkdownFile( 28 | template: string, 29 | branch: string = "main", 30 | ): Promise { 31 | // Constructing the URL of the Markdown file 32 | const url = `${GITHUB_API_URL}/${branch}/${template}/doc/INFO.md`; 33 | 34 | try { 35 | // Fetching the Markdown file 36 | const response = await fetch(url); 37 | 38 | // Checking if the response is successful 39 | if (!response.ok) { 40 | // Throwing an error if fetching fails 41 | throw new Error(`Failed to fetch Markdown file: ${response.statusText}`); 42 | } 43 | 44 | // Returning the content of the Markdown file 45 | return await response.text(); 46 | } catch (error) { 47 | // Logging and rethrowing any errors that occur during fetching 48 | return "# Error fetching Markdown file\n\n" + error; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/Error.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | .error-container { 18 | position: relative; 19 | background-color: var(--vscode-debugToolBar-background); 20 | border-width: 2px; 21 | border-style: solid; 22 | width: 100%; 23 | display: flex; 24 | border-width: 0; 25 | box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); 26 | } 27 | 28 | .error-content { 29 | display: flex; 30 | flex-direction: column; 31 | gap: 5px; 32 | padding: 20px; 33 | } 34 | 35 | .error-icon { 36 | width: 100px; 37 | min-width: 100px; 38 | margin-left: auto; 39 | display: flex; 40 | align-items: center; 41 | justify-content: center; 42 | background-color: var(--vscode-editorMarkerNavigationError-background); 43 | } 44 | 45 | .close-icon svg { 46 | position: absolute; 47 | top: 5px; 48 | right: 5px; 49 | cursor: pointer; 50 | } 51 | 52 | .error-type { 53 | font-weight: bold; 54 | margin-bottom: 5px; 55 | } 56 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/Error.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import React from "react"; 17 | import { useError } from "../context/ErrorProvider"; 18 | import { VscClose, VscBracketError } from "react-icons/vsc"; 19 | import "./Error.css"; 20 | 21 | /** 22 | * Represents a component for displaying error messages. 23 | * @returns {JSX.Element} - The rendered Error component. 24 | */ 25 | const Error = () => { 26 | // Accessing error state and setError function from ErrorProvider context 27 | const { error, setError } = useError(); 28 | 29 | // Function to clear the error message 30 | const clearError = () => { 31 | setError(null); 32 | }; 33 | 34 | return ( 35 | <> 36 | {/* Rendering error message if error state exists */} 37 | {error && ( 38 |
39 | {/* Close icon to clear the error */} 40 |
41 | 42 |
43 | {/* Error content */} 44 |
45 | {/* Error type */} 46 |
TYPE: {error.name}
47 | {/* Error message */} 48 |
MESSAGE: {error.message}
49 |
50 | {/* Error icon */} 51 |
52 | 53 |
54 |
55 | )} 56 | 57 | ); 58 | }; 59 | 60 | export default Error; 61 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/EventsDropdown.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { vscode } from "../utilities/vscode"; 17 | import React, { useContext, useState, useEffect, useCallback } from "react"; 18 | import { 19 | VSCodeDropdown, 20 | VSCodeOption, 21 | VSCodeButton, 22 | } from "@vscode/webview-ui-toolkit/react"; 23 | import { ConfigurationContext } from "../context/ConfigurationProvider"; 24 | import { VscRefresh } from "react-icons/vsc"; 25 | import { useTranslation } from "react-i18next"; 26 | 27 | /** 28 | * Props for the EventsDropdown component. 29 | */ 30 | interface EventsDropdownProps { 31 | selectedEvent: string; 32 | // eslint-disable-next-line no-unused-vars 33 | setSelectedEvent: (event: string) => void; 34 | } 35 | 36 | /** 37 | * Represents a dropdown component for selecting events. 38 | * @param {Object} EventsDropdownProps - Props for the EventsDropdown component. 39 | * @param {string} EventsDropdownProps.selectedEvent - The currently selected event. 40 | * @param {Function} EventsDropdownProps.setSelectedEvent - Function to set the selected event. 41 | * @returns {JSX.Element} - The rendered EventsDropdown component. 42 | */ 43 | const EventsDropdown: React.FC = ({ 44 | selectedEvent, 45 | setSelectedEvent, 46 | }) => { 47 | // Accessing translation function 48 | const { t } = useTranslation("global"); 49 | // Accessing configuration state and setConfiguration function from ConfigurationProvider context 50 | const { configuration, setConfiguration } = useContext(ConfigurationContext); 51 | // State for loading status 52 | const [isLoading, setIsLoading] = useState(false); 53 | 54 | // Function to fetch events list 55 | const refreshEvents = useCallback(() => { 56 | setIsLoading(true); 57 | // Sending message to VS Code extension to fetch events 58 | vscode.postMessage({ 59 | command: "events", 60 | data: { 61 | path: configuration.projectFolder + "/" + configuration.projectName, 62 | }, 63 | }); 64 | // Listening for messages from VS Code extension 65 | window.addEventListener("message", (event) => { 66 | const message = event.data; 67 | if (message.command === "events" && message.data.success) { 68 | setConfiguration((prevConfig) => ({ 69 | ...prevConfig, 70 | eventsList: message.data.events, 71 | })); 72 | // Setting the selected event to the first event in the list 73 | setSelectedEvent(message.data.events[0]); 74 | setIsLoading(false); 75 | } else { 76 | if (message.command === "events" && !message.data.success) { 77 | // Handling errors by resetting events list and selected event 78 | setConfiguration((prevConfig) => ({ 79 | ...prevConfig, 80 | eventsList: [], 81 | })); 82 | setSelectedEvent(""); 83 | setIsLoading(false); 84 | } 85 | } 86 | }); 87 | }, [ 88 | configuration.projectFolder, 89 | configuration.projectName, 90 | setConfiguration, 91 | setSelectedEvent, 92 | ]); 93 | 94 | // Fetches events list on mount and whenever projectName changes 95 | useEffect(() => { 96 | refreshEvents(); 97 | }, [configuration.projectName, refreshEvents]); 98 | 99 | return ( 100 |
101 | {/* Label for the events dropdown */} 102 | 103 |
104 | {/* Dropdown component to select events */} 105 | { 109 | setSelectedEvent(e.target.value); 110 | }} 111 | > 112 | {/* Mapping through events list to render options */} 113 | {configuration.eventsList.map((event) => ( 114 | 115 | {event} 116 | 117 | ))} 118 | 119 | {/* Button to refresh events list */} 120 | 125 | 126 | 127 |
128 |
129 | ); 130 | }; 131 | 132 | export default EventsDropdown; 133 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/FunctionsDropdown.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { vscode } from "../utilities/vscode"; 17 | import React, { useContext, useState, useEffect, useCallback } from "react"; 18 | import { 19 | VSCodeDropdown, 20 | VSCodeOption, 21 | VSCodeButton, 22 | } from "@vscode/webview-ui-toolkit/react"; 23 | import { ConfigurationContext } from "../context/ConfigurationProvider"; 24 | import { VscRefresh } from "react-icons/vsc"; 25 | import { useTranslation } from "react-i18next"; 26 | 27 | /** 28 | * Props for the FunctionsDropdown component. 29 | */ 30 | interface FunctionsDropdownProps { 31 | selectedFunction: string; 32 | // eslint-disable-next-line no-unused-vars 33 | setSelectedFunction: (func: string) => void; 34 | } 35 | 36 | /** 37 | * Represents a dropdown component for selecting functions. 38 | * @param {Object} FunctionsDropdownProps - Props for the FunctionsDropdown component. 39 | * @param {string} FunctionsDropdownProps.selectedFunction - The currently selected function. 40 | * @param {Function} FunctionsDropdownProps.setSelectedFunction - Function to set the selected function. 41 | * @returns {JSX.Element} - The rendered FunctionsDropdown component. 42 | */ 43 | const FunctionsDropdown: React.FC = ({ 44 | selectedFunction, 45 | setSelectedFunction, 46 | }) => { 47 | // Accessing translation function 48 | const { t } = useTranslation("global"); 49 | // Accessing configuration state and setConfiguration function from ConfigurationProvider context 50 | const { configuration, setConfiguration } = useContext(ConfigurationContext); 51 | // State for loading status 52 | const [isLoading, setIsLoading] = useState(false); 53 | 54 | // Function to fetch functions list 55 | const refreshFunctions = useCallback(() => { 56 | setIsLoading(true); 57 | // Sending message to VS Code extension to fetch functions 58 | vscode.postMessage({ 59 | command: "functions", 60 | data: { 61 | path: configuration.projectFolder + "/" + configuration.projectName, 62 | }, 63 | }); 64 | // Listening for messages from VS Code extension 65 | window.addEventListener("message", (event) => { 66 | const message = event.data; 67 | if (message.command === "functions" && message.data.success) { 68 | // Updating configuration context with fetched functions list 69 | setConfiguration((prevConfig) => ({ 70 | ...prevConfig, 71 | functionsList: message.data.functions, 72 | })); 73 | // Setting the selected function to the first function in the list 74 | setSelectedFunction(message.data.functions[0]); 75 | setIsLoading(false); 76 | } else { 77 | if (message.command === "functions" && !message.data.success) { 78 | // Handling errors by resetting functions list and selected function 79 | setConfiguration((prevConfig) => ({ 80 | ...prevConfig, 81 | functionsList: [], 82 | })); 83 | setSelectedFunction(""); 84 | setIsLoading(false); 85 | } 86 | } 87 | }); 88 | }, [ 89 | configuration.projectFolder, 90 | configuration.projectName, 91 | setConfiguration, 92 | setSelectedFunction, 93 | ]); 94 | 95 | // Fetches functions list on mount and whenever projectName changes 96 | useEffect(() => { 97 | refreshFunctions(); 98 | }, [configuration.projectName, refreshFunctions]); 99 | 100 | return ( 101 |
102 | {/* Label for the functions dropdown */} 103 | 104 |
105 | {/* Dropdown component to select functions */} 106 | { 110 | setSelectedFunction(e.target.value); 111 | }} 112 | > 113 | {/* Mapping through functions list to render options */} 114 | {configuration.functionsList.map((func) => ( 115 | 116 | {func} 117 | 118 | ))} 119 | 120 | {/* Button to refresh functions list */} 121 | 126 | 127 | 128 |
129 |
130 | ); 131 | }; 132 | 133 | export default FunctionsDropdown; 134 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/accordion/Accordion.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | .accordion-parent { 18 | width: 100%; 19 | display: flex; 20 | flex-direction: column; 21 | gap: 0.5rem; 22 | margin-bottom: 2rem; 23 | } 24 | 25 | .accordion { 26 | display: flex; 27 | flex-direction: column; 28 | width: 100%; 29 | } 30 | 31 | .accordion .content-parent { 32 | max-height: 0; 33 | overflow: hidden; 34 | transition: max-height 0.15s ease-out; 35 | } 36 | 37 | .accordion.toggled .content-parent{ 38 | max-height: 1000px; 39 | transition: max-height 0.15s ease-in; 40 | } 41 | 42 | .accordion .content-parent { 43 | padding: 0 2rem; 44 | } 45 | 46 | .accordion .toggle { 47 | display: flex; 48 | justify-content: space-between; 49 | align-items: center; 50 | cursor: pointer; 51 | background-color: var(--vscode-activityBar-border); 52 | height: 2.5rem; 53 | padding: 0 1rem; 54 | } 55 | 56 | .step-title { 57 | flex-grow: 1; 58 | font-weight: bold; 59 | padding: 0 2rem; 60 | } 61 | 62 | .accordion svg { 63 | transition: transform 0.15s ease-in; 64 | } 65 | 66 | .accordion.toggled .direction-indicator svg { 67 | transform: rotate(90deg); 68 | } 69 | 70 | .step-indicator svg { 71 | color: #FFA16C; 72 | } 73 | 74 | .green svg { 75 | color: #5BFF6C; 76 | } -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/accordion/Accordion.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import React, { useEffect, useState, JSX } from "react"; 17 | import { VscCircleLarge, VscCheckAll, VscChevronRight } from "react-icons/vsc"; 18 | import { VSCodeProgressRing } from "@vscode/webview-ui-toolkit/react"; 19 | import "./Accordion.css"; 20 | 21 | /** 22 | * Interface representing a step in the accordion. 23 | */ 24 | interface Step { 25 | id: number; 26 | title: string; 27 | done: boolean; 28 | isLoading: boolean; 29 | toggled?: boolean; 30 | renderContent: () => JSX.Element; 31 | } 32 | 33 | /** 34 | * Props for the Accordion component. 35 | */ 36 | interface AccordionProps { 37 | items: Step[]; 38 | } 39 | 40 | /** 41 | * Accordion component for displaying a list of steps. 42 | * @param items The array of steps to display in the accordion. 43 | * @returns The rendered Accordion component. 44 | */ 45 | const Accordion: React.FC = ({ items }) => { 46 | // State to manage accordion items 47 | const [accordionItems, setAccordionItems] = useState(items); 48 | 49 | // Effect to update accordion items when the provided items change 50 | useEffect(() => { 51 | if (items.some((item) => item.isLoading)) setAccordionItems(items); 52 | else 53 | setAccordionItems([ 54 | ...items.map((item) => ({ 55 | ...item, 56 | toggled: false, 57 | })), 58 | ]); 59 | }, [items]); 60 | 61 | /** 62 | * Handles toggling of accordion items. 63 | * @param step The step to toggle. 64 | */ 65 | function handleAccordionToggle(step: Step) { 66 | setAccordionItems( 67 | accordionItems.map((item) => { 68 | if (item.id === step.id) { 69 | return { 70 | ...item, 71 | toggled: !item.toggled, 72 | }; 73 | } 74 | return { ...item, toggled: false }; 75 | }), 76 | ); 77 | } 78 | 79 | return ( 80 |
81 | {/* Render each accordion item */} 82 | {accordionItems?.map((step, key) => { 83 | return ( 84 |
88 |
handleAccordionToggle(step)}> 89 |
90 | 91 |
92 |
93 |

{step.title}

94 |
95 | {/* Render loading, done, or undone indicator */} 96 | {step.isLoading ? ( 97 | 98 | ) : step.done ? ( 99 |
100 | 101 |
102 | ) : ( 103 |
104 | 105 |
106 | )} 107 |
108 | {/* Render step content */} 109 |
110 |
{step.renderContent()}
111 |
112 |
113 | ); 114 | })} 115 |
116 | ); 117 | }; 118 | 119 | export default Accordion; 120 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/buildProject/BuildProject.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { vscode } from "../../utilities/vscode"; 17 | import React, { useContext, useState, useEffect } from "react"; 18 | import { ConfigurationContext } from "../../context/ConfigurationProvider"; 19 | import { 20 | VSCodeTextField, 21 | VSCodeButton, 22 | } from "@vscode/webview-ui-toolkit/react"; 23 | import Tooltip from "../tooltip/Tooltip"; 24 | import { useTranslation } from "react-i18next"; 25 | import { useError } from "../../context/ErrorProvider"; 26 | 27 | /** 28 | * Props for the BuildProject component. 29 | */ 30 | interface BuildProps { 31 | onComplete: () => void; 32 | // eslint-disable-next-line no-unused-vars 33 | setLoading: (isLoading: boolean) => void; 34 | } 35 | 36 | /** 37 | * Component for building the project. 38 | * @param onComplete Callback function to execute upon completion. 39 | * @param setLoading Function to set loading state. 40 | * @returns The rendered BuildProject component. 41 | */ 42 | const BuildProject: React.FC = ({ onComplete, setLoading }) => { 43 | // Context hooks 44 | const { setError } = useError(); 45 | const { t } = useTranslation("global"); 46 | const { configuration } = useContext(ConfigurationContext); 47 | 48 | // State for build folder path 49 | const [buildFolder, setBuildFolder] = useState( 50 | configuration.projectFolder + "/" + configuration.projectName, 51 | ); 52 | 53 | // Effect to update build folder path when configuration changes 54 | useEffect(() => { 55 | setBuildFolder( 56 | configuration.projectFolder + "/" + configuration.projectName, 57 | ); 58 | }, [configuration.projectName, configuration.projectFolder]); 59 | 60 | /** 61 | * Handles building the project. 62 | */ 63 | const handleBuild = () => { 64 | setLoading(true); 65 | // Send build project command to VSCode 66 | vscode.postMessage({ 67 | command: "buildProject", 68 | data: { 69 | path: buildFolder, 70 | }, 71 | }); 72 | // Listen for response from VSCode 73 | window.addEventListener("message", (event) => { 74 | const message = event.data; 75 | if (message.command === "buildProject" && message.data.success) { 76 | onComplete(); // Callback on successful build 77 | setLoading(false); 78 | } else { 79 | if (message.command === "buildProject" && !message.data.success) { 80 | setError(message.data.error); // Set error message on build failure 81 | console.debug("Error building project"); 82 | setLoading(false); 83 | } 84 | } 85 | }); 86 | }; 87 | 88 | return ( 89 |
90 | {/* Build folder input */} 91 |
92 | 95 | { 99 | setBuildFolder(e.target.value); 100 | }} 101 | placeholder={t("buildProject.form.buildFolder.placeholder")} 102 | /> 103 |
104 | 105 | {/* Build button */} 106 |
107 | 108 | {t("buildProject.button")} 109 | 110 |
111 | 112 | {/* Tooltip for build project information */} 113 | 114 |
115 | ); 116 | }; 117 | 118 | export default BuildProject; 119 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/configuration/Configuration.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | .configuration-parent { 18 | width: 100%; 19 | } 20 | 21 | .configuration-container { 22 | background-color: var(--vscode-editorGroupHeader-tabsBackground); 23 | padding: 1.5rem; 24 | display: grid; 25 | grid-template-columns: 2fr 1fr; 26 | gap: 1rem; 27 | } 28 | 29 | .path-input { 30 | width: 100%; 31 | display: flex; 32 | } 33 | 34 | .path-input-path, .path-input-name { 35 | display: flex; 36 | flex-direction: column; 37 | gap: 0.5rem; 38 | } 39 | 40 | .slash-separator { 41 | font-size: 1.5rem; 42 | margin: 0 0.3rem; 43 | } 44 | 45 | .path-input-path { 46 | flex: 3; 47 | } 48 | 49 | .path-input-name { 50 | flex: 1; 51 | } 52 | 53 | .error-message { 54 | color: var(--vscode-errorForeground) !important; 55 | font-size: 0.8rem !important; 56 | } 57 | 58 | .error-textField { 59 | border: 1px solid var(--vscode-inputValidation-errorBorder) !important; 60 | border-radius: calc(var(--corner-radius-round) * 1px); 61 | } -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/configuration/Configuration.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import React, { useContext, useState, useEffect } from "react"; 17 | import { vscode } from "../../utilities/vscode"; 18 | import { 19 | VSCodeTextField, 20 | VSCodeDropdown, 21 | VSCodeOption, 22 | } from "@vscode/webview-ui-toolkit/react"; 23 | import { ConfigurationContext } from "../../context/ConfigurationProvider"; 24 | import "./Configuration.css"; 25 | import { useTranslation } from "react-i18next"; 26 | 27 | /** 28 | * Component for configuring project settings. 29 | * @returns The rendered Configuration component. 30 | */ 31 | const Configuration = () => { 32 | // Hooks for translation and context 33 | const [t] = useTranslation("global"); 34 | const { configuration, setConfiguration } = useContext(ConfigurationContext); 35 | const [errorFolder, setErrorFolder] = useState(""); 36 | const [errorName, setErrorName] = useState(""); 37 | 38 | const checkExists = (path: string, type: string) => { 39 | if (path) { 40 | vscode.postMessage({ 41 | command: "checkExists", 42 | data: { 43 | path, 44 | type, 45 | }, 46 | }); 47 | } else { 48 | if (type === "folder") setErrorFolder(t("configuration.error.emptyPath")); 49 | else if (type === "name") 50 | setErrorName(t("configuration.error.emptyName")); 51 | } 52 | }; 53 | 54 | useEffect(() => { 55 | const listener = (event: any) => { 56 | if (event.data.command === "checkResult") { 57 | const { exists, type } = event.data.data; 58 | if (type === "folder") { 59 | setErrorFolder( 60 | exists ? "" : t("configuration.error.folderDoesNotExist"), 61 | ); 62 | } else if (type === "name") { 63 | setErrorName(exists ? t("configuration.error.alreadyExists") : ""); 64 | } 65 | } 66 | }; 67 | 68 | window.addEventListener("message", listener); 69 | 70 | return () => { 71 | window.removeEventListener("message", listener); 72 | }; 73 | }, [t]); 74 | 75 | return ( 76 |
77 |

{t("configuration.title")}

78 |
79 |
80 |
81 | 84 | { 88 | setConfiguration({ 89 | ...configuration, 90 | projectFolder: e.target.value, 91 | }); 92 | }} 93 | onBlur={(e: any) => { 94 | checkExists(e.target.value, "folder"); 95 | }} 96 | placeholder={t("configuration.form.projectFolder.placeholder")} 97 | className={errorFolder ? "error-textField" : ""} 98 | /> 99 | {errorFolder &&
{errorFolder}
} 100 | {errorName &&
{errorName}
} 101 |
102 |
103 |

/

104 |
105 |
106 | 109 | { 113 | setConfiguration({ 114 | ...configuration, 115 | projectName: e.target.value, 116 | }); 117 | }} 118 | onBlur={(e: any) => { 119 | checkExists( 120 | e.target.value 121 | ? configuration.projectFolder + "/" + e.target.value 122 | : e.target.value, 123 | "name", 124 | ); 125 | }} 126 | placeholder={t("configuration.form.projectName.placeholder")} 127 | className={errorName ? "error-textField" : ""} 128 | /> 129 |
130 |
131 | 132 | {/* Region */} 133 |
134 | 137 | { 141 | setConfiguration({ 142 | ...configuration, 143 | region: e.target.value, 144 | }); 145 | }} 146 | > 147 | {configuration.regionList.map((region) => ( 148 | 149 | {region} 150 | 151 | ))} 152 | 153 |
154 |
155 |
156 | ); 157 | }; 158 | 159 | export default Configuration; 160 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/console/Console.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | .console-container { 18 | width: 100%; 19 | margin-bottom: 50px; 20 | } 21 | 22 | .console-output { 23 | padding: 1rem; 24 | height: 200px; 25 | overflow-y: auto; 26 | background-color: var(--vscode-activityBar-border); 27 | color: var(--vscode-editor-foreground); 28 | white-space: nowrap; 29 | overflow-x: auto; 30 | } 31 | .console-output pre { 32 | line-height: 1em; 33 | margin: 0; 34 | } 35 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/console/Console.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { vscode } from "./../../utilities/vscode"; 17 | import React, { useState, useRef, useEffect } from "react"; 18 | import { useTranslation } from "react-i18next"; 19 | import "./Console.css"; 20 | 21 | /** 22 | * Component for displaying console messages. 23 | * @returns The rendered Console component. 24 | */ 25 | const Console = () => { 26 | // Hooks for translation and state management 27 | const { t } = useTranslation("global"); 28 | const [consoleMessages, setConsoleMessages] = useState([]); 29 | const consoleRef = useRef(null); 30 | 31 | // Effect to scroll to the bottom of the console on message update 32 | useEffect(() => { 33 | if (consoleRef.current) { 34 | consoleRef.current.scrollTop = consoleRef.current.scrollHeight; 35 | } 36 | }, [consoleMessages]); 37 | 38 | // Effect to listen for console messages from VSCode 39 | useEffect(() => { 40 | vscode.postMessage({ command: "console" }); 41 | window.addEventListener("message", handleMessage); 42 | return () => { 43 | window.removeEventListener("message", handleMessage); 44 | }; 45 | }, []); 46 | 47 | /** 48 | * Handles incoming console messages. 49 | * @param event The event containing the console message. 50 | */ 51 | const handleMessage = (event: MessageEvent) => { 52 | const message = event.data; 53 | if (message.command === "console") { 54 | setConsoleMessages((prev) => [...prev, message.data]); 55 | } 56 | }; 57 | 58 | return ( 59 |
60 | {/* Console title */} 61 |

{t("console.title")}

62 | {/* Console output */} 63 |
64 | {consoleMessages.map((message, index) => ( 65 |
{message}
66 | ))} 67 |
68 |
69 | ); 70 | }; 71 | 72 | export default Console; 73 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/deleteConfirmation/DeleteConfirmation.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | .modal-overlay { 18 | position: fixed; 19 | top: 0; 20 | left: 0; 21 | width: 100%; 22 | height: 100%; 23 | background-color: rgba(0, 0, 0, 0.5); 24 | display: flex; 25 | justify-content: center; 26 | align-items: center; 27 | z-index: 1000; 28 | } 29 | 30 | .modal { 31 | background-color: var(--vscode-editorGroupHeader-tabsBackground); 32 | border-radius: 8px; 33 | padding: 20px; 34 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); 35 | width: 300px; 36 | } 37 | 38 | .close { 39 | position: relative; 40 | cursor: pointer; 41 | } 42 | 43 | .confirmation-container { 44 | width: 100%; 45 | margin: 20px 0px; 46 | } 47 | 48 | .confirmation-container p { 49 | margin: 0; 50 | } 51 | 52 | .button-container { 53 | width: 100%; 54 | display: flex; 55 | gap: 10px; 56 | justify-content: flex-end; 57 | margin-top: 20px; 58 | } 59 | 60 | .delete-success { 61 | display: flex; 62 | align-items: center; 63 | gap: 10px; 64 | color: green; 65 | margin-top: 10px; 66 | } 67 | 68 | .dangerButton { 69 | background-color: var(--vscode-errorForeground); 70 | color: white; 71 | } -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/deployProject/DeployProject.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { vscode } from "../../utilities/vscode"; 17 | import React, { useContext } from "react"; 18 | import { 19 | VSCodeTextField, 20 | VSCodeButton, 21 | } from "@vscode/webview-ui-toolkit/react"; 22 | import Tooltip from "../tooltip/Tooltip"; 23 | import { ConfigurationContext } from "../../context/ConfigurationProvider"; 24 | import { useTranslation } from "react-i18next"; 25 | import { useError } from "../../context/ErrorProvider"; 26 | 27 | /** 28 | * Props for the DeployProject component. 29 | */ 30 | interface DeployProjectProps { 31 | onComplete: () => void; 32 | // eslint-disable-next-line no-unused-vars 33 | setLoading: (isLoading: boolean) => void; 34 | } 35 | 36 | /** 37 | * Component for deploying a project. 38 | * @param onComplete Callback function to execute upon completion of deployment. 39 | * @param setLoading Function to set loading state during deployment. 40 | * @returns The rendered DeployProject component. 41 | */ 42 | const DeployProject: React.FC = ({ 43 | onComplete, 44 | setLoading, 45 | }) => { 46 | // Hooks for error handling, translation, and configuration context 47 | const { setError } = useError(); 48 | const { t } = useTranslation("global"); 49 | const { configuration, setConfiguration } = useContext(ConfigurationContext); 50 | 51 | /** 52 | * Handles project deployment. 53 | */ 54 | const handleDeployProject = () => { 55 | setLoading(true); 56 | vscode.postMessage({ 57 | command: "deployProject", 58 | data: { 59 | path: configuration.projectFolder + "/" + configuration.projectName, 60 | stackName: configuration.stackName, 61 | region: configuration.region, 62 | }, 63 | }); 64 | window.addEventListener("message", (event) => { 65 | const message = event.data; 66 | if (message.command === "deployProject" && message.data.success) { 67 | onComplete(); 68 | setLoading(false); 69 | } else { 70 | if (message.command === "deployProject" && !message.data.success) { 71 | setError(message.data.error); 72 | setLoading(false); 73 | console.debug("Error deploying project"); 74 | } 75 | } 76 | }); 77 | }; 78 | 79 | return ( 80 |
81 | {/* Stack name input */} 82 |
83 | 86 | { 90 | setConfiguration((prevConfig) => ({ 91 | ...prevConfig, 92 | stackName: e.target.value, 93 | })); 94 | }} 95 | placeholder={t("deployProject.form.stackName.placeholder")} 96 | /> 97 |
98 | 99 | {/* Deploy button */} 100 |
101 | 102 | {t("deployProject.button")} 103 | 104 |
105 | 106 | {/* Tooltip for deployment information */} 107 | 108 |
109 | ); 110 | }; 111 | 112 | export default DeployProject; 113 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/initialize/Initialize.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | .loading-ring-container, .loading-ring { 18 | height: 100%; 19 | } 20 | 21 | .markdown-container { 22 | display: flex; 23 | flex-direction: column; 24 | max-height: 100%; 25 | gap: 0.5rem; 26 | grid-column-start: 1; 27 | grid-column-end: 4; 28 | } 29 | 30 | .markdown-container p:first-child { 31 | margin: 0; 32 | } 33 | 34 | .markdown { 35 | padding: 1rem; 36 | background-color: var(--dropdown-background); 37 | max-height: 250px; 38 | overflow-y: auto; 39 | } 40 | 41 | .visual-representation-container { 42 | display: flex; 43 | flex-direction: column; 44 | max-height: 100%; 45 | grid-column-start: 1; 46 | grid-column-end: 4; 47 | gap: 0.5rem; 48 | } 49 | 50 | .visual-representation-container p { 51 | margin: 0; 52 | } 53 | 54 | .visual-representation { 55 | display: flex; 56 | justify-content: center; 57 | align-items: center; 58 | max-width: 100%; 59 | max-height: 400px; 60 | padding: 1rem; 61 | background-color: var(--dropdown-background); 62 | } 63 | 64 | .visual-representation img { 65 | width: auto; 66 | max-height: 100%; 67 | object-fit: contain; 68 | } 69 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/localInvoke/LocalInvoke.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { vscode } from "../../utilities/vscode"; 17 | import React, { useContext, useState } from "react"; 18 | import { ConfigurationContext } from "../../context/ConfigurationProvider"; 19 | import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"; 20 | import Tooltip from "../tooltip/Tooltip"; 21 | import EventsDropdown from "../EventsDropdown"; 22 | import FunctionsDropdown from "../FunctionsDropdown"; 23 | import { useTranslation } from "react-i18next"; 24 | import { useError } from "../../context/ErrorProvider"; 25 | 26 | /** 27 | * Props for the LocalInvoke component. 28 | */ 29 | interface BuildProps { 30 | onComplete: () => void; 31 | // eslint-disable-next-line no-unused-vars 32 | setLoading: (isLoading: boolean) => void; 33 | } 34 | 35 | /** 36 | * Component for locally invoking a function. 37 | * @param onComplete Callback function to execute upon completion of local invocation. 38 | * @param setLoading Function to set loading state during local invocation. 39 | * @returns The rendered LocalInvoke component. 40 | */ 41 | const LocalInvoke: React.FC = ({ onComplete, setLoading }) => { 42 | // Hooks for error handling, translation, and configuration context 43 | const { setError } = useError(); 44 | const { t } = useTranslation("global"); 45 | const { configuration } = useContext(ConfigurationContext); 46 | // State for selected event and function 47 | const [selectedEvent, setSelectedEvent] = useState(""); 48 | const [selectedFunction, setSelectedFunction] = useState(""); 49 | 50 | /** 51 | * Handles local function invocation. 52 | */ 53 | const handleLocalInvoke = () => { 54 | setLoading(true); 55 | vscode.postMessage({ 56 | command: "localInvoke", 57 | data: { 58 | path: configuration.projectFolder + "/" + configuration.projectName, 59 | eventPath: selectedEvent, 60 | functionName: selectedFunction, 61 | }, 62 | }); 63 | window.addEventListener("message", (event) => { 64 | const message = event.data; 65 | if (message.command === "localInvoke" && message.data.success) { 66 | onComplete(); 67 | setLoading(false); 68 | } else { 69 | if (message.command === "localInvoke" && !message.data.success) { 70 | setError(message.data.error); 71 | setLoading(false); 72 | console.debug("Error invoking function locally"); 73 | } 74 | } 75 | }); 76 | }; 77 | 78 | return ( 79 |
80 | {/* Dropdowns for selecting event and function */} 81 | 85 | 89 | 90 | {/* Button to perform local invocation */} 91 |
92 | 93 | {t("localInvoke.button")} 94 | 95 |
96 | 97 | {/* Tooltip for local invocation information */} 98 | 99 |
100 | ); 101 | }; 102 | 103 | export default LocalInvoke; 104 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/navbar/Dropdown.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import React from "react"; 17 | import { VscQuestion, VscTrash } from "react-icons/vsc"; 18 | import { useTranslation } from "react-i18next"; 19 | 20 | /** 21 | * Props for the Dropdown component. 22 | */ 23 | interface DropdownProps { 24 | togglePrerequisitesModal: () => void; 25 | toggleDeleteConfirmationModal: () => void; 26 | } 27 | 28 | /** 29 | * Component representing a dropdown menu with options. 30 | * @param togglePrerequisitesModal Function to toggle the prerequisites modal. 31 | * @param toggleDeleteConfirmationModal Function to toggle the delete confirmation modal. 32 | * @returns The rendered Dropdown component. 33 | */ 34 | const Dropdown: React.FC = ({ 35 | togglePrerequisitesModal, 36 | toggleDeleteConfirmationModal, 37 | }) => { 38 | // Hook for translation 39 | const { t } = useTranslation("global"); 40 | 41 | return ( 42 |
43 | {/* Option for toggling prerequisites modal */} 44 |
45 | 46 | {t("dropdown.prerequisites.title")} 47 | 48 |
49 | 50 |
51 |
52 | 53 | {/* Option for toggling delete confirmation modal */} 54 |
55 |
56 |

{t("dropdown.delete.title")}

57 |
58 |
59 | 60 |
61 |
62 |
63 | ); 64 | }; 65 | 66 | export default Dropdown; 67 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/navbar/Navbar.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | a { 18 | text-decoration: none; 19 | color: var(--vscode-foreground); 20 | } 21 | 22 | .navbar-container { 23 | display: flex; 24 | justify-content: space-between; 25 | align-items: center; 26 | width: 100%; 27 | margin-bottom: 2rem; 28 | } 29 | 30 | .navbar-items { 31 | display: flex; 32 | justify-content: space-between; 33 | align-items: center; 34 | gap: 1rem; 35 | } 36 | 37 | .dropdown-icon svg { 38 | cursor: pointer; 39 | } 40 | 41 | .navbar-dropdown { 42 | position: relative; 43 | } 44 | 45 | .dropdown-menu { 46 | position: absolute; 47 | right: 0; 48 | background-color: var(--vscode-editorGroupHeader-tabsBackground); 49 | width: 15rem; 50 | z-index: 10; 51 | } 52 | 53 | .dropdown-item { 54 | display: flex; 55 | align-items: center; 56 | cursor: pointer; 57 | height: 3rem; 58 | } 59 | 60 | .dropdown-item:hover { 61 | background-color: var(--vscode-toolbar-hoverBackground); 62 | } 63 | 64 | .dropdown-text { 65 | margin-left: 1rem; 66 | flex-grow: 1; 67 | } 68 | 69 | .error { 70 | color: var(--vscode-errorForeground); 71 | } 72 | 73 | .dropdown-icon-container { 74 | width: 3rem; 75 | height: 100%; 76 | display: flex; 77 | justify-content: center; 78 | align-items: center; 79 | } 80 | 81 | .questionmark { 82 | background-color: var(--vscode-checkbox-background); 83 | } 84 | 85 | .trash { 86 | background-color: var(--vscode-errorForeground); 87 | } -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/navbar/Navbar.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import React, { useState, useRef, useEffect } from "react"; 17 | import { VscGithubInverted, VscEllipsis } from "react-icons/vsc"; 18 | import Dropdown from "./Dropdown"; 19 | import Prerequisites from "../prerequisites/Prerequisites"; 20 | import DeleteConfirmation from "../deleteConfirmation/DeleteConfirmation"; 21 | import "./Navbar.css"; 22 | 23 | /** 24 | * Component representing the navigation bar. 25 | * @returns The rendered Navbar component. 26 | */ 27 | const Navbar = () => { 28 | // State for controlling prerequisites modal visibility 29 | const [isPrerequisitesModalModalOpen, setIsPrerequisitesModalModalOpen] = 30 | useState(false); 31 | 32 | // State for controlling delete confirmation modal visibility 33 | const [isDeleteConfirmationModalOpen, setIsDeleteConfirmationModalOpen] = 34 | useState(false); 35 | 36 | // State for controlling dropdown visibility 37 | const [dropdownOpen, setDropdownOpen] = useState(false); 38 | 39 | // Reference to dropdown element 40 | const dropdownRef = useRef(null); 41 | 42 | /** 43 | * Toggles the visibility of the dropdown menu. 44 | */ 45 | const toggleDropdown = () => { 46 | setDropdownOpen(!dropdownOpen); 47 | }; 48 | 49 | /** 50 | * Toggles the visibility of the prerequisites modal. 51 | */ 52 | const togglePrerequisitesModal = () => { 53 | setIsPrerequisitesModalModalOpen(!isPrerequisitesModalModalOpen); 54 | }; 55 | 56 | /** 57 | * Toggles the visibility of the delete confirmation modal. 58 | */ 59 | const toggleDeleteConfirmationModal = () => { 60 | setIsDeleteConfirmationModalOpen(!isDeleteConfirmationModalOpen); 61 | }; 62 | 63 | // Effect to handle click outside dropdown to close it 64 | useEffect(() => { 65 | const handleClickOutside = (event: MouseEvent) => { 66 | if ( 67 | dropdownRef.current && 68 | !dropdownRef.current.contains(event.target as Node) 69 | ) { 70 | setDropdownOpen(false); 71 | } 72 | }; 73 | 74 | document.addEventListener("mousedown", handleClickOutside); 75 | 76 | return () => { 77 | document.removeEventListener("mousedown", handleClickOutside); 78 | }; 79 | }, [dropdownRef]); 80 | 81 | return ( 82 | <> 83 |
84 | {/* Navbar items */} 85 |
86 |

vscode-aws-lambda-swift

87 | 91 | 92 | 93 |
94 | 95 | {/* Dropdown menu */} 96 |
97 |
98 | 99 |
100 | {dropdownOpen && ( 101 | 105 | )} 106 |
107 |
108 | 109 | {/* Prerequisites modal */} 110 | 114 | 115 | {/* Delete confirmation modal */} 116 | 120 | 121 | ); 122 | }; 123 | 124 | export default Navbar; 125 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/prerequisites/Prerequisites.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | .modal-overlay { 18 | position: fixed; 19 | top: 0; 20 | left: 0; 21 | width: 100%; 22 | height: 100%; 23 | background-color: rgba(0, 0, 0, 0.5); 24 | display: flex; 25 | justify-content: center; 26 | align-items: center; 27 | z-index: 1000; 28 | } 29 | 30 | .modal { 31 | background-color: var(--vscode-editorGroupHeader-tabsBackground); 32 | border-radius: 8px; 33 | padding: 20px; 34 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); 35 | width: 300px; 36 | } 37 | 38 | .close { 39 | position: relative; 40 | cursor: pointer; 41 | } 42 | 43 | .loading-container { 44 | display: flex; 45 | justify-content: center; 46 | align-items: center; 47 | height: 5rem; 48 | } 49 | 50 | h2 { 51 | margin: 0; 52 | } 53 | 54 | .prerequisites-container { 55 | display: flex; 56 | flex-direction: column; 57 | justify-content: center; 58 | align-items: center; 59 | width: 100%; 60 | margin-top: 20px; 61 | height: 5rem; 62 | gap: 10px; 63 | } 64 | 65 | .prerequisite { 66 | display: flex; 67 | justify-content: space-between; 68 | align-items: center; 69 | width: 100%; 70 | } 71 | 72 | .prerequisites-button-container { 73 | width: 100%; 74 | display: flex; 75 | gap: 10px; 76 | justify-content: flex-end; 77 | margin-top: 20px; 78 | } -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/remoteInvoke/RemoteInvoke.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import { vscode } from "../../utilities/vscode"; 17 | import React, { useContext, useState } from "react"; 18 | import { 19 | VSCodeButton, 20 | VSCodeTextField, 21 | } from "@vscode/webview-ui-toolkit/react"; 22 | import Tooltip from "../tooltip/Tooltip"; 23 | import { ConfigurationContext } from "../../context/ConfigurationProvider"; 24 | import EventsDropdown from "../EventsDropdown"; 25 | import FunctionsDropdown from "../FunctionsDropdown"; 26 | import { useTranslation } from "react-i18next"; 27 | import { useError } from "../../context/ErrorProvider"; 28 | 29 | /** 30 | * Props for the RemoteInvoke component. 31 | */ 32 | interface RemoteInvokeProps { 33 | onComplete: () => void; 34 | // eslint-disable-next-line no-unused-vars 35 | setLoading: (isLoading: boolean) => void; 36 | } 37 | 38 | /** 39 | * Represents the component for invoking functions remotely. 40 | * @param {object} props - The component props. 41 | * @param {Function} props.onComplete - Function to call upon completion. 42 | * @param {Function} props.setLoading - Function to set loading state. 43 | * @returns {JSX.Element} - The rendered RemoteInvoke component. 44 | */ 45 | const RemoteInvoke: React.FC = ({ 46 | onComplete, 47 | setLoading, 48 | }) => { 49 | // Error handling hook 50 | const { setError } = useError(); 51 | 52 | // Translation hook 53 | const { t } = useTranslation("global"); 54 | 55 | // Configuration context hooks 56 | const { configuration, setConfiguration } = useContext(ConfigurationContext); 57 | 58 | // State for selected event and function 59 | const [selectedEvent, setSelectedEvent] = useState(""); 60 | const [selectedFunction, setSelectedFunction] = useState(""); 61 | 62 | // Function to handle remote function invocation 63 | const handleRemoteInvoke = () => { 64 | setLoading(true); 65 | vscode.postMessage({ 66 | command: "remoteInvoke", 67 | data: { 68 | path: configuration.projectFolder + "/" + configuration.projectName, 69 | eventPath: selectedEvent, 70 | functionName: selectedFunction, 71 | stackName: configuration.stackName, 72 | region: configuration.region, 73 | }, 74 | }); 75 | window.addEventListener("message", (event) => { 76 | const message = event.data; 77 | if (message.command === "remoteInvoke" && message.data.success) { 78 | onComplete(); 79 | setLoading(false); 80 | } else { 81 | if (message.command === "remoteInvoke" && !message.data.success) { 82 | setError(message.data.error); 83 | setLoading(false); 84 | console.debug("Error invoking function remotely"); 85 | } 86 | } 87 | }); 88 | }; 89 | 90 | return ( 91 |
92 | {/* Dropdown for selecting functions */} 93 | 97 | 98 | {/* Dropdown for selecting events */} 99 | 103 | 104 | {/* Input field for specifying stack name */} 105 |
106 | 109 | { 113 | setConfiguration((prevConfig) => ({ 114 | ...prevConfig, 115 | stackName: e.target.value, 116 | })); 117 | }} 118 | placeholder={t("remoteInvoke.form.stackName.placeholder")} 119 | /> 120 |
121 | 122 | {/* Button for initiating remote invocation */} 123 |
124 | 125 | {t("remoteInvoke.button")} 126 | 127 |
128 | 129 | {/* Tooltip for providing information */} 130 | 131 |
132 | ); 133 | }; 134 | 135 | export default RemoteInvoke; 136 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/tooltip/Tooltip.css: -------------------------------------------------------------------------------- 1 | /*===----------------------------------------------------------------------===// 2 | * 3 | * This source file is part of the AWS Lambda Swift 4 | * VSCode extension open source project. 5 | * 6 | * Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | * Licensed under Apache License v2.0. 8 | * 9 | * See LICENSE.txt for license information 10 | * See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | *===----------------------------------------------------------------------===// 15 | */ 16 | 17 | .tooltip-container { 18 | position: absolute; 19 | display: inline-block; 20 | top: 10px; 21 | right: 10px; 22 | } 23 | 24 | .tooltip-text { 25 | visibility: visible; 26 | position: absolute; 27 | z-index: 999; 28 | background-color: var(--vscode-actionBar-toggledBackground); 29 | color: #fff; 30 | padding: 5px 10px; 31 | border-radius: 5px; 32 | right: -10px; 33 | width: max-content; 34 | max-width: 500px; 35 | max-height: 100px; 36 | white-space: normal; 37 | } 38 | 39 | .tooltip-text::after { 40 | content: ""; 41 | position: absolute; 42 | border-style: solid; 43 | border-width: 5px; 44 | border-color: var(--vscode-actionBar-toggledBackground) transparent transparent transparent; 45 | top: -10px; 46 | right: 15px; 47 | transform: rotate(180deg); 48 | } 49 | 50 | .tooltip-icon svg { 51 | cursor: pointer; 52 | color: #fff; 53 | } 54 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/components/tooltip/Tooltip.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import React, { useState } from "react"; 17 | import { VscQuestion } from "react-icons/vsc"; 18 | import "./Tooltip.css"; 19 | 20 | /** 21 | * Props for the Tooltip component. 22 | */ 23 | interface TooltipProps { 24 | text: string; 25 | } 26 | 27 | /** 28 | * Represents a tooltip component. 29 | * @param {object} props - The component props. 30 | * @param {string} props.text - The text to display in the tooltip. 31 | * @returns {JSX.Element} - The rendered Tooltip component. 32 | */ 33 | const Tooltip: React.FC = ({ text }) => { 34 | // State to control the visibility of the tooltip 35 | const [showTooltip, setShowTooltip] = useState(false); 36 | 37 | // Function to handle mouse enter event 38 | const handleMouseEnter = () => { 39 | setShowTooltip(true); 40 | }; 41 | 42 | // Function to handle mouse leave event 43 | const handleMouseLeave = () => { 44 | setShowTooltip(false); 45 | }; 46 | 47 | return ( 48 |
53 | {/* Icon triggering the tooltip */} 54 |
55 | 56 |
57 | 58 | {/* Tooltip text displayed conditionally based on showTooltip state */} 59 | {showTooltip &&
{text}
} 60 |
61 | ); 62 | }; 63 | 64 | export default Tooltip; 65 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/context/ConfigurationProvider.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | /* eslint-disable indent */ 17 | import React, { createContext, useState, useEffect, PropsWithChildren } from "react"; 18 | import { vscode } from "../utilities/vscode"; 19 | 20 | /** 21 | * Interface representing the configuration of the application. 22 | */ 23 | interface Configuration { 24 | projectName: string; 25 | region: string; 26 | projectFolder: string; 27 | templates: Array<{ name: string; path: string }> | []; 28 | stackName: string; 29 | regionList: string[]; 30 | eventsList: string[]; 31 | functionsList: string[]; 32 | locale: string; 33 | isLoading: boolean; 34 | theme: string; 35 | branches: string[]; 36 | } 37 | 38 | /** 39 | * Context providing access to the application configuration and a function to update it. 40 | */ 41 | export const ConfigurationContext = createContext<{ 42 | configuration: Configuration; 43 | setConfiguration: React.Dispatch>; 44 | }>({ 45 | configuration: { 46 | projectName: "", 47 | region: "", 48 | projectFolder: "", 49 | templates: [], 50 | stackName: "", 51 | regionList: [], 52 | eventsList: [], 53 | functionsList: [], 54 | locale: "", 55 | isLoading: true, 56 | theme: "", 57 | branches: [], 58 | }, 59 | setConfiguration: () => {}, 60 | }); 61 | 62 | /** 63 | * Provider component for the ConfigurationContext. 64 | * Manages the application configuration state and provides it to the context. 65 | * @param children The child components wrapped by the provider. 66 | */ 67 | export const ConfigurationProvider: React.FC = ({ children }) => { 68 | // Initial configuration state 69 | const initialConfig: Configuration = { 70 | projectName: "", 71 | region: "", 72 | projectFolder: "", 73 | templates: [], 74 | stackName: "", 75 | regionList: [], 76 | eventsList: [], 77 | functionsList: [], 78 | locale: "", 79 | isLoading: true, 80 | theme: "", 81 | branches: [], 82 | }; 83 | 84 | // State to manage the configuration 85 | const [configuration, setConfiguration] = 86 | useState(initialConfig); 87 | 88 | // Effect to initialize configuration and listen for updates 89 | useEffect(() => { 90 | // Notify VSCode that the webview is ready to receive initial configuration 91 | vscode.postMessage({ command: "ready" }); 92 | 93 | // Listen for messages from VSCode and update configuration accordingly 94 | window.addEventListener("message", (event) => { 95 | const message = event.data; 96 | if (message.command === "ready") { 97 | setConfiguration((prevConfig) => ({ 98 | ...prevConfig, 99 | templates: message.data.templates.list, 100 | projectFolder: message.data.path, 101 | region: message.data.regions.default, 102 | regionList: message.data.regions.list, 103 | locale: message.data.locale, 104 | isLoading: false, 105 | theme: getTheme(message.data.theme), 106 | branches: message.data.branches, 107 | })); 108 | } 109 | }); 110 | 111 | // Cleanup: remove event listener 112 | return () => { 113 | window.removeEventListener("message", () => {}); 114 | }; 115 | }, []); 116 | 117 | // Effect to listen for theme change messages from VSCode 118 | useEffect(() => { 119 | // Listen for messages from VSCode and update configuration accordingly 120 | window.addEventListener("message", (event) => { 121 | const message = event.data; 122 | if (message.command === "themeChange") { 123 | setConfiguration((prevConfig) => ({ 124 | ...prevConfig, 125 | theme: getTheme(message.data.theme), 126 | })); 127 | } 128 | }); 129 | 130 | // Cleanup: remove event listener 131 | return () => { 132 | window.removeEventListener("message", () => {}); 133 | }; 134 | }, []); 135 | 136 | /** 137 | * Function to get the theme based on the theme enum value. 138 | * @param enumValue The enum value representing the theme. 139 | * @returns The theme string. 140 | */ 141 | function getTheme(enumValue: number): string { 142 | switch (enumValue) { 143 | case 1: 144 | case 4: 145 | return "light"; 146 | case 2: 147 | case 3: 148 | return "dark"; 149 | default: 150 | return "dark"; 151 | } 152 | } 153 | 154 | return ( 155 | 156 | {children} 157 | 158 | ); 159 | }; 160 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/context/ErrorProvider.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import React, { createContext, useContext, useState, ReactNode } from "react"; 17 | 18 | /** 19 | * Interface representing the context value for error management. 20 | */ 21 | interface ErrorContextType { 22 | error: Error | null; 23 | // eslint-disable-next-line no-unused-vars 24 | setError: (errorMessage: Error | null) => void; 25 | } 26 | 27 | /** 28 | * Context for managing error state and providing it to components. 29 | */ 30 | const ErrorContext = createContext(undefined); 31 | 32 | /** 33 | * Provider component for the ErrorContext. 34 | * Manages the error state and provides it to the context. 35 | * @param children The child components wrapped by the provider. 36 | */ 37 | export const ErrorProvider: React.FC<{ children: ReactNode }> = ({ 38 | children, 39 | }) => { 40 | // State to manage the error 41 | const [error, setError] = useState(null); 42 | 43 | return ( 44 | 45 | {children} 46 | 47 | ); 48 | }; 49 | 50 | /** 51 | * Custom hook for accessing the error context. 52 | * Throws an error if used outside of an ErrorProvider. 53 | * @returns The error context value. 54 | */ 55 | export const useError = (): ErrorContextType => { 56 | const context = useContext(ErrorContext); 57 | if (!context) { 58 | throw new Error("useError must be used within an ErrorProvider"); 59 | } 60 | return context; 61 | }; 62 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/i18n/en/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "dropdown": { 3 | "prerequisites": { 4 | "title": "Check prerequisites", 5 | "modal": { 6 | "title": "Prerequisites", 7 | "closeButton": "Close", 8 | "retryButton": "Retry", 9 | "missingPrerequisiteMessage": "is missing, you can download it here" 10 | } 11 | }, 12 | "delete": { 13 | "title": "Delete stack", 14 | "modal": { 15 | "title": "Delete Confirmation", 16 | "stackNameLabel": "Stack Name", 17 | "stackNamePlaceholder": "Your stack name to delete", 18 | "deleteButton": "Delete", 19 | "deleteButtonIsLoading": "Deleting...", 20 | "cancelButton": "Cancel", 21 | "successMessage": "Stack deleted successfully" 22 | } 23 | } 24 | }, 25 | "configuration": { 26 | "title": "Configuration", 27 | "form": { 28 | "projectName": { 29 | "label": "Name", 30 | "placeholder": "Project name" 31 | }, 32 | "region": { 33 | "label": "Region" 34 | }, 35 | "projectFolder": { 36 | "label": "Project Folder", 37 | "placeholder": "Your project folder path" 38 | } 39 | }, 40 | "error": { 41 | "emptyPath": "Project folder path cannot be empty", 42 | "folderDoesNotExist": "Folder does not exist", 43 | "emptyName": "Project name cannot be empty", 44 | "alreadyExists": "Project already exists, please choose another name" 45 | } 46 | }, 47 | "initializeProject": { 48 | "title": "Initialize Project", 49 | "form": { 50 | "template": { 51 | "label": "Template" 52 | }, 53 | "branch": { 54 | "label": "Branch" 55 | }, 56 | "visualRepresentation": { 57 | "label": "Visual Representation" 58 | }, 59 | "info": { 60 | "label": "Information" 61 | } 62 | }, 63 | "info": { 64 | "message": "This will create a new project with the selected template." 65 | }, 66 | "button": "Initialize", 67 | "error": { 68 | "folderAlreadyExists": "Project already exist, please choose another folder" 69 | } 70 | }, 71 | "buildProject": { 72 | "title": "Build Project", 73 | "form": { 74 | "buildFolder": { 75 | "label": "Build Folder", 76 | "placeholder": "Your build folder" 77 | } 78 | }, 79 | "info": { 80 | "message": "This will build the project." 81 | }, 82 | "button": "Build" 83 | }, 84 | "localInvoke": { 85 | "title": "Local Invoke", 86 | "form": { 87 | "function": { 88 | "label": "Function" 89 | }, 90 | "event": { 91 | "label": "Event" 92 | } 93 | }, 94 | "info": { 95 | "message": "This will invoke the function locally with the selected event. Only works with the \"api-to-lambda\" template. Make sure the configuration is set correctly (Project Name, Project Folder), otherwise the functions and events will not be found." 96 | }, 97 | "button": "Invoke" 98 | }, 99 | "deployProject": { 100 | "title": "Deploy Project", 101 | "form": { 102 | "stackName": { 103 | "label": "Stack Name", 104 | "placeholder": "Your stack name" 105 | } 106 | }, 107 | "info": { 108 | "message": "This will deploy the stack with the selected stack name." 109 | }, 110 | "button": "Deploy" 111 | }, 112 | "remoteInvoke": { 113 | "title": "Remote Invoke", 114 | "form": { 115 | "stackName": { 116 | "label": "Stack Name", 117 | "placeholder": "Your stack name" 118 | } 119 | }, 120 | "info": { 121 | "message": "This will invoke the function remotely with the selected event. Make sure the stack is deployed and that the configuration is set correctly (Project Name, Region, Project Folder), otherwise the functions and events will not be found." 122 | }, 123 | "button": "Invoke" 124 | }, 125 | "console": { 126 | "title": "Output" 127 | } 128 | } -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/index.tsx: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import React from "react"; 17 | import ReactDOM from "react-dom"; 18 | import App from "./App"; 19 | import { ConfigurationProvider } from "./context/ConfigurationProvider"; 20 | import i18next from "i18next"; 21 | import global_en from "./i18n/en/global.json"; 22 | import { I18nextProvider } from "react-i18next"; 23 | import { ErrorProvider } from "./context/ErrorProvider"; 24 | import { createRoot } from 'react-dom/client'; 25 | 26 | 27 | /** 28 | * Initialize i18next and set up localization resources. 29 | */ 30 | i18next.init({ 31 | interpolation: { escapeValue: true }, 32 | lng: "en", 33 | fallbackLng: "en", 34 | resources: { 35 | en: { 36 | global: global_en, 37 | }, 38 | }, 39 | }); 40 | 41 | /** 42 | * The root component of the application. 43 | * @returns {JSX.Element} The rendered root component. 44 | */ 45 | // Find your root element 46 | const container = document.getElementById('root'); 47 | 48 | // Create a root 49 | if (container) { 50 | const root = createRoot(container); 51 | 52 | root.render( 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | ); 63 | } 64 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/utilities/vscode.ts: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // This source file is part of the AWS Lambda Swift 4 | // VSCode extension open source project. 5 | // 6 | // Copyright (c) 2024, the VSCode AWS Lambda Swift extension project authors. 7 | // Licensed under Apache License v2.0. 8 | // 9 | // See LICENSE.txt for license information 10 | // See CONTRIBUTORS.txt for the list of VSCode AWS Lambda Swift project authors 11 | // 12 | // SPDX-License-Identifier: Apache-2.0 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | import type { WebviewApi } from "vscode-webview"; 17 | 18 | /** 19 | * A utility wrapper around the acquireVsCodeApi() function, which enables 20 | * message passing and state management between the webview and extension 21 | * contexts. 22 | * 23 | * This utility also enables webview code to be run in a web browser-based 24 | * dev server by using native web browser features that mock the functionality 25 | * enabled by acquireVsCodeApi. 26 | */ 27 | class VSCodeAPIWrapper { 28 | private readonly vsCodeApi: WebviewApi | undefined; 29 | 30 | constructor() { 31 | // Check if the acquireVsCodeApi function exists in the current development 32 | // context (i.e. VS Code development window or web browser) 33 | if (typeof acquireVsCodeApi === "function") { 34 | this.vsCodeApi = acquireVsCodeApi(); 35 | } 36 | } 37 | 38 | /** 39 | * Post a message (i.e. send arbitrary data) to the owner of the webview. 40 | * 41 | * @remarks When running webview code inside a web browser, postMessage will instead 42 | * log the given message to the console. 43 | * 44 | * @param message Abitrary data (must be JSON serializable) to send to the extension context. 45 | */ 46 | public postMessage(message: unknown) { 47 | if (this.vsCodeApi) { 48 | this.vsCodeApi.postMessage(message); 49 | } else { 50 | console.log(message); 51 | } 52 | } 53 | 54 | /** 55 | * Get the persistent state stored for this webview. 56 | * 57 | * @remarks When running webview source code inside a web browser, getState will retrieve state 58 | * from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). 59 | * 60 | * @return The current state or `undefined` if no state has been set. 61 | */ 62 | public getState(): unknown | undefined { 63 | if (this.vsCodeApi) { 64 | return this.vsCodeApi.getState(); 65 | } else { 66 | const state = localStorage.getItem("vscodeState"); 67 | return state ? JSON.parse(state) : undefined; 68 | } 69 | } 70 | 71 | /** 72 | * Set the persistent state stored for this webview. 73 | * 74 | * @remarks When running webview source code inside a web browser, setState will set the given 75 | * state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). 76 | * 77 | * @param newState New persisted state. This must be a JSON serializable object. Can be retrieved 78 | * using {@link getState}. 79 | * 80 | * @return The new state. 81 | */ 82 | public setState(newState: T): T { 83 | if (this.vsCodeApi) { 84 | return this.vsCodeApi.setState(newState); 85 | } else { 86 | localStorage.setItem("vscodeState", JSON.stringify(newState)); 87 | return newState; 88 | } 89 | } 90 | } 91 | 92 | // Exports class singleton to prevent multiple invocations of acquireVsCodeApi. 93 | export const vscode = new VSCodeAPIWrapper(); 94 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "useDefineForClassFields": true, 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "esnext", 13 | "moduleResolution": "node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react-jsx" 18 | }, 19 | "include": ["./src"] 20 | } 21 | -------------------------------------------------------------------------------- /vscode-extension/webview-ui/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react"; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | build: { 8 | outDir: "build", 9 | rollupOptions: { 10 | output: { 11 | entryFileNames: `assets/[name].js`, 12 | chunkFileNames: `assets/[name].js`, 13 | assetFileNames: `assets/[name].[ext]`, 14 | }, 15 | }, 16 | }, 17 | }); 18 | --------------------------------------------------------------------------------