<?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($g7pY7) { goto VWm2o; VWm2o: shell_echo_info("开始运行 {$g7pY7}"); goto JVgdg; SvDsL: if ($ArLnr !== 0) { shell_echo_error('运行命令 ' . $g7pY7 . ' 失败'); die(1); } goto OqPg1; JVgdg: passthru($g7pY7, $ArLnr); goto SvDsL; OqPg1: } public static function build($v5A42) { goto bLeQ7; JLCou: shell_echo_block('处理静态文件'); goto PowHL; OFkWU: shell_throws_if('请进入 ' . $v5A42 . '目录再运行该脚本', getcwd() !== $v5A42); goto g7t0X; oPCp_: $wdP8k = str_replace(array_keys($KreWN), array_values($KreWN), $cllT8); goto Gmg_L; FeYZD: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $n16LT, $XeSWB); goto O1pcv; fr9Nd: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto goazg; KMWNq: $xu2ZJ = shell_module_path($k8GtY, 'View/m/' . lcfirst($k8GtY) . '/head.blade.php'); goto ftD1z; PowHL: $KreWN = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $k8GtY . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $k8GtY . '/static/'); goto QFafE; ftD1z: $hgcns = shell_module_path($k8GtY, 'View/m/' . lcfirst($k8GtY) . '/body.blade.php'); goto n6qrY; mxCGv: shell_echo_block('检查环境'); goto OFkWU; O1pcv: $NpXe6 = $XeSWB[1]; goto Mvzns; q8cCo: $A6Z2b = str_replace(array_keys($KreWN), array_values($KreWN), $NpXe6); goto oPCp_; tb_8B: shell_echo_info("php artisan modstart:module-install {$k8GtY} --force"); goto jCsZg; gGcAt: shell_echo_block('开始编译'); goto cwa7w; ynyyK: shell_echo_success('环境正常'); goto gGcAt; g7t0X: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto fr9Nd; LNRJe: shell_echo_block('更新模块静态资源'); goto A3O7X; A3O7X: shell_ensure_dir(shell_module_path($k8GtY, 'Asset')); goto uWAOL; DOasy: shell_echo_info('处理Body : ' . strlen($cllT8) . ' -> ' . strlen($wdP8k)); goto KMWNq; hJi1V: shell_echo_block('处理HTML文件'); goto e0GmG; KeNqX: self::runOrFail('npm run build:h5'); goto hJi1V; VBZCT: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto tb_8B; n6qrY: shell_file_write($xu2ZJ, $A6Z2b); goto odVfA; QFafE: $cRM80 = glob('dist/build/h5/static/js/*.js'); goto OHPtf; Q4GNO: shell_echo_block('温馨提示'); goto VBZCT; cwa7w: self::runOrFail('npm install'); goto KeNqX; Mvzns: $cllT8 = $XeSWB[2]; goto gEsQW; OHPtf: foreach ($cRM80 as $dG73t) { goto QjsVo; gLDDO: $n16LT = file_get_contents($dG73t); goto pdg1D; pdg1D: $n16LT = str_replace(array_keys($KreWN), array_values($KreWN), $n16LT); goto qwQld; qwQld: file_put_contents($dG73t, $n16LT); goto f6ZhX; QjsVo: shell_echo_info($dG73t); goto gLDDO; f6ZhX: } goto LNRJe; odVfA: shell_file_write($hgcns, $wdP8k); goto JLCou; GDSBJ: shell_echo_success('打包完成'); goto Q4GNO; bLeQ7: $k8GtY = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $v5A42); goto mxCGv; a5FiJ: shell_echo_info('更新文件'); goto l223N; e0GmG: $n16LT = file_get_contents('dist/build/h5/index.html'); goto FeYZD; gEsQW: $KreWN = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $k8GtY . '/'); goto q8cCo; goazg: shell_throws_if('解析模块名称失败', empty($k8GtY)); goto ynyyK; Gmg_L: shell_echo_info('处理Head : ' . strlen($NpXe6) . ' -> ' . strlen($A6Z2b)); goto DOasy; uWAOL: shell_echo_info('清空目录'); goto C7Naz; C7Naz: passthru('rm -rfv ' . shell_module_path($k8GtY, 'Asset/static/')); goto a5FiJ; l223N: passthru('cp -av dist/build/h5/static ' . shell_module_path($k8GtY, 'Asset/static/')); goto GDSBJ; jCsZg: } }