nitor 1.4.0 → 1.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitor",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
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,20 +71,21 @@ 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',
79
81
  shell: isWindows ? 'cmd.exe' : '/bin/sh',
80
82
  });
81
- console.log(`${colors.green}Mongorestore completed successfully${colors.reset}`);
83
+ console.log(`${colors.green}Mongorestore completed successfully${colors.reset}`);
82
84
  } catch (error) {
83
85
  // mongorestore returns non-zero even for partial success (e.g., duplicate keys)
84
86
  // Log the warning but don't throw unless it's a critical failure
85
87
  console.log(
86
- `${colors.red}Mongorestore completed with some errors (this may be expected if data already exists)${colors.reset}`,
88
+ `${colors.red}Mongorestore completed with some errors (this may be expected if data already exists)${colors.reset}`,
87
89
  );
88
90
  console.log(`Check the output above for details`);
89
91
  }
@@ -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}`,
@@ -41,7 +41,7 @@ const processArgs = async (type, value) => {
41
41
  }
42
42
 
43
43
  if (values === null) {
44
- return;
44
+ process.exit(1);
45
45
  }
46
46
 
47
47
  switch (type) {
@@ -57,7 +57,7 @@ Options:
57
57
  -c, --components <name> component name | client, administration, provider, rest-api
58
58
  -i, --instance <name> instance name | dev, qa, pilot`);
59
59
 
60
- return;
60
+ break;
61
61
  }
62
62
 
63
63
  await build(values);
@@ -77,7 +77,7 @@ Options:
77
77
  -c, --components <name> component name | client, administration, provider, rest-api
78
78
  -i, --instance <name> instance name | dev, qa, pilot`);
79
79
 
80
- return;
80
+ break;
81
81
  }
82
82
 
83
83
  const configs = await build(values);
@@ -110,7 +110,7 @@ Options:
110
110
  -c, --components <name> component name | client, administration, provider, rest-api
111
111
  -i, --instance <name> instance name | dev, qa, pilot`);
112
112
 
113
- return;
113
+ break;
114
114
  }
115
115
 
116
116
  await deploy(values);
@@ -131,7 +131,7 @@ Options:
131
131
  -d, --description <description> description
132
132
  -p, --project <project short name> project short name | portal, gateway, phr, configService, healthRecords, centralAuth, mpi, phrAdminBackend, phrAdminClient, terminologyService`);
133
133
 
134
- return;
134
+ break;
135
135
  }
136
136
 
137
137
  await createBranch(values);
@@ -147,11 +147,10 @@ Options:
147
147
  Review merge request
148
148
 
149
149
  Options:
150
- -p, --project <project short name> project short name | portal, gateway, phr, configService, healthRecords, centralAuth, mpi, phrAdminBackend, phrAdminClient, terminologyService
151
- -mId, --mergeId <merge id> merge id
152
- -r, --repository <repository name> repository name
150
+ -p, --project <project short name>
151
+ -mId, --mergeId <merge id>
153
152
 
154
- Repository list:
153
+ Project list:
155
154
  centralAuth
156
155
  configService
157
156
  gatewayBackend
@@ -170,7 +169,7 @@ Repository list:
170
169
  portalDeployment
171
170
  terminologyService`);
172
171
 
173
- return;
172
+ break;
174
173
  }
175
174
 
176
175
  await mrAIReview(values);
@@ -184,7 +183,7 @@ Repository list:
184
183
 
185
184
  Enhance the provided text for improved clarity, conciseness, and professional quality.`);
186
185
 
187
- return;
186
+ break;
188
187
  }
189
188
 
190
189
  await refactor(values);
@@ -204,7 +203,7 @@ project list:
204
203
  - medicaPortal
205
204
  - phr`);
206
205
 
207
- return;
206
+ break;
208
207
  }
209
208
 
210
209
  await backup(values);
@@ -230,7 +229,7 @@ This command will:
230
229
  4. Merge source into target
231
230
  5. Push changes`);
232
231
 
233
- return;
232
+ break;
234
233
  }
235
234
 
236
235
  await merge(values);
@@ -250,7 +249,7 @@ This command will:
250
249
 
251
250
  Note: This operation cannot be undone. Make sure you have pushed any important changes.`);
252
251
 
253
- return;
252
+ break;
254
253
  }
255
254
 
256
255
  await cleanup();
@@ -296,7 +295,7 @@ View task stats
296
295
  Options:
297
296
  -t, --task <number> task number`);
298
297
 
299
- return;
298
+ break;
300
299
  }
301
300
 
302
301
  const spinner = createSpinner('Fetching task statistics');
@@ -366,7 +365,7 @@ Get task details
366
365
  Options:
367
366
  -t, --task <numbers with space> task numbers with space`);
368
367
 
369
- return;
368
+ break;
370
369
  }
371
370
 
372
371
  if (!values.task) {
@@ -572,7 +571,7 @@ Running 'nitor help' will list available subcommands and provide some conceptual
572
571
  default: {
573
572
  console.error(`nitor: '${type}' is not a nitor command. See 'nitor help'.`);
574
573
 
575
- return;
574
+ break;
576
575
  }
577
576
  }
578
577
 
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',