@@ -35,7 +35,7 @@ async function getGitHash(): Promise<string> {
35
35
return new TextDecoder ( ) . decode ( gitOutput . stdout ) . trim ( ) ;
36
36
}
37
37
38
- async function runBuild ( ) {
38
+ async function runBuild ( baseUrl = "/" ) {
39
39
console . log ( "Running yarn install" ) ;
40
40
const installOutput = await new Deno . Command ( "yarn" , {
41
41
args : [ "install" ] ,
@@ -47,9 +47,11 @@ async function runBuild() {
47
47
} ) . output ( ) ;
48
48
assert ( installOutput . success , "Failed to run yarn install" ) ;
49
49
50
- console . log ( "Running yarn build" ) ;
50
+ console . log (
51
+ `Running yarn build${ baseUrl ? ` with base URL: ${ baseUrl } ` : "" } ` ,
52
+ ) ;
51
53
const buildOutput = await new Deno . Command ( "yarn" , {
52
- args : [ "run" , "build" ] ,
54
+ args : [ "run" , "build:prod" , `--base= ${ baseUrl } ` ] ,
53
55
stdout : "inherit" ,
54
56
stderr : "inherit" ,
55
57
env : {
@@ -66,14 +68,17 @@ async function runBuild() {
66
68
assert ( buildOutput . success , "Failed to run yarn build" ) ;
67
69
}
68
70
69
- async function generateZipFile ( ) : Promise < string > {
71
+ async function generateZipFile ( variant : string ) : Promise < string > {
70
72
const gitHash = await getGitHash ( ) ;
71
73
const timestamp = format ( new Date ( ) , "yyyy-MM-dd-HH-mm-ss" , {
72
74
timeZone : "UTC" ,
73
75
} ) ;
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
+
77
82
const zipOutput = await new Deno . Command ( "zip" , {
78
83
args : [ "-r" , zipPath , "." ] ,
79
84
cwd : DIST_DIR ,
@@ -111,10 +116,17 @@ async function uploadZipToS3(zipPath: string): Promise<string> {
111
116
}
112
117
113
118
async function main ( ) {
119
+ // Build and upload the normal variant
114
120
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 ) ;
118
130
}
119
131
120
132
if ( import . meta. main ) {
0 commit comments