notion-github 0.1.16 → 0.2.1

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/dist/cli.js +135 -38
  2. package/package.json +2 -1
package/dist/cli.js CHANGED
@@ -927,8 +927,8 @@ var require_command = __commonJS({
927
927
  "use strict";
928
928
  var EventEmitter = require("events").EventEmitter;
929
929
  var childProcess = require("child_process");
930
- var path2 = require("path");
931
- var fs2 = require("fs");
930
+ var path3 = require("path");
931
+ var fs3 = require("fs");
932
932
  var process2 = require("process");
933
933
  var { Argument: Argument2, humanReadableArgName } = require_argument();
934
934
  var { CommanderError: CommanderError2 } = require_error();
@@ -1751,10 +1751,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1751
1751
  let launchWithNode = false;
1752
1752
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1753
1753
  function findFile(baseDir, baseName) {
1754
- const localBin = path2.resolve(baseDir, baseName);
1755
- if (fs2.existsSync(localBin)) return localBin;
1756
- if (sourceExt.includes(path2.extname(baseName))) return void 0;
1757
- const foundExt = sourceExt.find((ext) => fs2.existsSync(`${localBin}${ext}`));
1754
+ const localBin = path3.resolve(baseDir, baseName);
1755
+ if (fs3.existsSync(localBin)) return localBin;
1756
+ if (sourceExt.includes(path3.extname(baseName))) return void 0;
1757
+ const foundExt = sourceExt.find((ext) => fs3.existsSync(`${localBin}${ext}`));
1758
1758
  if (foundExt) return `${localBin}${foundExt}`;
1759
1759
  return void 0;
1760
1760
  }
@@ -1765,23 +1765,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
1765
1765
  if (this._scriptPath) {
1766
1766
  let resolvedScriptPath;
1767
1767
  try {
1768
- resolvedScriptPath = fs2.realpathSync(this._scriptPath);
1768
+ resolvedScriptPath = fs3.realpathSync(this._scriptPath);
1769
1769
  } catch (err) {
1770
1770
  resolvedScriptPath = this._scriptPath;
1771
1771
  }
1772
- executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
1772
+ executableDir = path3.resolve(path3.dirname(resolvedScriptPath), executableDir);
1773
1773
  }
1774
1774
  if (executableDir) {
1775
1775
  let localFile = findFile(executableDir, executableFile);
1776
1776
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1777
- const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
1777
+ const legacyName = path3.basename(this._scriptPath, path3.extname(this._scriptPath));
1778
1778
  if (legacyName !== this._name) {
1779
1779
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1780
1780
  }
1781
1781
  }
1782
1782
  executableFile = localFile || executableFile;
1783
1783
  }
1784
- launchWithNode = sourceExt.includes(path2.extname(executableFile));
1784
+ launchWithNode = sourceExt.includes(path3.extname(executableFile));
1785
1785
  let proc;
1786
1786
  if (process2.platform !== "win32") {
1787
1787
  if (launchWithNode) {
@@ -2564,7 +2564,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2564
2564
  * @return {Command}
2565
2565
  */
2566
2566
  nameFromFilename(filename) {
2567
- this._name = path2.basename(filename, path2.extname(filename));
2567
+ this._name = path3.basename(filename, path3.extname(filename));
2568
2568
  return this;
2569
2569
  }
2570
2570
  /**
@@ -2578,9 +2578,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2578
2578
  * @param {string} [path]
2579
2579
  * @return {string|null|Command}
2580
2580
  */
2581
- executableDir(path3) {
2582
- if (path3 === void 0) return this._executableDir;
2583
- this._executableDir = path3;
2581
+ executableDir(path4) {
2582
+ if (path4 === void 0) return this._executableDir;
2583
+ this._executableDir = path4;
2584
2584
  return this;
2585
2585
  }
2586
2586
  /**
@@ -2789,7 +2789,7 @@ var {
2789
2789
  } = import_index.default;
2790
2790
 
2791
2791
  // package.json
2792
- var version = "0.1.16";
2792
+ var version = "0.2.1";
2793
2793
 
2794
2794
  // src/commands/create/action.ts
2795
2795
  var import_rest = require("@octokit/rest");
@@ -2806,7 +2806,11 @@ function readConfig() {
2806
2806
  if (!config.githubToken) {
2807
2807
  throw new Error("GitHub token not found in config file.");
2808
2808
  }
2809
- return config;
2809
+ return {
2810
+ ...config,
2811
+ language: config.language || "en"
2812
+ // 기본값 설정
2813
+ };
2810
2814
  }
2811
2815
  throw new Error(`Config file not found at ${currentDirPath}`);
2812
2816
  } catch (error) {
@@ -2819,33 +2823,94 @@ function readConfig() {
2819
2823
 
2820
2824
  // src/commands/create/action.ts
2821
2825
  var import_child_process = require("child_process");
2826
+
2827
+ // src/utils/messages.ts
2828
+ var messages = {
2829
+ repoFormatError: {
2830
+ en: "\nRepository format error:",
2831
+ ko: "\n\uB808\uD3EC\uC9C0\uD1A0\uB9AC \uD615\uC2DD \uC624\uB958:"
2832
+ },
2833
+ repoFormatExample: {
2834
+ en: "- Correct format: owner/repo",
2835
+ ko: "- \uC62C\uBC14\uB978 \uD615\uC2DD: owner/repo"
2836
+ },
2837
+ repoFormatSample: {
2838
+ en: "- Example: Ryokuman/testing",
2839
+ ko: "- \uC608\uC2DC: Ryokuman/testing"
2840
+ },
2841
+ checkingBranches: {
2842
+ en: "\nChecking and pushing branches...",
2843
+ ko: "\n\uBE0C\uB79C\uCE58 \uD655\uC778 \uBC0F push \uC911..."
2844
+ },
2845
+ pushingMainBranch: {
2846
+ en: "- Pushing main branch...",
2847
+ ko: "- main \uBE0C\uB79C\uCE58 push \uC911..."
2848
+ },
2849
+ pushingBranch: {
2850
+ en: "- Pushing %s branch...",
2851
+ ko: "- %s \uBE0C\uB79C\uCE58 push \uC911..."
2852
+ },
2853
+ branchPushError: {
2854
+ en: "\nBranch push failed:",
2855
+ ko: "\n\uBE0C\uB79C\uCE58 push \uC2E4\uD328:"
2856
+ },
2857
+ checkGitConfig: {
2858
+ en: "- Please check your git configuration",
2859
+ ko: "- git \uC124\uC815\uC774 \uC62C\uBC14\uB978\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694"
2860
+ },
2861
+ checkRepoPermission: {
2862
+ en: "- Check if you have push permission to the repository",
2863
+ ko: "- \uC6D0\uACA9 \uC800\uC7A5\uC18C\uC5D0 \uB300\uD55C push \uAD8C\uD55C\uC774 \uC788\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694"
2864
+ },
2865
+ checkBranchName: {
2866
+ en: "- Check if branch name contains special characters or spaces",
2867
+ ko: "- \uBE0C\uB79C\uCE58 \uC774\uB984\uC5D0 \uD2B9\uC218\uBB38\uC790\uB098 \uACF5\uBC31\uC774 \uC5C6\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694"
2868
+ },
2869
+ creatingPR: {
2870
+ en: "\nCreating PR...",
2871
+ ko: "\nPR \uC0DD\uC131 \uC911..."
2872
+ },
2873
+ repoNotFound: {
2874
+ en: "\nRepository not found:",
2875
+ ko: "\n\uB808\uD3EC\uC9C0\uD1A0\uB9AC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4:"
2876
+ }
2877
+ // ... 나머지 메시지들도 추가
2878
+ };
2879
+ function getMessage(key, lang = "en", ...args) {
2880
+ const message = messages[key]?.[lang] || messages[key]?.en || key;
2881
+ return args.length ? message.replace(/%s/g, () => args.shift()) : message;
2882
+ }
2883
+
2884
+ // src/commands/create/action.ts
2822
2885
  async function action(options) {
2886
+ let lang = "en";
2823
2887
  try {
2824
2888
  const config = readConfig();
2889
+ lang = config.language || "en";
2825
2890
  const octokit = new import_rest.Octokit({ auth: config.githubToken });
2826
2891
  const [owner, repo] = options.repo.split("/");
2827
2892
  if (!owner || !repo) {
2828
- console.error("\n\uB808\uD3EC\uC9C0\uD1A0\uB9AC \uD615\uC2DD \uC624\uB958:");
2829
- console.error("- \uC62C\uBC14\uB978 \uD615\uC2DD: owner/repo");
2830
- console.error("- \uC608\uC2DC: Ryokuman/testing");
2893
+ console.error(getMessage("repoFormatError", lang));
2894
+ console.error(getMessage("repoFormatExample", lang));
2895
+ console.error(getMessage("repoFormatSample", lang));
2831
2896
  process.exit(1);
2832
2897
  }
2833
- console.log("\n\uBE0C\uB79C\uCE58 \uD655\uC778 \uBC0F push \uC911...");
2898
+ console.log(getMessage("checkingBranches", lang));
2834
2899
  try {
2835
- console.log("- main \uBE0C\uB79C\uCE58 push \uC911...");
2900
+ console.log(getMessage("pushingMainBranch", lang));
2836
2901
  (0, import_child_process.execSync)("git push -u origin main", { stdio: "inherit" });
2837
- console.log(`- ${options.head} \uBE0C\uB79C\uCE58 push \uC911...`);
2902
+ console.log(getMessage("pushingBranch", lang, options.head));
2838
2903
  (0, import_child_process.execSync)(`git push -u origin ${options.head}`, { stdio: "inherit" });
2839
2904
  } catch (error) {
2840
- console.error("\n\uBE0C\uB79C\uCE58 push \uC2E4\uD328:");
2841
- console.error("- git \uC124\uC815\uC774 \uC62C\uBC14\uB978\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2842
- console.error("- \uC6D0\uACA9 \uC800\uC7A5\uC18C\uC5D0 \uB300\uD55C push \uAD8C\uD55C\uC774 \uC788\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2843
- console.error("- \uBE0C\uB79C\uCE58 \uC774\uB984\uC5D0 \uD2B9\uC218\uBB38\uC790\uB098 \uACF5\uBC31\uC774 \uC5C6\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2905
+ console.error(getMessage("branchPushError", lang));
2906
+ console.error(getMessage("checkGitConfig", lang));
2907
+ console.error(getMessage("checkRepoPermission", lang));
2908
+ console.error(getMessage("checkBranchName", lang));
2844
2909
  if (error instanceof Error) console.error(`
2845
- \uC0C1\uC138 \uC624\uB958: ${error.message}`);
2910
+ ${error.message}`);
2846
2911
  process.exit(1);
2847
2912
  }
2848
- console.log("\nPR \uC0DD\uC131 \uC911...");
2913
+ console.log(getMessage("creatingPR", lang));
2849
2914
  try {
2850
2915
  const response = await octokit.pulls.create({
2851
2916
  owner,
@@ -2859,20 +2924,20 @@ async function action(options) {
2859
2924
  \u2705 PR\uC774 \uC131\uACF5\uC801\uC73C\uB85C \uC0DD\uC131\uB418\uC5C8\uC2B5\uB2C8\uB2E4: ${response.data.html_url}`);
2860
2925
  } catch (e) {
2861
2926
  if (e.message.includes("Not Found")) {
2862
- console.error("\n\uB808\uD3EC\uC9C0\uD1A0\uB9AC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4:");
2927
+ console.error(getMessage("repoNotFound", lang));
2863
2928
  console.error(`- ${owner}/${repo} \uB808\uD3EC\uC9C0\uD1A0\uB9AC\uAC00 \uC874\uC7AC\uD558\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694`);
2864
2929
  console.error("- GitHub \uD1A0\uD070\uC774 \uD574\uB2F9 \uB808\uD3EC\uC9C0\uD1A0\uB9AC\uC5D0 \uC811\uADFC \uAD8C\uD55C\uC774 \uC788\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2865
2930
  } else if (e.message.includes("Validation Failed")) {
2866
- console.error("\n\uBE0C\uB79C\uCE58 \uAC80\uC99D \uC2E4\uD328:");
2931
+ console.error(getMessage("branchValidationFailed", lang));
2867
2932
  console.error(`- head \uBE0C\uB79C\uCE58(${options.head})\uAC00 \uC6D0\uACA9 \uC800\uC7A5\uC18C\uC5D0 \uC788\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694`);
2868
2933
  console.error(`- base \uBE0C\uB79C\uCE58(${options.base || "main"})\uAC00 \uC6D0\uACA9 \uC800\uC7A5\uC18C\uC5D0 \uC788\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694`);
2869
2934
  console.error("- \uC774\uBBF8 \uB3D9\uC77C\uD55C \uBE0C\uB79C\uCE58\uB85C \uC0DD\uC131\uB41C PR\uC774 \uC788\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2870
2935
  } else if (e.message.includes("Bad credentials")) {
2871
- console.error("\n\uC778\uC99D \uC2E4\uD328:");
2936
+ console.error(getMessage("authError", lang));
2872
2937
  console.error("- GitHub \uD1A0\uD070\uC774 \uC720\uD6A8\uD55C\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2873
2938
  console.error("- \uD1A0\uD070\uC774 \uB9CC\uB8CC\uB418\uC9C0 \uC54A\uC558\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2874
2939
  } else {
2875
- console.error("\n\uC54C \uC218 \uC5C6\uB294 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4:");
2940
+ console.error(getMessage("unknownError", lang));
2876
2941
  console.error(e.message);
2877
2942
  }
2878
2943
  process.exit(1);
@@ -2880,16 +2945,16 @@ async function action(options) {
2880
2945
  } catch (error) {
2881
2946
  if (error instanceof Error) {
2882
2947
  if (error.message.includes("git push")) {
2883
- console.error("\n\uBE0C\uB79C\uCE58 push \uC2E4\uD328:");
2884
- console.error("- git \uC124\uC815\uC774 \uC62C\uBC14\uB978\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2885
- console.error("- \uC6D0\uACA9 \uC800\uC7A5\uC18C\uC5D0 \uB300\uD55C push \uAD8C\uD55C\uC774 \uC788\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2886
- console.error("- \uBE0C\uB79C\uCE58 \uC774\uB984\uC5D0 \uD2B9\uC218\uBB38\uC790\uB098 \uACF5\uBC31\uC774 \uC5C6\uB294\uC9C0 \uD655\uC778\uD574\uC8FC\uC138\uC694");
2948
+ console.error(getMessage("branchPushError", lang));
2949
+ console.error(getMessage("checkGitConfig", lang));
2950
+ console.error(getMessage("checkRepoPermission", lang));
2951
+ console.error(getMessage("checkBranchName", lang));
2887
2952
  } else {
2888
- console.error("\n\uC608\uC0C1\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4:");
2953
+ console.error(getMessage("unexpectedError", lang));
2889
2954
  console.error(error.message);
2890
2955
  }
2891
2956
  } else {
2892
- console.error("\n\uC54C \uC218 \uC5C6\uB294 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4");
2957
+ console.error(getMessage("unknownError", lang));
2893
2958
  }
2894
2959
  process.exit(1);
2895
2960
  }
@@ -2927,8 +2992,40 @@ function registerCommands(program3) {
2927
2992
  debugCommand(program3);
2928
2993
  }
2929
2994
 
2995
+ // src/commands/init/action.ts
2996
+ var import_fs2 = __toESM(require("fs"));
2997
+ var import_path2 = __toESM(require("path"));
2998
+ async function action3(options) {
2999
+ try {
3000
+ const configPath = import_path2.default.join(process.cwd(), "ng-config.json");
3001
+ if (import_fs2.default.existsSync(configPath)) {
3002
+ console.error("ng-config.json already exists");
3003
+ process.exit(1);
3004
+ }
3005
+ const defaultConfig = {
3006
+ githubToken: options.token || "YOUR_GITHUB_TOKEN_HERE",
3007
+ language: options.language || "en"
3008
+ // 추가적인 기본 설정이 필요하다면 여기에 추가
3009
+ };
3010
+ import_fs2.default.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2) + "\n");
3011
+ console.log("Created ng-config.json successfully");
3012
+ if (!options.token) {
3013
+ console.log("\nPlease replace YOUR_GITHUB_TOKEN_HERE with your actual GitHub token in ng-config.json");
3014
+ }
3015
+ } catch (error) {
3016
+ console.error("Failed to create config file:", error);
3017
+ process.exit(1);
3018
+ }
3019
+ }
3020
+
3021
+ // src/commands/init/index.ts
3022
+ function initCommand(program3) {
3023
+ program3.command("init").description("Initialize configuration file").option("--token <token>", "GitHub token").option("--language <lang>", "Language setting (en|ko)", /^(en|ko)$/, "en").action(action3);
3024
+ }
3025
+
2930
3026
  // src/cli.ts
2931
3027
  var program2 = new Command();
2932
3028
  program2.name("pr-cli").description("A simple CLI tool").version(version);
3029
+ initCommand(program2);
2933
3030
  registerCommands(program2);
2934
3031
  program2.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notion-github",
3
- "version": "0.1.16",
3
+ "version": "0.2.1",
4
4
  "description": "GitHub and Notion integration for PR automation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -11,6 +11,7 @@
11
11
  "scripts": {
12
12
  "build": "tsup",
13
13
  "upload": "tsup && npm publish",
14
+ "version": "changeset version",
14
15
  "lint": "tsc"
15
16
  },
16
17
  "engines": {