From 2144fb07b53812f565b2801f99e69cee9b28cab3 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期三, 11 十二月 2024 17:26:57 +0800
Subject: [PATCH] 代理、输出

---
 scripts/helper.js |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/scripts/helper.js b/scripts/helper.js
index 2b399f3..f63ba78 100644
--- a/scripts/helper.js
+++ b/scripts/helper.js
@@ -15,9 +15,13 @@
 const customerProjectListDir = path.join(rootDir, 'src', 'views', 'project');
 const firstCustomerName = customerList[0]?.split(':')[0];
 /** 鍏叡鏂囦欢澶癸紝鎵�鏈夊鎴锋枃浠跺す鍏变韩鏂囦欢 */
-const commonDir = path.join(customerListDir,'common')
+const commonDir = path.join(customerListDir, 'common');
 
-const homeDir = os.homedir();
+const item = customerList[0];
+const customerSplit = item?.split(':');
+const deployEnv = customerSplit?.[1];
+// 鏄惁涓虹敓浜х幆澧�
+const isPro = deployEnv === 'pro';
 // const deployEnv = process.argv[3];
 
 const logColor = (text, color) => {
@@ -30,6 +34,10 @@
 
 const logSuccess = (text) => {
 	logColor(text, 'green');
+};
+
+const logWarn = (text) => {
+	logColor(text, 'yellow');
 };
 
 /**
@@ -185,6 +193,23 @@
 	return format;
 };
 
+const copyAmisEditor = () => {
+	// 澶嶅埗amis-editor 鍒� public鏂囦欢澶逛腑
+	const amisEditorPath = path.join(rootDir, 'wi.amis', 'amis-editor');
+	const targetPath = path.join(publicDir, 'amis-editor');
+	const isExist = fs.pathExistsSync(amisEditorPath);
+	if (!isExist) {
+		logWarn(`amis-editor锛堣矾寰勶細${amisEditorPath} 涓嶅瓨鍦紒`);
+	} else {
+		const isExist = fs.pathExistsSync(targetPath);
+		if (!isExist) {
+			fs.mkdirSync(targetPath);
+		}
+		const res = fs.copySync(amisEditorPath, targetPath);
+		res ?? logSuccess('========= 宸查泦鎴� amis-editor =========');
+	}
+};
+
 /**
  * 澶嶅埗鏂囦欢鍒� public 鏂囦欢澶逛腑
  * (鍙兘澶嶅埗涓�涓鎴锋枃浠堕厤缃�)
@@ -211,7 +236,8 @@
 	const customerDir = path.join(customerListDir, firstCustomerName);
 	// 澶嶅埗婧愭枃浠跺す涓殑鎵�鏈夋枃浠跺埌 public 鏂囦欢澶�
 	fs.copySync(customerDir, publicDir, { filter });
-	fs.copySync(commonDir,publicDir);
+	fs.copySync(commonDir, publicDir);
+	copyAmisEditor();
 }
 
 /**
@@ -312,7 +338,23 @@
 	logSuccess(`${formatDate(new Date(), 'HH:MM:SS')} > 馃帀馃帀馃帀銆�${customerList.join(',')}銆戦」鐩凡鎴愬姛閮ㄧ讲锛侌煄夝煄夝煄塦);
 };
 
+/**
+ * 鍒囨崲鍒嗘敮
+ */
+const changeBranch = () => {
+	if (isPro) {
+		try {
+			execSync('git checkout master', { stdio: 'inherit' });
+		} catch (error) {}
+	} else {
+		try {
+			execSync('git checkout test', { stdio: 'inherit' });
+		} catch (error) {}
+	}
+};
+
 module.exports = {
+	isPro,
 	firstCustomerName,
 	exit,
 	customerList,
@@ -336,9 +378,12 @@
 	//#region ====================== 鎵撳嵃 ======================
 	logError,
 	logSuccess,
+	logWarn,
 	//#endregion
 	formatDate,
 
 	updateImportGlob,
 	restoreImportGlob,
+	deployEnv,
+	changeBranch,
 };

--
Gitblit v1.9.3