berget 2.2.8 → 2.2.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "berget",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "berget": "dist/index.js"
@@ -43,6 +43,7 @@
43
43
  "eslint-plugin-perfectionist": "^5.9.0",
44
44
  "eslint-plugin-prettier": "^5.5.5",
45
45
  "eslint-plugin-promise": "^7.3.0",
46
+ "eslint-plugin-sonarjs": "^3.0.2",
46
47
  "husky": "^9.1.7",
47
48
  "lint-staged": "^17.0.4",
48
49
  "prettier": "^3.8.3",
@@ -59,6 +60,7 @@
59
60
  "commander": "^12.0.0",
60
61
  "dotenv": "^17.2.3",
61
62
  "fs-extra": "^11.3.0",
63
+ "globals": "^17.6.0",
62
64
  "jsonc-parser": "^3.3.1",
63
65
  "marked": "^9.1.6",
64
66
  "marked-terminal": "^6.2.0",
@@ -341,19 +341,5 @@ function formatDate(dateString) {
341
341
  return chalk_1.default.gray(`${Math.floor(diffDays / 365)} years ago`);
342
342
  }
343
343
  function formatLastUsed(dateString) {
344
- const date = new Date(dateString);
345
- const now = new Date();
346
- const diffTime = Math.abs(now.getTime() - date.getTime());
347
- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
348
- if (diffDays === 0)
349
- return chalk_1.default.green('Today');
350
- if (diffDays === 1)
351
- return chalk_1.default.yellow('Yesterday');
352
- if (diffDays < 7)
353
- return chalk_1.default.yellow(`${diffDays} days ago`);
354
- if (diffDays < 30)
355
- return chalk_1.default.blue(`${Math.floor(diffDays / 7)} weeks ago`);
356
- if (diffDays < 365)
357
- return chalk_1.default.magenta(`${Math.floor(diffDays / 30)} months ago`);
358
- return chalk_1.default.gray(`${Math.floor(diffDays / 365)} years ago`);
344
+ return formatDate(dateString);
359
345
  }
@@ -87,7 +87,7 @@ class ChatService {
87
87
  if (hasValidAuth && !hasExplicitApiKey) {
88
88
  logger_1.logger.debug('Using authenticated client with refresh token support');
89
89
  // Create a copy without apiKey to let the authenticated client handle auth automatically
90
- const { apiKey: _apiKey, ...optionsWithoutKey } = optionsCopy;
90
+ const { apiKey: _, ...optionsWithoutKey } = optionsCopy;
91
91
  return this.executeCompletion(optionsWithoutKey, {});
92
92
  }
93
93
  // Check for environment variables first - prioritize this over everything else
@@ -244,7 +244,7 @@ class ChatService {
244
244
  headers['Authorization'] = options.apiKey;
245
245
  }
246
246
  // Remove apiKey and onChunk from options before sending to API
247
- const { apiKey: _apiKey, onChunk, ...requestOptions } = options;
247
+ const { apiKey: _, onChunk, ...requestOptions } = options;
248
248
  logger_1.logger.debug('Request options:');
249
249
  logger_1.logger.debug(JSON.stringify({
250
250
  ...requestOptions,
@@ -34,7 +34,7 @@ function checkBergetConfig() {
34
34
  if (fs.existsSync(configPath)) {
35
35
  try {
36
36
  const config = fs.readFileSync(configPath, 'utf8');
37
- const match = config.match(/cluster:\s*(.+)/);
37
+ const match = /cluster:\s*(.+)/.exec(config);
38
38
  if (match && match[1]) {
39
39
  const clusterName = match[1].trim();
40
40
  console.log(`🔄 Berget: Switched to cluster "${clusterName}"`);
package/eslint.config.mjs CHANGED
@@ -2,6 +2,7 @@ import vitest from '@vitest/eslint-plugin';
2
2
  import perfectionist from 'eslint-plugin-perfectionist';
3
3
  import prettier from 'eslint-plugin-prettier';
4
4
  import promise from 'eslint-plugin-promise';
5
+ import sonarjs from 'eslint-plugin-sonarjs';
5
6
  import tseslint from 'typescript-eslint';
6
7
 
7
8
  export default tseslint.config(
@@ -22,6 +23,7 @@ export default tseslint.config(
22
23
  },
23
24
  ...tseslint.configs.recommended,
24
25
  ...tseslint.configs.strict,
26
+ sonarjs.configs.recommended,
25
27
  promise.configs['flat/recommended'],
26
28
  perfectionist.configs['recommended-natural'],
27
29
  {
@@ -62,6 +64,19 @@ export default tseslint.config(
62
64
  'error',
63
65
  { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
64
66
  ],
67
+ 'sonarjs/cognitive-complexity': 'off',
68
+ 'sonarjs/different-types-comparison': 'off',
69
+ 'sonarjs/function-return-type': 'off',
70
+ 'sonarjs/no-duplicated-branches': 'off',
71
+ 'sonarjs/no-nested-conditional': 'off',
72
+ 'sonarjs/no-nested-functions': 'off',
73
+ 'sonarjs/no-nested-template-literals': 'off',
74
+ 'sonarjs/no-os-command-from-path': 'off',
75
+ 'sonarjs/no-unused-vars': 'off',
76
+ 'sonarjs/prefer-regexp-exec': 'off',
77
+ 'sonarjs/publicly-writable-directories': 'off',
78
+ 'sonarjs/redundant-type-aliases': 'off',
79
+ 'sonarjs/slow-regex': 'off',
65
80
  },
66
81
  },
67
82
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "berget",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "berget": "dist/index.js"
@@ -43,6 +43,7 @@
43
43
  "eslint-plugin-perfectionist": "^5.9.0",
44
44
  "eslint-plugin-prettier": "^5.5.5",
45
45
  "eslint-plugin-promise": "^7.3.0",
46
+ "eslint-plugin-sonarjs": "^3.0.2",
46
47
  "husky": "^9.1.7",
47
48
  "lint-staged": "^17.0.4",
48
49
  "prettier": "^3.8.3",
@@ -59,6 +60,7 @@
59
60
  "commander": "^12.0.0",
60
61
  "dotenv": "^17.2.3",
61
62
  "fs-extra": "^11.3.0",
63
+ "globals": "^17.6.0",
62
64
  "jsonc-parser": "^3.3.1",
63
65
  "marked": "^9.1.6",
64
66
  "marked-terminal": "^6.2.0",
@@ -429,15 +429,5 @@ function formatDate(dateString: string): string {
429
429
  }
430
430
 
431
431
  function formatLastUsed(dateString: string): string {
432
- const date = new Date(dateString);
433
- const now = new Date();
434
- const diffTime = Math.abs(now.getTime() - date.getTime());
435
- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
436
-
437
- if (diffDays === 0) return chalk.green('Today');
438
- if (diffDays === 1) return chalk.yellow('Yesterday');
439
- if (diffDays < 7) return chalk.yellow(`${diffDays} days ago`);
440
- if (diffDays < 30) return chalk.blue(`${Math.floor(diffDays / 7)} weeks ago`);
441
- if (diffDays < 365) return chalk.magenta(`${Math.floor(diffDays / 30)} months ago`);
442
- return chalk.gray(`${Math.floor(diffDays / 365)} years ago`);
432
+ return formatDate(dateString);
443
433
  }
@@ -96,7 +96,7 @@ export class ChatService {
96
96
  if (hasValidAuth && !hasExplicitApiKey) {
97
97
  logger.debug('Using authenticated client with refresh token support');
98
98
  // Create a copy without apiKey to let the authenticated client handle auth automatically
99
- const { apiKey: _apiKey, ...optionsWithoutKey } = optionsCopy;
99
+ const { apiKey: _, ...optionsWithoutKey } = optionsCopy;
100
100
  return this.executeCompletion(optionsWithoutKey, {});
101
101
  }
102
102
 
@@ -278,7 +278,7 @@ export class ChatService {
278
278
  }
279
279
 
280
280
  // Remove apiKey and onChunk from options before sending to API
281
- const { apiKey: _apiKey, onChunk, ...requestOptions } = options;
281
+ const { apiKey: _, onChunk, ...requestOptions } = options;
282
282
 
283
283
  logger.debug('Request options:');
284
284
  logger.debug(
@@ -9,7 +9,7 @@ export function checkBergetConfig(): void {
9
9
  if (fs.existsSync(configPath)) {
10
10
  try {
11
11
  const config = fs.readFileSync(configPath, 'utf8');
12
- const match = config.match(/cluster:\s*(.+)/);
12
+ const match = /cluster:\s*(.+)/.exec(config);
13
13
  if (match && match[1]) {
14
14
  const clusterName = match[1].trim();
15
15
  console.log(`🔄 Berget: Switched to cluster "${clusterName}"`);