-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const crypto = require('crypto'); | ||
|
||
const { runTest } = require('./test-utils/runTest'); | ||
const { createS3Client } = require('./s3client'); | ||
const { generateFileList } = require('./generateFileList'); | ||
const assert = require('node:assert'); | ||
|
||
// This is a test file. It is intended to be run manually with the proper environment variables set | ||
// | ||
// Run it from the project root using "node tasks/aws-s3-builds-page/generateFileList-test.js" | ||
|
||
const s3Client = createS3Client(); | ||
|
||
runTest(async ({ log }) => { | ||
log('Generate file list'); | ||
const filename = `test-file-list${crypto.randomUUID()}`; | ||
await generateFileList(filename); | ||
|
||
log(`Checking JSON at ${s3Client.fileUrl(`${filename}.json`)}`); | ||
const jsonList = JSON.parse(await s3Client.fetchFile(`${filename}.json`)); | ||
assert(jsonList.includes('handlebars-v4.7.7.js')); | ||
|
||
log(`Deleting file ${filename}.json`); | ||
await s3Client.deleteFile(`${filename}.json`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* eslint-disable no-console */ | ||
const { createS3Client } = require('./s3client'); | ||
|
||
async function generateFileList(nameWithoutExtension) { | ||
const s3Client = createS3Client(); | ||
const fileList = await s3Client.listFiles(); | ||
const fileListJson = JSON.stringify(fileList, null, 2); | ||
await s3Client.uploadData(fileListJson, nameWithoutExtension + '.json', { | ||
contentType: 'application/json' | ||
}); | ||
} | ||
|
||
module.exports = { generateFileList }; |