Skip to content

fix(core): handle case where package.json is not available at CWD#7187

Merged
slorber merged 4 commits into
mainfrom
jc/site-version
Apr 21, 2022
Merged

fix(core): handle case where package.json is not available at CWD#7187
slorber merged 4 commits into
mainfrom
jc/site-version

Conversation

@Josh-Cena
Copy link
Copy Markdown
Collaborator

@Josh-Cena Josh-Cena commented Apr 17, 2022

Motivation

Fix #7161. Moreover, this PR adds a DOCUSAURUS_VERSION env so that different modules can read this version without re-importing the package.json file.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Delete website/package.json, and add "dev": "cd website && docusaurus start", to the root package.json. The site starts gracefully:

image

@Josh-Cena Josh-Cena added the pr: bug fix This PR fixes a bug in a past release. label Apr 17, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 17, 2022
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 17, 2022

[V2]

Name Link
🔨 Latest commit 896f76c
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/625ba3fcff15ad0009421374
😎 Deploy Preview https://deploy-preview-7187--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 69
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

Lighthouse ran on https://deploy-preview-7187--docusaurus-2.netlify.app/

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2022

Size Change: +117 B (0%)

Total Size: 799 kB

Filename Size Change
website/build/assets/css/styles.********.css 107 kB +232 B (0%)
website/build/assets/js/main.********.js 604 kB -115 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 50 kB
website/build/index.html 38.8 kB

compressed-size-action

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 17, 2022

[V2]

Name Link
🔨 Latest commit ec720ab
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/62612e62db013300081702d1
😎 Deploy Preview https://deploy-preview-7187--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Josh-Cena
Copy link
Copy Markdown
Collaborator Author

Josh-Cena commented Apr 17, 2022

We could have used pkg-up or similar utilities, but I'm not sure if that would lead to unexpected results, like finding a package.json that's below the desired one... If we are to make docusaurus upgrade (#4082), the package.json file has to be unambiguous, so it's better if we can set a standard practice from the beginning.

Copy link
Copy Markdown
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

🤷‍♂️ not really fan, particularly the DOCUSAURUS_VERSION env var

Comment thread packages/docusaurus/bin/beforeCli.mjs
Comment thread packages/docusaurus/bin/beforeCli.mjs Outdated
@slorber slorber merged commit 3b32a41 into main Apr 21, 2022
@slorber slorber deleted the jc/site-version branch April 21, 2022 14:07
Josh-Cena added a commit that referenced this pull request May 5, 2022
* Revert "fix(core): handle case where package.json is not available at CWD (#7187)"

This reverts commit 3b32a41.

* properly fix

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should not assume package.json is available at CWD

3 participants