notion-github 1.0.5 → 1.0.7
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/dist/cli.js +24 -28
- package/package.json +1 -1
package/dist/cli.js
CHANGED
@@ -4558,7 +4558,7 @@ var {
|
|
4558
4558
|
} = import_index.default;
|
4559
4559
|
|
4560
4560
|
// package.json
|
4561
|
-
var version = "1.0.
|
4561
|
+
var version = "1.0.7";
|
4562
4562
|
|
4563
4563
|
// src/commands/create/action.ts
|
4564
4564
|
var import_rest = require("@octokit/rest");
|
@@ -5949,32 +5949,31 @@ fetch.Promise = global.Promise;
|
|
5949
5949
|
var lib_default = fetch;
|
5950
5950
|
|
5951
5951
|
// src/utils/discord.ts
|
5952
|
-
async function sendDiscordNotification(webhookUrl, prTitle, prUrl, reviewers, lang = "en") {
|
5953
|
-
const
|
5954
|
-
|
5955
|
-
|
5956
|
-
|
5957
|
-
|
5958
|
-
|
5959
|
-
|
5960
|
-
|
5961
|
-
}
|
5962
|
-
|
5963
|
-
|
5952
|
+
async function sendDiscordNotification(webhookUrl, prTitle, prUrl, reviewers, lang = "en", template, discordReviewerMapping) {
|
5953
|
+
const defaultTemplate = {
|
5954
|
+
ko: ["# \u{1F389} \uC0C8\uB85C\uC6B4 PR\uC774 \uC0DD\uC131\uB418\uC5C8\uC2B5\uB2C8\uB2E4!", "## \uC81C\uBAA9", "> ${title}", "## \uB9C1\uD06C", "> ${url}", "${reviewers}"].join("\n"),
|
5955
|
+
en: ["# \u{1F389} New PR Created!", "## Title", "> ${title}", "## Link", "> ${url}", "${reviewers}"].join("\n")
|
5956
|
+
};
|
5957
|
+
const selectedTemplate = template && template[lang] || defaultTemplate[lang];
|
5958
|
+
const mappedReviewers = reviewers?.map((reviewer) => {
|
5959
|
+
const discordId = discordReviewerMapping?.[reviewer];
|
5960
|
+
return discordId ? `@${discordId}` : `@${reviewer}`;
|
5961
|
+
});
|
5962
|
+
let message = selectedTemplate.replace("${title}", prTitle).replace("${url}", prUrl).replace(
|
5963
|
+
"${reviewers}",
|
5964
|
+
mappedReviewers && mappedReviewers.length > 0 ? `## ${lang === "ko" ? "\uB9AC\uBDF0\uC5B4" : "Reviewers"}
|
5965
|
+
> ${mappedReviewers.join(", ")}` : ""
|
5966
|
+
);
|
5964
5967
|
try {
|
5965
5968
|
const response = await lib_default(webhookUrl, {
|
5966
5969
|
method: "POST",
|
5967
5970
|
headers: { "Content-Type": "application/json" },
|
5968
|
-
body: JSON.stringify(
|
5971
|
+
body: JSON.stringify({ content: message })
|
5969
5972
|
});
|
5970
5973
|
if (!response.ok) {
|
5971
|
-
const errorText = await response.text();
|
5972
|
-
console.error("Discord API Error:", errorText);
|
5973
5974
|
throw new Error(`Discord API returned ${response.status}`);
|
5974
5975
|
}
|
5975
|
-
console.log("Discord notification sent successfully");
|
5976
5976
|
} catch (error) {
|
5977
|
-
console.error("Discord notification error:", error);
|
5978
5977
|
throw new Error(lang === "ko" ? "\uB514\uC2A4\uCF54\uB4DC \uC54C\uB9BC \uC804\uC1A1 \uC2E4\uD328" : "Failed to send Discord notification");
|
5979
5978
|
}
|
5980
5979
|
}
|
@@ -5992,7 +5991,7 @@ async function action(options) {
|
|
5992
5991
|
}
|
5993
5992
|
options.repo = config.defaultRepository;
|
5994
5993
|
}
|
5995
|
-
const [owner, repo] = options.repo.split("/");
|
5994
|
+
const [owner, repo] = (options.repo || config.defaultRepository || "").split("/");
|
5996
5995
|
const octokit = new import_rest.Octokit({ auth: config.githubToken });
|
5997
5996
|
if (!owner || !repo) {
|
5998
5997
|
console.error(getMessage("repoFormatError", lang));
|
@@ -6045,35 +6044,32 @@ ${error.message}`);
|
|
6045
6044
|
}
|
6046
6045
|
}
|
6047
6046
|
}
|
6048
|
-
console.log(getMessage("prCreateSuccess", lang, response.data.html_url));
|
6049
6047
|
if (config.discordWebhook) {
|
6050
|
-
console.log("Discord webhook URL:", config.discordWebhook);
|
6051
6048
|
try {
|
6052
6049
|
await sendDiscordNotification(
|
6053
6050
|
config.discordWebhook,
|
6054
6051
|
options.title,
|
6055
6052
|
response.data.html_url,
|
6056
6053
|
config.defaultReviewers,
|
6057
|
-
lang
|
6054
|
+
lang,
|
6055
|
+
config.discordTemplate,
|
6056
|
+
config.discordReviewerMapping
|
6058
6057
|
);
|
6059
6058
|
console.log(getMessage("discordNotificationSent", lang));
|
6060
6059
|
} catch (error) {
|
6061
|
-
console.error("Discord error:", error);
|
6062
6060
|
console.error(getMessage("discordNotificationFailed", lang, error.message));
|
6063
6061
|
}
|
6064
6062
|
}
|
6063
|
+
console.log(getMessage("prCreateSuccess", lang, response.data.html_url));
|
6065
6064
|
} catch (e) {
|
6066
|
-
console.error("Full error:", e);
|
6067
|
-
console.error("Status:", e.status);
|
6068
|
-
console.error("Response:", e.response?.data);
|
6069
6065
|
if (e.message.includes("Bad credentials")) {
|
6070
6066
|
console.error(getMessage("invalidToken", lang));
|
6071
6067
|
} else if (e.message.includes("Not Found")) {
|
6072
6068
|
console.error(getMessage("accessError", lang));
|
6073
6069
|
console.error(getMessage("checkToken", lang));
|
6074
|
-
console.error(getMessage("checkRepo", lang
|
6070
|
+
console.error(getMessage("checkRepo", lang));
|
6075
6071
|
} else {
|
6076
|
-
console.error(
|
6072
|
+
console.error(e.message);
|
6077
6073
|
}
|
6078
6074
|
process.exit(1);
|
6079
6075
|
}
|