flowpilot 0.0.2 → 0.1.16
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 +34 -145
- package/dist/cli.js +309 -82
- package/dist/client/chunks/{client-DSXtnba0.js → client-Cc7BGooE.js} +1 -1
- package/dist/client/chunks/{client-oAYP8wOx.js → client-D1_CE06D.js} +423 -35
- package/dist/client/chunks/{client-Bb-xh-5_.js → client-IzVnMhfC.js} +1 -1
- package/dist/client/chunks/{jsx-dev-runtime-DGBfem3G.js → jsx-dev-runtime-DOO7Tqjo.js} +1 -1
- package/dist/client/client.js +3 -3
- package/dist/serve.js +116 -14
- package/dist/server.js +116 -14
- package/package.json +22 -6
package/dist/serve.js
CHANGED
|
@@ -4895,7 +4895,15 @@ var en_default = {
|
|
|
4895
4895
|
"createIssueFailed": "Failed to create issue",
|
|
4896
4896
|
"selectHistoryOrNew": "Select history for quick execute, or create new",
|
|
4897
4897
|
"historyNew": "Create new...",
|
|
4898
|
-
"historyQuickExecute": "Quick execute"
|
|
4898
|
+
"historyQuickExecute": "Quick execute",
|
|
4899
|
+
"createMR": "Create Merge Request for this release?",
|
|
4900
|
+
"selectSourceBranch": "Select source branch for MR",
|
|
4901
|
+
"noSourceBranches": "No other branches available as MR source",
|
|
4902
|
+
"selectMrBranch": "Select MR branch",
|
|
4903
|
+
"confirmCreateMr": "Confirm Create MR",
|
|
4904
|
+
"creatingMrBtn": "Creating MR...",
|
|
4905
|
+
"mrFromTo": "MR: {{source}} → {{target}}",
|
|
4906
|
+
"mrCreated": "MR created"
|
|
4899
4907
|
},
|
|
4900
4908
|
web: {
|
|
4901
4909
|
"flowpilot": "FlowPilot",
|
|
@@ -4967,8 +4975,13 @@ var en_default = {
|
|
|
4967
4975
|
"newModalTitle": "Create Release Request",
|
|
4968
4976
|
"clearSuccess": "History cleared",
|
|
4969
4977
|
"cancel": "Cancel",
|
|
4978
|
+
"createMrCheckbox": "Create MR",
|
|
4970
4979
|
"endTitle": "End",
|
|
4971
|
-
"endDesc": "End current task: rebase, push, create MR, update Jira."
|
|
4980
|
+
"endDesc": "End current task: rebase, push, create MR, update Jira.",
|
|
4981
|
+
"createMrBtn": "Create MR",
|
|
4982
|
+
"creatingMrBtn": "Creating MR...",
|
|
4983
|
+
"confirmCreateMr": "Confirm Create MR",
|
|
4984
|
+
"loadingMr": "Loading branches..."
|
|
4972
4985
|
},
|
|
4973
4986
|
end: {
|
|
4974
4987
|
"notGitRepo": "Not a git repository. Run this inside a git project.",
|
|
@@ -5122,7 +5135,15 @@ var zh_CN_default = {
|
|
|
5122
5135
|
"createIssueFailed": "创建 issue 失败",
|
|
5123
5136
|
"selectHistoryOrNew": "选择历史记录快速执行,或新建",
|
|
5124
5137
|
"historyNew": "新建...",
|
|
5125
|
-
"historyQuickExecute": "快速执行"
|
|
5138
|
+
"historyQuickExecute": "快速执行",
|
|
5139
|
+
"createMR": "为此发布创建 Merge Request?",
|
|
5140
|
+
"selectSourceBranch": "选择 MR 的源分支",
|
|
5141
|
+
"noSourceBranches": "没有其他分支可作为 MR 源分支",
|
|
5142
|
+
"selectMrBranch": "选择 MR 分支",
|
|
5143
|
+
"confirmCreateMr": "确认创建 MR",
|
|
5144
|
+
"creatingMrBtn": "正在创建 MR...",
|
|
5145
|
+
"mrFromTo": "MR: {{source}} → {{target}}",
|
|
5146
|
+
"mrCreated": "MR 已创建"
|
|
5126
5147
|
},
|
|
5127
5148
|
web: {
|
|
5128
5149
|
"flowpilot": "FlowPilot",
|
|
@@ -5194,8 +5215,13 @@ var zh_CN_default = {
|
|
|
5194
5215
|
"newModalTitle": "新建发布申请",
|
|
5195
5216
|
"clearSuccess": "历史已清空",
|
|
5196
5217
|
"cancel": "取消",
|
|
5218
|
+
"createMrCheckbox": "创建 MR",
|
|
5197
5219
|
"endTitle": "End",
|
|
5198
|
-
"endDesc": "结束当前任务:rebase、推送、创建 MR、更新 Jira。"
|
|
5220
|
+
"endDesc": "结束当前任务:rebase、推送、创建 MR、更新 Jira。",
|
|
5221
|
+
"createMrBtn": "创建 MR",
|
|
5222
|
+
"creatingMrBtn": "正在创建 MR...",
|
|
5223
|
+
"confirmCreateMr": "确认创建 MR",
|
|
5224
|
+
"loadingMr": "正在加载分支..."
|
|
5199
5225
|
},
|
|
5200
5226
|
end: {
|
|
5201
5227
|
"notGitRepo": "当前不在 git 仓库中。请在 git 项目内运行。",
|
|
@@ -18488,6 +18514,7 @@ const CONTEXT_404_MAP = {
|
|
|
18488
18514
|
gitlabFile: "error.http404File",
|
|
18489
18515
|
gitlabBranch: "error.http404",
|
|
18490
18516
|
gitlabGeneral: "error.http404",
|
|
18517
|
+
gitlabMR: "error.http404",
|
|
18491
18518
|
jiraProject: "error.http404",
|
|
18492
18519
|
jiraSearch: "error.http404",
|
|
18493
18520
|
jiraVersion: "error.http404",
|
|
@@ -18500,6 +18527,7 @@ const CONTEXT_FALLBACK_MAP = {
|
|
|
18500
18527
|
gitlabBranch: "error.fetchBranchesFailed",
|
|
18501
18528
|
gitlabFile: "error.fetchPomFailed",
|
|
18502
18529
|
gitlabGeneral: "error.gitlabApiFailed",
|
|
18530
|
+
gitlabMR: "error.gitlabApiFailed",
|
|
18503
18531
|
jiraProject: "error.fetchJiraProjectsFailed",
|
|
18504
18532
|
jiraSearch: "error.jiraSearchFailed",
|
|
18505
18533
|
jiraVersion: "error.jiraVersionFailed",
|
|
@@ -18956,6 +18984,35 @@ function cleanVersion(v) {
|
|
|
18956
18984
|
//#region src/commands/release/routes.tsx
|
|
18957
18985
|
const releaseStore = new Store("release-history.json");
|
|
18958
18986
|
const dedupKey = (e) => `${e.projectId}:${e.branch}:${e.jiraProjectKey}`;
|
|
18987
|
+
async function createMrForRelease(git, projectId, targetBranch, jiraUrl, sourceBranchOverride) {
|
|
18988
|
+
try {
|
|
18989
|
+
const sourceBranch = sourceBranchOverride ?? (await git.listBranches(projectId)).find((b) => b.default)?.name;
|
|
18990
|
+
if (!sourceBranch || sourceBranch === targetBranch) return void 0;
|
|
18991
|
+
try {
|
|
18992
|
+
const mr = await git.createMergeRequest(projectId, sourceBranch, targetBranch, `${sourceBranch} → ${targetBranch}`, { description: jiraUrl ? `Jira: ${jiraUrl}` : "" });
|
|
18993
|
+
return {
|
|
18994
|
+
mrUrl: mr.webUrl ?? mr.web_url,
|
|
18995
|
+
sourceBranch,
|
|
18996
|
+
targetBranch
|
|
18997
|
+
};
|
|
18998
|
+
} catch (mrErr) {
|
|
18999
|
+
if ((mrErr instanceof Error ? mrErr.message : String(mrErr)).includes("already exists")) {
|
|
19000
|
+
const existing = (await git.listMergeRequests({
|
|
19001
|
+
projectId,
|
|
19002
|
+
state: "opened"
|
|
19003
|
+
})).find((m) => m.sourceBranch === sourceBranch && m.targetBranch === targetBranch);
|
|
19004
|
+
if (existing) return {
|
|
19005
|
+
mrUrl: existing.webUrl ?? existing.web_url ?? "",
|
|
19006
|
+
sourceBranch,
|
|
19007
|
+
targetBranch
|
|
19008
|
+
};
|
|
19009
|
+
}
|
|
19010
|
+
return;
|
|
19011
|
+
}
|
|
19012
|
+
} catch {
|
|
19013
|
+
return;
|
|
19014
|
+
}
|
|
19015
|
+
}
|
|
18959
19016
|
const REQUIRED_KEYS = [
|
|
18960
19017
|
"jiraHost",
|
|
18961
19018
|
"jiraName",
|
|
@@ -18995,11 +19052,14 @@ router.delete("/api/history", (c) => {
|
|
|
18995
19052
|
});
|
|
18996
19053
|
router.post("/api/history/:id/execute", async (c) => {
|
|
18997
19054
|
const id = c.req.param("id");
|
|
19055
|
+
const createMr = (await c.req.json().catch(() => ({ createMr: false }))).createMr ?? false;
|
|
18998
19056
|
const entry = releaseStore.getAll().find((h) => h.id === id);
|
|
18999
19057
|
if (!entry) return c.json({ error: t$1("error.http404") }, 404);
|
|
19000
19058
|
const git = new GitlabController();
|
|
19001
19059
|
const jira = new JiraController();
|
|
19002
19060
|
const config = new ConfigJson().getConfig();
|
|
19061
|
+
let mrResult;
|
|
19062
|
+
if (createMr) mrResult = await createMrForRelease(git, entry.projectId, entry.branch, "", entry.mrSourceBranch);
|
|
19003
19063
|
let pomInfo;
|
|
19004
19064
|
try {
|
|
19005
19065
|
const file = await git.getFile(entry.projectId, "pom.xml", entry.branch);
|
|
@@ -19016,15 +19076,15 @@ router.post("/api/history/:id/execute", async (c) => {
|
|
|
19016
19076
|
if (searchResult.total > 0 && searchResult.issues?.[0]) {
|
|
19017
19077
|
const existingKey = searchResult.issues[0].key;
|
|
19018
19078
|
const jiraUrl = config.jiraHost ? `${config.jiraHost}/browse/${existingKey}` : "";
|
|
19019
|
-
releaseStore.add({
|
|
19020
|
-
...entry,
|
|
19021
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
19022
|
-
}, dedupKey);
|
|
19023
19079
|
return c.json({
|
|
19024
19080
|
issueKey: existingKey,
|
|
19025
19081
|
issueUrl: jiraUrl,
|
|
19026
19082
|
version: displayVersion,
|
|
19027
|
-
versionCreated: false
|
|
19083
|
+
versionCreated: false,
|
|
19084
|
+
issueCreated: false,
|
|
19085
|
+
mrUrl: mrResult?.mrUrl,
|
|
19086
|
+
mrSourceBranch: mrResult?.sourceBranch,
|
|
19087
|
+
mrTargetBranch: mrResult?.targetBranch
|
|
19028
19088
|
});
|
|
19029
19089
|
}
|
|
19030
19090
|
} catch {}
|
|
@@ -19050,15 +19110,14 @@ router.post("/api/history/:id/execute", async (c) => {
|
|
|
19050
19110
|
customfield_13341: [{ name: "licheng.li" }]
|
|
19051
19111
|
});
|
|
19052
19112
|
const jiraUrl = config.jiraHost ? `${config.jiraHost}/browse/${issue.key}` : "";
|
|
19053
|
-
releaseStore.add({
|
|
19054
|
-
...entry,
|
|
19055
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
19056
|
-
}, dedupKey);
|
|
19057
19113
|
return c.json({
|
|
19058
19114
|
issueKey: issue.key,
|
|
19059
19115
|
issueUrl: jiraUrl,
|
|
19060
19116
|
version: displayVersion,
|
|
19061
|
-
versionCreated
|
|
19117
|
+
versionCreated,
|
|
19118
|
+
mrUrl: mrResult?.mrUrl,
|
|
19119
|
+
mrSourceBranch: mrResult?.sourceBranch,
|
|
19120
|
+
mrTargetBranch: mrResult?.targetBranch
|
|
19062
19121
|
});
|
|
19063
19122
|
} catch (e) {
|
|
19064
19123
|
return c.json({ error: translateApiError(e, "jiraCreateIssue") }, 500);
|
|
@@ -19081,6 +19140,49 @@ router.get("/api/projects/:id/branches", async (c) => {
|
|
|
19081
19140
|
return c.json({ error: translateApiError(e, "gitlabBranch") }, 500);
|
|
19082
19141
|
}
|
|
19083
19142
|
});
|
|
19143
|
+
router.post("/api/create-mr", async (c) => {
|
|
19144
|
+
let mrUrl = "";
|
|
19145
|
+
let sourceBranch = "";
|
|
19146
|
+
let targetBranch = "";
|
|
19147
|
+
let projectId = 0;
|
|
19148
|
+
try {
|
|
19149
|
+
const body = await c.req.json();
|
|
19150
|
+
projectId = Number(body.projectId);
|
|
19151
|
+
targetBranch = body.targetBranch;
|
|
19152
|
+
sourceBranch = body.sourceBranch;
|
|
19153
|
+
const jiraUrl = body.jiraUrl ?? "";
|
|
19154
|
+
const git = new GitlabController();
|
|
19155
|
+
try {
|
|
19156
|
+
const mr = await git.createMergeRequest(projectId, sourceBranch, targetBranch, `${sourceBranch} → ${targetBranch}`, { description: jiraUrl ? `Jira: ${jiraUrl}` : "" });
|
|
19157
|
+
mrUrl = mr.webUrl ?? mr.web_url;
|
|
19158
|
+
} catch (mrErr) {
|
|
19159
|
+
if ((mrErr instanceof Error ? mrErr.message : String(mrErr)).includes("already exists")) try {
|
|
19160
|
+
const existing = (await git.listMergeRequests({
|
|
19161
|
+
projectId,
|
|
19162
|
+
state: "opened"
|
|
19163
|
+
})).find((m) => m.sourceBranch === sourceBranch && m.targetBranch === targetBranch);
|
|
19164
|
+
if (existing) mrUrl = existing.webUrl ?? existing.web_url ?? "";
|
|
19165
|
+
} catch {}
|
|
19166
|
+
if (!mrUrl) return c.json({ error: translateApiError(mrErr, "gitlabMR") }, 500);
|
|
19167
|
+
}
|
|
19168
|
+
} catch (e) {
|
|
19169
|
+
return c.json({ error: translateApiError(e, "gitlabMR") }, 500);
|
|
19170
|
+
}
|
|
19171
|
+
if (mrUrl && projectId) try {
|
|
19172
|
+
const match = releaseStore.getAll().find((e) => Number(e.projectId) === projectId && e.branch === targetBranch);
|
|
19173
|
+
if (match) releaseStore.add({
|
|
19174
|
+
...match,
|
|
19175
|
+
mrUrl,
|
|
19176
|
+
mrSourceBranch: sourceBranch,
|
|
19177
|
+
mrTargetBranch: targetBranch
|
|
19178
|
+
}, dedupKey);
|
|
19179
|
+
} catch {}
|
|
19180
|
+
return c.json({
|
|
19181
|
+
mrUrl,
|
|
19182
|
+
sourceBranch,
|
|
19183
|
+
targetBranch
|
|
19184
|
+
});
|
|
19185
|
+
});
|
|
19084
19186
|
router.get("/api/projects/:id/pom-version", async (c) => {
|
|
19085
19187
|
try {
|
|
19086
19188
|
const projectId = c.req.param("id");
|
package/dist/server.js
CHANGED
|
@@ -2149,7 +2149,15 @@ var en_default = {
|
|
|
2149
2149
|
"createIssueFailed": "Failed to create issue",
|
|
2150
2150
|
"selectHistoryOrNew": "Select history for quick execute, or create new",
|
|
2151
2151
|
"historyNew": "Create new...",
|
|
2152
|
-
"historyQuickExecute": "Quick execute"
|
|
2152
|
+
"historyQuickExecute": "Quick execute",
|
|
2153
|
+
"createMR": "Create Merge Request for this release?",
|
|
2154
|
+
"selectSourceBranch": "Select source branch for MR",
|
|
2155
|
+
"noSourceBranches": "No other branches available as MR source",
|
|
2156
|
+
"selectMrBranch": "Select MR branch",
|
|
2157
|
+
"confirmCreateMr": "Confirm Create MR",
|
|
2158
|
+
"creatingMrBtn": "Creating MR...",
|
|
2159
|
+
"mrFromTo": "MR: {{source}} → {{target}}",
|
|
2160
|
+
"mrCreated": "MR created"
|
|
2153
2161
|
},
|
|
2154
2162
|
web: {
|
|
2155
2163
|
"flowpilot": "FlowPilot",
|
|
@@ -2221,8 +2229,13 @@ var en_default = {
|
|
|
2221
2229
|
"newModalTitle": "Create Release Request",
|
|
2222
2230
|
"clearSuccess": "History cleared",
|
|
2223
2231
|
"cancel": "Cancel",
|
|
2232
|
+
"createMrCheckbox": "Create MR",
|
|
2224
2233
|
"endTitle": "End",
|
|
2225
|
-
"endDesc": "End current task: rebase, push, create MR, update Jira."
|
|
2234
|
+
"endDesc": "End current task: rebase, push, create MR, update Jira.",
|
|
2235
|
+
"createMrBtn": "Create MR",
|
|
2236
|
+
"creatingMrBtn": "Creating MR...",
|
|
2237
|
+
"confirmCreateMr": "Confirm Create MR",
|
|
2238
|
+
"loadingMr": "Loading branches..."
|
|
2226
2239
|
},
|
|
2227
2240
|
end: {
|
|
2228
2241
|
"notGitRepo": "Not a git repository. Run this inside a git project.",
|
|
@@ -2376,7 +2389,15 @@ var zh_CN_default = {
|
|
|
2376
2389
|
"createIssueFailed": "创建 issue 失败",
|
|
2377
2390
|
"selectHistoryOrNew": "选择历史记录快速执行,或新建",
|
|
2378
2391
|
"historyNew": "新建...",
|
|
2379
|
-
"historyQuickExecute": "快速执行"
|
|
2392
|
+
"historyQuickExecute": "快速执行",
|
|
2393
|
+
"createMR": "为此发布创建 Merge Request?",
|
|
2394
|
+
"selectSourceBranch": "选择 MR 的源分支",
|
|
2395
|
+
"noSourceBranches": "没有其他分支可作为 MR 源分支",
|
|
2396
|
+
"selectMrBranch": "选择 MR 分支",
|
|
2397
|
+
"confirmCreateMr": "确认创建 MR",
|
|
2398
|
+
"creatingMrBtn": "正在创建 MR...",
|
|
2399
|
+
"mrFromTo": "MR: {{source}} → {{target}}",
|
|
2400
|
+
"mrCreated": "MR 已创建"
|
|
2380
2401
|
},
|
|
2381
2402
|
web: {
|
|
2382
2403
|
"flowpilot": "FlowPilot",
|
|
@@ -2448,8 +2469,13 @@ var zh_CN_default = {
|
|
|
2448
2469
|
"newModalTitle": "新建发布申请",
|
|
2449
2470
|
"clearSuccess": "历史已清空",
|
|
2450
2471
|
"cancel": "取消",
|
|
2472
|
+
"createMrCheckbox": "创建 MR",
|
|
2451
2473
|
"endTitle": "End",
|
|
2452
|
-
"endDesc": "结束当前任务:rebase、推送、创建 MR、更新 Jira。"
|
|
2474
|
+
"endDesc": "结束当前任务:rebase、推送、创建 MR、更新 Jira。",
|
|
2475
|
+
"createMrBtn": "创建 MR",
|
|
2476
|
+
"creatingMrBtn": "正在创建 MR...",
|
|
2477
|
+
"confirmCreateMr": "确认创建 MR",
|
|
2478
|
+
"loadingMr": "正在加载分支..."
|
|
2453
2479
|
},
|
|
2454
2480
|
end: {
|
|
2455
2481
|
"notGitRepo": "当前不在 git 仓库中。请在 git 项目内运行。",
|
|
@@ -18576,6 +18602,7 @@ const CONTEXT_404_MAP = {
|
|
|
18576
18602
|
gitlabFile: "error.http404File",
|
|
18577
18603
|
gitlabBranch: "error.http404",
|
|
18578
18604
|
gitlabGeneral: "error.http404",
|
|
18605
|
+
gitlabMR: "error.http404",
|
|
18579
18606
|
jiraProject: "error.http404",
|
|
18580
18607
|
jiraSearch: "error.http404",
|
|
18581
18608
|
jiraVersion: "error.http404",
|
|
@@ -18588,6 +18615,7 @@ const CONTEXT_FALLBACK_MAP = {
|
|
|
18588
18615
|
gitlabBranch: "error.fetchBranchesFailed",
|
|
18589
18616
|
gitlabFile: "error.fetchPomFailed",
|
|
18590
18617
|
gitlabGeneral: "error.gitlabApiFailed",
|
|
18618
|
+
gitlabMR: "error.gitlabApiFailed",
|
|
18591
18619
|
jiraProject: "error.fetchJiraProjectsFailed",
|
|
18592
18620
|
jiraSearch: "error.jiraSearchFailed",
|
|
18593
18621
|
jiraVersion: "error.jiraVersionFailed",
|
|
@@ -18957,6 +18985,35 @@ function cleanVersion(v) {
|
|
|
18957
18985
|
//#region src/commands/release/routes.tsx
|
|
18958
18986
|
const releaseStore = new Store("release-history.json");
|
|
18959
18987
|
const dedupKey = (e) => `${e.projectId}:${e.branch}:${e.jiraProjectKey}`;
|
|
18988
|
+
async function createMrForRelease(git, projectId, targetBranch, jiraUrl, sourceBranchOverride) {
|
|
18989
|
+
try {
|
|
18990
|
+
const sourceBranch = sourceBranchOverride ?? (await git.listBranches(projectId)).find((b) => b.default)?.name;
|
|
18991
|
+
if (!sourceBranch || sourceBranch === targetBranch) return void 0;
|
|
18992
|
+
try {
|
|
18993
|
+
const mr = await git.createMergeRequest(projectId, sourceBranch, targetBranch, `${sourceBranch} → ${targetBranch}`, { description: jiraUrl ? `Jira: ${jiraUrl}` : "" });
|
|
18994
|
+
return {
|
|
18995
|
+
mrUrl: mr.webUrl ?? mr.web_url,
|
|
18996
|
+
sourceBranch,
|
|
18997
|
+
targetBranch
|
|
18998
|
+
};
|
|
18999
|
+
} catch (mrErr) {
|
|
19000
|
+
if ((mrErr instanceof Error ? mrErr.message : String(mrErr)).includes("already exists")) {
|
|
19001
|
+
const existing = (await git.listMergeRequests({
|
|
19002
|
+
projectId,
|
|
19003
|
+
state: "opened"
|
|
19004
|
+
})).find((m) => m.sourceBranch === sourceBranch && m.targetBranch === targetBranch);
|
|
19005
|
+
if (existing) return {
|
|
19006
|
+
mrUrl: existing.webUrl ?? existing.web_url ?? "",
|
|
19007
|
+
sourceBranch,
|
|
19008
|
+
targetBranch
|
|
19009
|
+
};
|
|
19010
|
+
}
|
|
19011
|
+
return;
|
|
19012
|
+
}
|
|
19013
|
+
} catch {
|
|
19014
|
+
return;
|
|
19015
|
+
}
|
|
19016
|
+
}
|
|
18960
19017
|
const REQUIRED_KEYS = [
|
|
18961
19018
|
"jiraHost",
|
|
18962
19019
|
"jiraName",
|
|
@@ -18996,11 +19053,14 @@ router.delete("/api/history", (c) => {
|
|
|
18996
19053
|
});
|
|
18997
19054
|
router.post("/api/history/:id/execute", async (c) => {
|
|
18998
19055
|
const id = c.req.param("id");
|
|
19056
|
+
const createMr = (await c.req.json().catch(() => ({ createMr: false }))).createMr ?? false;
|
|
18999
19057
|
const entry = releaseStore.getAll().find((h) => h.id === id);
|
|
19000
19058
|
if (!entry) return c.json({ error: t("error.http404") }, 404);
|
|
19001
19059
|
const git = new GitlabController();
|
|
19002
19060
|
const jira = new JiraController();
|
|
19003
19061
|
const config = new ConfigJson().getConfig();
|
|
19062
|
+
let mrResult;
|
|
19063
|
+
if (createMr) mrResult = await createMrForRelease(git, entry.projectId, entry.branch, "", entry.mrSourceBranch);
|
|
19004
19064
|
let pomInfo;
|
|
19005
19065
|
try {
|
|
19006
19066
|
const file = await git.getFile(entry.projectId, "pom.xml", entry.branch);
|
|
@@ -19017,15 +19077,15 @@ router.post("/api/history/:id/execute", async (c) => {
|
|
|
19017
19077
|
if (searchResult.total > 0 && searchResult.issues?.[0]) {
|
|
19018
19078
|
const existingKey = searchResult.issues[0].key;
|
|
19019
19079
|
const jiraUrl = config.jiraHost ? `${config.jiraHost}/browse/${existingKey}` : "";
|
|
19020
|
-
releaseStore.add({
|
|
19021
|
-
...entry,
|
|
19022
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
19023
|
-
}, dedupKey);
|
|
19024
19080
|
return c.json({
|
|
19025
19081
|
issueKey: existingKey,
|
|
19026
19082
|
issueUrl: jiraUrl,
|
|
19027
19083
|
version: displayVersion,
|
|
19028
|
-
versionCreated: false
|
|
19084
|
+
versionCreated: false,
|
|
19085
|
+
issueCreated: false,
|
|
19086
|
+
mrUrl: mrResult?.mrUrl,
|
|
19087
|
+
mrSourceBranch: mrResult?.sourceBranch,
|
|
19088
|
+
mrTargetBranch: mrResult?.targetBranch
|
|
19029
19089
|
});
|
|
19030
19090
|
}
|
|
19031
19091
|
} catch {}
|
|
@@ -19051,15 +19111,14 @@ router.post("/api/history/:id/execute", async (c) => {
|
|
|
19051
19111
|
customfield_13341: [{ name: "licheng.li" }]
|
|
19052
19112
|
});
|
|
19053
19113
|
const jiraUrl = config.jiraHost ? `${config.jiraHost}/browse/${issue.key}` : "";
|
|
19054
|
-
releaseStore.add({
|
|
19055
|
-
...entry,
|
|
19056
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
19057
|
-
}, dedupKey);
|
|
19058
19114
|
return c.json({
|
|
19059
19115
|
issueKey: issue.key,
|
|
19060
19116
|
issueUrl: jiraUrl,
|
|
19061
19117
|
version: displayVersion,
|
|
19062
|
-
versionCreated
|
|
19118
|
+
versionCreated,
|
|
19119
|
+
mrUrl: mrResult?.mrUrl,
|
|
19120
|
+
mrSourceBranch: mrResult?.sourceBranch,
|
|
19121
|
+
mrTargetBranch: mrResult?.targetBranch
|
|
19063
19122
|
});
|
|
19064
19123
|
} catch (e) {
|
|
19065
19124
|
return c.json({ error: translateApiError(e, "jiraCreateIssue") }, 500);
|
|
@@ -19082,6 +19141,49 @@ router.get("/api/projects/:id/branches", async (c) => {
|
|
|
19082
19141
|
return c.json({ error: translateApiError(e, "gitlabBranch") }, 500);
|
|
19083
19142
|
}
|
|
19084
19143
|
});
|
|
19144
|
+
router.post("/api/create-mr", async (c) => {
|
|
19145
|
+
let mrUrl = "";
|
|
19146
|
+
let sourceBranch = "";
|
|
19147
|
+
let targetBranch = "";
|
|
19148
|
+
let projectId = 0;
|
|
19149
|
+
try {
|
|
19150
|
+
const body = await c.req.json();
|
|
19151
|
+
projectId = Number(body.projectId);
|
|
19152
|
+
targetBranch = body.targetBranch;
|
|
19153
|
+
sourceBranch = body.sourceBranch;
|
|
19154
|
+
const jiraUrl = body.jiraUrl ?? "";
|
|
19155
|
+
const git = new GitlabController();
|
|
19156
|
+
try {
|
|
19157
|
+
const mr = await git.createMergeRequest(projectId, sourceBranch, targetBranch, `${sourceBranch} → ${targetBranch}`, { description: jiraUrl ? `Jira: ${jiraUrl}` : "" });
|
|
19158
|
+
mrUrl = mr.webUrl ?? mr.web_url;
|
|
19159
|
+
} catch (mrErr) {
|
|
19160
|
+
if ((mrErr instanceof Error ? mrErr.message : String(mrErr)).includes("already exists")) try {
|
|
19161
|
+
const existing = (await git.listMergeRequests({
|
|
19162
|
+
projectId,
|
|
19163
|
+
state: "opened"
|
|
19164
|
+
})).find((m) => m.sourceBranch === sourceBranch && m.targetBranch === targetBranch);
|
|
19165
|
+
if (existing) mrUrl = existing.webUrl ?? existing.web_url ?? "";
|
|
19166
|
+
} catch {}
|
|
19167
|
+
if (!mrUrl) return c.json({ error: translateApiError(mrErr, "gitlabMR") }, 500);
|
|
19168
|
+
}
|
|
19169
|
+
} catch (e) {
|
|
19170
|
+
return c.json({ error: translateApiError(e, "gitlabMR") }, 500);
|
|
19171
|
+
}
|
|
19172
|
+
if (mrUrl && projectId) try {
|
|
19173
|
+
const match = releaseStore.getAll().find((e) => Number(e.projectId) === projectId && e.branch === targetBranch);
|
|
19174
|
+
if (match) releaseStore.add({
|
|
19175
|
+
...match,
|
|
19176
|
+
mrUrl,
|
|
19177
|
+
mrSourceBranch: sourceBranch,
|
|
19178
|
+
mrTargetBranch: targetBranch
|
|
19179
|
+
}, dedupKey);
|
|
19180
|
+
} catch {}
|
|
19181
|
+
return c.json({
|
|
19182
|
+
mrUrl,
|
|
19183
|
+
sourceBranch,
|
|
19184
|
+
targetBranch
|
|
19185
|
+
});
|
|
19186
|
+
});
|
|
19085
19187
|
router.get("/api/projects/:id/pom-version", async (c) => {
|
|
19086
19188
|
try {
|
|
19087
19189
|
const projectId = c.req.param("id");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowpilot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.13"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"module": "./dist/server.js",
|
|
16
16
|
"types": "./dist/server.d.ts",
|
|
17
|
-
"description": "
|
|
17
|
+
"description": "Jira & GitLab workflow automation — config, release, end and more",
|
|
18
18
|
"bin": {
|
|
19
19
|
"flowpilot": "./dist/cli.js"
|
|
20
20
|
},
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
"dev": "rolldown -c rolldown.config.ts --watch",
|
|
25
25
|
"format": "biome format --write",
|
|
26
26
|
"test": "vitest",
|
|
27
|
-
"release
|
|
28
|
-
"release:
|
|
29
|
-
"release:
|
|
27
|
+
"release": "vitest run && pnpm build && bash scripts/bump-version.sh | xargs npm version && git push && git push --tags",
|
|
28
|
+
"release:patch": "vitest run && pnpm build && npm version patch && git push && git push --tags",
|
|
29
|
+
"release:minor": "vitest run && pnpm build && npm version minor && git push && git push --tags",
|
|
30
|
+
"release:major": "vitest run && pnpm build && npm version major && git push && git push --tags",
|
|
30
31
|
"postinstall": "node dist/cli.js serve",
|
|
31
32
|
"prepublishOnly": "pnpm build"
|
|
32
33
|
},
|
|
@@ -35,8 +36,23 @@
|
|
|
35
36
|
"favicon",
|
|
36
37
|
"README.md"
|
|
37
38
|
],
|
|
38
|
-
"keywords": [
|
|
39
|
+
"keywords": [
|
|
40
|
+
"jira",
|
|
41
|
+
"gitlab",
|
|
42
|
+
"cli",
|
|
43
|
+
"release",
|
|
44
|
+
"merge-request",
|
|
45
|
+
"workflow",
|
|
46
|
+
"devops"
|
|
47
|
+
],
|
|
39
48
|
"author": "Corazon",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/FriendsA/flowpilot"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"provenance": true
|
|
55
|
+
},
|
|
40
56
|
"license": "ISC",
|
|
41
57
|
"dependencies": {
|
|
42
58
|
"@clack/prompts": "^1.4.0",
|