@worldware/msg-cli 0.2.0 → 0.2.2

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  msg-cli is a command-line tool for the [msg](https://github.com/worldware-studios/msg) library. It helps you scaffold internationalization (i18n) and localization (l10n) layout and wire up your project for use with msg.
6
6
 
7
- **Current status:** CLI for the msg library (npm: `@worldware/msg-cli`, v0.2.0). Commands: `init` (scaffold i18n/l10n and config), `create project` (new MsgProject in i18n/projects), `create resource` (new MsgResource in i18n/resources), `export` (serialize MsgResources to XLIFF 2.0 in l10n/xliff), `import` (import translations from XLIFF 2.0 to JSON in l10n/translations).
7
+ **Current status:** CLI for the msg library (npm: `@worldware/msg-cli`, v0.2.2). Commands: `init` (scaffold i18n/l10n and config), `create project` (new MsgProject in i18n/projects), `create resource` (new MsgResource in i18n/resources), `export` (serialize MsgResources to XLIFF 2.0 in l10n/xliff), `import` (import translations from XLIFF 2.0 to JSON in l10n/translations).
8
8
 
9
9
  ## Installation
10
10
 
@@ -20,7 +20,7 @@ Or use via `npx`:
20
20
  npx msg <command>
21
21
  ```
22
22
 
23
- For project-local setup, run `msg init` in your project root to add msg and msg-cli as dependencies and scaffold directories and config.
23
+ For project-local setup, run `msg init` in your project root to add `@worldware/msg` and scaffold directories and config. Install msg-cli globally (as above) or as a dev dependency to run the commands.
24
24
 
25
25
  ## Core Concepts
26
26
 
@@ -113,9 +113,10 @@ msg create project -h
113
113
 
114
114
  **Behavior:**
115
115
 
116
- - Writes the file to `i18n/projects/<projectName>.js` or `.ts` (TypeScript if `tsconfig.json` exists).
117
- - Uses ES module or CommonJS export based on `package.json` `"type"`.
116
+ - Writes the file to `i18n/projects/<projectName>.js` (always `.js`).
117
+ - Uses ES module or CommonJS export syntax based on `package.json` `"type"` or presence of `tsconfig.json`.
118
118
  - Generates a translation loader that imports from `l10n/translations` using the relative path from `i18n/projects` (from `directories` in package.json).
119
+ - Includes `pseudoLocale: 'en-XA'` by default (or inherits from the base project when extending), for use with msg's `getTranslation(pseudoLocale)` pseudolocalization support.
119
120
  - With `--extend <name>`, merges target locales and pseudoLocale from the existing project. If `source` and `targets` are omitted, they are inherited from the base project.
120
121
  - Errors if the project name already exists, package.json is missing or invalid, or required directories are not configured.
121
122
 
@@ -153,8 +154,8 @@ msg create resource myProject messages --edit
153
154
 
154
155
  **Behavior:**
155
156
 
156
- - Writes the file to `i18n/resources/<title>.msg.js` or `.msg.ts` (TypeScript if `tsconfig.json` exists).
157
- - Uses ES module or CommonJS export based on `package.json` `"type"`.
157
+ - Writes the file to `i18n/resources/<title>.msg.js` (always `.js`).
158
+ - Uses ES module or CommonJS export syntax based on `package.json` `"type"` or presence of `tsconfig.json`.
158
159
  - Sets `lang` from the project's `sourceLocale` and `dir` to `rtl` for Arabic/Hebrew, `ltr` otherwise.
159
160
  - Includes a minimal example message. Validates that the generated file is importable.
160
161
  - Errors if i18n/projects or i18n/resources does not exist, the project is not found, or the resource file already exists (unless `--force`).
@@ -236,6 +237,7 @@ msg import -l zh
236
237
  - Dynamically imports `MsgProject` from `i18n/projects` to validate target locales.
237
238
  - Skips monolingual XLIFF files (no `trgLang`).
238
239
  - Skips files whose target locale is not in the project's `targetLocales`.
240
+ - Skips files when the matching project file does not exist or cannot be loaded.
239
241
  - Writes JSON to `l10n/translations/<project>/<locale>/<title>.json`.
240
242
  - Preserves existing translation files for other projects or locales when filtering.
241
243
  - Errors on malformed XLIFF and logs each step.
@@ -215,9 +215,8 @@ var CreateProject = class _CreateProject extends import_core.Command {
215
215
  const projectsDir = (0, import_path3.join)(rootDir, i18nDir, "projects");
216
216
  const translationsDir = (0, import_path3.join)(rootDir, l10nDir, "translations");
217
217
  const relPath = calculateRelativePath(projectsDir, translationsDir);
218
- const useTypeScript = (0, import_fs3.existsSync)((0, import_path3.join)(rootDir, "tsconfig.json"));
219
- const isEsm = pkg.type === "module";
220
- const ext = useTypeScript ? ".ts" : ".js";
218
+ const isEsm = pkg.type === "module" || (0, import_fs3.existsSync)((0, import_path3.join)(rootDir, "tsconfig.json"));
219
+ const ext = ".js";
221
220
  const outPath = (0, import_path3.join)(projectsDir, `${projectName}${ext}`);
222
221
  if ((0, import_fs3.existsSync)(outPath)) {
223
222
  this.error(`A project with the name '${projectName}' already exists.`, { exit: 1 });
@@ -70,9 +70,8 @@ var CreateProject = class _CreateProject extends Command {
70
70
  const projectsDir = join(rootDir, i18nDir, "projects");
71
71
  const translationsDir = join(rootDir, l10nDir, "translations");
72
72
  const relPath = calculateRelativePath(projectsDir, translationsDir);
73
- const useTypeScript = existsSync(join(rootDir, "tsconfig.json"));
74
- const isEsm = pkg.type === "module";
75
- const ext = useTypeScript ? ".ts" : ".js";
73
+ const isEsm = pkg.type === "module" || existsSync(join(rootDir, "tsconfig.json"));
74
+ const ext = ".js";
76
75
  const outPath = join(projectsDir, `${projectName}${ext}`);
77
76
  if (existsSync(outPath)) {
78
77
  this.error(`A project with the name '${projectName}' already exists.`, { exit: 1 });
@@ -307,7 +307,7 @@ var CreateResource = class _CreateResource extends import_core.Command {
307
307
  { exit: 1 }
308
308
  );
309
309
  }
310
- const ext = pkgInfo.useTypeScript ? ".ts" : ".js";
310
+ const ext = ".js";
311
311
  const outPath = (0, import_path3.join)(resourcesDir, `${title.trim()}.msg${ext}`);
312
312
  if ((0, import_fs3.existsSync)(outPath) && !flags.force) {
313
313
  this.error(
@@ -320,7 +320,7 @@ var CreateResource = class _CreateResource extends import_core.Command {
320
320
  projectName: projectName.trim(),
321
321
  sourceLocale: projectData.sourceLocale,
322
322
  dir: projectData.dir,
323
- isEsm: pkgInfo.isEsm
323
+ isEsm: pkgInfo.isEsm || pkgInfo.useTypeScript
324
324
  });
325
325
  try {
326
326
  writeMsgResourceFile(outPath, content);
@@ -92,7 +92,7 @@ var CreateResource = class _CreateResource extends Command {
92
92
  { exit: 1 }
93
93
  );
94
94
  }
95
- const ext = pkgInfo.useTypeScript ? ".ts" : ".js";
95
+ const ext = ".js";
96
96
  const outPath = join(resourcesDir, `${title.trim()}.msg${ext}`);
97
97
  if (existsSync(outPath) && !flags.force) {
98
98
  this.error(
@@ -105,7 +105,7 @@ var CreateResource = class _CreateResource extends Command {
105
105
  projectName: projectName.trim(),
106
106
  sourceLocale: projectData.sourceLocale,
107
107
  dir: projectData.dir,
108
- isEsm: pkgInfo.isEsm
108
+ isEsm: pkgInfo.isEsm || pkgInfo.useTypeScript
109
109
  });
110
110
  try {
111
111
  writeMsgResourceFile(outPath, content);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldware/msg-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "CLI for msg library",
5
5
  "main": "dist/commands/init.cjs",
6
6
  "module": "dist/commands/init.mjs",
@@ -30,8 +30,8 @@
30
30
  "topicSeparator": " "
31
31
  },
32
32
  "dependencies": {
33
- "@oclif/core": "^4.8.0",
34
- "@worldware/msg": "^0.6.4",
33
+ "@oclif/core": "^3.21.2",
34
+ "@worldware/msg": "^0.7.0",
35
35
  "fast-xml-parser": "^5.3.4"
36
36
  },
37
37
  "devDependencies": {