@lingui/cli 4.5.0 → 4.7.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.
@@ -93,7 +93,10 @@ function getCatalogForFile(file, catalogs) {
93
93
  for (const catalog of catalogs) {
94
94
  const catalogFile = `${catalog.path}${catalog.format.getCatalogExtension()}`;
95
95
  const catalogGlob = (0, utils_1.replacePlaceholders)(catalogFile, { locale: "*" });
96
- const match = micromatch_1.default.capture((0, utils_1.normalizeRelativePath)(path_1.default.relative(catalog.config.rootDir, catalogGlob)), (0, utils_1.normalizeRelativePath)(file));
96
+ const matchPattern = (0, utils_1.normalizeRelativePath)(path_1.default.relative(catalog.config.rootDir, catalogGlob))
97
+ .replace("(", "\\(")
98
+ .replace(")", "\\)");
99
+ const match = micromatch_1.default.capture(matchPattern, (0, utils_1.normalizeRelativePath)(file));
97
100
  if (match) {
98
101
  return {
99
102
  locale: match[0],
@@ -247,11 +247,14 @@ function orderByOrigin(messages) {
247
247
  }, {});
248
248
  }
249
249
  function orderByMessage(messages) {
250
+ // hardcoded en-US locale to have consistent sorting
251
+ // @see https://github.com/lingui/js-lingui/pull/1808
252
+ const collator = new Intl.Collator("en-US");
250
253
  return Object.keys(messages)
251
254
  .sort((a, b) => {
252
255
  const aMsg = messages[a].message || "";
253
256
  const bMsg = messages[b].message || "";
254
- return aMsg.localeCompare(bMsg);
257
+ return collator.compare(aMsg, bMsg);
255
258
  })
256
259
  .reduce((acc, key) => {
257
260
  ;
@@ -1,8 +1,6 @@
1
1
  export declare const PATHSEP = "/";
2
2
  export declare function prettyOrigin(origins: [filename: string, line?: number][]): string;
3
3
  export declare function replacePlaceholders(input: string, values: Record<string, string>): string;
4
- export declare const splitOrigin: (origin: string) => [file: string, line: number];
5
- export declare const joinOrigin: (origin: [file: string, line?: number]) => string;
6
4
  export declare function readFile(fileName: string): Promise<string | undefined>;
7
5
  export declare function isDirectory(filePath: string): boolean;
8
6
  export declare function writeFile(fileName: string, content: string): Promise<void>;
package/dist/api/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.normalizeRelativePath = exports.normalizeSlashes = exports.makeInstall = exports.hasYarn = exports.writeFileIfChanged = exports.writeFile = exports.isDirectory = exports.readFile = exports.joinOrigin = exports.splitOrigin = exports.replacePlaceholders = exports.prettyOrigin = exports.PATHSEP = void 0;
6
+ exports.normalizeRelativePath = exports.normalizeSlashes = exports.makeInstall = exports.hasYarn = exports.writeFileIfChanged = exports.writeFile = exports.isDirectory = exports.readFile = exports.replacePlaceholders = exports.prettyOrigin = exports.PATHSEP = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const normalize_path_1 = __importDefault(require("normalize-path"));
@@ -24,16 +24,9 @@ function replacePlaceholders(input, values) {
24
24
  });
25
25
  }
26
26
  exports.replacePlaceholders = replacePlaceholders;
27
- const splitOrigin = (origin) => {
28
- const [file, line] = origin.split(":");
29
- return [file, line ? Number(line) : null];
30
- };
31
- exports.splitOrigin = splitOrigin;
32
- const joinOrigin = (origin) => origin.join(":");
33
- exports.joinOrigin = joinOrigin;
34
27
  async function readFile(fileName) {
35
28
  try {
36
- return (await fs_1.default.promises.readFile(fileName)).toString();
29
+ return (await fs_1.default.promises.readFile(fileName, "utf-8")).toString();
37
30
  }
38
31
  catch (err) {
39
32
  if (err.code != "ENOENT") {
@@ -67,7 +60,7 @@ function isDirectory(filePath) {
67
60
  exports.isDirectory = isDirectory;
68
61
  async function writeFile(fileName, content) {
69
62
  await mkdirp(path_1.default.dirname(fileName));
70
- await fs_1.default.promises.writeFile(fileName, content);
63
+ await fs_1.default.promises.writeFile(fileName, content, "utf-8");
71
64
  }
72
65
  exports.writeFile = writeFile;
73
66
  async function writeFileIfChanged(filename, newContent) {
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getPackageJson = exports.buildExternalizeFilter = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
4
8
  function createPackageRegExp(packageName) {
5
9
  return new RegExp("^" + packageName + "(?:\\/.+)?");
6
10
  }
@@ -33,6 +37,11 @@ async function getPackageJson(rootDir) {
33
37
  throw new Error("We could not able to find your package.json file. " +
34
38
  "Check that `rootDir` is pointing to the folder with package.json");
35
39
  }
36
- return await import(packageJsonPath);
40
+ try {
41
+ return JSON.parse(await node_fs_1.default.promises.readFile(packageJsonPath, "utf-8"));
42
+ }
43
+ catch (e) {
44
+ throw new Error(`Unable to read package.json file at path ${packageJsonPath}. \n\n Error: ${e.message}`);
45
+ }
37
46
  }
38
47
  exports.getPackageJson = getPackageJson;
@@ -64,7 +64,7 @@ async function command(config, options) {
64
64
  let compiledPath = await catalog.writeCompiled(locale, compiledCatalog, namespace);
65
65
  if (options.typescript) {
66
66
  const typescriptPath = compiledPath.replace(/\.ts?$/, "") + ".d.ts";
67
- fs_1.default.writeFileSync(typescriptPath, `import { Messages } from '@lingui/core';
67
+ fs_1.default.writeFileSync(typescriptPath, `import type { Messages } from '@lingui/core';
68
68
  declare const messages: Messages;
69
69
  export { messages };
70
70
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/cli",
3
- "version": "4.5.0",
3
+ "version": "4.7.0",
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.5.0",
57
- "@lingui/conf": "4.5.0",
58
- "@lingui/core": "4.5.0",
59
- "@lingui/format-po": "4.5.0",
60
- "@lingui/message-utils": "4.5.0",
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",
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.5.0",
83
+ "@lingui/macro": "4.7.0",
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": "62c92d1f8c60b3890bdda870f307fa780d423080"
91
+ "gitHead": "ebb6353aef59d1b1a29a10ba6ffe94eb42c51a77"
92
92
  }