devops-mcp-server-extension 1.0.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/LICENSE +218 -0
- package/README.md +527 -0
- package/README.zh-cn.md +503 -0
- package/dist/common/errors.js +77 -0
- package/dist/common/modularTemplates.js +483 -0
- package/dist/common/pipelineTemplates.js +19 -0
- package/dist/common/toolsetManager.js +123 -0
- package/dist/common/toolsets.js +23 -0
- package/dist/common/types.js +60 -0
- package/dist/common/utils.js +381 -0
- package/dist/common/version.js +1 -0
- package/dist/index.js +225 -0
- package/dist/operations/appstack/appOrchestrations.js +260 -0
- package/dist/operations/appstack/appTags.js +168 -0
- package/dist/operations/appstack/appTemplates.js +72 -0
- package/dist/operations/appstack/applications.js +171 -0
- package/dist/operations/appstack/changeOrders.js +320 -0
- package/dist/operations/appstack/changeRequests.js +288 -0
- package/dist/operations/appstack/deploymentResources.js +286 -0
- package/dist/operations/appstack/globalVars.js +221 -0
- package/dist/operations/appstack/releaseWorkflows.js +695 -0
- package/dist/operations/appstack/variableGroups.js +245 -0
- package/dist/operations/codeup/branches.js +157 -0
- package/dist/operations/codeup/changeRequestComments.js +140 -0
- package/dist/operations/codeup/changeRequests.js +230 -0
- package/dist/operations/codeup/commits.js +121 -0
- package/dist/operations/codeup/compare.js +30 -0
- package/dist/operations/codeup/files.js +249 -0
- package/dist/operations/codeup/repositories.js +71 -0
- package/dist/operations/codeup/types.js +414 -0
- package/dist/operations/flow/hostGroup.js +52 -0
- package/dist/operations/flow/pipeline.js +609 -0
- package/dist/operations/flow/pipelineJob.js +126 -0
- package/dist/operations/flow/resourceMember.js +137 -0
- package/dist/operations/flow/serviceConnection.js +27 -0
- package/dist/operations/flow/tag.js +191 -0
- package/dist/operations/flow/types.js +523 -0
- package/dist/operations/flow/vmDeployOrder.js +171 -0
- package/dist/operations/organization/members.js +106 -0
- package/dist/operations/organization/organization.js +110 -0
- package/dist/operations/organization/types.js +111 -0
- package/dist/operations/packages/artifacts.js +71 -0
- package/dist/operations/packages/repositories.js +39 -0
- package/dist/operations/packages/types.js +56 -0
- package/dist/operations/projex/effort.js +122 -0
- package/dist/operations/projex/project.js +243 -0
- package/dist/operations/projex/sprint.js +103 -0
- package/dist/operations/projex/types.js +618 -0
- package/dist/operations/projex/workitem.js +826 -0
- package/dist/operations/testhub/testcases.js +240 -0
- package/dist/operations/testhub/testplans.js +128 -0
- package/dist/tool-handlers/appstack-app-release-workflows.js +103 -0
- package/dist/tool-handlers/appstack-change-orders.js +55 -0
- package/dist/tool-handlers/appstack-change-requests.js +49 -0
- package/dist/tool-handlers/appstack-deployment-resources.js +31 -0
- package/dist/tool-handlers/appstack-global-vars.js +37 -0
- package/dist/tool-handlers/appstack-orchestrations.js +49 -0
- package/dist/tool-handlers/appstack-release-workflows.js +37 -0
- package/dist/tool-handlers/appstack-tags.js +37 -0
- package/dist/tool-handlers/appstack-templates.js +19 -0
- package/dist/tool-handlers/appstack-variable-groups.js +55 -0
- package/dist/tool-handlers/appstack.js +37 -0
- package/dist/tool-handlers/base.js +25 -0
- package/dist/tool-handlers/code-management.js +150 -0
- package/dist/tool-handlers/commit.js +31 -0
- package/dist/tool-handlers/effort.js +103 -0
- package/dist/tool-handlers/index.js +119 -0
- package/dist/tool-handlers/organization.js +72 -0
- package/dist/tool-handlers/packages.js +32 -0
- package/dist/tool-handlers/pipeline.js +289 -0
- package/dist/tool-handlers/project-management.js +201 -0
- package/dist/tool-handlers/resourceMember.js +43 -0
- package/dist/tool-handlers/service-connections.js +16 -0
- package/dist/tool-handlers/tag.js +64 -0
- package/dist/tool-handlers/test-management.js +74 -0
- package/dist/tool-handlers/vmDeployOrder.js +50 -0
- package/dist/tool-registry/appstack-app-release-workflows.js +80 -0
- package/dist/tool-registry/appstack-change-orders.js +40 -0
- package/dist/tool-registry/appstack-change-requests.js +35 -0
- package/dist/tool-registry/appstack-deployment-resources.js +20 -0
- package/dist/tool-registry/appstack-global-vars.js +25 -0
- package/dist/tool-registry/appstack-orchestrations.js +35 -0
- package/dist/tool-registry/appstack-release-workflows.js +25 -0
- package/dist/tool-registry/appstack-tags.js +25 -0
- package/dist/tool-registry/appstack-templates.js +10 -0
- package/dist/tool-registry/appstack-variable-groups.js +40 -0
- package/dist/tool-registry/appstack.js +25 -0
- package/dist/tool-registry/base.js +19 -0
- package/dist/tool-registry/code-management.js +109 -0
- package/dist/tool-registry/commit.js +20 -0
- package/dist/tool-registry/effort.js +39 -0
- package/dist/tool-registry/index.js +7 -0
- package/dist/tool-registry/organization.js +65 -0
- package/dist/tool-registry/packages.js +21 -0
- package/dist/tool-registry/pipeline.js +190 -0
- package/dist/tool-registry/project-management.js +143 -0
- package/dist/tool-registry/resourceMember.js +29 -0
- package/dist/tool-registry/service-connections.js +10 -0
- package/dist/tool-registry/tag.js +44 -0
- package/dist/tool-registry/test-management.js +59 -0
- package/dist/tool-registry/vmDeployOrder.js +34 -0
- package/package.json +52 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模块化流水线模板定义
|
|
3
|
+
* 基于云效Flow官方文档,将Sources、构建步骤、部署组件分离
|
|
4
|
+
*/
|
|
5
|
+
// Codeup 源码模板
|
|
6
|
+
export const CODEUP_SOURCE_TEMPLATE = {
|
|
7
|
+
type: 'codeup',
|
|
8
|
+
name: 'Codeup 代码源',
|
|
9
|
+
description: '阿里云 Codeup 代码仓库',
|
|
10
|
+
keywords: ['codeup', 'aliyun', '阿里云'],
|
|
11
|
+
template: `sources:
|
|
12
|
+
main_repo:
|
|
13
|
+
type: codeup
|
|
14
|
+
name: {{serviceName || '项目'}}
|
|
15
|
+
endpoint: {{repoUrl || 'https://codeup.aliyun.com/your-org/your-repo.git'}}
|
|
16
|
+
branch: {{branch || 'main'}}
|
|
17
|
+
triggerEvents: push
|
|
18
|
+
certificate:
|
|
19
|
+
type: serviceConnection
|
|
20
|
+
serviceConnection: {{serviceConnectionId || 'your-service-connection-id'}}`,
|
|
21
|
+
defaultVariables: {
|
|
22
|
+
branch: 'main'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
// GitHub 源码模板
|
|
26
|
+
export const GITHUB_SOURCE_TEMPLATE = {
|
|
27
|
+
type: 'github',
|
|
28
|
+
name: 'GitHub 代码源',
|
|
29
|
+
description: 'GitHub 代码仓库',
|
|
30
|
+
keywords: ['github'],
|
|
31
|
+
template: `sources:
|
|
32
|
+
main_repo:
|
|
33
|
+
type: github
|
|
34
|
+
name: {{serviceName || '项目'}}
|
|
35
|
+
endpoint: {{repoUrl || 'https://github.com/your-org/your-repo.git'}}
|
|
36
|
+
branch: {{branch || 'main'}}
|
|
37
|
+
triggerEvents: push
|
|
38
|
+
certificate:
|
|
39
|
+
type: serviceConnection
|
|
40
|
+
serviceConnection: {{serviceConnectionId || 'your-service-connection-id'}}`,
|
|
41
|
+
defaultVariables: {
|
|
42
|
+
branch: 'main'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// Java Maven 构建步骤
|
|
46
|
+
export const JAVA_MAVEN_BUILD_TEMPLATE = {
|
|
47
|
+
type: 'java_maven',
|
|
48
|
+
name: 'Java Maven 构建',
|
|
49
|
+
description: 'Java项目使用Maven进行构建',
|
|
50
|
+
keywords: ['java', 'maven', 'mvn'],
|
|
51
|
+
languages: ['java'],
|
|
52
|
+
buildTools: ['maven'],
|
|
53
|
+
template: ` build_job:
|
|
54
|
+
name: Maven构建
|
|
55
|
+
runsOn:
|
|
56
|
+
group: public/cn-beijing
|
|
57
|
+
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest
|
|
58
|
+
steps:
|
|
59
|
+
setup_maven_settings_step:
|
|
60
|
+
name: "下载MavenSettings"
|
|
61
|
+
step: SetupMavenSettings
|
|
62
|
+
with:
|
|
63
|
+
mavenSettingXmlPath: "/root/.m2/settings.xml"
|
|
64
|
+
setup_java_step:
|
|
65
|
+
name: "安装Java环境"
|
|
66
|
+
step: SetupJava
|
|
67
|
+
with:
|
|
68
|
+
jdkVersion: {{jdkVersion || "1.8"}}
|
|
69
|
+
mavenVersion: {{mavenVersion || "3.5.2"}}
|
|
70
|
+
command_step:
|
|
71
|
+
name: "执行命令"
|
|
72
|
+
step: Command
|
|
73
|
+
with:
|
|
74
|
+
run: |
|
|
75
|
+
{{buildCommand || 'mvn clean package -Dmaven.test.skip=true'}}`,
|
|
76
|
+
defaultVariables: {
|
|
77
|
+
jdkVersion: '"1.8"',
|
|
78
|
+
mavenVersion: '"3.5.2"',
|
|
79
|
+
buildCommand: 'mvn clean package -Dmaven.test.skip=true',
|
|
80
|
+
testCommand: 'mvn test',
|
|
81
|
+
artifactPath: 'target/'
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// Node.js NPM 构建步骤
|
|
85
|
+
export const NODEJS_NPM_BUILD_TEMPLATE = {
|
|
86
|
+
type: 'nodejs_npm',
|
|
87
|
+
name: 'Node.js NPM 构建',
|
|
88
|
+
description: 'Node.js项目使用NPM进行构建',
|
|
89
|
+
keywords: ['nodejs', 'node.js', 'npm', 'javascript'],
|
|
90
|
+
languages: ['nodejs', 'javascript', 'js'],
|
|
91
|
+
buildTools: ['npm'],
|
|
92
|
+
template: ` build_job:
|
|
93
|
+
name: Node.js构建
|
|
94
|
+
runsOn:
|
|
95
|
+
group: public/cn-beijing
|
|
96
|
+
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest
|
|
97
|
+
steps:
|
|
98
|
+
setup_npmrc_step:
|
|
99
|
+
name: "下载npmrc"
|
|
100
|
+
step: SetupNpmrc
|
|
101
|
+
with:
|
|
102
|
+
npmPrivateRepoConfigPath: "/root/.npmrc"
|
|
103
|
+
setup_node_step:
|
|
104
|
+
name: "安装Node"
|
|
105
|
+
step: SetupNode
|
|
106
|
+
with:
|
|
107
|
+
versionType: "predefined" # 支持填写 predefined、custom、nvmrc
|
|
108
|
+
nodeVersion: {{nodeVersion || "18.12"}}
|
|
109
|
+
npmType: "npm"
|
|
110
|
+
command_step:
|
|
111
|
+
name: "执行命令"
|
|
112
|
+
step: Command
|
|
113
|
+
with:
|
|
114
|
+
run: |
|
|
115
|
+
{{buildCommand || 'npm install && npm run build'}}`,
|
|
116
|
+
defaultVariables: {
|
|
117
|
+
nodeVersion: '"18.12"',
|
|
118
|
+
buildCommand: 'npm install && npm run build',
|
|
119
|
+
testCommand: 'npm test',
|
|
120
|
+
artifactPath: 'dist/'
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
// Python 构建步骤
|
|
124
|
+
export const PYTHON_BUILD_TEMPLATE = {
|
|
125
|
+
type: 'python',
|
|
126
|
+
name: 'Python 构建',
|
|
127
|
+
description: 'Python项目构建',
|
|
128
|
+
keywords: ['python', 'pip'],
|
|
129
|
+
languages: ['python'],
|
|
130
|
+
buildTools: ['pip', 'poetry'],
|
|
131
|
+
template: ` build_job:
|
|
132
|
+
name: Python构建
|
|
133
|
+
runsOn:
|
|
134
|
+
group: public/cn-beijing
|
|
135
|
+
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest
|
|
136
|
+
steps:
|
|
137
|
+
setup_python_step:
|
|
138
|
+
name: "安装Python"
|
|
139
|
+
step: SetupPython
|
|
140
|
+
with:
|
|
141
|
+
pythonVersion: {{pythonVersion || "3.7"}}
|
|
142
|
+
command_step:
|
|
143
|
+
name: "执行命令"
|
|
144
|
+
step: Command
|
|
145
|
+
with:
|
|
146
|
+
run: |
|
|
147
|
+
{{buildCommand || 'python --version'}}`,
|
|
148
|
+
defaultVariables: {
|
|
149
|
+
pythonVersion: '"3.7"',
|
|
150
|
+
buildCommand: 'python --version',
|
|
151
|
+
testCommand: 'python -m pytest',
|
|
152
|
+
artifactPath: '.'
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
// Go 构建步骤
|
|
156
|
+
export const GO_BUILD_TEMPLATE = {
|
|
157
|
+
type: 'go',
|
|
158
|
+
name: 'Go 构建',
|
|
159
|
+
description: 'Go项目构建',
|
|
160
|
+
keywords: ['go', 'golang'],
|
|
161
|
+
languages: ['go', 'golang'],
|
|
162
|
+
buildTools: ['go'],
|
|
163
|
+
template: ` build_job:
|
|
164
|
+
name: Go构建
|
|
165
|
+
runsOn:
|
|
166
|
+
group: public/cn-beijing
|
|
167
|
+
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest
|
|
168
|
+
steps:
|
|
169
|
+
golang_build_step:
|
|
170
|
+
name: "安装 Golang"
|
|
171
|
+
step: SetupGo
|
|
172
|
+
with:
|
|
173
|
+
goVersion: {{goVersion || "1.21"}}
|
|
174
|
+
command_step:
|
|
175
|
+
name: "执行命令"
|
|
176
|
+
step: Command
|
|
177
|
+
with:
|
|
178
|
+
run: |
|
|
179
|
+
{{buildCommand || 'make build'}}`,
|
|
180
|
+
defaultVariables: {
|
|
181
|
+
goVersion: '"1.21"',
|
|
182
|
+
buildCommand: 'make build',
|
|
183
|
+
testCommand: 'go test ./...',
|
|
184
|
+
artifactPath: '.'
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
// .NET Core 构建步骤
|
|
188
|
+
export const DOTNET_BUILD_TEMPLATE = {
|
|
189
|
+
type: 'dotnet',
|
|
190
|
+
name: '.NET Core 构建',
|
|
191
|
+
description: '.NET Core项目构建',
|
|
192
|
+
keywords: ['dotnet', '.net', 'csharp'],
|
|
193
|
+
languages: ['csharp'],
|
|
194
|
+
buildTools: ['dotnet'],
|
|
195
|
+
template: ` build_job:
|
|
196
|
+
name: .NET Core构建
|
|
197
|
+
runsOn:
|
|
198
|
+
group: public/cn-beijing
|
|
199
|
+
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/dotnetcore:8.0
|
|
200
|
+
steps:
|
|
201
|
+
command_step:
|
|
202
|
+
name: "执行命令"
|
|
203
|
+
step: Command
|
|
204
|
+
with:
|
|
205
|
+
run: |
|
|
206
|
+
dotnet --info
|
|
207
|
+
{{buildCommand || 'dotnet restore && dotnet publish -c Release -o out'}}`,
|
|
208
|
+
defaultVariables: {
|
|
209
|
+
buildCommand: 'dotnet restore && dotnet publish -c Release -o out',
|
|
210
|
+
testCommand: 'dotnet test',
|
|
211
|
+
artifactPath: 'out/'
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
// Packages 制品库上传
|
|
215
|
+
export const PACKAGES_UPLOAD_TEMPLATE = {
|
|
216
|
+
type: 'packages',
|
|
217
|
+
name: 'Packages 制品库上传',
|
|
218
|
+
description: '上传到云效制品库',
|
|
219
|
+
template: ` upload_step:
|
|
220
|
+
step: ArtifactUpload
|
|
221
|
+
name: 构建物上传
|
|
222
|
+
with:
|
|
223
|
+
uploadType: packages
|
|
224
|
+
serviceConnection: {{packagesServiceConnection || 'your-packages-service-connection-id'}}
|
|
225
|
+
repo: {{packagesRepoId || 'flow_generic_repo'}}
|
|
226
|
+
artifact: {{artifactName || 'default'}}
|
|
227
|
+
version: {{artifactVersion || '1.0.0'}}
|
|
228
|
+
filePath:
|
|
229
|
+
- {{artifactPath || '.'}}
|
|
230
|
+
includePathInArtifact: {{includePathInArtifact || false}}`,
|
|
231
|
+
defaultVariables: {
|
|
232
|
+
uploadType: 'packages',
|
|
233
|
+
artifactName: 'default',
|
|
234
|
+
artifactVersion: '1.0.0',
|
|
235
|
+
includePathInArtifact: false
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
// Flow Public 上传
|
|
239
|
+
export const FLOW_PUBLIC_UPLOAD_TEMPLATE = {
|
|
240
|
+
type: 'flowPublic',
|
|
241
|
+
name: 'Flow Public 上传',
|
|
242
|
+
description: '上传到Flow公共存储',
|
|
243
|
+
template: ` upload_step:
|
|
244
|
+
step: ArtifactUpload
|
|
245
|
+
name: 构建物上传
|
|
246
|
+
with:
|
|
247
|
+
uploadType: flowPublic
|
|
248
|
+
artifact: {{artifactName || 'default'}}
|
|
249
|
+
filePath:
|
|
250
|
+
- {{artifactPath || '.'}}
|
|
251
|
+
includePathInArtifact: {{includePathInArtifact || false}}`,
|
|
252
|
+
defaultVariables: {
|
|
253
|
+
uploadType: 'flowPublic',
|
|
254
|
+
artifactName: 'default',
|
|
255
|
+
includePathInArtifact: false
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
// 主机部署组件
|
|
259
|
+
export const VM_DEPLOY_COMPONENT_TEMPLATE = {
|
|
260
|
+
type: 'vm_deploy',
|
|
261
|
+
name: '主机部署',
|
|
262
|
+
description: '部署到虚拟主机/ECS',
|
|
263
|
+
keywords: ['vm', 'host', '主机', 'ecs'],
|
|
264
|
+
deployTargets: ['vm', 'host', '主机'],
|
|
265
|
+
template: ` deploy_job:
|
|
266
|
+
name: 主机部署
|
|
267
|
+
component: VMDeploy
|
|
268
|
+
with:
|
|
269
|
+
artifact: $[stages.build_stage.build_job.upload_step.artifacts.{{artifactName || 'default'}}]
|
|
270
|
+
machineGroup: {{machineGroupId || 'your-machine-group-id'}}
|
|
271
|
+
artifactDownloadPath: {{artifactDownloadPath || '/home/admin/app/package.tgz'}}
|
|
272
|
+
executeUser: {{executeUser || 'root'}}
|
|
273
|
+
pauseStrategy: {{pauseStrategy || 'firstBatchPause'}}
|
|
274
|
+
batchNumber: {{batchNumber || 2}}
|
|
275
|
+
run: |
|
|
276
|
+
cd /home/admin/app
|
|
277
|
+
tar -xzf package.tgz
|
|
278
|
+
{{deployCommand || 'echo "请配置部署命令"'}}`,
|
|
279
|
+
defaultVariables: {
|
|
280
|
+
executeUser: 'root',
|
|
281
|
+
artifactDownloadPath: '/home/admin/app/package.tgz',
|
|
282
|
+
pauseStrategy: 'firstBatchPause',
|
|
283
|
+
batchNumber: 2
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
// Kubernetes 部署组件
|
|
287
|
+
export const KUBERNETES_DEPLOY_COMPONENT_TEMPLATE = {
|
|
288
|
+
type: 'kubernetes_deploy',
|
|
289
|
+
name: 'Kubernetes发布',
|
|
290
|
+
description: '部署到Kubernetes集群',
|
|
291
|
+
keywords: ['kubernetes', 'k8s', 'kubectl', 'deploy', 'apply'],
|
|
292
|
+
deployTargets: ['kubernetes', 'k8s'],
|
|
293
|
+
template: ` kubectl_apply_job:
|
|
294
|
+
name: Kubernetes发布
|
|
295
|
+
runsOn:
|
|
296
|
+
group: public/cn-beijing
|
|
297
|
+
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest
|
|
298
|
+
setps:
|
|
299
|
+
kubectl_apply:
|
|
300
|
+
step: KubectlApply
|
|
301
|
+
name: "Kubectl 发布"
|
|
302
|
+
with:
|
|
303
|
+
kubernetesCluster: {{kubernetesClusterId || 'your-kubernetesCluster-id'}}
|
|
304
|
+
kubectlVersion: {{kubectlVersion || "1.27.9"}}
|
|
305
|
+
namespace: {{namespace || default}}
|
|
306
|
+
yamlPath: {{yamlPath || app-configs/manifest-app}}
|
|
307
|
+
variables:
|
|
308
|
+
- key: image
|
|
309
|
+
value: $[stages.java_build_stage.java_build_job.acr_docker_build_step.artifacts.{{dockerImage || my_image}}]`,
|
|
310
|
+
defaultVariables: {
|
|
311
|
+
namespace: 'default',
|
|
312
|
+
kubectlVersion: "1.27.9",
|
|
313
|
+
yamlPath: 'app-configs/manifest-app'
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
// ===== 模板集合 =====
|
|
317
|
+
export const SOURCE_TEMPLATES = [
|
|
318
|
+
CODEUP_SOURCE_TEMPLATE,
|
|
319
|
+
GITHUB_SOURCE_TEMPLATE
|
|
320
|
+
];
|
|
321
|
+
export const BUILD_STEP_TEMPLATES = [
|
|
322
|
+
JAVA_MAVEN_BUILD_TEMPLATE,
|
|
323
|
+
NODEJS_NPM_BUILD_TEMPLATE,
|
|
324
|
+
PYTHON_BUILD_TEMPLATE,
|
|
325
|
+
GO_BUILD_TEMPLATE,
|
|
326
|
+
DOTNET_BUILD_TEMPLATE
|
|
327
|
+
];
|
|
328
|
+
export const ARTIFACT_UPLOAD_TEMPLATES = [
|
|
329
|
+
PACKAGES_UPLOAD_TEMPLATE,
|
|
330
|
+
FLOW_PUBLIC_UPLOAD_TEMPLATE
|
|
331
|
+
];
|
|
332
|
+
export const DEPLOY_COMPONENT_TEMPLATES = [
|
|
333
|
+
VM_DEPLOY_COMPONENT_TEMPLATE,
|
|
334
|
+
KUBERNETES_DEPLOY_COMPONENT_TEMPLATE
|
|
335
|
+
];
|
|
336
|
+
// ===== 模板匹配函数 =====
|
|
337
|
+
export function findMatchingSourceTemplate(keywords) {
|
|
338
|
+
const normalizedKeywords = keywords.map(k => k.toLowerCase());
|
|
339
|
+
const matched = SOURCE_TEMPLATES.find(template => template.keywords.some(keyword => normalizedKeywords.some(nk => nk.includes(keyword) || keyword.includes(nk))));
|
|
340
|
+
return matched || CODEUP_SOURCE_TEMPLATE; // 默认使用 Codeup
|
|
341
|
+
}
|
|
342
|
+
export function findMatchingBuildTemplate(keywords, languages, buildTools) {
|
|
343
|
+
const normalizedKeywords = keywords.map(k => k.toLowerCase());
|
|
344
|
+
const normalizedLanguages = languages.map(l => l.toLowerCase());
|
|
345
|
+
const normalizedBuildTools = buildTools.map(t => t.toLowerCase());
|
|
346
|
+
// 使用评分系统选择最佳匹配模板
|
|
347
|
+
let bestTemplate = null;
|
|
348
|
+
let bestScore = 0;
|
|
349
|
+
for (const template of BUILD_STEP_TEMPLATES) {
|
|
350
|
+
let score = 0;
|
|
351
|
+
// 语言匹配 (权重最高)
|
|
352
|
+
for (const lang of template.languages) {
|
|
353
|
+
if (normalizedLanguages.some(nl => nl.includes(lang) || lang.includes(nl))) {
|
|
354
|
+
score += 10;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
// 构建工具匹配 (权重中等)
|
|
358
|
+
for (const tool of template.buildTools) {
|
|
359
|
+
if (normalizedBuildTools.some(nt => nt.includes(tool) || tool.includes(nt))) {
|
|
360
|
+
score += 5;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// 关键词匹配 (权重较低)
|
|
364
|
+
for (const keyword of template.keywords) {
|
|
365
|
+
if (normalizedKeywords.some(nk => nk.includes(keyword) || keyword.includes(nk))) {
|
|
366
|
+
score += 2;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (score > bestScore) {
|
|
370
|
+
bestScore = score;
|
|
371
|
+
bestTemplate = template;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return bestTemplate;
|
|
375
|
+
}
|
|
376
|
+
export function findMatchingUploadTemplate(uploadType) {
|
|
377
|
+
return ARTIFACT_UPLOAD_TEMPLATES.find(template => template.type === uploadType)
|
|
378
|
+
|| PACKAGES_UPLOAD_TEMPLATE; // 默认使用 packages
|
|
379
|
+
}
|
|
380
|
+
export function findMatchingDeployTemplate(keywords, deployTargets) {
|
|
381
|
+
const normalizedKeywords = keywords.map(k => k.toLowerCase());
|
|
382
|
+
const normalizedTargets = deployTargets.map(t => t.toLowerCase());
|
|
383
|
+
return DEPLOY_COMPONENT_TEMPLATES.find(template => {
|
|
384
|
+
return template.keywords.some(keyword => normalizedKeywords.some(nk => nk.includes(keyword) || keyword.includes(nk))) ||
|
|
385
|
+
template.deployTargets.some(target => normalizedTargets.some(nt => nt.includes(target) || target.includes(nt)));
|
|
386
|
+
}) || null;
|
|
387
|
+
}
|
|
388
|
+
export function generateModularPipeline(options) {
|
|
389
|
+
const { sourceType, buildLanguages = [], buildTools = [], uploadType = 'packages', deployTargets = [], keywords = [], variables = {} } = options;
|
|
390
|
+
// 1. 选择源码模板
|
|
391
|
+
const sourceTemplate = findMatchingSourceTemplate(keywords);
|
|
392
|
+
// 2. 选择构建模板
|
|
393
|
+
const buildTemplate = findMatchingBuildTemplate(keywords, buildLanguages, buildTools);
|
|
394
|
+
// 3. 选择上传模板
|
|
395
|
+
const uploadTemplate = findMatchingUploadTemplate(uploadType);
|
|
396
|
+
// 4. 选择部署模板
|
|
397
|
+
const deployTemplate = deployTargets.length > 0
|
|
398
|
+
? findMatchingDeployTemplate(keywords, deployTargets)
|
|
399
|
+
: null;
|
|
400
|
+
// 5. 合并默认变量
|
|
401
|
+
const mergedVariables = {
|
|
402
|
+
...sourceTemplate.defaultVariables,
|
|
403
|
+
...buildTemplate?.defaultVariables,
|
|
404
|
+
...uploadTemplate.defaultVariables,
|
|
405
|
+
...deployTemplate?.defaultVariables,
|
|
406
|
+
...variables
|
|
407
|
+
};
|
|
408
|
+
// 6. 生成完整YAML
|
|
409
|
+
let pipeline = sourceTemplate.template;
|
|
410
|
+
if (buildTemplate) {
|
|
411
|
+
pipeline += `
|
|
412
|
+
|
|
413
|
+
stages:
|
|
414
|
+
build_stage:
|
|
415
|
+
name: 构建阶段
|
|
416
|
+
jobs:
|
|
417
|
+
${buildTemplate.template}
|
|
418
|
+
${uploadTemplate.template}`;
|
|
419
|
+
}
|
|
420
|
+
if (deployTemplate) {
|
|
421
|
+
pipeline += `
|
|
422
|
+
|
|
423
|
+
deploy_stage:
|
|
424
|
+
name: 部署阶段
|
|
425
|
+
jobs:
|
|
426
|
+
${deployTemplate.template}`;
|
|
427
|
+
}
|
|
428
|
+
// 7. 替换变量
|
|
429
|
+
return replaceTemplateVariables(pipeline, mergedVariables);
|
|
430
|
+
}
|
|
431
|
+
// 变量替换函数 (复用原有逻辑)
|
|
432
|
+
function replaceTemplateVariables(template, variables) {
|
|
433
|
+
let result = template;
|
|
434
|
+
result = result.replace(/\{\{([^}]+)\}\}/g, (match, expression) => {
|
|
435
|
+
const trimmed = expression.trim();
|
|
436
|
+
if (trimmed.includes('||')) {
|
|
437
|
+
const [varName, defaultValue] = trimmed.split('||').map((s) => s.trim());
|
|
438
|
+
const cleanVarName = varName.trim();
|
|
439
|
+
const cleanDefaultValue = defaultValue.replace(/['"]/g, '');
|
|
440
|
+
const value = variables[cleanVarName];
|
|
441
|
+
if (value !== undefined && value !== null) {
|
|
442
|
+
if (cleanVarName === 'repoUrl' && (value === '<your-repository-url>' || value.includes('<your-') || value.includes('>'))) {
|
|
443
|
+
const serviceName = variables['serviceName'];
|
|
444
|
+
if (serviceName && serviceName !== '<service-name>') {
|
|
445
|
+
return `https://codeup.aliyun.com/your-org/${serviceName}.git`;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (cleanVarName === 'serviceConnectionId' && (value === '<your-service-connection-id>' || value.includes('<your-'))) {
|
|
449
|
+
return 'your-service-connection-id';
|
|
450
|
+
}
|
|
451
|
+
if (cleanVarName === 'machineGroupId' && (value === '<your-machine-group-id>' || value.includes('<your-'))) {
|
|
452
|
+
return 'your-machine-group-id';
|
|
453
|
+
}
|
|
454
|
+
return value;
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
return cleanDefaultValue;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
const value = variables[trimmed];
|
|
462
|
+
if (value !== undefined && value !== null) {
|
|
463
|
+
if (typeof value === 'string' && value.includes('<your-')) {
|
|
464
|
+
if (trimmed === 'repoUrl') {
|
|
465
|
+
const serviceName = variables['serviceName'];
|
|
466
|
+
return serviceName && !serviceName.includes('<') ?
|
|
467
|
+
`https://codeup.aliyun.com/your-org/${serviceName}.git` :
|
|
468
|
+
'https://codeup.aliyun.com/your-org/your-repo.git';
|
|
469
|
+
}
|
|
470
|
+
if (trimmed === 'serviceConnectionId') {
|
|
471
|
+
return 'your-service-connection-id';
|
|
472
|
+
}
|
|
473
|
+
if (trimmed === 'machineGroupId') {
|
|
474
|
+
return 'your-machine-group-id';
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return value;
|
|
478
|
+
}
|
|
479
|
+
return match;
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
return result;
|
|
483
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 流水线模板相关类型定义
|
|
3
|
+
* 保留核心接口供模块化架构使用
|
|
4
|
+
*/
|
|
5
|
+
// 流水线模板类型枚举(保留用于类型兼容性)
|
|
6
|
+
export var PipelineTemplateType;
|
|
7
|
+
(function (PipelineTemplateType) {
|
|
8
|
+
PipelineTemplateType["JAVA_MAVEN"] = "java_maven";
|
|
9
|
+
PipelineTemplateType["NODEJS_NPM"] = "nodejs_npm";
|
|
10
|
+
PipelineTemplateType["PYTHON"] = "python";
|
|
11
|
+
PipelineTemplateType["GO"] = "go";
|
|
12
|
+
PipelineTemplateType["KUBERNETES_DEPLOY"] = "kubernetes_deploy";
|
|
13
|
+
PipelineTemplateType["VM_DEPLOY"] = "vm_deploy";
|
|
14
|
+
// 新增更多类型
|
|
15
|
+
PipelineTemplateType["JAVA_GRADLE"] = "java_gradle";
|
|
16
|
+
PipelineTemplateType["NODEJS_YARN"] = "nodejs_yarn";
|
|
17
|
+
PipelineTemplateType["PYTHON_POETRY"] = "python_poetry";
|
|
18
|
+
PipelineTemplateType["DOTNET_CORE"] = "dotnet_core";
|
|
19
|
+
})(PipelineTemplateType || (PipelineTemplateType = {}));
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Toolset, DEFAULT_ENABLED_TOOLSETS } from "./toolsets.js";
|
|
2
|
+
// 导入所有工具集函数
|
|
3
|
+
import { getCodeManagementTools } from '../tool-registry/code-management.js';
|
|
4
|
+
import { getOrganizationTools } from '../tool-registry/organization.js';
|
|
5
|
+
import { getProjectManagementTools } from '../tool-registry/project-management.js';
|
|
6
|
+
import { getPipelineTools } from '../tool-registry/pipeline.js';
|
|
7
|
+
import { getPackageManagementTools } from '../tool-registry/packages.js';
|
|
8
|
+
import { getServiceConnectionTools } from '../tool-registry/service-connections.js';
|
|
9
|
+
import { getAppStackTools } from '../tool-registry/appstack.js';
|
|
10
|
+
import { getAppStackTagTools } from '../tool-registry/appstack-tags.js';
|
|
11
|
+
import { getAppStackTemplateTools } from '../tool-registry/appstack-templates.js';
|
|
12
|
+
import { getAppStackGlobalVarTools } from '../tool-registry/appstack-global-vars.js';
|
|
13
|
+
import { getAppStackVariableGroupTools } from '../tool-registry/appstack-variable-groups.js';
|
|
14
|
+
import { getAppStackOrchestrationTools } from '../tool-registry/appstack-orchestrations.js';
|
|
15
|
+
import { getAppStackChangeRequestTools } from '../tool-registry/appstack-change-requests.js';
|
|
16
|
+
import { getAppStackDeploymentResourceTools } from '../tool-registry/appstack-deployment-resources.js';
|
|
17
|
+
import { getAppStackChangeOrderTools } from '../tool-registry/appstack-change-orders.js';
|
|
18
|
+
import { getAppStackAppReleaseWorkflowTools } from '../tool-registry/appstack-app-release-workflows.js';
|
|
19
|
+
import { getEffortTools } from '../tool-registry/effort.js';
|
|
20
|
+
import { getResourceMemberTools } from '../tool-registry/resourceMember.js';
|
|
21
|
+
import { getVMDeployOrderTools } from '../tool-registry/vmDeployOrder.js';
|
|
22
|
+
import { getCommitTools } from '../tool-registry/commit.js';
|
|
23
|
+
import { getBaseTools } from '../tool-registry/base.js';
|
|
24
|
+
import { getTestManagementTools } from '../tool-registry/test-management.js';
|
|
25
|
+
// 定义所有工具集配置
|
|
26
|
+
const ALL_TOOLSET_CONFIGS = {
|
|
27
|
+
[Toolset.BASE]: {
|
|
28
|
+
name: Toolset.BASE,
|
|
29
|
+
description: "Base tools that are always loaded",
|
|
30
|
+
tools: getBaseTools
|
|
31
|
+
},
|
|
32
|
+
[Toolset.CODE_MANAGEMENT]: {
|
|
33
|
+
name: Toolset.CODE_MANAGEMENT,
|
|
34
|
+
description: "Code repository management tools",
|
|
35
|
+
tools: (() => [
|
|
36
|
+
...getCodeManagementTools(),
|
|
37
|
+
...getCommitTools()
|
|
38
|
+
])
|
|
39
|
+
},
|
|
40
|
+
[Toolset.ORGANIZATION_MANAGEMENT]: {
|
|
41
|
+
name: Toolset.ORGANIZATION_MANAGEMENT,
|
|
42
|
+
description: "Organization management tools",
|
|
43
|
+
tools: (() => {
|
|
44
|
+
const allOrgTools = getOrganizationTools();
|
|
45
|
+
// 移除基础工具集中的三个常用工具
|
|
46
|
+
const filteredOrgTools = allOrgTools.filter(tool => tool.name !== "get_current_organization_info" &&
|
|
47
|
+
tool.name !== "get_user_organizations" &&
|
|
48
|
+
tool.name !== "get_current_user");
|
|
49
|
+
return filteredOrgTools;
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
[Toolset.PROJECT_MANAGEMENT]: {
|
|
53
|
+
name: Toolset.PROJECT_MANAGEMENT,
|
|
54
|
+
description: "Project management tools",
|
|
55
|
+
tools: (() => [
|
|
56
|
+
...getProjectManagementTools(),
|
|
57
|
+
...getEffortTools()
|
|
58
|
+
])
|
|
59
|
+
},
|
|
60
|
+
[Toolset.PIPELINE_MANAGEMENT]: {
|
|
61
|
+
name: Toolset.PIPELINE_MANAGEMENT,
|
|
62
|
+
description: "Pipeline management tools",
|
|
63
|
+
tools: (() => [
|
|
64
|
+
...getPipelineTools(),
|
|
65
|
+
...getServiceConnectionTools(),
|
|
66
|
+
...getResourceMemberTools(),
|
|
67
|
+
...getVMDeployOrderTools()
|
|
68
|
+
])
|
|
69
|
+
},
|
|
70
|
+
[Toolset.PACKAGES_MANAGEMENT]: {
|
|
71
|
+
name: Toolset.PACKAGES_MANAGEMENT,
|
|
72
|
+
description: "Package repository management tools",
|
|
73
|
+
tools: getPackageManagementTools
|
|
74
|
+
},
|
|
75
|
+
[Toolset.APPLICATION_DELIVERY]: {
|
|
76
|
+
name: Toolset.APPLICATION_DELIVERY,
|
|
77
|
+
description: "Application delivery tools",
|
|
78
|
+
tools: (() => [
|
|
79
|
+
...getAppStackTools(),
|
|
80
|
+
...getAppStackTagTools(),
|
|
81
|
+
...getAppStackTemplateTools(),
|
|
82
|
+
...getAppStackGlobalVarTools(),
|
|
83
|
+
...getAppStackVariableGroupTools(),
|
|
84
|
+
...getAppStackOrchestrationTools(),
|
|
85
|
+
...getAppStackChangeRequestTools(),
|
|
86
|
+
...getAppStackDeploymentResourceTools(),
|
|
87
|
+
...getAppStackChangeOrderTools(),
|
|
88
|
+
...getAppStackAppReleaseWorkflowTools()
|
|
89
|
+
])
|
|
90
|
+
},
|
|
91
|
+
[Toolset.TEST_MANAGEMENT]: {
|
|
92
|
+
name: Toolset.TEST_MANAGEMENT,
|
|
93
|
+
description: "Test management tools",
|
|
94
|
+
tools: getTestManagementTools
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
// 工具集管理器实现
|
|
98
|
+
export class DefaultToolsetManager {
|
|
99
|
+
getAllTools() {
|
|
100
|
+
return Object.values(ALL_TOOLSET_CONFIGS).flatMap(config => config.tools());
|
|
101
|
+
}
|
|
102
|
+
getToolsByToolset(toolsetName) {
|
|
103
|
+
const config = ALL_TOOLSET_CONFIGS[toolsetName];
|
|
104
|
+
if (!config) {
|
|
105
|
+
throw new Error(`Unknown toolset: ${toolsetName}`);
|
|
106
|
+
}
|
|
107
|
+
return config.tools();
|
|
108
|
+
}
|
|
109
|
+
getEnabledTools(enabledToolsets) {
|
|
110
|
+
// 如果没有指定启用的工具集,则使用默认配置
|
|
111
|
+
const toolsets = enabledToolsets.length > 0 ? enabledToolsets : DEFAULT_ENABLED_TOOLSETS;
|
|
112
|
+
return toolsets.flatMap(toolsetName => {
|
|
113
|
+
const config = ALL_TOOLSET_CONFIGS[toolsetName];
|
|
114
|
+
if (!config) {
|
|
115
|
+
console.warn(`Unknown toolset: ${toolsetName}, skipping...`);
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
return config.tools();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// 创建默认工具集管理器实例
|
|
123
|
+
export const defaultToolsetManager = new DefaultToolsetManager();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// 定义工具集枚举
|
|
2
|
+
export var Toolset;
|
|
3
|
+
(function (Toolset) {
|
|
4
|
+
Toolset["BASE"] = "base";
|
|
5
|
+
Toolset["CODE_MANAGEMENT"] = "code-management";
|
|
6
|
+
Toolset["ORGANIZATION_MANAGEMENT"] = "organization-management";
|
|
7
|
+
Toolset["PROJECT_MANAGEMENT"] = "project-management";
|
|
8
|
+
Toolset["PIPELINE_MANAGEMENT"] = "pipeline-management";
|
|
9
|
+
Toolset["PACKAGES_MANAGEMENT"] = "packages-management";
|
|
10
|
+
Toolset["APPLICATION_DELIVERY"] = "application-delivery";
|
|
11
|
+
Toolset["TEST_MANAGEMENT"] = "test-management";
|
|
12
|
+
})(Toolset || (Toolset = {}));
|
|
13
|
+
// 默认启用的工具集
|
|
14
|
+
export const DEFAULT_ENABLED_TOOLSETS = [
|
|
15
|
+
Toolset.BASE,
|
|
16
|
+
Toolset.CODE_MANAGEMENT,
|
|
17
|
+
Toolset.ORGANIZATION_MANAGEMENT,
|
|
18
|
+
Toolset.PROJECT_MANAGEMENT,
|
|
19
|
+
Toolset.PIPELINE_MANAGEMENT,
|
|
20
|
+
Toolset.PACKAGES_MANAGEMENT,
|
|
21
|
+
Toolset.APPLICATION_DELIVERY,
|
|
22
|
+
Toolset.TEST_MANAGEMENT
|
|
23
|
+
];
|