notion-rsync 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nonfx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # notion-rsync
2
+
3
+ One-way sync from Notion to local Markdown files. Fast, idempotent, and designed for docs-as-code workflows.
4
+
5
+ ```bash
6
+ # Sync your Notion workspace to markdown
7
+ notion-rsync sync --output ./docs
8
+ ```
9
+
10
+ ## Why?
11
+
12
+ - **Docs-as-code** - Keep your documentation in git, use your favorite editor, run CI/CD on it
13
+ - **LLM-friendly** - Export Notion content for RAG pipelines and AI context
14
+ - **Backup** - Simple, readable backups of your Notion workspace
15
+ - **Fast** - Parallel fetching with concurrency control
16
+ - **Idempotent** - Safe to run repeatedly, only overwrites what changed
17
+
18
+ ## Features
19
+
20
+ - Sync pages **and databases** (including nested databases)
21
+ - Preserves hierarchy as folder structure
22
+ - Rich frontmatter with all database properties
23
+ - Handles 20+ block types (text, lists, tables, code, callouts, toggles, equations, embeds...)
24
+ - Gracefully renders unsupported blocks (AI blocks, etc.) as HTML
25
+ - Dry-run mode for previewing changes
26
+ - Cleans up deleted pages automatically
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ # With npm
32
+ npm install -g notion-rsync
33
+
34
+ # With bun
35
+ bun add -g notion-rsync
36
+ ```
37
+
38
+ Or run directly without installing:
39
+
40
+ ```bash
41
+ npx notion-rsync sync --output ./docs
42
+ bunx notion-rsync sync --output ./docs
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ### 1. Create a Notion Integration
48
+
49
+ 1. Go to [notion.so/my-integrations](https://www.notion.so/my-integrations)
50
+ 2. Click "New integration"
51
+ 3. Give it a name and select your workspace
52
+ 4. Copy the "Internal Integration Secret"
53
+
54
+ ### 2. Share Your Page/Database
55
+
56
+ 1. Open the Notion page or database you want to sync
57
+ 2. Click "..." → "Add connections"
58
+ 3. Select your integration
59
+
60
+ ### 3. Initialize and Sync
61
+
62
+ ```bash
63
+ # Set your token
64
+ export NOTION_TOKEN="secret_abc123..."
65
+
66
+ # Get your page/database ID from the URL:
67
+ # https://notion.so/My-Page-abc123def456
68
+ # ^^^^^^^^^^^^^^^ this part
69
+
70
+ # Initialize (creates .notion-rsync config)
71
+ notion-rsync init abc123def456 --output ./docs
72
+
73
+ # Run sync
74
+ notion-rsync sync --output ./docs
75
+
76
+ # Or preview first
77
+ notion-rsync sync --output ./docs --dry-run
78
+ ```
79
+
80
+ ## Output Structure
81
+
82
+ ```
83
+ docs/
84
+ ├── .notion-rsync/
85
+ │ └── index.json # Sync state (tracks pages for cleanup)
86
+ ├── my-database/
87
+ │ ├── index.md # Database root (if it has content)
88
+ │ ├── page-one.md
89
+ │ ├── page-two/
90
+ │ │ ├── index.md # Pages with children become folders
91
+ │ │ └── nested-page.md
92
+ │ └── child-database/
93
+ │ ├── index.md
94
+ │ └── entry.md
95
+ └── standalone-page.md
96
+ ```
97
+
98
+ ## Generated Markdown
99
+
100
+ Each file includes:
101
+
102
+ ```markdown
103
+ <!--
104
+ Auto-generated by notion-rsync. Do not edit manually.
105
+ Changes will be overwritten on next sync.
106
+ -->
107
+ ---
108
+ notion_id: abc123-def456
109
+ title: "My Page Title"
110
+ last_edited: 2024-01-15T10:30:00.000Z
111
+ status: "In Progress" # Database properties
112
+ priority: "P1" # are included in
113
+ assignee: "John Doe" # frontmatter
114
+ tags: ["feature", "urgent"]
115
+ ---
116
+
117
+ # My Page Title
118
+
119
+ Your content here...
120
+ ```
121
+
122
+ ## Commands
123
+
124
+ ### `init <page-id>`
125
+
126
+ Initialize sync configuration for a Notion page or database.
127
+
128
+ ```bash
129
+ notion-rsync init abc123def456 --output ./docs
130
+ ```
131
+
132
+ ### `sync`
133
+
134
+ Sync content from Notion to local markdown files.
135
+
136
+ ```bash
137
+ notion-rsync sync --output ./docs [--dry-run]
138
+ ```
139
+
140
+ Options:
141
+ - `--output, -o` - Output directory (default: ./docs)
142
+ - `--dry-run, -n` - Preview changes without writing files
143
+ - `--verbose, -v` - Enable verbose logging
144
+
145
+ ### `status`
146
+
147
+ Show sync status and configuration.
148
+
149
+ ```bash
150
+ notion-rsync status --output ./docs
151
+ ```
152
+
153
+ ## Environment Variables
154
+
155
+ | Variable | Description |
156
+ |----------|-------------|
157
+ | `NOTION_TOKEN` | Notion API integration token (required) |
158
+
159
+ ## Supported Block Types
160
+
161
+ | Block Type | Markdown Output |
162
+ |------------|-----------------|
163
+ | Paragraph | Plain text |
164
+ | Headings (1-3) | `#`, `##`, `###` |
165
+ | Bulleted list | `- item` |
166
+ | Numbered list | `1. item` |
167
+ | To-do | `- [ ]` / `- [x]` |
168
+ | Toggle | `<details><summary>` |
169
+ | Code | Fenced code blocks |
170
+ | Quote | `> blockquote` |
171
+ | Callout | `> emoji text` |
172
+ | Divider | `---` |
173
+ | Table | Markdown tables |
174
+ | Image | `![alt](url)` |
175
+ | Video/File/PDF | `[name](url)` |
176
+ | Bookmark | `[title](url)` |
177
+ | Embed | `[title](url)` |
178
+ | Equation | `$$latex$$` |
179
+ | Columns | Sequential blocks |
180
+ | Synced block | Resolved content |
181
+ | Child page | Link |
182
+ | Child database | Recursed |
183
+
184
+ ## Supported Property Types
185
+
186
+ All Notion database property types are extracted to frontmatter:
187
+
188
+ - Text, Number, Checkbox, URL, Email, Phone
189
+ - Select, Multi-select, Status
190
+ - Date (with ranges)
191
+ - People, Files
192
+ - Formula, Relation, Rollup
193
+ - Created/Last edited time and by
194
+ - Unique ID
195
+
196
+ ## Development
197
+
198
+ ```bash
199
+ # Clone
200
+ git clone https://github.com/nonfx/notion-rsync.git
201
+ cd notion-rsync
202
+
203
+ # Install dependencies
204
+ bun install
205
+
206
+ # Run locally
207
+ bun run dev sync --output ./test-output
208
+
209
+ # Build
210
+ bun run build
211
+
212
+ # Lint & format
213
+ bun run lint
214
+ bun run format
215
+ ```
216
+
217
+ ## Roadmap
218
+
219
+ - [ ] Progress indicators
220
+ - [ ] Configuration file support
221
+ - [ ] Retry logic for rate limits
222
+ - [ ] Image downloading (optional)
223
+ - [ ] Two-way sync (future)
224
+
225
+ ## License
226
+
227
+ MIT