2018-10-01 01:02:10 +02:00
|
|
|
const notifier = require('node-notifier')
|
2019-02-27 15:12:40 +01:00
|
|
|
const relative = require('path').relative
|
|
|
|
|
2019-01-18 22:00:15 +01:00
|
|
|
const babelOpts = {
|
|
|
|
presets: [
|
|
|
|
['@babel/preset-env', {
|
|
|
|
modules: 'commonjs',
|
|
|
|
'targets': {
|
|
|
|
'browsers': ['IE 11']
|
2019-03-30 01:54:05 +01:00
|
|
|
},
|
|
|
|
exclude: ['transform-typeof-symbol']
|
2019-01-18 22:00:15 +01:00
|
|
|
}]
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
['@babel/plugin-transform-runtime', {
|
|
|
|
corejs: 2,
|
|
|
|
helpers: true,
|
2019-04-02 15:42:09 +02:00
|
|
|
regenerator: false,
|
2019-01-18 22:00:15 +01:00
|
|
|
useESModules: false
|
2019-04-02 15:42:09 +02:00
|
|
|
}],
|
|
|
|
['babel-plugin-transform-async-to-promises', {
|
|
|
|
inlineHelpers: true
|
2019-01-18 22:00:15 +01:00
|
|
|
}]
|
|
|
|
]
|
|
|
|
}
|
2018-10-01 01:02:10 +02:00
|
|
|
|
2019-03-24 23:38:03 +01:00
|
|
|
// 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')
|
|
|
|
}
|
|
|
|
|
2019-03-24 14:21:30 +01:00
|
|
|
// 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')
|
|
|
|
}
|
|
|
|
|
2019-02-27 15:22:18 +01:00
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
export async function ncc_unistore (task, opts) {
|
2019-02-27 15:12:40 +01:00
|
|
|
await task
|
|
|
|
.source(opts.src || relative(__dirname, require.resolve('unistore')))
|
|
|
|
.ncc({ packageName: 'unistore' })
|
|
|
|
.target('dist/compiled/unistore')
|
|
|
|
}
|
|
|
|
|
2019-03-19 00:21:18 +01:00
|
|
|
// 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')
|
|
|
|
}
|
|
|
|
|
2019-02-27 15:12:40 +01:00
|
|
|
export async function precompile (task) {
|
2019-03-24 23:38:03 +01:00
|
|
|
await task.parallel(['ncc_unistore', 'ncc_resolve', 'ncc_arg', 'ncc_nanoid', 'ncc_text_table'])
|
2019-02-27 15:12:40 +01:00
|
|
|
}
|
|
|
|
|
2018-10-01 01:02:10 +02:00
|
|
|
export async function compile (task) {
|
2019-02-26 21:57:32 +01:00
|
|
|
await task.parallel(['cli', 'bin', 'server', 'nextbuild', 'nextbuildstatic', 'pages', 'lib', 'client'])
|
2018-10-01 01:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function bin (task, opts) {
|
2019-02-19 22:45:07 +01:00
|
|
|
await task.source(opts.src || 'bin/*').typescript({ module: 'commonjs', stripExtension: true }).target('dist/bin', { mode: '0755' })
|
2018-10-01 01:02:10 +02:00
|
|
|
notify('Compiled binaries')
|
|
|
|
}
|
|
|
|
|
2019-02-26 21:57:32 +01:00
|
|
|
export async function cli (task, opts) {
|
|
|
|
await task.source(opts.src || 'cli/**/*.+(js|ts|tsx)').typescript({ module: 'commonjs' }).target('dist/cli')
|
|
|
|
notify('Compiled cli files')
|
|
|
|
}
|
|
|
|
|
2018-10-01 01:02:10 +02:00
|
|
|
export async function lib (task, opts) {
|
2019-02-19 22:45:07 +01:00
|
|
|
await task.source(opts.src || 'lib/**/*.+(js|ts|tsx)').typescript({ module: 'commonjs' }).target('dist/lib')
|
2018-10-01 01:02:10 +02:00
|
|
|
notify('Compiled lib files')
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function server (task, opts) {
|
2019-02-19 22:45:07 +01:00
|
|
|
await task.source(opts.src || 'server/**/*.+(js|ts|tsx)').typescript({ module: 'commonjs' }).target('dist/server')
|
2018-10-01 01:02:10 +02:00
|
|
|
notify('Compiled server files')
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function nextbuild (task, opts) {
|
2019-02-19 22:45:07 +01:00
|
|
|
await task.source(opts.src || 'build/**/*.+(js|ts|tsx)').typescript({ module: 'commonjs' }).target('dist/build')
|
2018-10-01 01:02:10 +02:00
|
|
|
notify('Compiled build files')
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function client (task, opts) {
|
2019-02-19 22:45:07 +01:00
|
|
|
await task.source(opts.src || 'client/**/*.+(js|ts|tsx)').typescript({ module: 'commonjs' }).babel(babelOpts).target('dist/client')
|
2018-10-01 01:02:10 +02:00
|
|
|
notify('Compiled client files')
|
|
|
|
}
|
|
|
|
|
|
|
|
// export is a reserved keyword for functions
|
|
|
|
export async function nextbuildstatic (task, opts) {
|
2019-02-19 22:45:07 +01:00
|
|
|
await task.source(opts.src || 'export/**/*.+(js|ts|tsx)').typescript({ module: 'commonjs' }).target('dist/export')
|
2018-10-01 01:02:10 +02:00
|
|
|
notify('Compiled export files')
|
|
|
|
}
|
|
|
|
|
2018-10-03 00:08:57 +02:00
|
|
|
export async function pages (task, opts) {
|
2019-02-19 22:45:07 +01:00
|
|
|
await task.source(opts.src || 'pages/**/*.+(js|ts|tsx)').typescript({ module: 'commonjs' }).babel(babelOpts).target('dist/pages')
|
2018-10-01 01:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function build (task) {
|
2019-02-27 15:12:40 +01:00
|
|
|
await task.serial(['precompile', 'compile'])
|
2018-10-01 01:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export default async function (task) {
|
2018-11-30 13:10:30 +01:00
|
|
|
await task.clear('dist')
|
2018-10-01 01:02:10 +02:00
|
|
|
await task.start('build')
|
|
|
|
await task.watch('bin/*', 'bin')
|
2018-12-13 01:00:46 +01:00
|
|
|
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)', 'nextexport')
|
|
|
|
await task.watch('client/**/*.+(js|ts|tsx)', 'client')
|
|
|
|
await task.watch('lib/**/*.+(js|ts|tsx)', 'lib')
|
2019-03-27 16:51:05 +01:00
|
|
|
await task.watch('cli/**/*.+(js|ts|tsx)', 'cli')
|
2018-10-01 01:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function release (task) {
|
|
|
|
await task.clear('dist').start('build')
|
|
|
|
}
|
|
|
|
|
|
|
|
// notification helper
|
|
|
|
function notify (msg) {
|
|
|
|
return notifier.notify({
|
|
|
|
title: '▲ Next',
|
|
|
|
message: msg,
|
|
|
|
icon: false
|
|
|
|
})
|
|
|
|
}
|