@vocoder/cli 0.1.3 → 0.1.6
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 +43 -91
- package/dist/bin.mjs +456 -1381
- package/dist/bin.mjs.map +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,127 +1,79 @@
|
|
|
1
1
|
# @vocoder/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command-line tool for Vocoder. Handles project setup and automatic string wrapping for translation.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- `vocoder init`
|
|
8
|
-
- `vocoder sync`
|
|
9
|
-
- `vocoder wrap`
|
|
10
|
-
|
|
11
|
-
## Install
|
|
5
|
+
## Installation
|
|
12
6
|
|
|
13
7
|
```bash
|
|
14
|
-
|
|
8
|
+
npm install -g @vocoder/cli
|
|
15
9
|
```
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Extracts translatable strings, sends them to Vocoder, then generates runtime artifacts for `@vocoder/react`.
|
|
20
|
-
|
|
21
|
-
Generated output:
|
|
22
|
-
|
|
23
|
-
`node_modules/@vocoder/generated`
|
|
24
|
-
|
|
25
|
-
Includes:
|
|
26
|
-
|
|
27
|
-
- `manifest.mjs`
|
|
28
|
-
- `manifest.cjs`
|
|
29
|
-
- `<locale>.js` files
|
|
30
|
-
- `package.json` exports map
|
|
31
|
-
|
|
32
|
-
### Typical usage
|
|
11
|
+
Or use directly with npx:
|
|
33
12
|
|
|
34
13
|
```bash
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Add to build pipeline:
|
|
39
|
-
|
|
40
|
-
```json
|
|
41
|
-
{
|
|
42
|
-
"scripts": {
|
|
43
|
-
"prebuild": "pnpm exec vocoder sync",
|
|
44
|
-
"build": "next build"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
14
|
+
npx vocoder <command>
|
|
47
15
|
```
|
|
48
16
|
|
|
49
|
-
|
|
17
|
+
## Commands
|
|
50
18
|
|
|
51
|
-
|
|
52
|
-
- `--exclude <pattern>` (repeatable)
|
|
53
|
-
- `--branch <name>`
|
|
54
|
-
- `--force`
|
|
55
|
-
- `--dry-run`
|
|
56
|
-
- `--verbose`
|
|
19
|
+
### `vocoder init`
|
|
57
20
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Scans source files and wraps likely user-facing strings with `<T>` / `t()` patterns.
|
|
21
|
+
Connect your repository to Vocoder.
|
|
61
22
|
|
|
62
23
|
```bash
|
|
63
|
-
|
|
24
|
+
vocoder init
|
|
64
25
|
```
|
|
65
26
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- `--include <pattern>` (repeatable)
|
|
69
|
-
- `--exclude <pattern>` (repeatable)
|
|
70
|
-
- `--dry-run`
|
|
71
|
-
- `--interactive`
|
|
72
|
-
- `--confidence <high|medium|low>`
|
|
73
|
-
- `--verbose`
|
|
27
|
+
The command detects your git remote and checks if a Vocoder project already exists for the repository. If found, it confirms the connection and prints next steps. If not, it opens a browser-based setup flow to create a new project.
|
|
74
28
|
|
|
75
|
-
|
|
29
|
+
**Options:**
|
|
76
30
|
|
|
77
|
-
|
|
31
|
+
| Flag | Description |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `--yes` | Skip confirmation prompts |
|
|
34
|
+
| `--project-name <name>` | Pre-fill project name |
|
|
35
|
+
| `--source-locale <locale>` | Pre-fill source locale |
|
|
36
|
+
| `--target-locales <list>` | Comma-separated target locales (e.g., `es,fr,de`) |
|
|
78
37
|
|
|
79
|
-
|
|
80
|
-
2. environment variables
|
|
81
|
-
3. defaults
|
|
38
|
+
### `vocoder wrap`
|
|
82
39
|
|
|
83
|
-
|
|
40
|
+
Automatically wrap string literals in your source code with `<T>` and `t()`.
|
|
84
41
|
|
|
85
42
|
```bash
|
|
86
|
-
|
|
87
|
-
VOCODER_API_URL=https://vocoder.app
|
|
88
|
-
VOCODER_EXTRACTION_PATTERN=src/**/*.{tsx,jsx,ts,js}
|
|
43
|
+
vocoder wrap
|
|
89
44
|
```
|
|
90
45
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
## `vocoder init`
|
|
46
|
+
Scans your JSX/TSX files for user-facing string literals and wraps them with the appropriate Vocoder translation markers. Uses AST analysis to detect strings that are likely user-facing (not keys, classnames, or internal identifiers).
|
|
94
47
|
|
|
95
|
-
|
|
96
|
-
a workspace/project API key.
|
|
48
|
+
**Options:**
|
|
97
49
|
|
|
98
|
-
|
|
99
|
-
|
|
50
|
+
| Flag | Description |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `--include <pattern>` | Glob pattern(s) to include (repeatable) |
|
|
53
|
+
| `--exclude <pattern>` | Glob pattern(s) to exclude (repeatable) |
|
|
54
|
+
| `--dry-run` | Preview changes without modifying files |
|
|
55
|
+
| `--interactive` | Confirm each string interactively |
|
|
56
|
+
| `--confidence <level>` | Minimum confidence: `high`, `medium`, `low` (default: `high`) |
|
|
57
|
+
| `--verbose` | Detailed output |
|
|
100
58
|
|
|
101
|
-
|
|
102
|
-
pnpm exec vocoder init
|
|
103
|
-
```
|
|
59
|
+
## String Extraction
|
|
104
60
|
|
|
105
|
-
|
|
61
|
+
The `wrap` command uses Babel to parse JSX/TSX files and detect strings that are likely user-facing. It distinguishes between:
|
|
106
62
|
|
|
107
|
-
|
|
63
|
+
- JSX text content (wrapped with `<T>`)
|
|
64
|
+
- String props like `placeholder`, `title`, `aria-label` (wrapped with `t()`)
|
|
65
|
+
- Non-translatable strings like class names, keys, and URLs (left alone)
|
|
108
66
|
|
|
109
|
-
|
|
67
|
+
It tracks imports from `@vocoder/react` to avoid double-wrapping strings that are already marked for translation.
|
|
110
68
|
|
|
111
|
-
|
|
69
|
+
## Git Integration
|
|
112
70
|
|
|
113
|
-
|
|
71
|
+
The CLI auto-detects the repository and branch:
|
|
114
72
|
|
|
115
|
-
|
|
73
|
+
- **Repository:** Reads the git remote URL and normalizes it to a canonical format (`github:owner/repo`)
|
|
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
|
|
116
76
|
|
|
117
|
-
|
|
77
|
+
## License
|
|
118
78
|
|
|
119
|
-
|
|
120
|
-
pnpm exec vocoder sync --branch main
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
or force:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
pnpm exec vocoder sync --force
|
|
127
|
-
```
|
|
79
|
+
MIT
|