UNPKG

newkit-cli

Version:

Newkit cli tools.

31 lines (28 loc) 1.08 kB
const fs = require('fs'); const child_process = require('child_process'); const util = require('./../lib/util'); const config = require('./config'); module.exports = () => { let cwd = process.cwd(); if (fs.readdirSync(cwd).length !== 0) { return util.error('Current folder is not empty.'); } config.getConfig('') .then(conf => { if (!conf.latestVersion) { return util.error('No published versions.'); } util.info('Get latest version succeed. Downloading...'); let packagePath = `${conf.newkit2PackageAddress}/${conf.latestVersion}.zip`; util.downloadFile(packagePath) .then((downloadFolder) => { util.info('Downloading zip package succeed. Unzip...'); util.unzip(downloadFolder, cwd) .then(folderPath => { util.info(`Init successfully. Current vesion ${conf.latestVersion}`); util.info(`Try to install dependencies...`); exec('npm i --registry http://10.16.75.27:7001/'); }).catch(util.error); }).catch(util.error); }); };