Skip to content

Commit

Permalink
Merge pull request #1 from salesforcecli/wr/addCommands
Browse files Browse the repository at this point in the history
fix: add command, test, config/readme housekeeping
  • Loading branch information
WillieRuemmele authored Nov 18, 2020
2 parents df5652e + 10d0de6 commit 746f68a
Show file tree
Hide file tree
Showing 19 changed files with 1,967 additions and 271 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ yarn-error.log
lerna-debug.log

# compile source
lib
lib/*
!src/lib/*

# test artifacts
*xunit.xml
Expand All @@ -32,4 +33,4 @@ node_modules

# os specific files
.DS_Store
.idea
.idea
41 changes: 15 additions & 26 deletions COMMANDS.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
## Commands

A list of the available commands
validate a digital signature for a npm package

- [`sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-helloorg--n-string--f--v-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
- [`sfdx plugins:trust:verify -n <string> [-r <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`]

## `sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
## `sfdx plugins:trust:verify -n <string> [-r <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

print a greeting and your org IDs

```
USAGE
$ sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
```USAGE
$ sfdx plugins:trust:verify -n <string> [-r <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-f, --force example boolean flag
-n, --name=name name to print
-u, --targetusername=targetusername username or alias for the target
org; overrides default target org
-n, --npm=npm (required) Specify the npm
name. This can include a
tag/version
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
org; overrides default dev hub org
--apiversion=apiversion override the api version used for
api requests made by this command
-r, --registry=registry The registry name. the
behavior is the same as npm
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging
level for this command
invocation
EXAMPLES
$ sfdx hello:org --targetusername [email protected] --targetdevhubusername [email protected]
Hello world! This is org: MyOrg and I will be around until Tue Mar 20 2018!
My hub org id is: 00Dxx000000001234
$ sfdx hello:org --name myname --targetusername [email protected]
Hello myname! This is org: MyOrg and I will be around until Tue Mar 20 2018!
sfdx plugins:trust:verify --npm @scope/npmName --registry http://my.repo.org:4874
sfdx plugins:trust:verify --npm @scope/npmName
```
74 changes: 23 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
# plugin-&lt;REPLACE ME&gt;
# plugin-trust

Change above to <REPLACE_ME> before finalizing

&lt;REPLACE ME DESCRIPTION START&gt;

This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:

1. Clone this repo
2. Delete the .git folder
3. Replace filler values
a) Every instance of `<REPLACE_ME>` can be directly substitued for the name of the new plugin. However beware, things like github paths are for the salesforcecli Github organization
b) Search for case-matching `REPLACE` to find other filler values, such as for the plugin description
4. Use `git init` to set up the desired git information
5. Follow the getting started steps below until the `sfdx hello:org` commmand is functioning
6. In order to prevent build failures on the intial build, you will need to do the following:
1. `npm publish`
2. `git tag v1.0.0 ; git push origin v1.0.0`

&lt;REPLACE ME DESCRIPTION END&gt;

### Everything past here is only a suggestion as to what should be in your specific plugin's descsription.
commands to verify the authenticity of a plugin

## Getting Started

Expand All @@ -28,8 +9,8 @@ To use, install the [Salesforce CLI](https://developer.salesforce.com/tools/sfdx
```
Verify the CLI is installed
$ sfdx (-v | --version)
Install the <REPLACE_ME> plugin
$ sfdx plugins:install <REPLACE_ME>
Install the plugin-trust plugin
$ sfdx plugins:install plugin-trust
To run a command
$ sfdx [command]
```
Expand All @@ -38,7 +19,7 @@ To build the plugin locally, make sure to have yarn installed and run the follow

```
Clone the repository
$ git clone [email protected]:salesforcecli/plugin-<REPLACE_ME>
$ git clone [email protected]:salesforcecli/plugin-trust
Install the dependencies and compile
$ yarn install
$ yarn prepack
Expand All @@ -52,7 +33,7 @@ To verify

We recommend using the Visual Studio Code (VS Code) IDE for your plugin development. Included in the `.vscode` directory of this plugin is a `launch.json` config file, which allows you to attach a debugger to the node process when running your commands.

To debug the `hello:org` command:
To debug the `plugins:trust:verify` command:

If you linked your plugin to the sfdx cli, call your command with the `dev-suspend` switch:

Expand All @@ -63,53 +44,44 @@ $ sfdx hello:org -u [email protected] --dev-suspend
Alternatively, to call your command using the `bin/run` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:

```sh-session
$ NODE_OPTIONS=--inspect-brk bin/run hello:org -u [email protected]
$ NODE_OPTIONS=--inspect-brk bin/run plugins:trust:verify
```

2. Set some breakpoints in your command code
3. Click on the Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
4. In the upper left hand corner of VS Code, verify that the "Attach to Remote" launch configuration has been chosen.
5. Hit the green play button to the left of the "Attach to Remote" launch configuration window. The debugger should now be suspended on the first line of the program.
6. Hit the green play button at the top middle of VS Code (this play button will be to the right of the play button that you clicked in step #5).
<br><img src=".images/vscodeScreenshot.png" width="480" height="278"><br>
![how to debug](./.images/vscodeScreenshot.png)
Congrats, you are debugging!

## Commands

- [`sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-helloorg--n-string--f--v-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
validate a digital signature for a npm package

## `sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
- [`sfdx plugins:trust:verify -n <string> [-r <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`]

print a greeting and your org IDs
## `sfdx plugins:trust:verify -n <string> [-r <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

```
USAGE
$ sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
```USAGE
$ sfdx plugins:trust:verify -n <string> [-r <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-f, --force example boolean flag
-n, --name=name name to print
-u, --targetusername=targetusername username or alias for the target
org; overrides default target org
-n, --npm=npm (required) Specify the npm
name. This can include a
tag/version
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
org; overrides default dev hub org
--apiversion=apiversion override the api version used for
api requests made by this command
-r, --registry=registry The registry name. the
behavior is the same as npm
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging
level for this command
invocation
EXAMPLES
$ sfdx hello:org --targetusername [email protected] --targetdevhubusername [email protected]
Hello world! This is org: MyOrg and I will be around until Tue Mar 20 2018!
My hub org id is: 00Dxx000000001234
$ sfdx hello:org --name myname --targetusername [email protected]
Hello myname! This is org: MyOrg and I will be around until Tue Mar 20 2018!
sfdx plugins:trust:verify --npm @scope/npmName --registry http://my.repo.org:4874
sfdx plugins:trust:verify --npm @scope/npmName
```
22 changes: 0 additions & 22 deletions messages/messages.json

This file was deleted.

6 changes: 0 additions & 6 deletions messages/org.json

This file was deleted.

11 changes: 11 additions & 0 deletions messages/verify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"description": "validate a digital signature for a npm package",
"examples": [
"sfdx plugins:trust:verify --npm @scope/npmName --registry http://my.repo.org:4874",
"sfdx plugins:trust:verify --npm @scope/npmName"
],
"flags": {
"npm": "Specify the npm name. This can include a tag/version",
"registry": "The registry name. the behavior is the same as npm"
}
}
28 changes: 18 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@salesforce/plugin-template",
"description": "A template repository for sfdx plugins",
"name": "@salesforce/plugin-trust",
"description": "validate a digital signature for a npm package",
"version": "1.0.0",
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/config": "^1",
"@salesforce/command": "^3.0.3",
"@salesforce/core": "^2.6.0",
"@oclif/config": "^1.17.0",
"@salesforce/command": "^3.0.5",
"@salesforce/core": "^2.15.2",
"tslib": "^1"
},
"devDependencies": {
Expand Down Expand Up @@ -53,7 +53,7 @@
"/messages",
"/oclif.manifest.json"
],
"homepage": "https://github.com/salesforcecli/plugin-template",
"homepage": "https://github.com/salesforcecli/plugin-trust",
"keywords": [
"force",
"salesforce",
Expand All @@ -64,21 +64,29 @@
"license": "BSD-3-Clause",
"oclif": {
"commands": "./lib/commands",
"bin": "sfdx",
"hooks": {
"plugins:preinstall:verify:signature": [
"./lib/hooks/verifyInstallSignature.js"
]
},
"devPlugins": [
"@oclif/plugin-help"
],
"topics": {
"hello": {
"description": "Commands to say hello."
"plugins": {
"subtopics": {
"trust": {
"description": "validate a digital signature for a npm package"
}
}
}
}
},
"repository": "salesforcecli/plugin-template",
"scripts": {
"build": "sf-build",
"clean": "sf-clean",
"clean-all": "-clean all",
"clean-all": "sf-clean all",
"clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json",
"compile": "sf-compile",
"docs": "sf-docs",
Expand Down
Loading

0 comments on commit 746f68a

Please sign in to comment.