@localess/cli 3.0.0-dev.20260313085125 → 3.0.0-dev.20260313114825
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 +208 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,82 +6,249 @@
|
|
|
6
6
|
|
|
7
7
|
----
|
|
8
8
|
|
|
9
|
-
# Localess
|
|
9
|
+
# Localess CLI
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The `@localess/cli` package is the official command-line interface for the [Localess](https://github.com/Lessify/localess) headless CMS platform. It provides commands to authenticate with your Localess instance, synchronize translations, and generate TypeScript type definitions from your content schemas.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Requirements
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
- 🌐 **Translations** - Sync and manage translations for your Localess space.
|
|
17
|
-
- 🛡️ **Type Safety** - Generate TypeScript type definitions for your Localess content schemas, ensuring type safety in your frontend applications.
|
|
15
|
+
- Node.js >= 20.0.0
|
|
18
16
|
|
|
19
|
-
##
|
|
17
|
+
## Installation
|
|
20
18
|
|
|
21
19
|
```bash
|
|
20
|
+
# Install as a project dev dependency (recommended)
|
|
22
21
|
npm install @localess/cli -D
|
|
22
|
+
|
|
23
|
+
# Or install globally
|
|
24
|
+
npm install @localess/cli -g
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- 🔐 **Authentication** — Secure credential storage for CLI and CI/CD environments
|
|
32
|
+
- 🌐 **Translations** — Push and pull translation files to/from your Localess space
|
|
33
|
+
- 🛡️ **Type Generation** — Generate TypeScript type definitions from your Localess content schemas for end-to-end type safety
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Authentication
|
|
38
|
+
|
|
39
|
+
### `localess login`
|
|
40
|
+
|
|
41
|
+
Authenticate with your Localess instance. Credentials are validated immediately and stored securely in `.localess/credentials.json` with restricted file permissions (`0600`).
|
|
28
42
|
|
|
29
|
-
#### Login with your Localess from CLI:
|
|
30
43
|
```bash
|
|
31
|
-
localess login --origin <
|
|
44
|
+
localess login --origin <origin> --space <space_id> --token <api_token>
|
|
32
45
|
```
|
|
33
|
-
|
|
46
|
+
|
|
47
|
+
If any option is omitted, the CLI will interactively prompt for the missing values.
|
|
48
|
+
|
|
49
|
+
**Options:**
|
|
50
|
+
|
|
51
|
+
| Flag | Description |
|
|
52
|
+
|------|-------------|
|
|
53
|
+
| `-o, --origin <origin>` | Localess instance URL (e.g., `https://my-localess.web.app`) |
|
|
54
|
+
| `-s, --space <space>` | Space ID (found in Localess Space settings) |
|
|
55
|
+
| `-t, --token <token>` | API token (input is masked for security) |
|
|
56
|
+
|
|
57
|
+
**Examples:**
|
|
58
|
+
|
|
34
59
|
```bash
|
|
35
|
-
|
|
36
|
-
export LOCALESS_SPACE=<space_id>
|
|
37
|
-
export LOCALESS_TOKEN=<space_access_token>
|
|
60
|
+
# Interactive login (prompts for any missing values)
|
|
38
61
|
localess login
|
|
62
|
+
|
|
63
|
+
# Non-interactive login (CI/CD)
|
|
64
|
+
localess login --origin https://my-localess.web.app --space MY_SPACE_ID --token MY_API_TOKEN
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Authentication via Environment Variables
|
|
68
|
+
|
|
69
|
+
For CI/CD pipelines, you can provide credentials through environment variables instead of running `localess login`. The CLI automatically reads these variables and skips the file-based credentials:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
export LOCALESS_ORIGIN=https://my-localess.web.app
|
|
73
|
+
export LOCALESS_SPACE=MY_SPACE_ID
|
|
74
|
+
export LOCALESS_TOKEN=MY_API_TOKEN
|
|
75
|
+
|
|
76
|
+
localess translations pull en --path ./public/locales/en.json
|
|
39
77
|
```
|
|
40
78
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
79
|
+
| Variable | Description |
|
|
80
|
+
|----------|-------------|
|
|
81
|
+
| `LOCALESS_ORIGIN` | Localess instance URL |
|
|
82
|
+
| `LOCALESS_SPACE` | Space ID |
|
|
83
|
+
| `LOCALESS_TOKEN` | API token |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### `localess logout`
|
|
88
|
+
|
|
89
|
+
Clear stored credentials from `.localess/credentials.json`.
|
|
90
|
+
|
|
44
91
|
```bash
|
|
45
92
|
localess logout
|
|
46
93
|
```
|
|
47
94
|
|
|
95
|
+
> If you authenticated via environment variables, those must be unset manually — `logout` only affects file-based credentials.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
48
99
|
## Translations Management
|
|
49
100
|
|
|
50
|
-
|
|
101
|
+
### `localess translations push <locale>`
|
|
102
|
+
|
|
103
|
+
Push a local JSON translation file to your Localess space. Only keys present in the file are affected, based on the selected update type.
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
localess translations push <locale> --path <file> [options]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Arguments:**
|
|
110
|
+
|
|
111
|
+
| Argument | Description |
|
|
112
|
+
|----------|-------------|
|
|
113
|
+
| `<locale>` | ISO 639-1 locale code (e.g., `en`, `de`, `fr`) |
|
|
114
|
+
|
|
115
|
+
**Options:**
|
|
116
|
+
|
|
117
|
+
| Flag | Default | Description |
|
|
118
|
+
|------|---------|-------------|
|
|
119
|
+
| `-p, --path <path>` | *(required)* | Path to the JSON translations file |
|
|
120
|
+
| `-f, --format <format>` | `flat` | File format: `flat` or `nested` |
|
|
121
|
+
| `-t, --type <type>` | `add-missing` | Update strategy: `add-missing` or `update-existing` |
|
|
122
|
+
| `--dry-run` | `false` | Preview changes without applying them |
|
|
123
|
+
|
|
124
|
+
**Update Strategies:**
|
|
51
125
|
|
|
52
|
-
|
|
53
|
-
|
|
126
|
+
| Type | Description |
|
|
127
|
+
|------|-------------|
|
|
128
|
+
| `add-missing` | Adds translations for keys that do not yet exist in Localess |
|
|
129
|
+
| `update-existing` | Updates translations for keys that already exist in Localess |
|
|
130
|
+
|
|
131
|
+
**File Formats:**
|
|
132
|
+
|
|
133
|
+
- **`flat`** — A flat JSON object where keys may use dot notation:
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"common.submit": "Submit",
|
|
137
|
+
"nav.home": "Home"
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- **`nested`** — A nested JSON object that is automatically flattened before uploading:
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"common": { "submit": "Submit" },
|
|
145
|
+
"nav": { "home": "Home" }
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Examples:**
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Push English translations (add missing keys only)
|
|
153
|
+
localess translations push en --path ./locales/en.json
|
|
154
|
+
|
|
155
|
+
# Push with update-existing strategy
|
|
156
|
+
localess translations push en --path ./locales/en.json --type update-existing
|
|
157
|
+
|
|
158
|
+
# Preview changes without applying (dry run)
|
|
159
|
+
localess translations push en --path ./locales/en.json --dry-run
|
|
160
|
+
|
|
161
|
+
# Push nested-format translations
|
|
162
|
+
localess translations push de --path ./locales/de.json --format nested
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### `localess translations pull <locale>`
|
|
168
|
+
|
|
169
|
+
Pull translations from your Localess space and save them to a local file.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
localess translations pull <locale> --path <file> [options]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Arguments:**
|
|
176
|
+
|
|
177
|
+
| Argument | Description |
|
|
178
|
+
|----------|-------------|
|
|
179
|
+
| `<locale>` | ISO 639-1 locale code (e.g., `en`, `de`, `fr`) |
|
|
180
|
+
|
|
181
|
+
**Options:**
|
|
182
|
+
|
|
183
|
+
| Flag | Default | Description |
|
|
184
|
+
|------|---------|-------------|
|
|
185
|
+
| `-p, --path <path>` | *(required)* | Output file path |
|
|
186
|
+
| `-f, --format <format>` | `flat` | File format: `flat` or `nested` |
|
|
187
|
+
|
|
188
|
+
**Examples:**
|
|
54
189
|
|
|
55
190
|
```bash
|
|
56
|
-
|
|
191
|
+
# Pull English translations as flat JSON
|
|
192
|
+
localess translations pull en --path ./locales/en.json
|
|
193
|
+
|
|
194
|
+
# Pull German translations as nested JSON
|
|
195
|
+
localess translations pull de --path ./locales/de.json --format nested
|
|
57
196
|
```
|
|
58
|
-
- `<locale>`: Locale code (e.g., `en`)
|
|
59
|
-
- `--path`: Path to the translations file to push (required)
|
|
60
|
-
- `--format`: File format (`flat` or `nested`, default: `flat`). **Note:** Only `flat` format is currently supported for push.
|
|
61
|
-
- `--type`: Push type (`add-missing`, `update-existing`, `delete-missing`. Default: `add-missing`)
|
|
62
197
|
|
|
63
|
-
|
|
64
|
-
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## TypeScript Type Generation
|
|
201
|
+
|
|
202
|
+
### `localess types generate`
|
|
203
|
+
|
|
204
|
+
Fetch your space's OpenAPI schema from Localess and generate TypeScript type definitions. The output file provides full type safety when working with Localess content in your TypeScript projects.
|
|
65
205
|
|
|
66
206
|
```bash
|
|
67
|
-
localess
|
|
207
|
+
localess types generate [--path <output_path>]
|
|
68
208
|
```
|
|
69
|
-
- `<locale>`: Locale code (e.g., `en`)
|
|
70
|
-
- `--path`: Path where the translations file will be saved (required)
|
|
71
|
-
- `--format`: File format (`flat` or `nested`, default: `flat`)
|
|
72
209
|
|
|
73
|
-
|
|
210
|
+
**Options:**
|
|
74
211
|
|
|
75
|
-
|
|
212
|
+
| Flag | Default | Description |
|
|
213
|
+
|------|---------|-------------|
|
|
214
|
+
| `-p, --path <path>` | `.localess/localess.d.ts` | Path to write the generated TypeScript definitions file |
|
|
76
215
|
|
|
77
|
-
|
|
216
|
+
> **Note:** Your API token must have **Development Tools** permission enabled in Localess Space settings.
|
|
217
|
+
|
|
218
|
+
**Example:**
|
|
78
219
|
|
|
79
220
|
```bash
|
|
80
|
-
|
|
221
|
+
# Generate types to the default location
|
|
222
|
+
localess types generate
|
|
223
|
+
|
|
224
|
+
# Generate types to a custom path
|
|
225
|
+
localess types generate --path src/types/localess.d.ts
|
|
81
226
|
```
|
|
82
|
-
- `--path`: Path to the file where to save the generated types. Default is `.localess/localess.d.ts` in your current working directory.
|
|
83
227
|
|
|
84
|
-
|
|
85
|
-
|
|
228
|
+
**Using generated types:**
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import type { Page, HeroBlock } from './.localess/localess';
|
|
232
|
+
import { getLocalessClient } from "@localess/react";
|
|
233
|
+
|
|
234
|
+
const client = getLocalessClient();
|
|
235
|
+
const content = await client.getContentBySlug<Page>('home', { locale: 'en' });
|
|
236
|
+
// content.data is now fully typed as Page
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Stored Files
|
|
242
|
+
|
|
243
|
+
| File | Description |
|
|
244
|
+
|------|-------------|
|
|
245
|
+
| `.localess/credentials.json` | Stored login credentials (created by `localess login`) |
|
|
246
|
+
| `.localess/localess.d.ts` | Generated TypeScript definitions (created by `localess types generate`) |
|
|
247
|
+
|
|
248
|
+
> It is recommended to add `.localess/credentials.json` to your `.gitignore` to avoid committing sensitive credentials.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## License
|
|
86
253
|
|
|
87
|
-
|
|
254
|
+
[MIT](../../LICENSE)
|