<?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($Wfnzb) { goto Ename; Ev0mw: if ($nO7Qf !== 0) { shell_echo_error('运行命令 ' . $Wfnzb . ' 失败'); die(1); } goto uZ9Q_; fIi47: passthru($Wfnzb, $nO7Qf); goto Ev0mw; Ename: shell_echo_info("开始运行 {$Wfnzb}"); goto fIi47; uZ9Q_: } public static function build($LaRMD) { goto N37jW; sr0V0: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto ATPfh; ckWS_: shell_echo_block('开始编译'); goto Cr90e; Cr90e: self::runOrFail('npm install'); goto oSdcd; rwa7v: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto f1wtP; imwGe: shell_throws_if('请进入 ' . $LaRMD . '目录再运行该脚本', getcwd() !== $LaRMD); goto S75XE; vICDS: $sw1W0 = shell_module_path($FgH5V, 'View/m/' . lcfirst($FgH5V) . '/head.blade.php'); goto hfQuP; I2hbj: shell_echo_block('更新模块静态资源'); goto AHgdl; hfQuP: $zcECg = shell_module_path($FgH5V, 'View/m/' . lcfirst($FgH5V) . '/body.blade.php'); goto TaUaF; Ni1lp: shell_echo_success('环境正常'); goto ckWS_; ikwGY: shell_echo_block('温馨提示'); goto rwa7v; dO40I: $yGKLN = $YpeHe[2]; goto VMPRP; PGPf8: shell_echo_block('处理HTML文件'); goto CoAMG; AHgdl: shell_ensure_dir(shell_module_path($FgH5V, 'Asset')); goto tLkF7; dS_q4: shell_echo_success('打包完成'); goto ikwGY; TaUaF: shell_file_write($sw1W0, $g9cpI); goto emRId; HnUBH: $g9cpI = str_replace(array_keys($JwicM), array_values($JwicM), $uozlB); goto vJKo2; rkcCx: shell_echo_info('更新文件'); goto rmDIL; CoAMG: $V0Dls = file_get_contents('dist/build/h5/index.html'); goto JA3ko; iMLw4: $nHAO4 = glob('dist/build/h5/static/js/*.js'); goto yILW2; WU49u: shell_echo_block('处理静态文件'); goto XQ485; XQ485: $JwicM = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $FgH5V . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $FgH5V . '/static/'); goto iMLw4; yILW2: foreach ($nHAO4 as $okURS) { goto XmjAT; XmjAT: shell_echo_info($okURS); goto sZJe9; jypL1: $V0Dls = str_replace(array_keys($JwicM), array_values($JwicM), $V0Dls); goto Lnezb; sZJe9: $V0Dls = file_get_contents($okURS); goto jypL1; Lnezb: file_put_contents($okURS, $V0Dls); goto fVibt; fVibt: } goto I2hbj; jgeBQ: $uozlB = $YpeHe[1]; goto dO40I; f1wtP: shell_echo_info("php artisan modstart:module-install {$FgH5V} --force"); goto Iey4C; N37jW: $FgH5V = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $LaRMD); goto M4lrR; JA3ko: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $V0Dls, $YpeHe); goto jgeBQ; rmDIL: passthru('cp -av dist/build/h5/static ' . shell_module_path($FgH5V, 'Asset/static/')); goto dS_q4; iDKIm: passthru('rm -rfv ' . shell_module_path($FgH5V, 'Asset/static/')); goto rkcCx; ATPfh: shell_throws_if('解析模块名称失败', empty($FgH5V)); goto Ni1lp; tLkF7: shell_echo_info('清空目录'); goto iDKIm; M4lrR: shell_echo_block('检查环境'); goto imwGe; emRId: shell_file_write($zcECg, $qsV4g); goto WU49u; vJKo2: $qsV4g = str_replace(array_keys($JwicM), array_values($JwicM), $yGKLN); goto OXcPq; oSdcd: self::runOrFail('npm run build:h5'); goto PGPf8; S75XE: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto sr0V0; VMPRP: $JwicM = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $FgH5V . '/'); goto HnUBH; OXcPq: shell_echo_info('处理Head : ' . strlen($uozlB) . ' -> ' . strlen($g9cpI)); goto SnTEm; SnTEm: shell_echo_info('处理Body : ' . strlen($yGKLN) . ' -> ' . strlen($qsV4g)); goto vICDS; Iey4C: } }