koishi-plugin-minecraft-notifier 1.2.3 → 1.3.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.
Files changed (2) hide show
  1. package/lib/index.cjs +26 -9
  2. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -125,14 +125,10 @@ var import_node_path = __toESM(require("node:path"), 1);
125
125
  var import_axios = __toESM(require("axios"), 1);
126
126
  async function upsertFileToGitee(owner, repo, path3, content, message, token, branch = "master") {
127
127
  const base64Content = Buffer.from(content, "utf-8").toString("base64");
128
- const checkUrl = `https://gitee.com/api/v5/repos/${owner}/${repo}/contents/${path3}?ref=${branch}`;
128
+ const checkUrl = `https://gitee.com/api/v5/repos/${owner}/${repo}/contents/${path3}?ref=${branch}&access_token=${token}`;
129
129
  let fileSha = null;
130
130
  try {
131
- const checkResponse = await import_axios.default.get(checkUrl, {
132
- headers: {
133
- Authorization: `token ${token}`
134
- }
135
- });
131
+ const checkResponse = await import_axios.default.get(checkUrl);
136
132
  if (checkResponse.status === 200) {
137
133
  fileSha = checkResponse.data.sha;
138
134
  } else {
@@ -145,13 +141,13 @@ async function upsertFileToGitee(owner, repo, path3, content, message, token, br
145
141
  const createResponse = await import_axios.default.post(
146
142
  createUrl,
147
143
  {
144
+ access_token: token,
148
145
  content: base64Content,
149
146
  message,
150
147
  branch
151
148
  },
152
149
  {
153
150
  headers: {
154
- Authorization: `token ${token}`,
155
151
  "Content-Type": "application/json"
156
152
  }
157
153
  }
@@ -184,6 +180,7 @@ async function upsertFileToGitee(owner, repo, path3, content, message, token, br
184
180
  const updateResponse = await import_axios.default.put(
185
181
  updateUrl,
186
182
  {
183
+ access_token: token,
187
184
  content: base64Content,
188
185
  sha: fileSha,
189
186
  message,
@@ -191,7 +188,6 @@ async function upsertFileToGitee(owner, repo, path3, content, message, token, br
191
188
  },
192
189
  {
193
190
  headers: {
194
- Authorization: `token ${token}`,
195
191
  "Content-Type": "application/json"
196
192
  }
197
193
  }
@@ -357,6 +353,27 @@ async function exportXaml(ctx, cfg, summary, version) {
357
353
  `feat: update PCL HomePage XAML for version ${version}`,
358
354
  cfg.giteeApiToken,
359
355
  "master"
356
+ ).then((result) => {
357
+ if (result.success) {
358
+ ctx.logger("minecraft-notifier").info(
359
+ "Upsert successful:",
360
+ result.data?.data
361
+ );
362
+ } else {
363
+ ctx.logger("minecraft-notifier").warn(
364
+ "Upsert failed:",
365
+ result.error
366
+ );
367
+ }
368
+ });
369
+ await upsertFileToGitee(
370
+ cfg.giteeOwner,
371
+ cfg.giteeRepo,
372
+ "Custom.xaml.ini",
373
+ version,
374
+ `feat: update PCL HomePage XAML INI for version ${version}`,
375
+ cfg.giteeApiToken,
376
+ "master"
360
377
  );
361
378
  }
362
379
  return fullXamlPath;
@@ -757,7 +774,7 @@ function apply(ctx, cfg) {
757
774
  if (!import_fs.default.existsSync(xamlPath)) {
758
775
  import_fs.default.mkdirSync(xamlPath, { recursive: true });
759
776
  }
760
- ctx.server.get("/PCL", async (koaCtx) => {
777
+ ctx.server.get("/Custom.xaml", async (koaCtx) => {
761
778
  koaCtx.set("Content-Type", "application/xml; charset=utf-8");
762
779
  koaCtx.set(
763
780
  "Content-Disposition",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-minecraft-notifier",
3
3
  "description": "A Minecraft new version notification plugin, also featuring a PCL homepage.",
4
- "version": "1.2.3",
4
+ "version": "1.3.0",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",