-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnofile.js
118 lines (101 loc) · 3.44 KB
/
nofile.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
const kit = require('nokit')
module.exports = (task, option) => {
option('-p, --platform <darwin | windows>', 'package for platform')
task('default', ['dev'], 'default task', () => {
kit.log('\n>>>>>>> start >>>>>>>\n')
})
task('tsc-w', 'watch typescript', (opt) => {
const args = [
'./src/index.tsx',
'-w',
'--lib',
'es2015,dom',
'--jsx',
'react',
'--experimentalDecorators',
'true'
]
kit.spawn('./node_modules/typescript/bin/tsc', args, {
prefix: 'TSC | :blue'
})
})
task('check-dev', kit.async(function * () {
let ret = yield kit.exec('git rev-parse --abbrev-ref HEAD')
if (ret.stdout === 'master\n') {
throw new Error(kit.log('git should be on dev branch'))
process.exit()
}
}))
task('tsc-p', 'typescript compile', kit.async(function * (opt) {
const args = [
'-p',
'./tsconfig.json'
]
yield kit.spawn('./node_modules/.bin/tsc', args, {
prefix: 'TSC | :blue'
})
}))
task('lint', 'lint whole project', function (opts) {
let conf = [
'--force',
'-t', 'stylish',
'-c', 'tslint.json',
'src/**/*.ts',
'*.ts'
]
if (opts.fix)
conf.unshift('--fix')
return kit.spawn('tslint', conf)
})
task('template-dev', 'render-template-dev', kit.async(function * () {
yield kit.exec('node ./config/template.js development')
}))
task('template-prod', 'render-template-prod', kit.async(function * () {
yield kit.exec('node ./config/template.js production')
}))
task('dev', ['check-dev', 'tsc-w', 'template-dev', 'electron'], 'run in development', (opt) => {
kit.spawn('./node_modules/.bin/webpack-dev-server', [
'--progress',
'--hot',
'--info',
'false',
'--config',
'./config/dev.config.js'
], {
prefix: 'WEB | :green'
})
})
task('electron', 'open electron in dev model', () => {
kit.spawn('./node_modules/.bin/electron', ['.', 'development'], {prefix: 'Electron | :blue'})
})
task('build', ['lint', 'tsc-p', 'template-prod'], 'build app to dist', kit.async(function * (opt) {
const config = opt.config || 'prod'
kit.log(`\n>>>>>>>> build >>>>>>>>>>>\n`)
yield kit.spawn('./node_modules/webpack/bin/webpack.js', [
'--progress',
'--config',
'./config/prod.config.js'
], {
prefix: 'BUILD | :black'
})
}))
task('production', ['build'], 'run in production', kit.async(function * () {
kit.log(`\n>>>>>>>> start electron >>>>>>>>>>>\n`)
yield kit.spawn('./node_modules/.bin/electron', ['.', 'production'], {prefix: 'Electron | :blue'})
}))
task('package', ['build'], 'package to macos app', kit.async(function * (opt) {
const platform = opt.platform || 'darwin'
kit.log(`\n>>>>>>>> package >>>>>>>>>>>\n`)
yield kit.spawn('./node_modules/.bin/electron-packager', [
'.',
'NiRethink',
'--platform',
platform,
'--out',
'./build',
'--icon',
'./src/assets/nirethink.icns',
'--overwrite'
])
}))
}