(force = false)
| 85156 | content.toString() |
| 85157 | ); |
| 85158 | return commitLintLLMConfig; |
| 85159 | }; |
| 85160 | |
| 85161 | // src/modules/commitlint/config.ts |
| 85162 | var config3 = getConfig(); |
| 85163 | var translation2 = i18n[config3.OCO_LANGUAGE || "en"]; |
| 85164 | var configureCommitlintIntegration = async (force = false) => { |
| 85165 | const spin = le(); |
| 85166 | spin.start("Loading @commitlint configuration"); |
| 85167 | const fileExists = await commitlintLLMConfigExists(); |
| 85168 | const commitLintConfig = await getCommitLintPWDConfig(); |
| 85169 | if (commitLintConfig === null) { |
| 85170 | throw new Error( |
| 85171 | `Failed to load @commitlint config. Please check the following: |
| 85172 | * @commitlint >= 9.0.0 is installed in the local directory. |
| 85173 | * 'node_modules/@commitlint/load' package exists. |
| 85174 | * A valid @commitlint configuration exists. |
| 85175 | ` |
| 85176 | ); |
| 85177 | } |
| 85178 | const hash = await computeHash(JSON.stringify(commitLintConfig)); |
| 85179 | spin.stop(`Read @commitlint configuration (hash: ${hash})`); |
| 85180 | if (fileExists) { |
| 85181 | const { hash: existingHash } = await getCommitlintLLMConfig(); |
| 85182 | if (hash === existingHash && !force) { |
| 85183 | spin.stop( |
| 85184 | 'Hashes are the same, no need to update the config. Run "force" command to bypass.' |
| 85185 | ); |
| 85186 | return; |
| 85187 | } |
| 85188 | } |
| 85189 | spin.start("Generating consistency with given @commitlint rules"); |
| 85190 | const prompts = inferPromptsFromCommitlintConfig(commitLintConfig); |
| 85191 | const consistencyPrompts = commitlintPrompts.GEN_COMMITLINT_CONSISTENCY_PROMPT(prompts); |
| 85192 | const engine = getEngine(); |
| 85193 | let consistency = await engine.generateCommitMessage(consistencyPrompts) || "{}"; |
| 85194 | prompts.forEach((prompt) => consistency = consistency.replace(prompt, "")); |
| 85195 | consistency = getJSONBlock(consistency); |
| 85196 | consistency = removeDoubleNewlines(consistency); |
| 85197 | const commitlintLLMConfig = { |
| 85198 | hash, |
| 85199 | prompts, |
| 85200 | consistency: { |
| 85201 | [translation2.localLanguage]: { |
| 85202 | ...JSON.parse(consistency) |
| 85203 | } |
| 85204 | } |
| 85205 | }; |
no test coverage detected
searching dependent graphs…