Skip to content

Commit c5cd426

Browse files
committed
fix: add doc for contributing to and developing in the packaging plugin
1 parent daea62a commit c5cd426

File tree

3 files changed

+156
-45
lines changed

3 files changed

+156
-45
lines changed

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Contributing
2+
3+
1. The [DEVELOPING](DEVELOPING.md) doc has details on how to set up your environment.
4+
1. Create a new issue before starting your project so that we can keep track of
5+
what you are trying to add/fix. That way, we can also offer suggestions or
6+
let you know if there is already an effort in progress.
7+
1. Fork this repository (external contributors) or branch off main (committers).
8+
1. Create a _topic_ branch in your fork based on the main branch. Note, this step is recommended but technically not required if contributing using a fork.
9+
1. Edit the code in your fork/branch.
10+
1. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without associated tests.
11+
1. Sign CLA (see [CLA](#cla) below).
12+
1. Send us a pull request when you are done. We'll review your code, suggest any
13+
needed changes, and merge it in.
14+
1. Upon merge, a new release of the `@salesforce/plugin-packaging` plugin will be published to npmjs with a version bump corresponding to commitizen rules.
15+
16+
### CLA
17+
18+
External contributors will be required to sign a Contributor's License
19+
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
20+
21+
## Branches
22+
23+
- We work in branches off of `main`.
24+
- Our released (aka. _production_) branch is `main`.
25+
- Our work happens in _topic_ branches (feature and/or bug-fix).
26+
- feature as well as bug-fix branches are based on `main`
27+
- branches _should_ be kept up-to-date using `rebase`
28+
- [commit messages are enforced](DEVELOPING.md#When-you-are-ready-to-commit)
29+
30+
## Pull Requests
31+
32+
- Develop features and bug fixes in _topic_ branches off main, or forks.
33+
- _Topic_ branches can live in forks (external contributors) or within this repository (committers).
34+
\*\* When creating _topic_ branches in this repository please prefix with `<initials>/`.
35+
- PRs will be reviewed and merged by committers.
36+
37+
## Releasing
38+
39+
- A new version of this plugin (`@salesforce/plugin-packaging`) will be published upon merging PRs to `main`, with the version number increment based on commitizen rules.

DEVELOPING.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Developing
2+
3+
## Table of Contents
4+
5+
[One-time Setup](#one-time-setup)</br>
6+
[Quick Start](#quick-start)</br>
7+
[Testing](#testing)</br>
8+
[Debugging](#debugging)</br>
9+
[Linking the Packaging Library](#linking-the-packaging-library)</br>
10+
[Running Commands](#running-commands)</br>
11+
[Useful Yarn Commands](#useful-yarn-commands)</br>
12+
13+
<hr>
14+
15+
## One-time Setup
16+
17+
1. Install NodeJS. If you need to work with multiple versions of Node, you
18+
might consider using [nvm](https://github.com/creationix/nvm). </br>_Suggestion: use the current [LTS version of node](https://github.com/nodejs/release#release-schedule)._
19+
1. Install [yarn](https://yarnpkg.com/) to manage node dependencies. </br>_Suggestion: install yarn globally using `npm install --global yarn`_
20+
1. Clone this repository from git. E.g., (ssh): </br>`git clone [email protected]:salesforcecli/plugin-packaging.git`
21+
1. Configure [git commit signing](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits).
22+
23+
## Quick Start
24+
25+
1. `cd` into the `plugin-packaging` directory
26+
1. Checkout the main branch: `git checkout main`
27+
1. Get all latest changes: `git pull`
28+
1. 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.
29+
1. Build and lint the code: `yarn build`
30+
1. 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.
31+
1. Make code changes and build: `yarn build`
32+
1. Run changed commands: `./bin/dev force:package:beta:create -h`
33+
1. Write tests and run: `yarn test` (unit) and/or `yarn test:nuts` (NUTs)
34+
1. Show all changed files: `git status`
35+
1. Add all files to staging: `git add .`
36+
1. Commit staged files with helpful commit message: `git commit`
37+
1. Push commit(s) to remote: `git push -u origin <branch_name>`
38+
1. Create a pull request (PR) using the GitHub UI [here](https://github.com/salesforcecli/plugin-packaging).
39+
40+
## Testing
41+
42+
All changes must have associated tests. This library uses a combination of unit testing and NUTs (non-unit tests).
43+
44+
### Unit tests
45+
46+
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](test/commands/force/package/install.test.ts). Reference the existing unit tests when writing and testing code changes.
47+
48+
### NUTs (non-unit tests)
49+
50+
Non-unit tests are run with `yarn test:nuts` and use the [cli-plugin-testkit](https://github.com/salesforcecli/cli-plugins-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.
51+
52+
## Debugging
53+
54+
If you need to debug plugin code or tests you should refer to the excellent documentation on this topic in the [Plugin Developer Guide](https://github.com/salesforcecli/cli/wiki/Debug-Your-Plugin).
55+
56+
## Linking the packaging library
57+
58+
When you want to use a branch of the packaging library in this plugin to test changes, reference [this doc](https://github.com/forcedotcom/packaging/blob/main/DEVELOPING.md#linking-to-the-packaging-plugin) in the packaging library.
59+
60+
## Running Commands
61+
62+
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.
63+
64+
```bash
65+
# Run using local dev file.
66+
./bin/dev force:package:create --help
67+
```
68+
69+
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.
70+
71+
```bash
72+
# Link your plugin to the sfdx cli
73+
sfdx plugins:link .
74+
# To verify
75+
sfdx plugins
76+
# To run
77+
sfdx force:package:create --help
78+
```
79+
80+
## Useful yarn commands
81+
82+
#### `yarn install`
83+
84+
This downloads all NPM dependencies into the node_modules directory.
85+
86+
#### `yarn compile`
87+
88+
This compiles the typescript to javascript.
89+
90+
#### `yarn lint`
91+
92+
This lints all the typescript using eslint.
93+
94+
#### `yarn build`
95+
96+
This compiles and lints all the typescript (e.g., `yarn compile && yarn lint`).
97+
98+
#### `yarn clean`
99+
100+
This cleans all generated files and directories. Run `yarn clean-all` to also clean up the node_module directories.
101+
102+
#### `yarn test`
103+
104+
This runs unit tests (mocha) for the project using ts-node.
105+
106+
#### `yarn test:nuts`
107+
108+
This runs NUTs (non-unit tests) for the project using ts-node.

README.md

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,31 @@
22

33
> :warning: **This plugin is currently in beta. We appreciate any feedback via https://github.com/forcedotcom/cli/issues**
44
5-
[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-packaging.svg?label=@salesforce/plugin-packaging)](https://www.npmjs.com/package/@salesforce/plugin-packaging) [![CircleCI](https://circleci.com/gh/salesforcecli/plugin-packaging/tree/main.svg?style=shield)](https://circleci.com/gh/salesforcecli/plugin-packaging/tree/main) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-packaging.svg)](https://npmjs.org/package/@salesforce/plugin-packaging) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/plugin-packaging/main/LICENSE.txt)
5+
[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-packaging.svg?label=@salesforce/plugin-packaging)](https://www.npmjs.com/package/@salesforce/plugin-packaging) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-packaging.svg)](https://npmjs.org/package/@salesforce/plugin-packaging) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/plugin-packaging/main/LICENSE.txt)
66

7-
## This plugin provides the sfdx cli commands that support Salesforce Packaging Platform
7+
### This plugin provides the sfdx cli commands that support the Salesforce Packaging Platform.
88

99
## Install
1010

11+
This plugin is bundled with the Salesforce CLI, so you typically don't need to install it. However, if you want to install a specific version of the plugin you can run:
12+
1113
```bash
1214
sfdx plugins:install @salesforce/[email protected]
1315
```
1416

17+
_NOTE: If you install a specific version of a bundled plugin you will not get an updated packaging plugin when the CLI updates. You must either update to the packaging plugin version you want manually, or uninstall the version of the plugin you have to go back to the CLI bundled version._
18+
1519
## Issues
1620

1721
Please report any issues at https://github.com/forcedotcom/cli/issues
1822

1923
## Contributing
2024

21-
1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
22-
2. Create a new issue before starting your project so that we can keep track of
23-
what you are trying to add/fix. That way, we can also offer suggestions or
24-
let you know if there is already an effort in progress.
25-
3. Fork this repository.
26-
4. [Build the plugin locally](#build)
27-
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
28-
6. Edit the code in your fork.
29-
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
30-
8. Sign CLA (see [CLA](#cla) below).
31-
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
32-
33-
### CLA
34-
35-
External contributors will be required to sign a Contributor's License
36-
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
37-
38-
### Build
39-
40-
To build the plugin locally, make sure to have yarn installed and run the following commands:
41-
42-
```bash
43-
# Clone the repository
44-
git clone [email protected]:salesforcecli/plugin-packaging.git
45-
46-
# Install the dependencies and compile
47-
yarn install
48-
yarn build
49-
```
50-
51-
To use your plugin, run using the local `./bin/run` or `./bin/run.cmd` file.
52-
53-
```bash
54-
# Run using local run file.
55-
./bin/run package:create --help
56-
```
25+
See [CONTRIBUTING.md](CONTRIBUTING.md)
5726

58-
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
27+
## Developing
5928

60-
```bash
61-
# Link your plugin to the sfdx cli
62-
sfdx plugins:link .
63-
# To verify
64-
sfdx plugins
65-
```
29+
See [DEVELOPING.md](DEVELOPING.md)
6630

6731
## Commands
6832

0 commit comments

Comments
 (0)