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

Bump cosmiconfig version and conditionally support mjs config #3747

Merged
merged 15 commits into from Nov 10, 2023

Conversation

joberstein
Copy link
Contributor

@joberstein joberstein commented Nov 8, 2023

Bump cosmiconfig version and conditionally support mjs config. Also simplify CI test matrix and add more tests for the different config files.

Draft until I do manual testing + need to update docs too.

Description

This PR:

  • Bumps the cosmiconfig version to latest (v8.3.6)
  • Adds additional tests for each variation of acceptable config files (.commitlintrc.xxx and commitling.config.xxx)
  • Conditionally supports loading mjs configuration files (node engine must be >= 20.8.0). Otherwise, mjs configuration files are not supported.
  • Conditionally supports async loaders for js/cjs configuration files (node engine must be >= 20.8.0). Otherwise, js/cjs configuration files are loaded using the synchronous loaders (underlying implementation is the same).

Motivation and Context

Replacement PR for automated PR: #3654

Also resolves: #3611

Usage examples

With node >= 20.8.0, a user can now specify commitlint config in '.commitlintrc.mjs' or 'commitlint.config.mjs'.

How Has This Been Tested?

  • Unit/Integration tests
  • Manual testing - tested by creating a new empty repo locally with a commitlint config for mjs (separately with .commitlintrc.mjs and commitlint.config.mjs). I locally installed @commitlint/cli with a locally installed @commitlint/load. With node 20.9.0, I verified that the mjs config was loaded successfully. With node v18.18.2, I verified that the mjs config was not parsed (current behavior). I did not need the "type": "module" property in my package.json, so I will only modify the README to add the new file types.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

image: 'ubuntu:22.04'
build:
strategy:
matrix:
Copy link
Contributor Author

@joberstein joberstein Nov 8, 2023

Choose a reason for hiding this comment

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

Simplified this with the build matrix so they all run the same steps, but @escapedcat do I need to keep the original checks around temporarily?

I did this to take advantage of the fact that the setup node action pulls down node 20.9.0, whereas the original job pulled down only 20.5.x and I didn't see a way to configure it.

Copy link
Member

Choose a reason for hiding this comment

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

I think pulling latest v20 is fine.
Thanks for introducing the matrix. Simplifies things in the future.
I might need to adjust the required checks in the settings. Will check.

@@ -186,6 +188,44 @@ test('respects cwd option', async () => {
});
});

const mjsConfigFiles = isDynamicAwaitSupported()
Copy link
Contributor Author

@joberstein joberstein Nov 8, 2023

Choose a reason for hiding this comment

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

New set of tests for each config type. I removed the older tests and their fixture data, but verified they were still passing in an older commit.

const configPath = path.join(__dirname, `../fixtures/config/${configFile}`);
const config = readFileSync(configPath);

writeFileSync(path.join(cwd, configFile), config);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test.each writes a config file from fixtures/config to the template directory and then loads the found config from the current working directory. Everything except ts files should be supported by the template directory.

image: 'ubuntu:22.04'
build:
strategy:
matrix:
Copy link
Member

Choose a reason for hiding this comment

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

I think pulling latest v20 is fine.
Thanks for introducing the matrix. Simplifies things in the future.
I might need to adjust the required checks in the settings. Will check.

@escapedcat
Copy link
Member

If you don't mind you could introduce the matrix checks in a separate PR. We could merge that first, adjust required checks and merge this after.

@escapedcat
Copy link
Member

Thanks a lot for this @joberstein ! ❤️

@joberstein
Copy link
Contributor Author

If you don't mind you could introduce the matrix checks in a separate PR. We could merge that first, adjust required checks and merge this after.

Sure, I'll make a separate one for that first.

@joberstein
Copy link
Contributor Author

If you don't mind you could introduce the matrix checks in a separate PR. We could merge that first, adjust required checks and merge this after.

Link to separate PR is: #3748

@escapedcat
Copy link
Member

Merged the matrix PR, wanna rebase this?

@joberstein joberstein marked this pull request as ready for review November 10, 2023 04:58
@joberstein
Copy link
Contributor Author

@escapedcat I finished manual testing (added a description in the first comment) and updated the docs.

@escapedcat
Copy link
Member

Impressive, thanks! Will merge and release

@escapedcat escapedcat merged commit a2b65fc into conventional-changelog:master Nov 10, 2023
4 checks passed
@B4nan
Copy link

B4nan commented Nov 10, 2023

Looks like this breaks our CI:

https://github.com/mikro-orm/mikro-orm/actions/runs/6823592237/job/18558301519

I can't reproduce this locally now.

@joberstein
Copy link
Contributor Author

joberstein commented Nov 10, 2023

@B4nan I cloned the master branch of your repo and reproduced with a test commit. I noticed that cosmiconfig is at 8.0.0 in its package.json in node_modules though, which is a version from before they added support for mjs files. Going to look into why this version is being installed instead of ^8.0.0 (v8.3.6).

@B4nan
Copy link

B4nan commented Nov 10, 2023

Oh I see, tried to deduplicate the lock file, lets see if that helps

mikro-orm/mikro-orm@f95b57b?w=1

@joberstein
Copy link
Contributor Author

Oh I see, tried to deduplicate the lock file, lets see if that helps

mikro-orm/mikro-orm@f95b57b?w=1

Apparently it's an issue with yarn (maybe npm also?) in that it won't re-install transitive dependencies to meet semver requirements. So even though commitlint/load is using ^8.0.0, since the consuming repo already has installed it as 8.0.0, it won't update unless the commitlint/load cosmiconfig version changes to something compatible (in this case ^8.2.0). I'd like to use an exact version though, so it won't be assumed to update for dependent projects.

I think what you have should work as well though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add support to commitlint.config.mjs and commitlintrc.mjs config file
3 participants