|
1 | | -# Contribution guide |
| 1 | +# 👩💻 Contribution guide |
2 | 2 |
|
| 3 | +## 🛠 Required tools |
3 | 4 |
|
4 | | -## Build the project |
5 | | - 1. Clone the repo by running 'git clone https://github.com/microsoft/botframework-cli.git' |
6 | | - 2. Inside the project folder run 'npm install' |
7 | | - 3. Run 'npm run build' |
| 5 | +We use [rush](https://rushjs.io/) with [pnpm](https://pnpm.js.org) to manage our monorepo. All your commands to build and test will use `rush`/`rushx`. |
8 | 6 |
|
9 | | -## Steps to create a new plugin |
| 7 | + - git |
| 8 | + - node 10 LTS or 12 LTS |
| 9 | + - (other versions not officially supported) (recommend [nvs](https://github.com/jasongin/nvs/releases) to help manage node versions) |
| 10 | + |
| 11 | + - (rush newer rush versions will manage this for you) |
| 12 | + - (optional) pnpm@5+ |
| 13 | + - useful to make vs code happy when trying to resolve your typescript version |
| 14 | + - MacOSX, Windows, "modern" Linux |
| 15 | + - We develop on Mac and Windows machines, and test on Ubuntu 14+. |
10 | 16 |
|
11 | | - 1. Build the project |
12 | | - 2. Inside the packages folder(https://github.com/microsoft/botframework-cli/tree/master/packages) run 'npx oclif plugin <plugin-name>' |
13 | | - 3. Follow the wizard and set the prompts: |
14 | | - |
15 | | - ? npm package: @microsoft/bf-<plugin-name> |
16 | | - ? description: <Plugin brief description> |
17 | | - ? author: Microsoft |
18 | | - ? version: 1.0.0 |
19 | | - ? license: MIT |
20 | | - ? Who is the GitHub owner of repository (https://github.com/OWNER/repo): microsoft |
21 | | - ? What is the GitHub name of repository (https://github.com/owner/REPO): botframework-cli |
22 | | - ? Select a package manager: npm |
23 | | - ? TypeScript: Y |
24 | | - ? Use tslint (linter for TypeScript): Y |
25 | | - ? Use mocha (testing framework): Y |
26 | | - ? Add CI service config (Press <space> to select, <a> to toggle all, <i> to invert selection): select any |
27 | | - |
28 | | - 4. Go to the folder created by the previous command and add @microsoft/bf-cli-command as a dependency in your package.json file |
29 | | - |
30 | | - "dependencies": { |
31 | | - ..., |
32 | | - "@microsoft/bf-cli-command": "1.0.0", |
33 | | - ... |
34 | | - } |
35 | | - |
36 | | - 5. At the root level(https://github.com/microsoft/botframework-cli) run 'npm run build' to bootstrap the packages |
| 17 | +## ⚡ Quickstart to contribute |
37 | 18 |
|
38 | | -## Steps to create a new command |
39 | | - 1. Inside the plugin folder run 'npx oclif command <command-name>'. |
40 | | - a. To add a subcommand use a colon separated format as follows: |
41 | | - <command-name:subcommand-name> |
42 | | - 2. Replace the import 'import {Command, flags} from '@oclif/command' line inside the newly created command with '@microsoft/bf-cli-command' |
43 | | - |
44 | | - - import {Command, flags} from '@oclif/command' |
45 | | - + import {Command, flags} from '@microsoft/bf-cli-command' |
46 | | - |
47 | | - 3. Add the typing to the flags property like this if needed: |
48 | | - |
49 | | - static flags: flags.Input<any> = { |
50 | | - help: flags.help({description: 'Display help'}), |
51 | | - } |
52 | | - |
53 | | - 4. Implement the run method |
| 19 | +0. Fork the repo at https://github.com/microsoft/botframework-cli |
| 20 | +0. Clone your fork - `git clone https://github.com/<YOU>/botframework-cli.git` |
| 21 | +0. `npm i -g @microsoft/rush` |
| 22 | + - Install rush |
| 23 | +0. `rush update` |
| 24 | + - installs and links packages - use `rush install` and `rush link` for readonly |
| 25 | +0. `rush build` |
| 26 | + - builds all the projects |
| 27 | +0. `rush test` |
| 28 | + - runs tests in all the projects |
54 | 29 |
|
55 | | -## General Guidelines |
| 30 | +## 💅 Tips |
| 31 | + |
| 32 | +- DO NOT USE `npm install` (and in general avoid `npm` commands). If you need to add a package, look at `rush add` or modify the package.json directly. |
| 33 | +- We don't hoist common dev dependencies from a single list. It must be declared in each package, but pnpm will only install it once. |
| 34 | +- You can use `rush --help` to get more details about what commands you can run. |
| 35 | +- You can also use `rushx` to run specific commands in a given package (but rush install/link usually needs to have run for it to work). |
| 36 | + |
| 37 | +## 📃 General Guidelines |
56 | 38 |
|
57 | 39 | ### Common Options Rules |
58 | 40 |
|
|
79 | 61 | - Detect --in / --out file or folder based on specified value. If need to disambiguate introduce param (only if no way to infer). |
80 | 62 | - Use the input/output stream tables below to guide command line I/O processing |
81 | 63 |
|
82 | | - |
83 | | - |
84 | 64 | #### Input Stream |
85 | 65 |
|
86 | 66 | | Specified | Expected | Exist | File Action | Folder Action | |
@@ -179,3 +159,58 @@ CLI contribution Software Development Lifecycle is as follows: |
179 | 159 | 3. Implement. All code must be test-covered at > 90% coverage integrated into CI. |
180 | 160 | 4. Schedule a team show & tell demo for introduction, feedback and fine tuning |
181 | 161 |
|
| 162 | +## ❓ FAQ |
| 163 | + |
| 164 | +### Why rush/pnpm? |
| 165 | + |
| 166 | +Rush and pnpm are newer tools and not all that popular outside of Microsoft, why use them? |
| 167 | + |
| 168 | +- Speed. We get ordered and parallel builds for free. |
| 169 | +- Standarization. Many of the Microsoft JS repos are moving to `rush`. |
| 170 | +- Quality of life. The command line help, enforcement & customization tools, etc. that come from `rush` and `pnpm` are super useful. Also, we like avoiding the "parent" project for hoisting dependencies. That frequently bites us with our old system. |
| 171 | + |
| 172 | +### Steps to create a new plugin |
| 173 | + |
| 174 | + 1. Build the project |
| 175 | + 2. Inside the packages folder(https://github.com/microsoft/botframework-cli/tree/master/packages) run 'npx oclif plugin <plugin-name>' |
| 176 | + 3. Follow the wizard and set the prompts: |
| 177 | + |
| 178 | + ? npm package: @microsoft/bf-<plugin-name> |
| 179 | + ? description: <Plugin brief description> |
| 180 | + ? author: Microsoft |
| 181 | + ? version: 1.0.0 |
| 182 | + ? license: MIT |
| 183 | + ? Who is the GitHub owner of repository (https://github.com/OWNER/repo): microsoft |
| 184 | + ? What is the GitHub name of repository (https://github.com/owner/REPO): botframework-cli |
| 185 | + ? Select a package manager: npm |
| 186 | + ? TypeScript: Y |
| 187 | + ? Use tslint (linter for TypeScript): Y |
| 188 | + ? Use mocha (testing framework): Y |
| 189 | + ? Add CI service config (Press <space> to select, <a> to toggle all, <i> to invert selection): select any |
| 190 | + |
| 191 | + 4. Go to the folder created by the previous command and add @microsoft/bf-cli-command as a dependency in your package.json file |
| 192 | + |
| 193 | + "dependencies": { |
| 194 | + ..., |
| 195 | + "@microsoft/bf-cli-command": "1.0.0", |
| 196 | + ... |
| 197 | + } |
| 198 | + |
| 199 | + 5. At the root level(https://github.com/microsoft/botframework-cli) run 'npm run build' to bootstrap the packages |
| 200 | + |
| 201 | +### Steps to create a new command |
| 202 | + 1. Inside the plugin folder run 'npx oclif command <command-name>'. |
| 203 | + a. To add a subcommand use a colon separated format as follows: |
| 204 | + <command-name:subcommand-name> |
| 205 | + 2. Replace the import 'import {Command, flags} from '@oclif/command' line inside the newly created command with '@microsoft/bf-cli-command' |
| 206 | + |
| 207 | + - import {Command, flags} from '@oclif/command' |
| 208 | + + import {Command, flags} from '@microsoft/bf-cli-command' |
| 209 | + |
| 210 | + 3. Add the typing to the flags property like this if needed: |
| 211 | + |
| 212 | + static flags: flags.Input<any> = { |
| 213 | + help: flags.help({description: 'Display help'}), |
| 214 | + } |
| 215 | + |
| 216 | + 4. Implement the run method |
0 commit comments