@localess/cli 3.0.1-dev.20260425203948 → 3.0.1-dev.20260426083432

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 (2) hide show
  1. package/dist/index.mjs +29 -24
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -315,7 +315,7 @@ var D = new e("login").description("Login to Localess CLI").option("-o, --origin
315
315
  return e.ADD_MISSING = "add-missing", e.UPDATE_EXISTING = "update-existing", e.DELETE_MISSING = "delete-missing", e;
316
316
  }({}), M = /* @__PURE__ */ function(e) {
317
317
  return e.FLAT = "flat", e.NESTED = "nested", e;
318
- }({}), N = "// Generated by Localess CLI - do not edit manually\n\nexport interface ContentAsset {\n kind: 'ASSET';\n uri: string;\n}\n\nexport interface ContentLink {\n kind: 'LINK';\n target: '_blank' | '_self';\n type: 'url' | 'content';\n uri: string;\n}\n\nexport interface ContentReference {\n kind: 'REFERENCE';\n uri: string;\n}\n\nexport interface ContentRichText {\n type?: string;\n content?: ContentRichText[];\n}\n";
318
+ }({}), N = "/**\n * Generated by Localess CLI\n * Do not edit manually.\n */\n\n/**\n * Content Asset define reference to a Asset.\n */\nexport interface ContentAsset {\n /** Define the type of Asset */\n kind: 'ASSET';\n /** Unique identifier for the asset. */\n uri: string;\n}\n\n/**\n * Content Link define reference to a Link.\n */\nexport interface ContentLink {\n /** Define the type of Link */\n kind: 'LINK';\n /** Define the target of the link. _blank for new tab and _self for same tab. */\n target: '_blank' | '_self';\n /** Define the type of Link. URL for external links and Content for internal links. */\n type: 'url' | 'content';\n /** If type is content, then it will be Content ID. Otherwise it will be URL. */\n uri: string;\n}\n\n/**\n * Content Reference define reference to a Content.\n */\nexport interface ContentReference {\n /** Define the type of Reference */\n kind: 'REFERENCE';\n /** Unique identifier for the Content Document. */\n uri: string;\n}\n\n/**\n * Content RichText define content as JSON Object.\n */\nexport interface ContentRichText {\n /** Define the type of Content Node */\n type?: string;\n /** List of Content Nodes */\n content?: ContentRichText[];\n}\n";
319
319
  function P(e) {
320
320
  return e.replace(/[-_\s]+([a-zA-Z0-9])/g, (e, t) => t.toUpperCase()).replace(/^[a-z]/, (e) => e.toUpperCase());
321
321
  }
@@ -351,36 +351,41 @@ function F(e) {
351
351
  }
352
352
  }
353
353
  }
354
- function I(e) {
354
+ function I(e, t = "") {
355
+ return `${t}/**\n${t} * ${e}\n${t} */`;
356
+ }
357
+ function L(e) {
355
358
  let t = [N], n = [];
356
359
  for (let [r, i] of Object.entries(e)) {
357
- let e = P(r);
360
+ let e = P(r), a = i.description ? `${I(i.description)}\n` : "";
358
361
  if (i.type === k.ENUM) {
359
362
  let n = i.values ?? [];
360
- if (n.length === 0) t.push(`export type ${e} = string;\n`);
363
+ if (n.length === 0) t.push(`${a}export type ${e} = string;\n`);
361
364
  else {
362
365
  let r = n.map((e) => `'${e.value}'`).join(" | ");
363
- t.push(`export type ${e} = ${r};\n`);
366
+ t.push(`${a}export type ${e} = ${r};\n`);
364
367
  }
365
368
  } else {
366
- let a = i;
369
+ let o = i;
367
370
  i.type === k.ROOT && n.push(e);
368
- let o = [
371
+ let s = [
372
+ " /** Unique identifier of a component in a content. */",
369
373
  " _id: string;",
374
+ " /** Unique identifier for the Schema object. */",
370
375
  ` _schema: '${r}';`,
371
- ...(a.fields ?? []).map((e) => {
372
- let t = F(e), n = e.required ? "" : "?";
373
- return ` ${e.name}${n}: ${t};`;
376
+ ...(o.fields ?? []).flatMap((e) => {
377
+ let t = F(e), n = e.required ? "" : "?", r = [];
378
+ return e.description && r.push(` /** ${e.description} */`), r.push(` ${e.name}${n}: ${t};`), r;
374
379
  })
375
380
  ];
376
- t.push(`export interface ${e} {\n${o.join("\n")}\n}\n`);
381
+ t.push(`${a}export interface ${e} {\n${s.join("\n")}\n}\n`);
377
382
  }
378
383
  }
379
- return n.length > 0 ? t.push(`export type ContentData = ${n.join(" | ")};\n`) : t.push("export type ContentData = unknown;\n"), t.join("\n");
384
+ return t.push("/**\n* ContentData defined Object to connect all possible root Schemas.\n*/"), n.length > 0 ? t.push(`export type ContentData = ${n.join(" | ")};\n`) : t.push("export type ContentData = unknown;\n"), t.join("\n");
380
385
  }
381
386
  //#endregion
382
387
  //#region src/commands/types/generate/index.ts
383
- var L = s(u.cwd(), b, "localess.ts"), R = new e("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.ts", L).action(async (e) => {
388
+ var R = s(u.cwd(), b, "localess.ts"), z = new e("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.ts", R).action(async (e) => {
384
389
  console.log("Types in with options:", e);
385
390
  let t = await w();
386
391
  if (!t.isLoggedIn) {
@@ -395,17 +400,17 @@ var L = s(u.cwd(), b, "localess.ts"), R = new e("generate").description("Generat
395
400
  console.log("Fetching schemas from Localess...");
396
401
  let r = await n.getSchemas();
397
402
  console.log("Generating types...");
398
- let i = I(r);
403
+ let i = L(r);
399
404
  await x(e.path, i), console.log(`Types written to ${e.path}`);
400
- }), z = new e("types").description("Generate types for your schemas").addCommand(R), B = d.record(d.string(), d.string()), V = d.enum(["add-missing", "update-existing"]);
405
+ }), B = new e("types").description("Generate types for your schemas").addCommand(z), V = d.record(d.string(), d.string()), H = d.enum(["add-missing", "update-existing"]);
401
406
  d.object({
402
- type: V,
403
- values: B
407
+ type: H,
408
+ values: V
404
409
  });
405
410
  //#endregion
406
411
  //#region src/commands/translations/push/index.ts
407
- var H = new e("push").argument("<locale>", "Locale to push").description("Push locale translations to Localess").requiredOption("-p, --path <path>", "Path to the translations file to push").option("-f, --format <format>", `File format. Possible values are : ${Object.values(M)}`, M.FLAT).option("-t, --type <type>", `Push type. Possible values are : ${Object.values(j)}`, j.ADD_MISSING).option("--dry-run", "Preview changes without applying them to Localess").action(async (e, t) => {
408
- if (console.log("Pushing translations with arguments:", e), console.log("Pushing translations with options:", t), !V.safeParse(t.type).success) {
412
+ var U = new e("push").argument("<locale>", "Locale to push").description("Push locale translations to Localess").requiredOption("-p, --path <path>", "Path to the translations file to push").option("-f, --format <format>", `File format. Possible values are : ${Object.values(M)}`, M.FLAT).option("-t, --type <type>", `Push type. Possible values are : ${Object.values(j)}`, j.ADD_MISSING).option("--dry-run", "Preview changes without applying them to Localess").action(async (e, t) => {
413
+ if (console.log("Pushing translations with arguments:", e), console.log("Pushing translations with options:", t), !H.safeParse(t.type).success) {
409
414
  console.error("Invalid type provided. Possible values are :", Object.values(j));
410
415
  return;
411
416
  }
@@ -420,7 +425,7 @@ var H = new e("push").argument("<locale>", "Locale to push").description("Push l
420
425
  token: n.token
421
426
  });
422
427
  t.dryRun && console.warn("Dry run mode enabled: No changes will be made."), t.format === M.NESTED && console.error("Nested format is not implemented yet. Please use flat format for now."), console.log("Reading translations file from:", t.path);
423
- let i = await S(t.path), a = JSON.parse(i), o = B.safeParse(a);
428
+ let i = await S(t.path), a = JSON.parse(i), o = V.safeParse(a);
424
429
  if (!o.success) {
425
430
  console.error("Invalid translations file format:", o.error);
426
431
  return;
@@ -428,7 +433,7 @@ var H = new e("push").argument("<locale>", "Locale to push").description("Push l
428
433
  console.log("Pushing translations to Localess with locale:", e, "and type:", t.type);
429
434
  let s = await r.updateTranslations(e, t.type, a, t.dryRun);
430
435
  s ? (s.dryRun && console.log("Dry run results:"), console.log("Successfully pushed translations to Localess"), console.log("Summary:", s.message), s.ids && console.log("Updated translation IDs:", s.ids)) : console.log("Something went wrong while pushing translations to Localess");
431
- }), U = new e("pull").argument("<locale>", "Locale to pull").description("Pull locale translations from Localess").requiredOption("-p, --path <path>", "Path where the translations file will be saved").option("-f, --format <format>", `File format. Possible values are : ${Object.values(M)}`, M.FLAT).action(async (e, t) => {
436
+ }), W = new e("pull").argument("<locale>", "Locale to pull").description("Pull locale translations from Localess").requiredOption("-p, --path <path>", "Path where the translations file will be saved").option("-f, --format <format>", `File format. Possible values are : ${Object.values(M)}`, M.FLAT).action(async (e, t) => {
432
437
  if (console.log("Pulling translations with arguments:", e), console.log("Pulling translations with options:", t), !Object.values(M).includes(t.format)) {
433
438
  console.error("Invalid format provided. Possible values are :", Object.values(M));
434
439
  return;
@@ -451,12 +456,12 @@ var H = new e("push").argument("<locale>", "Locale to push").description("Push l
451
456
  await x(t.path, JSON.stringify(e, null, 2));
452
457
  }
453
458
  console.log("Successfully saved translations from Localess");
454
- }), W = new e("translations").description("Manage translations").addCommand(H).addCommand(U), G = new e();
455
- G.name("Localess CLI").description("CLI tool for Localess platform management").version("0.0.6"), G.addCommand(D), G.addCommand(O), G.addCommand(W), G.addCommand(z);
459
+ }), G = new e("translations").description("Manage translations").addCommand(U).addCommand(W), K = new e();
460
+ K.name("Localess CLI").description("CLI tool for Localess platform management").version("0.0.6"), K.addCommand(D), K.addCommand(O), K.addCommand(G), K.addCommand(B);
456
461
  //#endregion
457
462
  //#region src/index.ts
458
463
  try {
459
- G.parse(process.argv);
464
+ K.parse(process.argv);
460
465
  } catch (e) {
461
466
  console.error("Error executing command:", e instanceof Error ? e.message : e), process.exit(1);
462
467
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localess/cli",
3
- "version": "3.0.1-dev.20260425203948",
3
+ "version": "3.0.1-dev.20260426083432",
4
4
  "description": "Localess Command Line.",
5
5
  "keywords": [
6
6
  "localess",