Files
web_hgdjb_h5/tests/deploy-scripts.test.mjs
2026-11-07 11:14:16 +07:00

43 lines
2.1 KiB
JavaScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
test("测试部署对齐 91 短剧打包方式,并使用熟果短剧目录", () => {
const deploy = readFileSync(new URL("../deploy_test.sh", import.meta.url), "utf8");
const run = readFileSync(new URL("../deploy/run.sh", import.meta.url), "utf8");
const update = readFileSync(new URL("../deploy/up_next_h5.sh", import.meta.url), "utf8");
assert.match(deploy, /root@172\.104\.181\.99/);
assert.match(deploy, /\/server\/web_sgdj\/h5/);
assert.match(deploy, /web_sgdj_h5\.tar\.gz/);
assert.match(deploy, /bash run\.sh/);
assert.match(deploy, /up_next_h5\.sh/);
assert.match(deploy, /--exclude='node_modules'/);
assert.match(deploy, /\.next-test\/BUILD_ID/);
assert.match(run, /APP_DIR=\/server\/web_sgdj\/h5/);
assert.match(run, /APP_NAME=web_sgdj_h5/);
assert.match(run, /"\$NPM" ci --omit=dev/);
assert.match(run, /\.next-test\/BUILD_ID/);
assert.match(update, /sgdj_next_h5/);
assert.match(update, /web_sgdj_h5\.tar\.gz/);
assert.match(update, /npm ci --omit=dev/);
});
test("正式服支持 pnpm pack:gz 一键打包并部署", () => {
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
const prod = readFileSync(new URL("../deploy_prod.sh", import.meta.url), "utf8");
const wrapper = readFileSync(new URL("../scripts/package-prod.sh", import.meta.url), "utf8");
const env = readFileSync(new URL("../config/production.env", import.meta.url), "utf8");
assert.equal(pkg.scripts["pack:gz"], "bash scripts/package-prod.sh");
assert.equal(pkg.scripts["pack:gz:only"], "bash scripts/package-prod.sh --package-only");
assert.match(wrapper, /deploy_prod\.sh/);
assert.match(prod, /--package-only\) PACKAGE_ONLY=1/);
assert.match(prod, /web_sgdj_h5\.tar\.gz/);
assert.match(prod, /server@34\.92\.204\.175/);
assert.match(prod, /\/home\/server\/web_sgdj\/h5/);
assert.match(prod, /bash rsupdate\.sh/);
assert.match(env, /API_PROXY_TARGET=https:\/\/webhgbapi\.mfcg\.me/);
assert.match(env, /PORT=21038/);
assert.match(env, /NEXT_PUBLIC_SITE_URL=https:\/\/huangguoduanju\.im/);
});