-
Notifications
You must be signed in to change notification settings - Fork 0
/
slushfile.js
155 lines (149 loc) · 3.58 KB
/
slushfile.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
var gulp = require('gulp')
var install = require('gulp-install')
var conflict = require('gulp-conflict')
var rename = require('gulp-rename')
var template = require('gulp-template')
var inquirer = require('inquirer')
var xdcConfig = require('xdc-config')
gulp.task('default', function (done) {
inquirer.prompt([
{
type: 'input',
name: 'name',
message: 'Give your app a name',
default: getNameProposal()
},
{
type: 'input',
name: 'description',
message: 'Give your app a description',
default: 'A vue project.'
},
{
type: 'confirm',
name: 'private',
message: 'Private?',
default: true
},
{
type: 'list',
name: 'vueVersion',
message: 'Which Vue version do you want?',
default: 2,
choices: [
{name: 'Vue 2', value: 2},
{name: 'Vue 1', value: ''}
]
},
{
type: 'list',
name: 'js',
message: 'Which ES2015+ compiler do you want to use?',
default: '',
choices: [
{name: 'bable (preset-es2015, preset-stage-0, perset-stage-2, plugin-transform-runtime)', value: ''},
{name: 'bublé (only use wepback 2)', value: 'buble'}
]
},
{
type: 'list',
name: 'xdc',
message: 'How do you want to use xdc?',
default: '',
choices: [
{name: 'Global xdc (webpack 2)', value: ''},
{name: 'Local xdc (and use webpack 1)', value: '1'},
{name: 'Local xdc (and use webpack 2)', value: 'beta'}
]
},
{
type: 'confirm',
name: 'devServer',
message: 'Need dev server?',
default: true
},
{
type: 'list',
name: 'csstype',
message: 'Which CSS preprocessor do you want to use?',
default: '',
choices: [
{name: 'Only CSS', value: ''},
{name: 'Salad', value: 'saladcss'},
{name: 'Sass', value: 'sass'}
]
},
{
type: 'confirm',
name: 'unit',
message: 'Setup unit tests with Karma + Mocha?',
default: true
},
{
type: 'input',
name: 'github',
message: 'git repository',
default: xdcConfig.github
},
{
type: 'input',
name: 'author',
message: 'author',
default: xdcConfig.author
},
{
type: 'input',
name: 'license',
message: 'license',
default: 'ISC'
},
{
type: 'confirm',
name: 'moveon',
message: 'Continue?'
}
],
function (answers) {
if (answers.github) {
answers.github = answers.github.replace(/\/$/, '') + '/' + answers.name
}
if (!answers.moveon) {
return done()
}
var filesPath = [__dirname + '/template/**']
if (!answers.unit) {
filesPath = filesPath.concat([
'!' + __dirname + '/template/karma.conf.js',
'!' + __dirname + '/template/test',
'!' + __dirname + '/template/test/**'
])
}
if (answers.js) {
filesPath = filesPath.concat([
'!' + __dirname + '/template/_babelrc'
])
}
gulp.src(filesPath, { dot: true })
.pipe(template(answers))
.pipe(rename(function (file) {
if (file.basename[0] === '_') {
file.basename = '.' + file.basename.slice(1)
}
}))
.pipe(conflict('./'))
.pipe(gulp.dest('./'))
.pipe(install())
.on('end', function () {
done()
})
.resume()
})
})
function getNameProposal () {
var path = require('path')
try {
return require(path.join(process.cwd(), 'package.json')).name
} catch (e) {
return path.basename(process.cwd())
}
}