Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added emitter support to init template #5415

Merged

Conversation

allenjzhang
Copy link
Member

Init template now supports a list of emitters for user to choose from to be included in the project.

Artifacts affected:

  • package.json Emitters with optional package version are added
  • tspconfig.yaml emitters with options are added to emit and options section. Currently options do not support token replacement
  • optional messages are display after scaffolding for any additional environment setup instructions

Here is a sample template. We will evaluate whether to make it a built-in template:

{
  "azure-core": {
    "title": "REST API with client or server project",
    "description": "Create a project representing a generic REST API with options to include client or server project",
    "compilerVersion": "0.63.0",
    "libraries": ["@typespec/http", "@typespec/rest", "@typespec/openapi3"],
    "config": {},
    "emitters": {
      "@typespec/openapi3": {
        "selected": true,
        "description": "Generate OpenAPI 3.0 or 3.1 specification",
        "options": {
          "emitter-output-dir": "{project-root}/openapi/"
        },
        "version": "0.49.0"
      },
      "@typespec/http-client-csharp": {
        "description": "Client: generate CSharp client",
        "options": {
          "emitter-output-dir": "{project-root}/client/csharp/generated"
        },
        "message": "Please ensure dotnet SDK has been installed. Download from https://dotnet.microsoft.com/download"
      },
      "@typespec/http-server-csharp": {
        "description": "Server: generate ASP.NET Core server",
        "options": {
          "emitter-output-dir": "{project-root}/servers/aspnet/generated"
        },
        "message": "Please ensure dotnet SDK has been installed. Download from https://dotnet.microsoft.com/download"
      }
    }
  }
}

@azure-sdk
Copy link
Collaborator

azure-sdk commented Dec 19, 2024

All changed packages have been documented.

  • @typespec/compiler
  • typespec-vscode
Show changes

typespec-vscode - internal ✏️

Updated the init project template to include the new emitter definition

@typespec/compiler - feature ✏️

Added support for emitter selections for init template.

@allenjzhang allenjzhang requested a review from RodgeFu as a code owner December 19, 2024 22:17
@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs 🛝 VSCode Extension

Copy link
Contributor

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit

packages/compiler/src/init/init.ts Outdated Show resolved Hide resolved
@allenjzhang allenjzhang added this pull request to the merge queue Dec 20, 2024
Merged via the queue into microsoft:main with commit 70f8ea5 Dec 20, 2024
24 checks passed
@allenjzhang allenjzhang deleted the azhang_InitTemplateWithEmitterSupport branch December 20, 2024 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants