UNPKG

custom-app

Version:

ITIMS��Ʒ�鿪��ר��React���,�Dz��ý��ּ�dhcc-app���������

338 lines (312 loc) 12.1 kB
let exec = require('child_process').exec; let spinner = require('../util/spinner'); let chalk = require('chalk') let execList = []; let uninstallNRM = function (op) { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('nrm uninstall start')) var install_webpack = 'npm uninstall nrm -g'; exec(install_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('nrm 初始化失败:' + stderr)); console.log(stdout); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('nrm uninstall complete')) spinner.logWithSpinner(' '); resolve(); } }); }) } execList.push(uninstallNRM); let initNRM = function (op) { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('nrm init start')) var install_webpack = 'npm install nrm -g'; exec(install_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('nrm 初始化失败:' + stderr)); console.log(stdout); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('nrm init complete')) spinner.logWithSpinner(' '); resolve(); } }); }) } execList.push(initNRM); let addDHCCRegistry = function () { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('nrm dhcc init start')) var install_webpack = 'nrm add dhcc http://172.24.24.236:8081/repository/npmGroup24.236/'; exec(install_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('nrm dhcc 初始化失败:' + stderr)); console.log(stdout); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('nrm dhcc init complete')) spinner.logWithSpinner(' '); resolve(); } }); }) } //execList.push(addDHCCRegistry); let addDHCCHostRegistry = function () { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('nrm dhcchost init start')) var install_webpack = 'nrm add dhcchost http://172.24.24.236:8081/repository/host236/'; exec(install_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('nrm dhcchost 初始化失败:' + stderr)); console.log(stdout); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('nrm dhcchost init complete')) spinner.logWithSpinner(' '); resolve(); } }); }) } //execList.push(addDHCCHostRegistry); let useDHCCRegistry = function () { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('nrm use dhcc start')) var install_webpack = 'nrm use dhcc'; exec(install_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('nrm use dhcc失败:' + stderr)); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('nrm use dhcc complete')) spinner.logWithSpinner(' '); resolve(); } }); }) } //execList.push(useDHCCRegistry); //安装webpack webpack-cli let uninstallWebpack = function () { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('webpack webpack-cli webpack-dev-server uninstall')) var install_webpack = 'npm uninstall webpack webpack-cli webpack-dev-server -g'; exec(install_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('webpack 删除安装失败:' + stderr)); console.log(stdout); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('webpack webpack-cli uninstall complete')) spinner.logWithSpinner(' ', ' '); resolve(); } }); }) } //execList.push(uninstallWebpack); //安装webpack webpack-cli let installWebpack = function () { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('webpack webpack-cli webpack-dev-server installing')) var install_webpack = 'npm i webpack webpack-cli webpack-dev-server -g'; exec(install_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('webpack 安装失败:' + stderr)); console.log(stdout); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('webpack webpack-cli installed complete')) spinner.logWithSpinner(' ', ' '); resolve(); } }); }) } //execList.push(installWebpack); // //安装react react-dom // let uninstallReact = function () { // return new Promise(function (resolve, reject) { // spinner.logWithSpinner('', chalk.cyan('react react-dom redux react-redux react-router react-router-dom react-lazyload prop-types uninstall')) // var react_webpack = 'npm uninstall react react-dom redux react-redux redux-thunk react-router react-router-dom react-lazyload prop-types -S'; // exec(react_webpack, function (err, stdout, stderr) { // if (err) { // console.error(chalk.red('react 删除安装失败:' + stderr)); // console.log(stdout); // spinner.stopSpinner(); // } else { // spinner.logWithSpinner('', stdout) // spinner.logWithSpinner(chalk.cyan('react react-dom uninstall complete \n')) // spinner.logWithSpinner(' ', ' '); // resolve(); // } // }); // }) // } // execList.push(uninstallReact); // //安装react react-dom // let installReact = function () { // return new Promise(function (resolve, reject) { // spinner.logWithSpinner('', chalk.cyan('react react-dom redux react-redux react-router react-router-dom react-lazyload prop-types installing')) // var react_webpack = 'npm i react react-dom redux react-redux redux-thunk react-router react-router-dom react-lazyload prop-types -S'; // exec(react_webpack, function (err, stdout, stderr) { // if (err) { // console.error(chalk.red('react 安装失败:' + stderr)); // console.log(stdout); // spinner.stopSpinner(); // } else { // spinner.logWithSpinner('', stdout) // spinner.logWithSpinner(chalk.cyan('react react-dom installed complete \n')) // spinner.logWithSpinner(' ', ' '); // resolve(); // } // }); // }) // } // execList.push(installReact); // //安装semantic-ui-react semantic-ui-css react的UI框架 // let uninstallSemantic = function () { // return new Promise(function (resolve, reject) { // spinner.logWithSpinner('', chalk.cyan('semantic-ui-react semantic-ui-css uninstall')) // var semantic_webpack = 'npm uninstall semantic-ui-react semantic-ui-css -g'; // exec(semantic_webpack, function (err, stdout, stderr) { // if (err) { // console.error(chalk.red('semantic-ui-react semantic-ui-css 安装失败:' + stderr)) // console.log(stdout); // spinner.stopSpinner(); // } else { // spinner.logWithSpinner('', stdout) // spinner.logWithSpinner(chalk.cyan('semantic-ui-react semantic-ui-css uninstall complete \n')) // spinner.logWithSpinner(' ', ' '); // resolve(); // } // }); // }) // } // execList.push(uninstallSemantic); // //安装semantic-ui-react semantic-ui-css react的UI框架 // let installSemantic = function () { // return new Promise(function (resolve, reject) { // spinner.logWithSpinner('', chalk.cyan('semantic-ui-react semantic-ui-css installing')) // var semantic_webpack = 'npm i semantic-ui-react semantic-ui-css -g'; // exec(semantic_webpack, function (err, stdout, stderr) { // if (err) { // console.error(chalk.red('semantic-ui-react semantic-ui-css 安装失败:' + stderr)) // console.log(stdout); // spinner.stopSpinner(); // } else { // spinner.logWithSpinner('', stdout) // spinner.logWithSpinner(chalk.cyan('semantic-ui-react semantic-ui-css installed complete \n')) // spinner.logWithSpinner(' ', ' '); // resolve(); // } // }); // }) // } // execList.push(installSemantic); // //安装antd react的UI框架 // let uninstallAntd = function () { // return new Promise(function (resolve, reject) { // spinner.logWithSpinner('', chalk.cyan('antd uninstall')) // var semantic_webpack = 'npm uninstall antd -g'; // exec(semantic_webpack, function (err, stdout, stderr) { // if (err) { // console.error(chalk.red('antd 安装失败:' + stderr)) // console.log(stdout); // spinner.stopSpinner(); // } else { // spinner.logWithSpinner('', stdout) // spinner.logWithSpinner(chalk.cyan('antd uninstall complete \n')) // spinner.logWithSpinner(' ', ' '); // resolve(); // } // }); // }) // } // execList.push(uninstallAntd); // //安装antd react的UI框架 // let installAntd = function () { // return new Promise(function (resolve, reject) { // spinner.logWithSpinner('', chalk.cyan('antd installing')) // var semantic_webpack = 'npm i antd -g'; // exec(semantic_webpack, function (err, stdout, stderr) { // if (err) { // console.error(chalk.red('antd 安装失败:' + stderr)) // console.log(stdout); // spinner.stopSpinner(); // } else { // spinner.logWithSpinner('', stdout) // spinner.logWithSpinner(chalk.cyan('antd installed complete \n')) // spinner.logWithSpinner(' ', ' '); // resolve(); // } // }); // }) // } // execList.push(installAntd); //安装itims4-2ndpage 二级页面模板插件 let uninstall2ndpage = function () { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('itims4-2ndpage uninstall')) var semantic_webpack = 'npm uninstall itims4-2ndpage -g'; exec(semantic_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('itims4-2ndpage 安装失败:' + stderr)) console.log(stdout); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('itims4-2ndpage uninstall complete \n')) spinner.logWithSpinner(' ', ' '); resolve(); } }); }) } execList.push(uninstall2ndpage); //安装itims4-2ndpage 二级页面模板插件 let install2ndpage = function () { return new Promise(function (resolve, reject) { spinner.logWithSpinner('', chalk.cyan('itims4-2ndpage installing')) var semantic_webpack = 'npm i itims4-2ndpage -g'; exec(semantic_webpack, function (err, stdout, stderr) { if (err) { console.error(chalk.red('itims4-2ndpage 安装失败:' + stderr)) console.log(stdout); spinner.stopSpinner(); } else { spinner.logWithSpinner('', stdout) spinner.logWithSpinner(chalk.cyan('itims4-2ndpage installed complete \n')) spinner.logWithSpinner(' ', ' '); resolve(); } }); }) } execList.push(install2ndpage); async function queue (arr) { let res = null for (let promise of arr) { res = await promise(res) } return await res } module.exports = function () { queue(execList) .then(data => { spinner.logWithSpinner(chalk.green('打完收工 \n')) spinner.stopSpinner(); }) }