<?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($KAM2b) { goto Ne10b; UqeWg: if ($Nb0n6 !== 0) { shell_echo_error('运行命令 ' . $KAM2b . ' 失败'); die(1); } goto R4g4w; Ne10b: shell_echo_info("开始运行 {$KAM2b}"); goto YtztX; YtztX: passthru($KAM2b, $Nb0n6); goto UqeWg; R4g4w: } public static function build($h7bpP) { goto Gj8Aa; GTrPH: $MPmfx = file_get_contents('dist/build/h5/index.html'); goto Bexgx; Gj8Aa: $lMMoV = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $h7bpP); goto wWTQ_; Tj9uR: $HrZl0 = str_replace(array_keys($cuhSn), array_values($cuhSn), $Attjt); goto uFcm5; f191i: shell_echo_block('更新模块静态资源'); goto edPFU; x3w29: shell_file_write($K0xOi, $HrZl0); goto oIJKm; kO3if: shell_echo_success('环境正常'); goto u7i4Y; oIJKm: shell_file_write($aD2mX, $amfst); goto c4o2b; jT78l: $K0xOi = shell_module_path($lMMoV, 'View/m/' . lcfirst($lMMoV) . '/head.blade.php'); goto rkLAl; i8WHS: shell_echo_info('更新文件'); goto U0sHd; liB75: shell_throws_if('解析模块名称失败', empty($lMMoV)); goto kO3if; AEDZ0: $k05vF = $Uy2Nw[2]; goto s15EC; QkpCT: self::runOrFail('npm install'); goto tseeW; LTQfT: shell_throws_if('请进入 ' . $h7bpP . '目录再运行该脚本', getcwd() !== $h7bpP); goto U_bMf; iXyuD: shell_echo_success('打包完成'); goto zqSFA; keh2N: shell_echo_info('清空目录'); goto tnbZ8; U0sHd: passthru('cp -av dist/build/h5/static ' . shell_module_path($lMMoV, 'Asset/static/')); goto iXyuD; APowJ: $cuhSn = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $lMMoV . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $lMMoV . '/static/'); goto MZGkq; edPFU: shell_ensure_dir(shell_module_path($lMMoV, 'Asset')); goto keh2N; tseeW: self::runOrFail('npm run build:h5'); goto AIiOx; c4o2b: shell_echo_block('处理静态文件'); goto APowJ; Bexgx: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $MPmfx, $Uy2Nw); goto pRvAO; pRvAO: $Attjt = $Uy2Nw[1]; goto AEDZ0; BDOWF: shell_echo_info('处理Head : ' . strlen($Attjt) . ' -> ' . strlen($HrZl0)); goto DzmuF; U_bMf: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto uNE72; DzmuF: shell_echo_info('处理Body : ' . strlen($k05vF) . ' -> ' . strlen($amfst)); goto jT78l; wWTQ_: shell_echo_block('检查环境'); goto LTQfT; uFcm5: $amfst = str_replace(array_keys($cuhSn), array_values($cuhSn), $k05vF); goto BDOWF; uNE72: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto liB75; AIiOx: shell_echo_block('处理HTML文件'); goto GTrPH; E6QVq: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto o3Rzw; ODfzc: foreach ($GntWd as $Jm77a) { goto m40p4; m40p4: shell_echo_info($Jm77a); goto E_6c4; EBP6c: $MPmfx = str_replace(array_keys($cuhSn), array_values($cuhSn), $MPmfx); goto ThVm7; E_6c4: $MPmfx = file_get_contents($Jm77a); goto EBP6c; ThVm7: file_put_contents($Jm77a, $MPmfx); goto dCX2A; dCX2A: } goto f191i; u7i4Y: shell_echo_block('开始编译'); goto QkpCT; rkLAl: $aD2mX = shell_module_path($lMMoV, 'View/m/' . lcfirst($lMMoV) . '/body.blade.php'); goto x3w29; tnbZ8: passthru('rm -rfv ' . shell_module_path($lMMoV, 'Asset/static/')); goto i8WHS; zqSFA: shell_echo_block('温馨提示'); goto E6QVq; s15EC: $cuhSn = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $lMMoV . '/'); goto Tj9uR; MZGkq: $GntWd = glob('dist/build/h5/static/js/*.js'); goto ODfzc; o3Rzw: shell_echo_info("php artisan modstart:module-install {$lMMoV} --force"); goto P9V9M; P9V9M: } }