<?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($ZsyG0) { goto uKOy0; uKOy0: shell_echo_info("开始运行 {$ZsyG0}"); goto UzofK; UzofK: passthru($ZsyG0, $QfmtB); goto j_luM; j_luM: if ($QfmtB !== 0) { shell_echo_error('运行命令 ' . $ZsyG0 . ' 失败'); die(1); } goto u4DEz; u4DEz: } public static function build($B13iK) { goto I3ZxE; I3ZxE: $ltDK0 = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $B13iK); goto yV4pG; cMOOu: passthru('cp -av dist/build/h5/static ' . shell_module_path($ltDK0, 'Asset/static/')); goto UQH0j; R_A9D: shell_echo_block('处理静态文件'); goto Anjbr; Anjbr: $ndv7A = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $ltDK0 . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $ltDK0 . '/static/'); goto WFqh3; P9FSM: self::runOrFail('npm run build:h5'); goto Co5Z9; bNg_s: shell_ensure_dir(shell_module_path($ltDK0, 'Asset')); goto NtkaU; Uezmn: shell_file_write($Amriu, $OhG1S); goto R_A9D; UQH0j: shell_echo_success('打包完成'); goto FLldy; YUBjn: $qhTwW = $hId04[2]; goto JDVTW; bnQQw: shell_echo_block('开始编译'); goto TNeyD; ef8x2: $kr_BV = str_replace(array_keys($ndv7A), array_values($ndv7A), $VZx3h); goto i9aso; JDVTW: $ndv7A = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $ltDK0 . '/'); goto ef8x2; SgVEX: $ayO0_ = shell_module_path($ltDK0, 'View/m/' . lcfirst($ltDK0) . '/head.blade.php'); goto EILGq; ROsLh: shell_echo_success('环境正常'); goto bnQQw; Co5Z9: shell_echo_block('处理HTML文件'); goto lRCkQ; UtpOw: shell_file_write($ayO0_, $kr_BV); goto Uezmn; TNeyD: self::runOrFail('npm install'); goto P9FSM; WFqh3: $wgUQc = glob('dist/build/h5/static/js/*.js'); goto bjrlS; FLldy: shell_echo_block('温馨提示'); goto xQDH4; IK7S5: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto l1w6s; NtkaU: shell_echo_info('清空目录'); goto CU1FK; EILGq: $Amriu = shell_module_path($ltDK0, 'View/m/' . lcfirst($ltDK0) . '/body.blade.php'); goto UtpOw; GSBpI: $VZx3h = $hId04[1]; goto YUBjn; i9aso: $OhG1S = str_replace(array_keys($ndv7A), array_values($ndv7A), $qhTwW); goto yTnxm; retwb: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $ybjC4, $hId04); goto GSBpI; yTnxm: shell_echo_info('处理Head : ' . strlen($VZx3h) . ' -> ' . strlen($kr_BV)); goto ivuVB; ivuVB: shell_echo_info('处理Body : ' . strlen($qhTwW) . ' -> ' . strlen($OhG1S)); goto SgVEX; CU1FK: passthru('rm -rfv ' . shell_module_path($ltDK0, 'Asset/static/')); goto VGX58; lRCkQ: $ybjC4 = file_get_contents('dist/build/h5/index.html'); goto retwb; bjrlS: foreach ($wgUQc as $bHKYd) { goto OtPmK; NQoMi: file_put_contents($bHKYd, $ybjC4); goto ELhVK; OtPmK: shell_echo_info($bHKYd); goto qe4h3; O0l4q: $ybjC4 = str_replace(array_keys($ndv7A), array_values($ndv7A), $ybjC4); goto NQoMi; qe4h3: $ybjC4 = file_get_contents($bHKYd); goto O0l4q; ELhVK: } goto kl95y; yV4pG: shell_echo_block('检查环境'); goto qrNI1; xQDH4: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto DR6eV; l1w6s: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto G438R; DR6eV: shell_echo_info("php artisan modstart:module-install {$ltDK0} --force"); goto faFCB; qrNI1: shell_throws_if('请进入 ' . $B13iK . '目录再运行该脚本', getcwd() !== $B13iK); goto IK7S5; G438R: shell_throws_if('解析模块名称失败', empty($ltDK0)); goto ROsLh; VGX58: shell_echo_info('更新文件'); goto cMOOu; kl95y: shell_echo_block('更新模块静态资源'); goto bNg_s; faFCB: } }