2024-10-18 07:04:57 -04:00
|
|
|
import minimist from 'minimist'
|
|
|
|
import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
|
|
|
|
|
|
|
|
const { batchedUpdateWithResultHandling } = BatchedUpdateModule
|
2020-08-17 10:14:26 -04:00
|
|
|
|
|
|
|
const argv = minimist(process.argv.slice(2))
|
|
|
|
const commit = argv.commit !== undefined
|
2024-08-22 05:02:08 -04:00
|
|
|
let imageName = argv._[0]
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
console.log(
|
2024-10-18 07:04:57 -04:00
|
|
|
'Usage: node backfill_project_image_name.mjs --commit <texlive_docker_image>'
|
2024-08-22 05:02:08 -04:00
|
|
|
)
|
|
|
|
console.log(
|
|
|
|
'Argument <texlive_docker_image> is not required when TEX_LIVE_DOCKER_IMAGE is set.'
|
|
|
|
)
|
|
|
|
console.log(
|
|
|
|
'Environment variable ALL_TEX_LIVE_DOCKER_IMAGES must contain <texlive_docker_image>.'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!imageName && process.env.TEX_LIVE_DOCKER_IMAGE) {
|
|
|
|
imageName = process.env.TEX_LIVE_DOCKER_IMAGE
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!imageName) {
|
|
|
|
usage()
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!process.env.ALL_TEX_LIVE_DOCKER_IMAGES) {
|
|
|
|
console.error(
|
|
|
|
'Error: environment variable ALL_TEX_LIVE_DOCKER_IMAGES is not defined.'
|
|
|
|
)
|
|
|
|
usage()
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!process.env.ALL_TEX_LIVE_DOCKER_IMAGES.split(',').includes(imageName)) {
|
|
|
|
console.error(
|
|
|
|
`Error: ALL_TEX_LIVE_DOCKER_IMAGES doesn't contain ${imageName}`
|
|
|
|
)
|
|
|
|
usage()
|
|
|
|
process.exit(1)
|
|
|
|
}
|
2020-08-17 10:14:26 -04:00
|
|
|
|
|
|
|
if (!commit) {
|
|
|
|
console.error('DOING DRY RUN. TO SAVE CHANGES PASS --commit')
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
batchedUpdateWithResultHandling(
|
|
|
|
'projects',
|
|
|
|
{ imageName: null },
|
2024-08-22 05:02:08 -04:00
|
|
|
{ $set: { imageName } }
|
2020-08-17 10:14:26 -04:00
|
|
|
)
|