diff --git a/f_install/install.php b/f_install/install.php index 1332dd00..9fc504b3 100644 --- a/f_install/install.php +++ b/f_install/install.php @@ -3,51 +3,6 @@ namespace sammo; require(__DIR__.'/../vendor/autoload.php'); -set_time_limit(600); - -function tryNpmInstall() -{ - $npmResultPath = '../npm_recent.json.log'; - $packageJsonPath = '../package.json'; - $packageJsonLockPath = '../package-lock.json'; - - $packageJsonHash = hash_file('sha512', $packageJsonPath); - $timestamp = time(); - if (file_exists($npmResultPath) && file_exists($packageJsonLockPath)) { - do { - $result = json_decode(file_get_contents($npmResultPath)); - $oldJsonHash = $result->packageJsonHash; - $oldTimestamp = $result->updateTimestamp; - - //1. package.json 파일이 다르면 업데이트. - if ($packageJsonHash != $oldJsonHash) { - break; - } - - //2. package-lock.json 업데이트가 2주를 초과했다면 업데이트. - if($oldTimestamp + 60*60*24*14 < $timestamp){ - break; - } - - //그것도 아니라면 업데이트하지 않겠다. - return; - } while (0); - } - - exec("npm install", $output, $result_code); - if ($result_code != 0) { - Json::die([ - 'result' => false, - 'reason' => $output - ]); - } - - file_put_contents($npmResultPath, json_encode([ - 'packageJsonHash'=>$packageJsonHash, - 'updateTimestamp'=>$timestamp, - ])); -} -tryNpmInstall(); ?> diff --git a/install.php b/install.php index 30d65a2c..798a9c80 100644 --- a/install.php +++ b/install.php @@ -1,4 +1,65 @@ packageJsonHash; + $oldTimestamp = $result->updateTimestamp; + + //1. package.json 파일이 다르면 업데이트. + if ($packageJsonHash != $oldJsonHash) { + break; + } + + //2. package-lock.json 업데이트가 2주를 초과했다면 업데이트. + if($oldTimestamp + 60*60*24*14 < $timestamp){ + break; + } + + //그것도 아니라면 업데이트하지 않겠다. + return false; + } while (0); + } + + exec("npm install", $output, $result_code); + if ($result_code != 0) { + Json::die([ + 'result' => false, + 'reason' => $output + ]); + } + + file_put_contents($npmResultPath, json_encode([ + 'packageJsonHash'=>$packageJsonHash, + 'updateTimestamp'=>$timestamp, + ])); + return true; +} +function genJS() +{ + $command = "./node_modules/.bin/webpack build"; + + exec(($command), $output, $result_code); + if ($result_code != 0) { + Json::die([ + 'result' => false, + 'reason' => $output + ]); + } +} +if(tryNpmInstall()){ + genJS(); +} + header('location:f_install/install.php'); \ No newline at end of file diff --git a/j_updateServer.php b/j_updateServer.php index 319b7c28..a85beb00 100644 --- a/j_updateServer.php +++ b/j_updateServer.php @@ -67,7 +67,7 @@ function tryNpmInstall() } //그것도 아니라면 업데이트하지 않겠다. - return; + return false; } while (0); } @@ -83,12 +83,15 @@ function tryNpmInstall() 'packageJsonHash'=>$packageJsonHash, 'updateTimestamp'=>$timestamp, ])); + return true; } //묻고 따지지 않고 일단 npm install은 시도한다. //hwe 업데이트인 경우에만 한번 더 부른다. -tryNpmInstall(); +if(tryNpmInstall()){ + genJS(Util::array_last_key(ServConfig::getServerList())); +} $session = Session::requireLogin(null)->setReadOnly(); $request = $_POST + $_GET; diff --git a/webpack.config.cjs b/webpack.config.cjs index e62854be..7ce074eb 100644 --- a/webpack.config.cjs +++ b/webpack.config.cjs @@ -11,7 +11,7 @@ module.exports = (env, argv) => { const mode = argv.mode ?? 'production'; const tsDir = resolve(__dirname, `${target}/ts/`); const ingame_vue = { - name: 'ingame_vue', + name: `ingame_${target}_vue`, resolve: { extensions: [".ts", ".tsx", ".vue", ".js"], alias: { @@ -164,7 +164,7 @@ module.exports = (env, argv) => { }, }; const ingame = { - name: 'ingame', + name: `ingame_${target}`, resolve: { extensions: [".js", ".ts", ".tsx"], },