-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·88 lines (74 loc) · 1.78 KB
/
index.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
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env node
/**
* pucc
* PowerUp Custom Connector CLI
*
* @author Nirmal Kumar <https://twitter.com/nirmal_kumar/>
*/
const init = require('./utils/init');
const cli = require('./utils/cli');
const log = require('./utils/log');
const inquirer=require('inquirer');
const alert = require('cli-alerts');
const create = require('./utils/core/create');
const input = cli.input;
const flags = cli.flags;
const { clear, debug } = flags;
(async () => {
init({ clear });
input.includes(`help`) && cli.showHelp(0);
flags.split &&
alert({
type: 'info',
name: `Power Up Custom Connector Cli`,
msg: `Schedule`
});
const path=require('path');
const fullPathName = process.cwd();
const targetDir = path.resolve(
fullPathName.substr(fullPathName.indexOf('/')),
'./freeagent'
);
const options = {
name: 'freeagent',
targetDirectory: targetDir,
template: 'default'
//templateDirectory:''
};
async function promptForMissingOptions(options) {
const defaultTemplate = 'default';
if (options.skipPrompts) {
return {
...options,
template: options.template || defaultTemplate,
};
}
const questions = [];
if (!options.name) {
questions.push({
type: 'text',
name: 'template',
message: 'Please enter the name of the connector',
default: 'my-connector-1',
});
}
if (!options.git) {
questions.push({
type: 'confirm',
name: 'filepicker',
message: 'Need filepicker capability ?',
default: false,
});
}
const answers = await inquirer.prompt(questions);
return {
...options,
template: options.template || answers.template,
filepicker: options.filepicker || answers.git,
};
}
flags.create &&
(await promptForMissingOptions(options)) &&
(await create(options));
debug && log(flags);
})();