wujingjing
2025-01-07 f93ffdd6a106c4aec20019da5f20f0dc2456e25f
scripts/helper.js
@@ -17,11 +17,11 @@
/** 公共文件夹,所有客户文件夹共享文件 */
const commonDir = path.join(customerListDir, 'common');
 const item = customerList[0];
const customerSplit = item.split(':');
const deployEnv = customerSplit[1];
const item = customerList[0];
const customerSplit = item?.split(':');
const deployEnv = customerSplit?.[1];
// 是否为生产环境
const isPro = deployEnv==='pro';
const isPro = deployEnv === 'pro';
// const deployEnv = process.argv[3];
const logColor = (text, color) => {
@@ -195,11 +195,11 @@
const copyAmisEditor = () => {
   // 复制amis-editor 到 public文件夹中
   const amisEditorPath = path.join(rootDir, 'amis-editor');
   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 不存在!');
      logWarn(`amis-editor(路径:${amisEditorPath} 不存在!`);
   } else {
      const isExist = fs.pathExistsSync(targetPath);
      if (!isExist) {
@@ -338,6 +338,21 @@
   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,
@@ -369,4 +384,6 @@
   updateImportGlob,
   restoreImportGlob,
   deployEnv,
   changeBranch,
};