2020-10-21 16:28:30 +02:00
|
|
|
const packageJson = require("../package.json")
|
|
|
|
const { execSync } = require("child_process")
|
|
|
|
const fs = require("fs")
|
|
|
|
|
|
|
|
const TO_SYNC = "dist/"
|
|
|
|
const BUCKET_LOCATION = "s3://prod-budi-app-assets/assets"
|
|
|
|
const S3_COMP_DIR = "@budibase/standard-components/dist"
|
|
|
|
const MANIFEST = "componentlibrary-latest.json"
|
|
|
|
|
|
|
|
function buildS3Path() {
|
|
|
|
return `${BUCKET_LOCATION}/componentlibrary-${packageJson.version}/${S3_COMP_DIR}`
|
|
|
|
}
|
|
|
|
|
|
|
|
async function run() {
|
|
|
|
// basic manifest file describing the latest
|
2020-10-21 16:29:13 +02:00
|
|
|
fs.writeFileSync(
|
|
|
|
MANIFEST,
|
|
|
|
JSON.stringify({
|
|
|
|
version: packageJson.version,
|
|
|
|
dir: S3_COMP_DIR,
|
|
|
|
})
|
|
|
|
)
|
2021-05-26 18:04:32 +02:00
|
|
|
execSync(`aws s3 sync ${TO_SYNC} ${buildS3Path()}`)
|
|
|
|
execSync(`aws s3 cp ${MANIFEST} ${BUCKET_LOCATION}/${MANIFEST}`)
|
2020-10-21 16:28:30 +02:00
|
|
|
fs.unlinkSync(MANIFEST)
|
|
|
|
}
|
|
|
|
|
2020-10-21 16:29:13 +02:00
|
|
|
run()
|
|
|
|
.then(() => {
|
|
|
|
console.log(`Deployment complete, version ${packageJson.version}`)
|
|
|
|
})
|
2021-05-04 12:32:22 +02:00
|
|
|
.catch(err => {
|
2020-10-21 16:29:13 +02:00
|
|
|
console.error(err)
|
|
|
|
})
|