@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 CHANGED
@@ -1,127 +1,79 @@
1
1
  # @vocoder/cli
2
2
 
3
- CLI for Vocoder translation workflows.
3
+ Command-line tool for Vocoder. Handles project setup and automatic string wrapping for translation.
4
4
 
5
- Commands:
6
-
7
- - `vocoder init`
8
- - `vocoder sync`
9
- - `vocoder wrap`
10
-
11
- ## Install
5
+ ## Installation
12
6
 
13
7
  ```bash
14
- pnpm add -D @vocoder/cli
8
+ npm install -g @vocoder/cli
15
9
  ```
16
10
 
17
- ## `vocoder sync`
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
- pnpm exec vocoder sync
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
- ### Options
17
+ ## Commands
50
18
 
51
- - `--include <pattern>` (repeatable)
52
- - `--exclude <pattern>` (repeatable)
53
- - `--branch <name>`
54
- - `--force`
55
- - `--dry-run`
56
- - `--verbose`
19
+ ### `vocoder init`
57
20
 
58
- ## `vocoder wrap`
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
- pnpm exec vocoder wrap
24
+ vocoder init
64
25
  ```
65
26
 
66
- Options:
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
- ## Configuration
29
+ **Options:**
76
30
 
77
- Config priority:
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
- 1. CLI flags
80
- 2. environment variables
81
- 3. defaults
38
+ ### `vocoder wrap`
82
39
 
83
- ### Environment variables
40
+ Automatically wrap string literals in your source code with `<T>` and `t()`.
84
41
 
85
42
  ```bash
86
- VOCODER_API_KEY=vc_xxx
87
- VOCODER_API_URL=https://vocoder.app
88
- VOCODER_EXTRACTION_PATTERN=src/**/*.{tsx,jsx,ts,js}
43
+ vocoder wrap
89
44
  ```
90
45
 
91
- `VOCODER_API_KEY` must come from the environment.
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
- Bootstraps a project by opening a browser authorization flow, then provisioning
96
- a workspace/project API key.
48
+ **Options:**
97
49
 
98
- During browser completion, you can paste a DeepL API key (BYOK) or reuse an
99
- existing org-level DeepL key.
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
- ```bash
102
- pnpm exec vocoder init
103
- ```
59
+ ## String Extraction
104
60
 
105
- ## Troubleshooting
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
- ### `VOCODER_API_KEY is required`
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
- Set `VOCODER_API_KEY` in `.env` or your environment.
67
+ It tracks imports from `@vocoder/react` to avoid double-wrapping strings that are already marked for translation.
110
68
 
111
- ### No strings found
69
+ ## Git Integration
112
70
 
113
- Use `<T>` (from `@vocoder/react`) around translatable JSX text.
71
+ The CLI auto-detects the repository and branch:
114
72
 
115
- ### Wrong branch / skipped sync
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
- Use:
77
+ ## License
118
78
 
119
- ```bash
120
- pnpm exec vocoder sync --branch main
121
- ```
122
-
123
- or force:
124
-
125
- ```bash
126
- pnpm exec vocoder sync --force
127
- ```
79
+ MIT