Skip to content

feat: Expose package version in build#108

Merged
stanleyjones merged 2 commits intoliftedinit:mainfrom
stanleyjones:expose-version
Feb 13, 2023
Merged

feat: Expose package version in build#108
stanleyjones merged 2 commits intoliftedinit:mainfrom
stanleyjones:expose-version

Conversation

@stanleyjones
Copy link
Copy Markdown
Contributor

Description

In order to better diagnose production bugs, this PR introduces a mechanism for exposing the package version in the production build (specifically in index.html as a meta tag).

  • Generate a better version string in package.json
  • Get the version in .env and write it in index.html
  • Document everything

Related Issue

No related issue, but useful in diagnosing future issues.

Testing

No changes.

Breaking Changes (if applicable)

None.

Screenshots (if applicable)

N/A

Checklist:

  • I have read and followed the CONTRIBUTING guidelines for this project.
  • I have added or updated tests and they pass.
  • I have added or updated documentation and it is accurate.
  • I have noted any breaking changes in this module or downstream modules.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 13, 2023

Deploy Preview for lifted-alberto ready!

Name Link
🔨 Latest commit c6cede7
🔍 Latest deploy log https://app.netlify.com/sites/lifted-alberto/deploys/63eac38dc48421000841a57c
😎 Deploy Preview https://deploy-preview-108--lifted-alberto.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.

Comment thread .env
REACT_APP_WEB3AUTH_NETWORK=testnet
REACT_APP_WEB3AUTH_CLIENTID=BKj3lr6GfN2CnvO4CIKo5fuoCg_TpHsAPK7R8lbl6kUlz0CAH_5mFNswScEb7M6szV4hd1Tkwa2oPZ9KiXJB-44 No newline at end of file
REACT_APP_WEB3AUTH_CLIENTID=BKj3lr6GfN2CnvO4CIKo5fuoCg_TpHsAPK7R8lbl6kUlz0CAH_5mFNswScEb7M6szV4hd1Tkwa2oPZ9KiXJB-44
REACT_APP_VERSION=${npm_package_version}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Get the package version from package.json.

Comment thread README.md
following command:

```sh
npm version prerelease --preid alpha
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Generate an actually useful version string (instead of just 0.1.0). By using this command, npm will:

  • Bump the version (i.e. 0.1.0-alpha.8 -> 0.1.0-alpha.9)
  • Update package.json
  • Commit all changes
  • Create a tag (i.e. 0.1.0-alpha.9)
  • Push changes and tags to GitHub

Comment thread package.json Outdated
Comment on lines +14 to +15
"version": "git add -A",
"postversion": "git push && git push --tags"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"version" will add the updated package.json to git and "postversion" will push it, along with the newly created tag.

Comment thread public/index.html
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<meta name="version" content="%REACT_APP_VERSION%" />
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Finally, actually expose the more useful version in the front-end code.

@stanleyjones stanleyjones requested a review from rfisch February 13, 2023 23:00
@stanleyjones stanleyjones self-assigned this Feb 13, 2023
@stanleyjones stanleyjones merged commit f87cf2c into liftedinit:main Feb 13, 2023
@stanleyjones stanleyjones deleted the expose-version branch February 13, 2023 23:11
stanleyjones added a commit to stanleyjones/alberto that referenced this pull request Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants