@salesforce/plugin-signups 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ## 1.0.0 (2022-04-13)
6
+
7
+ ### Features
8
+
9
+ - multiple aliases, omit property if none ([2fc3781](https://github.com/salesforcecli/plugin-signups/commit/2fc3781aedbd886e21ba1221c9e0d38a80e5c4c5))
10
+
11
+ ### Bug Fixes
12
+
13
+ - aliases might not exist ([aa18406](https://github.com/salesforcecli/plugin-signups/commit/aa18406fac59d8b317b5ca74cac83873d0257219))
14
+ - exit delete command when no shapes are found ([274fb80](https://github.com/salesforcecli/plugin-signups/commit/274fb80a8288196e93b4888b53746ea7864519b8))
15
+ - look in all non-scratch orgs for ShapeRep ([36c804d](https://github.com/salesforcecli/plugin-signups/commit/36c804db25c49cf6bcf01ee50af60b28389a35a4))
package/LICENSE.txt ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (c) 2022, Salesforce.com, Inc.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # plugin-signups
2
+
3
+ [![NPM](https://img.shields.io/npm/v/@salesforce/plugin-signups.svg?label=@salesforce/plugin-signups)](https://www.npmjs.com/package/@salesforce/plugin-signups) [![CircleCI](https://circleci.com/gh/salesforcecli/plugin-signups/tree/main.svg?style=shield)](https://circleci.com/gh/salesforcecli/plugin-signups/tree/main) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-signups.svg)](https://npmjs.org/package/@salesforce/plugin-signups) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/plugin-signups/main/LICENSE.txt)
4
+
5
+ ## Learn about the plugin-signups
6
+
7
+ 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.
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ # Everything past here is only a suggestion as to what should be in your specific plugin's description
14
+
15
+ 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).
16
+
17
+ 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.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ sfdx plugins:install signups@x.y.z
23
+ ```
24
+
25
+ ## Issues
26
+
27
+ Please report any issues at https://github.com/forcedotcom/cli/issues
28
+
29
+ ## Contributing
30
+
31
+ 1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
32
+ 2. Create a new issue before starting your project so that we can keep track of
33
+ what you are trying to add/fix. That way, we can also offer suggestions or
34
+ let you know if there is already an effort in progress.
35
+ 3. Fork this repository.
36
+ 4. [Build the plugin locally](#build)
37
+ 5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
38
+ 6. Edit the code in your fork.
39
+ 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.
40
+ 8. Sign CLA (see [CLA](#cla) below).
41
+ 9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
42
+
43
+ ### CLA
44
+
45
+ External contributors will be required to sign a Contributor's License
46
+ Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
47
+
48
+ ### Build
49
+
50
+ To build the plugin locally, make sure to have yarn installed and run the following commands:
51
+
52
+ ```bash
53
+ # Clone the repository
54
+ git clone git@github.com:salesforcecli/plugin-signups
55
+
56
+ # Install the dependencies and compile
57
+ yarn install
58
+ yarn build
59
+ ```
60
+
61
+ To use your plugin, run using the local `./bin/run` or `./bin/run.cmd` file.
62
+
63
+ ```bash
64
+ # Run using local run file.
65
+ ./bin/run force:org:shape
66
+ ```
67
+
68
+ 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.
69
+
70
+ ```bash
71
+ # Link your plugin to the sfdx cli
72
+ sfdx plugins:link .
73
+ # To verify
74
+ sfdx plugins
75
+ ```
76
+
77
+ ## Commands
78
+
79
+ <!-- commands -->
80
+
81
+ - [`sfdx force:org:shape:create [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-forceorgshapecreate--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
82
+ - [`sfdx force:org:shape:delete [-p] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-forceorgshapedelete--p--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
83
+ - [`sfdx force:org:shape:list [--verbose] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-forceorgshapelist---verbose---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
84
+
85
+ ## `sfdx force:org:shape:create [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
86
+
87
+ Create a scratch org configuration (shape) based on the specified source org
88
+
89
+ ```
90
+ USAGE
91
+ $ sfdx force:org:shape:create [-u <string>] [--apiversion <string>] [--json] [--loglevel
92
+ trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
93
+
94
+ FLAGS
95
+ -u, --targetusername=<value> username or alias for the target
96
+ org; overrides default target org
97
+ --apiversion=<value> override the api version used for
98
+ api requests made by this command
99
+ --json format output as json
100
+ --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
101
+ this command invocation
102
+
103
+ DESCRIPTION
104
+ Create a scratch org configuration (shape) based on the specified source org
105
+
106
+ EXAMPLES
107
+ $ sfdx force:org:shape:create -u me@my.org
108
+
109
+ $ sfdx force:org:shape:create -u me@my.org --json --loglevel debug
110
+ ```
111
+
112
+ _See code: [src/commands/force/org/shape/create.ts](https://github.com/salesforcecli/plugin-signups/blob/v1.0.0/src/commands/force/org/shape/create.ts)_
113
+
114
+ ## `sfdx force:org:shape:delete [-p] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
115
+
116
+ Delete all org shapes for a target org
117
+
118
+ ```
119
+ USAGE
120
+ $ sfdx force:org:shape:delete [-p] [-u <string>] [--apiversion <string>] [--json] [--loglevel
121
+ trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
122
+
123
+ FLAGS
124
+ -p, --noprompt do not prompt for confirmation
125
+ -u, --targetusername=<value> username or alias for the target
126
+ org; overrides default target org
127
+ --apiversion=<value> override the api version used for
128
+ api requests made by this command
129
+ --json format output as json
130
+ --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
131
+ this command invocation
132
+
133
+ DESCRIPTION
134
+ Delete all org shapes for a target org
135
+
136
+ EXAMPLES
137
+ $ sfdx force:org:shape:delete -u me@my.org
138
+
139
+ $ sfdx force:org:shape:delete -u MyOrgAlias -p
140
+
141
+ $ sfdx force:org:shape:delete -u me@my.org --json
142
+
143
+ $ sfdx force:org:shape:delete -u me@my.org -p --json > tmp/MyOrgShapeDelete.json
144
+ ```
145
+
146
+ _See code: [src/commands/force/org/shape/delete.ts](https://github.com/salesforcecli/plugin-signups/blob/v1.0.0/src/commands/force/org/shape/delete.ts)_
147
+
148
+ ## `sfdx force:org:shape:list [--verbose] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
149
+
150
+ List all org shapes you’ve created
151
+
152
+ ```
153
+ USAGE
154
+ $ sfdx force:org:shape:list [--verbose] [--json] [--loglevel
155
+ trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
156
+
157
+ FLAGS
158
+ --json format output as json
159
+ --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
160
+ this command invocation
161
+ --verbose list more information about each org
162
+ shape
163
+
164
+ DESCRIPTION
165
+ List all org shapes you’ve created
166
+
167
+ EXAMPLES
168
+ $ sfdx force:org:shape:list
169
+
170
+ $ sfdx force:org:shape:list --json
171
+
172
+ $ sfdx force:org:shape:list --json > tmp/MyOrgShapeList.json
173
+ ```
174
+
175
+ _See code: [src/commands/force/org/shape/list.ts](https://github.com/salesforcecli/plugin-signups/blob/v1.0.0/src/commands/force/org/shape/list.ts)_
176
+
177
+ <!-- commandsstop -->
@@ -0,0 +1,14 @@
1
+ import { SfdxCommand } from '@salesforce/command';
2
+ export interface ShapeCreateResult {
3
+ shapeId: string;
4
+ success: boolean;
5
+ errors: [];
6
+ }
7
+ export declare class OrgShapeCreateCommand extends SfdxCommand {
8
+ static readonly description: string;
9
+ static readonly examples: string[];
10
+ static readonly requiresUsername = true;
11
+ private conn;
12
+ run(): Promise<ShapeCreateResult>;
13
+ private createShapeOrg;
14
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2022, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.OrgShapeCreateCommand = void 0;
10
+ const os_1 = require("os");
11
+ const command_1 = require("@salesforce/command");
12
+ const core_1 = require("@salesforce/core");
13
+ const orgShapeListUtils_1 = require("../../../../shared/orgShapeListUtils");
14
+ core_1.Messages.importMessagesDirectory(__dirname);
15
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-signups', 'shape.create');
16
+ class OrgShapeCreateCommand extends command_1.SfdxCommand {
17
+ async run() {
18
+ this.conn = this.org.getConnection();
19
+ if (!(await (0, orgShapeListUtils_1.isShapeEnabled)(this.conn))) {
20
+ const err = messages.createError('noAccess', [this.org.getUsername()]);
21
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
+ // @ts-ignore override readonly .name field
23
+ err.name = 'noAccess';
24
+ throw err;
25
+ }
26
+ const createShapeResponse = await this.createShapeOrg();
27
+ if (createShapeResponse.success !== true) {
28
+ this.logger.error('Shape create failed', createShapeResponse['errors']);
29
+ const err = messages.createError('shape_create_failed_message');
30
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
31
+ // @ts-ignore override readonly .name field
32
+ err.name = 'shape_create_failed_message';
33
+ throw err;
34
+ }
35
+ const output = {
36
+ shapeId: createShapeResponse.id,
37
+ success: true,
38
+ errors: [],
39
+ };
40
+ this.ux.log(messages.getMessage('create_shape_command_success_id', [output.shapeId]));
41
+ return output;
42
+ }
43
+ createShapeOrg() {
44
+ try {
45
+ return this.conn.sobject('ShapeRepresentation').create({
46
+ Description: '',
47
+ });
48
+ }
49
+ catch (err) {
50
+ const JsForceErr = err;
51
+ if (JsForceErr.errorCode && JsForceErr.errorCode === 'NOT_FOUND' && JsForceErr['name'] === 'ACCESS_DENIED') {
52
+ const e = messages.createError('create_shape_command_no_crud_access');
53
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
54
+ // @ts-ignore override readonly .name field
55
+ e.name = 'create_shape_command_no_crud_access';
56
+ throw e;
57
+ }
58
+ else {
59
+ throw JsForceErr;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ exports.OrgShapeCreateCommand = OrgShapeCreateCommand;
65
+ OrgShapeCreateCommand.description = messages.getMessage('create_shape_command_description');
66
+ OrgShapeCreateCommand.examples = messages.getMessage('create_shape_command_help').split(os_1.EOL);
67
+ OrgShapeCreateCommand.requiresUsername = true;
68
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../../src/commands/force/org/shape/create.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2BAAyB;AACzB,iDAAkD;AAClD,2CAAwD;AAExD,4EAAoF;AAEpF,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,4BAA4B,EAAE,cAAc,CAAC,CAAC;AAQrF,MAAa,qBAAsB,SAAQ,qBAAW;IAM7C,KAAK,CAAC,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAErC,IAAI,CAAC,CAAC,MAAM,IAAA,kCAAc,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;YACtC,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YACvE,6DAA6D;YAC7D,2CAA2C;YAC3C,GAAG,CAAC,IAAI,GAAG,UAAU,CAAC;YACtB,MAAM,GAAG,CAAC;SACX;QAED,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAExD,IAAI,mBAAmB,CAAC,OAAO,KAAK,IAAI,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;YACxE,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAAC;YAChE,6DAA6D;YAC7D,2CAA2C;YAC3C,GAAG,CAAC,IAAI,GAAG,6BAA6B,CAAC;YACzC,MAAM,GAAG,CAAC;SACX;QACD,MAAM,MAAM,GAAsB;YAChC,OAAO,EAAE,mBAAmB,CAAC,EAAE;YAC/B,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,EAAE;SACX,CAAC;QAEF,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,iCAAiC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACtF,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,cAAc;QACpB,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC;gBACrD,WAAW,EAAE,EAAE;aAChB,CAAC,CAAC;SACJ;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,UAAU,GAAG,GAAmB,CAAC;YACvC,IAAI,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,SAAS,KAAK,WAAW,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,eAAe,EAAE;gBAC1G,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,qCAAqC,CAAC,CAAC;gBACtE,6DAA6D;gBAC7D,2CAA2C;gBAC3C,CAAC,CAAC,IAAI,GAAG,qCAAqC,CAAC;gBAC/C,MAAM,CAAC,CAAC;aACT;iBAAM;gBACL,MAAM,UAAU,CAAC;aAClB;SACF;IACH,CAAC;;AAtDH,sDAuDC;AAtDwB,iCAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC;AACtE,8BAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAC,KAAK,CAAC,QAAG,CAAC,CAAC;AACvE,sCAAgB,GAAG,IAAI,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { FlagsConfig, SfdxCommand } from '@salesforce/command';
2
+ interface FailureMsg {
3
+ shapeId: string;
4
+ message: string;
5
+ }
6
+ interface DeleteAllResult {
7
+ shapeIds: string[];
8
+ failures: FailureMsg[];
9
+ }
10
+ export interface OrgShapeDeleteResult extends DeleteAllResult {
11
+ orgId: string;
12
+ }
13
+ export declare class OrgShapeDeleteCommand extends SfdxCommand {
14
+ static readonly description: string;
15
+ static readonly examples: string[];
16
+ static readonly requiresUsername = true;
17
+ static readonly flagsConfig: FlagsConfig;
18
+ private conn;
19
+ run(): Promise<OrgShapeDeleteResult>;
20
+ protected setExitCode(code: number): void;
21
+ /**
22
+ * Delete all ShapeRepresentation records for the shapeOrg.
23
+ *
24
+ * @return List of SR IDs that were deleted
25
+ */
26
+ private deleteAll;
27
+ }
28
+ export {};
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2022, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.OrgShapeDeleteCommand = void 0;
10
+ const os_1 = require("os");
11
+ const command_1 = require("@salesforce/command");
12
+ const core_1 = require("@salesforce/core");
13
+ const orgShapeListUtils_1 = require("../../../../shared/orgShapeListUtils");
14
+ core_1.Messages.importMessagesDirectory(__dirname);
15
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-signups', 'shape.delete');
16
+ class OrgShapeDeleteCommand extends command_1.SfdxCommand {
17
+ async run() {
18
+ if (!this.flags.noprompt) {
19
+ if (!(await this.ux.confirm(messages.getMessage('deleteCommandYesNo', [this.org.getUsername()])))) {
20
+ return;
21
+ }
22
+ }
23
+ this.conn = this.org.getConnection();
24
+ if (!(await (0, orgShapeListUtils_1.isShapeEnabled)(this.conn))) {
25
+ const err = messages.createError('noAccess', [this.org.getUsername()]);
26
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27
+ // @ts-ignore override readonly .name field
28
+ err.name = 'noAccess';
29
+ throw err;
30
+ }
31
+ const deleteRes = await this.deleteAll();
32
+ if (deleteRes.shapeIds.length === 0) {
33
+ this.ux.log(messages.getMessage('noShapesHumanSuccess', [this.org.getOrgId()]));
34
+ return;
35
+ }
36
+ if (deleteRes.failures.length > 0 && deleteRes.shapeIds.length > 0) {
37
+ this.setExitCode(68);
38
+ this.ux.styledHeader('Partial Success');
39
+ this.ux.log(messages.getMessage('humanSuccess', [this.org.getOrgId()]));
40
+ this.ux.log('');
41
+ this.ux.styledHeader('Failures');
42
+ const columns = {
43
+ shapeId: { header: 'Shape ID' },
44
+ message: { header: 'Error Message' },
45
+ };
46
+ this.ux.table(deleteRes.failures, columns);
47
+ }
48
+ else if (deleteRes.failures.length > 0) {
49
+ this.setExitCode(1);
50
+ }
51
+ else if (deleteRes.shapeIds.length > 0) {
52
+ this.setExitCode(0);
53
+ this.ux.log(messages.getMessage('humanSuccess', [this.org.getOrgId()]));
54
+ }
55
+ return {
56
+ orgId: this.org.getOrgId(),
57
+ shapeIds: deleteRes.shapeIds,
58
+ failures: deleteRes.failures,
59
+ };
60
+ }
61
+ setExitCode(code) {
62
+ process.exitCode = code;
63
+ }
64
+ /**
65
+ * Delete all ShapeRepresentation records for the shapeOrg.
66
+ *
67
+ * @return List of SR IDs that were deleted
68
+ */
69
+ async deleteAll() {
70
+ const deleteAllResult = {
71
+ shapeIds: [],
72
+ failures: [],
73
+ };
74
+ let shapeIds = [];
75
+ try {
76
+ const result = await this.conn.query('SELECT Id FROM ShapeRepresentation');
77
+ if (result.totalSize === 0) {
78
+ return deleteAllResult;
79
+ }
80
+ shapeIds = result.records.map((shape) => shape.Id);
81
+ }
82
+ catch (err) {
83
+ const JsForceErr = err;
84
+ if (JsForceErr.errorCode && JsForceErr.errorCode === 'INVALID_TYPE') {
85
+ // ShapeExportPref is not enabled, or user does not have CRUD access
86
+ const e = messages.createError('noAccess', [this.org.getUsername()]);
87
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
88
+ // @ts-ignore override readonly .name field
89
+ e.name = 'noAccess';
90
+ throw e;
91
+ }
92
+ // non-access error
93
+ throw JsForceErr;
94
+ }
95
+ await Promise.allSettled(shapeIds.map(async (id) => {
96
+ try {
97
+ const delResult = await this.conn.sobject('ShapeRepresentation').delete(id);
98
+ if (delResult.success) {
99
+ deleteAllResult.shapeIds.push(id);
100
+ }
101
+ }
102
+ catch (err) {
103
+ deleteAllResult.failures.push({
104
+ shapeId: id,
105
+ message: err instanceof Error ? err.message : 'error contained no message',
106
+ });
107
+ }
108
+ }));
109
+ return deleteAllResult;
110
+ }
111
+ }
112
+ exports.OrgShapeDeleteCommand = OrgShapeDeleteCommand;
113
+ OrgShapeDeleteCommand.description = messages.getMessage('description');
114
+ OrgShapeDeleteCommand.examples = messages.getMessage('help').split(os_1.EOL);
115
+ OrgShapeDeleteCommand.requiresUsername = true;
116
+ OrgShapeDeleteCommand.flagsConfig = {
117
+ noprompt: command_1.flags.boolean({
118
+ char: 'p',
119
+ description: messages.getMessage('noPrompt'),
120
+ }),
121
+ };
122
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../../src/commands/force/org/shape/delete.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2BAAyB;AACzB,iDAAsE;AACtE,2CAAwD;AACxD,4EAAoF;AAEpF,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,4BAA4B,EAAE,cAAc,CAAC,CAAC;AA0BrF,MAAa,qBAAsB,SAAQ,qBAAW;IAY7C,KAAK,CAAC,GAAG;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACxB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;gBACjG,OAAO;aACR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AgB,GAAG,IAAI,CAAC;AACxB,iCAAW,GAAgB;IAChD,QAAQ,EAAE,eAAK,CAAC,OAAO,CAAC;QACtB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC;KAC7C,CAAC;CACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { FlagsConfig, SfdxCommand } from '@salesforce/command';
2
+ import { OrgShapeListResult } from '../../../../shared/orgShapeListUtils';
3
+ export declare class OrgShapeListCommand extends SfdxCommand {
4
+ static readonly description: string;
5
+ static readonly examples: string[];
6
+ static readonly flagsConfig: FlagsConfig;
7
+ run(): Promise<OrgShapeListResult[]>;
8
+ getAllOrgShapesFromAuthenticatedOrgs(): Promise<OrgShapeListResult[]>;
9
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2022, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.OrgShapeListCommand = void 0;
10
+ const os_1 = require("os");
11
+ const command_1 = require("@salesforce/command");
12
+ const core_1 = require("@salesforce/core");
13
+ const chalk = require("chalk");
14
+ const orgShapeListUtils_1 = require("../../../../shared/orgShapeListUtils");
15
+ core_1.Messages.importMessagesDirectory(__dirname);
16
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-signups', 'shape.list');
17
+ // default columns for the shape list
18
+ const orgShapeColumns = {
19
+ alias: {
20
+ header: 'ALIAS',
21
+ get: (data) => { var _a; return (_a = data.alias) !== null && _a !== void 0 ? _a : ''; },
22
+ },
23
+ username: { header: 'USERNAME' },
24
+ orgId: { header: 'ORG ID' },
25
+ status: { header: 'SHAPE STATUS' },
26
+ createdBy: { header: 'CREATED BY' },
27
+ createdDate: { header: 'CREATED DATE' },
28
+ };
29
+ class OrgShapeListCommand extends command_1.SfdxCommand {
30
+ async run() {
31
+ const shapes = await this.getAllOrgShapesFromAuthenticatedOrgs();
32
+ if (shapes.length === 0) {
33
+ this.ux.log(messages.getMessage('noOrgShapes'));
34
+ return shapes;
35
+ }
36
+ this.ux.styledHeader('Org Shapes');
37
+ this.ux.table(shapes.map((shape) => (shape.status === 'Active' ? { ...shape, status: chalk.green(shape.status) } : shape)), orgShapeColumns);
38
+ return shapes;
39
+ }
40
+ async getAllOrgShapesFromAuthenticatedOrgs() {
41
+ const orgs = await core_1.AuthInfo.listAllAuthorizations((orgAuth) => !orgAuth.error && !orgAuth.isScratchOrg);
42
+ if (orgs.length === 0) {
43
+ const e = messages.createError('noAuthFound');
44
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
45
+ // @ts-ignore override readonly .name field
46
+ e.name = 'noAuthFound';
47
+ throw e;
48
+ }
49
+ const shapes = await Promise.all(orgs.map((o) => (0, orgShapeListUtils_1.getAllShapesFromOrg)(o)));
50
+ return shapes.flat();
51
+ }
52
+ }
53
+ exports.OrgShapeListCommand = OrgShapeListCommand;
54
+ OrgShapeListCommand.description = messages.getMessage('description');
55
+ OrgShapeListCommand.examples = messages.getMessage('help').split(os_1.EOL);
56
+ OrgShapeListCommand.flagsConfig = {
57
+ verbose: command_1.flags.builtin({
58
+ description: messages.getMessage('verbose'),
59
+ }),
60
+ };
61
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../../src/commands/force/org/shape/list.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2BAAyB;AACzB,iDAAsE;AACtE,2CAAsD;AACtD,+BAA+B;AAC/B,4EAA+F;AAE/F,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,4BAA4B,EAAE,YAAY,CAAC,CAAC;AAEnF,qCAAqC;AACrC,MAAM,eAAe,GAA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K,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACxG,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YAC9C,6DAA6D;YAC7D,2CAA2C;YAC3C,CAAC,CAAC,IAAI,GAAG,aAAa,CAAC;YACvB,MAAM,CAAC,CAAC;SACT;QACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uCAAmB,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;;AAnCH,kDAoCC;AAnCwB,+BAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACjD,4BAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAG,CAAC,CAAC;AAClD,+BAAW,GAAgB;IAChD,OAAO,EAAE,eAAK,CAAC,OAAO,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;KAC5C,CAAC;CACH,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export = _default;
package/lib/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2021, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ module.exports = {};
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,iBAAS,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { OrgAuthorization, Connection } from '@salesforce/core';
2
+ export interface OrgShapeListResult {
3
+ orgId: string;
4
+ username: string;
5
+ alias?: string;
6
+ shapeId: string;
7
+ status: string;
8
+ createdBy: string;
9
+ createdDate: string;
10
+ }
11
+ export interface JsForceError extends Error {
12
+ errorCode: string;
13
+ fields: string[];
14
+ }
15
+ export declare function getAllShapesFromOrg(orgAuth: OrgAuthorization): Promise<OrgShapeListResult[]>;
16
+ /**
17
+ * Check if the ShapeExportPilot preference is enabled.
18
+ */
19
+ export declare function isShapeEnabled(conn: Connection): Promise<boolean>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2022, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.isShapeEnabled = exports.getAllShapesFromOrg = void 0;
10
+ const core_1 = require("@salesforce/core");
11
+ async function getAllShapesFromOrg(orgAuth) {
12
+ const org = await core_1.Org.create({ aliasOrUsername: orgAuth.username });
13
+ const conn = org.getConnection();
14
+ const logger = await core_1.Logger.child(`getAllShapesFromOrg, ${orgAuth.username}`);
15
+ logger.info(`Query org: ${orgAuth.username} for shapes`);
16
+ try {
17
+ const shapesFound = await conn.query("SELECT Id, Status, CreatedBy.Username, CreatedDate FROM ShapeRepresentation WHERE Status IN ( 'Active', 'InProgress' )");
18
+ return shapesFound.records.map((shape) => {
19
+ var _a;
20
+ return ({
21
+ ...{
22
+ orgId: orgAuth.orgId,
23
+ username: orgAuth.username,
24
+ shapeId: shape.Id,
25
+ status: shape.Status,
26
+ createdBy: shape.CreatedBy.Username,
27
+ createdDate: shape.CreatedDate,
28
+ },
29
+ ...(((_a = orgAuth.aliases) === null || _a === void 0 ? void 0 : _a.length) > 0 ? { alias: orgAuth.aliases.join(',') } : {}),
30
+ });
31
+ });
32
+ }
33
+ catch (err) {
34
+ const JsForceErr = err;
35
+ if (JsForceErr.errorCode === 'INVALID_TYPE') {
36
+ return [];
37
+ }
38
+ else {
39
+ logger.error(false, 'Error finding org shapes', JsForceErr);
40
+ throw JsForceErr;
41
+ }
42
+ }
43
+ }
44
+ exports.getAllShapesFromOrg = getAllShapesFromOrg;
45
+ /**
46
+ * Check if the ShapeExportPilot preference is enabled.
47
+ */
48
+ async function isShapeEnabled(conn) {
49
+ var _a, _b;
50
+ const prefValue = await conn.tooling.query(`SELECT IsShapeExportPrefEnabled FROM ${'DevHubSettings'}`);
51
+ // no records are returned if ShapeExportPilot perm is disabled
52
+ return prefValue.totalSize > 0 && ((_b = (_a = prefValue.records) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.IsShapeExportPrefEnabled);
53
+ }
54
+ exports.isShapeEnabled = isShapeEnabled;
55
+ //# sourceMappingURL=orgShapeListUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orgShapeListUtils.js","sourceRoot":"","sources":["../../src/shared/orgShapeListUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2CAA6E;AA0BtE,KAAK,UAAU,mBAAmB,CAAC,OAAyB;IACjE,MAAM,GAAG,GAAG,MAAM,UAAG,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,aAAM,CAAC,KAAK,CAAC,wBAAwB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9E,MAAM,CAAC,IAAI,CAAC,cAAc,OAAO,CAAC,QAAQ,aAAa,CAAC,CAAC;IACzD,IAAI;QACF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,KAAK,CAClC,wHAAwH,CACzH,CAAC;QACF,OAAO,WAAW,CAAC,OAAO,CAAC,G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Representation object. Then try again.",
3
+ "create_shape_command_success_id": "Successfully created org shape for %s.",
4
+ "shape_create_failed_message": "Error creating scratch definition file. Please contact Salesforce support.",
5
+ "shape_get_not_a_shape_id": "the value passed in was not a shape id",
6
+
7
+ "create_shape_command_description": "Create a scratch org configuration (shape) based on the specified source org",
8
+ "create_shape_command_description_long": "Create a scratch org configuration (shape) based on the specified source org.",
9
+ "create_shape_command_help": [
10
+ "sfdx force:org:shape:create -u me@my.org",
11
+ "sfdx force:org:shape:create -u me@my.org --json --loglevel debug"
12
+ ],
13
+ "create_shape_command_username": "a username or alias for the target org",
14
+ "create_shape_command_username_long": "Username or alias of the previously authorized org from which you want to create an org shape.",
15
+ "noAccess": "The org needs to be enabled for org shape before one can be created. %s"
16
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "description": "Delete all org shapes for a target org",
3
+ "longDescription": "Deletes all org shapes that you’ve created for an org using the Salesforce CLI.",
4
+ "verbose": "list more information about each org shape",
5
+ "verboseLong": "Lists more information about each org shape.",
6
+ "usernameOption": "username for the target org",
7
+ "usernameOptionLong": "Username for the target org.",
8
+ "targetUsernameOption": "username for the target org",
9
+ "targetUsernameOptionLong": "Username for the target org.",
10
+ "noPrompt": "do not prompt for confirmation",
11
+ "noPromptLong": "Do not prompt for confirmation.",
12
+ "noAccess": "The org with name: %s needs to be enabled for org shape before shapes can be deleted.",
13
+ "deleteCommandYesNo": "Delete shapes for org with name: %s? Are you sure (y/n)?",
14
+ "humanSuccess": "Successfully deleted org shape for %s.",
15
+ "noShapesHumanSuccess": "Can't delete org shape. No org shape found for org %s.",
16
+ "help": [
17
+ "sfdx force:org:shape:delete -u me@my.org",
18
+
19
+ "sfdx force:org:shape:delete -u MyOrgAlias -p",
20
+
21
+ "sfdx force:org:shape:delete -u me@my.org --json",
22
+
23
+ "sfdx force:org:shape:delete -u me@my.org -p --json > tmp/MyOrgShapeDelete.json"
24
+ ]
25
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "description": "List all org shapes you’ve created",
3
+ "longDescription": "Lists all org shapes that you’ve created using the Salesforce CLI.",
4
+ "verbose": "list more information about each org shape",
5
+ "verboseLong": "Lists more information about each org shape.",
6
+ "noOrgShapes": "No org shapes found.",
7
+ "noAuthFound": "No authenticated orgs found.",
8
+ "help": [
9
+ "sfdx force:org:shape:list",
10
+ "sfdx force:org:shape:list --json",
11
+ "sfdx force:org:shape:list --json > tmp/MyOrgShapeList.json"
12
+ ]
13
+ }
@@ -0,0 +1 @@
1
+ {"version":"1.0.0","commands":{"force:org:shape:create":{"id":"force:org:shape:create","description":"Create a scratch org configuration (shape) based on the specified source org","strict":true,"usage":"<%= command.id %> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@salesforce/plugin-signups","pluginAlias":"@salesforce/plugin-signups","pluginType":"core","aliases":[],"examples":["sfdx force:org:shape:create -u me@my.org","sfdx force:org:shape:create -u me@my.org --json --loglevel debug"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","multiple":false,"options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org","multiple":false},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command","multiple":false}},"args":[],"requiresUsername":true},"force:org:shape:delete":{"id":"force:org:shape:delete","description":"Delete all org shapes for a target org","strict":true,"usage":"<%= command.id %> [-p] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@salesforce/plugin-signups","pluginAlias":"@salesforce/plugin-signups","pluginType":"core","aliases":[],"examples":["sfdx force:org:shape:delete -u me@my.org","sfdx force:org:shape:delete -u MyOrgAlias -p","sfdx force:org:shape:delete -u me@my.org --json","sfdx force:org:shape:delete -u me@my.org -p --json > tmp/MyOrgShapeDelete.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","multiple":false,"options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org","multiple":false},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command","multiple":false},"noprompt":{"name":"noprompt","type":"boolean","char":"p","description":"do not prompt for confirmation","allowNo":false}},"args":[],"requiresUsername":true,"flagsConfig":{"noprompt":{"kind":"boolean","char":"p","description":"do not prompt for confirmation","allowNo":false,"type":"boolean"}}},"force:org:shape:list":{"id":"force:org:shape:list","description":"List all org shapes you’ve created","strict":true,"usage":"<%= command.id %> [--verbose] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@salesforce/plugin-signups","pluginAlias":"@salesforce/plugin-signups","pluginType":"core","aliases":[],"examples":["sfdx force:org:shape:list","sfdx force:org:shape:list --json","sfdx force:org:shape:list --json > tmp/MyOrgShapeList.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","multiple":false,"options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"verbose":{"name":"verbose","type":"boolean","description":"list more information about each org shape","allowNo":false}},"args":[],"flagsConfig":{"verbose":{"description":"list more information about each org shape","type":"boolean","kind":"boolean","longDescription":"Emit additional command output to stdout.","allowNo":false}}}}}
package/package.json ADDED
@@ -0,0 +1,122 @@
1
+ {
2
+ "name": "@salesforce/plugin-signups",
3
+ "description": "Commands to interact with org shapes",
4
+ "version": "1.0.0",
5
+ "author": "Salesforce",
6
+ "main": "lib/index.js",
7
+ "bugs": "https://github.com/forcedotcom/cli/issues",
8
+ "dependencies": {
9
+ "@oclif/core": "^1.6.3",
10
+ "@salesforce/command": "^5.0.1",
11
+ "@salesforce/core": "^3.10.1",
12
+ "chalk": "^4.1.2",
13
+ "tslib": "^2"
14
+ },
15
+ "devDependencies": {
16
+ "oclif": "^2.6.1",
17
+ "@oclif/plugin-command-snapshot": "^3.1.3",
18
+ "@salesforce/cli-plugins-testkit": "^1.5.3",
19
+ "@salesforce/dev-config": "^3.0.1",
20
+ "@salesforce/dev-scripts": "^2.0.1",
21
+ "@salesforce/plugin-command-reference": "^1.3.18",
22
+ "@salesforce/prettier-config": "^0.0.2",
23
+ "@salesforce/ts-sinon": "1.3.21",
24
+ "@salesforce/ts-types": "^1.5.20",
25
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
26
+ "@typescript-eslint/parser": "^4.32.0",
27
+ "chai": "^4.3.4",
28
+ "chai-as-promised": "7.1.1",
29
+ "cz-conventional-changelog": "^3.3.0",
30
+ "eslint": "^7.32.0",
31
+ "eslint-config-prettier": "^8.3.0",
32
+ "eslint-config-salesforce": "^0.1.6",
33
+ "eslint-config-salesforce-license": "^0.1.6",
34
+ "eslint-config-salesforce-typescript": "^0.2.8",
35
+ "eslint-plugin-header": "^3.1.1",
36
+ "eslint-plugin-import": "^2.24.2",
37
+ "eslint-plugin-jsdoc": "^35.5.1",
38
+ "eslint-plugin-prettier": "^3.4.1",
39
+ "husky": "^7.0.4",
40
+ "lint-staged": "^11.2.0",
41
+ "mocha": "^9.1.3",
42
+ "nyc": "^15.1.0",
43
+ "prettier": "^2.4.1",
44
+ "pretty-quick": "^3.1.0",
45
+ "shx": "0.2.2",
46
+ "sinon": "^11.1.1",
47
+ "ts-node": "^10.2.1",
48
+ "typescript": "^4.1.3"
49
+ },
50
+ "config": {
51
+ "commitizen": {
52
+ "path": "cz-conventional-changelog"
53
+ }
54
+ },
55
+ "engines": {
56
+ "node": ">=12.0.0"
57
+ },
58
+ "files": [
59
+ "/lib",
60
+ "/messages",
61
+ "/oclif.manifest.json"
62
+ ],
63
+ "homepage": "https://github.com/salesforcecli/plugin-signups",
64
+ "keywords": [
65
+ "force",
66
+ "salesforce",
67
+ "sfdx",
68
+ "salesforcedx",
69
+ "sfdx-plugin"
70
+ ],
71
+ "license": "BSD-3-Clause",
72
+ "oclif": {
73
+ "commands": "./lib/commands",
74
+ "bin": "sfdx",
75
+ "devPlugins": [
76
+ "@oclif/plugin-command-snapshot",
77
+ "@salesforce/plugin-command-reference"
78
+ ],
79
+ "topics": {
80
+ "force": {
81
+ "external": true,
82
+ "subtopics": {
83
+ "org": {
84
+ "subtopics": {
85
+ "shape": {
86
+ "description": "manage org shape"
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ },
94
+ "repository": "salesforcecli/plugin-signups",
95
+ "scripts": {
96
+ "build": "sf-build",
97
+ "clean": "sf-clean",
98
+ "clean-all": "sf-clean all",
99
+ "clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json",
100
+ "compile": "sf-compile",
101
+ "docs": "sf-docs",
102
+ "format": "sf-format",
103
+ "lint": "sf-lint",
104
+ "postpack": "shx rm -f oclif.manifest.json",
105
+ "posttest": "yarn lint && yarn test:deprecation-policy && yarn test:command-reference",
106
+ "prepack": "sf-prepack",
107
+ "prepare": "sf-install",
108
+ "pretest": "sf-compile-test",
109
+ "test": "sf-test",
110
+ "test:command-reference": "./bin/run commandreference:generate --erroronwarnings",
111
+ "test:deprecation-policy": "./bin/run snapshot:compare",
112
+ "test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel",
113
+ "version": "oclif readme"
114
+ },
115
+ "publishConfig": {
116
+ "access": "public"
117
+ },
118
+ "sfdx": {
119
+ "publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-signups/1.0.0.crt",
120
+ "signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-signups/1.0.0.sig"
121
+ }
122
+ }