Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit ec98d0c

Browse files
committed
chore: expose vite base url in env in release.ts (#383)
1 parent 26041b7 commit ec98d0c

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ dist
3636
!.yarn/sdks
3737
!.yarn/versions
3838

39-
.env
4039
.env.test
4140
.env.yarn
42-
.env*.local
41+
.env*.local

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This will open `http://localhost:5080` in your browser. By default, this will co
3131

3232
## Environment variables configuration
3333

34-
1. Copy `apps/hub/.env.example` to `apps/hub/.env` and change variables if needed.
34+
1. Copy `apps/hub/.env.example` to `apps/hub/.env.development.local` and change variables if needed.
3535

3636
## Developing with self-hosted backend
3737

apps/hub/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc && vite build",
8+
"build": "tsc && vite build --mode=development",
9+
"build:prod": "tsc && vite build --mode=production",
910
"preview": "vite preview"
1011
},
1112
"dependencies": {

deno.lock

+15-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/release.ts

+22-10
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function getGitHash(): Promise<string> {
3535
return new TextDecoder().decode(gitOutput.stdout).trim();
3636
}
3737

38-
async function runBuild() {
38+
async function runBuild(baseUrl = "/") {
3939
console.log("Running yarn install");
4040
const installOutput = await new Deno.Command("yarn", {
4141
args: ["install"],
@@ -47,9 +47,11 @@ async function runBuild() {
4747
}).output();
4848
assert(installOutput.success, "Failed to run yarn install");
4949

50-
console.log("Running yarn build");
50+
console.log(
51+
`Running yarn build${baseUrl ? ` with base URL: ${baseUrl}` : ""}`,
52+
);
5153
const buildOutput = await new Deno.Command("yarn", {
52-
args: ["run", "build"],
54+
args: ["run", "build:prod", `--base=${baseUrl}`],
5355
stdout: "inherit",
5456
stderr: "inherit",
5557
env: {
@@ -66,14 +68,17 @@ async function runBuild() {
6668
assert(buildOutput.success, "Failed to run yarn build");
6769
}
6870

69-
async function generateZipFile(): Promise<string> {
71+
async function generateZipFile(variant: string): Promise<string> {
7072
const gitHash = await getGitHash();
7173
const timestamp = format(new Date(), "yyyy-MM-dd-HH-mm-ss", {
7274
timeZone: "UTC",
7375
});
74-
const fileName = `${timestamp}-${gitHash}.zip`;
75-
console.log("Generating zip file");
76-
const zipPath = resolve(fileName);
76+
const fileName = `${timestamp}-${gitHash}-${variant}.zip`;
77+
console.log(`Generating zip file: ${fileName}`);
78+
79+
const tempDir = await Deno.makeTempDir();
80+
const zipPath = resolve(tempDir, fileName);
81+
7782
const zipOutput = await new Deno.Command("zip", {
7883
args: ["-r", zipPath, "."],
7984
cwd: DIST_DIR,
@@ -111,10 +116,17 @@ async function uploadZipToS3(zipPath: string): Promise<string> {
111116
}
112117

113118
async function main() {
119+
// Build and upload the normal variant
114120
await runBuild();
115-
const zipPath = await generateZipFile();
116-
const zipUrl = await uploadZipToS3(zipPath);
117-
console.log("Uploaded zip URL:", zipUrl);
121+
const normalZipPath = await generateZipFile("default");
122+
const normalZipUrl = await uploadZipToS3(normalZipPath);
123+
console.log("Uploaded normal variant zip URL:", normalZipUrl);
124+
125+
// Build and upload the variant with VITE_BASE_URL="/ui/"
126+
await runBuild("/ui/");
127+
const uiBaseZipPath = await generateZipFile("embed");
128+
const uiBaseZipUrl = await uploadZipToS3(uiBaseZipPath);
129+
console.log("Uploaded UI base variant zip URL:", uiBaseZipUrl);
118130
}
119131

120132
if (import.meta.main) {

0 commit comments

Comments
 (0)