-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmeta.js
203 lines (189 loc) · 4.93 KB
/
meta.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
let asciiBolide = '' +
' _ _________ __ (_) __ \n' +
' _ _ ____ __ )______ ___/ /___ _ ______/ /_____ \n' +
'_ _ _ ___/ __ |_ __ \\__/ / __/ / _/ __ / _/ _ \\ \n' +
' _ _ __/ /_/ /_/ /_/ /_/ / _/ / / /_/ / / __/\n' +
' _ _/_____/ \\____/ /_/ /_/ \\____/ \\___/\n\n' +
'= = = =======================================(*)> \n'
let counter = 0
let spinner = [
"▒ ▌",
"▒☼ ▌",
"▒=☼ ▌",
"▒==☼ ▌",
"▒===☼ ▌",
"▒====☼ ▌",
"▒ ====☼ ▌",
"▒ ====☼ ▌",
"▒ ====☼ ▌",
"▒ ====☼ ▌",
"▒ ====☼ ▌",
"▒ ====☼ ▌",
"▒ ====☼ ▌",
"▒ ===✸▌",
"▒ ==✹▌",
"▒ =✺▌",
"▒ ✺▌",
]
let css_frameworks = [
'• Vuetify',
'• Buefy',
'• Element-UI',
'• Bootstrap-Vue',
'• AT-UI',
'• MUSE-UI',
'• install manually later..'
]
let css_frameworks_commands = [
` && yarn add vuetify`,
` && yarn add buefy`,
` && yarn add element-ui`,
` && yarn add bootstrap-vue [email protected]`,
` && yarn add at-ui at-ui-style`,
` && yarn add muse-ui`
]
module.exports = {
helpers: {
raw: function(options) {
return options.fn(this)
},
switch: function (value, options) {
this._switch_value_ = value;
this._switch_break_ = false;
var html = options.fn(this);
delete this._switch_break_;
delete this._switch_value_;
return html;
},
case: function (value, options) {
var args = Array.prototype.slice.call(arguments);
var options = args.pop();
var caseValues = args;
if (this._switch_break_ || caseValues.indexOf(this._switch_value_) === -1) {
return '';
} else {
if (options.hash.break === true) {
this._switch_break_ = true;
}
return options.fn(this);
}
},
default: function (options) {
if (!this._switch_break_) {
return options.fn(this);
}
}
},
prompts: {
name: {
'type': 'string',
'required': true,
'message': 'Project slug name'
},
author: {
'type': 'string',
'message': 'Author'
},
port: {
'type': 'number',
'required': false,
'message': 'In which port will it run?',
'default': 8080
},
seo: {
'type': 'confirm',
'message': 'Would you like to configure a basic SEO?',
'default': true
},
title: {
'when': 'seo',
'type': 'string',
'required': false,
'message': 'SEO: Default page title',
'default': 'Bolide Nuxt.js!'
},
description: {
'when': 'seo',
'type': 'string',
'required': false,
'message': 'SEO: Default page description',
'default': 'This is a bolide-template project.'
},
fb_app_id: {
'when': 'seo',
'type': 'string',
'required': false,
'message': 'SEO: Insert a fb:app_id',
'default': 'none'
},
css_framework: {
'type': 'list',
'required': false,
'message': 'Select a CSS framework:',
'choices': css_frameworks,
'required': true,
'default': css_frameworks[css_frameworks.length - 1]
},
spa: {
'type': 'confirm',
'required': false,
'message': 'Will it be a SPA?',
'default': false
},
autoSetup: {
'type': 'confirm',
'required': false,
'message': 'Auto install packages?',
'default': true
}
},
complete (data, {logger, chalk}) {
const exec = require('child_process').exec
var title = data.autoSetup ? '[*** Now executing: ***]' : '[*** Next steps: ***]'
var command = data.inPlace ? `npm run setup` : `cd ${data.destDirName} && npm run setup`
for (let i = 0; i < css_frameworks.length; i++) {
if (css_frameworks[i] === data.css_framework) {
command = command + css_frameworks_commands[i]
}
}
console.log('\n')
console.log('\x1b[92m' + asciiBolide)
console.log('\x1b[39m')
if (data.inPlace) {
data.autoSetup ?
console.log(title + `\n\n - npm run setup`)
: console.log(title + `\n\n - npm run setup\n - npm run dev`)
} else {
data.autoSetup ?
console.log(title + `\n\n - cd ${data.destDirName}\n - npm run setup`)
: console.log(title + `\n\n - cd ${data.destDirName}\n - npm run setup\n - npm run dev`)
}
if (data.autoSetup) {
console.log('\n')
console.log('Installing dependencies..')
console.log('\n')
var animation = setInterval(a => {
if (counter >= spinner.length) counter = 0
process.stdout.clearLine()
process.stdout.cursorTo(0)
process.stdout.write('\x1b[92m' + spinner[counter]);
counter++
}, 150)
exec(command, (error, stdout, stderr) => {
if (error) {
// console.error(`exec error: ${error}`)
return
}
// if (stdout) { console.log('\x1b[39m'); console.log(`stdout: ${stdout}`) }
// if (stderr) { console.log('\x1b[39m'); console.log(`stderr: ${stderr}`) }
}).on('exit', function() {
console.log('\n')
console.log('Done.')
process.stdout.clearLine()
process.stdout.clearLine()
clearInterval(animation)
console.log('\x1b[39m')
})
}
}
}