diff --git a/README.md b/README.md index 3061db1..e8cec2d 100644 --- a/README.md +++ b/README.md @@ -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 [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawcodecleancheck--i-string---json---loglevel-tracedebuginfowarnerrorfatal) * [`sfdx-waw-plugin waw:codeclean:results -i [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawcodecleanresults--i-string---json---loglevel-tracedebuginfowarnerrorfatal) * [`sfdx-waw-plugin waw:codeclean:start [-u ] [--apiversion ] [--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 [-l ] [-r] [-c ] [-d ] [-s ] [-e ] [-u ] [--apiversion ] [--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 [-l ] [-r] [-c ] [-d ] [-s ] [-e ] [-q ] [-i ] [-m ] [-f ] [-o ] [-p ] [-u ] [--apiversion ] [--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 [-u ] [--apiversion ] [--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 [-u ] [--apiversion ] [--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 [-i ] [-n ] [-v ] [--json] [--loglevel trace|debug|info|warn|error|fatal]`](#sfdx-waw-plugin-wawpackage2update--d-string--i-id--n-string--v-string---json---loglevel-tracedebuginfowarnerrorfatal) @@ -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 [-l ] [-r] [-c ] [-d ] [-s ] [-e ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal]` +## `sfdx-waw-plugin waw:connectedapp:create -n [-l ] [-r] [-c ] [-d ] [-s ] [-e ] [-q ] [-i ] [-m ] [-f ] [-o ] [-p ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal]` create a connected app in your org ``` USAGE $ sfdx-waw-plugin waw:connectedapp:create -n [-l ] [-r] [-c ] [-d ] [-s ] [-e - ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal] + ] [-q ] [-i ] [-m ] [-f ] [-o ] [-p ] [-u ] + [--apiversion ] [--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; diff --git a/messages/waw.json b/messages/waw.json index cbf17e8..359af0d 100644 --- a/messages/waw.json +++ b/messages/waw.json @@ -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": { diff --git a/src/commands/waw/connectedapp/create.ts b/src/commands/waw/connectedapp/create.ts index 789bf96..68f8c23 100644 --- a/src/commands/waw/connectedapp/create.ts +++ b/src/commands/waw/connectedapp/create.ts @@ -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') }) }; @@ -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, @@ -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; @@ -98,8 +142,14 @@ export default class ConnectedAppCreate extends SfdxCommand { private async createConnectedApp(metadata): Promise { 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; }