<?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($j4wOI) { goto Ah3Bb; HCk95: passthru($j4wOI, $gdMPv); goto xqp9B; Ah3Bb: shell_echo_info("开始运行 {$j4wOI}"); goto HCk95; xqp9B: if ($gdMPv !== 0) { shell_echo_error('运行命令 ' . $j4wOI . ' 失败'); die(1); } goto GvYEQ; GvYEQ: } public static function build($BJC7d) { goto rgoC8; IWK61: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $Ral1i, $oxpiO); goto NCimP; VS8Qa: $ag7D8 = shell_module_path($z_J2N, 'View/m/' . lcfirst($z_J2N) . '/head.blade.php'); goto iK3Wh; FaX4_: passthru('cp -av dist/build/h5/static ' . shell_module_path($z_J2N, 'Asset/static/')); goto PJurC; UroyJ: foreach ($QxXQB as $wjJPd) { goto mqyZj; QEtmT: $Ral1i = file_get_contents($wjJPd); goto ovbo_; iYfMr: file_put_contents($wjJPd, $Ral1i); goto bhiAk; mqyZj: shell_echo_info($wjJPd); goto QEtmT; ovbo_: $Ral1i = str_replace(array_keys($cLAmS), array_values($cLAmS), $Ral1i); goto iYfMr; bhiAk: } goto TcncT; FeKXz: shell_echo_info('清空目录'); goto JnkGT; GHe6i: shell_echo_block('处理静态文件'); goto tUTK3; RiE4t: shell_echo_block('温馨提示'); goto O0fNW; QCmL3: shell_echo_info('处理Head : ' . strlen($Rqm5X) . ' -> ' . strlen($NC0nf)); goto a02CI; KnlFr: shell_throws_if('解析模块名称失败', empty($z_J2N)); goto DwzHV; sGAL0: $NC0nf = str_replace(array_keys($cLAmS), array_values($cLAmS), $Rqm5X); goto Gt3h8; qW38r: shell_echo_block('开始编译'); goto zzrxB; R3pAg: shell_file_write($ag7D8, $NC0nf); goto SiiHK; tmSWB: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto KnlFr; EY9mm: shell_echo_info("php artisan modstart:module-install {$z_J2N} --force"); goto i2GK8; iT9EF: $QxXQB = glob('dist/build/h5/static/js/*.js'); goto UroyJ; tUTK3: $cLAmS = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $z_J2N . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $z_J2N . '/static/'); goto iT9EF; UzZwN: shell_echo_info('更新文件'); goto FaX4_; PJurC: shell_echo_success('打包完成'); goto RiE4t; SiiHK: shell_file_write($ofGoS, $eZic4); goto GHe6i; D47MY: $cLAmS = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $z_J2N . '/'); goto sGAL0; JnkGT: passthru('rm -rfv ' . shell_module_path($z_J2N, 'Asset/static/')); goto UzZwN; Y1GYy: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto tmSWB; O0fNW: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto EY9mm; iK3Wh: $ofGoS = shell_module_path($z_J2N, 'View/m/' . lcfirst($z_J2N) . '/body.blade.php'); goto R3pAg; DwzHV: shell_echo_success('环境正常'); goto qW38r; zzrxB: self::runOrFail('npm install'); goto ItdDd; rgoC8: $z_J2N = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $BJC7d); goto menDL; yXZOh: shell_ensure_dir(shell_module_path($z_J2N, 'Asset')); goto FeKXz; Gt3h8: $eZic4 = str_replace(array_keys($cLAmS), array_values($cLAmS), $kLqG9); goto QCmL3; ItdDd: self::runOrFail('npm run build:h5'); goto MiD8u; a02CI: shell_echo_info('处理Body : ' . strlen($kLqG9) . ' -> ' . strlen($eZic4)); goto VS8Qa; a9XI2: shell_throws_if('请进入 ' . $BJC7d . '目录再运行该脚本', getcwd() !== $BJC7d); goto Y1GYy; nIP6J: $Ral1i = file_get_contents('dist/build/h5/index.html'); goto IWK61; NCimP: $Rqm5X = $oxpiO[1]; goto iVffG; TcncT: shell_echo_block('更新模块静态资源'); goto yXZOh; MiD8u: shell_echo_block('处理HTML文件'); goto nIP6J; menDL: shell_echo_block('检查环境'); goto a9XI2; iVffG: $kLqG9 = $oxpiO[2]; goto D47MY; i2GK8: } }