-
Notifications
You must be signed in to change notification settings - Fork 818
/
pull-headless.ts
51 lines (49 loc) · 1.48 KB
/
pull-headless.ts
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
import { nspawn as spawn, getCLIPath } from '..';
const defaultSettings = {
name: '\r',
envName: 'integtest',
editor: '\r',
appType: '\r',
framework: '\r',
srcDir: '\r',
distDir: '\r',
buildCmd: '\r',
startCmd: '\r',
useProfile: '\r',
profileName: '\r',
appId: '',
};
export function pullProject(cwd: string, settings: Object) {
const s = { ...defaultSettings, ...settings };
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['pull', '--appId', s.appId, '--envName', s.envName], { cwd, stripColors: true })
.wait('Select the authentication method you want to use:')
.sendLine(s.useProfile)
.wait('Please choose the profile you want to use')
.sendLine(s.profileName)
.wait('Choose your default editor:')
.sendLine(s.editor)
.wait("Choose the type of app that you're building")
.sendLine(s.appType)
.wait('What javascript framework are you using')
.sendLine(s.framework)
.wait('Source Directory Path:')
.sendLine(s.srcDir)
.wait('Distribution Directory Path:')
.sendLine(s.distDir)
.wait('Build Command:')
.sendLine(s.buildCmd)
.wait('Start Command:')
.sendCarriageReturn()
.wait('Do you plan on modifying this backend?')
.sendLine('n')
.wait('Added backend environment config object to your project.')
.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
});
});
}