Commit 97cbe806 authored by rockyl's avatar rockyl

增加自动识别paths配置

parent b6de9e21
const path = require('path');
const program = require('commander');
const {exit, getManifest} = require('./tools');
const {exit, getBuildConfig} = require('./tools');
const ossUpload = require('./oss-upload');
program
......@@ -13,11 +13,11 @@ async function execute() {
let version = program.versionCode;
let releasePath = './bin-release/web/';
const manifest = getManifest();
if(manifest && manifest.build){
remotePath = manifest.build['remote-path'];
version = version ? version : manifest.build['version'];
releasePath = manifest.build['release-path'] || releasePath;
const buildConfig = getBuildConfig();
if(buildConfig){
remotePath = buildConfig['remote-path'];
version = version ? version : buildConfig['version'];
releasePath = buildConfig['release-path'] || releasePath;
}
if(version){
......
......@@ -42,7 +42,6 @@ function handler(request, response) {
const headers = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Methods': 'POST,GET,PUT,OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type,Access-Token',
};
......
......@@ -76,28 +76,22 @@ function savePackage(){
}
}
const getManifest = exports.getManifest = function () {
const getBuildConfig = exports.getBuildConfig = function () {
if(!ensurePackage()){
console.log('package.json is not exist');
return;
}
let manifest = packageObj.manifest;
if (!manifest) {
manifest = packageObj.manifest = {};
let build = packageObj.build;
if (!build) {
build = packageObj.build = {};
}
return manifest;
return build;
};
exports.updateBuildConfig = function (key, value) {
const manifest = getManifest();
if (manifest) {
let build = manifest.build;
if (!build) {
build = manifest.build = {};
}
build[key] = value;
savePackage();
}
const build = getBuildConfig();
build[key] = value;
savePackage();
};
function findGlobalModulePath(moduleName){
......@@ -123,9 +117,9 @@ exports.executeBuildProcess = function (cmd) {
return new Promise((resolve, reject) => {
let buildProcessName;
const manifest = getManifest();
const buildConfig = getBuildConfig();
try {
buildProcessName = manifest.build['build-process'];
buildProcessName = buildConfig['build-process'];
}catch (e) {
console.log('invalid manifest config')
}
......@@ -141,7 +135,8 @@ exports.executeBuildProcess = function (cmd) {
console.log(`Build process [${buildProcessName}] has not implement ${cmd} function`)
}
} catch (e) {
reject('Build process is not found, please install with --global\n' + 'GLOBAL_NPM_PATH: ' + npm.GLOBAL_NPM_PATH);
console.log(e);
reject('Build process is not found, please install with --global\n' + 'GLOBAL_NPM_PATH: ' + globalModulePath);
}
}
reject('Build process name is not found, please setup ' + packageJsonFile);
......
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