@vocoder/cli 0.1.6 → 0.1.8
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/README.md +134 -28
- package/dist/bin.mjs +1737 -784
- package/dist/bin.mjs.map +1 -1
- package/dist/chunk-OC5N5C5X.mjs +546 -0
- package/dist/chunk-OC5N5C5X.mjs.map +1 -0
- package/dist/lib.d.mts +175 -0
- package/dist/lib.mjs +15 -0
- package/dist/lib.mjs.map +1 -0
- package/package.json +8 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vocoder/cli
|
|
2
2
|
|
|
3
|
-
Command-line tool for Vocoder. Handles project setup
|
|
3
|
+
Command-line tool for Vocoder. Handles project setup, string extraction, and translation sync.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ Command-line tool for Vocoder. Handles project setup and automatic string wrappi
|
|
|
8
8
|
npm install -g @vocoder/cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Or use
|
|
11
|
+
Or use without installing:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
npx vocoder <command>
|
|
@@ -18,61 +18,167 @@ npx vocoder <command>
|
|
|
18
18
|
|
|
19
19
|
### `vocoder init`
|
|
20
20
|
|
|
21
|
-
Connect your repository to Vocoder.
|
|
21
|
+
Connect your repository to Vocoder. Runs an interactive TUI that handles authentication, workspace setup, and project configuration — all in the terminal. Only one browser step is required (GitHub authorization), and only on first run.
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
vocoder init
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
**First-time setup:**
|
|
28
|
+
|
|
29
|
+
The CLI opens the Vocoder GitHub App installation page. Authorizing the App creates your account and workspace in one step — no separate sign-up required.
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
┌ Vocoder Setup
|
|
33
|
+
|
|
34
|
+
◆ Opening GitHub to connect your account...
|
|
35
|
+
│ Authorize Vocoder and install the GitHub App in one step.
|
|
36
|
+
│
|
|
37
|
+
│ https://github.com/apps/vocoder/installations/new?state=...
|
|
38
|
+
│
|
|
39
|
+
◆ Open in your browser? › Yes
|
|
40
|
+
|
|
41
|
+
◒ Waiting for GitHub authorization...
|
|
42
|
+
|
|
43
|
+
◇ Connected as @username — workspace: username
|
|
44
|
+
|
|
45
|
+
◆ App Directory (Optional)
|
|
46
|
+
│ Leave blank to cover the entire repository (or enter a subdirectory for monorepos)
|
|
47
|
+
|
|
48
|
+
◆ Source language (type to search)
|
|
49
|
+
│ English — en
|
|
50
|
+
|
|
51
|
+
◆ Target languages (type to search, space to select)
|
|
52
|
+
│ ◼ Spanish — es
|
|
53
|
+
|
|
54
|
+
◆ Target branches
|
|
55
|
+
│ ◼ main
|
|
56
|
+
|
|
57
|
+
◒ Creating project...
|
|
58
|
+
|
|
59
|
+
◆ Step 1: Add the plugin to vite.config.ts
|
|
60
|
+
◆ Step 2: Wrap your app with VocoderProvider
|
|
61
|
+
◆ Step 3: Mark strings for translation with <T>
|
|
62
|
+
|
|
63
|
+
◆ Use Vocoder with Claude Code
|
|
64
|
+
│ claude mcp add --scope project --transport stdio \
|
|
65
|
+
│ --env VOCODER_API_KEY=vc_xxxx \
|
|
66
|
+
│ vocoder -- npx -y @vocoder/mcp
|
|
67
|
+
|
|
68
|
+
◇ You're all set.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Returning user (stored credentials):**
|
|
72
|
+
|
|
73
|
+
No browser opens. The stored token is verified and the flow continues in the terminal.
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
┌ Vocoder Setup
|
|
77
|
+
|
|
78
|
+
◇ Authenticated as user@example.com
|
|
79
|
+
|
|
80
|
+
◆ Select workspace
|
|
81
|
+
│ ● my-workspace (3 projects)
|
|
82
|
+
│ ○ + Create new workspace
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Monorepo support:**
|
|
86
|
+
|
|
87
|
+
When running `vocoder init` from a subdirectory of a git repository, the CLI automatically suggests that subdirectory as the app directory. Each app in a monorepo should be set up as a separate Vocoder project.
|
|
28
88
|
|
|
29
89
|
**Options:**
|
|
30
90
|
|
|
31
91
|
| Flag | Description |
|
|
32
92
|
|---|---|
|
|
33
|
-
| `--yes` | Skip confirmation
|
|
34
|
-
| `--
|
|
35
|
-
|
|
36
|
-
|
|
93
|
+
| `--yes` | Skip the "Open in your browser?" confirmation |
|
|
94
|
+
| `--ci` | Non-interactive mode. Prints `VOCODER_AUTH_URL: <url>` to stdout instead of opening a browser. Intended for CI environments where the browser step is driven externally. |
|
|
95
|
+
|
|
96
|
+
**Stored credentials:**
|
|
37
97
|
|
|
38
|
-
|
|
98
|
+
After first sign-in, the CLI stores credentials at `~/.config/vocoder/auth.json` (mode `0600`). Tokens do not expire. Use `vocoder logout` to revoke.
|
|
39
99
|
|
|
40
|
-
|
|
100
|
+
**Token resolution:**
|
|
101
|
+
|
|
102
|
+
| Command | Source |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `vocoder init` | `VOCODER_AUTH_TOKEN` env var → `~/.config/vocoder/auth.json` |
|
|
105
|
+
| `vocoder sync` | `VOCODER_API_KEY` env var → `.env` file |
|
|
106
|
+
| MCP tools | `VOCODER_API_KEY` env var |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### `vocoder sync`
|
|
111
|
+
|
|
112
|
+
Extract translatable strings from your source code and submit them for translation.
|
|
41
113
|
|
|
42
114
|
```bash
|
|
43
|
-
vocoder
|
|
115
|
+
vocoder sync
|
|
44
116
|
```
|
|
45
117
|
|
|
46
|
-
|
|
118
|
+
Reads `VOCODER_API_KEY` from environment or `.env`. Detects `<T>` and `t()` usages, submits them to Vocoder, and polls until translations are returned. Writes locale JSON files to the configured output path.
|
|
47
119
|
|
|
48
120
|
**Options:**
|
|
49
121
|
|
|
50
122
|
| Flag | Description |
|
|
51
123
|
|---|---|
|
|
52
|
-
| `--
|
|
53
|
-
| `--
|
|
54
|
-
| `--
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
124
|
+
| `--locale <code>` | Sync only this target locale |
|
|
125
|
+
| `--dry-run` | Show what would be synced without submitting |
|
|
126
|
+
| `--verbose` | Show extraction and sync details |
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### `vocoder logout`
|
|
131
|
+
|
|
132
|
+
Revoke the stored credentials and clear `~/.config/vocoder/auth.json`.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
vocoder logout
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The token is also revoked server-side.
|
|
58
139
|
|
|
59
|
-
|
|
140
|
+
---
|
|
60
141
|
|
|
61
|
-
|
|
142
|
+
### `vocoder whoami`
|
|
62
143
|
|
|
63
|
-
|
|
64
|
-
- String props like `placeholder`, `title`, `aria-label` (wrapped with `t()`)
|
|
65
|
-
- Non-translatable strings like class names, keys, and URLs (left alone)
|
|
144
|
+
Print the currently authenticated user.
|
|
66
145
|
|
|
67
|
-
|
|
146
|
+
```bash
|
|
147
|
+
vocoder whoami
|
|
148
|
+
# Authenticated as user@example.com (my-workspace)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## How `init` interacts with the browser
|
|
154
|
+
|
|
155
|
+
`vocoder init` opens exactly one browser window, and only on first run. The browser is used to authorize the Vocoder GitHub App — this simultaneously authenticates you and connects your GitHub account, so no separate sign-up is needed.
|
|
156
|
+
|
|
157
|
+
Once the GitHub authorization is complete, the browser redirects back and the CLI receives your credentials automatically via a local callback server. The rest of setup happens in the terminal.
|
|
158
|
+
|
|
159
|
+
On subsequent runs, the stored token is used directly and no browser is needed.
|
|
160
|
+
|
|
161
|
+
---
|
|
68
162
|
|
|
69
163
|
## Git Integration
|
|
70
164
|
|
|
71
|
-
The CLI auto-detects the
|
|
165
|
+
The CLI auto-detects repository context from the working directory:
|
|
166
|
+
|
|
167
|
+
- **Repository:** Reads the git remote URL and normalizes it to `github:owner/repo`
|
|
168
|
+
- **Branch:** Checks CI environment variables first (GitHub Actions, Vercel, Netlify, etc.), then falls back to `.git/HEAD`
|
|
169
|
+
- **App directory:** For monorepos, computes the relative path from the git root to `process.cwd()`
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Environment Variables
|
|
174
|
+
|
|
175
|
+
| Variable | Used by | Purpose |
|
|
176
|
+
|---|---|---|
|
|
177
|
+
| `VOCODER_API_KEY` | `sync`, MCP | Project API key (`vc_` prefix) |
|
|
178
|
+
| `VOCODER_AUTH_TOKEN` | `init` | Override stored user token (`vcu_` prefix) |
|
|
179
|
+
| `VOCODER_API_URL` | All commands | Override API base URL (default: `https://vocoder.app`) |
|
|
72
180
|
|
|
73
|
-
|
|
74
|
-
- **Branch:** Checks CI environment variables first (GitHub Actions, Vercel, Netlify, etc.), then falls back to reading `.git/HEAD`
|
|
75
|
-
- **Scope path:** For monorepos, computes the relative path from the git root to the working directory
|
|
181
|
+
---
|
|
76
182
|
|
|
77
183
|
## License
|
|
78
184
|
|