<?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($fWYdy) { goto bfW9a; EaKaa: if ($k3CUX !== 0) { shell_echo_error('运行命令 ' . $fWYdy . ' 失败'); die(1); } goto RvBIF; bfW9a: shell_echo_info("开始运行 {$fWYdy}"); goto KOqMb; KOqMb: passthru($fWYdy, $k3CUX); goto EaKaa; RvBIF: } public static function build($DlTOm) { goto O4Li0; R4vPP: passthru('rm -rfv ' . shell_module_path($WQ9HU, 'Asset/static/')); goto frYzy; o1Qbm: $eTwx_ = file_get_contents('dist/build/h5/index.html'); goto jKdEW; ivYSi: shell_ensure_dir(shell_module_path($WQ9HU, 'Asset')); goto xw43Q; q7cXj: shell_throws_if('解析模块名称失败', empty($WQ9HU)); goto Uvm3s; U1G5y: shell_echo_block('开始编译'); goto jdURt; ceGIZ: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto TLxW9; Uvm3s: shell_echo_success('环境正常'); goto U1G5y; XmAmA: shell_throws_if('请进入 ' . $DlTOm . '目录再运行该脚本', getcwd() !== $DlTOm); goto YGo_9; ElUAQ: $ZI5AS = $Qie0V[2]; goto HOBz2; HOBz2: $Rt4t5 = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $WQ9HU . '/'); goto nZ5IY; IZvmM: $hP6r2 = str_replace(array_keys($Rt4t5), array_values($Rt4t5), $ZI5AS); goto RidnW; PZIVj: $utcjB = shell_module_path($WQ9HU, 'View/m/' . lcfirst($WQ9HU) . '/body.blade.php'); goto Vutly; UsXVE: shell_echo_block('检查环境'); goto XmAmA; hROEu: $UReQO = $Qie0V[1]; goto ElUAQ; QpYKE: self::runOrFail('npm run build:h5'); goto Q33sI; jdURt: self::runOrFail('npm install'); goto QpYKE; ckuAK: $MS7w0 = shell_module_path($WQ9HU, 'View/m/' . lcfirst($WQ9HU) . '/head.blade.php'); goto PZIVj; LNRZD: $Rt4t5 = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $WQ9HU . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $WQ9HU . '/static/'); goto cPnRC; frYzy: shell_echo_info('更新文件'); goto xQubO; jKdEW: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $eTwx_, $Qie0V); goto hROEu; xw43Q: shell_echo_info('清空目录'); goto R4vPP; xFcLU: shell_file_write($utcjB, $hP6r2); goto z0ESy; Vutly: shell_file_write($MS7w0, $gJXLJ); goto xFcLU; kL1uM: shell_echo_success('打包完成'); goto FWG4V; FWG4V: shell_echo_block('温馨提示'); goto ceGIZ; nZ5IY: $gJXLJ = str_replace(array_keys($Rt4t5), array_values($Rt4t5), $UReQO); goto IZvmM; TLxW9: shell_echo_info("php artisan modstart:module-install {$WQ9HU} --force"); goto gFnek; Q33sI: shell_echo_block('处理HTML文件'); goto o1Qbm; z0ESy: shell_echo_block('处理静态文件'); goto LNRZD; xQubO: passthru('cp -av dist/build/h5/static ' . shell_module_path($WQ9HU, 'Asset/static/')); goto kL1uM; fiDa9: shell_echo_info('处理Body : ' . strlen($ZI5AS) . ' -> ' . strlen($hP6r2)); goto ckuAK; Vgb53: shell_echo_block('更新模块静态资源'); goto ivYSi; O4Li0: $WQ9HU = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $DlTOm); goto UsXVE; ORJL7: foreach ($cKrwB as $x_XbT) { goto YB_xc; ge2j4: file_put_contents($x_XbT, $eTwx_); goto hZ210; TZOZD: $eTwx_ = file_get_contents($x_XbT); goto EbAZW; EbAZW: $eTwx_ = str_replace(array_keys($Rt4t5), array_values($Rt4t5), $eTwx_); goto ge2j4; YB_xc: shell_echo_info($x_XbT); goto TZOZD; hZ210: } goto Vgb53; RidnW: shell_echo_info('处理Head : ' . strlen($UReQO) . ' -> ' . strlen($gJXLJ)); goto fiDa9; YGo_9: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto xv4H9; cPnRC: $cKrwB = glob('dist/build/h5/static/js/*.js'); goto ORJL7; xv4H9: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto q7cXj; gFnek: } }