plugin-git-manager 1.2.27 → 1.3.1
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/README.md +151 -108
- package/client-v2.d.ts +2 -2
- package/client-v2.js +1 -1
- package/client.d.ts +3 -3
- package/client.js +1 -1
- package/dist/client/{326.90c276058682b536.js → 313.d38fc1d40c4589b9.js} +1 -1
- package/dist/client/941.1793e67472872992.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/156.445366026c1cc9a8.js +10 -0
- package/dist/client-v2/{326.42b7b53651ffab3a.js → 313.3c867179c3a1e817.js} +1 -1
- package/dist/client-v2/434.19c7579c06b9077c.js +10 -0
- package/dist/client-v2/928.bba701b5a1ece58e.js +10 -0
- package/dist/client-v2/941.b0d55429cd053f32.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +9 -8
- package/dist/locale/en-US.json +396 -297
- package/dist/locale/vi-VN.json +384 -292
- package/dist/locale/zh-CN.json +150 -51
- package/dist/node_modules/simple-git/dist/cjs/index.js +25 -25
- package/dist/node_modules/simple-git/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/actions/git-actions.js +90 -36
- package/dist/server/actions/gitlab-api.js +4 -2
- package/dist/server/actions/poller.js +5 -2
- package/dist/server/actions/review-cutover.js +137 -0
- package/dist/server/actions/review.js +150 -51
- package/dist/server/actions/role-permissions.js +1 -0
- package/dist/server/ai-tools.js +8 -9
- package/dist/server/collections/gitCodeReviews.js +10 -0
- package/dist/server/collections/gitReviewCutover.js +44 -0
- package/dist/server/collections/gitReviewFlows.js +3 -0
- package/dist/server/collections/gitReviewInbox.js +51 -0
- package/dist/server/collections/gitReviewProjects.js +43 -0
- package/dist/server/collections/gitReviewRequests.js +56 -0
- package/dist/server/index.js +8 -2
- package/dist/server/plugin.js +57 -20
- package/dist/server/poller.js +95 -74
- package/dist/server/repository-access.js +23 -5
- package/dist/server/request-method-policy.js +76 -0
- package/dist/server/review-control-access.js +79 -0
- package/dist/server/services/legacy-post-service.js +412 -0
- package/dist/server/services/registry-content-service.js +4 -3
- package/dist/server/services/review-service.js +1451 -0
- package/dist/server/services/review-source.js +325 -0
- package/dist/server/utils/get-repo-account.js +3 -2
- package/dist/server/utils/url-security.js +24 -0
- package/package.json +61 -43
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/src/client/__tests__/CommitHistory.test.tsx +79 -0
- package/src/client/__tests__/ReviewHistory.test.tsx +126 -0
- package/src/client/__tests__/RunReviewButton.test.tsx +84 -0
- package/src/client/__tests__/workflowRoutes.test.ts +65 -0
- package/src/client/ai-context.tsx +114 -114
- package/src/client/components/AIEmployeeSelect.tsx +63 -63
- package/src/client/components/CommitHistory.tsx +429 -374
- package/src/client/components/FileExplorer.tsx +386 -386
- package/src/client/components/GitAccounts.tsx +179 -179
- package/src/client/components/GitManagerSettings.tsx +160 -160
- package/src/client/components/GitOperations.tsx +220 -220
- package/src/client/components/LLMModelSelect.tsx +63 -63
- package/src/client/components/LLMServiceSelect.tsx +58 -58
- package/src/client/components/MarkdownView.tsx +80 -80
- package/src/client/components/MergeRequests.tsx +790 -790
- package/src/client/components/PollingStatus.tsx +225 -225
- package/src/client/components/RepositoryConfig.tsx +335 -335
- package/src/client/components/RepositoryPermissions.tsx +123 -123
- package/src/client/components/ReviewFlows.tsx +352 -303
- package/src/client/components/ReviewHistory.tsx +796 -566
- package/src/client/components/RunReviewButton.tsx +57 -173
- package/src/client/context/GitManagerContext.tsx +92 -92
- package/src/client/index.tsx +91 -82
- package/src/client/locale.ts +9 -9
- package/src/client/promptTemplates.ts +31 -31
- package/src/client/workflowRoutes.ts +42 -0
- package/src/client-v2/ai-context.tsx +99 -0
- package/src/client-v2/components/SubtreeSplits.tsx +547 -547
- package/src/client-v2/index.tsx +1 -1
- package/src/client-v2/locale.ts +8 -8
- package/src/client-v2/plugin.tsx +67 -39
- package/src/index.ts +2 -2
- package/src/locale/en-US.json +396 -297
- package/src/locale/vi-VN.json +384 -292
- package/src/locale/zh-CN.json +150 -51
- package/src/server/__tests__/git-actions.test.ts +24 -24
- package/src/server/__tests__/git-security.test.ts +170 -0
- package/src/server/__tests__/plugin-url-security.test.ts +17 -17
- package/src/server/__tests__/poller-lifecycle.test.ts +71 -0
- package/src/server/__tests__/poller.test.ts +37 -37
- package/src/server/__tests__/repository-access.test.ts +760 -752
- package/src/server/__tests__/review-service.integration.test.ts +1263 -0
- package/src/server/__tests__/review.test.ts +76 -137
- package/src/server/__tests__/role-permissions.test.ts +147 -147
- package/src/server/__tests__/smoke.test.ts +139 -17
- package/src/server/__tests__/subtree.test.ts +85 -85
- package/src/server/actions/git-actions.ts +540 -480
- package/src/server/actions/gitlab-api.ts +422 -411
- package/src/server/actions/poller.ts +39 -27
- package/src/server/actions/review-cutover.ts +121 -0
- package/src/server/actions/review.ts +1498 -1369
- package/src/server/actions/role-permissions.ts +331 -321
- package/src/server/actions/subtree.ts +508 -508
- package/src/server/ai-tools.ts +334 -319
- package/src/server/collections/gitAccounts.ts +56 -56
- package/src/server/collections/gitCodeReviews.ts +218 -199
- package/src/server/collections/gitRepositories.ts +87 -87
- package/src/server/collections/gitReviewCutover.ts +23 -0
- package/src/server/collections/gitReviewFlows.ts +120 -108
- package/src/server/collections/gitReviewInbox.ts +30 -0
- package/src/server/collections/gitReviewProjects.ts +22 -0
- package/src/server/collections/gitReviewRequests.ts +35 -0
- package/src/server/collections/gitSubtreeConfigs.ts +38 -38
- package/src/server/collections/gitSubtreeRuns.ts +30 -30
- package/src/server/index.ts +14 -2
- package/src/server/migrations/20260508000000-add-auto-review-flow-id.ts +29 -29
- package/src/server/migrations/20260712000000-add-git-accounts.ts +198 -198
- package/src/server/migrations/20260730000000-migrate-legacy-repository-permissions.ts +81 -81
- package/src/server/plugin.ts +409 -361
- package/src/server/poller.ts +365 -352
- package/src/server/repository-access.ts +803 -773
- package/src/server/request-method-policy.ts +56 -0
- package/src/server/review-control-access.ts +71 -0
- package/src/server/services/__tests__/registry-content-service.test.ts +359 -345
- package/src/server/services/__tests__/review-source.test.ts +226 -0
- package/src/server/services/legacy-post-service.ts +550 -0
- package/src/server/services/registry-content-service.ts +495 -484
- package/src/server/services/review-service.ts +1899 -0
- package/src/server/services/review-source.ts +359 -0
- package/src/server/utils/__tests__/redact.test.ts +56 -56
- package/src/server/utils/__tests__/url-security.test.ts +85 -85
- package/src/server/utils/get-repo-account.ts +51 -41
- package/src/server/utils/gitlab-url.ts +38 -38
- package/src/server/utils/redact.ts +87 -87
- package/src/server/utils/url-security.ts +128 -95
- package/dist/client/900.acf7d1fa22f95e71.js +0 -10
- package/dist/client-v2/434.7a27051db18526c0.js +0 -10
- package/dist/client-v2/900.f32b9dc85249fc0a.js +0 -10
package/src/client/locale.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useApp } from '@nocobase/client-v2';
|
|
2
|
-
|
|
3
|
-
export const namespace = 'plugin-git-manager';
|
|
4
|
-
|
|
5
|
-
export function useT() {
|
|
6
|
-
const app = useApp();
|
|
7
|
-
return (str: string, options?: any): string =>
|
|
8
|
-
app.i18n.t(str, { ns: [namespace, 'client'], ...options }) as unknown as string;
|
|
9
|
-
}
|
|
1
|
+
import { useApp } from '@nocobase/client-v2';
|
|
2
|
+
|
|
3
|
+
export const namespace = 'plugin-git-manager';
|
|
4
|
+
|
|
5
|
+
export function useT() {
|
|
6
|
+
const app = useApp();
|
|
7
|
+
return (str: string, options?: any): string =>
|
|
8
|
+
app.i18n.t(str, { ns: [namespace, 'client'], ...options }) as unknown as string;
|
|
9
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export interface ReviewPromptTemplate {
|
|
2
|
-
key: 'application' | 'workflow-config';
|
|
3
|
-
label: string;
|
|
4
|
-
text: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const REVIEW_PROMPT_TEMPLATES: ReviewPromptTemplate[] = [
|
|
8
|
-
{
|
|
9
|
-
key: 'application',
|
|
10
|
-
label: 'Application code (C#, .NET, Java, JS/TS…)',
|
|
11
|
-
text: `Please review the code changes with a focus on:
|
|
12
|
-
1. Best Practices & Style:
|
|
13
|
-
- C#/VB.NET: Follow standard naming conventions (PascalCase for methods/properties, camelCase for fields). Ensure proper use of async/await (avoid .Result/.Wait()). Use LINQ efficiently.
|
|
14
|
-
- Java: Follow standard naming conventions. Check null-safety (Optional, null checks). Prefer try-with-resources for closeable resources and use streams/collections idiomatically.
|
|
15
|
-
- JS/TS: Use strict equality (===), prefer const/let. Ensure TypeScript types are explicit and avoid 'any'.
|
|
16
|
-
2. Performance: Watch out for N+1 queries, unnecessary loops, and memory leaks.
|
|
17
|
-
3. Security: Identify potential SQL injections, XSS vulnerabilities, and improper data validation.
|
|
18
|
-
4. Maintainability: Check for readability, SOLID principles, and DRY. Ensure meaningful naming.
|
|
19
|
-
5. Error Handling: Verify that exceptions are properly caught, handled, and logged.`,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
key: 'workflow-config',
|
|
23
|
-
label: 'Workflow / Config (XML, XAML, YAML, JSON…)',
|
|
24
|
-
text: `Please review the workflow/configuration files (XML, XAML, YAML, JSON, ...) with a focus on:
|
|
25
|
-
1. Structure & Validity: Well-formed syntax, correct schema/namespace usage, no duplicate or conflicting keys, consistent indentation and encoding.
|
|
26
|
-
2. Workflow Logic: Unreachable or dead steps, missing error handling / retry / timeout settings, incorrect transitions or dependencies between steps, infinite loops.
|
|
27
|
-
3. Security: Hardcoded credentials, secrets, tokens or connection strings; insecure endpoints (http instead of https); overly broad permissions.
|
|
28
|
-
4. Environment & Portability: Hardcoded environment-specific values (paths, hosts, ports) that should be parameterized; missing default values.
|
|
29
|
-
5. Maintainability: Meaningful naming for steps/variables, duplicated blocks that should be shared, obsolete or unused entries.`,
|
|
30
|
-
},
|
|
31
|
-
];
|
|
1
|
+
export interface ReviewPromptTemplate {
|
|
2
|
+
key: 'application' | 'workflow-config';
|
|
3
|
+
label: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const REVIEW_PROMPT_TEMPLATES: ReviewPromptTemplate[] = [
|
|
8
|
+
{
|
|
9
|
+
key: 'application',
|
|
10
|
+
label: 'Application code (C#, .NET, Java, JS/TS…)',
|
|
11
|
+
text: `Please review the code changes with a focus on:
|
|
12
|
+
1. Best Practices & Style:
|
|
13
|
+
- C#/VB.NET: Follow standard naming conventions (PascalCase for methods/properties, camelCase for fields). Ensure proper use of async/await (avoid .Result/.Wait()). Use LINQ efficiently.
|
|
14
|
+
- Java: Follow standard naming conventions. Check null-safety (Optional, null checks). Prefer try-with-resources for closeable resources and use streams/collections idiomatically.
|
|
15
|
+
- JS/TS: Use strict equality (===), prefer const/let. Ensure TypeScript types are explicit and avoid 'any'.
|
|
16
|
+
2. Performance: Watch out for N+1 queries, unnecessary loops, and memory leaks.
|
|
17
|
+
3. Security: Identify potential SQL injections, XSS vulnerabilities, and improper data validation.
|
|
18
|
+
4. Maintainability: Check for readability, SOLID principles, and DRY. Ensure meaningful naming.
|
|
19
|
+
5. Error Handling: Verify that exceptions are properly caught, handled, and logged.`,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: 'workflow-config',
|
|
23
|
+
label: 'Workflow / Config (XML, XAML, YAML, JSON…)',
|
|
24
|
+
text: `Please review the workflow/configuration files (XML, XAML, YAML, JSON, ...) with a focus on:
|
|
25
|
+
1. Structure & Validity: Well-formed syntax, correct schema/namespace usage, no duplicate or conflicting keys, consistent indentation and encoding.
|
|
26
|
+
2. Workflow Logic: Unreachable or dead steps, missing error handling / retry / timeout settings, incorrect transitions or dependencies between steps, infinite loops.
|
|
27
|
+
3. Security: Hardcoded credentials, secrets, tokens or connection strings; insecure endpoints (http instead of https); overly broad permissions.
|
|
28
|
+
4. Environment & Portability: Hardcoded environment-specific values (paths, hosts, ports) that should be parameterized; missing default values.
|
|
29
|
+
5. Maintainability: Meaningful naming for steps/variables, duplicated blocks that should be shared, obsolete or unused entries.`,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
getModernClientPrefix,
|
|
12
|
+
getRouteRuntimeVersion,
|
|
13
|
+
getV2EffectiveBasePath,
|
|
14
|
+
stripModernClientPrefix,
|
|
15
|
+
} from '@nocobase/client-v2';
|
|
16
|
+
|
|
17
|
+
type App = Parameters<typeof getV2EffectiveBasePath>[0];
|
|
18
|
+
|
|
19
|
+
function join(base: string, path: string) {
|
|
20
|
+
return `${base.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function legacyBase(app: App) {
|
|
24
|
+
const configured = typeof window === 'undefined' ? undefined : window.__nocobase_public_path__;
|
|
25
|
+
return stripModernClientPrefix(configured || app.getPublicPath());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function workflowHref(app: App, type: 'workflow' | 'execution', id: string | number) {
|
|
29
|
+
const modern = getRouteRuntimeVersion() === 'modern';
|
|
30
|
+
const path = modern
|
|
31
|
+
? `/admin/workflow/${type === 'workflow' ? 'workflows' : 'executions'}/${encodeURIComponent(String(id))}`
|
|
32
|
+
: `/admin/settings/workflow/${type === 'workflow' ? 'workflows' : 'executions'}/${encodeURIComponent(String(id))}`;
|
|
33
|
+
return join(modern ? getV2EffectiveBasePath(app) : legacyBase(app), path);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function reviewApprovalHref(app: App) {
|
|
37
|
+
const base =
|
|
38
|
+
getRouteRuntimeVersion() === 'modern'
|
|
39
|
+
? getV2EffectiveBasePath(app)
|
|
40
|
+
: join(legacyBase(app), getModernClientPrefix());
|
|
41
|
+
return join(base, '/admin/workflow/tasks/git-review-approval/pending');
|
|
42
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { BranchesOutlined, MergeOutlined, NodeIndexOutlined } from '@ant-design/icons';
|
|
2
|
+
import type { AIManager, ContextItem } from '@nocobase/plugin-ai/client-v2';
|
|
3
|
+
import { Space } from 'antd';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
type WorkContextOptions = Parameters<AIManager['registerWorkContext']>[1];
|
|
8
|
+
|
|
9
|
+
function ContextLabel({ kind, title }: { kind: 'repository' | 'merge-request' | 'commit'; title?: string }) {
|
|
10
|
+
const { t } = useTranslation('plugin-git-manager');
|
|
11
|
+
const labels = { repository: 'Git Repository', 'merge-request': 'Git Merge Request', commit: 'Git Commit' };
|
|
12
|
+
const icons = { repository: <BranchesOutlined />, 'merge-request': <MergeOutlined />, commit: <NodeIndexOutlined /> };
|
|
13
|
+
return (
|
|
14
|
+
<Space size={4}>
|
|
15
|
+
{icons[kind]}
|
|
16
|
+
<span>{title || t(labels[kind])}</span>
|
|
17
|
+
</Space>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function recordFromResponse(response: unknown): Record<string, unknown> | null {
|
|
22
|
+
const data = (response as { data?: { data?: unknown } })?.data?.data;
|
|
23
|
+
return data && typeof data === 'object' ? (data as Record<string, unknown>) : null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function contextComponents(kind: 'repository' | 'merge-request' | 'commit') {
|
|
27
|
+
return {
|
|
28
|
+
menu: { Component: () => <ContextLabel kind={kind} /> },
|
|
29
|
+
tag: {
|
|
30
|
+
Component: ({ item }: { item: ContextItem }) => <ContextLabel kind={kind} title={item.title || item.uid} />,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const GitRepositoryWorkContext: WorkContextOptions = {
|
|
36
|
+
name: 'git-repository',
|
|
37
|
+
...contextComponents('repository'),
|
|
38
|
+
getContent: async (app, { uid }) => {
|
|
39
|
+
const repo = recordFromResponse(
|
|
40
|
+
await app.apiClient.request({ url: 'gitRepositories:get', params: { filterByTk: uid } }),
|
|
41
|
+
);
|
|
42
|
+
if (!repo) return null;
|
|
43
|
+
return {
|
|
44
|
+
type: 'git-repository',
|
|
45
|
+
repositoryId: repo.id,
|
|
46
|
+
name: repo.name,
|
|
47
|
+
repoUrl: repo.repoUrl,
|
|
48
|
+
defaultBranch: repo.defaultBranch,
|
|
49
|
+
status: repo.status,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const GitMergeRequestWorkContext: WorkContextOptions = {
|
|
55
|
+
name: 'git-merge-request',
|
|
56
|
+
...contextComponents('merge-request'),
|
|
57
|
+
getContent: async (app, { uid }) => {
|
|
58
|
+
const [repositoryId, iid] = uid.split(':');
|
|
59
|
+
const mrIid = Number(iid);
|
|
60
|
+
if (!repositoryId || !Number.isSafeInteger(mrIid) || mrIid <= 0) return null;
|
|
61
|
+
const data = recordFromResponse(
|
|
62
|
+
await app.apiClient.request({
|
|
63
|
+
url: 'gitManager:mergeRequestDetail',
|
|
64
|
+
params: { repositoryId, mrIid },
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
if (!data) return null;
|
|
68
|
+
return {
|
|
69
|
+
type: 'git-merge-request',
|
|
70
|
+
repositoryId,
|
|
71
|
+
mrIid,
|
|
72
|
+
title: data.title,
|
|
73
|
+
sourceBranch: data.sourceBranch,
|
|
74
|
+
targetBranch: data.targetBranch,
|
|
75
|
+
author: data.author,
|
|
76
|
+
changes: data.changes,
|
|
77
|
+
description: data.description,
|
|
78
|
+
webUrl: data.webUrl,
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const GitCommitWorkContext: WorkContextOptions = {
|
|
84
|
+
name: 'git-commit',
|
|
85
|
+
...contextComponents('commit'),
|
|
86
|
+
getContent: async (app, { uid }) => {
|
|
87
|
+
const separator = uid.indexOf(':');
|
|
88
|
+
const repositoryId = uid.slice(0, separator),
|
|
89
|
+
commitSha = uid.slice(separator + 1);
|
|
90
|
+
if (separator <= 0 || !commitSha) return null;
|
|
91
|
+
const data = recordFromResponse(
|
|
92
|
+
await app.apiClient.request({
|
|
93
|
+
url: 'gitManager:commitDetail',
|
|
94
|
+
params: { repositoryId, commitHash: commitSha },
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
return data ? { ...data, type: 'git-commit', repositoryId, commitSha } : null;
|
|
98
|
+
},
|
|
99
|
+
};
|