-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.js
More file actions
46 lines (38 loc) · 1.3 KB
/
Copy pathinit.js
File metadata and controls
46 lines (38 loc) · 1.3 KB
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
const { Command } = require('@oclif/command');
const prompts = require('../prompts');
const api = require('../aws');
const Conf = require('conf');
const config = new Conf();
const log = require('../util/log.js');
const {
populateWorkflows,
createWorkflowDir,
copyWorkflowFilesToRepo,
} = require('../util/fs');
const getAppInfo = async () => {
const appInfo = await prompts.appInfoPrompt();
return appInfo;
};
const addAppToConfigFile = APP_NAME => {
if(config.get('APP_NAMES') === undefined) {
log.warn('Oops! Something went wrong T^T \nPlease run gander destroy and try again.')
process.exit(1)
}
let apps = JSON.parse(config.get('APP_NAMES'));
apps.push(APP_NAME);
config.set('APP_NAMES', JSON.stringify(apps));
};
class InitCommand extends Command {
async run() {
log.header('🐥 Initializing your project repository with Gander\n');
createWorkflowDir();
copyWorkflowFilesToRepo();
const appInfo = await getAppInfo();
addAppToConfigFile(appInfo.APP_NAME);
api.clients.ecs = await api.initializeEcsClient(config.get('AWS_REGION'));
await api.createCluster({ clusterName: appInfo.APP_NAME });
await populateWorkflows(appInfo);
}
}
InitCommand.description = 'Initialize your project repository as a Gander review app';
module.exports = InitCommand;