Setup your development environment
Setting up your local copy of the project for development and testing is essential. Follow the steps below to configure your environment.
Before you start contributing to this project, you will need node@18 and npm@8 installed.
To avoid having to install all dependencies by hand you can use Github Codespaces or our dev container. More information can be found under GitHub Codespaces & Visual Studio Remote Development Container.
Getting your local version of the CLI
Setting up your GitHub fork
- Navigate to the CLI for Microsoft 365 repository.
- Fork this repository. On the GitHub repository page, click the "Fork" button to create your own copy of the repository.
- Make sure the option 'Copy the
mainbranch only' is selected.
- Make sure the option 'Copy the
- Clone the forked repository to your local machine using Git. Navigate to a folder where you want to store your local copy of the CLI. Then execute the following command in your terminal:
git clone [repository URL of your fork].
For more insights about forking a repository, refer to the GitHub Docs - Fork a repo guide.
Setting up your local project
After you've cloned your fork onto your device, navigate to the project directory and execute the following commands to get the project running.
If you have installed the CLI globally using the
npm i -g @pnp/cli-microsoft365 command, we recommend that you uninstall it, using
npm un -g @pnp/cli-microsoft365, before running
npm ito restore all project dependencies.
npm run buildto build the entire project.
npm linkto create a link/reference to your local project. This allows you to reference your locally installed CLI instead of the npm-hosted package.
That's it! If you run
m365 version now, you will see that you are using the beta version of CLI for Microsoft 365 in your shell!
Visual Studio Code extensions
Although you can use any IDE, we recommend using Visual Studio Code. When using VS Code, the following extensions will come in handy:
|Extension||Why is it useful?|
|Mocha Test Explorer||This extension helps you when writing tests. It can run individual tests and facilitate debugging. You also get a nice overview of all tests within the project.|
|ESLint||We use ESLint to ensure code consistency within the project. By installing this extension, you will be notified of problems while writing code.|
|MDX||We use MDX to write our documentation. This extension provides syntax highlighting and other useful features when writing MDX files.|
During your development, you will need a set of commands to test, run, and validate your code. The CLI for Microsoft 365 comes with a set of commands that you can use for each occasion.
|Builds the entire project first. After this, a watcher will trigger an incremental build every time a file is saved. This means that only the changed files are rebuilt, not the entire project. You typically use this command while developing.|
|Builds the entire project.|
|Cleans the output directory by deleting all built files.|
|Runs all tests and checks all ESLint rules. This is a combination of |
|Runs all tests and creates a coverage report.|
With these commands at your disposal, you're ready to contribute to the CLI for Microsoft 365 repository!
Now that your local environment is ready to go, you can take the following steps to start contributing to the CLI for Microsoft 365:
Adding a new command
Learn how to add a new command to the CLI for Microsoft 365 by following these steps:
Adding a new script sample
Explore the process of adding a new script sample to the CLI for Microsoft 365 with the following steps: