@lingui/cli 4.0.0-next.5 → 4.0.0-next.6

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 (66) hide show
  1. package/dist/api/catalog/extractFromFiles.d.ts +5 -0
  2. package/dist/api/catalog/extractFromFiles.js +27 -44
  3. package/dist/api/catalog/getCatalogs.d.ts +14 -0
  4. package/dist/api/catalog/getCatalogs.js +70 -78
  5. package/dist/api/catalog/getTranslationsForCatalog.d.ts +14 -0
  6. package/dist/api/catalog/getTranslationsForCatalog.js +36 -32
  7. package/dist/api/catalog/mergeCatalog.d.ts +3 -0
  8. package/dist/api/catalog/mergeCatalog.js +43 -74
  9. package/dist/api/catalog.d.ts +66 -0
  10. package/dist/api/catalog.js +144 -169
  11. package/dist/api/compile.d.ts +19 -0
  12. package/dist/api/compile.js +60 -87
  13. package/dist/api/extractors/babel.d.ts +3 -0
  14. package/dist/api/extractors/babel.js +43 -100
  15. package/dist/api/extractors/index.d.ts +6 -0
  16. package/dist/api/extractors/index.js +17 -23
  17. package/dist/api/extractors/typescript.d.ts +3 -0
  18. package/dist/api/extractors/typescript.js +7 -11
  19. package/dist/api/formats/formatterWrapper.d.ts +10 -0
  20. package/dist/api/formats/formatterWrapper.js +14 -19
  21. package/dist/api/formats/index.d.ts +5 -0
  22. package/dist/api/formats/index.js +15 -63
  23. package/dist/api/help.d.ts +1 -0
  24. package/dist/api/help.js +12 -13
  25. package/dist/api/index.d.ts +4 -0
  26. package/dist/api/index.js +24 -30
  27. package/dist/api/pseudoLocalize.d.ts +1 -0
  28. package/dist/api/pseudoLocalize.js +23 -27
  29. package/dist/api/rethrownError.d.ts +4 -0
  30. package/dist/api/rethrownError.js +4 -9
  31. package/dist/api/stats.d.ts +6 -0
  32. package/dist/api/stats.js +23 -55
  33. package/dist/api/types.d.ts +5 -0
  34. package/dist/api/types.js +1 -3
  35. package/dist/api/utils.d.ts +22 -0
  36. package/dist/api/utils.js +61 -59
  37. package/dist/extract-experimental/buildExternalizeFilter.d.ts +13 -0
  38. package/dist/extract-experimental/buildExternalizeFilter.js +19 -64
  39. package/dist/extract-experimental/bundleSource.d.ts +2 -0
  40. package/dist/extract-experimental/bundleSource.js +25 -74
  41. package/dist/extract-experimental/constants.d.ts +2 -0
  42. package/dist/extract-experimental/constants.js +4 -15
  43. package/dist/extract-experimental/getEntryPoints.d.ts +1 -0
  44. package/dist/extract-experimental/getEntryPoints.js +8 -16
  45. package/dist/extract-experimental/getExperimentalCatalogs.d.ts +3 -0
  46. package/dist/extract-experimental/getExperimentalCatalogs.js +15 -19
  47. package/dist/extract-experimental/resolveCatalogPath.d.ts +2 -0
  48. package/dist/extract-experimental/resolveCatalogPath.js +13 -24
  49. package/dist/extract-experimental/resolveTemplatePath.d.ts +1 -0
  50. package/dist/extract-experimental/resolveTemplatePath.js +11 -14
  51. package/dist/extract-experimental/writeCatalogs.d.ts +21 -0
  52. package/dist/extract-experimental/writeCatalogs.js +23 -36
  53. package/dist/lingui-compile.d.ts +9 -0
  54. package/dist/lingui-compile.js +94 -82
  55. package/dist/lingui-extract-experimental.d.ts +10 -0
  56. package/dist/lingui-extract-experimental.js +58 -67
  57. package/dist/lingui-extract-template.d.ts +6 -0
  58. package/dist/lingui-extract-template.js +29 -35
  59. package/dist/lingui-extract.d.ts +11 -0
  60. package/dist/lingui-extract.js +81 -117
  61. package/dist/lingui.d.ts +2 -0
  62. package/dist/lingui.js +11 -6
  63. package/dist/services/translationIO.d.ts +3 -0
  64. package/dist/services/translationIO.js +92 -89
  65. package/package.json +23 -14
  66. package/dist/tests.js +0 -137
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/cli",
3
- "version": "4.0.0-next.5",
3
+ "version": "4.0.0-next.6",
4
4
  "description": "CLI for working wit message catalogs",
5
5
  "keywords": [
6
6
  "cli",
@@ -27,17 +27,26 @@
27
27
  "require": "./dist/lingui.js"
28
28
  },
29
29
  "./api": {
30
- "require": "./dist/api/index.js"
30
+ "require": {
31
+ "types": "./dist/api/index.d.ts",
32
+ "default": "./dist/api/index.js"
33
+ }
31
34
  },
32
35
  "./api/extractors/babel": {
33
- "require": "./dist/api/extractors/babel.js"
36
+ "require": {
37
+ "types": "./dist/api/extractors/babel.d.ts",
38
+ "default": "./dist/api/extractors/babel.js"
39
+ }
34
40
  },
35
41
  "./api/extractors/typescript": {
36
- "require": "./dist/api/extractors/typescript.js"
42
+ "require": {
43
+ "types": "./dist/api/extractors/typescript.d.ts",
44
+ "default": "./dist/api/extractors/typescript.js"
45
+ }
37
46
  }
38
47
  },
39
48
  "scripts": {
40
- "build": "rimraf ./dist && swc ./src -d dist"
49
+ "build": "rimraf ./dist && tsc -p tsconfig.build.json"
41
50
  },
42
51
  "engines": {
43
52
  "node": ">=16.0.0"
@@ -53,11 +62,11 @@
53
62
  "@babel/parser": "^7.21.2",
54
63
  "@babel/runtime": "^7.21.0",
55
64
  "@babel/types": "^7.21.2",
56
- "@lingui/babel-plugin-extract-messages": "^4.0.0-next.5",
57
- "@lingui/conf": "^4.0.0-next.5",
58
- "@lingui/core": "^4.0.0-next.5",
59
- "@lingui/format-po": "^4.0.0-next.5",
60
- "@lingui/message-utils": "^4.0.0-next.5",
65
+ "@lingui/babel-plugin-extract-messages": "^4.0.0-next.6",
66
+ "@lingui/conf": "^4.0.0-next.6",
67
+ "@lingui/core": "^4.0.0-next.6",
68
+ "@lingui/format-po": "^4.0.0-next.6",
69
+ "@lingui/message-utils": "^4.0.0-next.6",
61
70
  "babel-plugin-macros": "^3.0.1",
62
71
  "chalk": "^4.1.0",
63
72
  "chokidar": "3.5.1",
@@ -73,19 +82,19 @@
73
82
  "ora": "^5.1.0",
74
83
  "pkg-up": "^3.1.0",
75
84
  "pofile": "^1.1.4",
76
- "pseudolocale": "^1.1.0",
85
+ "pseudolocale": "^2.0.0",
77
86
  "ramda": "^0.27.1",
78
87
  "source-map": "^0.8.0-beta.0"
79
88
  },
80
89
  "devDependencies": {
81
90
  "@lingui/jest-mocks": "^3.0.3",
82
- "@swc/cli": "^0.1.62",
83
- "@swc/core": "^1.3.42",
91
+ "@lingui/macro": "^4.0.0-next.6",
84
92
  "@types/convert-source-map": "^2.0.0",
93
+ "@types/glob": "^8.1.0",
85
94
  "@types/micromatch": "^4.0.1",
86
95
  "@types/normalize-path": "^3.0.0",
87
96
  "mock-fs": "^5.2.0",
88
97
  "mockdate": "^3.0.5"
89
98
  },
90
- "gitHead": "bdbd6cf310cbcf09e1fe288f20ef530c28de481d"
99
+ "gitHead": "d4d9e149b2419d1796e14176d53703a7cff4b82c"
91
100
  }
package/dist/tests.js DELETED
@@ -1,137 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- copyFixture: ()=>copyFixture,
13
- defaultMakeOptions: ()=>defaultMakeOptions,
14
- defaultMakeTemplateOptions: ()=>defaultMakeTemplateOptions,
15
- defaultMergeOptions: ()=>defaultMergeOptions,
16
- normalizeLineEndings: ()=>normalizeLineEndings,
17
- makeCatalog: ()=>makeCatalog,
18
- makePrevMessage: ()=>makePrevMessage,
19
- makeNextMessage: ()=>makeNextMessage,
20
- listingToHumanReadable: ()=>listingToHumanReadable,
21
- createFixtures: ()=>createFixtures,
22
- readFsToJson: ()=>readFsToJson
23
- });
24
- const _os = /*#__PURE__*/ _interopRequireDefault(require("os"));
25
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
26
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
27
- const _catalog = require("./api/catalog");
28
- const _conf = require("@lingui/conf");
29
- const _api = require("./api");
30
- function _interopRequireDefault(obj) {
31
- return obj && obj.__esModule ? obj : {
32
- default: obj
33
- };
34
- }
35
- async function copyFixture(fixtureDir) {
36
- const tmpDir = await _fs.default.promises.mkdtemp(_path.default.join(_os.default.tmpdir(), `lingui-test-${process.pid}`));
37
- try {
38
- await _fs.default.promises.cp(fixtureDir, tmpDir, {
39
- recursive: true
40
- });
41
- } catch (err) {
42
- if (err.code != "ENOENT") {
43
- throw err;
44
- }
45
- }
46
- return tmpDir;
47
- }
48
- const defaultMakeOptions = {
49
- verbose: false,
50
- clean: false,
51
- overwrite: false,
52
- locale: null,
53
- prevFormat: null,
54
- orderBy: "messageId"
55
- };
56
- const defaultMakeTemplateOptions = {
57
- verbose: false,
58
- orderBy: "messageId"
59
- };
60
- const defaultMergeOptions = {
61
- overwrite: false
62
- };
63
- const normalizeLineEndings = (str)=>str.replace(/\r?\n/g, "\r\n");
64
- const makeCatalog = async (_config = {})=>{
65
- const config = (0, _conf.makeConfig)(_config, {
66
- skipValidation: true
67
- });
68
- return new _catalog.Catalog({
69
- name: "messages",
70
- path: "{locale}/messages",
71
- include: [],
72
- exclude: [],
73
- format: await (0, _api.getFormat)(config.format, config.formatOptions, config.sourceLocale)
74
- }, config);
75
- };
76
- function makePrevMessage(message = {}) {
77
- return {
78
- translation: "",
79
- ...makeNextMessage(message)
80
- };
81
- }
82
- function makeNextMessage(message = {}) {
83
- return {
84
- origin: [
85
- [
86
- "catalog.test.ts",
87
- 1
88
- ]
89
- ],
90
- obsolete: false,
91
- ...message
92
- };
93
- }
94
- function listingToHumanReadable(listing) {
95
- const output = [];
96
- Object.entries(listing).forEach(([filename, value])=>{
97
- if (typeof value === "string") {
98
- output.push("#######################");
99
- output.push(`Filename: ${filename}`);
100
- output.push("#######################");
101
- output.push("");
102
- output.push(normalizeLineEndings(value));
103
- output.push("");
104
- } else {
105
- output.push(...listingToHumanReadable(value));
106
- }
107
- });
108
- return output.join("\n");
109
- }
110
- async function createFixtures(listing) {
111
- const tmpDir = await _fs.default.promises.mkdtemp(_path.default.join(_os.default.tmpdir(), `lingui-test-${process.pid}`));
112
- async function create(listing) {
113
- for (const [filename, value] of Object.entries(listing)){
114
- if (typeof value === "string") {
115
- await _fs.default.promises.writeFile(_path.default.join(tmpDir, filename), value);
116
- } else {
117
- await create(value);
118
- }
119
- }
120
- }
121
- await create(listing);
122
- return tmpDir;
123
- }
124
- function readFsToJson(directory, filter) {
125
- const out = {};
126
- _fs.default.readdirSync(directory).map((filename)=>{
127
- const filepath = _path.default.join(directory, filename);
128
- if (_fs.default.lstatSync(filepath).isDirectory()) {
129
- out[filename] = readFsToJson(filepath);
130
- return out;
131
- }
132
- if (!filter || filter(filename)) {
133
- out[filename] = _fs.default.readFileSync(filepath).toString();
134
- }
135
- });
136
- return out;
137
- }