copyhub-cli 1.0.0 → 1.0.3

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/.env.example CHANGED
@@ -1,24 +1,25 @@
1
- # Copy to .env and fill in values. CopyHub reads .env when you run the CLI from the current directory.
2
- #
3
- # Google Cloud Console → APIs: enable "Google Sheets API" on the SAME project as your OAuth client ID
4
- # (if sync fails with project=..., open the Enable link in the log or Library → Google Sheets API → Enable).
5
- #
6
- # Spreadsheet ID + platform + overlay shortcut: set after copyhub login (web setup page),
7
- # or copyhub config ... --sheet-id <ID> and edit overlayPlatform / overlayAccelerator in ~/.copyhub/config.json
8
- # One tab per local calendar day: COPYHUB-YYYY-MM-DD (machine timezone).
9
- #
10
- # copyhub start opens the Electron overlay by default; set to 1 for clipboard + Sheet only:
11
- # COPYHUB_START_NO_OVERLAY=1
12
-
13
- COPYHUB_GOOGLE_CLIENT_ID=
14
- COPYHUB_GOOGLE_CLIENT_SECRET=
15
- COPYHUB_OAUTH_REDIRECT_PORT=19999
16
-
17
- # Overlay accelerator (optional): if set here it OVERRIDES the value saved after copyhub login (config overlayAccelerator).
18
- COPYHUB_OVERLAY_ACCELERATOR=
19
-
20
- # Set to 1 to NOT show the window when overlay starts (open via shortcut / tray only).
21
- # COPYHUB_OVERLAY_HIDE_ON_START=1
22
- # Set to 1 so the overlay does not close when clicking outside (default: click outside closes).
23
- # COPYHUB_OVERLAY_STICKY=1
24
- # Hide overlay icon from the taskbar: COPYHUB_OVERLAY_SKIP_TASKBAR=1
1
+ # Copy to .env and fill in values. CopyHub reads .env when you run the CLI from the current directory.
2
+ #
3
+ # Google Cloud Console → APIs: enable "Google Sheets API" on the SAME project as your OAuth client ID
4
+ # (if sync fails with project=..., open the Enable link in the log or Library → Google Sheets API → Enable).
5
+ #
6
+ # Spreadsheet ID + platform + overlay shortcut: set after copyhub login (web setup page),
7
+ # or copyhub config ... --sheet-id <ID> and edit overlayPlatform / overlayAccelerator in ~/.copyhub/config.json
8
+ # One tab per local calendar day: COPYHUB-YYYY-MM-DD (machine timezone).
9
+ #
10
+ # copyhub start opens the Electron overlay by default; set to 1 for clipboard + Sheet only:
11
+ # COPYHUB_START_NO_OVERLAY=1
12
+
13
+ # OAuth Client ID / Secret: optional here — running copyhub login opens a browser wizard that saves them to ~/.copyhub/config.json instead.
14
+ COPYHUB_GOOGLE_CLIENT_ID=
15
+ COPYHUB_GOOGLE_CLIENT_SECRET=
16
+ COPYHUB_OAUTH_REDIRECT_PORT=19999
17
+
18
+ # Overlay accelerator (optional): if set here it OVERRIDES the value saved after copyhub login (config overlayAccelerator).
19
+ COPYHUB_OVERLAY_ACCELERATOR=
20
+
21
+ # Set to 1 to NOT show the window when overlay starts (open via shortcut / tray only).
22
+ # COPYHUB_OVERLAY_HIDE_ON_START=1
23
+ # Set to 1 so the overlay does not close when clicking outside (default: click outside closes).
24
+ # COPYHUB_OVERLAY_STICKY=1
25
+ # Hide overlay icon from the taskbar: COPYHUB_OVERLAY_SKIP_TASKBAR=1
package/README.md CHANGED
@@ -1,122 +1,219 @@
1
- # CopyHub
2
-
3
- CopyHub watches your **clipboard**, keeps a **local history** under `~/.copyhub/history.jsonl`, optionally syncs copies to **Google Sheets** (one tab per day), and shows an **Electron overlay** so you can browse recent clips quickly.
4
-
5
- Runs on **Windows**, **macOS**, and **Linux**.
6
-
7
- ## Requirements
8
-
9
- - **Node.js** ≥ 18
10
- - A **Google Cloud** project with:
11
- - **Google Sheets API** enabled for the *same* project as your OAuth client
12
- - **OAuth 2.0 Client** (Desktop app type works well for localhost redirect)
13
-
14
- ## Installation
15
-
16
- From this repository:
17
-
18
- ```bash
19
- npm install
20
- ```
21
-
22
- Link the CLI globally (optional):
23
-
24
- ```bash
25
- npm link
26
- ```
27
-
28
- Or run commands with:
29
-
30
- ```bash
31
- node src/cli.js <command>
32
- ```
33
-
34
- ## Google Cloud setup
35
-
36
- 1. Enable **[Google Sheets API](https://console.cloud.google.com/apis/library/sheets.googleapis.com)** on your OAuth project.
37
- 2. Create **OAuth 2.0 credentials** and add this **Authorized redirect URI** (adjust the port if you change it):
38
-
39
- ```text
40
- http://127.0.0.1:19999/oauth2callback
41
- ```
42
-
43
- 3. Copy `.env.example` to `.env` and set:
44
-
45
- - `COPYHUB_GOOGLE_CLIENT_ID`
46
- - `COPYHUB_GOOGLE_CLIENT_SECRET`
47
- - Optionally `COPYHUB_OAUTH_REDIRECT_PORT` (default **19999**)
48
-
49
- Alternatively, store credentials in `~/.copyhub/config.json` via:
50
-
51
- ```bash
52
- copyhub config --client-id "<ID>" --client-secret "<SECRET>" [--sheet-id "<SPREADSHEET_ID>"] [--redirect-port 19999]
53
- ```
54
-
55
- ## First run
56
-
57
- 1. **Login** (opens the browser for OAuth, then a setup page):
58
-
59
- ```bash
60
- copyhub login
61
- ```
62
-
63
- 2. On the setup page, enter your **Spreadsheet ID** (from the URL `…/d/<SPREADSHEET_ID>/edit`), choose **platform** (Windows / macOS / Linux) for shortcut hints, set the **overlay accelerator** if you want, and save.
64
-
65
- 3. **Start** the background watcher (clipboard + Sheets + overlay by default):
66
-
67
- ```bash
68
- copyhub start
69
- ```
70
-
71
- You can close the terminal; the process keeps running. Check with `copyhub list` and stop with `copyhub stop`.
72
-
73
- ### Useful flags and environment variables
74
-
75
- | Action | How |
76
- |--------|-----|
77
- | Run in terminal (Ctrl+C stops everything) | `copyhub start --foreground` |
78
- | No Google Sheets | `copyhub start --no-sheet` |
79
- | No Electron overlay | `copyhub start --no-overlay` or `COPYHUB_START_NO_OVERLAY=1` |
80
- | Override shortcut | `COPYHUB_OVERLAY_ACCELERATOR` in `.env` (overrides saved config) |
81
- | Overlay stays open when clicking outside | `COPYHUB_OVERLAY_STICKY=1` |
82
-
83
- Run `copyhub --help` or `copyhub commands` for the full command list.
84
-
85
- ## CLI overview
86
-
87
- | Command | Purpose |
88
- |---------|---------|
89
- | `copyhub config` | Save OAuth client ID/secret (and optional Sheet ID) to `~/.copyhub/config.json` |
90
- | `copyhub login` | OAuth flow + setup page (Sheet ID, platform, overlay shortcut) |
91
- | `copyhub logout` | Remove saved tokens |
92
- | `copyhub status` | OAuth, Sheet, tokens, overlay platform/shortcut, daemon state |
93
- | `copyhub start` | Background daemon: clipboard watcher + optional Sheets + overlay |
94
- | `copyhub list` / `copyhub ls` | Show whether the daemon PID is running |
95
- | `copyhub stop` | Stop daemon and overlay child |
96
- | `copyhub overlay` | Launch only the Electron overlay (no clipboard daemon) |
97
-
98
- ## Data locations
99
-
100
- Everything lives under **`~/.copyhub/`** (or `%USERPROFILE%\.copyhub` on Windows):
101
-
102
- | File | Contents |
103
- |------|----------|
104
- | `config.json` | OAuth credentials (if not only in `.env`), `googleSheetId`, `overlayAccelerator`, `overlayPlatform` |
105
- | `tokens.json` | OAuth refresh/access tokens |
106
- | `history.jsonl` | Local clipboard history (JSON Lines) |
107
- | `run.json` | Daemon PID and metadata (when using `copyhub start` without `--foreground`) |
108
-
109
- ## Google Sheets layout
110
-
111
- - Rows are appended when Sheet sync is enabled and you are logged in.
112
- - New tabs are created per **local calendar day**, named: **`COPYHUB-YYYY-MM-DD`**.
113
-
114
- ## Overlay (Electron)
115
-
116
- - Global shortcut defaults to **`CommandOrControl+Shift+H`** if nothing else is set (`Ctrl+Shift+H` on Windows/Linux, `⌘⇧H` on macOS-style wording in Electron).
117
- - **macOS**: you may need to grant **Accessibility** permissions for global shortcuts.
118
- - Some **`Control+Alt+…`** combinations do not register reliably on Windows; prefer alternatives suggested on the setup page.
119
-
120
- ## License
121
-
122
- MIT — see `package.json`.
1
+ # CopyHub
2
+
3
+ CopyHub watches your **clipboard**, keeps a **local history** under `~/.copyhub/history.jsonl`, optionally syncs copies to **Google Sheets** (one tab per day), and shows an **Electron overlay** so you can browse recent clips quickly.
4
+
5
+ Runs on **Windows**, **macOS**, and **Linux**.
6
+
7
+ ## Requirements
8
+
9
+ - **Node.js** ≥ 18
10
+ - A **Google Cloud** project with:
11
+ - **Google Sheets API** enabled for the *same* project as your OAuth client
12
+ - **OAuth 2.0 Client** (Desktop app type works well for localhost redirect)
13
+
14
+ ## Installation
15
+
16
+ ### Install globally (npm)
17
+
18
+ After the package is published to npm:
19
+
20
+ ```bash
21
+ npm install -g copyhub-cli
22
+ ```
23
+
24
+ Then run `copyhub` from any directory (ensure Node.js ≥ 18 is on your `PATH`).
25
+
26
+ On Linux/macOS you may need elevated permissions or an npm prefix configured for your user; see [npm docs on global installs](https://docs.npmjs.com/cli/v10/commands/npm-install#global-installation).
27
+
28
+ ### From source (this repository)
29
+
30
+ From the repository root:
31
+
32
+ ```bash
33
+ npm install
34
+ ```
35
+
36
+ Register the CLI on your machine:
37
+
38
+ ```bash
39
+ npm link
40
+ ```
41
+
42
+ Or run without linking:
43
+
44
+ ```bash
45
+ node src/cli.js <command>
46
+ ```
47
+
48
+ ## Updating
49
+
50
+ Your settings (`~/.copyhub/config.json`, tokens, history) are kept when you upgrade the CLI.
51
+
52
+ **Recommended:** stop the background daemon before upgrading so Electron can reinstall cleanly; after upgrading start again:
53
+
54
+ ```bash
55
+ copyhub stop
56
+ ```
57
+
58
+ *(Skip `stop` if you only run `--foreground` or `overlay` and nothing is in the background.)*
59
+
60
+ ### Global install (`npm install -g copyhub-cli`)
61
+
62
+ Check what npm considers latest vs what you have:
63
+
64
+ ```bash
65
+ npm view copyhub-cli version
66
+ ```
67
+
68
+ Upgrade to the latest published release:
69
+
70
+ ```bash
71
+ npm install -g copyhub-cli@latest
72
+ ```
73
+
74
+ Alternatively:
75
+
76
+ ```bash
77
+ npm update -g copyhub-cli
78
+ ```
79
+
80
+ Restart CopyHub:
81
+
82
+ ```bash
83
+ copyhub start
84
+ ```
85
+
86
+ To see the installed package version: `npm list -g copyhub-cli --depth=0`.
87
+
88
+ ### From source
89
+
90
+ Pull latest commits and reinstall modules:
91
+
92
+ ```bash
93
+ copyhub stop
94
+ git pull
95
+ npm install
96
+ ```
97
+
98
+ If you previously ran **`npm link`**, linking stays tied to this folder — after `npm install` you usually **do not** need to link again unless npm warns otherwise:
99
+
100
+ ```bash
101
+ npm link
102
+ ```
103
+
104
+ Then:
105
+
106
+ ```bash
107
+ copyhub start
108
+ ```
109
+
110
+ ## Google Cloud setup
111
+
112
+ 1. Enable **[Google Sheets API](https://console.cloud.google.com/apis/library/sheets.googleapis.com)** on your OAuth project.
113
+ 2. Create **OAuth 2.0 credentials** and add this **Authorized redirect URI** (adjust the port if you change it):
114
+
115
+ ```text
116
+ http://127.0.0.1:19999/oauth2callback
117
+ ```
118
+
119
+ 3. Provide OAuth credentials in **any one** of these ways:
120
+
121
+ - **Recommended for first setup:** run **`copyhub login`** with no secrets configured — your browser opens a **localhost wizard** where you paste **Client ID** and **Client secret** (the same values as `COPYHUB_GOOGLE_CLIENT_ID` / `COPYHUB_GOOGLE_CLIENT_SECRET`); they are stored in `~/.copyhub/config.json`.
122
+
123
+ - Copy `.env.example` to `.env` and set `COPYHUB_GOOGLE_CLIENT_ID`, `COPYHUB_GOOGLE_CLIENT_SECRET`, and optionally `COPYHUB_OAUTH_REDIRECT_PORT` (default **19999**).
124
+
125
+ - Or run **`copyhub config`**:
126
+
127
+ ```bash
128
+ copyhub config --client-id "<ID>" --client-secret "<SECRET>" [--sheet-id "<SPREADSHEET_ID>"] [--redirect-port 19999]
129
+ ```
130
+
131
+ ## First run
132
+
133
+ 1. **Login** — opens the browser:
134
+
135
+ ```bash
136
+ copyhub login
137
+ ```
138
+
139
+ - If Client ID / Secret are **not** already in `.env` or `~/.copyhub/config.json`, the first screen collects them (**Google OAuth credentials** page). Submit it to save into config.
140
+ - After Google sign-in, another setup page asks for **Spreadsheet ID**, **platform**, and optional **overlay shortcut**.
141
+
142
+ 2. On that spreadsheet/setup page, enter your **Spreadsheet ID** (from the URL `…/d/<SPREADSHEET_ID>/edit`), choose **platform** (Windows / macOS / Linux) for shortcut hints, set the **overlay accelerator** if you want, and save.
143
+
144
+ 3. **Start** the background watcher (clipboard + Sheets + overlay by default):
145
+
146
+ ```bash
147
+ copyhub start
148
+ ```
149
+
150
+ You can close the terminal; the process keeps running. Check with `copyhub list` and stop with `copyhub stop`.
151
+
152
+ ### Useful flags and environment variables
153
+
154
+ | Action | How |
155
+ |--------|-----|
156
+ | Run in terminal (Ctrl+C stops everything) | `copyhub start --foreground` |
157
+ | No Google Sheets | `copyhub start --no-sheet` |
158
+ | No Electron overlay | `copyhub start --no-overlay` or `COPYHUB_START_NO_OVERLAY=1` |
159
+ | Override shortcut | `COPYHUB_OVERLAY_ACCELERATOR` in `.env` (overrides saved config) |
160
+ | Overlay stays open when clicking outside | `COPYHUB_OVERLAY_STICKY=1` |
161
+
162
+ Run `copyhub --help` or `copyhub commands` for built-in help.
163
+
164
+ ## CLI commands
165
+
166
+ Quick reference (same as `copyhub commands`):
167
+
168
+ ```bash
169
+ copyhub config --client-id "<ID>" --client-secret "<SECRET>" [--redirect-port 19999] [--sheet-id "<SPREADSHEET_ID>"]
170
+ copyhub login
171
+ copyhub logout
172
+ copyhub status
173
+ copyhub start [--no-sheet] [--no-overlay] [--foreground]
174
+ copyhub list # alias: copyhub ls
175
+ copyhub stop
176
+ copyhub overlay
177
+ copyhub commands # alias: copyhub cmds
178
+ copyhub --help
179
+ ```
180
+
181
+ | Command | What it does |
182
+ |---------|----------------|
183
+ | `copyhub config` | Writes OAuth client ID/secret (and optional Sheet ID, redirect port) to `~/.copyhub/config.json`. `--client-id` and `--client-secret` are required. |
184
+ | `copyhub login` | Opens browser: localhost wizard for Client ID/secret if missing, then Google OAuth, then spreadsheet/platform setup. |
185
+ | `copyhub logout` | Deletes saved OAuth tokens (`~/.copyhub/tokens.json`). |
186
+ | `copyhub status` | Prints OAuth config source, sheet target, tokens, overlay settings, and whether the background daemon is running. |
187
+ | `copyhub start` | Starts clipboard watcher + optional Sheets sync + Electron overlay in the **background** (closing the terminal does not stop it). Only one instance at a time. |
188
+ | `copyhub start --foreground` | Same as above but attached to the terminal; **Ctrl+C** stops everything. |
189
+ | `copyhub start --no-sheet` | Local history only; no Google Sheets writes. |
190
+ | `copyhub start --no-overlay` | No Electron window; use env `COPYHUB_START_NO_OVERLAY=1` for the same effect. |
191
+ | `copyhub list` / `copyhub ls` | Shows PID and start time if the daemon from `copyhub start` is running. |
192
+ | `copyhub stop` | Stops the background daemon and its overlay child process. |
193
+ | `copyhub overlay` | Runs **only** the Electron overlay (no clipboard daemon). Useful if you run the daemon separately or for debugging. |
194
+
195
+ ## Data locations
196
+
197
+ Everything lives under **`~/.copyhub/`** (or `%USERPROFILE%\.copyhub` on Windows):
198
+
199
+ | File | Contents |
200
+ |------|----------|
201
+ | `config.json` | OAuth credentials (if not only in `.env`), `googleSheetId`, `overlayAccelerator`, `overlayPlatform` |
202
+ | `tokens.json` | OAuth refresh/access tokens |
203
+ | `history.jsonl` | Local clipboard history (JSON Lines) |
204
+ | `run.json` | Daemon PID and metadata (when using `copyhub start` without `--foreground`) |
205
+
206
+ ## Google Sheets layout
207
+
208
+ - Rows are appended when Sheet sync is enabled and you are logged in.
209
+ - New tabs are created per **local calendar day**, named: **`COPYHUB-YYYY-MM-DD`**.
210
+
211
+ ## Overlay (Electron)
212
+
213
+ - Global shortcut defaults to **`CommandOrControl+Shift+H`** if nothing else is set (`Ctrl+Shift+H` on Windows/Linux, `⌘⇧H` on macOS-style wording in Electron).
214
+ - **macOS**: you may need to grant **Accessibility** permissions for global shortcuts.
215
+ - Some **`Control+Alt+…`** combinations do not register reliably on Windows; prefer alternatives suggested on the setup page.
216
+
217
+ ## License
218
+
219
+ MIT — see `package.json`.
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "copyhub-cli",
3
- "version": "1.0.0",
4
- "description": "CopyHub — clipboard, local history, Google Sheets sync (OAuth). Windows, macOS, Linux.",
5
- "type": "module",
6
- "bin": {
7
- "copyhub": "./src/cli.js"
8
- },
9
- "scripts": {
10
- "start": "node src/cli.js start",
11
- "login": "node src/cli.js login",
12
- "overlay": "node src/cli.js overlay"
13
- },
14
- "engines": {
15
- "node": ">=18"
16
- },
17
- "keywords": [
18
- "clipboard",
19
- "google-sheets",
20
- "oauth",
21
- "sync",
22
- "cli",
23
- "cross-platform",
24
- "windows",
25
- "linux",
26
- "macos"
27
- ],
28
- "files": ["src", "ui", ".env.example"],
29
- "license": "MIT",
30
- "dependencies": {
31
- "clipboardy": "^4.0.0",
32
- "dotenv": "^16.4.5",
33
- "electron": "^33.2.0",
34
- "commander": "^12.1.0",
35
- "google-auth-library": "^9.15.0",
36
- "googleapis": "^144.0.0",
37
- "open": "^10.1.0"
38
- }
39
- }
1
+ {
2
+ "name": "copyhub-cli",
3
+ "version": "1.0.3",
4
+ "description": "CopyHub — clipboard, local history, Google Sheets sync (OAuth). Windows, macOS, Linux.",
5
+ "type": "module",
6
+ "bin": {
7
+ "copyhub": "./src/cli.js"
8
+ },
9
+ "scripts": {
10
+ "start": "node src/cli.js start",
11
+ "login": "node src/cli.js login",
12
+ "overlay": "node src/cli.js overlay"
13
+ },
14
+ "engines": {
15
+ "node": ">=18"
16
+ },
17
+ "keywords": [
18
+ "clipboard",
19
+ "google-sheets",
20
+ "oauth",
21
+ "sync",
22
+ "cli",
23
+ "cross-platform",
24
+ "windows",
25
+ "linux",
26
+ "macos"
27
+ ],
28
+ "files": ["src", "ui", ".env.example"],
29
+ "license": "MIT",
30
+ "dependencies": {
31
+ "clipboardy": "^4.0.0",
32
+ "dotenv": "^16.4.5",
33
+ "electron": "^33.2.0",
34
+ "commander": "^12.1.0",
35
+ "google-auth-library": "^9.15.0",
36
+ "googleapis": "^144.0.0",
37
+ "open": "^10.1.0"
38
+ }
39
+ }