opencommit icon indicating copy to clipboard operation
opencommit copied to clipboard

🐛Fix: prompt-module/@commitlint

Open matscube opened this issue 1 year ago • 2 comments

Current Issue

  • The OCO_PROMPT_MODULE=@commitlint functionality is currently not working as expected. The following steps reproduce the issue:
    • Run npm i @commitlint/cli
    • Create commitlint.config.js
    • Set OCO_PROMPT_MODULE=@commitlint
    • run oco commitlint force
    • => An error occurs

Identified Problems

  • There's a bug in src/modules/commitlint/utils.ts#getJSONBlock
    • consistency is not defined (a misspelling of input).
  • The method src/modules/commitlint/pwd-commitlint.ts#getCommitLintPWDConfig only supports the CJS version of the @commitlint/load package.
    • This method calls the @commitlint/load package using require. However, commitlint v19 and onwards only support pure ESM.

Proposed Changes

  • Fix the OCO_PROMPT_MODULE=@commitlint functionality
    • by correcting the bug in src/modules/commitlint/utils.ts#getJSONBlock.
  • Add support for the ESM version of @commitlint.
    • This change will ensure compatibility with both CJS and ESM versions of @commitlint.
    • Currently, the minimum supported version is v9 (as CJS) and the maximum supported version is v19 (as ESM, latest).
  • Add end-to-end tests related to commitlint to ensure the functionality works as expected.

Checklist

  • [x] Manual Setup
    • git init
    • npm init
    • Setup commitlint
      • for v19
        • install commitlint( npm install --save-dev @commitlint/{cli,config-conventional}@19.x )
        • create commitlint config (as esm)
          • echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
        • set type: module in package.json
      • for v18
        • install commitlint ( npm install --save-dev @commitlint/{cli,config-conventional}@18.x )
        • create commitlint config (as cjs)
          • echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
    • Run oco config set OCO_PROMPT_MODULE=@commitlint
    • Run oco commitlint force
    • Run oco
    • Edit .opencommit-commitlint config
    • Run oco again

matscube avatar May 10 '24 02:05 matscube

hi man, please calm down! haha <3

let me know when i can review and merge it

di-sukharev avatar May 10 '24 09:05 di-sukharev

@di-sukharev Hello, The PR is ready and I wanted to let you know. Please review it.

matscube avatar May 18 '24 13:05 matscube