Azure / azure-sdk-tools

Tools repository leveraged by the Azure SDK team.
MIT License
110 stars 172 forks source link

Add a new tool tsp-client #6838

Closed lmazuel closed 10 months ago

lmazuel commented 1 year ago

Replace the three powershell scripts with a typescript CLI called "tsp-client". The story should:

See https://github.com/Azure/azure-sdk-tools/blob/main/doc/common/TypeSpec-Project-Scripts.md for details.

Project has been started by @xirzec , and will be continued by @catalinaperalta

Step 1 is to re-implement this with the same features, to simplify adoption. Step 2 may be to add more convenient commands as needed as the project evolved.

CC @weshaggard

weshaggard commented 1 year ago

cc @raych1 @m-nash

lmazuel commented 1 year ago

Spec:

tsp-client sync  # No parameters, means look for tsp-location.yaml here
tsp-client sync project_folder  # Use that project folder to look for tsp-location.yaml and do the job
tsp-client sync project_folder --typespec-folder typespec_folder # Use that project folder to look for tsp-location.yaml and do the job
tsp-client generate   # No parameters, means look for the temp folder
tsp-client generate project_folder  # Use that project folder to look for the temp folder
tsp-client generate project_folder --typespec-additional-options=option1=value1;option2=value2
tsp-client generate project_folder --save-inputs
# This has to be run from the azure-sdk-for-language root cloned on a machine.
# This creates a project from a url
tsp-client init https://github.com/Azure/azure-rest-api-specs/blob/677e272f33a3eaa724abd769af79383a5ac2bba5/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml

# This creates a project from a folder with SHA and repo. If folder, SHA and repo are required.
tsp-client init ./specification/contosowidgetmanager/Contoso.WidgetManager 677e272f33a3eaa724abd769af79383a5ac2bba5 https://github.com/Azure/azure-rest-api-specs

# Keep flag --skip-sync-and-generate

# Also run sync and generate
# This one can be run from the project folder directly. The logic is otherwise plugged to the same as init on principle

# Sync and generate asusming the tsp-location.yaml is here
tsp-client update

# Sync and generate assuming the tsp-location.yaml is in project_folder
tsp-client update project_folder

# Update tsp-location.yaml from a SHA as input + sync + generate
tsp-client update --sha=677e272f33a3eaa724abd769af79383a5ac2bba5

# Update tsp-location.yaml from a url + sync + generate
tsp-client update --commit-url=https://github.com/Azure/azure-rest-api-specs/blob/677e272f33a3eaa724abd769af79383a5ac2bba5/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml

# Update tsp-location.yaml from a SHA/repo as input + sync + generate
tsp-client update --sha=677e272f33a3eaa724abd769af79383a5ac2bba5 --repo=https://github.com/Azure/azure-rest-api-specs

# Also run sync and generate
catalinaperalta commented 11 months ago

TypeSpec client generator tool

There is a need to facilitate client library generation from TypeSpec into various language repositories.

We currently use the Sync, Generate, and Process Powershell scripts to facilitate this process. We would like to remove the dependency on Powershell and add a tool for TypeSpec users that is intuitive and exists in the same ecosystem.

Proposals:

  1. Add a client command to the tsp cli.

    • Allows users to remain within the same tool they are using to compile their specification.
    • The code should live in one of the typespec repositories.
    • Tied to tsp release cycle.
  2. Expose the tsp-client tool with a npx script through tsp client.

    • Allows users to remain within the same tool they are using to compile their specification.
    • No need for knowledge of an additional package.
    • tsp-client can exist outside of the typespec repositories.
    • Would need a good way of surfacing new features from the tool to the cli.
  3. Publish the @<namespace tbd>/tsp-client tool and have this be the recommended option to create and generate client libraries.

    • Independent tool from tsp cli and versions independently.
    • Can provide more configuration and customization of the client generation workflow.
    • tsp-client can exist outside of the typespec repositories.
catalinaperalta commented 10 months ago

Closing as the initial package was released: https://www.npmjs.com/package/@azure-tools/typespec-client-generator-cli