-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsao.js
103 lines (100 loc) · 2.58 KB
/
sao.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
const { join } = require('path')
const superb = require('superb')
const glob = require('glob')
const rootDir = __dirname
const move = (from, to = '') => {
const result = {}
const options = { cwd: join(rootDir, 'template', from), nodir: true, dot: true }
for (const file of glob.sync(`**`, options)) {
result[join(from, file)] = join(to, file)
}
return result
}
module.exports = {
prompts: {
name: {
message: 'What is the name of the new project?',
default: ':folderName:'
},
description: {
message: 'How would you describe the new project?',
default: `my ${superb()} project`
},
distribute: {
message: 'Do you want to distribute the app using electron-builder',
default: true,
type: 'confirm',
store: true
},
bundler: {
message: 'Do you want to use a bundler',
default: false,
choices: [
{
name: 'No, move on',
value: false
},
{
name: 'Poi',
value: 'poi'
},
{
name: 'Parcel',
value: 'parcel'
}
],
type: 'list',
store: true
},
isLoadURL: {
message: 'Use this app to load a URL instead of local file',
default: false,
type: 'confirm',
when: answers => answers.bundler === false
},
loadURL: {
message: 'Enter the URL',
required: true,
when: answers => answers.isLoadURL
},
username: {
message: 'What is your GitHub username?',
default: ':gitUser:',
store: true
},
email: {
message: 'What is your GitHub email?',
default: ':gitEmail:',
store: true
},
website: {
message: 'The URL of your website?',
default({ username }) {
return `github.com/${username}`
},
store: true
}
},
move({ bundler }) {
const src = bundler === 'poi' ? 'src-poi' : 'src-parcel'
return Object.assign({
gitignore: '.gitignore'
}, move(src, 'src'))
},
filters: {
'app/renderer/**': '!isLoadURL && bundler === false',
'poi.config.js': 'bundler === "poi"',
'src-parcel/**': 'bundler === "parcel"',
'src-poi/**': 'bundler === "poi"'
},
async post({ gitInit, yarnInstall, log, chalk, pm, isNewFolder, folderName }) {
gitInit()
yarnInstall()
if (isNewFolder) {
log.info(`To get started: ${chalk.cyan('cd')} ${folderName}`)
}
log.info(`To develop the app: ${chalk.cyan(pm)} run dev`)
log.info(`To build for production: ${chalk.cyan(pm)} run build`)
log.info(`To distribute: ${chalk.cyan(pm)} run dist`)
}
}