| | |
| | | const os = require('os'); |
| | | const path = require('path'); |
| | | const chalk = require('chalk'); |
| | | require('dotenv').config({ path: '.env.local' }); |
| | | |
| | | // 获取当前脚本所在的目录 |
| | | const scriptDir = __dirname; |
| | |
| | | const argv2 = process.argv[2]; |
| | | const customerList = argv2?.split(' ') ?? ''; |
| | | const publicDir = path.join(rootDir, 'public'); |
| | | const distDir = path.join(rootDir, 'dist'); |
| | | |
| | | const distDir = process.env.VITE_OUTPUT_DIR || path.join(rootDir, 'dist'); |
| | | const customerListDir = path.join(rootDir, 'customer_list'); |
| | | const customerProjectListDir = path.join(rootDir, 'src', 'views', 'project'); |
| | | const firstCustomerName = customerList[0]?.split(':')[0]; |
| | | /** 公共文件夹,所有客户文件夹共享文件 */ |
| | | const commonDir = path.join(customerListDir, 'common'); |
| | | |
| | | const item = customerList[0]; |
| | | 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) => { |
| | |
| | | */ |
| | | const checkCustomer = (command, customer = firstCustomerName) => { |
| | | if (!customer) { |
| | | console.error(chalk.red(`请正确使用命令 “${command} [customer]” `)); |
| | | console.error(chalk.red(`请正确使用命令 "${command} [customer]"`)); |
| | | |
| | | exit(); // 退出脚本 |
| | | } |
| | |
| | | checkFileExist(deployJSON, '配置文件'); |
| | | // 读取 JSON 文件 |
| | | const config = await fs.readJson(deployJSON).catch((err) => { |
| | | console.error(`读取配置文件“${deployJSON}”出错:`, err); |
| | | console.error(`读取配置文件"${deployJSON}"出错:`, err); |
| | | exit(); |
| | | }); |
| | | |
| | |
| | | } |
| | | } |
| | | } catch (error) { |
| | | console.error(`读取“${customerFolder}”失败`, error); |
| | | console.error(`读取"${customerFolder}"失败`, error); |
| | | } |
| | | |
| | | try { |
| | |
| | | /** |
| | | * 切换分支 |
| | | */ |
| | | const changeBranch = () =>{ |
| | | const changeBranch = () => { |
| | | return; |
| | | if (isPro) { |
| | | try { |
| | |
| | | execSync('git checkout test', { stdio: 'inherit' }); |
| | | } catch (error) {} |
| | | } |
| | | } |
| | | }; |
| | | |
| | | module.exports = { |
| | | isPro, |
| | |
| | | updateImportGlob, |
| | | restoreImportGlob, |
| | | deployEnv, |
| | | changeBranch |
| | | changeBranch, |
| | | }; |