<?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($ZsyG0) { goto VKnIs; QEcUZ: passthru($ZsyG0, $QfmtB); goto vuIZo; VKnIs: shell_echo_info("开始运行 {$ZsyG0}"); goto QEcUZ; vuIZo: if ($QfmtB !== 0) { shell_echo_error('运行命令 ' . $ZsyG0 . ' 失败'); die(1); } goto z8ODO; z8ODO: } public static function build($B13iK) { goto vJTU7; B92UO: passthru('cp -av dist/build/h5/static ' . shell_module_path($ltDK0, 'Asset/static/')); goto Jat5d; FqlFy: $ybjC4 = file_get_contents('dist/build/h5/index.html'); goto RixRa; LVEY_: $qhTwW = $hId04[2]; goto cf_IT; G22_k: $ndv7A = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $ltDK0 . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $ltDK0 . '/static/'); goto MCqgI; k7bMS: $Amriu = shell_module_path($ltDK0, 'View/m/' . lcfirst($ltDK0) . '/body.blade.php'); goto bHnC9; AJNkh: $VZx3h = $hId04[1]; goto LVEY_; Zk83r: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto rlJIv; MCqgI: $wgUQc = glob('dist/build/h5/static/js/*.js'); goto uArfQ; hoyL1: shell_echo_block('检查环境'); goto K69D4; cmmaZ: shell_echo_info('处理Head : ' . strlen($VZx3h) . ' -> ' . strlen($kr_BV)); goto YeOi1; uArfQ: foreach ($wgUQc as $bHKYd) { goto yvp2H; yvp2H: shell_echo_info($bHKYd); goto LmrDo; OJhvX: file_put_contents($bHKYd, $ybjC4); goto vStyf; LmrDo: $ybjC4 = file_get_contents($bHKYd); goto mQhKc; mQhKc: $ybjC4 = str_replace(array_keys($ndv7A), array_values($ndv7A), $ybjC4); goto OJhvX; vStyf: } goto uzzNs; zA1OZ: $ayO0_ = shell_module_path($ltDK0, 'View/m/' . lcfirst($ltDK0) . '/head.blade.php'); goto k7bMS; lQvwo: shell_echo_info('更新文件'); goto B92UO; rfpIe: $kr_BV = str_replace(array_keys($ndv7A), array_values($ndv7A), $VZx3h); goto XvEoX; QRIfx: self::runOrFail('npm install'); goto ujn3H; Jat5d: shell_echo_success('打包完成'); goto gIGZt; cBFj7: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto feXgv; rlJIv: shell_throws_if('解析模块名称失败', empty($ltDK0)); goto Be2fV; XvEoX: $OhG1S = str_replace(array_keys($ndv7A), array_values($ndv7A), $qhTwW); goto cmmaZ; cf_IT: $ndv7A = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $ltDK0 . '/'); goto rfpIe; gIGZt: shell_echo_block('温馨提示'); goto cBFj7; RixRa: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $ybjC4, $hId04); goto AJNkh; xFfGh: shell_echo_block('开始编译'); goto QRIfx; YeOi1: shell_echo_info('处理Body : ' . strlen($qhTwW) . ' -> ' . strlen($OhG1S)); goto zA1OZ; Be2fV: shell_echo_success('环境正常'); goto xFfGh; HOylc: shell_file_write($Amriu, $OhG1S); goto jywIQ; vJTU7: $ltDK0 = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $B13iK); goto hoyL1; hOYsI: shell_echo_block('处理HTML文件'); goto FqlFy; gOHZg: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX, PlatformUtil::WINDOWS))); goto Zk83r; bHnC9: shell_file_write($ayO0_, $kr_BV); goto HOylc; QXO05: passthru('rm -rfv ' . shell_module_path($ltDK0, 'Asset/static/')); goto lQvwo; ujn3H: self::runOrFail('npm run build:h5'); goto hOYsI; WkFZJ: shell_echo_info('清空目录'); goto QXO05; eDugj: shell_ensure_dir(shell_module_path($ltDK0, 'Asset')); goto WkFZJ; feXgv: shell_echo_info("php artisan modstart:module-install {$ltDK0} --force"); goto JPneR; uzzNs: shell_echo_block('更新模块静态资源'); goto eDugj; jywIQ: shell_echo_block('处理静态文件'); goto G22_k; K69D4: shell_throws_if('请进入 ' . $B13iK . '目录再运行该脚本', getcwd() !== $B13iK); goto gOHZg; JPneR: } }