<?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($j4wOI) { goto cYAJ1; cYAJ1: shell_echo_info("开始运行 {$j4wOI}"); goto R7sV4; eU0yA: if ($gdMPv !== 0) { shell_echo_error('运行命令 ' . $j4wOI . ' 失败'); die(1); } goto yptLW; R7sV4: passthru($j4wOI, $gdMPv); goto eU0yA; yptLW: } public static function build($BJC7d) { goto saSQF; JMLqS: $NC0nf = str_replace(array_keys($cLAmS), array_values($cLAmS), $Rqm5X); goto Xuky0; wnRF8: $ofGoS = shell_module_path($z_J2N, 'View/m/' . lcfirst($z_J2N) . '/body.blade.php'); goto VLy1s; saSQF: $z_J2N = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $BJC7d); goto DZYuc; WOReG: $QxXQB = glob('dist/build/h5/static/js/*.js'); goto s357i; HT8UC: shell_echo_success('环境正常'); goto YEzMc; Su0ZZ: shell_ensure_dir(shell_module_path($z_J2N, 'Asset')); goto TH0xb; YEzMc: shell_echo_block('开始编译'); goto wDh0Z; ODJKw: $Ral1i = file_get_contents('dist/build/h5/index.html'); goto VZfIy; sls99: passthru('cp -av dist/build/h5/static ' . shell_module_path($z_J2N, 'Asset/static/')); goto bWKXm; V4hiu: shell_echo_block('处理HTML文件'); goto ODJKw; YG_3p: shell_echo_block('温馨提示'); goto Nt9fP; s357i: foreach ($QxXQB as $wjJPd) { goto mOKz1; mVDs4: file_put_contents($wjJPd, $Ral1i); goto Tronr; rRtlS: $Ral1i = file_get_contents($wjJPd); goto veYuw; mOKz1: shell_echo_info($wjJPd); goto rRtlS; veYuw: $Ral1i = str_replace(array_keys($cLAmS), array_values($cLAmS), $Ral1i); goto mVDs4; Tronr: } goto kykOw; kykOw: shell_echo_block('更新模块静态资源'); goto Su0ZZ; kB1B3: shell_echo_info('处理Head : ' . strlen($Rqm5X) . ' -> ' . strlen($NC0nf)); goto sltQ0; VLy1s: shell_file_write($ag7D8, $NC0nf); goto Mv98S; VZfIy: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $Ral1i, $oxpiO); goto kQ2a0; U7Kk_: passthru('rm -rfv ' . shell_module_path($z_J2N, 'Asset/static/')); goto acvMt; sltQ0: shell_echo_info('处理Body : ' . strlen($kLqG9) . ' -> ' . strlen($eZic4)); goto MmM8j; acvMt: shell_echo_info('更新文件'); goto sls99; Mv98S: shell_file_write($ofGoS, $eZic4); goto f7B1p; weTsZ: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto j28G_; fCLy8: $cLAmS = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $z_J2N . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $z_J2N . '/static/'); goto WOReG; wDh0Z: self::runOrFail('npm install'); goto K1qU5; j28G_: shell_throws_if('解析模块名称失败', empty($z_J2N)); goto HT8UC; XnEiC: shell_echo_info("php artisan modstart:module-install {$z_J2N} --force"); goto I6UhY; bWKXm: shell_echo_success('打包完成'); goto YG_3p; T35lp: $kLqG9 = $oxpiO[2]; goto g7hN0; g7hN0: $cLAmS = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $z_J2N . '/'); goto JMLqS; DZYuc: shell_echo_block('检查环境'); goto Oet2A; kQ2a0: $Rqm5X = $oxpiO[1]; goto T35lp; K1qU5: self::runOrFail('npm run build:h5'); goto V4hiu; TH0xb: shell_echo_info('清空目录'); goto U7Kk_; Xuky0: $eZic4 = str_replace(array_keys($cLAmS), array_values($cLAmS), $kLqG9); goto kB1B3; OCvDp: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto weTsZ; f7B1p: shell_echo_block('处理静态文件'); goto fCLy8; Oet2A: shell_throws_if('请进入 ' . $BJC7d . '目录再运行该脚本', getcwd() !== $BJC7d); goto OCvDp; MmM8j: $ag7D8 = shell_module_path($z_J2N, 'View/m/' . lcfirst($z_J2N) . '/head.blade.php'); goto wnRF8; Nt9fP: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto XnEiC; I6UhY: } }