chore: add script to deploy preview frontend

This commit is contained in:
Miodec 2025-12-10 14:35:22 +01:00
parent 1d3abf3f43
commit d997ae8746
3 changed files with 31 additions and 2 deletions

View file

@ -15,8 +15,6 @@
"madge": " madge --circular --extensions ts ./src",
"start": "vite preview --port 3000",
"dev": "vite dev",
"deploy-live": "npm run check-assets && npm run build && firebase deploy -P live --only hosting",
"deploy-preview": "npm run check-assets && npm run build && firebase hosting:channel:deploy preview -P live --expires 2h",
"test": "vitest run",
"test-coverage": "vitest run --coverage",
"dev-test": "concurrently --kill-others \"vite dev\" \"vitest\"",

View file

@ -34,6 +34,7 @@
"start-fe": "turbo run start --filter @monkeytype/frontend",
"docker": "cd backend && npm run docker",
"audit-fe": "cd frontend && npm run audit",
"preview-fe": "monkeytype-release --preview-fe",
"release": "monkeytype-release",
"release-fe": "monkeytype-release --fe",
"release-be": "monkeytype-release --be",

View file

@ -20,6 +20,7 @@ const isBackend = args.has("--be");
const isDryRun = args.has("--dry");
const noSyncCheck = args.has("--no-sync-check");
const hotfix = args.has("--hotfix");
const previewFe = args.has("--preview-fe");
const PROJECT_ROOT = path.resolve(__dirname, "../../../");
@ -252,6 +253,35 @@ const createGithubRelease = async (version, changelogContent) => {
};
const main = async () => {
if (previewFe) {
console.log(`Starting frontend preview deployment process...`);
checkUncommittedChanges();
installDependencies();
runProjectRootCommand(
"NODE_ENV=production npx turbo lint test check-assets build --filter @monkeytype/frontend --force",
);
const name = readlineSync.question(
"Enter preview channel name (default: preview): ",
);
const channelName = name.trim() || "preview";
const expirationTime = readlineSync.question(
"Enter expiration time (e.g., 2h, default: 1d): ",
);
const expires = expirationTime.trim() || "1d";
console.log(
`Deploying frontend preview to channel "${channelName}" with expiration "${expires}"...`,
);
const result = runProjectRootCommand(
`cd frontend && npx firebase hosting:channel:deploy ${channelName} -P live --expires ${expires}`,
);
console.log(result);
console.log("Frontend preview deployed successfully.");
process.exit(0);
}
console.log(`Starting ${hotfix ? "hotfix" : "release"} process...`);
if (!hotfix) checkBranchSync();