-
Notifications
You must be signed in to change notification settings - Fork 0
/
terms.js
69 lines (62 loc) · 1.61 KB
/
terms.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
const inquirer = require('inquirer');
const path = require('path');
const getPackageInfo = async () => {
const info = require(path.join(process.cwd(), 'package.json'));
return info;
}
const _INFO_DEFAULTS = {
name: 'PreactSPA',
author: 'Your Name <email> (web.page)',
version: '0.0.1',
license: 'GPL'
}
const askExecutionParams = async () => {
return inquirer
.prompt([
{
name: 'source',
message: 'Where is the build output of the App?',
default: 'build',
},
{
name: 'target',
message: 'Where to store the theme?',
default: 'wp-theme',
},
]);
}
const fulfillQuestions = async ({name, author, license, version}=_INFO_DEFAULTS) => {
return inquirer
.prompt([
{
name: 'name',
message: 'Name of the WP-Theme?',
default: name,
},
{
name: 'author',
message: 'Author?',
default: author,
},
{
name: 'version',
message: 'Version?',
default: version,
},
{
name: 'license',
message: 'License?',
default: license,
},
]);
}
const relativeToCWD = ({source, target}) => ({
source: path.join(process.cwd(), source),
target: path.join(process.cwd(), target),
})
const retrieveTerms = async () => {
const {source, target} = await askExecutionParams().then(relativeToCWD);
const information = await fulfillQuestions(getPackageInfo());
return {source, target, information};
}
module.exports = retrieveTerms;