From 481bcc6c95105331dcd8bc30a5ea55a06e3d8ce3 Mon Sep 17 00:00:00 2001 From: Navin Moorthy Date: Wed, 5 Apr 2023 12:58:54 +0530 Subject: [PATCH] =?UTF-8?q?feat(tooling)!:=20=E2=9C=A8=20add=20turbo=20rep?= =?UTF-8?q?o=20to=20local=20&=20ci=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added turbo & enabled vercel remote caching - Improved release pipeline with fancy looking changelog - Combine many lint script actions into `ci.yml` with turbo - Fix semantic-pr-title issue with token --- .eslintignore | 5 +- .eslintrc.cjs | 3 +- .github/CONTRIBUTING.md | 69 ++--- .github/DEVELOPMENT.md | 60 +++-- .github/PULL_REQUEST_TEMPLATE.md | 12 +- .github/labels.yml | 10 + .github/renovate.json | 7 +- .github/workflows/{lint-css.yml => ci.yml} | 8 +- .github/workflows/lint-eslint.yml | 16 -- .github/workflows/lint-knip.yml | 16 -- .github/workflows/lint-markdown.yml | 16 -- .github/workflows/lint-package-json.yml | 16 -- .github/workflows/lint-prettier.yml | 15 -- .github/workflows/lint-spelling.yml | 16 -- .github/workflows/lint-types.yml | 16 -- .github/workflows/semantic-pr.yml | 2 +- .github/workflows/stale.yml | 2 +- .github/workflows/sync-labels.yml | 2 +- .markdownlintignore | 5 +- .prettierignore | 5 +- .prettierrc.cjs | 3 +- .stylelintignore | 5 +- LICENSE.md | 8 +- env/schema.js | 1 - knip.ts | 4 + package.json | 51 ++-- pnpm-lock.yaml | 189 ++++++-------- ...nventionalChangelogWriterOptsTransform.cjs | 245 ++++++++++++++---- release-it/getCommitsSinceLastRelease.js | 1 - release-it/{ => templates}/commit.hbs | 34 +-- release-it/templates/template.hbs | 67 +++++ turbo.json | 45 ++++ 32 files changed, 550 insertions(+), 404 deletions(-) rename .github/workflows/{lint-css.yml => ci.yml} (52%) delete mode 100644 .github/workflows/lint-eslint.yml delete mode 100644 .github/workflows/lint-knip.yml delete mode 100644 .github/workflows/lint-markdown.yml delete mode 100644 .github/workflows/lint-package-json.yml delete mode 100644 .github/workflows/lint-prettier.yml delete mode 100644 .github/workflows/lint-spelling.yml delete mode 100644 .github/workflows/lint-types.yml rename release-it/{ => templates}/commit.hbs (53%) create mode 100644 release-it/templates/template.hbs create mode 100644 turbo.json diff --git a/.eslintignore b/.eslintignore index 81e77db..fbf1094 100644 --- a/.eslintignore +++ b/.eslintignore @@ -65,13 +65,16 @@ jspm_packages # Storybook Build storybook-static +# Turbo Repo +.turbo + # Lock files package-lock.json yarn.lock pnpm-lock.yaml # Custom -release-it/commit.hbs +release-it/**/*.hbs release-it/remote-commits.json release-it/conventionalChangelogWriterOptsTransform.cjs diff --git a/.eslintrc.cjs b/.eslintrc.cjs index e832cf9..68a8f7e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -125,7 +125,7 @@ module.exports = { }, }, { - files: ["*.tsx"], + files: ["*.tsx", "use*.ts"], extends: [ "canonical/react", "canonical/jsx-a11y", @@ -147,6 +147,7 @@ module.exports = { "react/forbid-component-props": "off", "react/prop-types": "off", "react/jsx-handler-names": "off", + "react/jsx-curly-newline": "off", }, settings: { tailwindcss: { diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 623a250..5a37329 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,8 +2,7 @@ Thanks for your interest in contributing to `next-react-app`! ๐Ÿ’– -> After this page, see [DEVELOPMENT.md](./DEVELOPMENT.md) for local development -> instructions. +> After this page, see [DEVELOPMENT.md][1] for local development instructions. ## Table of Contents @@ -19,17 +18,15 @@ Thanks for your interest in contributing to `next-react-app`! ๐Ÿ’– ## Code of Conduct -This project contains a -[Contributor Covenant code of conduct](./CODE_OF_CONDUCT.md) all contributors -are expected to follow. +This project contains a [Contributor Covenant code of conduct][2] all +contributors are expected to follow. ## Reporting Issues -Please do -[report an issue on the issue tracker](https://github.com/timelessco/next-react-app/issues/new/choose) -if there's any bugfix, documentation improvement, or general enhancement you'd -like to see in the repository! Please fully fill out all required fields in the -most appropriate issue form. +Please do [report an issue on the issue tracker][3] if there's any bugfix, +documentation improvement, or general enhancement you'd like to see in the +repository! Please fully fill out all required fields in the most appropriate +issue form. ## Sending Contributions @@ -42,12 +39,11 @@ steps involved: ### Finding an Issue With the exception of very small typos, all changes to this repository generally -need to correspond to an -[open issue marked as `accepting prs` on the issue tracker](https://github.com/timelessco/next-react-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22accepting+prs%22). -If this is your first time contributing, consider searching for -[unassigned issues that also have the `good first issue` label](https://github.com/timelessco/next-react-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22accepting+prs%22+label%3A%22good+first+issue%22+no%3Aassignee). -If the issue you'd like to fix isn't found on the issue, see -[Reporting Issues](#reporting-issues) for filing your own (please do!). +need to correspond to an [open issue marked as `accepting prs` on the issue +tracker][4]. If this is your first time contributing, consider searching for +[unassigned issues that also have the `good first issue` label][5]. If the issue +you'd like to fix isn't found on the issue, see [Reporting Issues][6] for filing +your own (please do!). ### Sending a Pull Request @@ -55,18 +51,15 @@ Once you've identified an open issue accepting PRs that doesn't yet have a PR sent, you're free to send a pull request. Be sure to fill out the pull request template's requested information -- otherwise your PR will likely be closed. -PRs are also expected to have a title that adheres to -[commitlint](https://github.com/conventional-changelog/commitlint). Only PR +PRs are also expected to have a title that adheres to [commitlint][7]. Only PR titles need to be in that format, not individual commits. Don't worry if you get this wrong: you can always change the PR title after sending it. Check -[previously merged PRs](https://github.com/timelessco/next-react-app/pulls?q=is%3Apr+is%3Amerged+-label%3Adependencies+) -for reference. +[previously merged PRs][8] for reference. #### Draft PRs -If you don't think your PR is ready for review, -[set it as a draft](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#converting-a-pull-request-to-a-draft). -Draft PRs won't be reviewed. +If you don't think your PR is ready for review, [set it as a draft][9]. Draft +PRs won't be reviewed. #### Pull Request Reviews @@ -75,15 +68,31 @@ manually `@` tag anybody to request review. A maintainer will look at it when they're next able to. After a maintainer reviews your PR, they may request changes on it. Once you've -made those changes, -[re-request review on GitHub](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/about-pull-request-reviews#re-requesting-a-review). +made those changes, [re-request review on GitHub][10]. Please try not to force-push commits to PRs that have already been reviewed. Doing so makes it harder to review the changes. We squash merge all commits so there's no need to try to preserve Git history within a PR branch. -Once your PR is merged, if you haven't yet been added to the -[_Contributors_ table in the README.md](../README.md#contributors) for its -[type of contribution](https://allcontributors.org/docs/en/emoji-key "Allcontributors emoji key"), -you should be soon. Please do ping the maintainer who merged your PR if that -doesn't happen within 24 hours - it was likely an oversight on our end! +Once your PR is merged, if you haven't yet been added to the [_Contributors_ +table in the README.md][11] for its [type of contribution][12], you should be +soon. Please do ping the maintainer who merged your PR if that doesn't happen +within 24 hours - it was likely an oversight on our end! + +[1]: ./DEVELOPMENT.md +[2]: ./CODE_OF_CONDUCT.md +[3]: https://github.com/timelessco/next-react-app/issues/new/choose +[4]: + https://github.com/timelessco/next-react-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22accepting+prs%22 +[5]: + https://github.com/timelessco/next-react-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22accepting+prs%22+label%3A%22good+first+issue%22+no%3Aassignee +[6]: #reporting-issues +[7]: https://github.com/conventional-changelog/commitlint +[8]: + https://github.com/timelessco/next-react-app/pulls?q=is%3Apr+is%3Amerged+-label%3Adependencies+ +[9]: + https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#converting-a-pull-request-to-a-draft +[10]: + https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/about-pull-request-reviews#re-requesting-a-review +[11]: ../README.md#contributors +[12]: https://allcontributors.org/docs/en/emoji-key "Allcontributors emoji key" diff --git a/.github/DEVELOPMENT.md b/.github/DEVELOPMENT.md index f059a81..128fe34 100644 --- a/.github/DEVELOPMENT.md +++ b/.github/DEVELOPMENT.md @@ -27,14 +27,14 @@ Before you get started, you will need to have the following tools installed on your machine: -- **[Node.js](https://nodejs.org/en/)** (version 12 or later) -- **[pnpm](https://pnpm.io/)** (version 7 or later) -- **[Git](https://git-scm.com/)** (optional, but recommended for version - control) +- **[Node.js][1]** (version 12 or later) +- **[pnpm][2]** (version 5 or later) or **[npm][3]** or **[yarn][4]** (version 6 + or later) +- **[Git][5]** (optional, but recommended for version control) > This repository includes a list of suggested VS Code extensions. It's a good -> idea to use [VS Code](https://code.visualstudio.com) and accept its suggestion -> to install them, as they'll help with development. +> idea to use [VS Code][6] and accept its suggestion to install them, as they'll +> help with development. ## Getting Started @@ -95,23 +95,22 @@ pnpm start ## Deploying the project -Guide on how to deploy Next.js to various -[hosting providers](https://nextjs.org/docs/deployment). +Guide on how to deploy Next.js to various [hosting providers][7]. ## More DX scripts -> Check for all the below errors in one command +> Check for all the below errors in one command using [Turbo Repo][8] `pnpm lint` -> AutoFix all the linting errors in one command +> AutoFix all the linting errors in one command using [Turbo Repo][8] `pnpm format` ### Prettier -[Prettier](https://prettier.io) is used to format code. It should be applied -automatically when you save files in VS Code or make a Git commit. +[Prettier][9] is used to format code. It should be applied automatically when +you save files in VS Code or make a Git commit. > Check the formatting errors @@ -127,9 +126,8 @@ automatically when you save files in VS Code or make a Git commit. ### Eslint -Extends all the necessary rulesets from -[eslint-config-canonical](https://github.com/gajus/eslint-config-canonical) for -the Next.js project that lints JavaScript and TypeScript source files +Extends all the necessary rulesets from [eslint-config-canonical][10] for the +Next.js project that lints JavaScript and TypeScript source files > Check for the linting errors @@ -141,7 +139,7 @@ the Next.js project that lints JavaScript and TypeScript source files ### Stylelint -([Stylelint](https://stylelint.io/)): Checks all css files +([Stylelint][11]): Checks all css files > Check the css linting errors @@ -153,8 +151,7 @@ the Next.js project that lints JavaScript and TypeScript source files ### Markdown -([Markdownlint](https://github.com/DavidAnson/markdownlint)): Checks all -Markdown files +([Markdownlint][12]): Checks all Markdown files > Check the markdown linting errors @@ -166,7 +163,7 @@ Markdown files ### Check Types -([TypeScript](https://www.typescriptlang.org/)): Checks all TypeScript files +([TypeScript][13]): Checks all TypeScript files > Check TypeScript types @@ -174,8 +171,7 @@ Markdown files ### Check unused dependencies, exports & types -([knip](https://github.com/webpro/knip)): Checks all unused dependencies, -exports & types +([knip][14]): Checks all unused dependencies, exports & types > Check the spelling errors @@ -183,7 +179,7 @@ exports & types ### Check Spelling -([cspell](https://cspell.org)): Spell checks across all source files +([cspell][15]): Spell checks across all source files > Check the spelling errors @@ -191,8 +187,7 @@ exports & types ### Check package.json -([npm-package-json-lint](https://npmpackagejsonlint.org/)): Lints the -`package.json` file +([npm-package-json-lint][16]): Lints the `package.json` file > Check the package.json linting errors @@ -203,3 +198,20 @@ exports & types > Run the test suite `pnpm test` + +[1]: https://nodejs.org/en/ +[2]: https://pnpm.io/ +[3]: https://www.npmjs.com/ +[4]: https://yarnpkg.com/ +[5]: https://git-scm.com/ +[6]: https://code.visualstudio.com +[7]: https://nextjs.org/docs/deployment +[8]: https://turbo.build/repo +[9]: https://prettier.io +[10]: https://github.com/gajus/eslint-config-canonical +[11]: https://stylelint.io/ +[12]: https://github.com/DavidAnson/markdownlint +[13]: https://www.typescriptlang.org/ +[14]: https://github.com/webpro/knip +[15]: https://cspell.org +[16]: https://npmpackagejsonlint.org/ diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9ebc845..ec71eb1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,12 +5,14 @@ Otherwise we may not be able to review your PR. --> ## PR Checklist - [ ] Addresses an existing open issue: fixes #000 -- [ ] That issue was marked as - [`status: accepting prs`](https://github.com/timelessco/next-react-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) -- [ ] Steps in - [CONTRIBUTING.md](https://github.com/timelessco/next-react-app/blob/main/.github/CONTRIBUTING.md) - were taken +- [ ] That issue was marked as [`status: accepting prs`][1] +- [ ] Steps in [CONTRIBUTING.md][2] were taken ## Overview + +[1]: + https://github.com/timelessco/next-react-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22 +[2]: + https://github.com/timelessco/next-react-app/blob/main/.github/CONTRIBUTING.md diff --git a/.github/labels.yml b/.github/labels.yml index 0732e0a..bf59fd8 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -46,6 +46,11 @@ color: 2af79e description: "Generic maintenance tasks, e.g., package updates." +- name: "Type: Testing" + color: 6009D7 + description: + "Improving how the repository's tests are run and/or code is tested" + - name: "Type: RFC" color: fbca04 @@ -106,6 +111,11 @@ - name: "Status: Good first issue" color: d7e102 + description: Good for newcomers, please hop on + +- name: "Status: Accepting PRs" + color: 0E8A16 + description: Please, send a pull request to resolve this! # Resolution Status labels - name: "Resolution: By Design" diff --git a/.github/renovate.json b/.github/renovate.json index 26d3f2c..bac426f 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -32,7 +32,8 @@ "dependencyDashboardTitle": "Renovate Dependency Updates", "automergeStrategy": "squash", "postUpdateOptions": ["pnpmDedupe"], - "commitMessageAction": "โฌ†๏ธ update", + "ignoreDeps": ["framer-motion"], + "commitMessageAction": "โฌ†๏ธ update", "commitMessageTopic": "{{depName}}", "packageRules": [ { @@ -80,7 +81,7 @@ "matchUpdateTypes": ["major"], "labels": ["Dependency โซ"], "semanticCommitScope": "deps", - "commitMessageAction": "โฌ†๏ธ upgrade", + "commitMessageAction": "โฌ†๏ธ upgrade", "semanticCommitType": "fix", "prPriority": 3 }, @@ -90,7 +91,7 @@ "matchUpdateTypes": ["major"], "labels": ["DevDependency ๐Ÿ”ผ"], "semanticCommitScope": "dev-deps", - "commitMessageAction": "โฌ†๏ธ upgrade", + "commitMessageAction": "โฌ†๏ธ upgrade", "prPriority": 3 }, { diff --git a/.github/workflows/lint-css.yml b/.github/workflows/ci.yml similarity index 52% rename from .github/workflows/lint-css.yml rename to .github/workflows/ci.yml index 944a1fe..dc567ef 100644 --- a/.github/workflows/lint-css.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Stylelint +name: CI on: pull_request: ~ @@ -8,9 +8,11 @@ on: - main jobs: - stylelint: + ci: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: ./.github/actions/prepare - - run: pnpm lint:css + - run: + npx turbo run lint:eslint lint:types lint:css lint:md lint:knip + lint:package-json lint:spelling lint:prettier test diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml deleted file mode 100644 index 2822159..0000000 --- a/.github/workflows/lint-eslint.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Eslint - -on: - pull_request: ~ - - push: - branches: - - main - -jobs: - eslint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/prepare - - run: pnpm lint:eslint diff --git a/.github/workflows/lint-knip.yml b/.github/workflows/lint-knip.yml deleted file mode 100644 index fbd3a15..0000000 --- a/.github/workflows/lint-knip.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Check for unused dependencies, exports and types - -on: - pull_request: ~ - - push: - branches: - - main - -jobs: - knip: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/prepare - - run: pnpm lint:knip diff --git a/.github/workflows/lint-markdown.yml b/.github/workflows/lint-markdown.yml deleted file mode 100644 index 7876fd5..0000000 --- a/.github/workflows/lint-markdown.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Markdownlint - -on: - pull_request: ~ - - push: - branches: - - main - -jobs: - markdownlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/prepare - - run: pnpm lint:md diff --git a/.github/workflows/lint-package-json.yml b/.github/workflows/lint-package-json.yml deleted file mode 100644 index 73075ac..0000000 --- a/.github/workflows/lint-package-json.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Lint Package - -on: - pull_request: ~ - - push: - branches: - - main - -jobs: - packagejsonlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/prepare - - run: pnpm lint:package-json diff --git a/.github/workflows/lint-prettier.yml b/.github/workflows/lint-prettier.yml deleted file mode 100644 index 59b5c58..0000000 --- a/.github/workflows/lint-prettier.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Prettier - -on: - pull_request: ~ - - push: - branches: - - main -jobs: - prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/prepare - - run: pnpm lint:prettier diff --git a/.github/workflows/lint-spelling.yml b/.github/workflows/lint-spelling.yml deleted file mode 100644 index 80ceee2..0000000 --- a/.github/workflows/lint-spelling.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Lint Spelling - -on: - pull_request: ~ - - push: - branches: - - main - -jobs: - spelling: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/prepare - - run: pnpm lint:spelling diff --git a/.github/workflows/lint-types.yml b/.github/workflows/lint-types.yml deleted file mode 100644 index fd77f5e..0000000 --- a/.github/workflows/lint-types.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Check Types - -on: - pull_request: ~ - - push: - branches: - - main - -jobs: - types: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/prepare - - run: pnpm lint:types diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 2c5f365..b7d9540 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -14,4 +14,4 @@ jobs: steps: - uses: amannn/action-semantic-pull-request@v5.2.0 env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 2344569..8c9583f 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -9,7 +9,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v7 + - uses: actions/stale@v8 with: days-before-issue-stale: 60 days-before-issue-close: 7 diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 769fd06..94bd6c4 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -8,7 +8,7 @@ on: - .github/labels.yml jobs: - build: + sync-label: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.markdownlintignore b/.markdownlintignore index 6f759e3..ae58ddf 100644 --- a/.markdownlintignore +++ b/.markdownlintignore @@ -65,13 +65,16 @@ jspm_packages # Storybook Build storybook-static +# Turbo Repo +.turbo + # Lock files package-lock.json yarn.lock pnpm-lock.yaml # Custom -release-it/commit.hbs +release-it/**/*.hbs release-it/remote-commits.json # Library files diff --git a/.prettierignore b/.prettierignore index 6f759e3..ae58ddf 100644 --- a/.prettierignore +++ b/.prettierignore @@ -65,13 +65,16 @@ jspm_packages # Storybook Build storybook-static +# Turbo Repo +.turbo + # Lock files package-lock.json yarn.lock pnpm-lock.yaml # Custom -release-it/commit.hbs +release-it/**/*.hbs release-it/remote-commits.json # Library files diff --git a/.prettierrc.cjs b/.prettierrc.cjs index 689954c..2e5bc4e 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -1,6 +1,7 @@ const prettierPluginPackagejson = require("prettier-plugin-packagejson"); -const prettierPluginTailwindcss = require("prettier-plugin-tailwindcss"); const prettierPluginSortImports = require("@ianvs/prettier-plugin-sort-imports"); +// Tailwind plugin should be last +const prettierPluginTailwindcss = require("prettier-plugin-tailwindcss"); module.exports = { // Plugins diff --git a/.stylelintignore b/.stylelintignore index 6f759e3..ae58ddf 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -65,13 +65,16 @@ jspm_packages # Storybook Build storybook-static +# Turbo Repo +.turbo + # Lock files package-lock.json yarn.lock pnpm-lock.yaml # Custom -release-it/commit.hbs +release-it/**/*.hbs release-it/remote-commits.json # Library files diff --git a/LICENSE.md b/LICENSE.md index 7b4c719..177167e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,9 +1,7 @@ -MIT License - -Copyright (c) 2023 Timeless +# MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in +this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, @@ -12,7 +10,7 @@ subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER diff --git a/env/schema.js b/env/schema.js index 76cbf30..0be7fa1 100644 --- a/env/schema.js +++ b/env/schema.js @@ -1,6 +1,5 @@ // Thanks to https://github.com/t3-oss/create-t3-app/ -/* eslint-disable node/no-process-env */ import { z } from "zod"; /** diff --git a/knip.ts b/knip.ts index 48932ec..1d27ba2 100644 --- a/knip.ts +++ b/knip.ts @@ -8,6 +8,10 @@ const config: KnipConfig = { "tailwind.config.cjs", "env/**/*", ], + // sharp - used by next/image + // autoprefixer - used by postcss for tailwind workflow + // tilg - used for debugging react components + ignoreDependencies: ["sharp", "autoprefixer"], }; export default config; diff --git a/package.json b/package.json index 2883e0e..2d65ccd 100644 --- a/package.json +++ b/package.json @@ -16,38 +16,45 @@ "url": "git+https://github.com/timelessco/next-react-app.git" }, "license": "MIT", - "author": "Navin Moorthy ", + "author": { + "name": "Timeless", + "email": "hello@timeless.co", + "url": "https://timeless.co/" + }, "type": "module", "scripts": { - "prepare": "husky install", - "dev": "next dev", - "dev:sourcemap": "SOURCEMAP=true pnpm dev", - "build": "next build", + "build": "npx turbo run build:next", "postbuild": "next-sitemap --config next-sitemap.config.cjs", "build:analyze": "ANALYZE=true pnpm build && pnpm start", "build:ci": "SKIP_ENV_VALIDATION=true next build", + "build:next": "next build", "build:sourcemap": "SOURCEMAP=true pnpm build && source-map-explorer .next/static/**/*.js && pnpm start", - "start": "next start", "build:start": "pnpm build && pnpm start", - "lint": "npm-run-all lint:*", - "lint:prettier": "prettier --check --cache --cache-location=.prettiercache --ignore-unknown .", - "lint:eslint": "eslint --cache --color .", - "lint:types": "tsc --noEmit", + "commit": "gacp", + "contributors:add": "all-contributors add", + "contributors:generate": "all-contributors generate", + "dev": "next dev", + "dev:sourcemap": "SOURCEMAP=true pnpm dev", + "format": "npx turbo run format:eslint format:css format:md format:prettier", + "format:css": "stylelint '**/*.css' --fix --cache --color -f verbose", + "format:eslint": "eslint --cache --report-unused-disable-directives --color . --fix", + "format:md": "markdownlint --fix **/*.md \".github/**/*.md\"", + "format:prettier": "prettier --write --cache --cache-location=.prettiercache --list-different --ignore-unknown .", + "lint": "npx turbo run lint:eslint lint:types lint:css lint:md lint:knip lint:package-json lint:spelling lint:prettier", "lint:css": "stylelint '**/*.css' --cache --color -f verbose", - "lint:md": "markdownlint **/*.md \".github/**/*.md\"", + "lint:eslint": "eslint --cache --report-unused-disable-directives --color .", "lint:knip": "knip --production", + "lint:md": "markdownlint **/*.md \".github/**/*.md\"", "lint:package-json": "npmPkgJsonLint .", + "lint:prettier": "prettier --check --cache --cache-location=.prettiercache --ignore-unknown .", "lint:spelling": "cspell --dot --gitignore --cache --no-progress check \"**/*\"", - "format": "npm-run-all format:*", - "format:prettier": "prettier --write --cache --cache-location=.prettiercache --list-different --ignore-unknown .", - "format:eslint": "eslint --cache --color . --fix", - "format:css": "stylelint '**/*.css' --fix --cache --color -f verbose", - "format:md": "markdownlint --fix **/*.md \".github/**/*.md\"", + "lint:types": "tsc --noEmit", "populate:dictionary": "del-cli project-words.txt && cspell --words-only --unique --gitignore --cache --dot \"**/*\" | sort --ignore-case >> project-words.txt", - "release": "node release-it/getCommitsSinceLastRelease.js && release-it", + "prepare": "husky install", + "release": "node release-it/getCommitsSinceLastRelease.js && release-it --ci", "release:dryrun": "release-it --dry-run", - "test": "echo \"no test specified\" && exit 0", - "commit": "gacp" + "start": "next start", + "test": "echo \"no test specified\" && exit 0" }, "commitlint": { "extends": [ @@ -112,11 +119,9 @@ "lint-staged": "13.2.0", "markdownlint": "0.28.0", "markdownlint-cli": "0.33.0", - "next-bundle-analyzer": "0.6.7", "next-sitemap": "4.0.6", "npm-package-json-lint": "6.4.0", "npm-package-json-lint-config-default": "5.0.0", - "npm-run-all": "4.1.5", "postcss": "8.4.21", "prettier": "2.8.7", "prettier-plugin-packagejson": "2.4.3", @@ -129,12 +134,14 @@ "stylelint-config-standard": "31.0.0", "tailwindcss": "3.3.0", "tilg": "0.1.1", + "title-case": "^3.0.3", "toml-eslint-parser": "0.5.0", + "turbo": "^1.8.8", "typescript": "5.0.2", "yaml-eslint-parser": "1.2.0", "zod": "3.21.4" }, - "packageManager": "pnpm@8.0.0", + "packageManager": "pnpm@8.1.1", "gacp": { "add": false, "push": false, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c998c59..0c7bc4e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,9 +114,6 @@ devDependencies: markdownlint-cli: specifier: 0.33.0 version: 0.33.0 - next-bundle-analyzer: - specifier: 0.6.7 - version: 0.6.7(next@13.2.4) next-sitemap: specifier: 4.0.6 version: 4.0.6(@next/env@13.2.4)(next@13.2.4) @@ -126,9 +123,6 @@ devDependencies: npm-package-json-lint-config-default: specifier: 5.0.0 version: 5.0.0(npm-package-json-lint@6.4.0) - npm-run-all: - specifier: 4.1.5 - version: 4.1.5 postcss: specifier: 8.4.21 version: 8.4.21 @@ -165,9 +159,15 @@ devDependencies: tilg: specifier: 0.1.1 version: 0.1.1(react@18.2.0) + title-case: + specifier: ^3.0.3 + version: 3.0.3 toml-eslint-parser: specifier: 0.5.0 version: 0.5.0 + turbo: + specifier: ^1.8.8 + version: 1.8.8 typescript: specifier: 5.0.2 version: 5.0.2 @@ -978,11 +978,6 @@ packages: postcss-selector-parser: 6.0.11 dev: true - /@discoveryjs/json-ext@0.5.7: - resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==} - engines: {node: '>=10.0.0'} - dev: true - /@es-joy/jsdoccomment@0.37.0: resolution: {integrity: sha512-hjK0wnsPCYLlF+HHB4R/RbUjOWeLW2SlarB67+Do5WsKILOkmIZvvPJFbtWSmbypxcjpoECLAMzoao0D4Bg5ZQ==} engines: {node: ^14 || ^16 || ^17 || ^18 || ^19} @@ -3220,17 +3215,6 @@ packages: which: 1.3.1 dev: true - /cross-spawn@6.0.5: - resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} - engines: {node: '>=4.8'} - dependencies: - nice-try: 1.0.5 - path-key: 2.0.1 - semver: 5.7.1 - shebang-command: 1.2.0 - which: 1.3.1 - dev: true - /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -6685,11 +6669,6 @@ packages: resolution: {integrity: sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==} dev: true - /memorystream@0.3.1: - resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} - engines: {node: '>= 0.10.0'} - dev: true - /meow@10.1.5: resolution: {integrity: sha512-/d+PQ4GKmGvM9Bee/DPa8z3mXs/pkvJE2KEThngVNOqtmljC6K7NMPxtc2JeZYTmpWb9k/TmxjeL18ez3h7vCw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -6937,19 +6916,6 @@ packages: type-fest: 2.19.0 dev: true - /next-bundle-analyzer@0.6.7(next@13.2.4): - resolution: {integrity: sha512-1fCPDnrw5nqRKe7guOlI6ko+ChKBrpmfIsFKTCEKsSX4nTJz0TTUQr/Gtj8Y3suz3Yv5quo5A2vUuG8J5bml+A==} - peerDependencies: - next: 10 || 11 || 12 || 13 - dependencies: - next: 13.2.4(@babel/core@7.21.3)(react-dom@18.2.0)(react@18.2.0) - open: 8.4.2 - webpack-bundle-analyzer: 4.8.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: true - /next-sitemap@4.0.6(@next/env@13.2.4)(next@13.2.4): resolution: {integrity: sha512-pZ9tynYe6mRR189qZqcOlWVgM1Gxo07BJQW0AjerKmLwQOt+6FQMdaDgifgCt6jDT3Y3EG/+NUDDZRcd0gbPkA==} engines: {node: '>=14.18'} @@ -7010,10 +6976,6 @@ packages: - '@babel/core' - babel-plugin-macros - /nice-try@1.0.5: - resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} - dev: true - /node-abi@3.33.0: resolution: {integrity: sha512-7GGVawqyHF4pfd0YFybhv/eM9JwTtPqx0mAanQ146O3FlSh3pA24zf9IRQTOsfTSqXTNzPSP5iagAJ94jjuVog==} engines: {node: '>=10'} @@ -7140,22 +7102,6 @@ packages: - supports-color dev: true - /npm-run-all@4.1.5: - resolution: {integrity: sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==} - engines: {node: '>= 4'} - hasBin: true - dependencies: - ansi-styles: 3.2.1 - chalk: 2.4.2 - cross-spawn: 6.0.5 - memorystream: 0.3.1 - minimatch: 3.1.2 - pidtree: 0.3.1 - read-pkg: 3.0.0 - shell-quote: 1.8.0 - string.prototype.padend: 3.1.4 - dev: true - /npm-run-path@1.0.0: resolution: {integrity: sha512-PrGAi1SLlqNvKN5uGBjIgnrTb8fl0Jz0a3JJmeMcGnIBh7UE9Gc4zsAMlwDajOMg2b1OgP6UPvoLUboTmMZPFA==} engines: {node: '>=0.10.0'} @@ -7557,11 +7503,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /path-key@2.0.1: - resolution: {integrity: sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==} - engines: {node: '>=4'} - dev: true - /path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -7604,12 +7545,6 @@ packages: engines: {node: '>=8.6'} dev: true - /pidtree@0.3.1: - resolution: {integrity: sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==} - engines: {node: '>=0.10'} - hasBin: true - dev: true - /pidtree@0.6.0: resolution: {integrity: sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==} engines: {node: '>=0.10'} @@ -8574,13 +8509,6 @@ packages: tunnel-agent: 0.6.0 dev: true - /shebang-command@1.2.0: - resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} - engines: {node: '>=0.10.0'} - dependencies: - shebang-regex: 1.0.0 - dev: true - /shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -8588,11 +8516,6 @@ packages: shebang-regex: 3.0.0 dev: true - /shebang-regex@1.0.0: - resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==} - engines: {node: '>=0.10.0'} - dev: true - /shebang-regex@3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} @@ -8602,10 +8525,6 @@ packages: resolution: {integrity: sha512-lT297f1WLAdq0A4O+AknIFRP6kkiI3s8C913eJ0XqBxJbZPGWUNkRQk2u8zk4bEAjUJ5i+fSLwB6z1HzeT+DEg==} dev: true - /shell-quote@1.8.0: - resolution: {integrity: sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==} - dev: true - /shelljs@0.8.5: resolution: {integrity: sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==} engines: {node: '>=4'} @@ -8878,15 +8797,6 @@ packages: side-channel: 1.0.4 dev: true - /string.prototype.padend@3.1.4: - resolution: {integrity: sha512-67otBXoksdjsnXXRUq+KMVTdlVRZ2af422Y0aTyTjVaoQkGr3mxl2Bc5emi7dOQ3OGVVQQskmLEWwFXwommpNw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.21.2 - dev: true - /string.prototype.trim@1.2.7: resolution: {integrity: sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg==} engines: {node: '>= 0.4'} @@ -9287,6 +9197,12 @@ packages: globrex: 0.1.2 dev: true + /title-case@3.0.3: + resolution: {integrity: sha512-e1zGYRvbffpcHIrnuqT0Dh+gEJtDaxDSoG4JAIpq4oDFyooziLBIiYQv0GBT4FUAnUop5uZ1hiIAj7oAF6sOCA==} + dependencies: + tslib: 2.5.0 + dev: true + /titleize@1.0.1: resolution: {integrity: sha512-rUwGDruKq1gX+FFHbTl5qjI7teVO7eOe+C8IcQ7QT+1BK3eEUXJqbZcBOeaRP4FwSC/C1A5jDoIVta0nIQ9yew==} engines: {node: '>=0.10.0'} @@ -9446,6 +9362,67 @@ packages: safe-buffer: 5.2.1 dev: true + /turbo-darwin-64@1.8.8: + resolution: {integrity: sha512-18cSeIm7aeEvIxGyq7PVoFyEnPpWDM/0CpZvXKHpQ6qMTkfNt517qVqUTAwsIYqNS8xazcKAqkNbvU1V49n65Q==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /turbo-darwin-arm64@1.8.8: + resolution: {integrity: sha512-ruGRI9nHxojIGLQv1TPgN7ud4HO4V8mFBwSgO6oDoZTNuk5ybWybItGR+yu6fni5vJoyMHXOYA2srnxvOc7hjQ==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /turbo-linux-64@1.8.8: + resolution: {integrity: sha512-N/GkHTHeIQogXB1/6ZWfxHx+ubYeb8Jlq3b/3jnU4zLucpZzTQ8XkXIAfJG/TL3Q7ON7xQ8yGOyGLhHL7MpFRg==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /turbo-linux-arm64@1.8.8: + resolution: {integrity: sha512-hKqLbBHgUkYf2Ww8uBL9UYdBFQ5677a7QXdsFhONXoACbDUPvpK4BKlz3NN7G4NZ+g9dGju+OJJjQP0VXRHb5w==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /turbo-windows-64@1.8.8: + resolution: {integrity: sha512-2ndjDJyzkNslXxLt+PQuU21AHJWc8f6MnLypXy3KsN4EyX/uKKGZS0QJWz27PeHg0JS75PVvhfFV+L9t9i+Yyg==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /turbo-windows-arm64@1.8.8: + resolution: {integrity: sha512-xCA3oxgmW9OMqpI34AAmKfOVsfDljhD5YBwgs0ZDsn5h3kCHhC4x9W5dDk1oyQ4F5EXSH3xVym5/xl1J6WRpUg==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /turbo@1.8.8: + resolution: {integrity: sha512-qYJ5NjoTX+591/x09KgsDOPVDUJfU9GoS+6jszQQlLp1AHrf1wRFA3Yps8U+/HTG03q0M4qouOfOLtRQP4QypA==} + hasBin: true + requiresBuild: true + optionalDependencies: + turbo-darwin-64: 1.8.8 + turbo-darwin-arm64: 1.8.8 + turbo-linux-64: 1.8.8 + turbo-linux-arm64: 1.8.8 + turbo-windows-64: 1.8.8 + turbo-windows-arm64: 1.8.8 + dev: true + /type-check@0.3.2: resolution: {integrity: sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==} engines: {node: '>= 0.8.0'} @@ -9766,26 +9743,6 @@ packages: - utf-8-validate dev: true - /webpack-bundle-analyzer@4.8.0: - resolution: {integrity: sha512-ZzoSBePshOKhr+hd8u6oCkZVwpVaXgpw23ScGLFpR6SjYI7+7iIWYarjN6OEYOfRt8o7ZyZZQk0DuMizJ+LEIg==} - engines: {node: '>= 10.13.0'} - hasBin: true - dependencies: - '@discoveryjs/json-ext': 0.5.7 - acorn: 8.8.2 - acorn-walk: 8.2.0 - chalk: 4.1.2 - commander: 7.2.0 - gzip-size: 6.0.0 - lodash: 4.17.21 - opener: 1.5.2 - sirv: 1.0.19 - ws: 7.5.9 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: true - /whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} dependencies: diff --git a/release-it/conventionalChangelogWriterOptsTransform.cjs b/release-it/conventionalChangelogWriterOptsTransform.cjs index 45ce0e5..0c6a3bb 100644 --- a/release-it/conventionalChangelogWriterOptsTransform.cjs +++ b/release-it/conventionalChangelogWriterOptsTransform.cjs @@ -1,16 +1,33 @@ -const path = require("path"); -const fs = require("fs"); +const { titleCase } = require("title-case"); +const { resolve } = require("path"); +const { readFileSync } = require("fs"); const remoteCommits = require("./remote-commits.json"); -// expand on the simple mustache-style templates supported in -// configuration (we may eventually want to use handlebars for this). -function expandTemplate(template, context) { - let expanded = template; - Object.keys(context).forEach((key) => { - expanded = expanded.replace(new RegExp(`{{${key}}}`, "g"), context[key]); - }); - return expanded; -} +const types = [ + { type: "feat", section: "โญ New Features" }, + { type: "fix", section: "๐Ÿž Bug Fixes" }, + { + type: "refactor", + section: "โ™ป๏ธ Refactors", + }, + { + type: "perf", + section: "โšก๏ธ Performance Improvements", + }, + { + type: "docs", + section: "๐Ÿ“” Documentation Changes", + }, + { type: "test", section: "๐Ÿงช Test Updates" }, + { type: "build", section: "๐Ÿ‘ท Build Updates" }, + { type: "ci", section: "๐Ÿ’š CI Changes" }, + { type: "revert", section: "โช๏ธ Reverted Changes" }, + { + type: "chore", + section: "๐Ÿ”จ Maintenance Updates", + }, + { type: "style", section: "๐ŸŽจ Other Changes" }, +]; function findTypeEntry(types, commit) { const typeKey = (commit.revert ? "revert" : commit.type || "").toLowerCase(); @@ -18,50 +35,150 @@ function findTypeEntry(types, commit) { if (entry.type !== typeKey) { return false; } + if (entry.scope && entry.scope !== commit.scope) { return false; } + return true; }); } -const types = [ - { type: "feat", section: "Feature Updates" }, - { type: "fix", section: "Bug Fixes" }, - { - type: "refactor", - section: "Code Refactors", - }, - { - type: "docs", - section: "Documentation Changes", - }, - { - type: "chore", - section: "Maintenance Updates", - }, - { type: "build", section: "Build Updates" }, - { type: "test", section: "Test Updates" }, - { type: "style", section: "Other Changes" }, +const owner = + "{{#if this.owner}}{{~this.owner}}{{else}}{{~@root.owner}}{{/if}}"; +const host = "{{~@root.host}}"; +const repository = + "{{#if this.repository}}{{~this.repository}}{{else}}{{~@root.repository}}{{/if}}"; + +const commitUrlFormat = expandTemplate( + "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}", { - type: "perf", - section: "Performance Improvements", + host, + owner, + repository, }, - { type: "ci", section: "CI Changes" }, - { type: "revert", section: "Updates Reverted" }, -]; +); + +function addBangNotes(commit, context) { + const match = commit.header.match(/^(\w*)(?:\((.*)\))?!: (.*)$/); + + if (match) { + const noteText = match[3]; // the description of the change. + + const commitHashUrl = `${context.host}/${context.owner}/${context.repository}/commit/${commit.hash}`; + + commit.notes.push({ + text: (commit?.body && commit.body) || noteText, + scope: commit?.scope, + body: commit?.body, + shortHash: commit.shortHash, + hashUrl: commitHashUrl, + }); + + // Remove the commit to the notable changes as it will be added as breaking change + commit.body = null; + } +} + +function addNotableChanges(commit, context) { + if (commit?.body) { + const commitHashUrl = `${context.host}/${context.owner}/${context.repository}/commit/${commit.hash}`; -const conventionalChangelogWriterOptsTransform = (commit, context) => { + context.notableChanges.push({ + scope: commit?.scope + ? titleCase(commit.scope.replaceAll(".", " ")).replaceAll("-", " ") + : null, + body: commit.body, + shortHash: commit.shortHash, + hashUrl: commitHashUrl, + }); + } +} + +// expand on the simple mustache-style templates supported in +// configuration (we may eventually want to use handlebars for this). +function expandTemplate(template, context) { + let expanded = template; + Object.keys(context).forEach((key) => { + expanded = expanded.replace(new RegExp(`{{${key}}}`, "g"), context[key]); + }); + return expanded; +} + +const releaseAsRe = + /release-as:\s*\w*@?([0-9]+\.[0-9]+\.[0-9a-z]+(-[0-9a-z.]+)?)\s*/i; + +const transform = (commit, context) => { + if (commit.shortHash === "2a31131") { + console.log( + "๐Ÿš€ ~ file: conventionalChangelogWriterOptsTransform.cjs:55 ~ conventionalChangelogWriterOptsTransform ~ commit:", + commit, + ); + console.log( + "๐Ÿš€ ~ file: conventionalChangelogWriterOptsTransform.cjs:55 ~ conventionalChangelogWriterOptsTransform ~ context:", + context, + ); + } + + // Remove commit body if it's author is a bot + if (commit.authorName === "renovate[bot]") { + commit.body = ""; + } + + let discard = true; const issues = []; const entry = findTypeEntry(types, commit); if (entry) commit.type = entry.section; + // adds additional breaking change notes + // for the special case, test(system)!: hello world, where there is + // a '!' but no 'BREAKING CHANGE' in body: + addBangNotes(commit, context); + + // Add an entry in the CHANGELOG if special Release-As footer + // is used: + if ( + (commit.footer && releaseAsRe.test(commit.footer)) || + (commit.body && releaseAsRe.test(commit.body)) + ) { + discard = false; + } + + commit.notes.forEach((note) => { + note.title = "BREAKING CHANGES"; + discard = false; + }); + + context.hasNotableChanges = true; + context.notableChangesTitle = "๐Ÿ‘€ Notable Changes"; + context.notableChanges = context.notableChanges || []; + + addNotableChanges(commit, context); + + if (context.notableChanges.length === 0) { + context.hasNotableChanges = false; + } + + // breaking changes attached to any type are still displayed. + if (discard && (entry === undefined || entry.hidden)) return; + + if (entry) commit.type = entry.section; + + if (commit.scope === "*") { + commit.scope = ""; + } + + if (typeof commit.hash === "string") { + commit.shortHash = commit.hash.substring(0, 7); + } + if (typeof commit.subject === "string") { const issueRegEx = `([#].join("|"))` + `([0-9]+)`; const re = new RegExp(issueRegEx, "g"); commit.subject = commit.subject.replace(re, (_, prefix, issue) => { issues.push(prefix + issue); + const url = expandTemplate( "{{host}}/{{owner}}/{{repository}}/issues/{{id}}", { @@ -72,6 +189,7 @@ const conventionalChangelogWriterOptsTransform = (commit, context) => { prefix, }, ); + return `[${prefix}${issue}](${url})`; }); @@ -116,20 +234,17 @@ const conventionalChangelogWriterOptsTransform = (commit, context) => { return commit; }; -const owner = - "{{#if this.owner}}{{~this.owner}}{{else}}{{~@root.owner}}{{/if}}"; -const host = "{{~@root.host}}"; -const repository = - "{{#if this.repository}}{{~this.repository}}{{else}}{{~@root.repository}}{{/if}}"; +const template = readFileSync( + resolve(__dirname, "./templates/template.hbs"), + "utf-8", +); +const mainTemplate = template; -const commitUrlFormat = expandTemplate( - "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}", - { - host, - owner, - repository, - }, +const commit = readFileSync( + resolve(__dirname, "./templates/commit.hbs"), + "utf-8", ); + const issueUrlFormat = expandTemplate( "{{host}}/{{owner}}/{{repository}}/issues/{{id}}", { @@ -140,11 +255,37 @@ const issueUrlFormat = expandTemplate( prefix: "{{this.prefix}}", }, ); -const commitTemplateString = fs - .readFileSync(path.resolve("release-it", "commit.hbs")) - .toString(); -const commitTemplate = commitTemplateString + +const commitPartial = commit .replace(/{{commitUrlFormat}}/g, commitUrlFormat) .replace(/{{issueUrlFormat}}/g, issueUrlFormat); -module.exports = { conventionalChangelogWriterOptsTransform, commitTemplate }; +const commitGroupsSort = (a, b) => { + const commitGroupOrder = [ + "๐ŸŽจ Other Changes", + "๐Ÿ’š CI Changes", + "๐Ÿ”จ Maintenance Updates", + "๐Ÿ“” Documentation Changes", + "๐Ÿงช Test Updates", + "๐Ÿ‘ท Build Updates", + "โช๏ธ Reverted Changes", + "โšก๏ธ Performance Improvements", + "โ™ป๏ธ Refactors", + "๐Ÿž Bug Fixes", + "โญ New Features", + ]; + const gRankA = commitGroupOrder.indexOf(a.title); + const gRankB = commitGroupOrder.indexOf(b.title); + if (gRankA >= gRankB) { + return -1; + } else { + return 1; + } +}; + +module.exports = { + transform, + mainTemplate, + commitPartial, + commitGroupsSort, +}; diff --git a/release-it/getCommitsSinceLastRelease.js b/release-it/getCommitsSinceLastRelease.js index 3f24c80..6f064d9 100644 --- a/release-it/getCommitsSinceLastRelease.js +++ b/release-it/getCommitsSinceLastRelease.js @@ -29,7 +29,6 @@ const getOldestCommitSinceLastTag = async () => { }; const octokit = new Octokit({ - // eslint-disable-next-line node/no-process-env auth: `token ${process.env.GITHUB_TOKEN}`, }); diff --git a/release-it/commit.hbs b/release-it/templates/commit.hbs similarity index 53% rename from release-it/commit.hbs rename to release-it/templates/commit.hbs index 9b6c823..08a8e40 100644 --- a/release-it/commit.hbs +++ b/release-it/templates/commit.hbs @@ -1,15 +1,19 @@ -*{{#if scope}} **{{scope}}:** -{{~/if}} {{#if subject}} - {{~subject}} +- {{#if scope}}**`{{scope}}:`** {{/if}} + +{{~#if subject}} +{{subject}} {{~else}} - {{~header}} +{{header}} {{~/if}} -{{~!-- commit link --}}{{~#if hash}} {{#if @root.linkReferences~}} - ([{{shortHash}}]({{commitUrlFormat}})) {{~#if userLogin}} by @{{userLogin}} {{~/if}} +{{~#if @root.linkReferences}} + [{{shortHash}}]({{commitUrlFormat}}) {{~else}} - {{~shortHash}} {{~#if userLogin}} by @{{userLogin}} {{~/if}} -{{~/if}}{{~/if}} + {{shortHash}} +{{~/if}} + +{{~!-- commit author details --}} +{{~#if userLogin}} by @{{userLogin}} {{~/if}} {{~!-- commit references --}} {{~#if references~}} @@ -28,18 +32,4 @@ {{~/if}}{{/each}} {{~/if}} -{{~#if body}} - {{#raw}}{{/raw}} - {{#if body}} - ---- - -{{body}} - ---- - - {{/if}} - {{#raw}}{{/raw}} -{{~/if}} - {{#raw}}{{/raw}} diff --git a/release-it/templates/template.hbs b/release-it/templates/template.hbs new file mode 100644 index 0000000..dde2443 --- /dev/null +++ b/release-it/templates/template.hbs @@ -0,0 +1,67 @@ +{{> header}} + +{{#if noteGroups}} +{{#each noteGroups}} + +### โš  {{title}} + +{{#raw}}{{/raw}} + +{{#each notes}} + +{{#if scope}}#### `{{scope}}` {{/if}} + +{{~#if body}} +{{text}} +{{~else}} +- {{text}} +{{~/if}} + +{{#raw}}{{/raw}} + +Introduced in: [`{{shortHash}}`]({{hashUrl}}) + +{{#raw}}{{/raw}} + +{{/each}} + +{{~/each}} +{{~/if}} + +{{~#if hasNotableChanges}} + +### {{notableChangesTitle}} + +{{#raw}}{{/raw}} + +{{#each notableChanges}} + +{{#if scope}}#### `{{scope}}` {{/if}} + +{{#if body}} +{{body}} +{{~/if}} + +{{#raw}}{{/raw}} + +Introduced in: [`{{shortHash}}`]({{hashUrl}}) + +{{#raw}}{{/raw}} + +{{/each}} + +{{/if}} + +### Commits + +{{#each commitGroups}} + +{{#if title}} +#### {{title}} +{{/if}} + +{{#each commits}} +{{> commit root=@root}} +{{/each}} + +{{/each}} diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..725d750 --- /dev/null +++ b/turbo.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build:next": { + "dependsOn": ["lint:eslint", "lint:types"], + "outputs": [".next/**", "!.next/cache/**"] + }, + "test": {}, + "lint:eslint": { + "outputs": [".eslintcache"] + }, + "lint:types": {}, + "lint:css": { + "inputs": ["**/*.css"], + "outputs": [".stylelintcache"] + }, + "lint:md": { + "inputs": ["**/*.md", ".github/**/*.md"] + }, + "lint:knip": { + "inputs": ["src/pages/**/*.{js,jsx,ts,tsx}"] + }, + "lint:package-json": { + "inputs": ["package.json"] + }, + "lint:prettier": { + "outputs": [".prettiercache"] + }, + "lint:spelling": {}, + "format:eslint": { + "outputs": [".eslintcache"] + }, + "format:css": { + "inputs": ["**/*.css"], + "outputs": [".stylelintcache"] + }, + "format:md": { + "inputs": ["**/*.md", ".github/**/*.md"] + }, + "format:prettier": { + "dependsOn": ["format:eslint", "format:css", "format:md"], + "outputs": [".prettiercache"] + } + } +}