|
| 1 | +# TypeSpec Client Generator CLI |
| 2 | + |
| 3 | +This directory contains npm package definitions for `@azure-tools/typespec-client-generator-cli` (tsp-client) with pinned versions to ensure reproducible builds across environments. |
| 4 | + |
| 5 | +## Files |
| 6 | + |
| 7 | +- **`package.json`** - npm package definition with pinned tsp-client version |
| 8 | +- **`package-lock.json`** - Lock file ensuring exact dependency versions |
| 9 | + |
| 10 | +## Prerequisites |
| 11 | + |
| 12 | +- **Node.js** (with npm) - Required to install and run tsp-client |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +### Install dependencies |
| 17 | + |
| 18 | +```bash |
| 19 | +# Navigate to this directory |
| 20 | +cd eng/common/tsp-client |
| 21 | + |
| 22 | +# Install dependencies |
| 23 | +npm ci |
| 24 | +``` |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +After installation, you can run tsp-client by navigating to the directory and using npm exec: |
| 29 | + |
| 30 | +```bash |
| 31 | +cd eng/common/tsp-client |
| 32 | + |
| 33 | +# Get help |
| 34 | +npm exec --no -- tsp-client --help |
| 35 | + |
| 36 | +# Check version |
| 37 | +npm exec --no -- tsp-client version |
| 38 | + |
| 39 | +# Generate client code |
| 40 | +npm exec --no -- tsp-client generate --output-dir ./generated |
| 41 | + |
| 42 | +# Initialize a new project |
| 43 | +npm exec --no -- tsp-client init --tsp-config ./tspconfig.yaml |
| 44 | +``` |
| 45 | + |
| 46 | +## CI/CD Best Practices |
| 47 | + |
| 48 | +```bash |
| 49 | +cd eng/common/tsp-client |
| 50 | +npm ci |
| 51 | +npm exec --no -- tsp-client init --update-if-exists --tsp-config https://github.com/Azure/azure-rest-api-specs/blob/dee71463cbde1d416c47cf544e34f7966a94ddcb/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml |
| 52 | +``` |
| 53 | + |
| 54 | +## Package Management |
| 55 | + |
| 56 | +### Automatic Updates via Dependabot |
| 57 | + |
| 58 | +Dependabot is configured to automatically check for updates to `@azure-tools/typespec-client-generator-cli` daily and create pull requests with updated `package.json` and `package-lock.json` files. This ensures the package stays current with the latest versions while maintaining security through the PR review process. |
| 59 | + |
| 60 | +### Manual Version Updates |
| 61 | + |
| 62 | +If you need to manually update the tsp-client version: |
| 63 | + |
| 64 | +1. Edit `package.json` to update the version: |
| 65 | + |
| 66 | + ```json |
| 67 | + { |
| 68 | + "dependencies": { |
| 69 | + "@azure-tools/typespec-client-generator-cli": "0.28.1" |
| 70 | + } |
| 71 | + } |
| 72 | + ``` |
| 73 | + |
| 74 | +2. Update the lock file: |
| 75 | + |
| 76 | + ```bash |
| 77 | + npm install |
| 78 | + ``` |
| 79 | + |
| 80 | +3. Commit both `package.json` and `package-lock.json` |
0 commit comments