Match-id-12d462d57e45d6a2337ce371637f7c45bec9ff99
This commit is contained in:
parent
670f453e23
commit
17a8e1b13e
|
@ -7,9 +7,9 @@
|
|||
"lint": "eslint . --ext .ts",
|
||||
"build": "rollup --config ./scripts/rollup/rollup.config.js",
|
||||
"build:watch": "rollup --watch --config ./scripts/rollup/rollup.config.js",
|
||||
"build-3rdLib": "node ./scripts/gen3rdLib.js",
|
||||
"build-3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js --dev",
|
||||
"build-horizon3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js --dev --type horizon",
|
||||
"build:3rdLib": "node ./scripts/gen3rdLib.js build:3rdLib",
|
||||
"build:3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js build:3rdLib-dev",
|
||||
"build:horizon3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js build:horizon3rdLib-dev",
|
||||
"build-types": "tsc -p ./libs/horizon/index.ts --emitDeclarationOnly --declaration --declarationDir ./build/horizon/@types --skipLibCheck",
|
||||
"debug-test": "yarn test --debug",
|
||||
"test": "jest --config=jest.config.js",
|
||||
|
|
|
@ -1,44 +1,24 @@
|
|||
'use strict';
|
||||
const ejs = require('ejs');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const console = require('console');
|
||||
const rimRaf = require('rimRaf');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const fs = require('fs');
|
||||
const childProcess = require('child_process');
|
||||
|
||||
const libPathPrefix = '../build';
|
||||
const suffix = argv.dev ? 'development.js' : 'production.js';
|
||||
const template = argv.type === 'horizon' ? 'horizon3rdTemplate.ejs' : 'template.ejs';
|
||||
const templatePath = path.resolve(__dirname, `./${template}`);
|
||||
if (!fs.existsSync(templatePath)) {
|
||||
console.log(chalk.yellow('Failed: Template file not exist'));
|
||||
return;
|
||||
const horizonEcoPath = path.resolve(__dirname, '../../horizon-ecosystem');
|
||||
if (!fs.existsSync(horizonEcoPath)) {
|
||||
throw Error('horizon-ecosystem not found, put horizon-core and horizon-ecosystem in same folder plz!');
|
||||
}
|
||||
const readLib = lib => {
|
||||
const libName = lib.split('.')[0];
|
||||
const libPath = path.resolve(__dirname, `${libPathPrefix}/${libName}/umd/${lib}`);
|
||||
if (fs.existsSync(libPath)) {
|
||||
return fs.readFileSync(libPath, 'utf-8');
|
||||
} else {
|
||||
console.log(chalk.red(`Error: "${libPath}" 文件不存在\n先运行 npm run build`));
|
||||
}
|
||||
};
|
||||
|
||||
ejs.renderFile(
|
||||
path.resolve(__dirname, `./${template}`),
|
||||
const cmd = process.argv[2];
|
||||
childProcess.exec(
|
||||
`npm run ${cmd}`,
|
||||
{
|
||||
Horizon: readLib(`horizon.${suffix}`),
|
||||
cwd: horizonEcoPath,
|
||||
},
|
||||
null,
|
||||
function(err, result) {
|
||||
const common3rdLibPath = path.resolve(__dirname, `${libPathPrefix}/horizonCommon3rdlib.min.js`);
|
||||
rimRaf(common3rdLibPath, e => {
|
||||
if (e) {
|
||||
console.log(e);
|
||||
function (error, stdout) {
|
||||
if (error) {
|
||||
console.log(`Error: ${error}`);
|
||||
} else {
|
||||
console.log(`STDOUT: ${stdout}`);
|
||||
}
|
||||
fs.writeFileSync(common3rdLibPath, result);
|
||||
console.log(chalk.green(`成功生成: ${common3rdLibPath}`));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue