Skip to content

Commit b30bd53

Browse files
authored
Revert "Add tsp-client compare command (#8793)" + package lock adjustments (#8811)
* Revert "Add `tsp-client compare` command (#8793)" This reverts commit ab1eacb. * update package version and lock * update changelog to reflect package version
1 parent 8154119 commit b30bd53

17 files changed

Lines changed: 435 additions & 3663 deletions

tools/tsp-client/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ node_modules
33
dist
44
types
55
temp
6-
tsp-output/
7-
output/

tools/tsp-client/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Release
22

3+
## 2024-08-08 - 0.11.1
4+
5+
- Removed `compare` command.
6+
37
## 2024-08-08 - 0.11.0
48

59
- Added `generate-lock-file` command, see [README](https://github.com/Azure/azure-sdk-tools/blob/main/tools/tsp-client/README.md) for more information.
610
- Removed the `--generate-lock-file` flag and replaced it with the command above.
711
- Migrated tsp-client from `node:util` to `yargs` for commandline infrastructure.
8-
- Added `compare` command to compare a hand-authored Swagger to a TypeSpec-generated Swagger to understand the relevant differences between them.
912

1013
## 2024-08-05 - 0.10.0
1114

tools/tsp-client/README.md

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,56 @@
33
A simple command line tool to facilitate generating client libraries from TypeSpec.
44

55
## Installation
6-
76
```
87
npm install @azure-tools/typespec-client-generator-cli
98
```
109

1110
## Prerequisites
12-
1311
Please note that these prerequisites apply on the repository where the client library is going to be generated. Repo owners should make sure to follow these prerequisites. Users working with a repository that already accepts this tool can continue to see the [Usage](#usage) section.
1412

1513
- Add an emitter-package.json to the repo following this [configuration](#emitter-packagejson).
1614
- Add the [TempTypeSpecFiles](#TempTypeSpecFiles) directory to the .gitignore file for your repository.
1715

1816
## Usage
19-
2017
```
2118
tsp-client <command> [options]
2219
```
2320

2421
## Commands
25-
2622
Use one of the supported commands to get started generating clients from a TypeSpec project.
2723
This tool will default to using your current working directory to generate clients in and will
2824
use it to look for relevant configuration files. To specify a different output directory, use
2925
the `-o` or `--output-dir` option.
3026

3127
### init
32-
3328
Initialize the client library directory using a tspconfig.yaml. When running this command pass in a path to a local or remote tspconfig.yaml with the `-c` or `--tsp-config` flag.
3429

3530
The `init` command generates a directory structure following the standard pattern used across Azure SDK language repositories, creates a [tsp-location.yaml](#tsp-locationyaml) file to control generation, and performs an initial generation of the client library. If you want to skip client library generation, then pass the `--skip-sync-and-generate` flag.
3631

3732
> IMPORTANT: This command should be run from the root of the repository.
3833
3934
### update
40-
4135
Sync and generate client libraries from a TypeSpec project. The `update` command will look for a [tsp-location.yaml](#tsp-locationyaml) file in your current directory to sync a TypeSpec project and generate a client library.
4236

4337
### sync
44-
4538
Sync a TypeSpec project with the parameters specified in tsp-location.yaml.
4639

4740
By default the `sync` command will look for a tsp-location.yaml to get the project details and sync them to a temporary directory called `TempTypeSpecFiles`. Alternately, you can pass in the `--local-spec-repo` flag with the path to your local TypeSpec project to pull those files into your temporary directory.
4841

4942
### generate
50-
5143
Generate a client library from a TypeSpec project. The `generate` command should be run after the `sync` command. `generate` relies on the existence of the `TempTypeSpecFiles` directory created by the `sync` command and on an `emitter-package.json` file checked into your repository at the following path: `<repo root>/eng/emitter-package.json`. The `emitter-package.json` file is used to install project dependencies and get the appropriate emitter package.
5244

5345
### convert
54-
5546
Convert an existing swagger specification to a TypeSpec project. This command should only be run once to get started working on a TypeSpec project. TypeSpec projects will need to be optimized manually and fully reviewed after conversion. When using this command a path or url to a swagger README file is required through the `--swagger-readme` flag.
5647

57-
### compare
58-
59-
Compares two Swagger definitions to identify the relevant differences between them. This command is useful when comparing an existing Swagger definition with a TypeSpec generated one. The `compare` command requires two parameters: `--lhs` which will typically be the original hand-authored Swagger and `--rhs` which will usually be the folder containing your TypeSpec. The command will generate the Swagger and compare the two definitions. The command will ignore differences in the Swagger that don't
60-
correspond to differences in the service, allowing you to focus only on differences that are relevant.
61-
6248
### sort-swagger
63-
6449
Sort an existing swagger specification to be the same content order with TypeSpec generated swagger. This will allow you to easily compare and identify differences between the existing swagger and TypeSpec generated one. You should run this command on existing swagger files and check them in prior to creating converted TypeSpec PRs.
6550

6651
### generate-lock-file
6752

6853
Generate an emitter-package-lock.json under the eng/ directory based on existing `<repo-root>/eng/emitter-package.json`.
6954

7055
## Options
71-
7256
```
7357
--arm Convert ARM swagger specification to TypeSpec [boolean]
7458
-c, --tsp-config The tspconfig.yaml file to use [string]
@@ -81,9 +65,9 @@ Generate an emitter-package-lock.json under the eng/ directory based on existing
8165
--save-inputs Don't clean up the temp directory after generation [boolean]
8266
--skip-sync-and-generate Skip sync and generate during project init [boolean]
8367
--swagger-readme Path or url to swagger readme file [string]
84-
-o, --output-dir Specify an alternate output directory for the
68+
-o, --output-dir Specify an alternate output directory for the
8569
generated files. Default is your current directory [string]
86-
--repo Repository where the project is defined for init
70+
--repo Repository where the project is defined for init
8771
or update [string]
8872
-v, --version Show version number [boolean]
8973
```
@@ -107,23 +91,22 @@ tsp-client update
10791
## Important concepts
10892

10993
### Per project setup
110-
11194
Each project will need to have a configuration file called tsp-location.yaml that will tell the tool where to find the TypeSpec project.
11295

11396
#### tsp-location.yaml
11497

115-
This file is created through the `tsp-client init` command or you can manually create it under the project directory to run other commands supported by this tool.
98+
This file is created through the `tsp-client init` command or you can manually create it under the project directory to run other commands supported by this tool.
11699

117100
> NOTE: This file should live under the project directory for each service.
118101
119102
The file has the following properties:
120103

121-
| Property | Description | IsRequired |
122-
| --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
123-
| <a id="directory-anchor"></a> directory | The top level directory where the main.tsp for the service lives. This should be relative to the spec repo root such as `specification/cognitiveservices/OpenAI.Inference` | true |
124-
| <a id="additionalDirectories-anchor"></a> additionalDirectories | Sometimes a typespec file will use a relative import that might not be under the main directory. In this case a single `directory` will not be enough to pull down all necessary files. To support this you can specify additional directories as a list to sync so that all needed files are synced. | false: default = null |
125-
| <a id="commit-anchor"></a> commit | The commit sha for the version of the typespec files you want to generate off of. This allows us to have idempotence on generation until we opt into pointing at a later version. | true |
126-
| <a id="repo-anchor"></a> repo | The repo this spec lives in. This should be either `Azure/azure-rest-api-specs` or `Azure/azure-rest-api-specs-pr`. Note that pr will work locally but not in CI until we add another change to handle token based auth. | true |
104+
| Property | Description | IsRequired |
105+
| --- | --- | --- |
106+
| <a id="directory-anchor"></a> directory | The top level directory where the main.tsp for the service lives. This should be relative to the spec repo root such as `specification/cognitiveservices/OpenAI.Inference` | true |
107+
| <a id="additionalDirectories-anchor"></a> additionalDirectories | Sometimes a typespec file will use a relative import that might not be under the main directory. In this case a single `directory` will not be enough to pull down all necessary files. To support this you can specify additional directories as a list to sync so that all needed files are synced. | false: default = null |
108+
| <a id="commit-anchor"></a> commit | The commit sha for the version of the typespec files you want to generate off of. This allows us to have idempotence on generation until we opt into pointing at a later version. | true |
109+
| <a id="repo-anchor"></a> repo | The repo this spec lives in. This should be either `Azure/azure-rest-api-specs` or `Azure/azure-rest-api-specs-pr`. Note that pr will work locally but not in CI until we add another change to handle token based auth. | true |
127110

128111
Example:
129112

@@ -152,6 +135,7 @@ See the following example of a valid tspconfig.yaml file: https://github.com/Azu
152135

153136
Using the tspconfig.yaml linked above, by default, the client libraries will be generated in the following directory for C#: `<repo>/sdk/contosowidgetmanager/Azure.Template.Contoso/`.
154137

138+
155139
### emitter-package.json (Required)
156140

157141
`emitter-package.json` will be used the same as a `package.json` file. If the is no `emitter-package-lock.json` file, the tool will run `npm install` on the contents of `emitter-package.json`. This file allows each repository to pin the version of their emitter and other dependencies to be used when generating client libraries.
@@ -161,16 +145,16 @@ Example:
161145

162146
```json
163147
{
164-
"main": "dist/src/index.js",
165-
"dependencies": {
166-
"@azure-tools/typespec-csharp": "0.1.11-beta.20230123.1"
167-
}
148+
"main": "dist/src/index.js",
149+
"dependencies": {
150+
"@azure-tools/typespec-csharp": "0.1.11-beta.20230123.1"
151+
}
168152
}
169153
```
170154

171155
> NOTE: tsp compile currently requires the "main" line to be there.
172156

173-
> NOTE: This file replaces the package.json checked into the `azure-rest-api-spec` repository.
157+
> NOTE: This file replaces the package.json checked into the `azure-rest-api-spec` repository.
174158

175159
### emitter-package-lock.json (Optional)
176160

-51 KB
Binary file not shown.

0 commit comments

Comments
 (0)