Skip to content

Minimal Path to Awesome

Milan Holemans edited this page Mar 24, 2024 · 17 revisions

The shortest way to prepare your local copy of the project for development and testing.

Install prerequisites

Before you start contributing to this project, you will need Node.js@20 and npm@10 installed.

Get the local version of the CLI

  1. Fork this repository
  2. Clone your fork to your local machine
  3. In the root of the project, run the following commands in your command line:
    1. npm i: restore all dependencies of the project
    2. npm run build: build the entire project
    3. npm link: create a link/reference to your local project. This allows you to reference your locally installed CLI instead of the npm-hosted package.

If you installed the CLI globally using the npm i -g @pnp/cli-microsoft365 command, we recommend that you uninstall it first, before running npm link

That's it! If you now run m365 version you will see that you are now using the beta version of CLI for Microsoft 365 in your shell!

Setting up your IDE

It doesn't really matter which IDE you are using. 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 will help you when writing tests. It is capable of running individual tests and debugging. You will also get a nice overview of all tests within the project.
ESLint We use ESLint to monitor consistency within the project. By installing this extension, you are notified of problems while writing code.

Npm scripts

CLI for Microsoft 365 comes with a set of commands that you will need during development.

Command Description
npm run build Builds the entire project.
npm run watch Builds the entire project first. After this, a watcher will make sure that every time a file is saved, an incremental build is triggered. This means that not the entire project is rebuilt but only the changed files. You typically use this command while developing.
npm run clean Clean the output directory. All built files will be deleted.
npm run test Run all tests, check all ESLint rules, ... This is a combination of npm run test:cov and npm run lint. This is what happens in our GitHub workflows when creating a PR.
npm run test:cov Run all tests and create a coverage report.
npm run test:test Run all tests.
npm run lint Run all ESLint rules.

Documentation

CLI for Microsoft 365 uses Docusaurus to publish documentation pages.

Preview docs locally

After doing any kind of modifications to the docs it's always good to check them locally before submitting a PR. To run your local development server that will serve CLI for Microsoft 365 docs locally simply go to the /docs folder and run

npm run start

For more information check out running the development server guide