@lingui/cli 4.7.0 → 4.7.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
@@ -60,7 +60,7 @@ node_modules/.bin/lingui compile
60
60
 
61
61
  ## Usage
62
62
 
63
- See the [tutorial][tutorial] or [reference][reference] documentation.
63
+ See the [reference][reference] documentation.
64
64
 
65
65
  ## License
66
66
 
@@ -69,7 +69,6 @@ This package is licensed under [MIT][license] license.
69
69
  [license]: https://github.com/lingui/js-lingui/blob/main/LICENSE
70
70
  [linguijs]: https://github.com/lingui/js-lingui
71
71
  [documentation]: https://lingui.dev
72
- [tutorial]: https://lingui.dev/tutorials/cli
73
72
  [reference]: https://lingui.dev/ref/cli
74
73
  [package]: https://www.npmjs.com/package/@lingui/cli
75
74
  [badge-downloads]: https://img.shields.io/npm/dw/@lingui/cli.svg
@@ -95,7 +95,9 @@ function getCatalogForFile(file, catalogs) {
95
95
  const catalogGlob = (0, utils_1.replacePlaceholders)(catalogFile, { locale: "*" });
96
96
  const matchPattern = (0, utils_1.normalizeRelativePath)(path_1.default.relative(catalog.config.rootDir, catalogGlob))
97
97
  .replace("(", "\\(")
98
- .replace(")", "\\)");
98
+ .replace(")", "\\)")
99
+ .replace("[", "\\[")
100
+ .replace("]", "\\]");
99
101
  const match = micromatch_1.default.capture(matchPattern, (0, utils_1.normalizeRelativePath)(file));
100
102
  if (match) {
101
103
  return {
@@ -134,14 +134,16 @@ class Catalog {
134
134
  }
135
135
  async writeCompiled(locale, compiledCatalog, namespace) {
136
136
  let ext;
137
- if (namespace === "es") {
138
- ext = "mjs";
139
- }
140
- else if (namespace === "ts") {
141
- ext = "ts";
142
- }
143
- else {
144
- ext = "js";
137
+ switch (namespace) {
138
+ case "es":
139
+ ext = "mjs";
140
+ break;
141
+ case "ts":
142
+ case "json":
143
+ ext = namespace;
144
+ break;
145
+ default:
146
+ ext = "js";
145
147
  }
146
148
  const filename = `${(0, utils_1.replacePlaceholders)(this.path, { locale })}.${ext}`;
147
149
  await (0, utils_1.writeFile)(filename, compiledCatalog);
@@ -53,7 +53,20 @@ function createCompiledCatalog(locale, messages, options) {
53
53
  }
54
54
  exports.createCompiledCatalog = createCompiledCatalog;
55
55
  function buildExportStatement(expression, namespace) {
56
- if (namespace === "es" || namespace === "ts") {
56
+ if (namespace === "ts") {
57
+ // import type { Messages } from "@lingui/core";
58
+ const importMessagesTypeDeclaration = t.importDeclaration([t.importSpecifier(t.identifier("Messages"), t.identifier("Messages"))], t.stringLiteral("@lingui/core"));
59
+ importMessagesTypeDeclaration.importKind = "type";
60
+ // Create the exported `messages` identifier with a `Messages` TS type annotation
61
+ const messagesIdentifier = t.identifier("messages");
62
+ messagesIdentifier.typeAnnotation = t.tsTypeAnnotation(t.tsTypeReference(t.identifier("Messages")));
63
+ // export const messages:Messages = { message: "Translation" }
64
+ const exportDeclaration = t.exportNamedDeclaration(t.variableDeclaration("const", [
65
+ t.variableDeclarator(messagesIdentifier, expression),
66
+ ]));
67
+ return t.program([importMessagesTypeDeclaration, exportDeclaration]);
68
+ }
69
+ else if (namespace === "es") {
57
70
  // export const messages = { message: "Translation" }
58
71
  return t.exportNamedDeclaration(t.variableDeclaration("const", [
59
72
  t.variableDeclarator(t.identifier("messages"), expression),
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.command = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const chokidar_1 = __importDefault(require("chokidar"));
9
- const fs_1 = __importDefault(require("fs"));
10
9
  const commander_1 = require("commander");
11
10
  const conf_1 = require("@lingui/conf");
12
11
  const compile_1 = require("./api/compile");
@@ -62,13 +61,6 @@ async function command(config, options) {
62
61
  compilerBabelOptions: config.compilerBabelOptions,
63
62
  });
64
63
  let compiledPath = await catalog.writeCompiled(locale, compiledCatalog, namespace);
65
- if (options.typescript) {
66
- const typescriptPath = compiledPath.replace(/\.ts?$/, "") + ".d.ts";
67
- fs_1.default.writeFileSync(typescriptPath, `import type { Messages } from '@lingui/core';
68
- declare const messages: Messages;
69
- export { messages };
70
- `);
71
- }
72
64
  compiledPath = (0, utils_1.normalizeSlashes)(path_1.default.relative(config.rootDir, compiledPath));
73
65
  options.verbose &&
74
66
  console.error(chalk_1.default.green(`${locale} ⇒ ${compiledPath}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/cli",
3
- "version": "4.7.0",
3
+ "version": "4.7.2",
4
4
  "description": "CLI for working wit message catalogs",
5
5
  "keywords": [
6
6
  "cli",
@@ -53,11 +53,11 @@
53
53
  "@babel/parser": "^7.21.2",
54
54
  "@babel/runtime": "^7.21.0",
55
55
  "@babel/types": "^7.21.2",
56
- "@lingui/babel-plugin-extract-messages": "4.7.0",
57
- "@lingui/conf": "4.7.0",
58
- "@lingui/core": "4.7.0",
59
- "@lingui/format-po": "4.7.0",
60
- "@lingui/message-utils": "4.7.0",
56
+ "@lingui/babel-plugin-extract-messages": "4.7.2",
57
+ "@lingui/conf": "4.7.2",
58
+ "@lingui/core": "4.7.2",
59
+ "@lingui/format-po": "4.7.2",
60
+ "@lingui/message-utils": "4.7.2",
61
61
  "babel-plugin-macros": "^3.0.1",
62
62
  "chalk": "^4.1.0",
63
63
  "chokidar": "3.5.1",
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "devDependencies": {
82
82
  "@lingui/jest-mocks": "*",
83
- "@lingui/macro": "4.7.0",
83
+ "@lingui/macro": "4.7.2",
84
84
  "@types/convert-source-map": "^2.0.0",
85
85
  "@types/glob": "^8.1.0",
86
86
  "@types/micromatch": "^4.0.1",
@@ -88,5 +88,5 @@
88
88
  "mock-fs": "^5.2.0",
89
89
  "mockdate": "^3.0.5"
90
90
  },
91
- "gitHead": "ebb6353aef59d1b1a29a10ba6ffe94eb42c51a77"
91
+ "gitHead": "f15ce1520efcf33fefc160f6f59fa86ead3183a3"
92
92
  }