Skip to content

Latest commit

 

History

History
108 lines (71 loc) · 4.65 KB

DEVELOPING.md

File metadata and controls

108 lines (71 loc) · 4.65 KB

Developing

Table of Contents

One-time Setup
Quick Start
Testing
Debugging
Linking the Packaging Library
Running Commands
Useful Yarn Commands


One-time Setup

  1. Install NodeJS. If you need to work with multiple versions of Node, you might consider using nvm.
    Suggestion: use the current LTS version of node.
  2. Install yarn to manage node dependencies.
    Suggestion: install yarn globally using npm install --global yarn
  3. Clone this repository from git. E.g., (ssh):
    git clone [email protected]:salesforcecli/plugin-packaging.git
  4. Configure git commit signing.

Quick Start

  1. cd into the plugin-packaging directory
  2. Checkout the main branch: git checkout main
  3. Get all latest changes: git pull
  4. Download NPM dependencies: yarn install. If it's been a while since you last did this you may want to run yarn clean-all before this step.
  5. Build and lint the code: yarn build
  6. Create a branch off main for new work: git checkout -b <branch_name> Suggestion: use branch_name format of initials/work-title. For external contributors, please fork the main branch of the repo instead and PR the fork to the main branch.
  7. Make code changes and build: yarn build
  8. Run changed commands: ./bin/dev force:package:beta:create -h
  9. Write tests and run: yarn test (unit) and/or yarn test:nuts (NUTs)
  10. Show all changed files: git status
  11. Add all files to staging: git add .
  12. Commit staged files with helpful commit message: git commit
  13. Push commit(s) to remote: git push -u origin <branch_name>
  14. Create a pull request (PR) using the GitHub UI here.

Testing

All changes must have associated tests. This library uses a combination of unit testing and NUTs (non-unit tests).

Unit tests

Unit tests are run with yarn test and use the mocha test framework. Tests are located in the test directory and are named with the pattern, <test-file>.test.ts. E.g., install.test.ts. Reference the existing unit tests when writing and testing code changes.

NUTs (non-unit tests)

Non-unit tests are run with yarn test:nuts and use the cli-plugin-testkit framework. These tests run using the default devhub in your environment. If you're running the 1GP package NUTs you will need to set the ONEGP_TESTKIT_AUTH_URL environment variable as a target org. NUTs are a way to test the library code in a real environment versus a unit test environment where many things are stubbed.

Debugging

If you need to debug plugin code or tests you should refer to the excellent documentation on this topic in the Plugin Developer Guide.

Linking the packaging library

When you want to use a branch of the packaging library in this plugin to test changes, reference this doc in the packaging library.

Running Commands

To run your modified plugin commands locally, use ./bin/dev or ./bin/dev.cmd file, which uses ts-node to execute the plugin's TypeScript commands.

# Run using local dev file.
./bin/dev force:package:create --help

There should be no differences when running via the Salesforce CLI or using the local scripts. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.

# Link your plugin to the sf cli
sf plugins:link .
# To verify
sf plugins
# To run
sf force package create --help

Useful yarn commands

yarn install

This downloads all NPM dependencies into the node_modules directory.

yarn compile

This compiles the typescript to javascript.

yarn lint

This lints all the typescript using eslint.

yarn build

This compiles and lints all the typescript (e.g., yarn compile && yarn lint).

yarn clean

This cleans all generated files and directories. Run yarn clean-all to also clean up the node_module directories.

yarn test

This runs unit tests (mocha) for the project using ts-node.

yarn test:nuts

This runs NUTs (non-unit tests) for the project using ts-node.