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

chore(deps): Upgrade dependencies #15

Merged
merged 10 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .changeset/mean-bugs-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
"@kevintyj/prlint": major
---

Adds pure native ESM support

**This new major version of prlint updates commitlint package to the new v19.
This update removes support for CJS and only exports the app as a ESM package
(this should not affect the way you use this plugin in any way as the Github
node runner handles ESM just fine).**

### This release drops support for:
- Custom configuration file names:
- The new upgrade takes advantage of the native commitlint config loader to
load the configuration from your project folder. If you do really need support for custom commitlint specification file names such as my-awesome-config-file.jsx, either way you need to be setting up custom commitlint configurations on your environment (which I do not recommend you to do), you could easily just create a symlink pointing to a valid name such as commitlint.config.mjs, this action will be able to work in your workflow without any further setup.

### New features:
- Native ESM & CJS compatibility
- As the new project bundles to native ESM ran on Node, previous handling of
CJS config files are unecessary
- Automatic configuration detection

Upgraded the following dependencies and devDependencies:

Dependencies:

@commitlint/config-conventional: ^18.1.0 -> ^19.2.2
@commitlint/lint: ^18.1.0 -> ^19.2.2
@commitlint/load: ^18.2.0 -> ^19.2.0
DevDependencies:

@antfu/eslint-config: ^2.1.0 -> ^2.21.1
@commitlint/cli: ^18.4.3 -> ^19.3.0
@commitlint/types: ^18.1.0 -> ^19.0.3
@types/node: ^20.9.0 -> ^20.14.8
eslint: ^8.54.0 -> ^8.57.0
lint-staged: ^15.1.0 -> ^15.2.7
rimraf: ^5.0.5 -> ^5.0.7
tsup: ^7.2.0 -> ^8.1.0
typescript: ^5.2.2 -> ^5.5.2
vitest: ^0.34.6 -> ^1.6.0

BREAKING: Upgraded @commitlint packages to v19 which have switched to pure ESM.

11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@ on:
branches:
- main

env:
DEBUG: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 🔖Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📦Setup PNPM
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
- name: 🌳Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: pnpm

- name: 🛠️Install dependencies from lockfile
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/prlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🔖Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📦Setup PNPM
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
version: 9
- name: 🌳Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: pnpm

- name: 🛠️Install dependencies from lockfile
Expand All @@ -33,5 +33,3 @@ jobs:

- name: 📝Validate PR title with commitlint
uses: ./
with:
cl-config: commitlint.config.js
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ jobs:
id-token: write
steps:
- name: 🔖Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📦Setup PNPM
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
version: 9
- name: 🌳Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: pnpm

- name: 🛠️Install dependencies from lockfile
Expand Down
39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Prlint
**Github PR title checker using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec on
# Prlint
**Github PR title checker using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec on
[Changesets](https://github.com/changesets/changesets)**

---
Expand All @@ -10,7 +10,7 @@
[![codecov](https://codecov.io/gh/kevintyj/prlint/graph/badge.svg?token=WBT1WWSLF0)](https://codecov.io/gh/kevintyj/prlint)

## Getting started
### Use as a standalone action
### Use as a standalone action
Use Prlint with any github repository with the latest release.
Checking out the repository is required to fetch the `commitlint.config.js`

Expand All @@ -27,49 +27,56 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🔖Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📦Setup PNPM
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
version: 9
- name: 🌳Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: pnpm
- name: 🛠️Install dependencies for prlint
run: pnpm install @commitlint/config-conventional
- name: 📝Validate PR title with commitlint
uses: kevintyj/prlint@v1
# Optional
with:
cl-config: commitlint-cjs.config.cjs
uses: kevintyj/prlint@v2
```
The above action only check's out the current repository to fetch the commitlint configuration file.
PNPM and node is used to install necessary dependencies, then config-conventional is used as a default config.
When using the above configuration, `pnpm-lock.yaml` is required. Please use npm and node if `package-lock.json` is used.

## v2 release
**This new major version of prlint updates commitlint package to the new v19.
This update removes support for CJS and only exports the app as a ESM package
(this should not affect the way you use this plugin in any way as the Github
node runner handles ESM just fine).**

### Inputs
#### `cl-config`
**Optional** Path to commit lint config. Default : `'commitlint.config.js'`

### Outputs
> Removed in v2

### Outputs
#### `lint-status`
Status of the lint result. Returns `✅ Commitlint tests passed!` if successful and `❌ Commitlint tests failed` if
Status of the lint result. Returns `✅ Commitlint tests passed!` if successful and `❌ Commitlint tests failed` if
linter tests fail.
#### `lint-details`
Output of the commitlint result.

### Limitations
The current action of Prlint only accepts javascript based configurations on commitlint.
The current action of Prlint only accepts javascript based configurations on commitlint.
`v1.0.1` introduced support for ESM based configuration files. `v1.1.0` introduced support for custom config file names.
However, due to ESM support added in `v1.0.1` non `js` config files such as `yaml` or `json` is not supported.

Even if the project does not use `config-conventional`, the Prlint uses the configuration as a fallback, therefore the
Even if the project does not use `config-conventional`, the Prlint uses the configuration as a fallback, therefore the
project must contain the `config-conventional` package as a development dependency.

> Above behavior corrected in v2

## Changelog
See [CHANGELOG](CHANGELOG.md) for the release details

Expand Down
8 changes: 3 additions & 5 deletions __tests__/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import load from '@commitlint/load';
import { testLintOptions, verifyTitle } from '../src/lint';

const { getLintOptions, convertESMtoCJS } = testLintOptions;
const { getLintOptions } = testLintOptions;

Check warning on line 6 in __tests__/lint.test.ts

View workflow job for this annotation

GitHub Actions / build

Unsafe assignment of an error typed value

/* eslint-disable regexp/no-super-linear-backtracking */
const emptyConfigOption = {
defaultIgnores: true,
helpUrl: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
Expand All @@ -30,6 +31,7 @@
},
plugins: {},
};
/* eslint-enable regexp/no-super-linear-backtracking */

const emptyConfigOptionNoParserOpts = {
defaultIgnores: true,
Expand Down Expand Up @@ -69,8 +71,4 @@
await expect(verifyTitle('feat: Title is short and nice!', 'something.config.js')).resolves.toEqual(true);
await expect(verifyTitle('test: Add test suites', 'commitlint.config.js')).resolves.toEqual(true);
});

it('return error if file for esm conversion does not exist', async () => {
await expect(convertESMtoCJS('dne.js', 'dne.cjs')).rejects.toThrowError(/no such file or directory/);
});
});
5 changes: 0 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ description: Ensure PR title match commitlint config
runs:
using: node20
main: dist/index.js
inputs:
cl-config:
description: Path to commit lint config (commitlint.config.js)
default: commitlint.config.js
required: false
outputs:
lint-status:
description: The status of the PR lint
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- src/index.ts
Loading
Loading