@d5render/cli 0.1.1 → 0.1.4
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/CHANGELOG.md +8 -3
- package/bin/CHANGELOG.md +1 -3
- package/bin/d5cli +21 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/bin/CHANGELOG.md
CHANGED
package/bin/d5cli
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync, spawn } from "node:child_process";
|
|
3
|
-
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync,
|
|
3
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
|
-
import { argv, env,
|
|
5
|
+
import { argv, env, platform } from "node:process";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name = "@d5render/cli";
|
|
10
|
-
var version = "0.1.
|
|
10
|
+
var version = "0.1.4";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region copilot/server/config.ts
|
|
@@ -116,17 +116,21 @@ function send(title, text) {
|
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region copilot/bin/deploy.ts
|
|
118
118
|
const root = () => {
|
|
119
|
-
const dir = env.HOME
|
|
119
|
+
const dir = env.HOME ?? env.HOMEPATH;
|
|
120
120
|
if (!dir) throw new Error("cannot find home directory");
|
|
121
121
|
return dir;
|
|
122
122
|
};
|
|
123
123
|
const cwd = join(dirname(fileURLToPath(import.meta.url)), "../");
|
|
124
124
|
function deploy() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
if (env.CI) {
|
|
126
|
+
const cl = join(cwd, "bin/CHANGELOG.md");
|
|
127
|
+
const clt = existsSync(cl) ? readFileSync(cl, "utf8") : "";
|
|
128
|
+
const clr = join(cwd, name.split("/").map(() => "..").join("/"), `${name.replaceAll("/", "-")}-notice`);
|
|
129
|
+
let need = !!clt;
|
|
130
|
+
if (existsSync(clr)) {
|
|
131
|
+
if (readFileSync(clr, "utf8") === version) need = false;
|
|
132
|
+
}
|
|
133
|
+
if (need && env.DINGTALK_WEBHOOK) send("NOTICE", `#### cli upgrade\n\n${clt}\n\n##### [HISTORY CHANGELOG](https://www.npmjs.com/package/${name}/v/${version}?activeTab=code)`).then(() => writeFileSync(clr, version)).catch(() => {});
|
|
130
134
|
}
|
|
131
135
|
const dir = join(root(), ".copilot/skills/codereview");
|
|
132
136
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
@@ -227,20 +231,24 @@ function installCopilot() {
|
|
|
227
231
|
|
|
228
232
|
//#endregion
|
|
229
233
|
//#region copilot/bin/index.ts
|
|
230
|
-
|
|
234
|
+
const prompt = `call the mcp tool '${name$1}-${getHash}' to load review commits, if the task encounters an error, throw that, otherwise, you can decide for yourself which tools to use to enrich context and determine whether a specific commit needs to be reviewed.
|
|
235
|
+
Then, use chinese as default language to organize the report into JSON format and call the mcp tool '${name$1}-${report}', please ignore error encountered when calling this and report title should not contain words such as MCP or "中文".`;
|
|
236
|
+
deploy();
|
|
237
|
+
if (canireview()) {
|
|
231
238
|
install();
|
|
232
239
|
const copilot = spawn("node", [
|
|
233
240
|
findCopilopt(),
|
|
234
241
|
...tools,
|
|
242
|
+
"--stream",
|
|
243
|
+
"off",
|
|
235
244
|
"-p",
|
|
236
245
|
prompt
|
|
237
246
|
], {
|
|
238
247
|
cwd: env.CI_PROJECT_DIR,
|
|
239
248
|
...platform === "win32" && { windowsHide: true }
|
|
240
249
|
});
|
|
241
|
-
copilot.stdout.on("data", (data) => console.log(
|
|
242
|
-
copilot.stderr.on("data", (data) => console.error(
|
|
243
|
-
copilot.on("close", (code) => exit(code));
|
|
250
|
+
copilot.stdout.on("data", (data) => console.log(data.toString()));
|
|
251
|
+
copilot.stderr.on("data", (data) => console.error(data.toString()));
|
|
244
252
|
}
|
|
245
253
|
function findCopilopt() {
|
|
246
254
|
let copilot = execSync("npm list @github/copilot -g -p").toString().trim();
|
|
@@ -265,9 +273,5 @@ copilot:
|
|
|
265
273
|
path: ${copilotPath}`);
|
|
266
274
|
return copilotPath;
|
|
267
275
|
}
|
|
268
|
-
const prompt = `call the mcp tool '${name$1}-${getHash}' to load review commits, if the task encounters an error, throw that, otherwise, you can decide for yourself which tools to use to enrich context and determine whether a specific commit needs to be reviewed.
|
|
269
|
-
Then, use chinese as default language to organize the report into JSON format and call the mcp tool '${name$1}-${report}', please ignore error encountered when calling this and report title should not contain words such as MCP or "中文".`;
|
|
270
|
-
deploy();
|
|
271
|
-
if (canireview()) review();
|
|
272
276
|
|
|
273
277
|
//#endregion
|