Skip to content

Commit cda4b6a

Browse files
authored
chore: update repo to use @oclif/core [skip ci] (#12)
* chore: update repo to use @oclif/core and add base project deploy command * chore: code review * chore: code review
1 parent 5820359 commit cda4b6a

File tree

16 files changed

+317
-623
lines changed

16 files changed

+317
-623
lines changed

.circleci/config.yml

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
11
version: 2.1
22
orbs:
33
release-management: salesforce/npm-release-management@4
4+
parameters:
5+
run-auto-workflows:
6+
description: >
7+
Boolean that controls when an workflow would run.
8+
9+
It is used to gate which workflows should run when github events occur.
10+
11+
This parameter is used by automation to determine if a workflow will run
12+
within a pipeline.
13+
default: true
14+
type: boolean
15+
run-just-nuts:
16+
description: >
17+
Boolean that controls when the just-nuts will run.
18+
19+
Default value is false and this parameter is used by automation to
20+
determine if
21+
22+
the just-nuts workflow will run.
23+
default: false
24+
type: boolean
25+
sfdx_version:
26+
description: |
27+
By default, the latest version of the standalone CLI will be installed.
28+
To install via npm, supply a version tag such as "latest" or "6".
29+
default: ''
30+
type: string
31+
repo_tag:
32+
description: "The tag of the module repo to checkout, '' defaults to branch/PR"
33+
default: ''
34+
type: string
435
workflows:
536
version: 2
637
test-and-release:
38+
when: << pipeline.parameters.run-auto-workflows >>
739
jobs:
840
- release-management/validate-pr:
941
filters:
1042
branches:
1143
ignore: main
12-
release-management/test-package:
13-
matrix:
14-
parameters:
15-
os:
16-
- linux
17-
- windows
18-
node_version:
19-
- latest
20-
- lts
21-
- maintenance
22-
exclude:
23-
- os: windows
24-
node_version: lts
25-
- os: windows
26-
node_version: maintenance
2744
- release-management/test-package:
2845
matrix:
2946
parameters:
@@ -39,6 +56,17 @@ workflows:
3956
node_version: lts
4057
- os: windows
4158
node_version: maintenance
59+
- release-management/test-nut:
60+
name: nuts-on-linux
61+
sfdx_version: latest
62+
requires:
63+
- release-management/test-package
64+
- release-management/test-nut:
65+
name: nuts-on-windows
66+
sfdx_version: latest
67+
os: windows
68+
requires:
69+
- release-management/test-package
4270
- release-management/release-package:
4371
sign: true
4472
github-release: true
@@ -47,7 +75,7 @@ workflows:
4775
filters:
4876
branches:
4977
only: main
50-
when: << pipeline.parameters.run-auto-workflows >>
78+
context: CLI_CTC
5179
test-ts-update:
5280
triggers:
5381
- schedule:
@@ -71,34 +99,3 @@ workflows:
7199
os:
72100
- linux
73101
- windows
74-
parameters:
75-
run-auto-workflows:
76-
description: >
77-
Boolean that controls when an workflow would run.
78-
79-
It is used to gate which workflows should run when github events occur.
80-
81-
This parameter is used by automation to determine if a workflow will run
82-
within a pipeline.
83-
default: true
84-
type: boolean
85-
run-just-nuts:
86-
description: >
87-
Boolean that controls when the just-nuts will run.
88-
89-
Default value is false and this parameter is used by automation to
90-
determine if
91-
92-
the just-nuts workflow will run.
93-
default: false
94-
type: boolean
95-
sfdx_version:
96-
description: |
97-
By default, the latest version of the standalone CLI will be installed.
98-
To install via npm, supply a version tag such as "latest" or "6".
99-
default: ''
100-
type: string
101-
repo_tag:
102-
description: 'The tag of the module repo to checkout, '''' defaults to branch/PR'
103-
default: ''
104-
type: string

README.md

Lines changed: 24 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,13 @@
1-
### Use the [lerna template](https://github.com/salesforcecli/lerna-template) if you need a library and plugin
1+
# plugin-project
22

3-
### This template is useful if the library is already in another repository or the plugin is a wrapper around an API.
4-
5-
# plugin-&lt;REPLACE ME&gt;
6-
7-
[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-template.svg?label=@salesforce/plugin-template)](https://www.npmjs.com/package/@salesforce/plugin-template) [![CircleCI](https://circleci.com/gh/salesforcecli/plugin-template/tree/main.svg?style=shield)](https://circleci.com/gh/salesforcecli/plugin-template/tree/main) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-template.svg)](https://npmjs.org/package/@salesforce/plugin-template) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/plugin-template/main/LICENSE.txt)
8-
9-
Change above to <REPLACE_ME> before finalizing
10-
11-
&lt;REPLACE ME DESCRIPTION START&gt;
12-
13-
This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
14-
15-
1. Clone this repo
16-
2. Delete the .git folder
17-
3. Replace filler values
18-
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
19-
b) Search for case-matching `REPLACE` to find other filler values, such as for the plugin description
20-
4. Use `git init` to set up the desired git information
21-
5. Follow the getting started steps below until the `sfdx hello:org` commmand is functioning
22-
23-
&lt;REPLACE ME DESCRIPTION END&gt;
24-
25-
## Learn about the plugin-template
26-
27-
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.
28-
29-
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.
30-
31-
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.
32-
33-
# Everything past here is only a suggestion as to what should be in your specific plugin's description
34-
35-
This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
36-
37-
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
3+
[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-project.svg?label=@salesforce/plugin-project)](https://www.npmjs.com/package/@salesforce/plugin-project) [![CircleCI](https://circleci.com/gh/salesforcecli/plugin-project/tree/main.svg?style=shield)](https://circleci.com/gh/salesforcecli/plugin-project/tree/main) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-project.svg)](https://npmjs.org/package/@salesforce/plugin-project) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/plugin-project/main/LICENSE.txt)
384

395
## Install
406

417
```bash
42-
sfdx plugins:install <REPLACE_ME>@x.y.z
8+
sf plugins:install plugin-project@x.y.z
439
```
4410

45-
## Issues
46-
47-
Please report any issues at https://github.com/forcedotcom/cli/issues
48-
4911
## Contributing
5012

5113
1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
@@ -71,7 +33,7 @@ To build the plugin locally, make sure to have yarn installed and run the follow
7133

7234
```bash
7335
# Clone the repository
74-
git clone [email protected]:salesforcecli/plugin-<REPLACE_ME>
36+
git clone [email protected]:salesforcecli/plugin-project
7537

7638
# Install the dependencies and compile
7739
yarn install
@@ -82,58 +44,47 @@ To use your plugin, run using the local `./bin/run` or `./bin/run.cmd` file.
8244

8345
```bash
8446
# Run using local run file.
85-
./bin/run <REPLACE_ME>
47+
./bin/run project
8648
```
8749

8850
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.
8951

9052
```bash
91-
# Link your plugin to the sfdx cli
92-
sfdx plugins:link .
53+
# Link your plugin to the sf cli
54+
sf plugins:link .
9355
# To verify
94-
sfdx plugins
56+
sf plugins
9557
```
9658

9759
## Commands
9860

9961
<!-- commands -->
10062

101-
- [`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)
102-
103-
## `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]`
63+
## `sf project:deploy`
10464

105-
print a greeting and your org IDs
65+
deploy a Salesforce project
10666

10767
```
10868
USAGE
109-
$ sfdx hello:org [-n <string>] [-f] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
110-
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
69+
$ sf project:deploy
11170
11271
OPTIONS
113-
-f, --force example boolean flag
114-
-n, --name=name name to print
115-
116-
-u, --targetusername=targetusername username or alias for the target
117-
org; overrides default target org
72+
--directory=directory directory to deploy
73+
--interactive TBD
74+
--target-env=target-env TBD
11875
119-
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
120-
org; overrides default dev hub org
121-
122-
--apiversion=apiversion override the api version used for
123-
api requests made by this command
124-
125-
--json format output as json
126-
127-
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
128-
this command invocation
76+
DESCRIPTION
77+
Deploy a project, including org metadata and functions. Be default, the deploy analyze your project and assume
78+
sensible defaults when possible, otherwise it will prompt. To always prompt and not assume defaults, use
79+
"--interctive".
80+
To run specialized deploys, especially when interactivity isn't an option like continuous deployment, used the scoped
81+
deploy commands like "sf project deploy org" or "sf project deploy functions"
12982
13083
EXAMPLES
131-
$ sfdx hello:org --targetusername [email protected] --targetdevhubusername [email protected]
132-
Hello world! This is org: MyOrg and I will be around until Tue Mar 20 2018!
133-
My hub org id is: 00Dxx000000001234
134-
135-
$ sfdx hello:org --name myname --targetusername [email protected]
136-
Hello myname! This is org: MyOrg and I will be around until Tue Mar 20 2018!
84+
sf project:deploy
85+
sf project:deploy --remote
13786
```
13887

88+
_See code: [src/commands/project/deploy.ts](https://github.com/salesforcecli/plugin-project/blob/v0.0.1/src/commands/project/deploy.ts)_
89+
13990
<!-- commandsstop -->

bin/dev

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env node
2+
3+
process.env.NODE_ENV = 'development';
4+
5+
const g = global.oclif = global.oclif || {};
6+
7+
// In dev mode, always show stack traces
8+
global.oclif.debug = true;
9+
10+
require('ts-node').register()
11+
12+
require('@oclif/core').run()
13+
.then(require('@oclif/core/flush'))
14+
.catch(require('@oclif/core/handle'))

bin/dev.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
set NODE_ENV=development
3+
node "%~dp0\dev" %*

bin/run

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
22

3-
require('@oclif/command').run()
4-
.catch(require('@oclif/errors/handle'))
3+
require('@oclif/core').run()
4+
.then(require('@oclif/core/flush'))
5+
.catch(require('@oclif/core/handle'))

bin/run.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
22

3-
node "%~dp0\run" %*
3+
node "%~dp0\run" %*

command-snapshot.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"command": "hello:org",
4-
"plugin": "@salesforce/plugin-template",
5-
"flags": ["apiversion", "force", "json", "loglevel", "name", "targetdevhubusername", "targetusername"]
3+
"command": "project:deploy",
4+
"plugin": "@salesforce/plugin-project",
5+
"flags": ["directory", "interactive", "target-env"]
66
}
77
]

messages/org.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

messages/project.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"deploy": {
3+
"commandDescription": "deploy a Salesforce project\nDeploy a project, including org metadata and functions. Be default, the deploy analyze your project and assume sensible defaults when possible, otherwise it will prompt. To always prompt and not assume defaults, use \"--interctive\".\nTo run specialized deploys, especially when interactivity isn't an option like continuous deployment, used the scoped deploy commands like \"sf project deploy org\" or \"sf project deploy functions\"",
4+
"examples": ["<%= config.bin %> <%= command.id %>", "<%= config.bin %> <%= command.id %> --remote"]
5+
}
6+
}

0 commit comments

Comments
 (0)