unique version numbers for staging uploads

This commit is contained in:
Matt Walsh
2025-09-04 21:57:12 -05:00
parent 517c560ef6
commit 093b6ac239

View File

@@ -97,23 +97,27 @@ const copyCss = () => src(cssSources)
const htmlSources = [ const htmlSources = [
'views/*.ejs', 'views/*.ejs',
]; ];
const compressHtml = async () => { const packageJson = await readFile('package.json');
const packageJson = await readFile('package.json'); let { version } = JSON.parse(packageJson);
const { version } = JSON.parse(packageJson); const previewVersion = async () => {
// generate a relatively unique timestamp for cache invalidation of the preview site
return src(htmlSources) const now = new Date();
.pipe(ejs({ const msNow = now.getTime() % 1_000_000;
production: version, version = msNow.toString();
serverAvailable: false,
version,
OVERRIDES,
query: {},
}))
.pipe(rename({ extname: '.html' }))
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(dest('./dist'));
}; };
const compressHtml = async () => src(htmlSources)
.pipe(ejs({
production: version,
serverAvailable: false,
version,
OVERRIDES,
query: {},
}))
.pipe(rename({ extname: '.html' }))
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(dest('./dist'));
const otherFiles = [ const otherFiles = [
'server/robots.txt', 'server/robots.txt',
'server/manifest.json', 'server/manifest.json',
@@ -205,7 +209,7 @@ const buildDist = series(clean, parallel(buildJs, compressJsVendor, copyCss, com
// upload_images could be in parallel with upload, but _images logs a lot and has little changes // upload_images could be in parallel with upload, but _images logs a lot and has little changes
// by running upload last the majority of the changes will be at the bottom of the log for easy viewing // by running upload last the majority of the changes will be at the bottom of the log for easy viewing
const publishFrontend = series(buildDist, uploadImages, upload, invalidate); const publishFrontend = series(buildDist, uploadImages, upload, invalidate);
const stageFrontend = series(buildDist, uploadImagesPreview, uploadPreview, invalidatePreview); const stageFrontend = series(previewVersion, buildDist, uploadImagesPreview, uploadPreview, invalidatePreview);
export default publishFrontend; export default publishFrontend;