@radicalstorage-lingo/cli 0.1.0 → 0.2.0

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.cjs +16 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -57,9 +57,9 @@ npx lingo pull
57
57
 
58
58
  | Command | What it does |
59
59
  | --- | --- |
60
- | `lingo init [--project <id-or-slug>] [--api-url <url>]` | Write a starter `lingo.config.json`. |
60
+ | `lingo init [--project <id-or-slug>] [--api-url <url>] [--out <dir>]` | Write a starter `lingo.config.json`. `--out` sets the generated `outDir` (default `messages`). |
61
61
  | `lingo login [--api-key <key>]` | Store the key in `~/.lingo/credentials.json`. If the config's `projectId` is blank, fills it in from the key's own project. |
62
- | `lingo pull` | Download translations → `messages/{lang}.json` + generate `.lingo/types.ts`. |
62
+ | `lingo pull [--out <dir>]` | Download translations → `messages/{lang}.json` + generate `.lingo/types.ts`. `--out` overrides `outDir` from the config for that run. |
63
63
  | `lingo push [-y, --yes]` | Upload changed local values to **existing** keys (preview unless `--yes`). |
64
64
  | `lingo status` | Summarize local vs remote drift per language. |
65
65
  | `lingo diff` | Per-key drift (added / changed / removed). |
package/dist/cli.cjs CHANGED
@@ -25235,6 +25235,9 @@ function bundlePath(config, language) {
25235
25235
  const ext = config.format === "json-flat" || config.format === "json-nested" ? ".json" : ".json";
25236
25236
  return `${config.outDir}/${language}${ext}`;
25237
25237
  }
25238
+ function resolveOutDir(flagOut, config) {
25239
+ return flagOut ?? config.outDir;
25240
+ }
25238
25241
 
25239
25242
  // src/drift.ts
25240
25243
  function diffMaps(local, remote) {
@@ -25315,7 +25318,7 @@ function initCommand(opts) {
25315
25318
  // an explicit list here to restrict a command to a subset.
25316
25319
  languages: [],
25317
25320
  format: "json-nested",
25318
- outDir: "messages",
25321
+ outDir: opts.out ?? "messages",
25319
25322
  typesOut: ".lingo/types.ts",
25320
25323
  pull: "translated"
25321
25324
  };
@@ -25359,24 +25362,25 @@ async function loginCommand(opts) {
25359
25362
  console.log(import_picocolors.default.yellow(` (couldn't auto-fill projectId: ${reason})`));
25360
25363
  }
25361
25364
  }
25362
- async function pullCommand() {
25365
+ async function pullCommand(opts = {}) {
25363
25366
  const config = loadConfig();
25364
- const api = connect(config);
25365
- const codec = getCodec(config.format);
25367
+ const cfg = { ...config, outDir: resolveOutDir(opts.out, config) };
25368
+ const api = connect(cfg);
25369
+ const codec = getCodec(cfg.format);
25366
25370
  let typeEntries = [];
25367
- const languages = await resolveProjectLanguages(api, config);
25368
- if (config.languages.length === 0) {
25371
+ const languages = await resolveProjectLanguages(api, cfg);
25372
+ if (cfg.languages.length === 0) {
25369
25373
  console.log(import_picocolors.default.dim(`\u2192 pulling all project languages: ${languages.join(", ")}`));
25370
25374
  }
25371
25375
  for (const language of languages) {
25372
25376
  const rows = await api.listTranslations(
25373
- config.projectId,
25377
+ cfg.projectId,
25374
25378
  language,
25375
- config.pull === "approved" ? "approved" : void 0
25379
+ cfg.pull === "approved" ? "approved" : void 0
25376
25380
  );
25377
25381
  const messages = rowsToMessages(rows);
25378
25382
  const skipped = rows.length - messages.length;
25379
- const file = bundlePath(config, language);
25383
+ const file = bundlePath(cfg, language);
25380
25384
  (0, import_node_fs2.mkdirSync)((0, import_node_path2.dirname)(file), { recursive: true });
25381
25385
  (0, import_node_fs2.writeFileSync)(file, codec.serialize({ messages, language }));
25382
25386
  const skippedNote = skipped > 0 ? `, ${skipped} untranslated skipped` : "";
@@ -25474,11 +25478,11 @@ async function run(fn) {
25474
25478
  }
25475
25479
  var program2 = new Command();
25476
25480
  program2.name("lingo").description("Pull/push Lingo translations as JSON at build time.").version("0.0.0");
25477
- program2.command("init").description("Create a lingo.config.json in the current directory").option("--project <id>", "project id or slug").option("--api-url <url>", "API base URL").action(
25478
- (opts) => run(() => initCommand({ project: opts.project, apiUrl: opts.apiUrl }))
25481
+ program2.command("init").description("Create a lingo.config.json in the current directory").option("--project <id>", "project id or slug").option("--api-url <url>", "API base URL").option("--out <dir>", "output directory for pulled bundles").action(
25482
+ (opts) => run(() => initCommand({ project: opts.project, apiUrl: opts.apiUrl, out: opts.out }))
25479
25483
  );
25480
25484
  program2.command("login").description("Store an API key (create one in project settings \u2192 API keys)").option("--api-key <key>", "the API key").action((opts) => run(() => loginCommand({ apiKey: opts.apiKey })));
25481
- program2.command("pull").description("Download translations to JSON bundles and generate types").action(() => run(pullCommand));
25485
+ program2.command("pull").description("Download translations to JSON bundles and generate types").option("--out <dir>", "output directory for the pulled bundles (overrides outDir in config)").action((opts) => run(() => pullCommand({ out: opts.out })));
25482
25486
  program2.command("push").description("Upload changed local values to existing keys").option("-y, --yes", "apply without the preview prompt").action((opts) => run(() => pushCommand({ yes: opts.yes })));
25483
25487
  program2.command("status").description("Summarize local vs remote drift").action(() => run(statusCommand));
25484
25488
  program2.command("diff").description("Per-key local vs remote drift").action(() => run(diffCommand));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radicalstorage-lingo/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Lingo CLI — pull/push translations as JSON at build time.",
6
6
  "license": "MIT",