Commit 97cbe806 authored by rockyl's avatar rockyl

增加自动识别paths配置

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