From 486450d6a4a0cc1b7de4c053cf561e54b7aafc85 Mon Sep 17 00:00:00 2001
From: Jacob <hlnie@tohours.com>
Date: 星期一, 12 十月 2026 16:44:09 +0800
Subject: [PATCH] feat: manifest.json 改为由 manifest.json.demo 生成
---
scripts/publish.js | 47 +++++---
scripts/set-env.js | 71 ++-----------
switch-prod.bat | 4
scripts/manifest.js | 121 ++++++++++++++++++++++++
switch-sit.bat | 4
5 files changed, 166 insertions(+), 81 deletions(-)
diff --git a/scripts/manifest.js b/scripts/manifest.js
new file mode 100644
index 0000000..c1dc145
--- /dev/null
+++ b/scripts/manifest.js
@@ -0,0 +1,121 @@
+/**
+ * manifest.json 鐢熸垚鍣�
+ *
+ * manifest.json 鏄� HBuilderX 鐨勭紪璇戣緭鍏ワ紝浣嗗唴鍚幆澧冪浉鍏� appid锛屼笉閫傚悎鐩存帴鎻愪氦锛�
+ * 鍥犳妯℃澘鍏ュ簱銆佺敓鎴愮墿蹇界暐锛�
+ *
+ * manifest.json.demo锛堝叆搴擄紝妯℃澘锛� 鈹�鈹�娉ㄥ叆鐜 appid鈹�鈹�鈻� manifest.json锛�.gitignore锛�
+ *
+ * appid 鏁版嵁婧愬敮涓�锛歝onfig/env/<env>.js 鐨� UNI_APPID锛圖Cloud 鏍囪瘑锛夈�丄PPID锛堝井淇″皬绋嬪簭 appid锛�
+ * 璇存槑锛氭ā鏉块噷 mp-weixin 鐨� appid 鍏佽鍐欐垚 null 鎴栦笉瀛樺湪锛岀敓鎴愭椂浼氳嚜鍔ㄥ啓鍏�/琛ラ綈銆�
+ */
+const fs = require('fs');
+const path = require('path');
+
+const ROOT = path.resolve(__dirname, '..');
+const TEMPLATE = path.join(ROOT, 'manifest.json.demo');
+const TARGET = path.join(ROOT, 'manifest.json');
+
+function fail(msg) {
+ console.error('[manifest] ' + msg);
+ process.exit(1);
+}
+
+/** 鍙浛鎹㈢涓�澶� "appid" : <瀛楃涓叉垨 null>锛屼繚鐣欏師鏈夌殑绌烘牸/缂╄繘椋庢牸 */
+function replaceAppId(text, value) {
+ let done = false;
+ const result = text.replace(/"appid"(\s*:\s*)(?:"[^"]*"|null)/, function(match, sep) {
+ done = true;
+ return '"appid"' + sep + '"' + value + '"';
+ });
+ return { text: result, done: done };
+}
+
+/** 娉ㄥ叆涓や釜 appid锛氶《灞傦紙DCloud 鏍囪瘑锛�+ mp-weixin 鍧楀唴锛堝井淇″皬绋嬪簭 appid锛� */
+function injectAppIds(text, env) {
+ // 1) 椤跺眰 appid锛堢涓�澶勫嚭鐜板嵆涓洪《灞傦級
+ const top = replaceAppId(text, env.UNI_APPID);
+ if (!top.done) fail('妯℃澘涓湭鎵惧埌椤跺眰 "appid" 瀛楁锛�' + path.relative(ROOT, TEMPLATE));
+ text = top.text;
+
+ // 2) mp-weixin 涓嬬殑 appid锛屽彧鍦ㄨ鍖哄潡鍐呮浛鎹㈢涓�澶�
+ const idx = text.indexOf('"mp-weixin"');
+ if (idx < 0) fail('妯℃澘涓湭鎵惧埌 "mp-weixin" 閰嶇疆鍧楋細' + path.relative(ROOT, TEMPLATE));
+ const head = text.slice(0, idx);
+ const body = text.slice(idx);
+ const scoped = replaceAppId(body, env.APPID);
+ if (scoped.done) return head + scoped.text;
+
+ // 3) 瀛楁琚垹鎺夋椂锛屾寜鍚岀骇瀛愰」缂╄繘琛ヤ竴琛�
+ const m = body.match(/^("mp-weixin"\s*:\s*\{)(\r?\n)([ \t]*)/);
+ if (!m) fail('妯℃澘鐨� "mp-weixin" 鍧楁牸寮忓紓甯革紝鏃犳硶鍐欏叆 appid');
+ const nl = m[2];
+ const indent = m[3];
+ return head + m[1] + nl + indent + '"appid" : "' + env.APPID + '",' + nl + indent + body.slice(m[0].length);
+}
+
+/** 缁熻銆岄櫎 appid 琛屼互澶栥�嶇殑宸紓锛堟寜琛屽唴瀹规瘮杈冿紝涓嶅彈琛屽彿浣嶇Щ褰卞搷锛� */
+function otherDiff(a, b) {
+ function count(text) {
+ const m = new Map();
+ text.split(/\r?\n/).forEach(function(line) {
+ const l = line.replace(/\s+$/, '');
+ if (/^\s*"appid"\s*:/.test(l.trim())) return;
+ m.set(l, (m.get(l) || 0) + 1);
+ });
+ return m;
+ }
+ const ma = count(a);
+ const mb = count(b);
+ const keys = new Set(Array.from(ma.keys()).concat(Array.from(mb.keys())));
+ let diff = 0;
+ const sample = [];
+ keys.forEach(function(k) {
+ const d = Math.abs((ma.get(k) || 0) - (mb.get(k) || 0));
+ if (!d) return;
+ diff += d;
+ if (sample.length < 3 && k.trim()) sample.push(k.trim().slice(0, 40));
+ });
+ return { count: diff, sample: sample };
+}
+
+/**
+ * 鎸夌幆澧冪敓鎴� manifest.json
+ * @param {object} env config/env/<env>.js 瀵煎嚭鐨勯厤缃�
+ * @returns {{ file: string, changed: boolean }}
+ */
+function generate(env) {
+ if (!fs.existsSync(TEMPLATE)) {
+ fail('鏈壘鍒版ā鏉� ' + path.relative(ROOT, TEMPLATE) +
+ '\n 璇锋妸 manifest.json 鐨勬ā鏉夸繚瀛樹负 manifest.json.demo锛堥渶鍏ュ簱锛夊悗鍐嶇敓鎴�');
+ }
+
+ const rendered = injectAppIds(fs.readFileSync(TEMPLATE, 'utf8'), env);
+ const exists = fs.existsSync(TARGET);
+
+ if (exists) {
+ const prev = fs.readFileSync(TARGET, 'utf8');
+ if (prev === rendered) {
+ console.log('[manifest] manifest.json 宸叉槸鐩爣鍐呭锛屾棤闇�閲嶅啓');
+ return { file: TARGET, changed: false };
+ }
+ const diffs = otherDiff(prev, rendered);
+ if (diffs.count) {
+ console.log('[manifest] 娉ㄦ剰锛氱幇鏈� manifest.json 鏈� ' + diffs.count + ' 琛屽唴瀹逛笌妯℃澘涓嶅悓锛屾湰娆′細琚ā鏉胯鐩�' +
+ (diffs.sample.length ? '锛堝 ' + diffs.sample.join(' | ') + '锛�' : ''));
+ console.log('[manifest] 闇�瑕侀暱鏈熶繚鐣欑殑鏀瑰姩璇峰啓杩� manifest.json.demo');
+ }
+ }
+
+ fs.writeFileSync(TARGET, rendered, 'utf8');
+ console.log('[manifest] 宸茬敱 manifest.json.demo 鐢熸垚 manifest.json' +
+ '锛圖Cloud ' + env.UNI_APPID + ' / 灏忕▼搴� ' + env.APPID + '锛�');
+ return { file: TARGET, changed: true };
+}
+
+module.exports = {
+ TEMPLATE: TEMPLATE,
+ TARGET: TARGET,
+ generate: generate,
+ injectAppIds: injectAppIds
+};
diff --git a/scripts/publish.js b/scripts/publish.js
index eca6706..bc9bf3e 100644
--- a/scripts/publish.js
+++ b/scripts/publish.js
@@ -2,17 +2,19 @@
* 鍛戒护琛屽彂琛岋紙涓嶄笂浼狅級锛� 鑷姩鐢ㄥ井淇″紑鍙戣�呭伐鍏锋墦寮�浜х墿
*
* 鐢ㄦ硶锛�
- * node scripts/publish.js sit # 鍙戣 SIT 鐗堟湰骞舵墦寮�寰俊寮�鍙戣�呭伐鍏�
- * node scripts/publish.js prod # 鍙戣 PROD 鐗堟湰骞舵墦寮�寰俊寮�鍙戣�呭伐鍏�
- * node scripts/publish.js sit --sync # 鍚屾椂鎶� appid 鍚屾杩� manifest.json锛堥粯璁や笉鍔� manifest锛�
- * node scripts/publish.js sit --no-open # 鍙紪璇戯紝涓嶆墦寮�寰俊寮�鍙戣�呭伐鍏�
- * node scripts/publish.js sit --dry-run # 鍙墦鍗板皢瑕佹墽琛岀殑鍛戒护
+ * node scripts/publish.js sit # 鍙戣 SIT 鐗堟湰骞舵墦寮�寰俊寮�鍙戣�呭伐鍏�
+ * node scripts/publish.js prod # 鍙戣 PROD 鐗堟湰骞舵墦寮�寰俊寮�鍙戣�呭伐鍏�
+ * node scripts/publish.js sit --no-gen # 涓嶆敼 manifest.json锛堣姹傚畠宸插瓨鍦級
+ * node scripts/publish.js sit --no-open # 鍙紪璇戯紝涓嶆墦寮�寰俊寮�鍙戣�呭伐鍏�
+ * node scripts/publish.js sit --dry-run # 鍙墦鍗板皢瑕佹墽琛岀殑鍛戒护
*
- * 鐜鍊肩粺涓�鍙栬嚜 config/env/<env>.js锛堝敮涓�鏁版嵁婧愶級锛屾帴鍙e湴鍧�绛夎繍琛屾椂鍙傛暟鐢卞寘鍐呰嚜鍔ㄨ瘑鍒紝
- * 鏈剼鏈彧璐熻矗璁┾�滅紪璇戞湡 appid鈥濅笌鐩爣鐜涓�鑷� 鈥斺�� 寰俊寮�鍙戣�呭伐鍏锋墦寮�鐨勪骇鐗� appid锛�
- * 灏辨槸 unpackage/dist/build/mp-weixin/project.config.json 閲岀殑 appid锛堟瀯寤烘椂鐢� manifest 鐢熸垚锛夈��
+ * 娴佺▼锛氫粠 manifest.json.demo 鐢熸垚 manifest.json锛堟寜鐩爣鐜娉ㄥ叆 appid锛夆啋 鍙戣缂栬瘧 鈫�
+ * 鏍℃浜х墿 appid 鈫� 鐢ㄥ井淇″紑鍙戣�呭伐鍏锋墦寮�浜х墿
*
- * 榛樿绛栫暐锛氫笉鍔� manifest.json锛堜粨搴撲繚鎸佸熀绾匡紝git 鏃犲櫔闊筹級锛屽彧鍥炲啓鏈窡韪殑浜х墿鏂囦欢銆�
+ * 鐜鍊肩粺涓�鍙栬嚜 config/env/<env>.js锛堝敮涓�鏁版嵁婧愶級锛屾帴鍙e湴鍧�绛夎繍琛屾椂鍙傛暟鐢卞寘鍐呮寜 appid 鑷姩璇嗗埆锛�
+ * manifest.json 鏄敓鎴愮墿锛堝凡 .gitignore锛夛紝鍥犳 git 姘歌繙娌℃湁鐜鍣煶銆�
+ * 寰俊寮�鍙戣�呭伐鍏锋墦寮�鐨勪骇鐗� appid = unpackage/dist/build/mp-weixin/project.config.json 鐨� appid
+ * 锛堟瀯寤烘椂鐢� manifest 鐢熸垚锛岃繖閲屽啀鍏滃簳鏍℃涓�娆★級銆�
*
* 澶栭儴宸ュ叿锛圚BuilderX cli.exe銆佸井淇″紑鍙戣�呭伐鍏� cli.bat锛変笉鍐欐缁濆璺緞锛屾寜椤哄簭鑷姩鏌ユ壘锛�
* 1) 鐜鍙橀噺 HBUILDERX_CLI / WX_DEVTOOLS_CLI
@@ -24,6 +26,7 @@
const { spawnSync } = require('child_process');
const fs = require('fs');
const path = require('path');
+const manifest = require('./manifest');
const ROOT = path.resolve(__dirname, '..');
const ENV_DIR = path.join(ROOT, 'config', 'env');
@@ -189,11 +192,11 @@
const argv = process.argv.slice(2);
const envName = (argv.find(function(a) { return a.charAt(0) !== '-'; }) || '').trim();
-const syncManifest = argv.indexOf('--sync') > -1;
+const noGen = argv.indexOf('--no-gen') > -1;
const noOpen = argv.indexOf('--no-open') > -1;
const dryRun = argv.indexOf('--dry-run') > -1;
-const OWN_ARGS = ['--sync', '--no-open', '--dry-run'];
+const OWN_ARGS = ['--no-gen', '--no-open', '--dry-run'];
// 閫忎紶缁� HBuilderX cli 鐨勯澶栧弬鏁帮紙淇濈暀 "鍙傛暟 鍊�" 鎴愬鍏崇郴锛�
const passthrough = [];
let envNameSkipped = false;
@@ -243,19 +246,27 @@
putOnPath(hx.file);
if (wx) putOnPath(wx.file);
+ // 鐩爣缂栬瘧浜х墿鐢� manifest.json 鍐冲畾锛岃�� manifest.json 鏄敓鎴愮墿
+ if (noGen && !fs.existsSync(manifest.TARGET)) {
+ fail('--no-gen 闇�瑕� manifest.json 宸插瓨鍦紝璇峰厛杩愯锛歯ode scripts/set-env.js ' + envName);
+ }
+
console.log('[release] 鐜 : ' + envName + '锛�' + env.ENV_NAME + '锛�');
console.log('[release] 灏忕▼搴廰ppid : ' + env.APPID);
console.log('[release] 鎺ュ彛鍦板潃 : ' + env.HTTP_REQUEST_URL);
console.log('[release] 浜х墿鐩綍 : ' + DIST_DIR);
console.log('[release] HBuilderX : ' + hx.file + '锛�' + hx.source + '锛�');
if (wx) console.log('[release] 寮�鍙戣�呭伐鍏� : ' + wx.file + '锛�' + wx.source + '锛�');
- console.log('[release] manifest.json: ' + (syncManifest ? '鍚屾涓� ' + envName + ' 鐨� appid锛堜細浜х敓 git 鏀瑰姩锛�' : '淇濇寔涓嶅姩锛堜粨搴撶淮鎸佸熀绾匡紝鏃� git 鏀瑰姩锛�'));
+ console.log('[release] manifest.json: ' + (noGen
+ ? '涓嶆敼鍔紙--no-gen锛�'
+ : '鐢� manifest.json.demo 鐢熸垚锛坅ppid ' + env.APPID + '锛岀敓鎴愮墿涓嶅叆搴擄級'));
const cliArgs = ['publish', '--platform', 'mp-weixin', '--project', ROOT].concat(passthrough);
// 璺緞鍚┖鏍�/涓枃锛屼氦缁� cmd 瑙f瀽鏇寸ǔ
const openCmd = '"' + wx.file + '" open --project "' + DIST_DIR + '"';
if (dryRun) {
+ console.log('[release] 0) 鐢熸垚: manifest.json 鈫� manifest.json.demo' + (noGen ? '锛堝凡鎸囧畾 --no-gen锛岃烦杩囷級' : ''));
console.log('[release] 1) 缂栬瘧: "' + hx.file + '" ' + cliArgs.join(' '));
console.log('[release] 2) 浜х墿 appid 鍥炲啓涓� ' + env.APPID + ' 鈫� ' + DIST_CONFIG);
if (!noOpen) console.log('[release] 3) 鎵撳紑: ' + openCmd);
@@ -263,11 +274,11 @@
return;
}
- // 1) 鍙�夛細鍚屾 manifest.json锛堜細璁╄璺熻釜鏂囦欢浜х敓鏀瑰姩锛岄粯璁や笉鍋氾級
- if (syncManifest) {
- console.log('[release] 鍚屾 manifest.json 鐨� appid鈥�');
- const sync = spawnSync(process.execPath, [path.join(__dirname, 'set-env.js'), envName], { cwd: ROOT, stdio: 'inherit' });
- if (sync.status !== 0) fail('鍚屾 manifest.json 澶辫触');
+ // 1) 鐢熸垚 manifest.json锛圚BuilderX 鐨勭紪璇戣緭鍏ワ紝妯℃澘锛歮anifest.json.demo锛�
+ if (noGen) {
+ console.log('[release] 璺宠繃 manifest.json 鐢熸垚锛�--no-gen锛�');
+ } else {
+ manifest.generate(env);
}
// 2) 鍙戣缂栬瘧锛堜骇鐗╋細unpackage/dist/build/mp-weixin锛�
@@ -276,7 +287,7 @@
if (build.error) fail('璋冪敤 cli.exe 澶辫触锛�' + build.error.message);
if (build.status !== 0) fail('cli.exe 閫�鍑虹爜 ' + build.status + '锛岃鏌ョ湅 HBuilderX 鎺у埗鍙拌緭鍑�');
- // 3) 鏍℃浜х墿 appid锛�--sync 鏃堕�氬父宸蹭竴鑷达紝杩欓噷鍏滃簳淇濊瘉锛�
+ // 3) 鏍℃浜х墿 appid锛堟甯稿簲涓� manifest 涓�鑷达紝杩欓噷鍏滃簳淇濊瘉锛�
if (!fs.existsSync(DIST_CONFIG)) {
fail('鍙戣浜х墿缂哄皯 project.config.json锛�' + DIST_CONFIG + '\n 璇风‘璁� HBuilderX 缂栬瘧鏄惁鎴愬姛');
}
diff --git a/scripts/set-env.js b/scripts/set-env.js
index 59f3188..26f1280 100644
--- a/scripts/set-env.js
+++ b/scripts/set-env.js
@@ -1,78 +1,31 @@
/**
- * 鐜鍒囨崲鑴氭湰锛氭妸 config/env/<env>.js 閲岀殑 appid 鍚屾鍒扮紪璇戞湡閰嶇疆鏂囦欢
+ * 鐜鍒囨崲锛氭寜 config/env/<env>.js 浠庢ā鏉跨敓鎴� manifest.json
*
* 鐢ㄦ硶锛�
* npm run env:sit 绛変环浜� node scripts/set-env.js sit
* npm run env:prod 绛変环浜� node scripts/set-env.js prod
*
* 璇存槑锛�
- * appid 鏄紪璇戞湡鍊硷紙HBuilderX 鐨勭紪璇戣緭鍏ュ氨鏄� manifest.json锛夛紝鏃犳硶鍍忔帴鍙e湴鍧�閭f牱
- * 杩愯鏃跺垏鎹紝鎵�浠ヨ繖閲屽仛鈥滀竴娆″懡浠ゅ啓鍥炩�濄�傛敼瀹屽繀椤婚噸鏂扮紪璇戜竴娆★紝浜х墿閲岀殑
- * project.config.json 鎵嶄細鏇存柊銆�
+ * manifest.json 鏄� HBuilderX 鐨勭紪璇戣緭鍏ワ紙appid 灞炰簬缂栬瘧鏈熷�硷紝鏃犳硶鍍忔帴鍙e湴鍧�閭f牱杩愯鏃跺垏鎹級锛�
+ * 浣嗗畠鍚幆澧冪浉鍏� appid锛屼笉閫傚悎鐩存帴鎻愪氦锛屾墍浠ワ細
+ * manifest.json.demo锛堝叆搴撴ā鏉匡級 --鐢熸垚--> manifest.json锛堝凡 .gitignore锛�
+ * 鐢熸垚鍚庡繀椤婚噸鏂扮紪璇戜竴娆★紝骞跺湪寰俊寮�鍙戣�呭伐鍏蜂腑閲嶆柊鎵撳紑椤圭洰锛坅ppid 鍙樻洿闇�閲嶅紑锛夈��
*
- * 鏃ュ父鎺ㄨ崘锛歮p-weixin.appid 淇濇寔 null锛屽彧璁╁彂琛岃剼鏈洖鍐欎骇鐗� appid锛坓it 闆跺櫔闊筹級銆�
- * 鏈剼鏈敤浜庨渶瑕佸湪 HBuilderX 閲岀洿鎺ヨ繍琛岃皟璇曘�佹垨瑕佸嚭 App 鍖咃紙椤跺眰 appid锛夌殑鍦烘櫙銆�
+ * 濡傞渶鍦� HBuilderX 閲岀洿鎺ョ紪璇�/杩愯璋冭瘯锛屽厛璺戜竴娆℃湰鑴氭湰锛�
+ * 璧板懡浠よ鍙戣鍒欑洿鎺ョ敤 scripts/publish.js锛堝唴閮ㄤ細鑷姩鐢熸垚锛夈��
*
- * 鍞竴鏁版嵁婧愶細config/env/<env>.js 涓殑 UNI_APPID锛圖Cloud 鏍囪瘑锛夈�丄PPID锛堝皬绋嬪簭 appid锛�
+ * appid 鏁版嵁婧愬敮涓�锛歝onfig/env/<env>.js 涓殑 UNI_APPID锛圖Cloud 鏍囪瘑锛夈�丄PPID锛堝皬绋嬪簭 appid锛�
*/
const fs = require('fs');
const path = require('path');
+const manifest = require('./manifest');
const ROOT = path.resolve(__dirname, '..');
const ENV_DIR = path.join(ROOT, 'config', 'env');
-// 鏍圭洰褰� project.config.json 涓嶅弬涓� mp-weixin 缂栬瘧涓斿凡涓嶅叆搴擄紝杩欓噷鍙淮鎶� manifest.json
-const files = {
- manifest: path.join(ROOT, 'manifest.json')
-};
-
function fail(msg) {
console.error('[set-env] ' + msg);
process.exit(1);
-}
-
-/** 鍙浛鎹㈢涓�澶� "appid" : <瀛楃涓叉垨 null>锛屼繚鐣欏師鏈夌┖鏍�/缂╄繘椋庢牸 */
-function replaceAppId(text, value) {
- let done = false;
- const result = text.replace(/"appid"(\s*:\s*)(?:"[^"]*"|null)/, function(match, sep) {
- done = true;
- return '"appid"' + sep + '"' + value + '"';
- });
- return { text: result, done: done };
-}
-
-/** 鏇挎崲 manifest.json 椤跺眰 appid锛堢涓�澶勫嚭鐜板嵆涓洪《灞傦級 */
-function patchManifest(text, env) {
- // 1) 椤跺眰 appid锛圖Cloud 搴旂敤鏍囪瘑锛�
- const top = replaceAppId(text, env.UNI_APPID);
- if (!top.done) fail('manifest.json 涓湭鎵惧埌椤跺眰 "appid" 瀛楁');
- text = top.text;
-
- // 2) mp-weixin 涓嬬殑 appid锛堝井淇″皬绋嬪簭 appid锛夛紝鍙湪璇ュ尯鍧楀唴鏇挎崲绗竴澶�
- const idx = text.indexOf('"mp-weixin"');
- if (idx < 0) fail('manifest.json 涓湭鎵惧埌 "mp-weixin" 閰嶇疆鍧�');
- const head = text.slice(0, idx);
- const body = text.slice(idx);
- const scoped = replaceAppId(body, env.APPID);
- if (scoped.done) return head + scoped.text;
-
- // 3) 瀛楁琚垹鎺夋椂锛屾寜鍚岀骇瀛愰」缂╄繘琛ヤ竴琛�
- const m = body.match(/^("mp-weixin"\s*:\s*\{)(\r?\n)([ \t]*)/);
- if (!m) fail('manifest.json 鐨� "mp-weixin" 鍧楁牸寮忓紓甯革紝鏃犳硶鍐欏叆 appid');
- const nl = m[2];
- const indent = m[3];
- return head + m[1] + nl + indent + '"appid" : "' + env.APPID + '",' + nl + indent + body.slice(m[0].length);
-}
-
-function writeIfChanged(file, next) {
- const prev = fs.readFileSync(file, 'utf8');
- if (prev === next) {
- console.log(' - ' + path.relative(ROOT, file) + ' 宸叉槸鐩爣鍊硷紝鏃犻渶鏀瑰姩');
- return false;
- }
- fs.writeFileSync(file, next, 'utf8');
- console.log(' 鈭� ' + path.relative(ROOT, file) + ' 宸叉洿鏂�');
- return true;
}
function main() {
@@ -98,11 +51,11 @@
console.log(' 灏忕▼搴� appid : ' + env.APPID);
console.log(' 鎺ュ彛鍦板潃 : ' + env.HTTP_REQUEST_URL);
- const changed = writeIfChanged(files.manifest, patchManifest(fs.readFileSync(files.manifest, 'utf8'), env));
+ const res = manifest.generate(env);
- console.log(changed
+ console.log(res.changed
? '[set-env] 瀹屾垚锛岃鍦� HBuilderX 涓噸鏂扮紪璇戜竴娆★紝骞跺湪寰俊寮�鍙戣�呭伐鍏蜂腑閲嶆柊鎵撳紑椤圭洰'
- : '[set-env] 鏃犻渶鏀瑰姩锛屽綋鍓嶅凡鏄� ' + envName + ' 鐜閰嶇疆');
+ : '[set-env] 鏃犻渶鏀瑰姩锛屽綋鍓� manifest.json 宸叉槸 ' + envName + ' 鐜');
}
main();
diff --git a/switch-prod.bat b/switch-prod.bat
index 018f10c..4758be3 100644
--- a/switch-prod.bat
+++ b/switch-prod.bat
@@ -7,8 +7,8 @@
echo 鎺ュ彛 : https://acmall.bluedeer.com.cn/crmeb/front
echo ============================================
echo.
-echo 璇存槑锛氭敼鍐� manifest.json / project.config.json 鐨勭紪璇戞湡 appid
-echo 锛堟帴鍙e湴鍧�鏄繍琛屾椂鎸� appid 鑷姩璇嗗埆鐨勶紝鏃犻渶鏀瑰姩锛�
+echo 璇存槑锛氭寜 config/env/prod.js锛屼粠 manifest.json.demo 鐢熸垚 manifest.json
+echo 锛坢anifest.json 鏄敓鎴愮墿銆佸凡涓嶅叆搴擄紱鎺ュ彛鍦板潃杩愯鏃舵寜 appid 鑷姩璇嗗埆锛�
echo.
node "scripts\set-env.js" prod
echo.
diff --git a/switch-sit.bat b/switch-sit.bat
index c060e42..3ab50e2 100644
--- a/switch-sit.bat
+++ b/switch-sit.bat
@@ -7,8 +7,8 @@
echo 鎺ュ彛 : https://sit.tohours.com/crmeb/front
echo ============================================
echo.
-echo 璇存槑锛氭敼鍐� manifest.json / project.config.json 鐨勭紪璇戞湡 appid
-echo 锛堟帴鍙e湴鍧�鏄繍琛屾椂鎸� appid 鑷姩璇嗗埆鐨勶紝鏃犻渶鏀瑰姩锛�
+echo 璇存槑锛氭寜 config/env/sit.js锛屼粠 manifest.json.demo 鐢熸垚 manifest.json
+echo 锛坢anifest.json 鏄敓鎴愮墿銆佸凡涓嶅叆搴擄紱鎺ュ彛鍦板潃杩愯鏃舵寜 appid 鑷姩璇嗗埆锛�
echo.
node "scripts\set-env.js" sit
echo.
--
Gitblit v1.4.0