<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Developer; use ModStart\Core\Util\PlatformUtil; use ModStart\Core\Util\ReUtil; include_once __DIR__ . '/../Shell/include.php'; class UniappUtil { public static function runOrFail($Wfnzb) { goto Km4OU; gH5DH: passthru($Wfnzb, $nO7Qf); goto ltwQt; Km4OU: shell_echo_info("开始运行 {$Wfnzb}"); goto gH5DH; ltwQt: if ($nO7Qf !== 0) { shell_echo_error('运行命令 ' . $Wfnzb . ' 失败'); die(1); } goto mx0Kf; mx0Kf: } public static function build($LaRMD) { goto gcc7e; q7S9E: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $V0Dls, $YpeHe); goto iilE6; HHM2y: shell_throws_if('请进入 ' . $LaRMD . '目录再运行该脚本', getcwd() !== $LaRMD); goto jKN2I; P0g5L: passthru('cp -av dist/build/h5/static ' . shell_module_path($FgH5V, 'Asset/static/')); goto wPBA3; VCw0f: shell_echo_block('处理HTML文件'); goto agaZx; Mxb4n: shell_file_write($zcECg, $qsV4g); goto ta36j; agaZx: $V0Dls = file_get_contents('dist/build/h5/index.html'); goto q7S9E; ex1Pr: passthru('rm -rfv ' . shell_module_path($FgH5V, 'Asset/static/')); goto dZDtm; aJ2Xk: $sw1W0 = shell_module_path($FgH5V, 'View/m/' . lcfirst($FgH5V) . '/head.blade.php'); goto lwyW9; eNiZe: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto BAgEX; ta36j: shell_echo_block('处理静态文件'); goto J_xgU; enOTk: foreach ($nHAO4 as $okURS) { goto FLPp0; NPZ4L: file_put_contents($okURS, $V0Dls); goto JuZew; tkt1P: $V0Dls = str_replace(array_keys($JwicM), array_values($JwicM), $V0Dls); goto NPZ4L; trPEw: $V0Dls = file_get_contents($okURS); goto tkt1P; FLPp0: shell_echo_info($okURS); goto trPEw; JuZew: } goto VueA9; BAgEX: shell_throws_if('解析模块名称失败', empty($FgH5V)); goto Wy9yy; VueA9: shell_echo_block('更新模块静态资源'); goto wTptf; TyX46: shell_echo_info('处理Body : ' . strlen($yGKLN) . ' -> ' . strlen($qsV4g)); goto aJ2Xk; jKN2I: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto eNiZe; dZDtm: shell_echo_info('更新文件'); goto P0g5L; K2Kcb: shell_echo_info('清空目录'); goto ex1Pr; D741h: self::runOrFail('npm run build:h5'); goto VCw0f; J_xgU: $JwicM = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $FgH5V . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $FgH5V . '/static/'); goto BiBXd; FuI5z: shell_file_write($sw1W0, $g9cpI); goto Mxb4n; dtdmQ: shell_echo_info('处理Head : ' . strlen($uozlB) . ' -> ' . strlen($g9cpI)); goto TyX46; iilE6: $uozlB = $YpeHe[1]; goto S5ezf; jItQT: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto yDMh6; S5ezf: $yGKLN = $YpeHe[2]; goto t1a84; zeXUh: shell_echo_block('检查环境'); goto HHM2y; BiBXd: $nHAO4 = glob('dist/build/h5/static/js/*.js'); goto enOTk; lwyW9: $zcECg = shell_module_path($FgH5V, 'View/m/' . lcfirst($FgH5V) . '/body.blade.php'); goto FuI5z; wTptf: shell_ensure_dir(shell_module_path($FgH5V, 'Asset')); goto K2Kcb; gtS_Y: shell_echo_block('温馨提示'); goto jItQT; gcc7e: $FgH5V = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $LaRMD); goto zeXUh; O5HiX: shell_echo_block('开始编译'); goto VD2yd; ui_nF: $g9cpI = str_replace(array_keys($JwicM), array_values($JwicM), $uozlB); goto PwyOS; VD2yd: self::runOrFail('npm install'); goto D741h; wPBA3: shell_echo_success('打包完成'); goto gtS_Y; yDMh6: shell_echo_info("php artisan modstart:module-install {$FgH5V} --force"); goto Muw7S; Wy9yy: shell_echo_success('环境正常'); goto O5HiX; t1a84: $JwicM = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $FgH5V . '/'); goto ui_nF; PwyOS: $qsV4g = str_replace(array_keys($JwicM), array_values($JwicM), $yGKLN); goto dtdmQ; Muw7S: } }