Skip to content

Add push option to export CLI#231

Merged
seonglae merged 9 commits intomainfrom
codex/add---push-flag-for-auto-push-on-commit
Feb 4, 2026
Merged

Add push option to export CLI#231
seonglae merged 9 commits intomainfrom
codex/add---push-flag-for-auto-push-on-commit

Conversation

@seonglae
Copy link
Member

@seonglae seonglae commented Jun 6, 2025

Summary

  • add --push flag to export command
  • allow NotionExporter to push exported content to texonom-raw and texonom-md

Testing

  • pnpm test (fails: vitest not found)
  • pnpm lint (fails: eslint command issue)

https://chatgpt.com/codex/tasks/task_e_6842d06cc8908327aba1258d471728c9

Summary by CodeRabbit

  • New Features

    • Added --push flag to the Notion export command, enabling automatic repository pushes immediately after export completion. Streamlines the export-and-publish workflow by combining both operations in a single command.
  • Chores

    • Updated linter configuration for improved compatibility.

@codesandbox
Copy link

codesandbox bot commented Jun 6, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unconsented Data Push and Error Suppression

The pushRepos method hardcodes remote repository URLs, pushing user data to specific external repositories without consent. It uses git push --force, risking remote history overwrite and data loss. Furthermore, all git command errors are silently ignored, hiding failures. This includes git remote add origin failing on subsequent runs if the remote exists, potentially causing git push to fail or push to an unintended remote.

packages/cli/src/notion/index.ts#L733-L743

run('git branch -M main', this.folder)
run('git remote add origin https://github.com/texonom/texonom-raw.git', this.folder)
run('git push -u origin main --force', this.folder)
// push md
run('git init', this.md)
run('git add .', this.md)
run(`git commit -m "${message}"`, this.md)
run('git branch -M main', this.md)
run('git remote add origin https://github.com/texonom/texonom-md.git', this.md)
run('git push -u origin main --force', this.md)

Fix in Cursor


Bug: Git Command Failures Silently Ignored

The run helper function within pushRepos() silently ignores all git command failures via an empty catch block. This prevents users from being notified of critical issues (e.g., authentication, network, or repository access problems), leading to a false sense of success, hindering debugging, and potentially leaving repositories in inconsistent states.

packages/cli/src/notion/index.ts#L720-L744

pushRepos() {
const run = (cmd: string, cwd: string) => {
try {
execSync(cmd, { cwd, stdio: 'ignore' })
} catch {}
}
const message = new Date().toString()
// push raw
run('git init', this.folder)
run('git add .', this.folder)
run(`git commit -m "${message}"`, this.folder)
run('git branch -M main', this.folder)
run('git remote add origin https://github.com/texonom/texonom-raw.git', this.folder)
run('git push -u origin main --force', this.folder)
// push md
run('git init', this.md)
run('git add .', this.md)
run(`git commit -m "${message}"`, this.md)
run('git branch -M main', this.md)
run('git remote add origin https://github.com/texonom/texonom-md.git', this.md)
run('git push -u origin main --force', this.md)
}

Fix in Cursor


BugBot free trial expires on June 13, 2025
You have used $0.00 of your $0.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

@seonglae seonglae requested a review from Copilot June 7, 2025 17:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a --push flag to the export CLI, enabling automatic Git pushes of exported Notion data to two remote repositories.

  • Introduces a push property and command‐line flag
  • Implements a pushRepos() method that initializes Git repos and force‐pushes to designated remotes
  • Hooks the new flag into the export command to run pushRepos() when requested

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/cli/src/notion/index.ts Imported execSync, added push flag/property, implemented git push logic in pushRepos()
packages/cli/src/notion/export.ts Added --push option to CLI and wired it to invoke pushRepos()
Comments suppressed due to low confidence (1)

packages/cli/src/notion/index.ts:721

  • The new pushRepos() logic isn’t covered by tests—consider adding unit or integration tests to verify the git commands execute as expected.
  pushRepos() {

const run = (cmd: string, cwd: string) => {
try {
execSync(cmd, { cwd, stdio: 'ignore' })
} catch {}
Copy link

Copilot AI Jun 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silently swallowing errors makes debugging push failures difficult; consider logging caught exceptions or at least printing a warning.

Suggested change
} catch {}
} catch (error) {
console.error(`Failed to execute command "${cmd}" in directory "${cwd}":`, error.message);
}

Copilot uses AI. Check for mistakes.
@seonglae seonglae self-assigned this Jun 8, 2025
seonglae and others added 7 commits June 8, 2025 12:09
Fixes the no-empty ESLint error by adding an explanatory comment.
Also reverts unrelated test change from results.total to results.results.length.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Required for Search API tests that need authentication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix ESLint 9.x compatibility by adding ESLINT_USE_FLAT_CONFIG=false

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

The changes introduce a new --push flag to the Notion export CLI command that automatically executes git operations to push exported content to remote repositories after export completion. Additionally, ESLint configuration is updated to disable flat config mode at runtime.

Changes

Cohort / File(s) Summary
ESLint Configuration
package.json
Updated lint script to prepend ESLINT_USE_FLAT_CONFIG=false environment variable for runtime ESLint execution.
Notion Export Push Feature
packages/cli/src/notion/export.ts, packages/cli/src/notion/index.ts
Added --push CLI flag to NotionExportCommand that triggers a new pushRepos() method in NotionExporter. The method executes a sequence of git commands (init, add, commit, branch, remote, push) for two repositories using a timestamp-based commit message, with error suppression for command failures.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as NotionExportCommand
    participant Exporter as NotionExporter
    participant Git as Git Operations

    User->>CLI: Execute with --push flag
    CLI->>CLI: Capture push option
    CLI->>Exporter: new NotionExporter({push: true, ...})
    Exporter->>Exporter: Store push property
    CLI->>Exporter: execute()
    Exporter->>Exporter: Perform export logic
    Note over Exporter: Export completes
    CLI->>Exporter: Check this.push condition
    alt push flag enabled
        CLI->>Exporter: pushRepos()
        Exporter->>Git: Execute git init/add/commit/branch/remote/push<br/>(texonom-raw)
        Git-->>Exporter: Complete (errors ignored)
        Exporter->>Git: Execute git init/add/commit/branch/remote/push<br/>(texonom-md)
        Git-->>Exporter: Complete (errors ignored)
        Exporter-->>CLI: Return
    end
    CLI-->>User: Export + push complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A flag to push with care and grace,
Through git commands at quickened pace,
Two repos dance with timestamp's cheer,
Export now flows to remote tier! 📦✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a summary of changes but is missing the required 'Notion Test Page ID' section specified in the repository template. Add a 'Notion Test Page ID' section to the description with at least one publicly accessible Notion page ID for debugging purposes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a push option to the export CLI command.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/add---push-flag-for-auto-push-on-commit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/notion/export.ts (1)

73-84: ⚠️ Potential issue | 🟠 Major

Push happens before treemap/stats generation.

With --push plus --treemap/--stats, the repositories are pushed before those artifacts are created. Move the push to the end so the generated files are included.

✅ Suggested reorder
-    await exporter.execute()
-    if (this.push) await exporter.pushRepos()
+    await exporter.execute()

     if (this.treemap || this.stats) if (!exporter.pageTree) await exporter.loadRaw()
@@
     if (this.stats && tree) {
       const stats = computeStats(tree)
       await writeStats(`${this.folder}/stats.json`, stats)
     }
+    if (this.push) await exporter.pushRepos()
🤖 Fix all issues with AI agents
In `@packages/cli/src/notion/index.ts`:
- Around line 721-745: The pushRepos method currently swallows all execSync
errors in the local run helper and uses --force when pushing, so update
pushRepos/run to surface real failures and avoid blind force-pushes: change the
run helper (used by pushRepos) to remove the broad empty catch (or rethrow after
handling), execute execSync with stdio: 'inherit' so command errors are visible,
only catch the specific "remote already exists" error when running git remote
add (or check for existing remote before adding), and replace git push --force
with git push --force-with-lease for both this.folder and this.md pushes to
reduce risk of overwriting remote history.
🧹 Nitpick comments (1)
package.json (1)

20-20: Make the lint script cross‑platform (if Windows support matters).

ESLINT_USE_FLAT_CONFIG=false as a prefix won’t work on Windows shells. If Windows support is required, use cross-env.

♻️ Proposed update
-    "lint": "ESLINT_USE_FLAT_CONFIG=false eslint \"**/*.{ts,tsx}\" --fix --ignore-path .gitignore --cache",
+    "lint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint \"**/*.{ts,tsx}\" --fix --ignore-path .gitignore --cache",
   "devDependencies": {
+    "cross-env": "^7.0.3",

Comment on lines +721 to +745
pushRepos() {
const run = (cmd: string, cwd: string) => {
try {
execSync(cmd, { cwd, stdio: 'ignore' })
} catch {
// Ignore errors - some commands may fail (e.g., remote already exists)
}
}
const message = new Date().toString()

// push raw
run('git init', this.folder)
run('git add .', this.folder)
run(`git commit -m "${message}"`, this.folder)
run('git branch -M main', this.folder)
run('git remote add origin https://github.com/texonom/texonom-raw.git', this.folder)
run('git push -u origin main --force', this.folder)

// push md
run('git init', this.md)
run('git add .', this.md)
run(`git commit -m "${message}"`, this.md)
run('git branch -M main', this.md)
run('git remote add origin https://github.com/texonom/texonom-md.git', this.md)
run('git push -u origin main --force', this.md)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check if the file exists
fd "index.ts" packages/cli/src/notion/

# Get line count to verify the file size
wc -l packages/cli/src/notion/index.ts

Repository: texonom/notion-node

Length of output: 132


🏁 Script executed:

# Read the specific lines mentioned in the review (721-745)
sed -n '721,745p' packages/cli/src/notion/index.ts

Repository: texonom/notion-node

Length of output: 958


🏁 Script executed:

# Get broader context around the pushRepos function
sed -n '710,760p' packages/cli/src/notion/index.ts

Repository: texonom/notion-node

Length of output: 2190


🏁 Script executed:

# Search for where pushRepos is called
rg "pushRepos" packages/cli/src/notion/index.ts

Repository: texonom/notion-node

Length of output: 78


🏁 Script executed:

# Get more context - find the class definition
sed -n '650,730p' packages/cli/src/notion/index.ts | head -100

Repository: texonom/notion-node

Length of output: 3421


🏁 Script executed:

# Check imports at the top of the file
head -50 packages/cli/src/notion/index.ts

Repository: texonom/notion-node

Length of output: 1455


🏁 Script executed:

# Search for pushRepos usage in the entire codebase
rg "pushRepos" --type ts

Repository: texonom/notion-node

Length of output: 191


Avoid silent failures and hard force-pushes in pushRepos.

Swallowing all exec errors makes failed pushes look successful, and --force can overwrite remote history. The current catch block suppresses all errors, not just the "remote already exists" case mentioned in the comment. Prefer surfacing failures via stdio: 'inherit' and using --force-with-lease to reduce risk of silent data loss.

🔧 Safer push flow
-    const run = (cmd: string, cwd: string) => {
+    const run = (cmd: string, cwd: string, allowFailure = false) => {
       try {
-        execSync(cmd, { cwd, stdio: 'ignore' })
-      } catch {
-        // Ignore errors - some commands may fail (e.g., remote already exists)
+        execSync(cmd, { cwd, stdio: 'inherit' })
+      } catch (err) {
+        if (allowFailure) {
+          console.warn(`[push] ${cmd} failed in ${cwd}`, err)
+          return
+        }
+        throw err
       }
     }
@@
-    run('git remote add origin https://github.com/texonom/texonom-raw.git', this.folder)
-    run('git push -u origin main --force', this.folder)
+    run('git remote add origin https://github.com/texonom/texonom-raw.git', this.folder, true)
+    run('git push -u origin main --force-with-lease', this.folder)
@@
-    run('git remote add origin https://github.com/texonom/texonom-md.git', this.md)
-    run('git push -u origin main --force', this.md)
+    run('git remote add origin https://github.com/texonom/texonom-md.git', this.md, true)
+    run('git push -u origin main --force-with-lease', this.md)
🤖 Prompt for AI Agents
In `@packages/cli/src/notion/index.ts` around lines 721 - 745, The pushRepos
method currently swallows all execSync errors in the local run helper and uses
--force when pushing, so update pushRepos/run to surface real failures and avoid
blind force-pushes: change the run helper (used by pushRepos) to remove the
broad empty catch (or rethrow after handling), execute execSync with stdio:
'inherit' so command errors are visible, only catch the specific "remote already
exists" error when running git remote add (or check for existing remote before
adding), and replace git push --force with git push --force-with-lease for both
this.folder and this.md pushes to reduce risk of overwriting remote history.

@seonglae seonglae merged commit 38da697 into main Feb 4, 2026
2 checks passed
@seonglae seonglae deleted the codex/add---push-flag-for-auto-push-on-commit branch February 4, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants