|
1 | 1 | # AutoRest PowerShell Generator - Development |
2 | 2 |
|
3 | | -## Requirements |
| 3 | +## Getting Started with Dev Containers (Recommended) |
4 | 4 |
|
5 | | -Use of this project requires the following: |
| 5 | +The easiest way to get started is using the provided Dev Container configuration, which automatically sets up all required tools and dependencies. |
6 | 6 |
|
7 | | -- [NodeJS LTS](https://nodejs.org) (currently 14.15.5) <br> I recommend that you use a tool like [nvs](https://github.com/jasongin/nvs) so that you can switch between versions of node without pain <br> |
8 | | -- [AutoRest](https://aka.ms/autorest) v3 <br> `npm install -g autorest@latest ` <br> |
9 | | -- [RushJS](https://rushjs.io/) manages multiple nodejs projects in a single repository. <br> `npm install -g @microsoft/rush` <br> |
10 | | -- PowerShell 6.0 - If you dont have it installed, you can use the cross-platform npm package <br> `npm install -g pwsh` <br> |
11 | | -- Dotnet SDK 2 or greater - If you dont have it installed, you can use the cross-platform npm package <br> `npm install -g dotnet-sdk-2.1 ` <br> |
12 | | -- _Recommended_: [Visual Studio Code](https://code.visualstudio.com/) |
| 7 | +### Prerequisites |
| 8 | +- [Docker](https://www.docker.com/get-started) or [Podman](https://podman.io/) |
| 9 | +- [Visual Studio Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) |
13 | 10 |
|
| 11 | +### Setup |
| 12 | +1. Clone the repository: |
| 13 | + ```bash |
| 14 | + git clone https://github.com/azure/autorest.powershell |
| 15 | + cd autorest.powershell |
| 16 | + ``` |
14 | 17 |
|
15 | | -## Cloning this repository |
| 18 | +2. Open in VS Code and reopen in container: |
| 19 | + - Open the folder in VS Code |
| 20 | + - When prompted, click "Reopen in Container" (or press `F1` and select "Dev Containers: Reopen in Container") |
| 21 | + - Wait for the container to build and initialize (this may take a few minutes on first run) |
16 | 22 |
|
17 | | -``` powershell |
18 | | -# clone recursively |
19 | | -git clone https://github.com/azure/autorest.powershell |
| 23 | +3. Once the container is ready, all tools are pre-installed and configured: |
| 24 | + - Node.js 18.20.4 |
| 25 | + - Rush 5.112.2 |
| 26 | + - PowerShell 7.5+ |
| 27 | + - .NET SDK 2.1 |
20 | 28 |
|
21 | | -# one-time |
22 | | -cd autorest.powershell |
23 | | -npm install |
24 | | -``` |
| 29 | +4. Build the project: |
| 30 | + ```bash |
| 31 | + rush update |
| 32 | + rush rebuild |
| 33 | + ``` |
25 | 34 |
|
26 | | -## Using RushJS |
| 35 | +## Manual Setup (Without Dev Container) |
27 | 36 |
|
28 | | -This repository is built as a 'monorepo' using [RushJS](https://rushjs.io/) - which manages multiple nodejs projects in a single repository. |
| 37 | +### Requirements |
29 | 38 |
|
30 | | -``` powershell |
31 | | -# install nodejs modules for all projects in the monorepo |
32 | | -rush update |
| 39 | +Use of this project requires the following: |
| 40 | + |
| 41 | +- **[Node.js LTS](https://nodejs.org)** (18.20.4) - We recommend using [nvs](https://github.com/jasongin/nvs) or [nvm](https://github.com/nvm-sh/nvm) to manage Node.js versions |
| 42 | +- **[Rush ](https://rushjs.io/)** (5.112.2) - `npm install -g @microsoft/[email protected]` |
| 43 | +- **[PowerShell](https://github.com/PowerShell/PowerShell)** (7.0+) - Cross-platform, install from [GitHub releases](https://github.com/PowerShell/PowerShell/releases) |
| 44 | +- **[.NET SDK](https://dotnet.microsoft.com/download)** (2.1+) - Required for building C# components |
| 45 | +- **Recommended**: [Visual Studio Code](https://code.visualstudio.com/) |
| 46 | + |
| 47 | +### Cloning this repository |
| 48 | + |
| 49 | +```bash |
| 50 | +# Clone the repository |
| 51 | +git clone https://github.com/azure/autorest.powershell |
| 52 | +cd autorest.powershell |
33 | 53 | ``` |
34 | 54 |
|
35 | | -Rush is used to make sure that package versions are consistent between sub-projects |
| 55 | +## Using Rush |
36 | 56 |
|
37 | | -``` powershell |
38 | | -# ensure all projects are using the same versions |
| 57 | +This repository is built as a monorepo using [Rush](https://rushjs.io/), which manages multiple Node.js projects in a single repository. |
| 58 | + |
| 59 | +```bash |
| 60 | +# First time setup: sync package versions |
39 | 61 | rush sync-versions |
40 | 62 |
|
41 | | -# install modules |
| 63 | +# Install dependencies for all projects |
42 | 64 | rush update |
43 | 65 | ``` |
44 | 66 |
|
45 | | -## Compiling |
| 67 | +If you update dependencies in `package.json` files, run `rush update` again to install the new packages. |
| 68 | + |
| 69 | +## Building |
46 | 70 |
|
47 | | -Rush is used to build `autorest.powershell` |
| 71 | +Build all projects in the correct dependency order: |
48 | 72 |
|
49 | | -``` powershell |
50 | | -# build everything |
| 73 | +```bash |
| 74 | +# Clean build everything from scratch |
51 | 75 | rush rebuild |
| 76 | + |
| 77 | +# Incremental build (faster, only rebuilds changed projects) |
| 78 | +rush build |
52 | 79 | ``` |
53 | 80 |
|
54 | | -You can use `watch` to compile when a file is changed, which will rebuild dependencies automatically. |
55 | | -Just kill the process with ctrl-c to stop it. |
| 81 | +### Watch Mode |
56 | 82 |
|
57 | | -``` powershell |
58 | | -# start watching |
| 83 | +For active development, you can use watch mode to automatically rebuild when files change: |
| 84 | + |
| 85 | +```bash |
| 86 | +# Watch mode - rebuilds on file changes |
59 | 87 | rush watch |
60 | 88 | ``` |
61 | 89 |
|
62 | | -## Using your locally built version of `autorest.powershell` |
| 90 | +Press `Ctrl+C` to stop the watch process. |
| 91 | + |
| 92 | +## Using Your Local Build |
63 | 93 |
|
64 | | -To use the locally built version of the plugin, add `--use:<path>` to the command line |
| 94 | +To use your locally built version of the plugin, use the `--use` flag with AutoRest: |
65 | 95 |
|
66 | | -``` powershell |
67 | | -# using a local build |
68 | | -> autorest --use:c:/work/autorest.powershell <...arguments> |
| 96 | +```bash |
| 97 | +# Using local build (cross-platform path) |
| 98 | +autorest --use:$PWD/powershell --powershell --input-file:path/to/spec.yaml --output-folder:./output |
69 | 99 |
|
| 100 | +# Or with absolute path |
| 101 | +autorest --use:/path/to/autorest.powershell/powershell --powershell <...other-arguments> |
70 | 102 | ``` |
71 | 103 |
|
72 | | -### Debugging |
| 104 | +**Note**: Use `$PWD` on Linux/macOS or `${PWD}` in PowerShell for the current directory. On Windows Command Prompt, use `%CD%`. |
| 105 | + |
| 106 | +## Debugging |
| 107 | + |
| 108 | +### Debugging AutoRest Generation |
| 109 | + |
| 110 | +1. Start AutoRest with the debugger flag (it will wait for the debugger to attach): |
| 111 | + ```bash |
| 112 | + autorest --use:$PWD/powershell --powershell.debugger --input-file:spec.yaml |
| 113 | + ``` |
| 114 | + |
| 115 | +2. In VS Code: |
| 116 | + - Open the `autorest.powershell` folder |
| 117 | + - Press `F5` to attach the debugger |
| 118 | + - You'll see "Debugger attached." in the AutoRest console |
| 119 | + - Set breakpoints and debug as needed |
| 120 | + |
| 121 | +### Debugging in VS Code |
73 | 122 |
|
74 | | -1. Start generating: `autorest --use:C:\path\to\local\autorest.powershell --powershell.debugger`. It will wait for debugger to attach. |
75 | | -1. Start debugging: open autorest.powershell repo in vscode; press `F5`. You will see "Debugger attached." in your autorest console, then you can start debugging. |
| 123 | +The repository includes VS Code launch configurations in `.vscode/launch.json` for debugging TypeScript code. |
76 | 124 |
|
77 | 125 | ### Testing |
78 | 126 |
|
|
0 commit comments