Amazon Q 开发者版中的示例开发文件 - Amazon Q 开发者版

Amazon Q 开发者版中的示例开发文件

以下示例显示符合开发文件规范且适合与 Amazon Q 结合使用的开发文件。本页末尾对示例进行了说明。

有关开发文件及其在 Amazon Q 中的使用方式的更多信息,请参阅测试由 Amazon Q“/dev”命令生成的代码建议

Python 示例

以下示例显示一个可以与 Python 项目结合使用的开发文件。

schemaVersion: 2.0.0 components: - name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest commands: - id: install exec: component: dev commandLine: "pip3.11 install -r requirements.txt" - id: test exec: component: dev commandLine: "python3.11 manage.py makemigrations && python3.11 manage.py test"

Node 示例

以下示例显示一个可以与 Node.js 项目结合使用的开发文件。

schemaVersion: 2.0.0 components: - name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest commands: - id: install exec: component: dev commandLine: "npm install" - id: build exec: component: dev commandLine: "npm run build" - id: test exec: component: dev commandLine: "npm run test"

示例的说明

下表描述前面的开发文件示例中的每一行或每个代码块。

行或代码块 描述
schemaVersion: 2.0.0

指定开发文件架构版本。Amazon Q 仅支持架构版本 2.0.0

components:

要部署到开发环境中的组件列表。

- name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest

指示使用公有 Amazon Elastic Container Registry(Amazon ECR)中提供的最新通用映像 Docker 映像作为开发环境。您可以更改此映像的版本,也可以用自己的映像替换该映像。有关更多信息,请参阅 通用映像内容

commands:

要执行的命令列表。

- id: install|build|test exec: component: dev commandLine: "cli-instructions"

installbuildtest 命令。Amazon Q 在开发环境中、通用映像上(或在 image: 中指定的任何映像上)运行 cli-instructions 指令。根据项目的上下文,cli-instructions 将有所不同。您可以更改这些命令来适合您的需要。