<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Util; use ModStart\Core\Util\PlatformUtil; use ModStart\Core\Util\ReUtil; include_once __DIR__ . '/../Shell/include.php'; class UniappUtil { public static function runOrFail($umOI_) { goto INyBn; INyBn: shell_echo_info("开始运行 {$umOI_}"); goto aNG24; SubdE: if ($B21po !== 0) { shell_echo_error('运行命令 ' . $umOI_ . ' 失败'); die(1); } goto A4b5k; aNG24: passthru($umOI_, $B21po); goto SubdE; A4b5k: } public static function build($vm4GG) { goto GwZd_; Y7pQW: shell_echo_info('更新文件'); goto pqytu; wz86k: shell_echo_block('更新模块静态资源'); goto PcwsB; IGio1: shell_echo_block('温馨提示'); goto kmFck; CVcZI: shell_echo_block('处理HTML文件'); goto kxKW9; wnBtF: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $fKViA, $hfN7a); goto k6r96; NysLf: $nMjX1 = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $X3Epx . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $X3Epx . '/static/'); goto wkFhN; PcwsB: shell_ensure_dir(shell_module_path($X3Epx, 'Asset')); goto LB0ml; wkFhN: $dz8Az = glob('dist/build/h5/static/js/*.js'); goto r84ts; kmFck: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto vh3Yk; r84ts: foreach ($dz8Az as $obXaA) { goto h2enP; bHNpW: file_put_contents($obXaA, $fKViA); goto l1CMr; h2enP: shell_echo_info($obXaA); goto fGAAC; fGAAC: $fKViA = file_get_contents($obXaA); goto E7SwT; E7SwT: $fKViA = str_replace(array_keys($nMjX1), array_values($nMjX1), $fKViA); goto bHNpW; l1CMr: } goto wz86k; yvca3: shell_echo_info('处理Body : ' . strlen($uilwH) . ' -> ' . strlen($PXJaU)); goto QDHeT; LB0ml: shell_echo_info('清空目录'); goto OO5Eh; POKYX: shell_echo_block('处理静态文件'); goto NysLf; PBVWE: shell_echo_success('打包完成'); goto IGio1; B7ZWa: shell_echo_block('检查环境'); goto bhcvk; QPZHj: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto DqclQ; bhcvk: shell_throws_if('请进入 ' . $vm4GG . '目录再运行该脚本', getcwd() !== $vm4GG); goto QPZHj; kEw6H: $uilwH = $hfN7a[2]; goto NQA3N; QDHeT: $AerE8 = shell_module_path($X3Epx, 'View/m/' . lcfirst($X3Epx) . '/head.blade.php'); goto Ejpud; jioCK: shell_echo_success('环境正常'); goto W0mp5; kxKW9: $fKViA = file_get_contents('dist/build/h5/index.html'); goto wnBtF; OrBXJ: self::runOrFail('npm install'); goto IN7sx; ujrxC: $PXJaU = str_replace(array_keys($nMjX1), array_values($nMjX1), $uilwH); goto mzrAO; k6r96: $KQYyW = $hfN7a[1]; goto kEw6H; YrJOp: shell_file_write($SIXEW, $PXJaU); goto POKYX; mzrAO: shell_echo_info('处理Head : ' . strlen($KQYyW) . ' -> ' . strlen($X60Sj)); goto yvca3; IN7sx: self::runOrFail('npm run build:h5'); goto CVcZI; ttq38: $X60Sj = str_replace(array_keys($nMjX1), array_values($nMjX1), $KQYyW); goto ujrxC; W0mp5: shell_echo_block('开始编译'); goto OrBXJ; GwZd_: $X3Epx = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $vm4GG); goto B7ZWa; v6XYj: shell_file_write($AerE8, $X60Sj); goto YrJOp; NQA3N: $nMjX1 = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $X3Epx . '/'); goto ttq38; B4Kps: shell_throws_if('解析模块名称失败', empty($X3Epx)); goto jioCK; OO5Eh: passthru('rm -rfv ' . shell_module_path($X3Epx, 'Asset/static/')); goto Y7pQW; DqclQ: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto B4Kps; Ejpud: $SIXEW = shell_module_path($X3Epx, 'View/m/' . lcfirst($X3Epx) . '/body.blade.php'); goto v6XYj; vh3Yk: shell_echo_info("php artisan modstart:module-install {$X3Epx} --force"); goto wZmJo; pqytu: passthru('cp -av dist/build/h5/static ' . shell_module_path($X3Epx, 'Asset/static/')); goto PBVWE; wZmJo: } }