git-coco 0.12.1 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.mjs +35 -39
- package/dist/index.js +35 -39
- package/package.json +1 -1
package/dist/index.esm.mjs
CHANGED
|
@@ -55,7 +55,7 @@ const getCommandUsageHeader = (command) => {
|
|
|
55
55
|
return chalk.green(`${USAGE_BANNER}\n${chalk.white('Command:')}\n\xa0\xa0\xa0\xa0\xa0 $0 ${chalk.greenBright(command)} [options]`);
|
|
56
56
|
};
|
|
57
57
|
const CONFIG_ALREADY_EXISTS = (path) => {
|
|
58
|
-
return `
|
|
58
|
+
return `existing config found in '${path}', do you want to override it?`;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -376,11 +376,11 @@ function loadGitConfig(config) {
|
|
|
376
376
|
if (fs.existsSync(gitConfigPath)) {
|
|
377
377
|
const gitConfigRaw = fs.readFileSync(gitConfigPath, 'utf-8');
|
|
378
378
|
const gitConfigParsed = ini.parse(gitConfigRaw);
|
|
379
|
-
const
|
|
379
|
+
const gitConfigServiceObject = gitConfigParsed.coco?.service;
|
|
380
380
|
let service = config.service;
|
|
381
|
-
if (
|
|
382
|
-
const gitServiceConfig =
|
|
383
|
-
service =
|
|
381
|
+
if (gitConfigServiceObject) {
|
|
382
|
+
const gitServiceConfig = JSON.parse(gitConfigServiceObject);
|
|
383
|
+
service = gitServiceConfig || config?.service;
|
|
384
384
|
}
|
|
385
385
|
config = {
|
|
386
386
|
...config,
|
|
@@ -391,32 +391,11 @@ function loadGitConfig(config) {
|
|
|
391
391
|
ignoredFiles: gitConfigParsed.coco?.ignoredFiles || config.ignoredFiles,
|
|
392
392
|
ignoredExtensions: gitConfigParsed.coco?.ignoredExtensions || config.ignoredExtensions,
|
|
393
393
|
defaultBranch: gitConfigParsed.coco?.defaultBranch || config.defaultBranch,
|
|
394
|
+
verbose: gitConfigParsed.coco?.verbose || config.verbose,
|
|
394
395
|
};
|
|
395
396
|
}
|
|
396
397
|
return removeUndefined(config);
|
|
397
398
|
}
|
|
398
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
399
|
-
function parseServiceConfig$1(service) {
|
|
400
|
-
if (!service)
|
|
401
|
-
return undefined;
|
|
402
|
-
switch (service.provider) {
|
|
403
|
-
case 'openai':
|
|
404
|
-
return {
|
|
405
|
-
provider: 'openai',
|
|
406
|
-
model: service.model,
|
|
407
|
-
fields: { apiKey: service.apiKey },
|
|
408
|
-
};
|
|
409
|
-
case 'ollama':
|
|
410
|
-
return {
|
|
411
|
-
provider: 'ollama',
|
|
412
|
-
model: service.model,
|
|
413
|
-
endpoint: service.endpoint,
|
|
414
|
-
fields: service.fields,
|
|
415
|
-
};
|
|
416
|
-
default:
|
|
417
|
-
return undefined;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
399
|
/**
|
|
421
400
|
* Appends the provided configuration to a git config file.
|
|
422
401
|
*
|
|
@@ -431,15 +410,18 @@ const appendToGitConfig = async (filePath, config) => {
|
|
|
431
410
|
const getNewContent = async () => {
|
|
432
411
|
const contentLines = [header];
|
|
433
412
|
for (const key in config) {
|
|
434
|
-
|
|
435
|
-
if (typeof
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
413
|
+
const value = config[key];
|
|
414
|
+
if (typeof value === 'object') {
|
|
415
|
+
// Serialize object to JSON string
|
|
416
|
+
contentLines.push(`\t${key} = ${JSON.stringify(value)}`);
|
|
417
|
+
}
|
|
418
|
+
else if (typeof value === 'string' && value.includes('\n')) {
|
|
419
|
+
// Wrap strings with new lines in quotes
|
|
420
|
+
contentLines.push(`\t${key} = ${JSON.stringify(value)}`);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
contentLines.push(`\t${key} = ${value}`);
|
|
441
424
|
}
|
|
442
|
-
contentLines.push(`\t${key} = ${config[key]}`);
|
|
443
425
|
}
|
|
444
426
|
return contentLines.join('\n');
|
|
445
427
|
};
|
|
@@ -6329,7 +6311,10 @@ const handler$2 = async (argv, logger) => {
|
|
|
6329
6311
|
parser,
|
|
6330
6312
|
});
|
|
6331
6313
|
const appendedText = argv.append ? `\n\n${argv.append}` : '';
|
|
6332
|
-
|
|
6314
|
+
const branchName = await getCurrentBranchName({ git });
|
|
6315
|
+
const ticketId = extractTicketIdFromBranchName(branchName);
|
|
6316
|
+
const ticketFooter = argv.appendTicket && ticketId ? `\n\nPart of **${ticketId}**` : '';
|
|
6317
|
+
return `${commitMsg.title}\n\n${commitMsg.body}${appendedText}${ticketFooter}`;
|
|
6333
6318
|
},
|
|
6334
6319
|
noResult: async () => {
|
|
6335
6320
|
await noResult$1({ git, logger });
|
|
@@ -6368,6 +6353,10 @@ const options$2 = {
|
|
|
6368
6353
|
description: 'Add content to the end of the generated commit message',
|
|
6369
6354
|
type: 'string',
|
|
6370
6355
|
},
|
|
6356
|
+
appendTicket: {
|
|
6357
|
+
description: 'Append ticket ID from branch name to the commit message',
|
|
6358
|
+
type: 'boolean',
|
|
6359
|
+
},
|
|
6371
6360
|
additional: {
|
|
6372
6361
|
description: 'Add extra contextual information to the prompt',
|
|
6373
6362
|
type: 'string',
|
|
@@ -6473,9 +6462,16 @@ async function checkAndHandlePackageInstallation({ global = false, logger, }) {
|
|
|
6473
6462
|
try {
|
|
6474
6463
|
// Global installation
|
|
6475
6464
|
if (global) {
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6465
|
+
const shouldInstall = await confirm({
|
|
6466
|
+
message: `Would you like to install/update '${packageName}' globally at this time?`,
|
|
6467
|
+
default: true,
|
|
6468
|
+
});
|
|
6469
|
+
if (!shouldInstall) {
|
|
6470
|
+
return;
|
|
6471
|
+
}
|
|
6472
|
+
logger.startSpinner(`Updating '${packageName}'...`, { color: 'blue' });
|
|
6473
|
+
// await installNpmPackage({ name: packageName, flags: ['-g'] })
|
|
6474
|
+
logger.stopSpinner(`Updated '${packageName}'`);
|
|
6479
6475
|
return;
|
|
6480
6476
|
}
|
|
6481
6477
|
// Project level installation
|
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ const getCommandUsageHeader = (command) => {
|
|
|
76
76
|
return chalk.green(`${USAGE_BANNER}\n${chalk.white('Command:')}\n\xa0\xa0\xa0\xa0\xa0 $0 ${chalk.greenBright(command)} [options]`);
|
|
77
77
|
};
|
|
78
78
|
const CONFIG_ALREADY_EXISTS = (path) => {
|
|
79
|
-
return `
|
|
79
|
+
return `existing config found in '${path}', do you want to override it?`;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
/**
|
|
@@ -397,11 +397,11 @@ function loadGitConfig(config) {
|
|
|
397
397
|
if (fs__namespace.existsSync(gitConfigPath)) {
|
|
398
398
|
const gitConfigRaw = fs__namespace.readFileSync(gitConfigPath, 'utf-8');
|
|
399
399
|
const gitConfigParsed = ini__namespace.parse(gitConfigRaw);
|
|
400
|
-
const
|
|
400
|
+
const gitConfigServiceObject = gitConfigParsed.coco?.service;
|
|
401
401
|
let service = config.service;
|
|
402
|
-
if (
|
|
403
|
-
const gitServiceConfig =
|
|
404
|
-
service =
|
|
402
|
+
if (gitConfigServiceObject) {
|
|
403
|
+
const gitServiceConfig = JSON.parse(gitConfigServiceObject);
|
|
404
|
+
service = gitServiceConfig || config?.service;
|
|
405
405
|
}
|
|
406
406
|
config = {
|
|
407
407
|
...config,
|
|
@@ -412,32 +412,11 @@ function loadGitConfig(config) {
|
|
|
412
412
|
ignoredFiles: gitConfigParsed.coco?.ignoredFiles || config.ignoredFiles,
|
|
413
413
|
ignoredExtensions: gitConfigParsed.coco?.ignoredExtensions || config.ignoredExtensions,
|
|
414
414
|
defaultBranch: gitConfigParsed.coco?.defaultBranch || config.defaultBranch,
|
|
415
|
+
verbose: gitConfigParsed.coco?.verbose || config.verbose,
|
|
415
416
|
};
|
|
416
417
|
}
|
|
417
418
|
return removeUndefined(config);
|
|
418
419
|
}
|
|
419
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
420
|
-
function parseServiceConfig$1(service) {
|
|
421
|
-
if (!service)
|
|
422
|
-
return undefined;
|
|
423
|
-
switch (service.provider) {
|
|
424
|
-
case 'openai':
|
|
425
|
-
return {
|
|
426
|
-
provider: 'openai',
|
|
427
|
-
model: service.model,
|
|
428
|
-
fields: { apiKey: service.apiKey },
|
|
429
|
-
};
|
|
430
|
-
case 'ollama':
|
|
431
|
-
return {
|
|
432
|
-
provider: 'ollama',
|
|
433
|
-
model: service.model,
|
|
434
|
-
endpoint: service.endpoint,
|
|
435
|
-
fields: service.fields,
|
|
436
|
-
};
|
|
437
|
-
default:
|
|
438
|
-
return undefined;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
420
|
/**
|
|
442
421
|
* Appends the provided configuration to a git config file.
|
|
443
422
|
*
|
|
@@ -452,15 +431,18 @@ const appendToGitConfig = async (filePath, config) => {
|
|
|
452
431
|
const getNewContent = async () => {
|
|
453
432
|
const contentLines = [header];
|
|
454
433
|
for (const key in config) {
|
|
455
|
-
|
|
456
|
-
if (typeof
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
434
|
+
const value = config[key];
|
|
435
|
+
if (typeof value === 'object') {
|
|
436
|
+
// Serialize object to JSON string
|
|
437
|
+
contentLines.push(`\t${key} = ${JSON.stringify(value)}`);
|
|
438
|
+
}
|
|
439
|
+
else if (typeof value === 'string' && value.includes('\n')) {
|
|
440
|
+
// Wrap strings with new lines in quotes
|
|
441
|
+
contentLines.push(`\t${key} = ${JSON.stringify(value)}`);
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
contentLines.push(`\t${key} = ${value}`);
|
|
462
445
|
}
|
|
463
|
-
contentLines.push(`\t${key} = ${config[key]}`);
|
|
464
446
|
}
|
|
465
447
|
return contentLines.join('\n');
|
|
466
448
|
};
|
|
@@ -6350,7 +6332,10 @@ const handler$2 = async (argv, logger) => {
|
|
|
6350
6332
|
parser,
|
|
6351
6333
|
});
|
|
6352
6334
|
const appendedText = argv.append ? `\n\n${argv.append}` : '';
|
|
6353
|
-
|
|
6335
|
+
const branchName = await getCurrentBranchName({ git });
|
|
6336
|
+
const ticketId = extractTicketIdFromBranchName(branchName);
|
|
6337
|
+
const ticketFooter = argv.appendTicket && ticketId ? `\n\nPart of **${ticketId}**` : '';
|
|
6338
|
+
return `${commitMsg.title}\n\n${commitMsg.body}${appendedText}${ticketFooter}`;
|
|
6354
6339
|
},
|
|
6355
6340
|
noResult: async () => {
|
|
6356
6341
|
await noResult$1({ git, logger });
|
|
@@ -6389,6 +6374,10 @@ const options$2 = {
|
|
|
6389
6374
|
description: 'Add content to the end of the generated commit message',
|
|
6390
6375
|
type: 'string',
|
|
6391
6376
|
},
|
|
6377
|
+
appendTicket: {
|
|
6378
|
+
description: 'Append ticket ID from branch name to the commit message',
|
|
6379
|
+
type: 'boolean',
|
|
6380
|
+
},
|
|
6392
6381
|
additional: {
|
|
6393
6382
|
description: 'Add extra contextual information to the prompt',
|
|
6394
6383
|
type: 'string',
|
|
@@ -6494,9 +6483,16 @@ async function checkAndHandlePackageInstallation({ global = false, logger, }) {
|
|
|
6494
6483
|
try {
|
|
6495
6484
|
// Global installation
|
|
6496
6485
|
if (global) {
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6486
|
+
const shouldInstall = await prompts.confirm({
|
|
6487
|
+
message: `Would you like to install/update '${packageName}' globally at this time?`,
|
|
6488
|
+
default: true,
|
|
6489
|
+
});
|
|
6490
|
+
if (!shouldInstall) {
|
|
6491
|
+
return;
|
|
6492
|
+
}
|
|
6493
|
+
logger.startSpinner(`Updating '${packageName}'...`, { color: 'blue' });
|
|
6494
|
+
// await installNpmPackage({ name: packageName, flags: ['-g'] })
|
|
6495
|
+
logger.stopSpinner(`Updated '${packageName}'`);
|
|
6500
6496
|
return;
|
|
6501
6497
|
}
|
|
6502
6498
|
// Project level installation
|