@d5render/cli 0.1.25 → 0.1.26
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/bin/copilot.js +1 -1
- package/bin/d5cli +30 -34
- package/package.json +1 -1
package/bin/copilot.js
CHANGED
|
@@ -18872,7 +18872,7 @@ const NAME = name$1.replaceAll("/", "_");
|
|
|
18872
18872
|
const RUNTIME_CWD = join(dirname(fileURLToPath(import.meta.url)), "../");
|
|
18873
18873
|
const HOME = env.USERPROFILE ?? env.HOME ?? env.HOMEPATH;
|
|
18874
18874
|
if (!HOME) throw new Error("cannot find `USERPROFILE` directory");
|
|
18875
|
-
const TEMP = env.CI_PROJECT_DIR + NAME;
|
|
18875
|
+
const TEMP = env.CI_PROJECT_DIR + "." + NAME;
|
|
18876
18876
|
|
|
18877
18877
|
//#endregion
|
|
18878
18878
|
//#region copilot/server/config.ts
|
package/bin/d5cli
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name$1 = "@d5render/cli";
|
|
10
|
-
var version = "0.1.
|
|
10
|
+
var version = "0.1.26";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region packages/gitlab/url.ts
|
|
@@ -71,8 +71,16 @@ const VERSION = version;
|
|
|
71
71
|
const RUNTIME_CWD = join(dirname(fileURLToPath(import.meta.url)), "../");
|
|
72
72
|
const HOME = env.USERPROFILE ?? env.HOME ?? env.HOMEPATH;
|
|
73
73
|
if (!HOME) throw new Error("cannot find `USERPROFILE` directory");
|
|
74
|
-
const TEMP = env.CI_PROJECT_DIR + NAME;
|
|
75
|
-
|
|
74
|
+
const TEMP = env.CI_PROJECT_DIR + "." + NAME;
|
|
75
|
+
const dingding = async (...args) => {
|
|
76
|
+
try {
|
|
77
|
+
const msg = await (await sendding(...args)).text();
|
|
78
|
+
console.log(msg);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
async function deploy() {
|
|
76
84
|
if (!env.CI) return;
|
|
77
85
|
const config = join(HOME, ".copilot/config.json"), dir = join(HOME, ".copilot/skills/codereview");
|
|
78
86
|
console.log("deploy...");
|
|
@@ -82,6 +90,14 @@ function deploy() {
|
|
|
82
90
|
}
|
|
83
91
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
84
92
|
const versiono = readFileSync(join(RUNTIME_CWD, ".skills/review/version"), "utf8");
|
|
93
|
+
const changelog = readFileSync(join(RUNTIME_CWD, "CHANGELOG.md"), "utf8");
|
|
94
|
+
const cachepath = join(TEMP, "CHANGELOG");
|
|
95
|
+
if (changelog !== (existsSync(cachepath) ? readFileSync(cachepath, "utf8") : "")) {
|
|
96
|
+
if (!existsSync(TEMP)) mkdirSync(TEMP, { recursive: true });
|
|
97
|
+
writeFileSync(cachepath, changelog, "utf8");
|
|
98
|
+
console.log("updated CHANGELOG cache.");
|
|
99
|
+
await dingding("NOTICE", `codereview skills has been updated to version ${versiono}\n\nfor more details, please refer to [ONLINE](https://www.npmjs.com/package/@d5render/cli?activeTab=readme)`);
|
|
100
|
+
}
|
|
85
101
|
const versionnPath = join(dir, "version");
|
|
86
102
|
if ((existsSync(versionnPath) ? readFileSync(versionnPath, "utf8") : "") === versiono) return;
|
|
87
103
|
const skillRoot = join(RUNTIME_CWD, ".skills/review");
|
|
@@ -89,25 +105,16 @@ function deploy() {
|
|
|
89
105
|
const instructionsRoot = join(RUNTIME_CWD, ".github/instructions");
|
|
90
106
|
readdirSync(instructionsRoot).forEach((instruction) => copyFileSync(join(instructionsRoot, instruction), join(dir, instruction)));
|
|
91
107
|
console.log("to new skill.");
|
|
92
|
-
const changelog = readFileSync(join(RUNTIME_CWD, "CHANGELOG.md"), "utf8");
|
|
93
|
-
const cachepath = join(TEMP, "CHANGELOG");
|
|
94
|
-
if (!existsSync(TEMP)) mkdirSync(TEMP, { recursive: true });
|
|
95
|
-
if (changelog !== (existsSync(cachepath) ? readFileSync(cachepath, "utf8") : "")) {
|
|
96
|
-
if (!existsSync(cachepath)) mkdirSync(cachepath, { recursive: true });
|
|
97
|
-
writeFileSync(cachepath, changelog, "utf8");
|
|
98
|
-
console.log("updated CHANGELOG cache.");
|
|
99
|
-
sendding("NOTICE", `NOTICE: codereview skills has been updated to version ${versiono}\n\nfor more details, please refer to [ONLINE](https://www.npmjs.com/package/@d5render/cli?activeTab=readme)`);
|
|
100
|
-
}
|
|
101
108
|
}
|
|
102
|
-
function need() {
|
|
109
|
+
async function need() {
|
|
103
110
|
if (!env.CI) return;
|
|
104
|
-
if (!existsSync(TEMP)) mkdirSync(TEMP, { recursive: true });
|
|
105
111
|
const { CI_MERGE_REQUEST_IID, CI_COMMIT_SHA } = env;
|
|
106
112
|
const file$1 = join(TEMP, "CODEREVIEW");
|
|
107
113
|
if (CI_MERGE_REQUEST_IID) {
|
|
108
114
|
let appended = `${existsSync(file$1) ? readFileSync(file$1, "utf8") : ""}\n${CI_MERGE_REQUEST_IID}`.split("\n");
|
|
109
115
|
const max = 1e4;
|
|
110
116
|
if (appended.length > max) appended = appended.slice(-max);
|
|
117
|
+
if (!existsSync(TEMP)) mkdirSync(TEMP, { recursive: true });
|
|
111
118
|
writeFileSync(file$1, appended.join("\n"), "utf8");
|
|
112
119
|
console.log("merge pipeline, recorded IID:", CI_MERGE_REQUEST_IID, "to:", file$1);
|
|
113
120
|
return true;
|
|
@@ -125,14 +132,14 @@ function need() {
|
|
|
125
132
|
console.warn(`Merge Request !${iid} has been AI reviewed before.`);
|
|
126
133
|
const mergeURL = visitPipeline(iid).url;
|
|
127
134
|
const url = `${commits()}/${CI_COMMIT_SHA}/comments`;
|
|
128
|
-
fetch(url, {
|
|
135
|
+
await fetch(url, {
|
|
129
136
|
method: "POST",
|
|
130
137
|
headers: buildHeaders(),
|
|
131
138
|
body: JSON.stringify({
|
|
132
139
|
note: `请查看管道评论:${mergeURL}#note`,
|
|
133
140
|
line_type: "new"
|
|
134
141
|
})
|
|
135
|
-
}).then((res) => res.text());
|
|
142
|
+
}).then((res) => res.text()).then((v) => console.log(v)).catch((e) => console.error(e));
|
|
136
143
|
}
|
|
137
144
|
return !yes;
|
|
138
145
|
}
|
|
@@ -241,12 +248,12 @@ function installCopilot() {
|
|
|
241
248
|
try {
|
|
242
249
|
codereview();
|
|
243
250
|
} catch (error) {
|
|
244
|
-
|
|
251
|
+
dingding("CRITICAL", "CI ERROR: 未知错误,请自行检查日志");
|
|
245
252
|
throw error;
|
|
246
253
|
}
|
|
247
|
-
function codereview() {
|
|
248
|
-
deploy();
|
|
249
|
-
if (!need()) {
|
|
254
|
+
async function codereview() {
|
|
255
|
+
await deploy();
|
|
256
|
+
if (!await need()) {
|
|
250
257
|
console.log("重复提交,进程跳过");
|
|
251
258
|
return;
|
|
252
259
|
}
|
|
@@ -267,23 +274,12 @@ Otherwise, use chinese as default language to call the mcp tool '${name}-${repor
|
|
|
267
274
|
"pipe",
|
|
268
275
|
"pipe"
|
|
269
276
|
],
|
|
270
|
-
env: {
|
|
271
|
-
...env,
|
|
272
|
-
NODE_NO_WARNINGS: "1",
|
|
273
|
-
PYTHONUNBUFFERED: "1"
|
|
274
|
-
},
|
|
275
277
|
...platform === "win32" && { windowsHide: true }
|
|
276
278
|
});
|
|
277
|
-
copilot.stdout.
|
|
278
|
-
copilot.stderr.
|
|
279
|
-
copilot.stdout.on("data", (chunk) => {
|
|
280
|
-
process.stdout.write(chunk);
|
|
281
|
-
});
|
|
282
|
-
copilot.stderr.on("data", (chunk) => {
|
|
283
|
-
process.stderr.write(chunk);
|
|
284
|
-
});
|
|
279
|
+
copilot.stdout.on("data", (chunk) => console.log(String(chunk)));
|
|
280
|
+
copilot.stderr.on("data", (chunk) => console.error(String(chunk)));
|
|
285
281
|
copilot.on("close", (code) => {
|
|
286
|
-
|
|
282
|
+
if (!code) dingding("CRITICAL", "CI ERROR: 代码审查任务失败,请自行检查日志");
|
|
287
283
|
exit(code);
|
|
288
284
|
});
|
|
289
285
|
}
|