nitor 1.4.1 → 1.5.0

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/CHANGELOG.md CHANGED
@@ -38,3 +38,11 @@ For a complete list of changes and discussion, see [Issue #1](https://github.com
38
38
  - Added support for task stats and get task commands.
39
39
 
40
40
  - [Issue #7](https://github.com/codebynithin/nitor/issues/7)
41
+
42
+ ## [1.5.0] - 2026-04-10
43
+
44
+ ### New Features
45
+
46
+ - Add table display for get-task command.
47
+
48
+ - [Issue #9](https://github.com/codebynithin/nitor/issues/9)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitor",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "A comprehensive CLI toolkit for automating GitLab operations, AI-powered code review, build/deploy automation, MongoDB backup/restore, and developer productivity tools",
5
5
  "main": "index.js",
6
6
  "author": "Nithin V <mails2nithin@gmail.com>",
@@ -49,6 +49,7 @@ const executeMongoRestore = async (config) => {
49
49
  : `docker exec -it ${containerName} mongorestore --drop --stopOnError=false ${containerBackupPath}`;
50
50
 
51
51
  console.log('Executing mongorestore...');
52
+
52
53
  try {
53
54
  execSync(restoreCommand, { stdio: 'inherit', shell: isWindows ? 'cmd.exe' : '/bin/sh' });
54
55
  console.log(`${colors.green}✓ Mongorestore completed successfully${colors.reset}`);
@@ -70,9 +71,10 @@ const executeMongoRestore = async (config) => {
70
71
  console.log(`${colors.green}Restore completed successfully!${colors.reset}\n`);
71
72
  } else {
72
73
  console.log(`\nStarting MongoDB restore to local machine`);
73
-
74
74
  console.log('Executing mongorestore...');
75
- const localRestoreCommand = `mongorestore --drop --stopOnError=false --uri="mongodb://localhost:27017/" "${normalizedLocalPath}"`;
75
+
76
+ const localRestoreCommand = `mongorestore --stopOnError=false --uri="mongodb://localhost:27017/" "${normalizedLocalPath}"`;
77
+
76
78
  try {
77
79
  execSync(localRestoreCommand, {
78
80
  stdio: 'inherit',
@@ -127,7 +129,9 @@ const executeMongoBackup = async (config) => {
127
129
  : `kubectl exec -it ${pod} -- mongodump --username ${username} --password ${password} --authenticationDatabase ${database} --db ${database} --out ${backupPath}`;
128
130
 
129
131
  console.log('Executing mongodump...');
132
+
130
133
  execSync(mongodumpCommand, { stdio: 'inherit', shell: isWindows ? 'cmd.exe' : '/bin/sh' });
134
+
131
135
  console.log(`${colors.green}✓ Mongodump completed successfully${colors.reset}`);
132
136
 
133
137
  // Expand and normalize paths for cross-platform compatibility
@@ -144,13 +148,15 @@ const executeMongoBackup = async (config) => {
144
148
  : `kubectl exec -it ${pod} -- rm -rf ${backupPath}`;
145
149
 
146
150
  console.log(`Copying backup to ${destinationPath}...`);
151
+
147
152
  execSync(copyCommand, { stdio: 'inherit', shell: isWindows ? 'cmd.exe' : '/bin/sh' });
148
- console.log(`${colors.green}✓ Backup copied successfully${colors.reset}`);
149
153
 
154
+ console.log(`${colors.green}✓ Backup copied successfully${colors.reset}`);
150
155
  console.log('Cleaning up backup data from pod...');
156
+
151
157
  execSync(cleanupCommand, { stdio: 'inherit', shell: isWindows ? 'cmd.exe' : '/bin/sh' });
152
- console.log(`${colors.green}✓ Backup data removed from pod${colors.reset}`);
153
158
 
159
+ console.log(`${colors.green}✓ Backup data removed from pod${colors.reset}`);
154
160
  console.log(
155
161
  `${colors.green}Backup completed! Files saved to: ${destinationPath}${colors.reset}\n`,
156
162
  );
@@ -191,9 +197,31 @@ const backup = async (values) => {
191
197
  console.log(`Processing backup for project: ${project}`);
192
198
  console.log(`========================================`);
193
199
 
194
- for (const dbConfig of projectConfigs) {
200
+ let configs = [];
201
+
202
+ if (values.components) {
203
+ configs = projectConfigs.filter((component) =>
204
+ component.database.includes(values.components),
205
+ );
206
+ } else {
207
+ configs = projectConfigs;
208
+ }
209
+
210
+ for (const dbConfig of configs) {
195
211
  try {
196
212
  await executeMongoBackup(dbConfig);
213
+
214
+ // Drop database in target MongoDB after backup download
215
+ const containerName = restoreConfig?.containerName || 'mongodb';
216
+ const dropCommand = values?.docker
217
+ ? `docker exec ${containerName} mongosh --eval "db.getSiblingDB('${dbConfig.database}').dropDatabase()"`
218
+ : `mongosh --eval "db.getSiblingDB('${dbConfig.database}').dropDatabase()"`;
219
+
220
+ console.log(`Dropping database ${dbConfig.database} in target MongoDB...`);
221
+
222
+ execSync(dropCommand, { stdio: 'inherit', shell: isWindows ? 'cmd.exe' : '/bin/sh' });
223
+
224
+ console.log(`${colors.green}✓ Database ${dbConfig.database} dropped${colors.reset}`);
197
225
  } catch (error) {
198
226
  console.error(
199
227
  `${colors.red}Failed to backup database ${dbConfig.database} for project ${project}${colors.reset}`,
@@ -374,25 +374,47 @@ Options:
374
374
  process.exit(1);
375
375
  }
376
376
 
377
- const tasks = {};
377
+ const taskNumbers = values.task.split(' ').filter(Boolean);
378
378
 
379
- for (const task of values.task.split(' ')) {
380
- const taskDetails = await getGitMergeRequestDetails(task);
379
+ const spinner = createSpinner('Fetching merge requests');
380
+ spinner.start();
381
381
 
382
- if (taskDetails.error) {
383
- console.log(`No merge requests found for task ${task}`);
382
+ try {
383
+ spinner.update(`Fetching ${taskNumbers.length} task(s)`);
384
384
 
385
- continue;
386
- }
385
+ const taskDetailsList = await Promise.all(
386
+ taskNumbers.map((task) =>
387
+ getGitMergeRequestDetails(task).then((details) => ({ task, details })),
388
+ ),
389
+ );
390
+
391
+ spinner.stop('Loaded merge request data', true);
392
+
393
+ const rows = [];
394
+
395
+ for (const { task, details: taskDetails } of taskDetailsList) {
396
+ if (taskDetails.error) {
397
+ rows.push({ GitLab: task, Zoho: 'No merge requests' });
398
+
399
+ continue;
400
+ }
401
+
402
+ let zoho = 'Not found';
387
403
 
388
- for (const taskDetail of taskDetails) {
389
- const zohoTaskMatch = taskDetail.description?.match(/itemdetails\/(I\d+)\)/);
404
+ for (const taskDetail of taskDetails) {
405
+ const zohoTaskMatch = taskDetail.description?.match(/itemdetails\/(I\d+)\)/);
406
+
407
+ zoho = zohoTaskMatch ? zohoTaskMatch[1] : 'Not found';
408
+ }
390
409
 
391
- tasks[task] = zohoTaskMatch ? zohoTaskMatch[1] : 'Not found';
410
+ rows.push({ GitLab: task, Zoho: zoho });
392
411
  }
393
- }
394
412
 
395
- console.log(tasks);
413
+ printTable(rows, { columns: ['GitLab', 'Zoho'] });
414
+ } catch (error) {
415
+ spinner.stop('Failed to fetch merge requests', false);
416
+ throw error;
417
+ }
396
418
 
397
419
  break;
398
420
  }
package/services/utils.js CHANGED
@@ -100,8 +100,10 @@ const projectIdMap = {
100
100
  phrBackend: '117',
101
101
  phrDeployment: '64',
102
102
  configService: '227',
103
+ configServiceDeployment: '228',
103
104
  healthRecords: '115',
104
105
  centralAuth: '134',
106
+ centralAuthDeployment: '138',
105
107
  mpi: '10',
106
108
  phrAdminBackend: '126',
107
109
  phrAdminClient: '130',
@@ -558,8 +560,11 @@ const printTable = (data, options = {}) => {
558
560
  } else if (col === 'MRStatus') {
559
561
  cellColor =
560
562
  value === 'merged' ? colors.green : value === 'opened' ? colors.yellow : colors.dim;
561
- } else if (col === 'Task' || col === 'MRID' || col === 'GitID') {
563
+ } else if (col === 'Task' || col === 'MRID' || col === 'GitID' || col === 'GitLab') {
562
564
  cellColor = colors.cyan;
565
+ } else if (col === 'Zoho') {
566
+ cellColor =
567
+ value === 'Not found' || value === 'No merge requests' ? colors.dim : colors.green;
563
568
  } else if (col === 'Owner' || col === 'MRAssignedTo') {
564
569
  cellColor = colors.magenta;
565
570
  } else if (col === 'Repo') {