MCPcopy
hub / github.com/di-sukharev/opencommit / configureCommitlintIntegration

Function configureCommitlintIntegration

out/cli.cjs:85158–85202  ·  view source on GitHub ↗
(force = false)

Source from the content-addressed store, hash-verified

85156 content.toString()
85157 );
85158 return commitLintLLMConfig;
85159};
85160
85161// src/modules/commitlint/config.ts
85162var config3 = getConfig();
85163var translation2 = i18n[config3.OCO_LANGUAGE || "en"];
85164var 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 };

Callers 2

getMainCommitPromptFunction · 0.70
cli.cjsFile · 0.70

Calls 13

getCommitLintPWDConfigFunction · 0.70
computeHashFunction · 0.70
getCommitlintLLMConfigFunction · 0.70
getEngineFunction · 0.70
getJSONBlockFunction · 0.70
removeDoubleNewlinesFunction · 0.70
writeCommitlintLLMConfigFunction · 0.70
generateCommitMessageMethod · 0.65
startMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…