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

feat(gatsby-core-utils): Add node.js export, and move site-metadata into its own function #26237

Merged
merged 5 commits into from Aug 20, 2020

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Aug 5, 2020

This adds an export for node.js-specific functions. It also adds new updateSIteMetadata and getSiteMetadata, which use service-lock.

@ascorbic ascorbic requested review from a team as code owners August 5, 2020 10:32
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 5, 2020
@ascorbic ascorbic requested a review from wardpeet August 5, 2020 10:32
@ascorbic ascorbic added status: needs core review Currently awaiting review from Core team member and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Aug 5, 2020
@ascorbic ascorbic requested a review from mxstbr August 5, 2020 10:33
@gatsby-cloud
Copy link

gatsby-cloud bot commented Aug 5, 2020

Gatsby Cloud Build Report

client-only-paths

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 18s

Performance

Lighthouse report

Metric Score
Performance 💚 100
Accessibility 🔶 85
Best Practices 💚 100
SEO 🔶 70

🔗 View full report

@gatsby-cloud
Copy link

gatsby-cloud bot commented Aug 5, 2020

Gatsby Cloud Build Report

using-styled-components

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 11s

Performance

Lighthouse report

Metric Score
Performance 💚 100
Accessibility 💚 90
Best Practices 💚 100
SEO 💚 90

🔗 View full report

@gatsby-cloud
Copy link

gatsby-cloud bot commented Aug 5, 2020

Gatsby Cloud Build Report

using-reach-skip-nav

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 20s

Performance

Lighthouse report

Metric Score
Performance 💚 100
Accessibility 💚 100
Best Practices 💚 100
SEO 🔶 82

🔗 View full report

@gatsby-cloud-staging
Copy link

gatsby-cloud-staging bot commented Aug 5, 2020

Gatsby Cloud Build Report

gatsby-master

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 16m

Performance

Lighthouse report

Metric Score
Performance 💚 95
Accessibility 🔶 87
Best Practices 💚 93
SEO 🔶 73

🔗 View full report

@gatsby-cloud
Copy link

gatsby-cloud bot commented Aug 5, 2020

Gatsby Cloud Build Report

gatsby

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 20m

pvdz
pvdz previously approved these changes Aug 5, 2020
Copy link
Contributor

@pvdz pvdz left a comment

Choose a reason for hiding this comment

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

lgtm


export async function updateSiteMetadata(
metadata: ISiteMetadata,
merge = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit

I would kind of suggest to not use a default and to use constants to prevent magic variables and "the boolean trap"-problem.

export const AND_MERGE = true
export const NOT_MERGE = false

or smth, or to export a version of this function that passes on false for you

export async function updateSiteMetadataAndMerge(
  metadata: ISiteMetadata
) {
  return updateSiteMetadata(metadata, true)
}

etc

Comment on lines 21 to 22
const oldMetadata = (await getSiteMetadata(metadata.sitePath)) || {}
metadata = { ...oldMetadata, ...metadata }
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit

Suggested change
const oldMetadata = (await getSiteMetadata(metadata.sitePath)) || {}
metadata = { ...oldMetadata, ...metadata }
const oldMetadata = await getSiteMetadata(metadata.sitePath)
if (oldMetadata) {
metadata = { ...oldMetadata, ...metadata }
}

mxstbr
mxstbr previously approved these changes Aug 10, 2020
Copy link
Contributor

@mxstbr mxstbr left a comment

Choose a reason for hiding this comment

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

💯 This is much nicer than /dist/service-lock! LGTM 👍

@wardpeet wardpeet dismissed stale reviews from mxstbr and pvdz via ca47529 August 13, 2020 12:55
@gatsby-cloud-staging
Copy link

Gatsby Cloud Build Report

gatsby

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 3h

Performance

Lighthouse report

Metric Score
Performance 💚 93
Accessibility 💚 100
Best Practices 💚 100
SEO 🔶 76

🔗 View full report

Copy link
Contributor

@laurieontech laurieontech left a comment

Choose a reason for hiding this comment

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

Nice! Great teamwork here.

@laurieontech laurieontech merged commit b164147 into master Aug 20, 2020
@wardpeet wardpeet deleted the feat/site-metadata branch August 20, 2020 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs core review Currently awaiting review from Core team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants