nitor 1.0.0 → 1.2.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 +8 -0
- package/README.md +39 -10
- package/docs/AUTOCOMPLETE.md +136 -0
- package/docs/BACKUP.md +343 -0
- package/docs/BUILD.md +120 -0
- package/docs/BUILD_DEPLOY.md +320 -0
- package/docs/CLEANUP.md +285 -0
- package/docs/CREATE_BRANCH.md +173 -0
- package/docs/DEPLOY.md +130 -0
- package/docs/MERGE.md +253 -0
- package/docs/README.md +277 -0
- package/docs/REFACTOR.md +375 -0
- package/docs/REVIEW.md +185 -0
- package/docs/TIME_ENTRY.md +422 -0
- package/index.js +14 -0
- package/package.json +27 -9
- package/services/autocomplete.js +251 -0
- package/services/cleanup.js +63 -0
- package/services/enums/actions.enum.js +19 -6
- package/services/process-commands.js +218 -24
- package/services/review.js +2 -2
- package/services/time-entry/add-task.js +50 -0
- package/services/time-entry/enums/actions.enum.js +16 -0
- package/services/time-entry/get-gitlab-activities.js +137 -0
- package/services/time-entry/get-report.js +142 -0
- package/services/time-entry/get-zoho-tasks.js +81 -0
- package/services/time-entry/log-task-hours-and-sync.js +81 -0
- package/services/time-entry/update-delete-task.js +85 -0
- package/services/time-entry/utils.js +301 -0
- package/services/utils.js +32 -15
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
const omelette = require('omelette');
|
|
2
|
+
const { ACTIONS } = require('./enums/actions.enum');
|
|
3
|
+
|
|
4
|
+
const setupAutocomplete = () => {
|
|
5
|
+
const completion = omelette('nitor|nu');
|
|
6
|
+
|
|
7
|
+
// Define the completion tree
|
|
8
|
+
completion.tree({
|
|
9
|
+
[ACTIONS.BUILD]: {
|
|
10
|
+
'-project': [
|
|
11
|
+
'portal',
|
|
12
|
+
'gateway',
|
|
13
|
+
'phr',
|
|
14
|
+
'configService',
|
|
15
|
+
'healthRecords',
|
|
16
|
+
'centralAuth',
|
|
17
|
+
'mpi',
|
|
18
|
+
'phrAdminBackend',
|
|
19
|
+
'phrAdminClient',
|
|
20
|
+
'terminologyService',
|
|
21
|
+
],
|
|
22
|
+
'-p': [
|
|
23
|
+
'portal',
|
|
24
|
+
'gateway',
|
|
25
|
+
'phr',
|
|
26
|
+
'configService',
|
|
27
|
+
'healthRecords',
|
|
28
|
+
'centralAuth',
|
|
29
|
+
'mpi',
|
|
30
|
+
'phrAdminBackend',
|
|
31
|
+
'phrAdminClient',
|
|
32
|
+
'terminologyService',
|
|
33
|
+
],
|
|
34
|
+
'-components': ['client', 'administration', 'provider', 'rest-api'],
|
|
35
|
+
'-c': ['client', 'administration', 'provider', 'rest-api'],
|
|
36
|
+
'-instance': ['dev', 'qa', 'pilot'],
|
|
37
|
+
'-i': ['dev', 'qa', 'pilot'],
|
|
38
|
+
'-help': [],
|
|
39
|
+
'--h': [],
|
|
40
|
+
},
|
|
41
|
+
[ACTIONS.DEPLOY]: {
|
|
42
|
+
'-project': [
|
|
43
|
+
'portal',
|
|
44
|
+
'gateway',
|
|
45
|
+
'phr',
|
|
46
|
+
'configService',
|
|
47
|
+
'healthRecords',
|
|
48
|
+
'centralAuth',
|
|
49
|
+
'mpi',
|
|
50
|
+
'phrAdminBackend',
|
|
51
|
+
'phrAdminClient',
|
|
52
|
+
'terminologyService',
|
|
53
|
+
],
|
|
54
|
+
'-p': [
|
|
55
|
+
'portal',
|
|
56
|
+
'gateway',
|
|
57
|
+
'phr',
|
|
58
|
+
'configService',
|
|
59
|
+
'healthRecords',
|
|
60
|
+
'centralAuth',
|
|
61
|
+
'mpi',
|
|
62
|
+
'phrAdminBackend',
|
|
63
|
+
'phrAdminClient',
|
|
64
|
+
'terminologyService',
|
|
65
|
+
],
|
|
66
|
+
'-components': ['client', 'administration', 'provider', 'rest-api'],
|
|
67
|
+
'-c': ['client', 'administration', 'provider', 'rest-api'],
|
|
68
|
+
'-instance': ['dev', 'qa', 'pilot'],
|
|
69
|
+
'-i': ['dev', 'qa', 'pilot'],
|
|
70
|
+
'-help': [],
|
|
71
|
+
'--h': [],
|
|
72
|
+
},
|
|
73
|
+
[ACTIONS.BUILD_DEPLOY]: {
|
|
74
|
+
'-project': [
|
|
75
|
+
'portal',
|
|
76
|
+
'gateway',
|
|
77
|
+
'phr',
|
|
78
|
+
'configService',
|
|
79
|
+
'healthRecords',
|
|
80
|
+
'centralAuth',
|
|
81
|
+
'mpi',
|
|
82
|
+
'phrAdminBackend',
|
|
83
|
+
'phrAdminClient',
|
|
84
|
+
'terminologyService',
|
|
85
|
+
],
|
|
86
|
+
'-p': [
|
|
87
|
+
'portal',
|
|
88
|
+
'gateway',
|
|
89
|
+
'phr',
|
|
90
|
+
'configService',
|
|
91
|
+
'healthRecords',
|
|
92
|
+
'centralAuth',
|
|
93
|
+
'mpi',
|
|
94
|
+
'phrAdminBackend',
|
|
95
|
+
'phrAdminClient',
|
|
96
|
+
'terminologyService',
|
|
97
|
+
],
|
|
98
|
+
'-components': ['client', 'administration', 'provider', 'rest-api'],
|
|
99
|
+
'-c': ['client', 'administration', 'provider', 'rest-api'],
|
|
100
|
+
'-instance': ['dev', 'qa', 'pilot'],
|
|
101
|
+
'-i': ['dev', 'qa', 'pilot'],
|
|
102
|
+
'-help': [],
|
|
103
|
+
'--h': [],
|
|
104
|
+
},
|
|
105
|
+
[ACTIONS.CREATE_BRANCH]: {
|
|
106
|
+
'-task': [],
|
|
107
|
+
'-t': [],
|
|
108
|
+
'-type': ['feat', 'fix'],
|
|
109
|
+
'-ty': ['feat', 'fix'],
|
|
110
|
+
'-description': [],
|
|
111
|
+
'-d': [],
|
|
112
|
+
'-project': [
|
|
113
|
+
'portal',
|
|
114
|
+
'gateway',
|
|
115
|
+
'phr',
|
|
116
|
+
'configService',
|
|
117
|
+
'healthRecords',
|
|
118
|
+
'centralAuth',
|
|
119
|
+
'mpi',
|
|
120
|
+
'phrAdminBackend',
|
|
121
|
+
'phrAdminClient',
|
|
122
|
+
'terminologyService',
|
|
123
|
+
],
|
|
124
|
+
'-p': [
|
|
125
|
+
'portal',
|
|
126
|
+
'gateway',
|
|
127
|
+
'phr',
|
|
128
|
+
'configService',
|
|
129
|
+
'healthRecords',
|
|
130
|
+
'centralAuth',
|
|
131
|
+
'mpi',
|
|
132
|
+
'phrAdminBackend',
|
|
133
|
+
'phrAdminClient',
|
|
134
|
+
'terminologyService',
|
|
135
|
+
],
|
|
136
|
+
'-help': [],
|
|
137
|
+
'--h': [],
|
|
138
|
+
},
|
|
139
|
+
[ACTIONS.REVIEW]: {
|
|
140
|
+
'-project': [
|
|
141
|
+
'portal',
|
|
142
|
+
'gateway',
|
|
143
|
+
'phr',
|
|
144
|
+
'configService',
|
|
145
|
+
'healthRecords',
|
|
146
|
+
'centralAuth',
|
|
147
|
+
'mpi',
|
|
148
|
+
'phrAdminBackend',
|
|
149
|
+
'phrAdminClient',
|
|
150
|
+
'terminologyService',
|
|
151
|
+
],
|
|
152
|
+
'-p': [
|
|
153
|
+
'portal',
|
|
154
|
+
'gateway',
|
|
155
|
+
'phr',
|
|
156
|
+
'configService',
|
|
157
|
+
'healthRecords',
|
|
158
|
+
'centralAuth',
|
|
159
|
+
'mpi',
|
|
160
|
+
'phrAdminBackend',
|
|
161
|
+
'phrAdminClient',
|
|
162
|
+
'terminologyService',
|
|
163
|
+
],
|
|
164
|
+
'-mergeId': [],
|
|
165
|
+
'-mId': [],
|
|
166
|
+
'-repository': [
|
|
167
|
+
'portalClient',
|
|
168
|
+
'portalBackend',
|
|
169
|
+
'portalDeployment',
|
|
170
|
+
'portalAutomation',
|
|
171
|
+
'gatewayBackend',
|
|
172
|
+
'gatewayClient',
|
|
173
|
+
'gatewayDeployment',
|
|
174
|
+
'phrClient',
|
|
175
|
+
'phrBackend',
|
|
176
|
+
'phrDeployment',
|
|
177
|
+
'configService',
|
|
178
|
+
'healthRecords',
|
|
179
|
+
'centralAuth',
|
|
180
|
+
'mpi',
|
|
181
|
+
'phrAdminBackend',
|
|
182
|
+
'phrAdminClient',
|
|
183
|
+
'terminologyService',
|
|
184
|
+
],
|
|
185
|
+
'-r': [
|
|
186
|
+
'portalClient',
|
|
187
|
+
'portalBackend',
|
|
188
|
+
'portalDeployment',
|
|
189
|
+
'portalAutomation',
|
|
190
|
+
'gatewayBackend',
|
|
191
|
+
'gatewayClient',
|
|
192
|
+
'gatewayDeployment',
|
|
193
|
+
'phrClient',
|
|
194
|
+
'phrBackend',
|
|
195
|
+
'phrDeployment',
|
|
196
|
+
'configService',
|
|
197
|
+
'healthRecords',
|
|
198
|
+
'centralAuth',
|
|
199
|
+
'mpi',
|
|
200
|
+
'phrAdminBackend',
|
|
201
|
+
'phrAdminClient',
|
|
202
|
+
'terminologyService',
|
|
203
|
+
],
|
|
204
|
+
'-help': [],
|
|
205
|
+
'--h': [],
|
|
206
|
+
},
|
|
207
|
+
[ACTIONS.REFACTOR]: {
|
|
208
|
+
'-help': [],
|
|
209
|
+
'--h': [],
|
|
210
|
+
},
|
|
211
|
+
[ACTIONS.BACKUP]: {
|
|
212
|
+
'-project': ['configService', 'medicaCentralAuth', 'medicaPortal', 'phr'],
|
|
213
|
+
'-p': ['configService', 'medicaCentralAuth', 'medicaPortal', 'phr'],
|
|
214
|
+
'-components': [],
|
|
215
|
+
'-c': [],
|
|
216
|
+
'-help': [],
|
|
217
|
+
'--h': [],
|
|
218
|
+
},
|
|
219
|
+
[ACTIONS.MERGE]: {
|
|
220
|
+
'-source': [],
|
|
221
|
+
'-s': [],
|
|
222
|
+
'-target': [],
|
|
223
|
+
'-ta': [],
|
|
224
|
+
'-help': [],
|
|
225
|
+
'--h': [],
|
|
226
|
+
},
|
|
227
|
+
[ACTIONS.CLEANUP]: {
|
|
228
|
+
'-help': [],
|
|
229
|
+
'--h': [],
|
|
230
|
+
},
|
|
231
|
+
[ACTIONS.TIME_INIT]: [],
|
|
232
|
+
[ACTIONS.TIME_SWITCH]: [],
|
|
233
|
+
[ACTIONS.TIME_ADD]: [],
|
|
234
|
+
[ACTIONS.TIME_UPDATE]: [],
|
|
235
|
+
[ACTIONS.TIME_DELETE]: [],
|
|
236
|
+
[ACTIONS.TIME_STATUS]: [],
|
|
237
|
+
[ACTIONS.TIME_ENTRIES]: [],
|
|
238
|
+
[ACTIONS.TIME_ZOHO]: [],
|
|
239
|
+
[ACTIONS.TIME_GITLAB]: [],
|
|
240
|
+
[ACTIONS.TIME_MERGE]: [],
|
|
241
|
+
[ACTIONS.VERSION]: [],
|
|
242
|
+
[ACTIONS.HELP]: [],
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Initialize the completion
|
|
246
|
+
completion.init();
|
|
247
|
+
|
|
248
|
+
return completion;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
module.exports = { setupAutocomplete };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
|
|
3
|
+
const cleanup = async () => {
|
|
4
|
+
try {
|
|
5
|
+
console.log('Starting cleanup process...\n');
|
|
6
|
+
|
|
7
|
+
// Get current branch
|
|
8
|
+
const currentBranch = execSync('git branch --show-current', { encoding: 'utf-8' }).trim();
|
|
9
|
+
console.log(`Current branch: ${currentBranch}`);
|
|
10
|
+
|
|
11
|
+
// Checkout to master
|
|
12
|
+
console.log('\nChecking out to master branch...');
|
|
13
|
+
try {
|
|
14
|
+
execSync('git checkout master', { encoding: 'utf-8', stdio: 'inherit' });
|
|
15
|
+
} catch (error) {
|
|
16
|
+
// Try main if master doesn't exist
|
|
17
|
+
console.log('Master branch not found, trying main...');
|
|
18
|
+
execSync('git checkout main', { encoding: 'utf-8', stdio: 'inherit' });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Get all local branches except master/main
|
|
22
|
+
console.log('\nFetching list of local branches...');
|
|
23
|
+
const branches = execSync('git branch', { encoding: 'utf-8' })
|
|
24
|
+
.split('\n')
|
|
25
|
+
.map((branch) => branch.trim().replace('* ', ''))
|
|
26
|
+
.filter((branch) => branch && branch !== 'master' && branch !== 'main');
|
|
27
|
+
|
|
28
|
+
if (!branches.length) {
|
|
29
|
+
console.log('\nNo branches to delete. Cleanup complete!');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(`\nFound ${branches.length} branch(es) to delete:`);
|
|
34
|
+
|
|
35
|
+
// Delete each branch
|
|
36
|
+
console.log('\nDeleting branches...');
|
|
37
|
+
let deletedCount = 0;
|
|
38
|
+
let failedCount = 0;
|
|
39
|
+
|
|
40
|
+
for (const branch of branches) {
|
|
41
|
+
try {
|
|
42
|
+
execSync(`git branch -D ${branch}`, { encoding: 'utf-8' });
|
|
43
|
+
console.log(` ✓ Deleted: ${branch}`);
|
|
44
|
+
deletedCount++;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.log(` ✗ Failed to delete: ${branch}`);
|
|
47
|
+
failedCount++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log(`\nCleanup complete!`);
|
|
52
|
+
console.log(` Deleted: ${deletedCount} branch(es)`);
|
|
53
|
+
|
|
54
|
+
if (failedCount > 0) {
|
|
55
|
+
console.log(` Failed: ${failedCount} branch(es)`);
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('Error during cleanup:', error.message);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
module.exports = { cleanup };
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
ACTIONS: {
|
|
3
|
+
BACKUP: 'backup',
|
|
4
|
+
BUILD_DEPLOY: 'build-deploy',
|
|
3
5
|
BUILD: 'build',
|
|
6
|
+
CLEANUP: 'cleanup',
|
|
7
|
+
CREATE_BRANCH: 'create-branch',
|
|
4
8
|
DEPLOY: 'deploy',
|
|
5
|
-
BUILD_DEPLOY: 'build-deploy',
|
|
6
|
-
VERSION: 'version',
|
|
7
9
|
HELP: 'help',
|
|
8
|
-
CREATE_BRANCH: 'create-branch',
|
|
9
|
-
REVIEW: 'review',
|
|
10
|
-
REFACTOR: 'refactor',
|
|
11
|
-
BACKUP: 'backup',
|
|
12
10
|
MERGE: 'merge',
|
|
11
|
+
REFACTOR: 'refactor',
|
|
12
|
+
REVIEW: 'review',
|
|
13
|
+
VERSION: 'version',
|
|
14
|
+
|
|
15
|
+
// Time entry commands
|
|
16
|
+
TIME_INIT: 'time-init',
|
|
17
|
+
TIME_SWITCH: 'time-switch',
|
|
18
|
+
TIME_ADD: 'time-add',
|
|
19
|
+
TIME_UPDATE: 'time-update',
|
|
20
|
+
TIME_DELETE: 'time-delete',
|
|
21
|
+
TIME_STATUS: 'time-stats',
|
|
22
|
+
TIME_ENTRIES: 'time-entries',
|
|
23
|
+
TIME_ZOHO: 'time-zoho',
|
|
24
|
+
TIME_GITLAB: 'time-gitlab',
|
|
25
|
+
TIME_MERGE: 'time-merge',
|
|
13
26
|
},
|
|
14
27
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const axios = require('axios');
|
|
2
2
|
const { build, buildStatus } = require('./build');
|
|
3
3
|
const { deploy } = require('./deploy');
|
|
4
4
|
const { ACTIONS } = require('./enums/actions.enum');
|
|
@@ -8,17 +8,37 @@ const { mrAIReview } = require('./review');
|
|
|
8
8
|
const { refactor } = require('./refactor');
|
|
9
9
|
const { backup } = require('./mongodb-backup');
|
|
10
10
|
const { merge } = require('./merge');
|
|
11
|
+
const { cleanup } = require('./cleanup');
|
|
12
|
+
|
|
13
|
+
// Time entry imports
|
|
14
|
+
const { removeEmpty } = require('./time-entry/utils');
|
|
15
|
+
const { getStatus, getTasksByDate } = require('./time-entry/get-report');
|
|
16
|
+
const { logTaskHoursAndSync } = require('./time-entry/log-task-hours-and-sync');
|
|
17
|
+
const { addNewTask } = require('./time-entry/add-task');
|
|
18
|
+
const { updateTask, deleteTask } = require('./time-entry/update-delete-task');
|
|
19
|
+
const { getGitlabActivities } = require('./time-entry/get-gitlab-activities');
|
|
20
|
+
const { getZohoTasks } = require('./time-entry/get-zoho-tasks');
|
|
11
21
|
|
|
12
22
|
const processArgs = async (type, value) => {
|
|
13
23
|
try {
|
|
14
24
|
let values;
|
|
15
25
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
// Skip convertParamsToMap for time commands and other special commands
|
|
27
|
+
const skipConversion = [
|
|
28
|
+
ACTIONS.HELP,
|
|
29
|
+
ACTIONS.VERSION,
|
|
30
|
+
ACTIONS.CLEANUP,
|
|
31
|
+
ACTIONS.TIME_ADD,
|
|
32
|
+
ACTIONS.TIME_UPDATE,
|
|
33
|
+
ACTIONS.TIME_DELETE,
|
|
34
|
+
ACTIONS.TIME_STATUS,
|
|
35
|
+
ACTIONS.TIME_ENTRIES,
|
|
36
|
+
ACTIONS.TIME_ZOHO,
|
|
37
|
+
ACTIONS.TIME_GITLAB,
|
|
38
|
+
ACTIONS.TIME_MERGE,
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
if (!skipConversion.includes(type) && !value?.includes('--h') && !value?.includes('-help')) {
|
|
22
42
|
values = await convertParamsToMap(value, type);
|
|
23
43
|
}
|
|
24
44
|
|
|
@@ -138,22 +158,22 @@ Options:
|
|
|
138
158
|
-r, --repository <repository name> repository name
|
|
139
159
|
|
|
140
160
|
Repository list:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
portalDeployment
|
|
144
|
-
portalAutomation
|
|
161
|
+
centralAuth
|
|
162
|
+
configService
|
|
145
163
|
gatewayBackend
|
|
146
164
|
gatewayClient
|
|
147
165
|
gatewayDeployment
|
|
148
|
-
phrClient
|
|
149
|
-
phrBackend
|
|
150
|
-
phrDeployment
|
|
151
|
-
configService
|
|
152
166
|
healthRecords
|
|
153
|
-
centralAuth
|
|
154
167
|
mpi
|
|
155
168
|
phrAdminBackend
|
|
156
169
|
phrAdminClient
|
|
170
|
+
phrBackend
|
|
171
|
+
phrClient
|
|
172
|
+
phrDeployment
|
|
173
|
+
portalAutomation
|
|
174
|
+
portalBackend
|
|
175
|
+
portalClient
|
|
176
|
+
portalDeployment
|
|
157
177
|
terminologyService`);
|
|
158
178
|
|
|
159
179
|
return;
|
|
@@ -224,12 +244,165 @@ This command will:
|
|
|
224
244
|
break;
|
|
225
245
|
}
|
|
226
246
|
|
|
247
|
+
case ACTIONS.CLEANUP: {
|
|
248
|
+
if (value === '-help' || value === '--h') {
|
|
249
|
+
console.log(`usage: \tnu cleanup
|
|
250
|
+
|
|
251
|
+
Cleanup local git branches
|
|
252
|
+
|
|
253
|
+
This command will:
|
|
254
|
+
1. Checkout to master (or main) branch
|
|
255
|
+
2. Delete all other local branches
|
|
256
|
+
|
|
257
|
+
Note: This operation cannot be undone. Make sure you have pushed any important changes.`);
|
|
258
|
+
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
await cleanup();
|
|
263
|
+
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
|
|
227
267
|
case ACTIONS.VERSION: {
|
|
228
268
|
const path = require('path');
|
|
229
269
|
const packageJson = require(path.resolve(__dirname, '../package.json'));
|
|
230
270
|
const packageVersion = packageJson.version;
|
|
271
|
+
// ANSI color codes
|
|
272
|
+
const cyan = '\x1b[36m';
|
|
273
|
+
const green = '\x1b[32m';
|
|
274
|
+
const yellow = '\x1b[33m';
|
|
275
|
+
const reset = '\x1b[0m';
|
|
276
|
+
const bold = '\x1b[1m';
|
|
277
|
+
|
|
278
|
+
console.log(`
|
|
279
|
+
${cyan}${bold}╔════════════════════════════════════════════════════╗
|
|
280
|
+
║ ║
|
|
281
|
+
║ ${yellow}███╗ ██╗ ██╗ ████████╗ ██████╗ ██████╗${cyan} ║
|
|
282
|
+
║ ${yellow}████╗ ██║ ██║ ╚══██╔══╝ ██╔═══██╗ ██╔══██╗${cyan} ║
|
|
283
|
+
║ ${yellow}██╔██╗ ██║ ██║ ██║ ██║ ██║ ██████╔╝${cyan} ║
|
|
284
|
+
║ ${yellow}██║╚██╗██║ ██║ ██║ ██║ ██║ ██╔══██╗${cyan} ║
|
|
285
|
+
║ ${yellow}██║ ╚████║ ██║ ██║ ╚██████╔╝ ██║ ██║${cyan} ║
|
|
286
|
+
║ ${yellow}╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝${cyan} ║
|
|
287
|
+
║ ║
|
|
288
|
+
╚════════════════════════════════════════════════════╝${reset}
|
|
289
|
+
|
|
290
|
+
${green}${bold}Version:${reset} ${bold}v${packageVersion}${reset}`);
|
|
291
|
+
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Time entry commands
|
|
296
|
+
case ACTIONS.TIME_ADD: {
|
|
297
|
+
const timeValues = value ? removeEmpty(value?.split(' -')) : value;
|
|
298
|
+
|
|
299
|
+
await addNewTask(timeValues);
|
|
300
|
+
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
case ACTIONS.TIME_UPDATE: {
|
|
305
|
+
const timeValues = value ? removeEmpty(value?.split(' -')) : value;
|
|
306
|
+
|
|
307
|
+
await updateTask(timeValues);
|
|
231
308
|
|
|
232
|
-
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
case ACTIONS.TIME_DELETE: {
|
|
313
|
+
const timeValues = value ? removeEmpty(value?.split(' -')) : value;
|
|
314
|
+
|
|
315
|
+
console.log(await deleteTask(timeValues));
|
|
316
|
+
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
case ACTIONS.TIME_STATUS: {
|
|
321
|
+
const timeValues = value ? removeEmpty(value?.split(' -')) : value;
|
|
322
|
+
|
|
323
|
+
await getStatus(timeValues);
|
|
324
|
+
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
case ACTIONS.TIME_ENTRIES: {
|
|
329
|
+
const timeValues = value ? removeEmpty(value?.split(' -')) : value;
|
|
330
|
+
|
|
331
|
+
console.table(await getTasksByDate(timeValues));
|
|
332
|
+
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
case ACTIONS.TIME_ZOHO: {
|
|
337
|
+
console.log('Final status: ', await logTaskHoursAndSync());
|
|
338
|
+
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
case ACTIONS.TIME_GITLAB: {
|
|
343
|
+
const timeValues = value ? removeEmpty(value?.split(' -')) : value;
|
|
344
|
+
|
|
345
|
+
await getGitlabActivities(timeValues);
|
|
346
|
+
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
case ACTIONS.TIME_MERGE: {
|
|
351
|
+
const tasks = await getZohoTasks({ params: { type: ['2'] } });
|
|
352
|
+
const taskIds = tasks.reduce((acc, task) => {
|
|
353
|
+
if (task.gitlab_iid) {
|
|
354
|
+
acc.push({ taskId: task.taskId, gitlabIid: task.gitlab_iid });
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return acc;
|
|
358
|
+
}, []);
|
|
359
|
+
|
|
360
|
+
if (!taskIds.length) {
|
|
361
|
+
console.log('No active tasks with GitLab IIDs found');
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const mergeRequests = await Promise.all(
|
|
366
|
+
taskIds.map(async ({ taskId, gitlabIid }) => {
|
|
367
|
+
try {
|
|
368
|
+
const response = await axios.get(
|
|
369
|
+
`${process.env.GITLAB_API_URL}/projects/${process.env.GITLAB_PROJECT_ID}/merge_requests/${gitlabIid}`,
|
|
370
|
+
{
|
|
371
|
+
headers: {
|
|
372
|
+
'PRIVATE-TOKEN': process.env.GITLAB_TOKEN,
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
);
|
|
376
|
+
return {
|
|
377
|
+
taskId,
|
|
378
|
+
gitlabIid,
|
|
379
|
+
status: response.data.state,
|
|
380
|
+
assignee: response.data.assignee?.name || 'Unassigned',
|
|
381
|
+
title: response.data.title,
|
|
382
|
+
webUrl: response.data.web_url,
|
|
383
|
+
};
|
|
384
|
+
} catch (error) {
|
|
385
|
+
return {
|
|
386
|
+
taskId,
|
|
387
|
+
gitlabIid,
|
|
388
|
+
status: 'error',
|
|
389
|
+
error: error.response?.status === 404 ? 'MR not found' : 'Failed to fetch MR',
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}),
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
console.table(
|
|
396
|
+
mergeRequests.map((mr) => ({
|
|
397
|
+
'Task ID': mr.taskId,
|
|
398
|
+
'MR IID': mr.gitlabIid,
|
|
399
|
+
Status: mr.status,
|
|
400
|
+
Assignee: mr.assignee || '-',
|
|
401
|
+
Title: mr.title || '-',
|
|
402
|
+
URL: mr.webUrl || '-',
|
|
403
|
+
Error: mr.error || '-',
|
|
404
|
+
})),
|
|
405
|
+
);
|
|
233
406
|
|
|
234
407
|
break;
|
|
235
408
|
}
|
|
@@ -237,28 +410,49 @@ This command will:
|
|
|
237
410
|
case ACTIONS.HELP: {
|
|
238
411
|
console.log(`usage: nitor \t[${ACTIONS.VERSION}] [${ACTIONS.HELP}]
|
|
239
412
|
\t[${ACTIONS.BUILD}] [${ACTIONS.DEPLOY}] [${ACTIONS.BUILD_DEPLOY}]
|
|
240
|
-
\t[${ACTIONS.CREATE_BRANCH}] [${ACTIONS.REVIEW}] [${ACTIONS.MERGE}]
|
|
413
|
+
\t[${ACTIONS.CREATE_BRANCH}] [${ACTIONS.REVIEW}] [${ACTIONS.MERGE}]
|
|
414
|
+
\t[${ACTIONS.CLEANUP}] [${ACTIONS.BACKUP}] [${ACTIONS.REFACTOR}]
|
|
415
|
+
\t[${ACTIONS.TIME_INIT}] [${ACTIONS.TIME_ADD}] [${ACTIONS.TIME_STATUS}]\n
|
|
241
416
|
Available commands:\n
|
|
417
|
+
backup : Backup MongoDB databases
|
|
242
418
|
build : Build specified components
|
|
243
|
-
deploy : Deploy specified components
|
|
244
419
|
build-deploy : Build and then deploy
|
|
420
|
+
cleanup : Cleanup local git branches (checkout to master and delete all other branches)
|
|
421
|
+
completion : Setup shell autocomplete
|
|
245
422
|
create-branch : Create git branch
|
|
246
|
-
|
|
247
|
-
refactor : REFACTOR the provided text for improved clarity, conciseness, and professional quality.
|
|
423
|
+
deploy : Deploy specified components
|
|
248
424
|
merge : Merge source branch into target branch
|
|
425
|
+
refactor : Refactor the provided text for improved clarity, conciseness, and professional quality
|
|
426
|
+
review : AI Review specified merge request
|
|
249
427
|
version : Show version info
|
|
250
428
|
help : Show help
|
|
251
429
|
|
|
430
|
+
Time Entry commands:
|
|
431
|
+
time-init : Initialize time entry configuration
|
|
432
|
+
time-add : Add time entry
|
|
433
|
+
time-delete : Delete time entry
|
|
434
|
+
time-entries : View time entries by date
|
|
435
|
+
time-gitlab : Get GitLab activities
|
|
436
|
+
time-merge : View merge request status for tasks
|
|
437
|
+
time-stats : View daily status of time entries
|
|
438
|
+
time-switch : Switch between default projects
|
|
439
|
+
time-update : Update existing time entry
|
|
440
|
+
time-zoho : Sync time entries to Zoho
|
|
441
|
+
|
|
252
442
|
For details of each actions run 'nitor <action> -help'
|
|
253
443
|
|
|
254
444
|
Example usage:\n
|
|
255
445
|
nitor build -project <project> -components <components> -instance <instance>
|
|
256
|
-
nitor deploy -project <project> -components <components> -instance <instance>
|
|
257
446
|
nitor build-deploy -project <project> -components <components> -instance <instance>
|
|
447
|
+
nitor cleanup
|
|
258
448
|
nitor create-branch -task <task number> -type <feat|fix> -description <description> -project <project short name>
|
|
259
|
-
nitor
|
|
260
|
-
nitor refactor <text>
|
|
449
|
+
nitor deploy -project <project> -components <components> -instance <instance>
|
|
261
450
|
nitor merge -source <source branch> -target <target branch>
|
|
451
|
+
nitor refactor <text>
|
|
452
|
+
nitor review -project <project short name> -mergeId <merge id> -repository <repository name>
|
|
453
|
+
nitor time-init
|
|
454
|
+
nitor time-add
|
|
455
|
+
nitor time-stats
|
|
262
456
|
|
|
263
457
|
Running 'nitor help' will list available subcommands and provide some conceptual guides.`);
|
|
264
458
|
break;
|
package/services/review.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { gitlabConfig, projectIdMap, mrPrompt, mrLang, mrApiUri } = require('./utils');
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
|
|
4
4
|
const executeMergeRequestReview = async (values) => {
|
|
@@ -9,7 +9,7 @@ const executeMergeRequestReview = async (values) => {
|
|
|
9
9
|
headers: { 'Content-Type': 'application/json' },
|
|
10
10
|
data: JSON.stringify({
|
|
11
11
|
language: mrLang,
|
|
12
|
-
gitlabToken,
|
|
12
|
+
gitlabToken: gitlabConfig.token,
|
|
13
13
|
llmModel: 'claude',
|
|
14
14
|
prompt: mrPrompt,
|
|
15
15
|
}),
|