@localess/cli 0.0.1-dev.20260221221032 → 0.0.1-dev.20260221224153
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 +30 -4
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ A powerful CLI tool to interact with your Localess spaces.
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
15
|
- 🔐 **Authentication** - Secure login system and CI environments.
|
|
16
|
-
- 🛡️ **Type Safety** - Generate TypeScript type definitions for your Localess content schemas, ensuring type safety in your frontend applications.
|
|
17
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.
|
|
18
18
|
|
|
19
19
|
## Setup
|
|
20
20
|
|
|
@@ -45,17 +45,43 @@ The CLI provides a `logout` command to clear your authentication token and log y
|
|
|
45
45
|
localess logout
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
## Translations Management
|
|
49
|
+
|
|
50
|
+
The CLI provides a `translations` command with `push` and `pull` subcommands to sync and manage translations for your Localess space.
|
|
51
|
+
|
|
52
|
+
### Push Translations
|
|
53
|
+
Push local translation files to Localess.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
localess translations push <locale> --path <file> [--format <flat|nested>] [--type <add-missing|replace>]
|
|
57
|
+
```
|
|
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`, `replace`, etc., default: `add-missing`)
|
|
62
|
+
|
|
63
|
+
### Pull Translations
|
|
64
|
+
Pull translations from Localess and save locally.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
localess translations pull <locale> --path <file> [--format <flat|nested>]
|
|
68
|
+
```
|
|
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
|
+
|
|
48
73
|
## Generate TypeScript Types
|
|
49
74
|
|
|
50
|
-
The CLI provides a `types` command to generate TypeScript definitions for your Localess content schemas. This command fetches your space's OpenAPI schema and writes a `localess.d.ts` file to your project, allowing for strong typing in your codebase.
|
|
75
|
+
The CLI provides a `types generate` command to generate TypeScript definitions for your Localess content schemas. This command fetches your space's OpenAPI schema and writes a `localess.d.ts` file to your project, allowing for strong typing in your codebase.
|
|
51
76
|
|
|
52
77
|
### Usage
|
|
53
78
|
|
|
54
79
|
```bash
|
|
55
|
-
localess types
|
|
80
|
+
localess types generate [--path <output_file>]
|
|
56
81
|
```
|
|
82
|
+
- `--path`: Path to the file where to save the generated types. Default is `.localess/localess.d.ts` in your current working directory.
|
|
57
83
|
|
|
58
84
|
- You must be logged in (`localess login`) before running this command.
|
|
59
|
-
- The generated types file will be saved as `./.localess/localess.d.ts`
|
|
85
|
+
- The generated types file will be saved as `./.localess/localess.d.ts` by default.
|
|
60
86
|
|
|
61
87
|
You can then import these types in your TypeScript project for improved type safety when working with Localess content.
|
package/dist/index.js
CHANGED
|
@@ -527,7 +527,7 @@ var import_openapi_typescript = __toESM(require("openapi-typescript"));
|
|
|
527
527
|
var import_node_path3 = require("path");
|
|
528
528
|
var import_node_process = __toESM(require("process"));
|
|
529
529
|
var TYPES_PATH = (0, import_node_path3.join)(import_node_process.default.cwd(), DEFAULT_CONFIG_DIR, "localess.d.ts");
|
|
530
|
-
var typesGenerateCommand = new import_commander3.Command("generate").description("Generate types for your schemas").option("-
|
|
530
|
+
var typesGenerateCommand = new import_commander3.Command("generate").description("Generate types for your schemas").option("-p, --path <path>", "Path to the file where to save the generated types. Default is .localess/localess.d.ts", TYPES_PATH).action(async (options) => {
|
|
531
531
|
console.log("Types in with options:", options);
|
|
532
532
|
const session = await getSession();
|
|
533
533
|
if (!session.isLoggedIn) {
|
|
@@ -551,8 +551,8 @@ var typesGenerateCommand = new import_commander3.Command("generate").description
|
|
|
551
551
|
};
|
|
552
552
|
const ast = await (0, import_openapi_typescript.default)(minimalSpec, { exportType: true, rootTypes: true, rootTypesNoSchemaPrefix: true });
|
|
553
553
|
const contents = (0, import_openapi_typescript.astToString)(ast);
|
|
554
|
-
await writeFile(options.
|
|
555
|
-
console.log(`Types generated successfully at ${options.
|
|
554
|
+
await writeFile(options.path, contents);
|
|
555
|
+
console.log(`Types generated successfully at ${options.path}`);
|
|
556
556
|
} catch (e) {
|
|
557
557
|
console.error(e);
|
|
558
558
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -504,7 +504,7 @@ import openapiTS, { astToString } from "openapi-typescript";
|
|
|
504
504
|
import { join as join2 } from "path";
|
|
505
505
|
import process3 from "process";
|
|
506
506
|
var TYPES_PATH = join2(process3.cwd(), DEFAULT_CONFIG_DIR, "localess.d.ts");
|
|
507
|
-
var typesGenerateCommand = new Command3("generate").description("Generate types for your schemas").option("-
|
|
507
|
+
var typesGenerateCommand = new Command3("generate").description("Generate types for your schemas").option("-p, --path <path>", "Path to the file where to save the generated types. Default is .localess/localess.d.ts", TYPES_PATH).action(async (options) => {
|
|
508
508
|
console.log("Types in with options:", options);
|
|
509
509
|
const session = await getSession();
|
|
510
510
|
if (!session.isLoggedIn) {
|
|
@@ -528,8 +528,8 @@ var typesGenerateCommand = new Command3("generate").description("Generate types
|
|
|
528
528
|
};
|
|
529
529
|
const ast = await openapiTS(minimalSpec, { exportType: true, rootTypes: true, rootTypesNoSchemaPrefix: true });
|
|
530
530
|
const contents = astToString(ast);
|
|
531
|
-
await writeFile(options.
|
|
532
|
-
console.log(`Types generated successfully at ${options.
|
|
531
|
+
await writeFile(options.path, contents);
|
|
532
|
+
console.log(`Types generated successfully at ${options.path}`);
|
|
533
533
|
} catch (e) {
|
|
534
534
|
console.error(e);
|
|
535
535
|
}
|