Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn upgrade archiver and logging #1379

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions projects/archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"aws-sdk": "2.518.0",
"encoding": "^0.1.12",
"jest": "^24.8.0",
"moment": "^2.24.0",
"node-fetch": "^2.6.0",
"p-all": "^2.1.0",
"ramda": "^0.26.1",
"ts-jest": "^24.0.2",
"ts-optchain": "^0.1.8",
"uuidv4": "5.0.1",
"moment": "^2.24.0"
"uuidv4": "5.0.1"
},
"resolutions": {
"handlebars": "4.6.0"
Expand Down
2,349 changes: 1,070 additions & 1,279 deletions projects/archiver/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions projects/backend/controllers/fronts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getFront } from '../fronts'
import { hasFailed } from '../utils/try'
import { isPreview } from '../preview'
import { IssuePublicationIdentifier } from '../common'
import { decodeVersionOrPreview } from '../utils/issue'
import { decodeVersionOrPreview, getEditionOrFallback } from '../utils/issue'

export const frontController = (req: Request, res: Response) => {
const frontId: string = req.params[0]
Expand All @@ -13,7 +13,7 @@ export const frontController = (req: Request, res: Response) => {
req.params.version,
isPreview,
)
const edition = req.params.edition
const edition = getEditionOrFallback(req.params.edition)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is just a yarn upgrade then why do we have changes to logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering that! Basically after I ran yarn upgrade the validate step started failing - perhaps because of babel changes? Doesn't really make sense though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see the failure stuff here - basically it was angry about treating strings as typed values

const [date, updater] = lastModified()
console.log(`Request for ${req.url} fetching front ${frontId}`)
const issue: IssuePublicationIdentifier = {
Expand Down
26 changes: 18 additions & 8 deletions projects/backend/controllers/image.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { Request, Response } from 'express'
import { imageSizes, ImageUse, imageUses } from '../../Apps/common/src/index'
import {
imageSizes,
ImageUse,
imageUses,
ImageSize,
} from '../../Apps/common/src/index'
import { Image, ImageRole, imageRoles } from '../common'
import { getImageURL } from '../image'

const getSize = (size: string | undefined): ImageSize | undefined => {
return imageSizes.find(_ => _ == size)
}

const getUse = (use: string | undefined): ImageUse | undefined => {
const imageUse = imageUses.find(_ => _ == use)
return imageUse
Expand All @@ -19,20 +28,21 @@ const getUse = (use: string | undefined): ImageUse | undefined => {
*/
export const imageController = (req: Request, res: Response) => {
const source = req.params.source
const size = req.params.size
const size = getSize(req.params.size)
const lastPathParam: string = req.params[0]
const use = getUse(req.params.use) || 'full-size'
const role: ImageRole =
imageRoles.find(r => r === req.query.role) || 'inline'
const img: Image = { source, path: lastPathParam, role }

if (!imageSizes.includes(size)) {
if (!size) {
res.status(500)
res.send('Invalid size')
} else {
const redirect = getImageURL(img, size, use)
console.log(
`Getting image redirect for ${source} ${size} ${lastPathParam} role : ${role} redirect: ${redirect}`,
)
res.redirect(redirect)
}
const redirect = getImageURL(img, size, use)
console.log(
`Getting image redirect for ${source} ${size} ${lastPathParam} role : ${role} redirect: ${redirect}`,
)
res.redirect(redirect)
}
6 changes: 4 additions & 2 deletions projects/backend/controllers/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const issueController = (req: Request, res: Response) => {
req.params.version,
isPreviewStage,
)
const edition = req.params.edition
const edition = getEditionOrFallback(req.params.edition)
const issue: IssuePublicationIdentifier = {
issueDate,
version,
Expand Down Expand Up @@ -121,7 +121,9 @@ export const getIssuesSummary = async (

export const issuesSummaryController = (req: Request, res: Response) => {
const issueEdition = req.params.edition
const pageSize = req.query.pageSize && parseInt(req.query.pageSize, 10)
const pageSize =
(req.query.pageSize && parseInt(req.query.pageSize.toString(), 10)) ||
undefined
getIssuesSummary(issueEdition, isPreviewStage, pageSize)
.then(data => {
if (hasFailed(data)) {
Expand Down
6 changes: 4 additions & 2 deletions projects/backend/jest-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ expect.extend({
if (hasFailed(received)) {
return {
pass: true,
message: `expected ${received} not to have failed, however it failed with ${received.error}`,
message: () =>
`expected ${received} not to have failed, however it failed with ${received.error}`,
}
}
return {
pass: false,
message: `expected ${received} to have failed, however it passed`,
message: () =>
`expected ${received} to have failed, however it passed`,
}
},
})