-
Notifications
You must be signed in to change notification settings - Fork 26.2k
/
taskfile.js
212 lines (186 loc) · 5.44 KB
/
taskfile.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
204
205
206
207
208
209
210
211
212
const notifier = require('node-notifier')
const relative = require('path').relative
// eslint-disable-next-line camelcase
export async function ncc_arg(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('arg')))
.ncc({ packageName: 'arg' })
.target('dist/compiled/arg')
}
// eslint-disable-next-line camelcase
export async function ncc_resolve(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('resolve')))
.ncc({ packageName: 'resolve' })
.target('dist/compiled/resolve')
}
// eslint-disable-next-line camelcase
export async function ncc_nanoid(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('nanoid')))
.ncc({ packageName: 'nanoid' })
.target('dist/compiled/nanoid')
}
// eslint-disable-next-line camelcase
export async function ncc_unistore(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('unistore')))
.ncc({ packageName: 'unistore' })
.target('dist/compiled/unistore')
}
// eslint-disable-next-line camelcase
export async function ncc_text_table(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('text-table')))
.ncc({ packageName: 'text-table' })
.target('dist/compiled/text-table')
}
export async function precompile(task) {
await task.parallel([
'ncc_unistore',
'ncc_resolve',
'ncc_arg',
'ncc_nanoid',
'ncc_text_table',
])
}
export async function compile(task) {
await task.parallel([
'cli',
'bin',
'server',
'nextbuild',
'nextbuildstatic',
'pages',
'lib',
'client',
'telemetry',
'nextserverserver',
'nextserverlib',
])
}
export async function bin(task, opts) {
await task
.source(opts.src || 'bin/*')
.babel('server', { stripExtension: true })
.target('dist/bin', { mode: '0755' })
notify('Compiled binaries')
}
export async function cli(task, opts) {
await task
.source(opts.src || 'cli/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/cli')
notify('Compiled cli files')
}
export async function lib(task, opts) {
await task
.source(opts.src || 'lib/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/lib')
notify('Compiled lib files')
}
export async function server(task, opts) {
await task
.source(opts.src || 'server/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/server')
notify('Compiled server files')
}
export async function nextbuild(task, opts) {
await task
.source(opts.src || 'build/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/build')
notify('Compiled build files')
}
export async function client(task, opts) {
await task
.source(opts.src || 'client/**/*.+(js|ts|tsx)')
.babel('client')
.target('dist/client')
notify('Compiled client files')
}
// export is a reserved keyword for functions
export async function nextbuildstatic(task, opts) {
await task
.source(opts.src || 'export/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/export')
notify('Compiled export files')
}
export async function pages_app(task) {
await task
.source('pages/_app.tsx')
.babel('client')
.target('dist/pages')
}
export async function pages_error(task) {
await task
.source('pages/_error.tsx')
.babel('client')
.target('dist/pages')
}
export async function pages_document(task) {
await task
.source('pages/_document.tsx')
.babel('server')
.target('dist/pages')
}
export async function pages(task, opts) {
await task.parallel(['pages_app', 'pages_error', 'pages_document'])
}
export async function telemetry(task, opts) {
await task
.source(opts.src || 'telemetry/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/telemetry')
notify('Compiled telemetry files')
}
export async function build(task) {
await task.serial(['precompile', 'compile'])
}
export default async function(task) {
await task.clear('dist')
await task.start('build')
await task.watch('bin/*', 'bin')
await task.watch('pages/**/*.+(js|ts|tsx)', 'pages')
await task.watch('server/**/*.+(js|ts|tsx)', 'server')
await task.watch('build/**/*.+(js|ts|tsx)', 'nextbuild')
await task.watch('export/**/*.+(js|ts|tsx)', 'nextbuildstatic')
await task.watch('client/**/*.+(js|ts|tsx)', 'client')
await task.watch('lib/**/*.+(js|ts|tsx)', 'lib')
await task.watch('cli/**/*.+(js|ts|tsx)', 'cli')
await task.watch('telemetry/**/*.+(js|ts|tsx)', 'telemetry')
await task.watch('next-server/server/**/*.+(js|ts|tsx)', 'nextserverserver')
await task.watch('next-server/lib/**/*.+(js|ts|tsx)', 'nextserverlib')
}
export async function nextserverlib(task, opts) {
await task
.source(opts.src || 'next-server/lib/**/*.+(js|ts|tsx)')
.typescript({ module: 'commonjs' })
.target('dist/next-server/lib')
notify('Compiled lib files')
}
export async function nextserverserver(task, opts) {
await task
.source(opts.src || 'next-server/server/**/*.+(js|ts|tsx)')
.typescript({ module: 'commonjs' })
.target('dist/next-server/server')
notify('Compiled server files')
}
export async function nextserverbuild(task) {
await task.parallel(['nextserverserver', 'nextserverlib'])
}
export async function release(task) {
await task.clear('dist').start('build')
await task.clear('dist/next-server').start('nextserverbuild')
}
// notification helper
function notify(msg) {
return notifier.notify({
title: '▲ Next',
message: msg,
icon: false,
})
}