koishi-plugin-minecraft-notifier 1.2.3 → 1.2.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/lib/index.cjs +17 -9
- 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,7 +353,19 @@ async function exportXaml(ctx, cfg, summary, version) {
|
|
|
357
353
|
`feat: update PCL HomePage XAML for version ${version}`,
|
|
358
354
|
cfg.giteeApiToken,
|
|
359
355
|
"master"
|
|
360
|
-
)
|
|
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
|
+
});
|
|
361
369
|
}
|
|
362
370
|
return fullXamlPath;
|
|
363
371
|
}
|
package/package.json
CHANGED