Commit 280e6cf9 authored by wildfirecode's avatar wildfirecode

add build.js

parent 658d5005
module.exports = {
devPort: 8080
}
// const path = require('path');
// module.exports = {
// context: __dirname,
// src: [path.resolve(__dirname, 'src'),path.resolve(__dirname, 'unit')],
// backup: path.resolve(__dirname, 'backup'),
// skins: path.resolve(__dirname, 'src/skins'),
// mock: path.resolve(__dirname, 'mock'),
// templates: path.resolve(__dirname, 'src/templates'),
// alias: {
// src: path.resolve(__dirname, 'src'),
// '@src': path.resolve(__dirname, 'src'),
// '@unit': path.resolve(__dirname, 'unit'),
// '@skins': path.resolve(__dirname, 'src/skins'),
// '@common': path.resolve(__dirname, 'src/common'),
// react: 'preact-compat',
// 'react-dom': 'preact-compat'
// },
// customEntry: ['index', 'components'], // 自定义入口 每个皮肤的entry
// publicEntry: {
// // 皮肤入口以外的常驻入口 js会按顺序加载执行
// 'common/base': '@src/common/base/base.js',
// 'common/common': '@src/common/base/common.js',
// entry: '@src/entry.js'
// },
// entryHtmlPath: path.resolve(__dirname, 'src/entry.html'),
// remUnit: 234.375, // 640算法: 234.375 750算法: 100
// urlLimit: 1024 * 3, // url-loader 图片转base64
// devPort: 6868,
// ossPath: '/h5/activity_custom/', // oss 文件夹路径
// domain_production: '//yun.duiba.com.cn',
// domain_development: '//yun.dui88.com',
// tinify: true, // 是否需要图片压缩
// autoUpload: true, // 是否需要自动上传cdn
// tinifyKey: 'A0Wm6WCH62JcnL28CjEletF5uFqaFXYN',
// tinify: true, // 是否需要图片压缩
// autoUpload: true, // 是否需要自动上传cdn
// imageExts: ['jpg', 'jpeg', 'png'], // tinypng要压缩的图片类型
// uploadExts: ['js', 'map', 'css', 'png', 'jpg'],
// useApiProxy: false,
// proxyTarget:
// 'http://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=3&uri='
// };
\ No newline at end of file
registry = http://npm.dui88.com/
\ No newline at end of file
let argvs = JSON.parse(process.env.npm_config_argv);
let remain = argvs.remain;
let cmd = process.argv[2];
const DBGBuild = require('duiba-game-build');
const config = require('./.buildrc');
let build = new DBGBuild(config);
if (cmd === 'build' && process.argv[3] === 'prod') {
// if (cmd === 'build' && remain[1] === 'prod') {
cmd = 'buildProd';
if (process.argv[4] === 'ts')
cmd = 'buildProdTS';
if (process.argv[4] === 'exml')
cmd = 'buildProdEXML';
}
build[cmd](...remain);
\ No newline at end of file
let inquirer = require('inquirer');
const spawn = require('cross-spawn');
const questions = require('./question');
let moment = require('moment');
const today = moment().format('YYYYMMDD');
inquirer.prompt(questions).then(answers => {
let cmdType = answers.commandType || '';
let skinName = answers.skinName || '';
let branchName = answers.branchName || '';
let cmd = '';
switch (cmdType) {
case 'create':
cmd = `npm run copy ${skinName}`;
break;
case 'create_react':
cmd = `npm run copy ${skinName} custom-react`;
break;
case 'prettier':
cmd = 'npm run lint';
break;
case 'develop':
cmd = `npm run dev ${skinName}`;
break;
case 'build_test':
cmd = `npm run build ${skinName}`;
break;
case 'build_prod':
cmd = `npm run build ${skinName} prod`;
break;
case 'backup':
cmd = `npm run backup`;
break;
case 'create_branch':
cmd = `git checkout -b feature/${today}-${branchName}`;
break;
default:
break;
}
if (cmd) {
cmd = cmd.split(' ');
let _cmd = cmd[0];
let _args = cmd.slice(1);
var ls = spawn(_cmd, _args);
ls.stdout.on('data', data => {
console.log(`${data}`);
});
ls.stderr.on('data', data => {
console.log(`stderr: ${data}`);
});
ls.on('close', code => {
// console.log(`子进程退出码:${code}`);
});
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment