22'use strict'
33
44require ( 'dotenv' ) . config ( )
5- const { rm, rename } = require ( 'node:fs/promises' )
65const { exit } = require ( 'node:process' )
76const path = require ( 'path' )
87
9- const { s3Prefix } = require ( '../src/server/config' )
10-
11- const clearCloudfrontCache = require ( './clear-cloudfront-cache' )
12- const { uploadToS3 } = require ( './s3-utils' )
13-
14- const rootDir = process . cwd ( )
15- const publicDir = path . join ( rootDir , 'public' )
16- const cacheDir = path . join ( rootDir , '.cache' )
8+ const { uploadToS3, s3Prefix } = require ( './s3-utils' )
179
1810/**
1911 * Deploy public/ to s3.
@@ -31,16 +23,9 @@ const cacheDir = path.join(rootDir, '.cache')
3123 * - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY: auth token to access the bucket.
3224 * - HEROKU_APP_NAME: (optional) app name to specify the ID of the PR if any.
3325 **/
34- async function main ( ) {
35- await uploadToS3 ( publicDir , '/' , s3Prefix )
36- // Move the 404 HTML file from public into the root dir for Heroku
37- await rename ( path . join ( publicDir , '404.html' ) , '404.html' )
38- // await rm(publicDir, { recursive: true, force: true })
39- await rm ( cacheDir , { recursive : true , force : true } )
40- await clearCloudfrontCache ( )
41- }
42-
43- main ( ) . catch ( e => {
26+ const rootDir = process . cwd ( )
27+ const publicDir = path . join ( rootDir , 'public' )
28+ uploadToS3 ( publicDir , '/' , s3Prefix ) . catch ( e => {
4429 console . error ( e )
4530 exit ( 1 )
4631} )
0 commit comments