git-coco 0.13.0 → 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 +27 -38
- package/dist/index.js +27 -38
- 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
|
};
|
|
@@ -6480,9 +6462,16 @@ async function checkAndHandlePackageInstallation({ global = false, logger, }) {
|
|
|
6480
6462
|
try {
|
|
6481
6463
|
// Global installation
|
|
6482
6464
|
if (global) {
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
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}'`);
|
|
6486
6475
|
return;
|
|
6487
6476
|
}
|
|
6488
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
|
};
|
|
@@ -6501,9 +6483,16 @@ async function checkAndHandlePackageInstallation({ global = false, logger, }) {
|
|
|
6501
6483
|
try {
|
|
6502
6484
|
// Global installation
|
|
6503
6485
|
if (global) {
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
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}'`);
|
|
6507
6496
|
return;
|
|
6508
6497
|
}
|
|
6509
6498
|
// Project level installation
|