Skip to content

Commit 6a7ad54

Browse files
committed
feat: add new tests and upadte readme
1 parent 73b429c commit 6a7ad54

File tree

4 files changed

+175
-16
lines changed

4 files changed

+175
-16
lines changed

README.md

+31-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ This repository provides a template for creating a plugin for the Salesforce CLI
1919

2020
<REPLACE ME DESCRIPTION END>
2121

22-
### Everything past here is only a suggestion as to what should be in your specific plugin's descsription.
22+
## Learn about the plugin-template
23+
24+
Salesforce CLI plugins are based on the [oclif plugin framework](<(https://oclif.io/docs/introduction.html)>). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development.
25+
26+
This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](https://github.com/forcedotcom/sfdx-dev-packages/) used by Salesforce. There is also a default circleci config using the [release management orb](https://github.com/forcedotcom/npm-release-management-orb) standards.
27+
28+
Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is recommended to keep these tests active in your plugin, regardless if you plan to have it bundled.
29+
30+
# Everything past here is only a suggestion as to what should be in your specific plugin's description
2331

2432
## Getting Started
2533

@@ -36,16 +44,29 @@ To run a command
3644

3745
To build the plugin locally, make sure to have yarn installed and run the following commands:
3846

47+
```bash
48+
# Clone the repository
49+
git clone git@github.com:salesforcecli/plugin-<REPLACE_ME>
50+
51+
# Install the dependencies and compile
52+
yarn install
53+
yarn build
3954
```
40-
Clone the repository
41-
$ git clone git@github.com:salesforcecli/plugin-<REPLACE_ME>
42-
Install the dependencies and compile
43-
$ yarn install
44-
$ yarn prepack
45-
Link your plugin to the sfdx cli
46-
$ sfdx plugins:link .
47-
To verify
48-
$ sfdx plugins
55+
56+
To use your plugin, run using the local `./bin/run` or `./bin/run.cmd` file.
57+
58+
```bash
59+
# Run using local run file.
60+
./bin/run hello:world
61+
```
62+
63+
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.
64+
65+
```bash
66+
# Link your plugin to the sfdx cli
67+
sfdx plugins:link .
68+
# To verify
69+
sfdx plugins
4970
```
5071

5172
## Debugging your plugin

command-snapshot.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"command": "hello:org",
4+
"plugin": "@salesforce/plugin-template",
5+
"flags": ["apiversion", "force", "json", "loglevel", "name", "targetdevhubusername", "targetusername"]
6+
}
7+
]

package.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
},
1313
"devDependencies": {
1414
"@oclif/dev-cli": "^1",
15+
"@oclif/plugin-command-snapshot": "^2.0.0",
1516
"@salesforce/dev-config": "^2.0.0",
1617
"@salesforce/dev-scripts": "0.6.2",
18+
"@salesforce/plugin-command-reference": "^1.2.3",
1719
"@salesforce/prettier-config": "^0.0.1",
1820
"@salesforce/ts-sinon": "1.1.3",
1921
"@typescript-eslint/eslint-plugin": "^2.30.0",
@@ -66,7 +68,9 @@
6668
"commands": "./lib/commands",
6769
"bin": "sfdx",
6870
"devPlugins": [
69-
"@oclif/plugin-help"
71+
"@oclif/plugin-help",
72+
"@oclif/plugin-command-snapshot",
73+
"@salesforce/plugin-command-reference"
7074
],
7175
"topics": {
7276
"hello": {
@@ -85,7 +89,9 @@
8589
"format": "sf-format",
8690
"lint": "sf-lint",
8791
"postpack": "shx rm -f oclif.manifest.json",
88-
"posttest": "yarn lint",
92+
"posttest": "yarn lint && yarn test:deprecation-policy && yarn test:command-reference",
93+
"test:deprecation-policy": "./bin/run snapshot:compare",
94+
"test:command-reference": "./bin/run commandreference:generate -p @salesforce/plugin-templates --erroronwarnings",
8995
"prepack": "sf-build",
9096
"prepare": "sf-install",
9197
"pretest": "sf-compile-test",

yarn.lock

+129-4
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@
356356
"@nodelib/fs.scandir" "2.1.3"
357357
fastq "^1.6.0"
358358

359-
"@oclif/command@^1.5.13", "@oclif/command@^1.5.17", "@oclif/command@^1.5.20", "@oclif/command@^1.6.0":
359+
"@oclif/command@^1.5.13", "@oclif/command@^1.5.17", "@oclif/command@^1.5.19", "@oclif/command@^1.5.20", "@oclif/command@^1.6.0":
360360
version "1.8.0"
361361
resolved "https://registry.npmjs.org/@oclif/command/-/command-1.8.0.tgz#c1a499b10d26e9d1a611190a81005589accbb339"
362362
integrity sha512-5vwpq6kbvwkQwKqAoOU3L72GZ3Ta8RRrewKj9OJRolx28KLJJ8Dg9Rf7obRwt5jQA9bkYd8gqzMTrI7H3xLfaw==
@@ -368,7 +368,7 @@
368368
debug "^4.1.1"
369369
semver "^7.3.2"
370370

371-
"@oclif/config@^1", "@oclif/config@^1.12.12", "@oclif/config@^1.15.1":
371+
"@oclif/config@^1", "@oclif/config@^1.12.12", "@oclif/config@^1.14.0", "@oclif/config@^1.15.1":
372372
version "1.17.0"
373373
resolved "https://registry.npmjs.org/@oclif/config/-/config-1.17.0.tgz#ba8639118633102a7e481760c50054623d09fcab"
374374
integrity sha512-Lmfuf6ubjQ4ifC/9bz1fSCHc6F6E653oyaRXxg+lgT4+bYf9bk+nqrUpAbrXyABkCqgIBiFr3J4zR/kiFdE1PA==
@@ -424,6 +424,17 @@
424424
chalk "^2.4.2"
425425
tslib "^1.9.3"
426426

427+
"@oclif/plugin-command-snapshot@^2.0.0":
428+
version "2.0.0"
429+
resolved "https://registry.yarnpkg.com/@oclif/plugin-command-snapshot/-/plugin-command-snapshot-2.0.0.tgz#61ee06fc191a34d096024a49fdae0026c88095dc"
430+
integrity sha512-DfEydDlic4TUY4MpgP1UGrRpdAzJZGH2RN0CxEkJ9mM4Z+q61YBjR56IVW2m4mz26DpOHAn7l6luA2WvRVHXXA==
431+
dependencies:
432+
"@oclif/command" "^1.6.0"
433+
"@oclif/config" "^1"
434+
chalk "^4.0.0"
435+
sinon "^9.0.0"
436+
tslib "^2"
437+
427438
"@oclif/plugin-help@^2.1.6", "@oclif/plugin-help@^2.2.0":
428439
version "2.2.3"
429440
resolved "https://registry.npmjs.org/@oclif/plugin-help/-/plugin-help-2.2.3.tgz#b993041e92047f0e1762668aab04d6738ac06767"
@@ -477,6 +488,22 @@
477488
mv "~2"
478489
safe-json-stringify "~1"
479490

491+
"@salesforce/command@^3.0.0":
492+
version "3.0.5"
493+
resolved "https://registry.yarnpkg.com/@salesforce/command/-/command-3.0.5.tgz#262665e0845f247005916b2a3ac62e1244b078e4"
494+
integrity sha512-FhQjRALvcqXjVjv/tjPweqyN6bEhVrxV2cyM+gqns5aY5GQy9KMtNI6Sg/D5Mg4Htf89jHgV+iqgndNzGyDX2g==
495+
dependencies:
496+
"@oclif/command" "^1.5.17"
497+
"@oclif/errors" "^1.2.2"
498+
"@oclif/parser" "^3.8.3"
499+
"@oclif/plugin-help" "^2.2.0"
500+
"@oclif/test" "^1.2.4"
501+
"@salesforce/core" "^2.15.2"
502+
"@salesforce/kit" "^1.2.2"
503+
"@salesforce/ts-types" "^1.2.0"
504+
chalk "^2.4.2"
505+
cli-ux "^4.9.3"
506+
480507
"@salesforce/command@^3.0.3":
481508
version "3.0.3"
482509
resolved "https://registry.yarnpkg.com/@salesforce/command/-/command-3.0.3.tgz#e750268bda094560992f1f494774d75f3644f6e3"
@@ -493,6 +520,26 @@
493520
chalk "^2.4.2"
494521
cli-ux "^4.9.3"
495522

523+
"@salesforce/core@^2.15.2", "@salesforce/core@^2.2.0":
524+
version "2.15.2"
525+
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-2.15.2.tgz#7e2b0ac6c1d67f850a461e007298d1381b37c07a"
526+
integrity sha512-PCP9HdGEl4us8X66tOfwlTOGFRju8m7ezqfBlH7nRzmKw57i2l0LhXBEZ+DPwEBtAwa9wlvd9FhMmlhUYhm/EQ==
527+
dependencies:
528+
"@salesforce/bunyan" "^2.0.0"
529+
"@salesforce/kit" "^1.3.3"
530+
"@salesforce/schemas" "^1.0.1"
531+
"@salesforce/ts-types" "^1.0.0"
532+
"@types/graceful-fs" "^4.1.3"
533+
"@types/jsforce" "1.9.23"
534+
"@types/mkdirp" "1.0.0"
535+
debug "^3.1.0"
536+
graceful-fs "^4.2.4"
537+
jsen "0.6.6"
538+
jsforce "1.9.3"
539+
jsonwebtoken "8.5.0"
540+
mkdirp "1.0.4"
541+
sfdx-faye "^1.0.9"
542+
496543
"@salesforce/core@^2.6.0":
497544
version "2.10.0"
498545
resolved "https://registry.npmjs.org/@salesforce/core/-/core-2.10.0.tgz#947a64a6c493337c55eff82545a8b0e8ae58e945"
@@ -565,6 +612,28 @@
565612
"@salesforce/ts-types" "^1.4.2"
566613
tslib "^1.10.0"
567614

615+
"@salesforce/kit@^1.3.3":
616+
version "1.3.3"
617+
resolved "https://registry.yarnpkg.com/@salesforce/kit/-/kit-1.3.3.tgz#eaea23b1be7aebb81f9f091c8f77c2733a8ae710"
618+
integrity sha512-Ed5lh8xyCwaXeB1Sovr9xbQZ1tpQg5vSeNvKROlJQRk4Gj3IBm73pKPPuNn+AeXN51lWr9my0ftLREtyig3FoA==
619+
dependencies:
620+
"@salesforce/ts-types" "^1.4.3"
621+
tslib "^1.10.0"
622+
623+
"@salesforce/plugin-command-reference@^1.2.3":
624+
version "1.2.3"
625+
resolved "https://registry.yarnpkg.com/@salesforce/plugin-command-reference/-/plugin-command-reference-1.2.3.tgz#7f4228cf8c37958a203617e66a447463d4b42eb9"
626+
integrity sha512-uXxrnhm9foCMKgJOL9tijeMr20aDwaVlPpTNIAQLMD52ZB8dtwB9qj+V4q2keZ8A464+e1DjCPTe45QUUEWATg==
627+
dependencies:
628+
"@oclif/command" "^1.5.19"
629+
"@oclif/config" "^1.14.0"
630+
"@oclif/errors" "^1.2.2"
631+
"@salesforce/command" "^3.0.0"
632+
"@salesforce/core" "^2.2.0"
633+
chalk "^3.0.0"
634+
handlebars "^4.7.3"
635+
tslib "^1"
636+
568637
"@salesforce/prettier-config@^0.0.1":
569638
version "0.0.1"
570639
resolved "https://registry.npmjs.org/@salesforce/prettier-config/-/prettier-config-0.0.1.tgz#4ef70bca610ea981181fb030b25a27797b15cdff"
@@ -591,7 +660,14 @@
591660
dependencies:
592661
tslib "^1.10.0"
593662

594-
"@sinonjs/commons@^1", "@sinonjs/commons@^1.3.0", "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.7.2":
663+
"@salesforce/ts-types@^1.4.3":
664+
version "1.4.3"
665+
resolved "https://registry.yarnpkg.com/@salesforce/ts-types/-/ts-types-1.4.3.tgz#941ceac6d72a2983ec03d5263b509f25bab574c3"
666+
integrity sha512-Fdx9KEBalwxBFkP0ZW9uIcndjFys9fm8ma9vItd3EwPZLJcAHWfBa5/y9uHLAvYHkKK8F8FYE0sRrVZ1cn48hw==
667+
dependencies:
668+
tslib "^1.10.0"
669+
670+
"@sinonjs/commons@^1", "@sinonjs/commons@^1.3.0", "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.7.2", "@sinonjs/commons@^1.8.1":
595671
version "1.8.1"
596672
resolved "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217"
597673
integrity sha512-892K+kWUUi3cl+LlqEWIDrhvLgdL79tECi8JZUyq6IviKy/DNhuzCRlbHUjxK89f4ypPMMaFnFuR9Ie6DoIMsw==
@@ -646,6 +722,15 @@
646722
lodash.get "^4.4.2"
647723
type-detect "^4.0.8"
648724

725+
"@sinonjs/samsam@^5.2.0":
726+
version "5.3.0"
727+
resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-5.3.0.tgz#1d2f0743dc54bf13fe9d508baefacdffa25d4329"
728+
integrity sha512-hXpcfx3aq+ETVBwPlRFICld5EnrkexXuXDwqUNhDdr5L8VjvMeSRwyOa0qL7XFmR+jVWR4rUZtnxlG7RX72sBg==
729+
dependencies:
730+
"@sinonjs/commons" "^1.6.0"
731+
lodash.get "^4.4.2"
732+
type-detect "^4.0.8"
733+
649734
"@sinonjs/text-encoding@^0.7.1":
650735
version "0.7.1"
651736
resolved "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5"
@@ -686,6 +771,13 @@
686771
resolved "https://registry.npmjs.org/@types/jsforce/-/jsforce-1.9.2.tgz#a321866dcb7c9c4c57a1d794d54ec52e3f07ff0b"
687772
integrity sha512-ZRRPNf/e44QnFI8VEsPxzrM/+Y5vx/HGsMI8qE4JvBHDkSfoFWAdZ93uW6Oh3sHmcoShexcoTH9gufihTgYBLQ==
688773

774+
"@types/jsforce@1.9.23":
775+
version "1.9.23"
776+
resolved "https://registry.yarnpkg.com/@types/jsforce/-/jsforce-1.9.23.tgz#06c2b604e02bfc8ba1143c6bf53530e565f18bae"
777+
integrity sha512-p1aqPWapTAG5xpTpebj4jSs5cwpNHe5PYFtEXCIjsSgfFgIW7GgQb5X/43/M8gkZNcGe8kchykrD9UgYKjz3eQ==
778+
dependencies:
779+
"@types/node" "*"
780+
689781
"@types/json-schema@^7.0.3":
690782
version "7.0.6"
691783
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"
@@ -711,6 +803,13 @@
711803
resolved "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
712804
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=
713805

806+
"@types/mkdirp@1.0.0":
807+
version "1.0.0"
808+
resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-1.0.0.tgz#16ce0eabe4a9a3afe64557ad0ee6886ec3d32927"
809+
integrity sha512-ONFY9//bCEr3DWKON3iDv/Q8LXnhaYYaNDeFSN0AtO5o4sLf9F0pstJKKKjQhXE0kJEeHs8eR6SAsROhhc2Csw==
810+
dependencies:
811+
"@types/node" "*"
812+
714813
"@types/mocha@^7.0.2":
715814
version "7.0.2"
716815
resolved "https://registry.npmjs.org/@types/mocha/-/mocha-7.0.2.tgz#b17f16cf933597e10d6d78eae3251e692ce8b0ce"
@@ -1257,6 +1356,14 @@ chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2:
12571356
escape-string-regexp "^1.0.5"
12581357
supports-color "^5.3.0"
12591358

1359+
chalk@^3.0.0:
1360+
version "3.0.0"
1361+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
1362+
integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
1363+
dependencies:
1364+
ansi-styles "^4.1.0"
1365+
supports-color "^7.1.0"
1366+
12601367
chardet@^0.7.0:
12611368
version "0.7.0"
12621369
resolved "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
@@ -2827,7 +2934,7 @@ growl@1.10.5:
28272934
resolved "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e"
28282935
integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==
28292936

2830-
handlebars@^4.7.6:
2937+
handlebars@^4.7.3, handlebars@^4.7.6:
28312938
version "4.7.6"
28322939
resolved "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
28332940
integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
@@ -5268,6 +5375,19 @@ sinon@5.1.1:
52685375
supports-color "^5.4.0"
52695376
type-detect "^4.0.8"
52705377

5378+
sinon@^9.0.0:
5379+
version "9.2.1"
5380+
resolved "https://registry.yarnpkg.com/sinon/-/sinon-9.2.1.tgz#64cc88beac718557055bd8caa526b34a2231be6d"
5381+
integrity sha512-naPfsamB5KEE1aiioaoqJ6MEhdUs/2vtI5w1hPAXX/UwvoPjXcwh1m5HiKx0HGgKR8lQSoFIgY5jM6KK8VrS9w==
5382+
dependencies:
5383+
"@sinonjs/commons" "^1.8.1"
5384+
"@sinonjs/fake-timers" "^6.0.1"
5385+
"@sinonjs/formatio" "^5.0.1"
5386+
"@sinonjs/samsam" "^5.2.0"
5387+
diff "^4.0.2"
5388+
nise "^4.0.4"
5389+
supports-color "^7.1.0"
5390+
52715391
sinon@^9.0.2:
52725392
version "9.0.3"
52735393
resolved "https://registry.npmjs.org/sinon/-/sinon-9.0.3.tgz#bffc3ec28c936332cd2a41833547b9eed201ecff"
@@ -5849,6 +5969,11 @@ tslib@^1, tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
58495969
resolved "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
58505970
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
58515971

5972+
tslib@^2:
5973+
version "2.0.3"
5974+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.3.tgz#8e0741ac45fc0c226e58a17bfc3e64b9bc6ca61c"
5975+
integrity sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==
5976+
58525977
tslib@^2.0.0:
58535978
version "2.0.1"
58545979
resolved "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e"

0 commit comments

Comments
 (0)