@patterkit/cli 0.13.4 → 0.14.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 (2) hide show
  1. package/dist/cli.js +22 -11
  2. package/package.json +4 -4
package/dist/cli.js CHANGED
@@ -34,6 +34,8 @@ import {
34
34
  extractLoc,
35
35
  applyLoc,
36
36
  describeLocExport,
37
+ describeLocImport,
38
+ importLocale,
37
39
  catalogToJson,
38
40
  jsonToCatalog,
39
41
  catalogToPo,
@@ -67,7 +69,7 @@ import { runMergetool } from "@wildwinter/toolkit/vcs";
67
69
  // package.json
68
70
  var package_default = {
69
71
  name: "@patterkit/cli",
70
- version: "0.13.4",
72
+ version: "0.14.0",
71
73
  description: "The `patter` CLI: validate, format, export, play, test coverage, localise, and merge Patter projects.",
72
74
  type: "module",
73
75
  license: "MIT",
@@ -96,10 +98,10 @@ var package_default = {
96
98
  "build:standalone:others": "node scripts/build-standalone.mjs --targets=linux-x64,linux-arm64,windows-x64"
97
99
  },
98
100
  dependencies: {
99
- "@patterkit/core": "0.9.6",
100
- "@patterkit/ops": "0.24.1",
101
+ "@patterkit/core": "0.10.0",
102
+ "@patterkit/ops": "0.25.0",
101
103
  "@wildwinter/simple-vc-lib": "^0.5.2",
102
- "@wildwinter/toolkit": "^0.3.1"
104
+ "@wildwinter/toolkit": "^0.4.0"
103
105
  }
104
106
  };
105
107
 
@@ -187,13 +189,14 @@ Usage:
187
189
  [--propose] (print auto-proposed @world input drivers instead of running)
188
190
  patter resolve <query> [path] Find a line by id, Game ID, or name: shows where it lives + what it says
189
191
  patter usage <query> [path] Find where a property is used (conditions / effects / text)
190
- [--json] (query: @gold \xB7 world.threat \xB7 "faction rebels"; quote a value)
192
+ [--json] (query: @gold, world.threat, or "faction rebels"; quote a value)
191
193
  patter report [path] Production report: status, burndown, recording coverage (alias: stats)
192
194
  [--xlsx file] [--json] Also write the spreadsheet / emit JSON (for pipelines)
193
195
  patter loc-export [path] -o file Export strings for translation (-o - streams json or po)
194
196
  --format json|xlsx|po [--locale xx] (no --locale = a blank template / POT)
195
197
  patter loc-import <file> [path] Import translated strings back into the project
196
- [--locale xx] (format by extension; --locale overrides the file's)
198
+ [--locale xx] [--force-locale] (format by extension; a file for another
199
+ language is refused unless --force-locale imports it as --locale)
197
200
  patter export-script [path] [-o file.pdf|.docx] Readable screenplay of the script + flow
198
201
  (dialogue, text, choices, jumps). Format from the extension; default
199
202
  beside the bundle, as .pdf. The PDF embeds its fonts and covers any script or emoji.
@@ -238,7 +241,7 @@ var FLAGS = {
238
241
  usage: { boolean: ["json"], valued: [], positionals: 2 },
239
242
  report: { boolean: ["json"], valued: ["xlsx"], positionals: 1 },
240
243
  "loc-export": { boolean: [], valued: ["format", "o", "locale"], positionals: 1 },
241
- "loc-import": { boolean: [], valued: ["locale"], positionals: 2 },
244
+ "loc-import": { boolean: ["force-locale"], valued: ["locale"], positionals: 2 },
242
245
  "voice-export": { boolean: ["all"], valued: ["o"], positionals: 1 },
243
246
  "export-script": { boolean: [], valued: ["o"], positionals: 1 },
244
247
  "export-editable": { boolean: ["status", "cast", "all-notes"], valued: ["o", "recipient", "by"], repeatable: ["scene"], positionals: 1 },
@@ -264,7 +267,7 @@ var SHORT = {
264
267
  usage: "usage <query> [path] [--json]",
265
268
  report: "report [path] [--xlsx FILE] [--json]",
266
269
  "loc-export": "loc-export [path] -o FILE --format json|xlsx|po [--locale xx]",
267
- "loc-import": "loc-import <file> [path] [--locale xx]",
270
+ "loc-import": "loc-import <file> [path] [--locale xx] [--force-locale]",
268
271
  "voice-export": "voice-export [path] -o FILE.xlsx [--all]",
269
272
  "export-script": "export-script [path] [-o FILE.pdf|FILE.docx]",
270
273
  "export-editable": "export-editable [path] -o FILE.docx [--scene name]... [--recipient X] [--status] [--cast] [--all-notes] [--by name]",
@@ -742,17 +745,25 @@ ${count} issue(s)${advisory}`);
742
745
  else if (ext === ".po" || ext === ".pot") catalog = poToCatalog(readFileSync2(file, "utf8"));
743
746
  else if (ext === ".xlsx") catalog = await xlsxToCatalog(readFileSync2(file));
744
747
  else return usage("loc-import", `unknown format '${ext}' (.json | .po | .xlsx)`);
745
- const locale = typeof flags.locale === "string" ? flags.locale : catalog.locale;
746
- if (!locale) return usage("loc-import", "no locale (the file carries none; pass --locale xx)");
748
+ const chosen = typeof flags.locale === "string" ? flags.locale : void 0;
749
+ const picked = importLocale(catalog.locale, chosen, { force: flags["force-locale"] === true });
750
+ if (!picked.ok) {
751
+ return usage("loc-import", picked.reason === "mismatch" ? `${picked.error} Pass --locale ${catalog.locale}, or add --force-locale to import it as '${chosen}' anyway.` : `${picked.error} Pass --locale xx.`);
752
+ }
753
+ const locale = picked.locale;
747
754
  if (locale === loaded.project.locales.default) return usage("loc-import", `'${locale}' is the source locale - nothing to import`);
748
- const { writes, stats } = applyLoc(loaded, { ...catalog, locale });
755
+ if (picked.warning) console.log(picked.warning);
756
+ const { writes, stats, report } = applyLoc(loaded, { ...catalog, locale });
757
+ const told = describeLocImport(loaded, report);
749
758
  if (writes.length === 0) {
750
759
  console.log("no translations to import");
760
+ for (const l of told) console.log(l);
751
761
  return 0;
752
762
  }
753
763
  if (!commitWrites(writes)) return 1;
754
764
  console.log(`imported ${stats.updated} string(s) for ${locale} across ${stats.files} scene(s)`);
755
765
  if (stats.dropped) console.log(`dropped ${stats.dropped} translation(s) of action text, which isn't localised while "Localise text lines in dialogue scenes" (localiseDialogueText) is off`);
766
+ for (const l of told) console.log(l);
756
767
  return 0;
757
768
  }
758
769
  case "share-scopes": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patterkit/cli",
3
- "version": "0.13.4",
3
+ "version": "0.14.0",
4
4
  "description": "The `patter` CLI: validate, format, export, play, test coverage, localise, and merge Patter projects.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,9 +29,9 @@
29
29
  "build:standalone:others": "node scripts/build-standalone.mjs --targets=linux-x64,linux-arm64,windows-x64"
30
30
  },
31
31
  "dependencies": {
32
- "@patterkit/core": "0.9.6",
33
- "@patterkit/ops": "0.24.1",
32
+ "@patterkit/core": "0.10.0",
33
+ "@patterkit/ops": "0.25.0",
34
34
  "@wildwinter/simple-vc-lib": "^0.5.2",
35
- "@wildwinter/toolkit": "^0.3.1"
35
+ "@wildwinter/toolkit": "^0.4.0"
36
36
  }
37
37
  }