<?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($d2exE) { goto J33hg; J33hg: shell_echo_info("开始运行 {$d2exE}"); goto DjgKX; way6S: if ($sPm4u !== 0) { shell_echo_error('运行命令 ' . $d2exE . ' 失败'); die(1); } goto Y08fr; DjgKX: passthru($d2exE, $sPm4u); goto way6S; Y08fr: } public static function build($upRcy) { goto E5I2l; Ls2N9: shell_throws_if('解析模块名称失败', empty($Ua5sf)); goto p7QUX; Rd25Y: shell_echo_block('处理HTML文件'); goto ENpho; Ubqi9: shell_echo_info('更新文件'); goto t9qeu; qkiMW: shell_echo_info('清空目录'); goto shmvz; X8Df9: self::runOrFail('npm install'); goto MQFOQ; FhF0L: $XIQOi = shell_module_path($Ua5sf, 'View/m/' . lcfirst($Ua5sf) . '/body.blade.php'); goto wAGHv; cP_5e: shell_echo_block('温馨提示'); goto R89ga; wAGHv: shell_file_write($VbfIl, $f0K5N); goto QmP_L; QmP_L: shell_file_write($XIQOi, $BVfh1); goto eQCrj; ENpho: $OfwYj = file_get_contents('dist/build/h5/index.html'); goto e96dt; ZaDVQ: $f0K5N = str_replace(array_keys($yXZDa), array_values($yXZDa), $DIGLT); goto Zr20C; nCdEB: shell_echo_info('处理Head : ' . strlen($DIGLT) . ' -> ' . strlen($f0K5N)); goto Mtr6R; kMkUE: $N_VNZ = glob('dist/build/h5/static/js/*.js'); goto lU0y5; shmvz: passthru('rm -rfv ' . shell_module_path($Ua5sf, 'Asset/static/')); goto Ubqi9; E5I2l: $Ua5sf = ReUtil::group1('/module[\\/\\\\](.*?)[\\/\\\\]resources/', $upRcy); goto keE3g; aKiO_: $yXZDa = array('"__cdn_url__/"' => 'window.__msCDN+"vendor/' . $Ua5sf . '/"', '"/static/' => 'window.__msCDN+"vendor/' . $Ua5sf . '/static/'); goto kMkUE; keE3g: shell_echo_block('检查环境'); goto IGJmT; T5JIt: shell_echo_block('开始编译'); goto X8Df9; OJR2z: shell_ensure_dir(shell_module_path($Ua5sf, 'Asset')); goto qkiMW; CqucW: shell_echo_info("php artisan modstart:module-install {$Ua5sf} --force"); goto UuJuF; lU0y5: foreach ($N_VNZ as $SgkW3) { goto zzte3; B3BhH: $OfwYj = str_replace(array_keys($yXZDa), array_values($yXZDa), $OfwYj); goto ikldM; ikldM: file_put_contents($SgkW3, $OfwYj); goto nrx7p; zzte3: shell_echo_info($SgkW3); goto MhIxI; MhIxI: $OfwYj = file_get_contents($SgkW3); goto B3BhH; nrx7p: } goto QRrdX; R89ga: shell_echo_info('如果您的正在运行的网站还没有更新静态资源，您需要运行如下命令更新模块静态资源'); goto CqucW; chhim: $yXZDa = array('__cdn_url__/' => '{{\\ModStart\\Core\\Assets\\AssetsUtil::cdn()}}vendor/' . $Ua5sf . '/'); goto ZaDVQ; U3a6f: $DIGLT = $QuDiu[1]; goto xT0Jw; t9qeu: passthru('cp -av dist/build/h5/static ' . shell_module_path($Ua5sf, 'Asset/static/')); goto XojH8; eQCrj: shell_echo_block('处理静态文件'); goto aKiO_; MQFOQ: self::runOrFail('npm run build:h5'); goto Rd25Y; Zr20C: $BVfh1 = str_replace(array_keys($yXZDa), array_values($yXZDa), $amxbk); goto nCdEB; ykeAG: shell_throws_if('请安装 nodejs，安装后自检 npm --version 输出正确', !shell_command_check('npm --version')); goto Ls2N9; QRrdX: shell_echo_block('更新模块静态资源'); goto OJR2z; xT0Jw: $amxbk = $QuDiu[2]; goto chhim; IGJmT: shell_throws_if('请进入 ' . $upRcy . '目录再运行该脚本', getcwd() !== $upRcy); goto L1Y9r; L1Y9r: shell_throws_if('系统只持支Linux和OSX', !PlatformUtil::isType(array(PlatformUtil::LINUX, PlatformUtil::OSX))); goto ykeAG; e96dt: preg_match('/<head>([\\s\\S]+)<\\/head>[\\s\\S]*<body>([\\s\\S]+)<\\/body>/', $OfwYj, $QuDiu); goto U3a6f; to5ET: $VbfIl = shell_module_path($Ua5sf, 'View/m/' . lcfirst($Ua5sf) . '/head.blade.php'); goto FhF0L; XojH8: shell_echo_success('打包完成'); goto cP_5e; Mtr6R: shell_echo_info('处理Body : ' . strlen($amxbk) . ' -> ' . strlen($BVfh1)); goto to5ET; p7QUX: shell_echo_success('环境正常'); goto T5JIt; UuJuF: } }