w-cli spins up new WordBox instances. Check out https://github.com/codefeathers/WordBox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

34 lines
1.1 KiB

'use strict';
const fs = require('fs');
const normalize = require('path').normalize;
const axios = require('axios');
const extract = require('../utils/extract');
const npminstall = require('../utils/npminstall');
const newapp = (appname, options) => {
console.log(`Spinning up a new WordBox app at ${appname}...`);
const tmp = normalize(process.cwd() + '/wordbox.zip');
console.log(`Downloading wordbox.zip`);
axios({
method: 'get',
url: 'https://github.com/codefeathers/WordBox/archive/master.zip',
responseType: 'stream'
})
.then(responseStream => new Promise((resolve, reject) => {
responseStream.data.once('error', reject);
let fileStream = fs.createWriteStream(tmp);
fileStream.once('error', reject);
fileStream.once('finish', resolve);
return responseStream.data.pipe(fileStream);
}))
.then(() => extract(tmp, normalize(process.cwd() + '/' + appname)))
.then(() => fs.unlink(tmp, (err) => { if(err) throw new Error(err) }))
.then(() => npminstall(appname))
.catch((err) => { if(err) throw new Error(err) });
};
module.exports.newapp = newapp;