notion-github 1.0.4 → 1.0.6
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 +26 -26
- 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.6";
|
|
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));
|
|
@@ -6017,6 +6016,8 @@ ${error.message}`);
|
|
|
6017
6016
|
}
|
|
6018
6017
|
console.log(getMessage("creatingPR", lang));
|
|
6019
6018
|
try {
|
|
6019
|
+
console.log("Config:", config);
|
|
6020
|
+
console.log("Creating PR with options:", options);
|
|
6020
6021
|
const response = await octokit.pulls.create({
|
|
6021
6022
|
owner,
|
|
6022
6023
|
repo,
|
|
@@ -6043,33 +6044,32 @@ ${error.message}`);
|
|
|
6043
6044
|
}
|
|
6044
6045
|
}
|
|
6045
6046
|
}
|
|
6046
|
-
console.log(getMessage("prCreateSuccess", lang, response.data.html_url));
|
|
6047
6047
|
if (config.discordWebhook) {
|
|
6048
|
-
console.log("Discord webhook URL:", config.discordWebhook);
|
|
6049
6048
|
try {
|
|
6050
6049
|
await sendDiscordNotification(
|
|
6051
6050
|
config.discordWebhook,
|
|
6052
6051
|
options.title,
|
|
6053
6052
|
response.data.html_url,
|
|
6054
6053
|
config.defaultReviewers,
|
|
6055
|
-
lang
|
|
6054
|
+
lang,
|
|
6055
|
+
config.discordTemplate,
|
|
6056
|
+
config.discordReviewerMapping
|
|
6056
6057
|
);
|
|
6057
6058
|
console.log(getMessage("discordNotificationSent", lang));
|
|
6058
6059
|
} catch (error) {
|
|
6059
|
-
console.error("Discord error:", error);
|
|
6060
6060
|
console.error(getMessage("discordNotificationFailed", lang, error.message));
|
|
6061
6061
|
}
|
|
6062
6062
|
}
|
|
6063
|
+
console.log(getMessage("prCreateSuccess", lang, response.data.html_url));
|
|
6063
6064
|
} catch (e) {
|
|
6064
|
-
console.error("Error details:", e);
|
|
6065
6065
|
if (e.message.includes("Bad credentials")) {
|
|
6066
6066
|
console.error(getMessage("invalidToken", lang));
|
|
6067
6067
|
} else if (e.message.includes("Not Found")) {
|
|
6068
6068
|
console.error(getMessage("accessError", lang));
|
|
6069
6069
|
console.error(getMessage("checkToken", lang));
|
|
6070
|
-
console.error(getMessage("checkRepo", lang
|
|
6070
|
+
console.error(getMessage("checkRepo", lang));
|
|
6071
6071
|
} else {
|
|
6072
|
-
console.error(
|
|
6072
|
+
console.error(e.message);
|
|
6073
6073
|
}
|
|
6074
6074
|
process.exit(1);
|
|
6075
6075
|
}
|