plugin-git-manager 1.2.12 → 1.2.14
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/client/900.ec1fa7f16eb8cce6.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/900.7a5e80bf21feda66.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +7 -7
- package/dist/locale/en-US.json +28 -1
- package/dist/locale/vi-VN.json +30 -1
- package/dist/server/actions/git-actions.js +6 -4
- package/dist/server/actions/review.js +40 -3
- package/dist/server/ai-tools.js +30 -0
- package/dist/server/collections/gitCodeReviews.js +8 -1
- package/dist/server/plugin.js +17 -10
- package/package.json +1 -1
- package/src/client/components/FileExplorer.tsx +63 -11
- package/src/client/components/ReviewFlows.tsx +33 -11
- package/src/client/components/ReviewHistory.tsx +45 -9
- package/src/client/components/RunReviewButton.tsx +436 -375
- package/src/client/promptTemplates.ts +31 -0
- package/src/locale/en-US.json +28 -1
- package/src/locale/vi-VN.json +30 -1
- package/src/server/actions/git-actions.ts +432 -430
- package/src/server/actions/review.ts +51 -7
- package/src/server/ai-tools.ts +32 -4
- package/src/server/collections/gitCodeReviews.ts +7 -0
- package/src/server/plugin.ts +250 -242
- package/dist/client/878.3e7b8b27c157996c.js +0 -10
- package/dist/client-v2/878.295f09c9d77ea6d8.js +0 -10
package/src/server/plugin.ts
CHANGED
|
@@ -1,242 +1,250 @@
|
|
|
1
|
-
import { Plugin } from '@nocobase/server';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
import { DataTypes } from 'sequelize';
|
|
4
|
-
import * as gitActions from './actions/git-actions';
|
|
5
|
-
import * as gitlabApi from './actions/gitlab-api';
|
|
6
|
-
import * as reviewActions from './actions/review';
|
|
7
|
-
import * as pollerActions from './actions/poller';
|
|
8
|
-
import * as rolePermissionsActions from './actions/role-permissions';
|
|
9
|
-
import { recoverStuckReviews, registerReviewQueue, unregisterReviewQueue } from './actions/review';
|
|
10
|
-
import { registerGitReviewAiTools } from './ai-tools';
|
|
11
|
-
import { startPoller, stopPoller } from './poller';
|
|
12
|
-
|
|
13
|
-
export class PluginGitManagerServer extends Plugin {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
declare app: any;
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
declare db: any;
|
|
18
|
-
async beforeLoad() {
|
|
19
|
-
await (this as any).app.db.import({
|
|
20
|
-
directory: resolve(__dirname, 'collections'),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
(this as any).app.db.addMigrations({
|
|
24
|
-
namespace: (this as any).name,
|
|
25
|
-
directory: resolve(__dirname, 'migrations'),
|
|
26
|
-
context: { plugin: this },
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async load() {
|
|
31
|
-
// Ensure dayjs timezone + utc plugins are loaded globally to prevent 'm.startOf is not a function' errors
|
|
32
|
-
const dayjsLib = require('dayjs');
|
|
33
|
-
const utcPlugin = require('dayjs/plugin/utc');
|
|
34
|
-
const timezonePlugin = require('dayjs/plugin/timezone');
|
|
35
|
-
dayjsLib.extend(utcPlugin);
|
|
36
|
-
dayjsLib.extend(timezonePlugin);
|
|
37
|
-
|
|
38
|
-
(this as any).app.resourceManager.define({
|
|
39
|
-
name: 'gitManager',
|
|
40
|
-
actions: {
|
|
41
|
-
clone: gitActions.clone,
|
|
42
|
-
pull: gitActions.pull,
|
|
43
|
-
push: gitActions.push,
|
|
44
|
-
fetch: gitActions.fetch,
|
|
45
|
-
diff: gitActions.diff,
|
|
46
|
-
status: gitActions.status,
|
|
47
|
-
log: gitActions.log,
|
|
48
|
-
branches: gitActions.branches,
|
|
49
|
-
checkout: gitActions.checkout,
|
|
50
|
-
fileTree: gitActions.fileTree,
|
|
51
|
-
fileContent: gitActions.fileContent,
|
|
52
|
-
commitDetail: gitActions.commitDetail,
|
|
53
|
-
mergeRequests: gitlabApi.mergeRequests,
|
|
54
|
-
mergeRequestDetail: gitlabApi.mergeRequestDetail,
|
|
55
|
-
mergeRequestNotes: gitlabApi.mergeRequestNotes,
|
|
56
|
-
triggerReview: reviewActions.triggerReview,
|
|
57
|
-
reviewApprovePost: reviewActions.reviewApprovePost,
|
|
58
|
-
reviewReject: reviewActions.reviewReject,
|
|
59
|
-
pollNow: pollerActions.pollNow,
|
|
60
|
-
pollerStatus: pollerActions.pollerStatus,
|
|
61
|
-
rolePermissions: rolePermissionsActions.rolePermissions,
|
|
62
|
-
updateRolePermissions: rolePermissionsActions.updateRolePermissions,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// Suppress noisy workflow pre-action/post-action warnings for custom resources
|
|
67
|
-
(this as any).app.use(async (ctx, next) => {
|
|
68
|
-
if (ctx.logger && ctx.logger.warn) {
|
|
69
|
-
const originalWarn = ctx.logger.warn.bind(ctx.logger);
|
|
70
|
-
ctx.logger.warn = (message: any, ...args: any[]) => {
|
|
71
|
-
if (
|
|
72
|
-
typeof message === 'string' &&
|
|
73
|
-
message.includes('[Workflow') &&
|
|
74
|
-
message.includes('collection') &&
|
|
75
|
-
message.includes('not found')
|
|
76
|
-
) {
|
|
77
|
-
return ctx.logger;
|
|
78
|
-
}
|
|
79
|
-
return originalWarn(message, ...args);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return next();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
registerReviewQueue((this as any).app);
|
|
86
|
-
registerGitReviewAiTools((this as any).app);
|
|
87
|
-
|
|
88
|
-
(this as any).app.on('afterStart', async () => {
|
|
89
|
-
await ensureAutoReviewFlowSchema((this as any).app).catch(
|
|
90
|
-
(err) => (this as any).app.log?.error?.('plugin-git-manager: ensure schema error', err),
|
|
91
|
-
);
|
|
92
|
-
// Sweep any review left in `running` state from a previous process.
|
|
93
|
-
recoverStuckReviews((this as any).app).catch(
|
|
94
|
-
(err) => (this as any).app.log?.error?.('plugin-git-manager: recoverStuckReviews error', err),
|
|
95
|
-
);
|
|
96
|
-
startPoller((this as any).app);
|
|
97
|
-
});
|
|
98
|
-
(this as any).app.on('beforeStop', () => {
|
|
99
|
-
unregisterReviewQueue((this as any).app);
|
|
100
|
-
stopPoller();
|
|
101
|
-
});
|
|
102
|
-
(this as any).app.on('beforeDestroy', () => {
|
|
103
|
-
unregisterReviewQueue((this as any).app);
|
|
104
|
-
stopPoller();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// Read-only operations available to all plugin users
|
|
108
|
-
(this as any).app.acl.registerSnippet({
|
|
109
|
-
name: `pm.${(this as any).name}.read`,
|
|
110
|
-
actions: [
|
|
111
|
-
'gitRepositories:list',
|
|
112
|
-
'gitRepositories:get',
|
|
113
|
-
'gitReviewFlows:list',
|
|
114
|
-
'gitReviewFlows:get',
|
|
115
|
-
'gitCodeReviews:list',
|
|
116
|
-
'gitCodeReviews:get',
|
|
117
|
-
'gitManager:status',
|
|
118
|
-
'gitManager:log',
|
|
119
|
-
'gitManager:branches',
|
|
120
|
-
'gitManager:diff',
|
|
121
|
-
'gitManager:fileTree',
|
|
122
|
-
'gitManager:fileContent',
|
|
123
|
-
'gitManager:commitDetail',
|
|
124
|
-
'gitManager:mergeRequests',
|
|
125
|
-
'gitManager:mergeRequestDetail',
|
|
126
|
-
'gitManager:mergeRequestNotes',
|
|
127
|
-
'gitManager:pollerStatus',
|
|
128
|
-
],
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// Write operations require separate permission
|
|
132
|
-
(this as any).app.acl.registerSnippet({
|
|
133
|
-
name: `pm.${(this as any).name}.write`,
|
|
134
|
-
actions: [
|
|
135
|
-
'gitRepositories:create',
|
|
136
|
-
'gitRepositories:update',
|
|
137
|
-
'gitRepositories:destroy',
|
|
138
|
-
'gitReviewFlows:create',
|
|
139
|
-
'gitReviewFlows:update',
|
|
140
|
-
'gitReviewFlows:destroy',
|
|
141
|
-
'gitCodeReviews:create',
|
|
142
|
-
'gitCodeReviews:update',
|
|
143
|
-
'gitCodeReviews:destroy',
|
|
144
|
-
'gitManager:clone',
|
|
145
|
-
'gitManager:pull',
|
|
146
|
-
'gitManager:push',
|
|
147
|
-
'gitManager:fetch',
|
|
148
|
-
'gitManager:checkout',
|
|
149
|
-
'gitManager:triggerReview',
|
|
150
|
-
'gitManager:reviewApprovePost',
|
|
151
|
-
'gitManager:reviewReject',
|
|
152
|
-
'gitManager:pollNow',
|
|
153
|
-
],
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
// Repositories config — CRUD on gitRepositories only (no operations)
|
|
157
|
-
(this as any).app.acl.registerSnippet({
|
|
158
|
-
name: `pm.${(this as any).name}.repositories`,
|
|
159
|
-
actions: [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
`pm.${(this as any).name}.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
1
|
+
import { Plugin } from '@nocobase/server';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { DataTypes } from 'sequelize';
|
|
4
|
+
import * as gitActions from './actions/git-actions';
|
|
5
|
+
import * as gitlabApi from './actions/gitlab-api';
|
|
6
|
+
import * as reviewActions from './actions/review';
|
|
7
|
+
import * as pollerActions from './actions/poller';
|
|
8
|
+
import * as rolePermissionsActions from './actions/role-permissions';
|
|
9
|
+
import { recoverStuckReviews, registerReviewQueue, unregisterReviewQueue } from './actions/review';
|
|
10
|
+
import { registerGitReviewAiTools } from './ai-tools';
|
|
11
|
+
import { startPoller, stopPoller } from './poller';
|
|
12
|
+
|
|
13
|
+
export class PluginGitManagerServer extends Plugin {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
declare app: any;
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
declare db: any;
|
|
18
|
+
async beforeLoad() {
|
|
19
|
+
await (this as any).app.db.import({
|
|
20
|
+
directory: resolve(__dirname, 'collections'),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
(this as any).app.db.addMigrations({
|
|
24
|
+
namespace: (this as any).name,
|
|
25
|
+
directory: resolve(__dirname, 'migrations'),
|
|
26
|
+
context: { plugin: this },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async load() {
|
|
31
|
+
// Ensure dayjs timezone + utc plugins are loaded globally to prevent 'm.startOf is not a function' errors
|
|
32
|
+
const dayjsLib = require('dayjs');
|
|
33
|
+
const utcPlugin = require('dayjs/plugin/utc');
|
|
34
|
+
const timezonePlugin = require('dayjs/plugin/timezone');
|
|
35
|
+
dayjsLib.extend(utcPlugin);
|
|
36
|
+
dayjsLib.extend(timezonePlugin);
|
|
37
|
+
|
|
38
|
+
(this as any).app.resourceManager.define({
|
|
39
|
+
name: 'gitManager',
|
|
40
|
+
actions: {
|
|
41
|
+
clone: gitActions.clone,
|
|
42
|
+
pull: gitActions.pull,
|
|
43
|
+
push: gitActions.push,
|
|
44
|
+
fetch: gitActions.fetch,
|
|
45
|
+
diff: gitActions.diff,
|
|
46
|
+
status: gitActions.status,
|
|
47
|
+
log: gitActions.log,
|
|
48
|
+
branches: gitActions.branches,
|
|
49
|
+
checkout: gitActions.checkout,
|
|
50
|
+
fileTree: gitActions.fileTree,
|
|
51
|
+
fileContent: gitActions.fileContent,
|
|
52
|
+
commitDetail: gitActions.commitDetail,
|
|
53
|
+
mergeRequests: gitlabApi.mergeRequests,
|
|
54
|
+
mergeRequestDetail: gitlabApi.mergeRequestDetail,
|
|
55
|
+
mergeRequestNotes: gitlabApi.mergeRequestNotes,
|
|
56
|
+
triggerReview: reviewActions.triggerReview,
|
|
57
|
+
reviewApprovePost: reviewActions.reviewApprovePost,
|
|
58
|
+
reviewReject: reviewActions.reviewReject,
|
|
59
|
+
pollNow: pollerActions.pollNow,
|
|
60
|
+
pollerStatus: pollerActions.pollerStatus,
|
|
61
|
+
rolePermissions: rolePermissionsActions.rolePermissions,
|
|
62
|
+
updateRolePermissions: rolePermissionsActions.updateRolePermissions,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Suppress noisy workflow pre-action/post-action warnings for custom resources
|
|
67
|
+
(this as any).app.use(async (ctx, next) => {
|
|
68
|
+
if (ctx.logger && ctx.logger.warn) {
|
|
69
|
+
const originalWarn = ctx.logger.warn.bind(ctx.logger);
|
|
70
|
+
ctx.logger.warn = (message: any, ...args: any[]) => {
|
|
71
|
+
if (
|
|
72
|
+
typeof message === 'string' &&
|
|
73
|
+
message.includes('[Workflow') &&
|
|
74
|
+
message.includes('collection') &&
|
|
75
|
+
message.includes('not found')
|
|
76
|
+
) {
|
|
77
|
+
return ctx.logger;
|
|
78
|
+
}
|
|
79
|
+
return originalWarn(message, ...args);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return next();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
registerReviewQueue((this as any).app);
|
|
86
|
+
registerGitReviewAiTools((this as any).app);
|
|
87
|
+
|
|
88
|
+
(this as any).app.on('afterStart', async () => {
|
|
89
|
+
await ensureAutoReviewFlowSchema((this as any).app).catch(
|
|
90
|
+
(err) => (this as any).app.log?.error?.('plugin-git-manager: ensure schema error', err),
|
|
91
|
+
);
|
|
92
|
+
// Sweep any review left in `running` state from a previous process.
|
|
93
|
+
recoverStuckReviews((this as any).app).catch(
|
|
94
|
+
(err) => (this as any).app.log?.error?.('plugin-git-manager: recoverStuckReviews error', err),
|
|
95
|
+
);
|
|
96
|
+
startPoller((this as any).app);
|
|
97
|
+
});
|
|
98
|
+
(this as any).app.on('beforeStop', () => {
|
|
99
|
+
unregisterReviewQueue((this as any).app);
|
|
100
|
+
stopPoller();
|
|
101
|
+
});
|
|
102
|
+
(this as any).app.on('beforeDestroy', () => {
|
|
103
|
+
unregisterReviewQueue((this as any).app);
|
|
104
|
+
stopPoller();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Read-only operations available to all plugin users
|
|
108
|
+
(this as any).app.acl.registerSnippet({
|
|
109
|
+
name: `pm.${(this as any).name}.read`,
|
|
110
|
+
actions: [
|
|
111
|
+
'gitRepositories:list',
|
|
112
|
+
'gitRepositories:get',
|
|
113
|
+
'gitReviewFlows:list',
|
|
114
|
+
'gitReviewFlows:get',
|
|
115
|
+
'gitCodeReviews:list',
|
|
116
|
+
'gitCodeReviews:get',
|
|
117
|
+
'gitManager:status',
|
|
118
|
+
'gitManager:log',
|
|
119
|
+
'gitManager:branches',
|
|
120
|
+
'gitManager:diff',
|
|
121
|
+
'gitManager:fileTree',
|
|
122
|
+
'gitManager:fileContent',
|
|
123
|
+
'gitManager:commitDetail',
|
|
124
|
+
'gitManager:mergeRequests',
|
|
125
|
+
'gitManager:mergeRequestDetail',
|
|
126
|
+
'gitManager:mergeRequestNotes',
|
|
127
|
+
'gitManager:pollerStatus',
|
|
128
|
+
],
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Write operations require separate permission
|
|
132
|
+
(this as any).app.acl.registerSnippet({
|
|
133
|
+
name: `pm.${(this as any).name}.write`,
|
|
134
|
+
actions: [
|
|
135
|
+
'gitRepositories:create',
|
|
136
|
+
'gitRepositories:update',
|
|
137
|
+
'gitRepositories:destroy',
|
|
138
|
+
'gitReviewFlows:create',
|
|
139
|
+
'gitReviewFlows:update',
|
|
140
|
+
'gitReviewFlows:destroy',
|
|
141
|
+
'gitCodeReviews:create',
|
|
142
|
+
'gitCodeReviews:update',
|
|
143
|
+
'gitCodeReviews:destroy',
|
|
144
|
+
'gitManager:clone',
|
|
145
|
+
'gitManager:pull',
|
|
146
|
+
'gitManager:push',
|
|
147
|
+
'gitManager:fetch',
|
|
148
|
+
'gitManager:checkout',
|
|
149
|
+
'gitManager:triggerReview',
|
|
150
|
+
'gitManager:reviewApprovePost',
|
|
151
|
+
'gitManager:reviewReject',
|
|
152
|
+
'gitManager:pollNow',
|
|
153
|
+
],
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Repositories config — CRUD on gitRepositories only (no operations)
|
|
157
|
+
(this as any).app.acl.registerSnippet({
|
|
158
|
+
name: `pm.${(this as any).name}.repositories`,
|
|
159
|
+
actions: ['gitRepositories:*'],
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Full management — all git manager actions
|
|
163
|
+
(this as any).app.acl.registerSnippet({
|
|
164
|
+
name: `pm.${(this as any).name}.manage`,
|
|
165
|
+
actions: [
|
|
166
|
+
`pm.${(this as any).name}.repositories`,
|
|
167
|
+
`pm.${(this as any).name}.read`,
|
|
168
|
+
`pm.${(this as any).name}.write`,
|
|
169
|
+
],
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Prevent overwriting PAT with obfuscated value on updates
|
|
173
|
+
(this as any).app.resourceManager.use(async (ctx, next) => {
|
|
174
|
+
if (ctx.action?.resourceName === 'gitRepositories' && ['create', 'update'].includes(ctx.action?.actionName)) {
|
|
175
|
+
if (ctx.action.params?.values?.pat === '••••••••') {
|
|
176
|
+
delete ctx.action.params.values.pat;
|
|
177
|
+
}
|
|
178
|
+
if (ctx.request.body?.pat === '••••••••') {
|
|
179
|
+
delete ctx.request.body.pat;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return next();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Strip PAT from API responses — scoped to gitRepositories only
|
|
186
|
+
(this as any).app.resourceManager.use(async (ctx, next) => {
|
|
187
|
+
if (ctx.action?.resourceName !== 'gitRepositories') {
|
|
188
|
+
return next();
|
|
189
|
+
}
|
|
190
|
+
await next();
|
|
191
|
+
if (ctx.body) {
|
|
192
|
+
const items = Array.isArray(ctx.body)
|
|
193
|
+
? ctx.body
|
|
194
|
+
: ctx.body?.data
|
|
195
|
+
? Array.isArray(ctx.body.data)
|
|
196
|
+
? ctx.body.data
|
|
197
|
+
: [ctx.body.data]
|
|
198
|
+
: [ctx.body];
|
|
199
|
+
items.forEach((item) => {
|
|
200
|
+
if (item && typeof item === 'object') {
|
|
201
|
+
if (item.pat) item.pat = '••••••••';
|
|
202
|
+
if (item.dataValues?.pat) item.dataValues.pat = '••••••••';
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async install() {
|
|
210
|
+
await (this as any).app.db.getCollection('gitRepositories')?.sync();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async beforeDisable() {
|
|
214
|
+
unregisterReviewQueue((this as any).app);
|
|
215
|
+
stopPoller();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async beforeUnload() {
|
|
219
|
+
unregisterReviewQueue((this as any).app);
|
|
220
|
+
stopPoller();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export async function ensureAutoReviewFlowSchema(app: any) {
|
|
225
|
+
const sequelize = app.db?.sequelize;
|
|
226
|
+
const queryInterface = sequelize?.getQueryInterface?.();
|
|
227
|
+
if (!queryInterface) return;
|
|
228
|
+
|
|
229
|
+
const tablePrefix = app.db.options?.tablePrefix || '';
|
|
230
|
+
|
|
231
|
+
const repoTable = `${tablePrefix}gitRepositories`;
|
|
232
|
+
const repoInfo = await queryInterface.describeTable(repoTable).catch(() => null);
|
|
233
|
+
if (repoInfo && !repoInfo.autoReviewFlowId) {
|
|
234
|
+
await queryInterface.addColumn(repoTable, 'autoReviewFlowId', {
|
|
235
|
+
type: DataTypes.INTEGER,
|
|
236
|
+
allowNull: true,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const reviewTable = `${tablePrefix}gitCodeReviews`;
|
|
241
|
+
const reviewInfo = await queryInterface.describeTable(reviewTable).catch(() => null);
|
|
242
|
+
if (reviewInfo && !reviewInfo.folderPath) {
|
|
243
|
+
await queryInterface.addColumn(reviewTable, 'folderPath', {
|
|
244
|
+
type: DataTypes.STRING,
|
|
245
|
+
allowNull: true,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export default PluginGitManagerServer;
|