prodlysfcli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -0
- package/lib/commands/prodly/checkin.d.ts +19 -0
- package/lib/commands/prodly/checkin.js +123 -0
- package/lib/commands/prodly/checkin.js.map +1 -0
- package/lib/commands/prodly/checkout.d.ts +20 -0
- package/lib/commands/prodly/checkout.js +130 -0
- package/lib/commands/prodly/checkout.js.map +1 -0
- package/lib/commands/prodly/deploy.d.ts +26 -0
- package/lib/commands/prodly/deploy.js +262 -0
- package/lib/commands/prodly/deploy.js.map +1 -0
- package/lib/commands/prodly/jobs.d.ts +15 -0
- package/lib/commands/prodly/jobs.js +33 -0
- package/lib/commands/prodly/jobs.js.map +1 -0
- package/lib/commands/prodly/manage.d.ts +24 -0
- package/lib/commands/prodly/manage.js +167 -0
- package/lib/commands/prodly/manage.js.map +1 -0
- package/lib/constants/index.d.ts +5 -0
- package/lib/constants/index.js +6 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/services/connections.d.ts +7 -0
- package/lib/services/connections.js +109 -0
- package/lib/services/connections.js.map +1 -0
- package/lib/services/connections.types.d.ts +31 -0
- package/lib/services/connections.types.js +2 -0
- package/lib/services/connections.types.js.map +1 -0
- package/lib/services/instances.d.ts +7 -0
- package/lib/services/instances.js +94 -0
- package/lib/services/instances.js.map +1 -0
- package/lib/services/instances.types.d.ts +40 -0
- package/lib/services/instances.types.js +2 -0
- package/lib/services/instances.types.js.map +1 -0
- package/lib/services/jobs.d.ts +4 -0
- package/lib/services/jobs.js +26 -0
- package/lib/services/jobs.js.map +1 -0
- package/lib/services/jobs.types.d.ts +13 -0
- package/lib/services/jobs.types.js +2 -0
- package/lib/services/jobs.types.js.map +1 -0
- package/lib/services/queries.d.ts +8 -0
- package/lib/services/queries.js +54 -0
- package/lib/services/queries.js.map +1 -0
- package/lib/types/prodly.d.ts +67 -0
- package/lib/types/prodly.js +2 -0
- package/lib/types/prodly.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +3 -0
- package/lib/utils/index.js.map +1 -0
- package/messages/prodly.checkin.md +15 -0
- package/messages/prodly.checkout.md +15 -0
- package/messages/prodly.deploy.md +14 -0
- package/messages/prodly.jobs.md +8 -0
- package/messages/prodly.json +43 -0
- package/messages/prodly.manage.md +12 -0
- package/oclif.lock +8039 -0
- package/oclif.manifest.json +557 -0
- package/package.json +189 -0
package/README.md
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# prodlysfcli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/prodlysfcli) [](https://npmjs.org/package/prodlysfcli) [](https://raw.githubusercontent.com/salesforcecli/prodlysfcli/main/LICENSE.txt)
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
sf plugins install prodlysfcli@x.y.z
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Issues
|
|
12
|
+
|
|
13
|
+
Please report any issues at https://github.com/prodly/prodly-sf-cli/issues
|
|
14
|
+
|
|
15
|
+
### Build
|
|
16
|
+
|
|
17
|
+
To build the plugin locally, make sure to have yarn installed and run the following commands:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Clone the repository
|
|
21
|
+
git clone https://github.com/prodly/prodly-sf-cli.git
|
|
22
|
+
|
|
23
|
+
# Install the dependencies and compile
|
|
24
|
+
yarn && yarn build
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Run using local run file.
|
|
29
|
+
./bin/run.js prodly:manage -l -p
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
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.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Link your plugin to the sf cli
|
|
36
|
+
sf plugins link .
|
|
37
|
+
# To verify
|
|
38
|
+
sf plugins
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Commands
|
|
42
|
+
|
|
43
|
+
<!-- commands -->
|
|
44
|
+
|
|
45
|
+
- [`sf prodly:checkin`](#sf-prodlycheckin)
|
|
46
|
+
- [`sf prodly:checkout`](#sf-prodlycheckout)
|
|
47
|
+
- [`sf prodly:deploy`](#sf-prodlydeploy)
|
|
48
|
+
- [`sf prodly:manage`](#sf-prodlymanage)
|
|
49
|
+
- [`sf prodly:jobs`](#sf-prodlyjobs)
|
|
50
|
+
|
|
51
|
+
## `sf prodly:checkin`
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
USAGE
|
|
55
|
+
$ sf prodly:checkin -v <value> -o <value> [--json] [-b <value>] [-c <value>] [-t <value>] [-i <value>] [-z
|
|
56
|
+
<value>] [-p <value>]
|
|
57
|
+
|
|
58
|
+
FLAGS
|
|
59
|
+
-b, --branch=<value> branch name for deployment
|
|
60
|
+
-c, --comment=<value> (required) comment for the command versioning commit
|
|
61
|
+
-i, --instance=<value> managed instance ID on which to perform the action
|
|
62
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not
|
|
63
|
+
required if the `target-org` configuration variable is already set.
|
|
64
|
+
-p, --plan=<value> name or record ID of the deployment plan to deploy
|
|
65
|
+
-t, --dataset=<value> name or record ID of the data set to deploy
|
|
66
|
+
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not
|
|
67
|
+
required if the `target-dev-hub` configuration variable is already set.
|
|
68
|
+
-z, --notes=<value> notes for the deployment
|
|
69
|
+
|
|
70
|
+
GLOBAL FLAGS
|
|
71
|
+
--json Format output as json.
|
|
72
|
+
|
|
73
|
+
DESCRIPTION
|
|
74
|
+
prodly:checkin command
|
|
75
|
+
|
|
76
|
+
Launches an Prodly relational data deployment.
|
|
77
|
+
|
|
78
|
+
EXAMPLES
|
|
79
|
+
$ sf prodly:checkin --target-org test-utxac7gbati9@example.com --target-dev-hub jsmith@acme.com
|
|
80
|
+
Save managed data to the branch associated with the managed instance identified by the target username.
|
|
81
|
+
The instance should be managed by the Prodly account associated with the provided DevHub control org.
|
|
82
|
+
|
|
83
|
+
$ sf prodly:checkin -u test-utxac7gbati9@example.com
|
|
84
|
+
Save managed data to the branch associated with the managed instance identified by the target username.
|
|
85
|
+
The instance should be managed by the Prodly account associated with the default DevHub control org.
|
|
86
|
+
|
|
87
|
+
$ sf prodly:checkin -i f50616b6-57b1-4941-802f-ee0e2506f217
|
|
88
|
+
Save managed data to the branch associated with the managed instance identified by the provided ID.
|
|
89
|
+
The instance should be managed by the Prodly account associated with the default DevHub control org.
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## `sf prodly:checkout`
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
USAGE
|
|
96
|
+
$ sf prodly:checkout -v <value> -o <value> [--json] [-b <value>] [-t <value>] [-e] [-i <value>] [-n <value>] [-z
|
|
97
|
+
<value>] [-p <value>]
|
|
98
|
+
|
|
99
|
+
FLAGS
|
|
100
|
+
-b, --branch=<value> branch name for deployment
|
|
101
|
+
-e, --deactivate deactivate all events for the deployment
|
|
102
|
+
-i, --instance=<value> managed instance ID on which to perform the action
|
|
103
|
+
-n, --name=<value> name for the deployment
|
|
104
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not
|
|
105
|
+
required if the `target-org` configuration variable is already set.
|
|
106
|
+
-p, --plan=<value> name or record ID of the deployment plan to deploy
|
|
107
|
+
-t, --dataset=<value> name or record ID of the data set to deploy
|
|
108
|
+
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not
|
|
109
|
+
required if the `target-dev-hub` configuration variable is already set.
|
|
110
|
+
-z, --notes=<value> notes for the deployment
|
|
111
|
+
|
|
112
|
+
GLOBAL FLAGS
|
|
113
|
+
--json Format output as json.
|
|
114
|
+
|
|
115
|
+
DESCRIPTION
|
|
116
|
+
prodly:checkout command
|
|
117
|
+
|
|
118
|
+
Launches an Prodly relational data deployment.
|
|
119
|
+
|
|
120
|
+
EXAMPLES
|
|
121
|
+
$ sf prodly:checkin --target-org test-utxac7gbati9@example.com --target-dev-hub jsmith@acme.com
|
|
122
|
+
Save managed data to the branch associated with the managed instance identified by the target username.
|
|
123
|
+
The instance should be managed by the Prodly account associated with the provided DevHub control org.
|
|
124
|
+
|
|
125
|
+
$ sf prodly:checkin -u test-utxac7gbati9@example.com
|
|
126
|
+
Save managed data to the branch associated with the managed instance identified by the target username.
|
|
127
|
+
The instance should be managed by the Prodly account associated with the default DevHub control org.
|
|
128
|
+
|
|
129
|
+
$ sf prodly:checkin -i f50616b6-57b1-4941-802f-ee0e2506f217
|
|
130
|
+
Save managed data to the branch associated with the managed instance identified by the provided ID.
|
|
131
|
+
The instance should be managed by the Prodly account associated with the default DevHub control org.
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## `sf prodly:deploy`
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
USAGE
|
|
138
|
+
$ sf prodly:deploy -v <value> -o <value> [--json] [-t <value>] [-e] [-d <value>] [-q <value>] [-b <value>] [-n
|
|
139
|
+
<value>] [-z <value>] [-p <value>] [-l] [-s <value>]
|
|
140
|
+
|
|
141
|
+
FLAGS
|
|
142
|
+
-b, --label=<value> connection and managed instance name
|
|
143
|
+
-d, --destination=<value> destination managed instance ID
|
|
144
|
+
-e, --deactivate deactivate all events for the deployment
|
|
145
|
+
-l, --simulation perform a data simulation
|
|
146
|
+
-n, --name=<value> name for the deployment
|
|
147
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not
|
|
148
|
+
required if the `target-org` configuration variable is already set.
|
|
149
|
+
-p, --plan=<value> name or record ID of the deployment plan to deploy
|
|
150
|
+
-q, --filter=<value> query filter override for a data set deployment
|
|
151
|
+
-s, --source=<value> source managed instance ID
|
|
152
|
+
-t, --dataset=<value> name or record ID of the data set to deploy
|
|
153
|
+
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not
|
|
154
|
+
required if the `target-dev-hub` configuration variable is already set.
|
|
155
|
+
-z, --notes=<value> notes for the deployment
|
|
156
|
+
|
|
157
|
+
GLOBAL FLAGS
|
|
158
|
+
--json Format output as json.
|
|
159
|
+
|
|
160
|
+
DESCRIPTION
|
|
161
|
+
prodly:deploy command
|
|
162
|
+
|
|
163
|
+
Launches an Prodly relational data deployment.
|
|
164
|
+
|
|
165
|
+
EXAMPLES
|
|
166
|
+
$ sf prodly:deploy -n scratchorg -u FixesScratchOrg -v MainDevHub
|
|
167
|
+
Command output... deploying from the dev hub, the control org, to the scratch org, auto managed with provided name.
|
|
168
|
+
Command output...
|
|
169
|
+
|
|
170
|
+
$ sf prodly:deploy --target-org test-utxac7gbati9@example.com --target-dev-hub jsmith@acme.com
|
|
171
|
+
Command output... deploying from the dev hub, the control org, to the scratch org. Long param names.
|
|
172
|
+
|
|
173
|
+
$ sf prodly:deploy -u test-utxac7gbati9@example.com -v jsmith@acme.com -d "UAT Sandbox Connection"
|
|
174
|
+
Command output... deploying from the scratch org to the UAT sandbox, using the named connection record in the dev hub, control org.
|
|
175
|
+
|
|
176
|
+
$ sf prodly:deploy --target-org test-utxac7gbati9@example.com --target-dev-hub jsmith@acme.com --source "UAT Sandbox Connection"
|
|
177
|
+
Command output... deploying to the scratch org from the UAT sandbox, using the named connection record in the dev hub, control org. Long param names.
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## `sf prodly:manage`
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
USAGE
|
|
184
|
+
$ sf prodly:manage -v <value> -o <value> [--json] [-c <value>] [-n <value>] [-i <value>] [-b <value>] [-l] [-m]
|
|
185
|
+
[-p] [-x] [-s]
|
|
186
|
+
|
|
187
|
+
FLAGS
|
|
188
|
+
-b, --label=<value> connection and managed instance name
|
|
189
|
+
-c, --comment=<value> comment for the command versioning commit
|
|
190
|
+
-i, --instance=<value> managed instance ID on which to perform the action
|
|
191
|
+
-l, --list list all managed instances
|
|
192
|
+
-m, --manage manage a new instance
|
|
193
|
+
-n, --connection=<value> connection to use for the managed instance
|
|
194
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not
|
|
195
|
+
required if the `target-org` configuration variable is already set.
|
|
196
|
+
-p, --print print the managed instances in a standard format in addition to returning structured
|
|
197
|
+
data
|
|
198
|
+
-s, --version version the new managed instance, branch created and data deployed to the org
|
|
199
|
+
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not
|
|
200
|
+
required if the `target-dev-hub` configuration variable is already set.
|
|
201
|
+
-x, --unmanage unmanage the specified instance
|
|
202
|
+
|
|
203
|
+
GLOBAL FLAGS
|
|
204
|
+
--json Format output as json.
|
|
205
|
+
|
|
206
|
+
DESCRIPTION
|
|
207
|
+
prodly:manage command
|
|
208
|
+
|
|
209
|
+
Launches an Prodly relational data deployment.
|
|
210
|
+
|
|
211
|
+
EXAMPLES
|
|
212
|
+
$ sf prodly:manage -l -p
|
|
213
|
+
List and print all of the managed instances for the Prodly account associated with the default DevHub control org.
|
|
214
|
+
|
|
215
|
+
$ sf prodly:manage -m --target-org test-utxac7gbati9@example.com --target-dev-hub jsmith@acme.com
|
|
216
|
+
Manage the org associated with the target username under the Prodly account associated with the provided DevHub control org.
|
|
217
|
+
|
|
218
|
+
$ sf prodly:manage -m -u test-utxac7gbati9@example.com -n dev7sbx
|
|
219
|
+
Manage and version the org associated with the target username under the Prodly account associated with the default DevHub control org.
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## `sf prodly:jobs`
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
USAGE
|
|
227
|
+
$ sf prodly jobs -v <value> -j <value> [--json]
|
|
228
|
+
|
|
229
|
+
FLAGS
|
|
230
|
+
-j, --job=<value> (required) Prodly Job ID
|
|
231
|
+
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org.
|
|
232
|
+
Not required if the `target-dev-hub` configuration variable is already set.
|
|
233
|
+
|
|
234
|
+
GLOBAL FLAGS
|
|
235
|
+
--json Format output as json.
|
|
236
|
+
|
|
237
|
+
DESCRIPTION
|
|
238
|
+
prodly:jobs command
|
|
239
|
+
|
|
240
|
+
Launches an Prodly relational data deployment.
|
|
241
|
+
|
|
242
|
+
EXAMPLES
|
|
243
|
+
$ sf prodly:jobs -j jobId -v MainDevHub
|
|
244
|
+
Print the job status for the provided job Id.
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
<!-- commandsstop -->
|
|
248
|
+
|
|
249
|
+
<!-- debugging-your-plugin -->
|
|
250
|
+
|
|
251
|
+
# Debugging your plugin
|
|
252
|
+
|
|
253
|
+
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.
|
|
254
|
+
|
|
255
|
+
To debug the `prodly:manage -l -p` command:
|
|
256
|
+
|
|
257
|
+
1. Start the inspector
|
|
258
|
+
|
|
259
|
+
Call your command using the `bin/run.js` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:
|
|
260
|
+
|
|
261
|
+
```sh-session
|
|
262
|
+
$ NODE_OPTIONS=--inspect-brk bin/run.js prodly:manage -l -p
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
2. Set some breakpoints in your command code
|
|
266
|
+
3. Click on the Run and Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
|
|
267
|
+
4. In the upper left hand corner of VS Code, verify that the "Attach" launch configuration has been chosen.
|
|
268
|
+
5. Hit the green play button to the left of the "Attach" launch configuration window. The debugger should now be suspended on the first line of the program.
|
|
269
|
+
6. Hit the blue 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).
|
|
270
|
+
<br><img src=".images/vscodeScreenshot.png" width="600" height="343"><br>
|
|
271
|
+
Congrats, you are debugging!
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { AnyJson } from '@salesforce/ts-types';
|
|
3
|
+
export default class ProdlyCheckin extends SfCommand<AnyJson> {
|
|
4
|
+
static readonly summary: string;
|
|
5
|
+
static readonly description: string;
|
|
6
|
+
static readonly examples: string[];
|
|
7
|
+
static readonly flags: {
|
|
8
|
+
'target-dev-hub': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
branch: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
comment: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
dataset: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
|
+
instance: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
+
notes: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
|
+
plan: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<AnyJson>;
|
|
18
|
+
private checkinInstance;
|
|
19
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Messages, SfError } from '@salesforce/core';
|
|
2
|
+
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
3
|
+
import { updateConnection } from '../../services/connections.js';
|
|
4
|
+
import { getManagedInstance } from '../../services/instances.js';
|
|
5
|
+
import { getDeploymentEntityId } from '../../services/queries.js';
|
|
6
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
7
|
+
const commandMessages = Messages.loadMessages('prodlysfcli', 'prodly.checkin');
|
|
8
|
+
const prodlyMessages = Messages.loadMessages('prodlysfcli', 'prodly');
|
|
9
|
+
export default class ProdlyCheckin extends SfCommand {
|
|
10
|
+
static summary = commandMessages.getMessage('summary');
|
|
11
|
+
static description = prodlyMessages.getMessage('commandDescription');
|
|
12
|
+
static examples = commandMessages.getMessages('examples');
|
|
13
|
+
static flags = {
|
|
14
|
+
'target-dev-hub': Flags.requiredHub(),
|
|
15
|
+
'target-org': Flags.requiredOrg(),
|
|
16
|
+
branch: Flags.string({ char: 'b', summary: prodlyMessages.getMessage('branchFlagDescription') }),
|
|
17
|
+
comment: Flags.string({ char: 'c', required: true, summary: prodlyMessages.getMessage('commentFlagDescription') }),
|
|
18
|
+
dataset: Flags.string({ char: 't', summary: prodlyMessages.getMessage('dataSetFlagDescription') }),
|
|
19
|
+
instance: Flags.string({ char: 'i', summary: prodlyMessages.getMessage('instanceFlagDescription') }),
|
|
20
|
+
notes: Flags.string({ char: 'z', summary: prodlyMessages.getMessage('notesFlagDescription') }),
|
|
21
|
+
plan: Flags.string({ char: 'p', summary: prodlyMessages.getMessage('deploymentPlanFlagDescription') }),
|
|
22
|
+
};
|
|
23
|
+
async run() {
|
|
24
|
+
const { flags } = await this.parse(ProdlyCheckin);
|
|
25
|
+
const { branch: branchFlag, comment: commentFlag, dataset: datasetFlag, instance: instanceFlag, notes: deploymentNotesFlag, plan: planFlag, } = flags;
|
|
26
|
+
this.log('Instance flag: ' + instanceFlag);
|
|
27
|
+
this.log('Deployment description flag: ' + deploymentNotesFlag);
|
|
28
|
+
this.log('Comment flag: ' + commentFlag);
|
|
29
|
+
this.log('Branch flag: ' + branchFlag);
|
|
30
|
+
this.log('Data set flag: ' + datasetFlag);
|
|
31
|
+
this.log('Deployment plan flag: ' + planFlag);
|
|
32
|
+
if (!datasetFlag && !planFlag) {
|
|
33
|
+
throw new SfError(prodlyMessages.getMessage('errorNoDatasetAndPlanFlags', []));
|
|
34
|
+
}
|
|
35
|
+
const org = flags['target-org'];
|
|
36
|
+
const hubOrg = flags['target-dev-hub'];
|
|
37
|
+
const hubConn = hubOrg.getConnection();
|
|
38
|
+
const print = (message, ...args) => this.log(message, ...args);
|
|
39
|
+
let mangedInstanceId = null;
|
|
40
|
+
let dataSetId;
|
|
41
|
+
let deploymentPlanId;
|
|
42
|
+
// Retrieve the data set or deployment plan to deploy
|
|
43
|
+
this.log('Retrieving data set or deployment plan to deploy.');
|
|
44
|
+
if (datasetFlag) {
|
|
45
|
+
dataSetId = await getDeploymentEntityId({
|
|
46
|
+
dataEntityFlag: datasetFlag,
|
|
47
|
+
dataEntityType: 'PDRI__DataSet__c',
|
|
48
|
+
hubConn,
|
|
49
|
+
print,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else if (planFlag) {
|
|
53
|
+
deploymentPlanId = await getDeploymentEntityId({
|
|
54
|
+
dataEntityFlag: planFlag,
|
|
55
|
+
dataEntityType: 'PDRI__Deployment_Plan__c',
|
|
56
|
+
hubConn,
|
|
57
|
+
print,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
this.log(`Data set ID: ${dataSetId}`);
|
|
61
|
+
this.log(`Deployment plan ID: ${deploymentPlanId}`);
|
|
62
|
+
// Check if instance is provided
|
|
63
|
+
if (instanceFlag) {
|
|
64
|
+
// Use provided managed instance
|
|
65
|
+
this.log(`Managed instance ID provided, using instance with id ${instanceFlag}`);
|
|
66
|
+
mangedInstanceId = instanceFlag;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Retrieve the managed instance associated with target org
|
|
70
|
+
// DevHub control org is never used as the default
|
|
71
|
+
const managedInstance = await getManagedInstance({ hubConn, orgId: org.getOrgId(), print });
|
|
72
|
+
if (!managedInstance) {
|
|
73
|
+
throw new SfError(prodlyMessages.getMessage('errorManagedInstaceNotFound'));
|
|
74
|
+
}
|
|
75
|
+
this.log(`Managed instance ID retrieved, using instance with id ${managedInstance.id}`);
|
|
76
|
+
mangedInstanceId = managedInstance.id;
|
|
77
|
+
this.log('Refreshing org session auth');
|
|
78
|
+
try {
|
|
79
|
+
await org.refreshAuth();
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Target username not valid or not specified, refresh failed
|
|
83
|
+
}
|
|
84
|
+
// Update the connection with the latest access token
|
|
85
|
+
this.log('Updating the connection with the latest access token');
|
|
86
|
+
await updateConnection({ connectionId: managedInstance.connectionId, hubConn, org });
|
|
87
|
+
}
|
|
88
|
+
// Perform the checkin
|
|
89
|
+
const jobId = await this.checkinInstance({
|
|
90
|
+
branchFlag,
|
|
91
|
+
comment: commentFlag,
|
|
92
|
+
dataSetId,
|
|
93
|
+
deploymentNotes: deploymentNotesFlag,
|
|
94
|
+
deploymentPlanId,
|
|
95
|
+
hubConn,
|
|
96
|
+
mangedInstanceId,
|
|
97
|
+
});
|
|
98
|
+
this.log(`Checkin launched with Job ID: ${jobId}`);
|
|
99
|
+
return { jobId, message: 'Checkin launched' };
|
|
100
|
+
}
|
|
101
|
+
async checkinInstance({ branchFlag, comment, dataSetId, deploymentNotes, deploymentPlanId, hubConn, mangedInstanceId, }) {
|
|
102
|
+
this.log(`Performing checkin for managed instance with id ${mangedInstanceId}.`);
|
|
103
|
+
const path = `/services/apexrest/PDRI/v1/instances/${mangedInstanceId}/checkin`;
|
|
104
|
+
const checkinInstance = {
|
|
105
|
+
allVersionedData: !dataSetId && !deploymentPlanId ? true : null,
|
|
106
|
+
branchName: branchFlag,
|
|
107
|
+
datasetId: dataSetId,
|
|
108
|
+
deploymentNotes,
|
|
109
|
+
deploymentPlanId,
|
|
110
|
+
options: { commitMessage: comment },
|
|
111
|
+
};
|
|
112
|
+
const request = {
|
|
113
|
+
body: JSON.stringify(checkinInstance),
|
|
114
|
+
method: 'POST',
|
|
115
|
+
url: path,
|
|
116
|
+
};
|
|
117
|
+
const res = await hubConn.request(request);
|
|
118
|
+
const jobsWrapper = JSON.parse(res);
|
|
119
|
+
const jobId = jobsWrapper.jobs[0].id;
|
|
120
|
+
return jobId;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=checkin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkin.js","sourceRoot":"","sources":["../../../src/commands/prodly/checkin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,YAAY,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAC/E,MAAM,cAAc,GAAG,QAAQ,CAAC,YAAY,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;AAEtE,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAkB;IACpD,MAAM,CAAU,OAAO,GAAG,eAAe,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,CAAU,WAAW,GAAG,cAAc,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC9E,MAAM,CAAU,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAEnE,MAAM,CAAU,KAAK,GAAG;QAC7B,gBAAgB,EAAE,KAAK,CAAC,WAAW,EAAE;QACrC,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE;QACjC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YACpC,gBAAgB;YAChB,OAAO;YACP,gBAAgB;SACjB,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;QACnD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAChD,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,EAC5B,UAAU,EACV,OAAO,EACP,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,gBAAgB,GACD;QACf,IAAI,CAAC,GAAG,CAAC,mDAAmD,gBAAgB,GAAG,CAAC,CAAC;QAEjF,MAAM,IAAI,GAAG,wCAAwC,gBAAgB,UAAU,CAAC;QAEhF,MAAM,eAAe,GAAG;YACtB,gBAAgB,EAAE,CAAC,SAAS,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;YAC/D,UAAU,EAAE,UAAU;YACtB,SAAS,EAAE,SAAS;YACpB,eAAe;YACf,gBAAgB;YAChB,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE;SACpC,CAAC;QAEF,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;YACrC,MAAM,EAAE,MAAe;YACvB,GAAG,EAAE,IAAI;SACV,CAAC;QAEF,MAAM,GAAG,GAAW,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAS,CAAC;QAE5C,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAErC,OAAO,KAAK,CAAC;IACf,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { AnyJson } from '@salesforce/ts-types';
|
|
3
|
+
export default class ProdlyCheckout extends SfCommand<AnyJson> {
|
|
4
|
+
static readonly summary: string;
|
|
5
|
+
static readonly description: string;
|
|
6
|
+
static readonly examples: string[];
|
|
7
|
+
static readonly flags: {
|
|
8
|
+
'target-dev-hub': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
branch: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
dataset: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
deactivate: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
|
+
instance: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
+
name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
|
+
notes: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
|
+
plan: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<AnyJson>;
|
|
19
|
+
private checkoutInstance;
|
|
20
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Messages, SfError } from '@salesforce/core';
|
|
2
|
+
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
3
|
+
import { updateConnection } from '../../services/connections.js';
|
|
4
|
+
import { getManagedInstance } from '../../services/instances.js';
|
|
5
|
+
import { getDeploymentEntityId } from '../../services/queries.js';
|
|
6
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
7
|
+
const commandMessages = Messages.loadMessages('prodlysfcli', 'prodly.checkout');
|
|
8
|
+
const prodlyMessages = Messages.loadMessages('prodlysfcli', 'prodly');
|
|
9
|
+
export default class ProdlyCheckout extends SfCommand {
|
|
10
|
+
static summary = commandMessages.getMessage('summary');
|
|
11
|
+
static description = prodlyMessages.getMessage('commandDescription');
|
|
12
|
+
static examples = commandMessages.getMessages('examples');
|
|
13
|
+
static flags = {
|
|
14
|
+
'target-dev-hub': Flags.requiredHub(),
|
|
15
|
+
'target-org': Flags.requiredOrg(),
|
|
16
|
+
branch: Flags.string({ char: 'b', summary: prodlyMessages.getMessage('branchFlagDescription') }),
|
|
17
|
+
dataset: Flags.string({ char: 't', summary: prodlyMessages.getMessage('dataSetFlagDescription') }),
|
|
18
|
+
deactivate: Flags.boolean({ char: 'e', summary: prodlyMessages.getMessage('deactivateFlagDescription') }),
|
|
19
|
+
instance: Flags.string({ char: 'i', summary: prodlyMessages.getMessage('instanceFlagDescription') }),
|
|
20
|
+
name: Flags.string({ char: 'n', summary: prodlyMessages.getMessage('deplomentNameFlagDescription') }),
|
|
21
|
+
notes: Flags.string({ char: 'z', summary: prodlyMessages.getMessage('notesFlagDescription') }),
|
|
22
|
+
plan: Flags.string({ char: 'p', summary: prodlyMessages.getMessage('deploymentPlanFlagDescription') }),
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
const { flags } = await this.parse(ProdlyCheckout);
|
|
26
|
+
const { instance: instanceFlag, deactivate: deactivateFlag, name: deploymentNameFlag, notes: deploymentNotesFlag, branch: branchFlag, dataset: datasetFlag, plan: planFlag, } = flags;
|
|
27
|
+
this.log('Deployment name flag: ' + deploymentNameFlag);
|
|
28
|
+
this.log('Instance flag: ' + instanceFlag);
|
|
29
|
+
this.log('Deactivate flag: ' + deactivateFlag);
|
|
30
|
+
this.log('Deployment description flag: ' + deploymentNotesFlag);
|
|
31
|
+
this.log('Branch flag: ' + branchFlag);
|
|
32
|
+
this.log('Data set flag: ' + datasetFlag);
|
|
33
|
+
this.log('Deployment plan flag: ' + planFlag);
|
|
34
|
+
if (!datasetFlag && !planFlag) {
|
|
35
|
+
throw new SfError(prodlyMessages.getMessage('errorNoDatasetAndPlanFlags', []));
|
|
36
|
+
}
|
|
37
|
+
if (!deploymentNameFlag) {
|
|
38
|
+
throw new SfError(prodlyMessages.getMessage('errorDeploymentNameFlag', []));
|
|
39
|
+
}
|
|
40
|
+
const org = flags['target-org'];
|
|
41
|
+
const hubOrg = flags['target-dev-hub'];
|
|
42
|
+
const hubConn = hubOrg.getConnection();
|
|
43
|
+
const print = (message, ...args) => this.log(message, ...args);
|
|
44
|
+
let mangedInstanceId = null;
|
|
45
|
+
let dataSetId;
|
|
46
|
+
let deploymentPlanId;
|
|
47
|
+
// Retrieve the data set or deployment plan to deploy
|
|
48
|
+
this.log('Retrieving data set or deployment plan to deploy.');
|
|
49
|
+
if (datasetFlag !== undefined) {
|
|
50
|
+
dataSetId = await getDeploymentEntityId({
|
|
51
|
+
dataEntityFlag: datasetFlag,
|
|
52
|
+
dataEntityType: 'PDRI__DataSet__c',
|
|
53
|
+
hubConn,
|
|
54
|
+
print,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else if (planFlag !== undefined) {
|
|
58
|
+
deploymentPlanId = await getDeploymentEntityId({
|
|
59
|
+
dataEntityFlag: planFlag,
|
|
60
|
+
dataEntityType: 'PDRI__Deployment_Plan__c',
|
|
61
|
+
hubConn,
|
|
62
|
+
print,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
this.log('Data set ID: ' + dataSetId);
|
|
66
|
+
this.log('Deployment plan ID: ' + deploymentPlanId);
|
|
67
|
+
// Check if instance is provided
|
|
68
|
+
if (instanceFlag !== undefined) {
|
|
69
|
+
// Use provided managed instance
|
|
70
|
+
this.log(`Managed instance ID provided, using instance with id ${instanceFlag}`);
|
|
71
|
+
mangedInstanceId = instanceFlag;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Retrieve the managed instance associated with target org
|
|
75
|
+
// DevHub control org is never used as the default
|
|
76
|
+
const managedInstance = await getManagedInstance({ orgId: org.getOrgId(), hubConn, print });
|
|
77
|
+
if (!managedInstance) {
|
|
78
|
+
throw new SfError(prodlyMessages.getMessage('errorManagedInstaceNotFound'));
|
|
79
|
+
}
|
|
80
|
+
this.log(`Managed instance ID retrieved, using instance with id ${managedInstance.id}`);
|
|
81
|
+
mangedInstanceId = managedInstance.id;
|
|
82
|
+
this.log('Refreshing org session auth');
|
|
83
|
+
try {
|
|
84
|
+
await org.refreshAuth();
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// console.log('Target username not valid or not specified, refresh failed');
|
|
88
|
+
}
|
|
89
|
+
// Update the connection with the latest access token
|
|
90
|
+
this.log('Updating the connection with the latest access token');
|
|
91
|
+
await updateConnection({ connectionId: managedInstance.connectionId, org, hubConn });
|
|
92
|
+
}
|
|
93
|
+
// Perform the checkout
|
|
94
|
+
const jobId = await this.checkoutInstance({
|
|
95
|
+
branchFlag,
|
|
96
|
+
dataSetId,
|
|
97
|
+
deactivateAllEvents: deactivateFlag,
|
|
98
|
+
deploymentNameFlag,
|
|
99
|
+
deploymentNotes: deploymentNotesFlag,
|
|
100
|
+
deploymentPlanId,
|
|
101
|
+
hubConn,
|
|
102
|
+
mangedInstanceId,
|
|
103
|
+
});
|
|
104
|
+
this.log(`Checkout launched with Job ID: ${jobId}`);
|
|
105
|
+
return { jobId, message: 'Checkout launched' };
|
|
106
|
+
}
|
|
107
|
+
async checkoutInstance({ branchFlag, dataSetId, deactivateAllEvents, deploymentNameFlag, deploymentNotes, deploymentPlanId, hubConn, mangedInstanceId, }) {
|
|
108
|
+
this.log(`Performing checkout for managed instance with id ${mangedInstanceId}.`);
|
|
109
|
+
const path = `/services/apexrest/PDRI/v1/instances/${mangedInstanceId}/checkout`;
|
|
110
|
+
const checkoutInstance = {
|
|
111
|
+
allVersionedData: !dataSetId && !deploymentPlanId ? true : null,
|
|
112
|
+
branchName: branchFlag,
|
|
113
|
+
datasetId: dataSetId,
|
|
114
|
+
deactivateAll: deactivateAllEvents === undefined ? false : true,
|
|
115
|
+
deploymentName: deploymentNameFlag,
|
|
116
|
+
deploymentNotes,
|
|
117
|
+
deploymentPlanId,
|
|
118
|
+
};
|
|
119
|
+
const request = {
|
|
120
|
+
body: JSON.stringify(checkoutInstance),
|
|
121
|
+
method: 'POST',
|
|
122
|
+
url: path,
|
|
123
|
+
};
|
|
124
|
+
const res = await hubConn.request(request);
|
|
125
|
+
const jobsWrapper = JSON.parse(res);
|
|
126
|
+
const jobId = jobsWrapper.jobs[0].id;
|
|
127
|
+
return jobId;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../../src/commands/prodly/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,YAAY,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;AAChF,MAAM,cAAc,GAAG,QAAQ,CAAC,YAAY,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;AAEtE,MAAM,CAAC,OAAO,OAAO,c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gBAAgB,GAAG;YACvB,gBAAgB,EAAE,CAAC,SAAS,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;YAC/D,UAAU,EAAE,UAAU;YACtB,SAAS,EAAE,SAAS;YACpB,aAAa,EAAE,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YAC/D,cAAc,EAAE,kBAAkB;YAClC,eAAe;YACf,gBAAgB;SACjB,CAAC;QAEF,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACtC,MAAM,EAAE,MAAe;YACvB,GAAG,EAAE,IAAI;SACV,CAAC;QAEF,MAAM,GAAG,GAAW,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAS,CAAC;QAE5C,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAErC,OAAO,KAAK,CAAC;IACf,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { AnyJson } from '@salesforce/ts-types';
|
|
3
|
+
export type ProdlyDeployResult = {
|
|
4
|
+
path: string;
|
|
5
|
+
};
|
|
6
|
+
export default class ProdlyDeploy extends SfCommand<AnyJson> {
|
|
7
|
+
static readonly summary: string;
|
|
8
|
+
static readonly description: string;
|
|
9
|
+
static readonly examples: string[];
|
|
10
|
+
static readonly flags: {
|
|
11
|
+
'target-dev-hub': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
|
+
dataset: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
+
deactivate: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
15
|
+
destination: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
|
+
filter: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
17
|
+
label: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
18
|
+
name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
19
|
+
notes: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
20
|
+
plan: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
21
|
+
simulation: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
22
|
+
source: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
23
|
+
};
|
|
24
|
+
run(): Promise<AnyJson>;
|
|
25
|
+
private deploy;
|
|
26
|
+
}
|