Skip to content

Commit

Permalink
Merge branch 'main' into 16290-event-listings
Browse files Browse the repository at this point in the history
  • Loading branch information
tjheffner authored Jan 11, 2024
2 parents 22e69b3 + f70b1d3 commit 85bd049
Show file tree
Hide file tree
Showing 29 changed files with 135 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dump.rdb
/storybook-static
/public/generated
/public/data
/public/img

# misc
.DS_Store
Expand Down
35 changes: 11 additions & 24 deletions .tugboat/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,17 @@ services:
# base previews are refreshed through the scheduled process! A manual
# rebuild of the base preview is necessary.
init:
# Create a directory for the new repository's keyring, if it doesn't exist
- mkdir -p /etc/apt/keyrings
# Download the new repository's GPG key and save it in the keyring directory
- curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
# Add the new repository's source list with its GPG key for package verification
- echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
# Update local package index to recognize the new repository
- sudo apt-get update

# Install Node.js from the new repository
- sudo apt-get install -y nodejs
- curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && sudo apt-get install -y nodejs

# Install nvm
- chmod -R 775 "./scripts/"
- ./scripts/install-nvm.sh
# Install and use our yarn version
- corepack enable
- corepack prepare yarn@3.6.1 --activate

# Install VA Root CA
- cp "${TUGBOAT_ROOT}"/certs/*.crt /usr/local/share/ca-certificates
- update-ca-certificates

# Clone vets-website
- ./scripts/install-repos.sh

# Build vets-website so assets are available (various widgets, fonts, etc)
- ./scripts/build-vets-website.sh

# Setup nginx to serve 404 page.
- cp -f "${TUGBOAT_ROOT}"/.tugboat/vhost-web.conf /etc/nginx/conf.d/default.conf

Expand All @@ -67,9 +52,11 @@ services:
# Restart nginx with the new config
- sudo service nginx reload

# Install and use our yarn version
- corepack enable
- corepack prepare yarn@3.6.1 --activate
# Tugboat user can run our scripts
- chmod -R 775 "./scripts/"

# Clone vets-website
- ./scripts/install-repos.sh

# Commands that build the site. This is where you would add
# steps required to set up or configure the site. When a
Expand All @@ -81,8 +68,8 @@ services:
# Install dependencies. These are included in .yarn/cache, shouldn't add significant time or network requests.
- yarn install

# Create symlink between vets-website assets and next-build
- ln -snf "/var/lib/vets-website/build/localhost/generated" "${TUGBOAT_ROOT}/public/generated"
# Get vets-website assets in the right place
- BUILD_TYPE=vagovprod node ./scripts/yarn/vets-website-assets.mjs

# Build the static pages. Set for self-signed certs
- NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt yarn export
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"debug": "^4.3.4",
"drupal-jsonapi-params": "^2.3.1",
"env-loader": "0.1.0",
"fs-extra": "^11.2.0",
"i18next": "^23.7.12",
"i18next-browser-languagedetector": "^7.2.0",
"jest-axe": "^8.0.0",
Expand Down Expand Up @@ -117,7 +118,6 @@
"eslint-plugin-storybook": "^0.6.15",
"eslint-plugin-testing-library": "^6.2.0",
"eslint-plugin-unused-imports": "^3.0.0",
"fs-extra": "^11.2.0",
"http-server": "^14.1.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
Expand Down
1 change: 0 additions & 1 deletion public/img/VCL-icon-white.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/img/arrow-down-white.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/img/arrow-right-blue.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/img/arrow-right-white.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/img/arrow-right.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/img/arrow-up.svg

This file was deleted.

Binary file removed public/img/design/icons/apple-touch-icon-114x114.png
Binary file not shown.
Binary file removed public/img/design/icons/apple-touch-icon-152x152.png
Binary file not shown.
Binary file removed public/img/design/icons/apple-touch-icon-72x72.png
Binary file not shown.
Binary file removed public/img/design/icons/apple-touch-icon.png
Binary file not shown.
Binary file removed public/img/design/icons/favicon.ico
Binary file not shown.
Binary file removed public/img/design/icons/va.png
Binary file not shown.
Binary file removed public/img/design/icons/watermark.png
Binary file not shown.
Binary file removed public/img/design/icons/wrench.png
Binary file not shown.
Binary file removed public/img/design/logo/va-logo.png
Binary file not shown.
Binary file removed public/img/design/logo/va-og-image.png
Binary file not shown.
Binary file removed public/img/design/logo/va-og-twitter-image.png
Binary file not shown.
Binary file removed public/img/header-logo.png
Binary file not shown.
Binary file removed public/img/homepage/va-logo-white.png
Binary file not shown.
1 change: 0 additions & 1 deletion public/img/icon-dot-gov.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/img/icon-https.svg

This file was deleted.

Binary file removed public/img/tiny-usa-flag.png
Binary file not shown.
Binary file removed public/img/vcl-logo.png
Binary file not shown.
20 changes: 0 additions & 20 deletions scripts/build-vets-website.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/yarn/dev.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { processEnv } = require('env-loader')

processEnv('yarn setup && next dev')
processEnv('next dev')
121 changes: 121 additions & 0 deletions scripts/yarn/vets-website-assets.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-console */

import fetch from 'cross-fetch'
import fs from 'fs-extra'
import path from 'path'

// exits with non-zero if a download failed
process.on('unhandledRejection', (up) => {
throw up
})

const prodBucket = 'https://prod-va-gov-assets.s3-us-gov-west-1.amazonaws.com'
const stagingBucket =
'https://staging-va-gov-assets.s3-us-gov-west-1.amazonaws.com'
const devBucket = 'https://dev-va-gov-assets.s3-us-gov-west-1.amazonaws.com'

const BUILD_TYPE_BUCKET = {
localhost: devBucket,
tugboat: devBucket,
vagovdev: devBucket,
vagovstaging: stagingBucket,
vagovprod: prodBucket,
}

const fileManifestPath = 'generated/file-manifest.json'

const vetsWebsiteAssetPath = '../vets-website/src/site/assets'

async function downloadFromLiveBucket(buildtype) {
const bucket = BUILD_TYPE_BUCKET[buildtype]

const fileManifestRequest = await fetch(`${bucket}/${fileManifestPath}`)
const fileManifest = await fileManifestRequest.json()

const files = []

files[fileManifestPath] = {
path: fileManifestPath,
contents: Buffer.from(JSON.stringify(fileManifest)),
}

const entryNames = Object.keys(fileManifest)

const downloads = entryNames.map(async (entryName) => {
let bundleFileName = fileManifest[entryName]
const bundleUrl = bundleFileName.includes(bucket)
? `${bundleFileName}`
: `${bucket}${bundleFileName}`
const bundleResponse = await fetch(bundleUrl)

if (bundleFileName.includes('generated/../')) {
console.log(`Excluding: ${bundleFileName} from download`)
} else {
if (!bundleResponse.ok) {
throw new Error(`Failed to download asset: ${bundleUrl}`)
}

if (bundleFileName.startsWith('/')) {
bundleFileName = bundleFileName.slice(1)
}

files[bundleFileName] = {
path: bundleFileName,
// No need to store file contents here since
// assets will be stored directly on disk
contents: '',
}

// Store file contents directly on disk
fs.outputFileSync(
path.join('./public/', bundleFileName),
await bundleResponse.buffer()
)
}
})
return Promise.all(downloads)
}

async function moveAssetsFromVetsWebsite() {
console.log('Moving additional assets from adjacent vets-website repo...')

try {
fs.copySync(`${vetsWebsiteAssetPath}/fonts`, './public/generated/')
console.log('Copied font files from vets-website')

fs.copySync(`${vetsWebsiteAssetPath}/img`, './public/img/')
console.log('Copied image assets from vets-website')
} catch (err) {
console.error(err)
}
}

export async function downloadAssets() {
const buildtype = process.env.BUILD_TYPE

// Clean + download assets if not localhost symlink
if (buildtype !== 'localhost') {
// Clear existing /public/generated/ of files + existing symlinks
fs.remove('./public/generated/', (err) => {
if (err) return console.err(err)
console.log(
`Removed existing vets-website assets. Preparing to download fresh from ${BUILD_TYPE_BUCKET[buildtype]}`
)
})

await downloadFromLiveBucket(buildtype)
console.log(
`Successfully downloaded all assets listed in ${BUILD_TYPE_BUCKET[buildtype]}/${fileManifestPath}`
)

await moveAssetsFromVetsWebsite()
}

// Create symlink for localhost
// if (buildtype === 'localhost') {

// }
}

downloadAssets()

0 comments on commit 85bd049

Please sign in to comment.