Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A plugin for the Salesforce CLI built by Wade Wegner and containing a lot of hel
* [`sfdx-waw-plugin waw:codeclean:check -i <string> [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawcodecleancheck--i-string---json---loglevel-tracedebuginfowarnerrorfatal)
* [`sfdx-waw-plugin waw:codeclean:results -i <string> [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawcodecleanresults--i-string---json---loglevel-tracedebuginfowarnerrorfatal)
* [`sfdx-waw-plugin waw:codeclean:start [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawcodecleanstart--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfatal)
* [`sfdx-waw-plugin waw:connectedapp:create -n <string> [-l <string>] [-r] [-c <string>] [-d <string>] [-s <string>] [-e <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawconnectedappcreate--n-string--l-string--r--c-string--d-string--s-string--e-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfatal)
* [`sfdx-waw-plugin waw:connectedapp:create -n <string> [-l <string>] [-r] [-c <string>] [-d <string>] [-s <string>] [-e <string>] [-q <string>] [-i <string>] [-m <string>] [-f <string>] [-o <string>] [-p <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawconnectedappcreate--n-string--l-string--r--c-string--d-string--s-string--e-string--q-string--i-string--m-string--f-string--o-string--p-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfatal)
* [`sfdx-waw-plugin waw:connectedapp:list -n <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawconnectedapplist--n-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfatal)
* [`sfdx-waw-plugin waw:org:share -e <email> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-waworgshare--e-email--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfatal)
* [`sfdx-waw-plugin waw:package2:update -d <string> [-i <id>] [-n <string>] [-v <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawpackage2update--d-string--i-id--n-string--v-string---json---loglevel-tracedebuginfowarnerrorfatal)
Expand Down Expand Up @@ -130,21 +130,42 @@ OPTIONS

_See code: [src/commands/waw/codeclean/start.ts](https://github.com/WadeWegner/sfdx-waw-plugin/blob/v1.5.0/src/commands/waw/codeclean/start.ts)_

## `sfdx-waw-plugin waw:connectedapp:create -n <string> [-l <string>] [-r] [-c <string>] [-d <string>] [-s <string>] [-e <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]`
## `sfdx-waw-plugin waw:connectedapp:create -n <string> [-l <string>] [-r] [-c <string>] [-d <string>] [-s <string>] [-e <string>] [-q <string>] [-i <string>] [-m <string>] [-f <string>] [-o <string>] [-p <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]`

create a connected app in your org

```
USAGE
$ sfdx-waw-plugin waw:connectedapp:create -n <string> [-l <string>] [-r] [-c <string>] [-d <string>] [-s <string>] [-e
<string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]
<string>] [-q <string>] [-i <string>] [-m <string>] [-f <string>] [-o <string>] [-p <string>] [-u <string>]
[--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal]

OPTIONS
-c, --callbackurl=callbackurl callbackUrl (default is "sfdx://success")
-d, --description=description connected app description
-e, --contactemail=contactemail connected app contact email

-f, --locations=locations Indicates where the canvas app can appear to the user. Valid values
are 'Chatter', 'ChatterFeed', 'MobileNav', 'PageLayout', 'Publisher',
'Visualforce'

-i, --canvasurl=canvasurl he URL of the third-party app that’s exposed as a canvas app.

-l, --label=label connected app label

-m, --accessmethod=accessmethod Indicates how the canvas app initiates the OAuth authentication flow.
Valid values are 'GET' and 'POST'

-n, --name=name (required) connected app name

-o, --options=options Indicates whether to hide the share button and header in the publisher
for your canvas app, and whether the app is a canvas personal app.

-p, --namespace=namespace Indicate if the Salesforce Organization has a namespace

-q, --consumersecret=consumersecret A value that is combined with the consumerKey and used by the consumer
for identification to Salesforce

-r, --certificate create and register a certificate

-s, --scopes=scopes scopes separated by commas (defaut: Basic, Api, Web, RefreshToken;
Expand Down
8 changes: 7 additions & 1 deletion messages/waw.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
"callbackurl": "callbackUrl (default is \"sfdx://success\")",
"description": "connected app description",
"scopes": "scopes separated by commas (defaut: Basic, Api, Web, RefreshToken; valid: Basic, Api, Web, Full, Chatter, CustomApplications, RefreshToken, OpenID, CustomPermissions, Wave, Eclair)",
"contactemail": "connected app contact email"
"contactemail": "connected app contact email",
"consumersecret": "A value that is combined with the consumerKey and used by the consumer for identification to Salesforce",
"canvasurl": "he URL of the third-party app that’s exposed as a canvas app.",
"accessmethod": "Indicates how the canvas app initiates the OAuth authentication flow. Valid values are 'GET' and 'POST'",
"locations": "Indicates where the canvas app can appear to the user. Valid values are 'Chatter', 'ChatterFeed', 'MobileNav', 'PageLayout', 'Publisher', 'Visualforce'",
"options": "Indicates whether to hide the share button and header in the publisher for your canvas app, and whether the app is a canvas personal app.",
"namespace": "Indicate if the Salesforce Organization has a namespace"
}
},
"list": {
Expand Down
54 changes: 52 additions & 2 deletions src/commands/waw/connectedapp/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ export default class ConnectedAppCreate extends SfdxCommand {
contactemail: flags.string({
char: 'e',
description: messages.getMessage('connectedapp.create.flags.contactemail')
}),
consumersecret: flags.string({
char: 'q',
description: messages.getMessage('connectedapp.create.flags.consumersecret')
}),
canvasurl: flags.string({
char: 'i',
description: messages.getMessage('connectedapp.create.flags.canvasurl')
}),
accessmethod: flags.string({
char: 'm',
description: messages.getMessage('connectedapp.create.flags.accessmethod')
}),
locations: flags.string({
// 'Chatter', 'ChatterFeed', 'MobileNav', 'PageLayout', 'Publisher', 'Visualforce'
char: 'f',
description: messages.getMessage('connectedapp.create.flags.locations')
}),
options: flags.string({
// PersonalEnabled
char: 'o',
description: messages.getMessage('connectedapp.create.flags.options')
}),
namespace: flags.string({
char: 'p',
description: messages.getMessage('connectedapp.create.flags.namespace')
})
};

Expand All @@ -63,7 +89,21 @@ export default class ConnectedAppCreate extends SfdxCommand {
const description = this.flags.description || 'generated by waw:connectedapp:create';
const scopes = this.flags.scopes && this.flags.scopes.split(',') || ['Basic', 'Api', 'Web', 'RefreshToken'];

const consumerSecret = this.getConsumerSecret();
const consumerSecret = this.flags.consumersecret || this.getConsumerSecret();

const canvasurl = this.flags.canvasurl;
const accessmethod = this.flags.accessmethod;
const locations = this.flags.locations;
const options = this.flags.options;

const canvasConfig = {};

if (canvasurl != null) {
canvasConfig['canvasUrl'] = canvasurl;
canvasConfig['accessMethod'] = accessmethod;
canvasConfig['locations'] = locations.split(',');
canvasConfig['options'] = options.split(',');
}

const metadata = [{
contactEmail,
Expand All @@ -73,6 +113,10 @@ export default class ConnectedAppCreate extends SfdxCommand {
oauthConfig: { callbackUrl, consumerSecret, scopes }
}];

if (canvasurl != null) {
metadata[0]['canvasConfig'] = canvasConfig;
}

if (createCerts) {
const pubKey = await this.generateCert(consumerSecret);
metadata[0].oauthConfig['certificate'] = pubKey;
Expand All @@ -98,8 +142,14 @@ export default class ConnectedAppCreate extends SfdxCommand {
private async createConnectedApp(metadata): Promise<SaveResult | MetadataInfo> {
const conn = this.org.getConnection();
const results = await conn.metadata.create('ConnectedApp', metadata) as SaveResult;

if (results.success) {
return (await conn.metadata.read('ConnectedApp', results.fullName) as MetadataInfo);
let connectedAppName = results.fullName;
if (this.flags.namespace != null) {
connectedAppName = this.flags.namespace + '__' + connectedAppName;
}

return (await conn.metadata.read('ConnectedApp', connectedAppName) as MetadataInfo);
}
return results;
}
Expand Down