notion-github 0.1.12 → 0.1.14

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +39 -36
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -53,7 +53,7 @@ MIT
53
53
 
54
54
  ## 설정
55
55
 
56
- 1. 디렉토리에 `notion_github_config.json` 파일을 생성합니다:
56
+ 1. 프로젝트 디렉토리에 `ng-config.json` 파일을 생성합니다:
57
57
 
58
58
  ```json
59
59
  {
package/dist/cli.js CHANGED
@@ -2789,7 +2789,7 @@ var {
2789
2789
  } = import_index.default;
2790
2790
 
2791
2791
  // package.json
2792
- var version = "0.1.12";
2792
+ var version = "0.1.14";
2793
2793
 
2794
2794
  // src/commands/create/action.ts
2795
2795
  var import_rest = require("@octokit/rest");
@@ -2797,37 +2797,18 @@ var import_rest = require("@octokit/rest");
2797
2797
  // src/utils/config.ts
2798
2798
  var import_fs = __toESM(require("fs"));
2799
2799
  var import_path = __toESM(require("path"));
2800
- var import_os = __toESM(require("os"));
2801
2800
  var CONFIG_FILE = "ng-config.json";
2802
2801
  function readConfig() {
2803
- console.log("=== Debug Information ===");
2804
- console.log("Current working directory:", process.cwd());
2805
- console.log("Home directory:", import_os.default.homedir());
2806
2802
  try {
2807
2803
  const currentDirPath = import_path.default.join(process.cwd(), CONFIG_FILE);
2808
- const homeDirPath = import_path.default.join(import_os.default.homedir(), CONFIG_FILE);
2809
- console.log("\nSearching for config file at:");
2810
- console.log("1.", currentDirPath);
2811
- console.log(" Exists:", import_fs.default.existsSync(currentDirPath));
2812
- console.log("2.", homeDirPath);
2813
- console.log(" Exists:", import_fs.default.existsSync(homeDirPath));
2814
- let configPath = "";
2815
2804
  if (import_fs.default.existsSync(currentDirPath)) {
2816
- configPath = currentDirPath;
2817
- console.log("\nUsing config from current directory");
2818
- } else if (import_fs.default.existsSync(homeDirPath)) {
2819
- configPath = homeDirPath;
2820
- console.log("\nUsing config from home directory");
2821
- } else {
2822
- throw new Error(
2823
- `Config file not found. Please create ${CONFIG_FILE} in your project directory or home directory.`
2824
- );
2825
- }
2826
- const config = JSON.parse(import_fs.default.readFileSync(configPath, "utf8"));
2827
- if (!config.githubToken) {
2828
- throw new Error("GitHub token not found in config file.");
2805
+ const config = JSON.parse(import_fs.default.readFileSync(currentDirPath, "utf8"));
2806
+ if (!config.githubToken) {
2807
+ throw new Error("GitHub token not found in config file.");
2808
+ }
2809
+ return config;
2829
2810
  }
2830
- return config;
2811
+ throw new Error(`Config file not found at ${currentDirPath}`);
2831
2812
  } catch (error) {
2832
2813
  if (error instanceof Error) {
2833
2814
  throw new Error(`Failed to read config: ${error.message}`);
@@ -2837,6 +2818,7 @@ function readConfig() {
2837
2818
  }
2838
2819
 
2839
2820
  // src/commands/create/action.ts
2821
+ var import_child_process = require("child_process");
2840
2822
  async function action(options) {
2841
2823
  try {
2842
2824
  const config = readConfig();
@@ -2845,19 +2827,40 @@ async function action(options) {
2845
2827
  if (!owner || !repo) {
2846
2828
  throw new Error("Invalid repository format. Use 'owner/repo' format.");
2847
2829
  }
2830
+ console.log("Checking and pushing branches...");
2831
+ try {
2832
+ console.log("Pushing main branch...");
2833
+ (0, import_child_process.execSync)("git push -u origin main", { stdio: "inherit" });
2834
+ console.log(`Pushing ${options.head} branch...`);
2835
+ (0, import_child_process.execSync)(`git push -u origin ${options.head}`, { stdio: "inherit" });
2836
+ } catch (error) {
2837
+ console.error("Failed to push branches:", error);
2838
+ throw new Error("Failed to push branches. Please ensure you have the correct permissions.");
2839
+ }
2848
2840
  console.log("Creating PR...");
2849
- const response = await octokit.pulls.create({
2850
- owner,
2851
- repo,
2852
- title: options.title,
2853
- head: options.head,
2854
- base: options.base || "main",
2855
- body: options.description
2856
- });
2857
- console.log(`PR created successfully: ${response.data.html_url}`);
2841
+ try {
2842
+ const response = await octokit.pulls.create({
2843
+ owner,
2844
+ repo,
2845
+ title: options.title,
2846
+ head: options.head,
2847
+ base: options.base || "main",
2848
+ body: options.description
2849
+ });
2850
+ console.log(`PR created successfully: ${response.data.html_url}`);
2851
+ } catch (e) {
2852
+ if (e.message.includes("Validation Failed")) {
2853
+ console.error("Failed to create PR: Please check if:");
2854
+ console.error("1. The source branch (--head) exists in the repository");
2855
+ console.error("2. The target branch (--base) exists in the repository");
2856
+ console.error("3. You have permission to create PRs in this repository");
2857
+ } else {
2858
+ throw e;
2859
+ }
2860
+ }
2858
2861
  } catch (error) {
2859
2862
  if (error instanceof Error) {
2860
- console.error("Failed to create PR:", error.message);
2863
+ console.error("Error:", error.message);
2861
2864
  } else {
2862
2865
  console.error("An unknown error occurred");
2863
2866
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notion-github",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "GitHub and Notion integration for PR automation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",