Skip to content

Commit

Permalink
Adding the ability to exclude files from s3 sync
Browse files Browse the repository at this point in the history
  • Loading branch information
tstibbs committed Jan 12, 2025
1 parent 30c0cbc commit e6446cc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
3 changes: 2 additions & 1 deletion backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"aws-cdk": "^2.140.0",
"aws-cdk-lib": "^2.140.0",
"esbuild": "^0.20.2",
"jest": "^29.7.0"
"jest": "^29.7.0",
"yargs": "^17.7.2"
},
"scripts": {
"testsynth": "cdk-tools testsynth",
Expand Down
45 changes: 33 additions & 12 deletions backend/tools/generate-pdf-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,37 @@ import {strict as assert} from 'assert'

import {IndexGenerator} from '@tstibbs/cloud-core-utils/src/tools/generate-s3-index.js'

import yargs from 'yargs'
import {hideBin} from 'yargs/helpers'
import aws from 'aws-sdk'
aws.config.region = 'eu-west-2'
aws.config.apiVersions = {
s3: '2006-03-01',
cloudformation: '2010-05-15'
}

const args = process.argv.slice(2)
if (args.length != 5 && args.length != 6) {
console.error(
'Usage: AWS_PROFILE=websiteCredentialsProfile node tools/generate-pdf-index.js pdfSyncCredentialsProfile localPath basePath websiteStackName pdfSyncStackName [localTestOutputFile]'
const yargConfig = yargs(hideBin(process.argv))
.command(
'$0 <pdfSyncCredentialsProfile> <localPath> <basePath> <websiteStackName> <pdfSyncStackName>',
'the default command',
yargs => {
IndexGenerator.buildYargs(yargs)
yargs
.positional('pdfSyncCredentialsProfile', {})
.positional('localPath', {})
.positional('basePath', {})
.positional('websiteStackName', {})
.positional('pdfSyncStackName', {})
.option('localTestOutputFile', {
describe: 'If specified, write the generated index to this file, instead of uploading it',
type: 'file'
})
}
)
process.exit(1)
}
const [pdfSyncCredentialsProfile, localPath, basePath, websiteStackName, pdfSyncStackName] = args.slice(0, 5)
const localTestOutputFile = args.length >= 6 ? args[5] : null
.help('help')
const yargv = await yargConfig.parse()

const {pdfSyncCredentialsProfile, localPath, basePath, websiteStackName, pdfSyncStackName, localTestOutputFile} = yargv

function buildApi(apiKey, credentialsProfileName) {
let options = {}
Expand Down Expand Up @@ -63,10 +78,16 @@ const generateFileHtml = (filePath, name) => {
}
}

const indexGenerator = new IndexGenerator(localPath, bucketName, basePath, {
fileIcon: 'fa-long-arrow-down',
openFileGenerator: generateFileHtml
})
const indexGenerator = new IndexGenerator(
localPath,
bucketName,
basePath,
{
fileIcon: 'fa-long-arrow-down',
openFileGenerator: generateFileHtml
},
yargv
)

const templateUrl = `https://tstibbs.github.io/pdf-viewer-sync/web/#endpoint=${encodeURIComponent(endpointUrl)}`
const urlParamForObject = 'file'
Expand Down

0 comments on commit e6446cc

Please sign in to comment.