Skip to content

Scripts and plugins that provide centralized defaults for HashiCorp Next.js web properties

License

Notifications You must be signed in to change notification settings

hashicorp/web-platform-packages

HashiCorp Web Platform Packages

This monorepo contains a collection of packages which layer a number of configuration choices, code quality checks, and code generators on top of Next.js. Specifically, it provides:

  • Baked in, zero-config typescript linting & prettier formatting via binary
  • Code generators for base website templates, new pages, and new components via binary
  • A pre-configured client for easily fetching from DatoCMS
  • A strong set of default plugins, including:
    • mdx-processed markdown with front-matter and layouts
    • css files with pre-configured postcss-preset-env can be imported directly into components
    • graphql file loader
    • webpack bundle analyzer

Packages

Current packages:

Publishing

Publishing is handled through the changesets library. Publishing is done in CI if changes are found. For more information on how to work with changesets, see this document.

Adding a changeset

Run the following command and follow the prompt:

npx changeset

To make any adjustments to your changeset, just edit the file!

Releases

The release process is handled mostly automatically via the changesets GitHub action. When changeset files get merged to main, a Pull Request is opened which will, upon merge, release all pending changesets and remove the changeset files. We should not need to publish manually with this flow. See the changesets/action(https://github.com/changesets/action) repo for more information.

Canary Releases

If you want to test your changes before merging, you can add a release:canary label to your pull request. If any changeset files are found, a release will be created and tagged with canary. You can then install the canary version elsewhere:

npm install @hashicorp/platform-package@canary

Prereleases

Prereleases are also handled through a process integrated into changesets. The full flow is outlined in this document. To enter a prerelease mode for the canary tag, we would do something like this:

npx changeset pre enter canary
GITHUB_TOKEN=<your token> npx changeset version
GITHUB_TOKEN=<your token> npx changeset publish

To continue publishing preleases, use the npx changeset command like normal and use the version and publish commands as appropriate.