2020-03-05 08:25:00 +03:00
|
|
|
#!/usr/bin/env node
|
|
|
|
let cmd = require('./build/lib/cmd')
|
|
|
|
let fss = require('fs')
|
|
|
|
let fs = require('fs').promises
|
|
|
|
|
|
|
|
let args = process.argv.slice(2)
|
|
|
|
|
|
|
|
let no_validation = '--no-validation'
|
|
|
|
async function init () {
|
|
|
|
if(!args.includes(no_validation)) {
|
2020-03-06 18:50:17 +03:00
|
|
|
await cmd.check_version('npm','6.13.4',{silent:true})
|
2020-03-05 08:25:00 +03:00
|
|
|
await cmd.check_version('node','v12.16.1',{silent:true})
|
|
|
|
await cmd.check_version('rustc','1.40.0-nightly',{preprocess:(v)=>v.substring(6,20),silent:true})
|
|
|
|
}
|
|
|
|
|
2020-03-05 22:00:47 +03:00
|
|
|
let initialized = fss.existsSync('target/.initialized')
|
2020-03-05 08:25:00 +03:00
|
|
|
if (!initialized) {
|
|
|
|
cmd.section('Initialization')
|
|
|
|
console.log('Installing build script dependencies.')
|
|
|
|
await cmd.with_cwd('build', async () => {
|
|
|
|
await cmd.run('npm',['install'])
|
|
|
|
})
|
|
|
|
|
|
|
|
if(args[0] == 'clean') {
|
2020-03-05 22:00:47 +03:00
|
|
|
try { await fs.unlink('target/.initialized') } catch {}
|
2020-03-05 08:25:00 +03:00
|
|
|
} else {
|
|
|
|
console.log('Installing application dependencies')
|
|
|
|
await cmd.with_cwd('app', async () => {
|
|
|
|
await cmd.run('npm',['run','install'])
|
|
|
|
})
|
2020-03-05 22:00:47 +03:00
|
|
|
await fs.mkdir('target', {recursive:true})
|
|
|
|
await fs.open('target/.initialized','w')
|
2020-03-05 08:25:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
await init()
|
|
|
|
cmd.run('node',['./build/run'].concat(args))
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|