mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-20 19:18:08 -05:00
* feat: support pnpm * fix(commitlint.ts): format commitlint config output as JSON for better readability * test(commitlint.test.ts): update expected console output for commit message consistency
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { intro, outro } from '@clack/prompts';
|
|
import chalk from 'chalk';
|
|
import { command } from 'cleye';
|
|
import { configureCommitlintIntegration } from '../modules/commitlint/config';
|
|
import { getCommitlintLLMConfig } from '../modules/commitlint/utils';
|
|
import { COMMANDS } from './ENUMS';
|
|
|
|
export enum CONFIG_MODES {
|
|
get = 'get',
|
|
force = 'force'
|
|
}
|
|
|
|
export const commitlintConfigCommand = command(
|
|
{
|
|
name: COMMANDS.commitlint,
|
|
parameters: ['<mode>']
|
|
},
|
|
async (argv) => {
|
|
intro('opencommit — configure @commitlint');
|
|
try {
|
|
const { mode } = argv._;
|
|
|
|
if (mode === CONFIG_MODES.get) {
|
|
const commitLintConfig = await getCommitlintLLMConfig();
|
|
|
|
outro(JSON.stringify(commitLintConfig, null, 2));
|
|
|
|
return;
|
|
}
|
|
|
|
if (mode === CONFIG_MODES.force) {
|
|
await configureCommitlintIntegration(true);
|
|
return;
|
|
}
|
|
|
|
throw new Error(
|
|
`Unsupported mode: ${mode}. Valid modes are: "force" and "get"`
|
|
);
|
|
} catch (error) {
|
|
outro(`${chalk.red('✖')} ${error}`);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
);
|