This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy.js
75 lines (67 loc) · 2.37 KB
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
const sh = require('shelljs');
const chalk = require('chalk');
const { userInputPrompt } = require('./deploy/get-user-input');
const { setupHerokuApp } = require('./deploy/setup-heroku-app');
const { salesforceScratchOrgSetup } = require('./deploy/setup-salesforce-org');
const {
createCertificate,
deployConnectedApp
} = require('./deploy/deploy-connected-app');
const log = console.log;
sh.env.PROJECT_ROOT_DIR = sh
.exec('git rev-parse --show-toplevel')
.toString()
.replace(/\n+$/, '');
sh.env.CURRENT_BRANCH = sh
.exec('git branch --show-current', {
silent: true
})
.toString()
.replace(/\n+$/, '');
sh.env.SF_USERNAME = '';
sh.env.SF_PASSWORD = '';
sh.env.SF_LOGIN_URL = '';
sh.env.ORGID = '';
sh.env.CONSUMERKEY = '';
sh.env.PRIVATE_KEY = '';
sh.env.HEROKU_APP_NAME = '';
sh.env.SLACK_BOT_TOKEN = '';
sh.env.SLACK_SIGNING_SECRET = '';
(async () => {
try {
// Run the commands in the rest of this script from the root directory
sh.cd(sh.env.PROJECT_ROOT_DIR);
// Ask user to input values needed for the deploy
await getuserinput();
log('');
log('*** Starting the salesforce and heroku app setup ***');
if (!sh.env.SF_PASSWORD) {
// jwt-bearer flow
log('*** Creating Salesforce org ***');
salesforceScratchOrgSetup();
log('*** Generating Certificates for Connected App');
const resultcert = createCertificate();
log('*** Creating Connected app');
deployConnectedApp(resultcert.pubkey);
}
log('*** Create Heroku App with necessary configs');
setupHerokuApp();
} catch (err) {
log(chalk.bold.red(`*** ERROR: ${err}`));
}
})();
async function getuserinput() {
log('');
log(chalk.bold('*** Please provide the following information: '));
const response = await userInputPrompt();
sh.env.SF_DEV_HUB = response.devhub ?? '';
sh.env.SF_SCRATCH_ORG = response.scratchorg ?? '';
sh.env.SF_USERNAME = response['sf-username'];
sh.env.SF_PASSWORD = response['sf-password'] ?? '';
sh.env.SF_LOGIN_URL =
response['sf-login-url'] ?? 'https://test.salesforce.com';
sh.env.HEROKU_APP_NAME = response['heroku-app'];
sh.env.SLACK_BOT_TOKEN = response['slack-bot-token'];
sh.env.SLACK_SIGNING_SECRET = response['slack-signing-secret'];
}