@lingual/i18n-check 0.8.1 → 0.8.3

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.
@@ -1,299 +1,358 @@
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
  const child_process_1 = require("child_process");
4
- describe("CLI", () => {
5
- describe("JSON", () => {
6
- it("should return the missing keys for single folder translations", (done) => {
7
- (0, child_process_1.exec)("node dist/bin/index.js -s en-US -l translations/flattenExamples", (_error, stdout, _stderr) => {
8
- const result = stdout.split("Done")[0];
9
- expect(result).toEqual(`i18n translations checker
7
+ const errorReporters_1 = require("../errorReporters");
8
+ const path_1 = __importDefault(require("path"));
9
+ function tr(file) {
10
+ return path_1.default.join('translations', file);
11
+ }
12
+ function multiFiles(file) {
13
+ return path_1.default.join('translations/multipleFilesFolderExample', file);
14
+ }
15
+ function multiFolders(file) {
16
+ return path_1.default.join('translations/multipleFoldersExample', file);
17
+ }
18
+ function codeEx(file) {
19
+ return path_1.default.join('translations/codeExamples', file);
20
+ }
21
+ function ymlMultiFolders(file) {
22
+ return path_1.default.join('translations/yaml/multipleFoldersExample', file);
23
+ }
24
+ function execAsync(cmd) {
25
+ return new Promise((resolve) => {
26
+ (0, child_process_1.exec)(cmd, (error, stdout) => {
27
+ resolve(stdout);
28
+ });
29
+ });
30
+ }
31
+ describe('CLI', () => {
32
+ describe('JSON', () => {
33
+ it('should return the missing keys for single folder translations', async () => {
34
+ const stdout = await execAsync('node dist/bin/index.js -s en-US -l translations/flattenExamples');
35
+ const result = stdout.split('Done')[0];
36
+ const filePath = tr('flattenExamples/de-de.json');
37
+ const table = (0, errorReporters_1.formatTable)([
38
+ [['file', 'key']],
39
+ [
40
+ [filePath, 'other.nested.three'],
41
+ [filePath, 'other.nested.deep.more.final'],
42
+ ],
43
+ ]);
44
+ expect(result).toEqual(`i18n translations checker
10
45
  Source: en-US
11
46
 
12
47
  Found missing keys!
13
- ┌───────────────────────────────────────────┬────────────────────────────────┐
14
- │ file │ key │
15
- ├───────────────────────────────────────────┼────────────────────────────────┤
16
- │ translations/flattenExamples/de-de.json │ other.nested.three │
17
- │ translations/flattenExamples/de-de.json │ other.nested.deep.more.final │
18
- └───────────────────────────────────────────┴────────────────────────────────┘
48
+ ${table}
19
49
 
20
50
  No invalid translations found!
21
51
 
22
52
  `);
23
- done();
24
- });
25
53
  });
26
- it("should return the missing/invalid keys for folder per locale with single file", (done) => {
27
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/folderExample/ -s en-US", (_error, stdout, _stderr) => {
28
- const result = stdout.split("Done")[0];
29
- expect(result).toEqual(`i18n translations checker
54
+ it('should return the missing/invalid keys for folder per locale with single file', async () => {
55
+ const stdout = await execAsync('node dist/bin/index.js -l translations/folderExample/ -s en-US');
56
+ const result = stdout.split('Done')[0];
57
+ const missingKeysTable = (0, errorReporters_1.formatTable)([
58
+ [['file', 'key']],
59
+ [[tr('folderExample/de-DE/index.json'), 'message.text-format']],
60
+ ]);
61
+ const invalidKeysTable = (0, errorReporters_1.formatTable)([
62
+ [['info', 'result']],
63
+ [
64
+ ['file', tr('folderExample/de-DE/index.json')],
65
+ ['key', 'message.select'],
66
+ [
67
+ 'msg',
68
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
69
+ ],
70
+ ],
71
+ ]);
72
+ expect(result).toEqual(`i18n translations checker
30
73
  Source: en-US
31
74
 
32
75
  Found missing keys!
33
- ┌───────────────────────────────────────────────┬───────────────────────┐
34
- │ file │ key │
35
- ├───────────────────────────────────────────────┼───────────────────────┤
36
- │ translations/folderExample/de-DE/index.json │ message.text-format │
37
- └───────────────────────────────────────────────┴───────────────────────┘
76
+ ${missingKeysTable}
38
77
 
39
78
  Found invalid keys!
40
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
41
- │ info │ result │
42
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
43
- │ file │ translations/folderExample/de-DE/index.json │
44
- │ key │ message.select │
45
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
46
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
79
+ ${invalidKeysTable}
47
80
 
48
81
  `);
49
- done();
50
- });
51
82
  });
52
- it("should return the missing/invalid keys for folder per locale with multiple files", (done) => {
53
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/multipleFilesFolderExample/ -s en-US", (_error, stdout, _stderr) => {
54
- const result = stdout.split("Done")[0];
55
- expect(result).toEqual(`i18n translations checker
83
+ it('should return the missing/invalid keys for folder per locale with multiple files', async () => {
84
+ const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFilesFolderExample/ -s en-US');
85
+ const missingKeysTable = (0, errorReporters_1.formatTable)([
86
+ [['file', 'key']],
87
+ [
88
+ [multiFiles('de-DE/one.json'), 'message.text-format'],
89
+ [multiFiles('de-DE/two.json'), 'test.drive.four'],
90
+ ],
91
+ ]);
92
+ const invalidKeysTable = (0, errorReporters_1.formatTable)([
93
+ [['info', 'result']],
94
+ [
95
+ ['file', multiFiles('de-DE/one.json')],
96
+ ['key', 'message.select'],
97
+ [
98
+ 'msg',
99
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
100
+ ],
101
+ ],
102
+ [
103
+ ['file', multiFiles('de-DE/three.json')],
104
+ ['key', 'multipleVariables'],
105
+ ['msg', 'Expected argument to contain "user" but received "name" '],
106
+ ],
107
+ ]);
108
+ const result = stdout.split('Done')[0];
109
+ expect(result).toEqual(`i18n translations checker
56
110
  Source: en-US
57
111
 
58
112
  Found missing keys!
59
- ┌──────────────────────────────────────────────────────────┬───────────────────────┐
60
- │ file │ key │
61
- ├──────────────────────────────────────────────────────────┼───────────────────────┤
62
- │ translations/multipleFilesFolderExample/de-DE/one.json │ message.text-format │
63
- │ translations/multipleFilesFolderExample/de-DE/two.json │ test.drive.four │
64
- └──────────────────────────────────────────────────────────┴───────────────────────┘
113
+ ${missingKeysTable}
65
114
 
66
115
  Found invalid keys!
67
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
68
- │ info │ result │
69
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
70
- │ file │ translations/multipleFilesFolderExample/de-DE/one.json │
71
- │ key │ message.select │
72
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
73
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
74
- │ file │ translations/multipleFilesFolderExample/de-DE/three.json │
75
- │ key │ multipleVariables │
76
- │ msg │ Expected argument to contain "user" but received "name" │
77
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
116
+ ${invalidKeysTable}
78
117
 
79
118
  `);
80
- done();
81
- });
82
119
  });
83
- it("should return the missing/invalid keys for folder containing multiple locale folders", (done) => {
84
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/multipleFoldersExample -s en-US", (_error, stdout, _stderr) => {
85
- const result = stdout.split("Done")[0];
86
- expect(result).toEqual(`i18n translations checker
120
+ it('should return the missing/invalid keys for folder containing multiple locale folders', async () => {
121
+ const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFoldersExample -s en-US');
122
+ const result = stdout.split('Done')[0];
123
+ expect(result).toEqual(`i18n translations checker
87
124
  Source: en-US
88
125
 
89
126
  Found missing keys!
90
- ┌───────────────────────────────────────────────────────────────────────┬───────────────────────┐
91
- file key
92
- ├───────────────────────────────────────────────────────────────────────┼───────────────────────┤
93
- │ translations/multipleFoldersExample/spaceOne/locales/de-DE/one.jsonmessage.text-format
94
- │ translations/multipleFoldersExample/spaceOne/locales/de-DE/two.jsontest.drive.four
95
- │ translations/multipleFoldersExample/spaceTwo/locales/de-DE/one.jsonmessage.plural
96
- │ translations/multipleFoldersExample/spaceTwo/locales/de-DE/two.jsontest.drive.two
97
- └───────────────────────────────────────────────────────────────────────┴───────────────────────┘
127
+ ${(0, errorReporters_1.formatTable)([
128
+ [['file', 'key']],
129
+ [
130
+ [multiFolders('spaceOne/locales/de-DE/one.json'), 'message.text-format'],
131
+ [multiFolders('spaceOne/locales/de-DE/two.json'), 'test.drive.four'],
132
+ [multiFolders('spaceTwo/locales/de-DE/one.json'), 'message.plural'],
133
+ [multiFolders('spaceTwo/locales/de-DE/two.json'), 'test.drive.two'],
134
+ ],
135
+ ])}
98
136
 
99
137
  Found invalid keys!
100
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
101
- info result
102
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
103
- file │ translations/multipleFoldersExample/spaceOne/locales/de-DE/one.json
104
- keymessage.select
105
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
106
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
107
- │ file │ translations/multipleFoldersExample/spaceOne/locales/de-DE/three.json │
108
- │ key │ multipleVariables │
109
- │ msg │ Expected argument to contain "user" but received "name" │
110
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
111
- file │ translations/multipleFoldersExample/spaceTwo/locales/de-DE/one.json
112
- key │ message.text-format │
113
- msgExpected element of type "tag" but received "number", Unexpected tag element │
114
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
115
- │ file │ translations/multipleFoldersExample/spaceTwo/locales/de-DE/three.json │
116
- │ key │ numberFormat │
117
- │ msg │ Missing element number │
118
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
138
+ ${(0, errorReporters_1.formatTable)([
139
+ [['info', 'result']],
140
+ [
141
+ ['file', multiFolders('spaceOne/locales/de-DE/one.json')],
142
+ ['key', 'message.select'],
143
+ [
144
+ 'msg',
145
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
146
+ ],
147
+ ],
148
+ [
149
+ ['file', multiFolders('spaceOne/locales/de-DE/three.json')],
150
+ ['key', 'multipleVariables'],
151
+ ['msg', 'Expected argument to contain "user" but received "name"'],
152
+ ],
153
+ [
154
+ ['file', multiFolders('spaceTwo/locales/de-DE/one.json')],
155
+ ['key', 'message.text-format'],
156
+ [
157
+ 'msg',
158
+ 'Expected element of type "tag" but received "number", Unexpected tag element',
159
+ ],
160
+ ],
161
+ [
162
+ ['file', multiFolders('spaceTwo/locales/de-DE/three.json')],
163
+ ['key', 'numberFormat'],
164
+ ['msg', 'Missing element number'],
165
+ ],
166
+ ])}
119
167
 
120
168
  `);
121
- done();
122
- });
123
169
  });
124
- it("should return the missing/invalid keys for multiple locale folders", (done) => {
125
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/multipleFoldersExample/spaceOne translations/multipleFoldersExample/spaceTwo -s en-US", (_error, stdout, _stderr) => {
126
- const result = stdout.split("Done")[0];
127
- expect(result).toEqual(`i18n translations checker
170
+ it('should return the missing/invalid keys for multiple locale folders', async () => {
171
+ const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFoldersExample/spaceOne translations/multipleFoldersExample/spaceTwo -s en-US');
172
+ const result = stdout.split('Done')[0];
173
+ expect(result).toEqual(`i18n translations checker
128
174
  Source: en-US
129
175
 
130
176
  Found missing keys!
131
- ┌───────────────────────────────────────────────────────────────────────┬───────────────────────┐
132
- file key
133
- ├───────────────────────────────────────────────────────────────────────┼───────────────────────┤
134
- │ translations/multipleFoldersExample/spaceOne/locales/de-DE/one.jsonmessage.text-format
135
- │ translations/multipleFoldersExample/spaceOne/locales/de-DE/two.jsontest.drive.four
136
- │ translations/multipleFoldersExample/spaceTwo/locales/de-DE/one.jsonmessage.plural
137
- │ translations/multipleFoldersExample/spaceTwo/locales/de-DE/two.jsontest.drive.two
138
- └───────────────────────────────────────────────────────────────────────┴───────────────────────┘
177
+ ${(0, errorReporters_1.formatTable)([
178
+ [['file', 'key']],
179
+ [
180
+ [multiFolders('spaceOne/locales/de-DE/one.json'), 'message.text-format'],
181
+ [multiFolders('spaceOne/locales/de-DE/two.json'), 'test.drive.four'],
182
+ [multiFolders('spaceTwo/locales/de-DE/one.json'), 'message.plural'],
183
+ [multiFolders('spaceTwo/locales/de-DE/two.json'), 'test.drive.two'],
184
+ ],
185
+ ])}
139
186
 
140
187
  Found invalid keys!
141
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
142
- info result
143
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
144
- file │ translations/multipleFoldersExample/spaceOne/locales/de-DE/one.json
145
- keymessage.select
146
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
147
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
148
- │ file │ translations/multipleFoldersExample/spaceOne/locales/de-DE/three.json │
149
- │ key │ multipleVariables │
150
- │ msg │ Expected argument to contain "user" but received "name" │
151
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
152
- file │ translations/multipleFoldersExample/spaceTwo/locales/de-DE/one.json
153
- key │ message.text-format │
154
- msgExpected element of type "tag" but received "number", Unexpected tag element │
155
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
156
- │ file │ translations/multipleFoldersExample/spaceTwo/locales/de-DE/three.json │
157
- │ key │ numberFormat │
158
- │ msg │ Missing element number │
159
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
188
+ ${(0, errorReporters_1.formatTable)([
189
+ [['info', 'result']],
190
+ [
191
+ ['file', multiFolders('spaceOne/locales/de-DE/one.json')],
192
+ ['key', 'message.select'],
193
+ [
194
+ 'msg',
195
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
196
+ ],
197
+ ],
198
+ [
199
+ ['file', multiFolders('spaceOne/locales/de-DE/three.json')],
200
+ ['key', 'multipleVariables'],
201
+ ['msg', 'Expected argument to contain "user" but received "name"'],
202
+ ],
203
+ [
204
+ ['file', multiFolders('spaceTwo/locales/de-DE/one.json')],
205
+ ['key', 'message.text-format'],
206
+ [
207
+ 'msg',
208
+ 'Expected element of type "tag" but received "number", Unexpected tag element',
209
+ ],
210
+ ],
211
+ [
212
+ ['file', multiFolders('spaceTwo/locales/de-DE/three.json')],
213
+ ['key', 'numberFormat'],
214
+ ['msg', 'Missing element number'],
215
+ ],
216
+ ])}
160
217
 
161
218
  `);
162
- done();
163
- });
164
219
  });
165
- it("should return the missing/invalid keys for all files in the provided locale folders", (done) => {
166
- (0, child_process_1.exec)("node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples", (_error, stdout, _stderr) => {
167
- const result = stdout.split("Done")[0];
168
- expect(result).toEqual(`i18n translations checker
220
+ it('should return the missing/invalid keys for all files in the provided locale folders', async () => {
221
+ const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples');
222
+ const result = stdout.split('Done')[0];
223
+ expect(result).toEqual(`i18n translations checker
169
224
  Source: en-US
170
225
 
171
226
  Found missing keys!
172
- ┌───────────────────────────────────────────┬────────────────────────────────┐
173
- file key
174
- ├───────────────────────────────────────────┼────────────────────────────────┤
175
- │ translations/flattenExamples/de-de.jsonother.nested.three
176
- │ translations/flattenExamples/de-de.jsonother.nested.deep.more.final
177
- │ translations/messageExamples/de-de.jsonrichText
178
- │ translations/messageExamples/de-de.jsonyo
179
- │ translations/messageExamples/de-de.jsonnesting1
180
- │ translations/messageExamples/de-de.jsonnesting2
181
- │ translations/messageExamples/de-de.jsonnesting3
182
- │ translations/messageExamples/de-de.jsonkey1
183
- └───────────────────────────────────────────┴────────────────────────────────┘
227
+ ${(0, errorReporters_1.formatTable)([
228
+ [['file', 'key']],
229
+ [
230
+ [tr('flattenExamples/de-de.json'), 'other.nested.three'],
231
+ [tr('flattenExamples/de-de.json'), 'other.nested.deep.more.final'],
232
+ [tr('messageExamples/de-de.json'), 'richText'],
233
+ [tr('messageExamples/de-de.json'), 'yo'],
234
+ [tr('messageExamples/de-de.json'), 'nesting1'],
235
+ [tr('messageExamples/de-de.json'), 'nesting2'],
236
+ [tr('messageExamples/de-de.json'), 'nesting3'],
237
+ [tr('messageExamples/de-de.json'), 'key1'],
238
+ ],
239
+ ])}
184
240
 
185
241
  Found invalid keys!
186
- ┌────────┬───────────────────────────────────────────┐
187
- info result
188
- ├────────┼───────────────────────────────────────────┤
189
- file │ translations/messageExamples/de-de.json
190
- keymultipleVariables
191
- msgUnexpected date element
192
- └────────┴───────────────────────────────────────────┘
242
+ ${(0, errorReporters_1.formatTable)([
243
+ [['info', 'result']],
244
+ [
245
+ ['file', tr('messageExamples/de-de.json')],
246
+ ['key', 'multipleVariables'],
247
+ ['msg', 'Unexpected date element'],
248
+ ],
249
+ ])}
193
250
 
194
251
  `);
195
- done();
196
- });
197
252
  });
198
- it("should return the missing/invalid keys for all files with source matching folder and source matching file", (done) => {
199
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/multipleFilesFolderExample translations/flattenExamples -s en-US", (_error, stdout, _stderr) => {
200
- const result = stdout.split("Done")[0];
201
- expect(result).toEqual(`i18n translations checker
253
+ it('should return the missing/invalid keys for all files with source matching folder and source matching file', async () => {
254
+ const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFilesFolderExample translations/flattenExamples -s en-US');
255
+ const result = stdout.split('Done')[0];
256
+ expect(result).toEqual(`i18n translations checker
202
257
  Source: en-US
203
258
 
204
259
  Found missing keys!
205
- ┌──────────────────────────────────────────────────────────┬────────────────────────────────┐
206
- file key
207
- ├──────────────────────────────────────────────────────────┼────────────────────────────────┤
208
- │ translations/flattenExamples/de-de.jsonother.nested.three
209
- │ translations/flattenExamples/de-de.jsonother.nested.deep.more.final
210
- │ translations/multipleFilesFolderExample/de-DE/one.jsonmessage.text-format
211
- │ translations/multipleFilesFolderExample/de-DE/two.jsontest.drive.four
212
- └──────────────────────────────────────────────────────────┴────────────────────────────────┘
260
+ ${(0, errorReporters_1.formatTable)([
261
+ [['file', 'key']],
262
+ [
263
+ [tr('flattenExamples/de-de.json'), 'other.nested.three'],
264
+ [tr('flattenExamples/de-de.json'), 'other.nested.deep.more.final'],
265
+ [multiFiles('de-DE/one.json'), 'message.text-format'],
266
+ [multiFiles('de-DE/two.json'), 'test.drive.four'],
267
+ ],
268
+ ])}
213
269
 
214
270
  Found invalid keys!
215
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
216
- info result
217
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
218
- file │ translations/multipleFilesFolderExample/de-DE/one.json
219
- keymessage.select
220
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
221
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
222
- │ file │ translations/multipleFilesFolderExample/de-DE/three.json │
223
- │ key │ multipleVariables │
224
- │ msg │ Expected argument to contain "user" but received "name" │
225
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
271
+ ${(0, errorReporters_1.formatTable)([
272
+ [['info', 'result']],
273
+ [
274
+ ['file', multiFiles('de-DE/one.json')],
275
+ ['key', 'message.select'],
276
+ [
277
+ 'msg',
278
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
279
+ ],
280
+ ],
281
+ [
282
+ ['file', multiFiles('de-DE/three.json')],
283
+ ['key', 'multipleVariables'],
284
+ ['msg', 'Expected argument to contain "user" but received "name"'],
285
+ ],
286
+ ])}
226
287
 
227
288
  `);
228
- done();
229
- });
230
289
  });
231
- it("should ignore the excluded file", (done) => {
232
- (0, child_process_1.exec)("node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/de-de.json", (_error, stdout, _stderr) => {
233
- const result = stdout.split("Done")[0];
234
- expect(result).toEqual(`i18n translations checker
290
+ it('should ignore the excluded file', async () => {
291
+ const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/de-de.json');
292
+ const result = stdout.split('Done')[0];
293
+ expect(result).toEqual(`i18n translations checker
235
294
  Source: en-US
236
295
 
237
296
  Found missing keys!
238
- ┌───────────────────────────────────────────┬────────────┐
239
- file key
240
- ├───────────────────────────────────────────┼────────────┤
241
- │ translations/messageExamples/de-de.jsonrichText
242
- │ translations/messageExamples/de-de.jsonyo
243
- │ translations/messageExamples/de-de.jsonnesting1
244
- │ translations/messageExamples/de-de.jsonnesting2
245
- │ translations/messageExamples/de-de.jsonnesting3
246
- │ translations/messageExamples/de-de.jsonkey1
247
- └───────────────────────────────────────────┴────────────┘
297
+ ${(0, errorReporters_1.formatTable)([
298
+ [['file', 'key']],
299
+ [
300
+ [tr('messageExamples/de-de.json'), 'richText'],
301
+ [tr('messageExamples/de-de.json'), 'yo'],
302
+ [tr('messageExamples/de-de.json'), 'nesting1'],
303
+ [tr('messageExamples/de-de.json'), 'nesting2'],
304
+ [tr('messageExamples/de-de.json'), 'nesting3'],
305
+ [tr('messageExamples/de-de.json'), 'key1'],
306
+ ],
307
+ ])}
248
308
 
249
309
  Found invalid keys!
250
- ┌────────┬───────────────────────────────────────────┐
251
- info result
252
- ├────────┼───────────────────────────────────────────┤
253
- file │ translations/messageExamples/de-de.json
254
- keymultipleVariables
255
- msgUnexpected date element
256
- └────────┴───────────────────────────────────────────┘
310
+ ${(0, errorReporters_1.formatTable)([
311
+ [['info', 'result']],
312
+ [
313
+ ['file', tr('messageExamples/de-de.json')],
314
+ ['key', 'multipleVariables'],
315
+ ['msg', 'Unexpected date element'],
316
+ ],
317
+ ])}
257
318
 
258
319
  `);
259
- done();
260
- });
261
320
  });
262
- it("should ignore the excluded folder", (done) => {
263
- (0, child_process_1.exec)("node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/*", (_error, stdout, _stderr) => {
264
- const result = stdout.split("Done")[0];
265
- expect(result).toEqual(`i18n translations checker
321
+ it('should ignore the excluded folder', async () => {
322
+ const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/*');
323
+ const result = stdout.split('Done')[0];
324
+ expect(result).toEqual(`i18n translations checker
266
325
  Source: en-US
267
326
 
268
327
  Found missing keys!
269
- ┌───────────────────────────────────────────┬────────────┐
270
- file key
271
- ├───────────────────────────────────────────┼────────────┤
272
- │ translations/messageExamples/de-de.jsonrichText
273
- │ translations/messageExamples/de-de.jsonyo
274
- │ translations/messageExamples/de-de.jsonnesting1
275
- │ translations/messageExamples/de-de.jsonnesting2
276
- │ translations/messageExamples/de-de.jsonnesting3
277
- │ translations/messageExamples/de-de.jsonkey1
278
- └───────────────────────────────────────────┴────────────┘
328
+ ${(0, errorReporters_1.formatTable)([
329
+ [['file', 'key']],
330
+ [
331
+ [tr('messageExamples/de-de.json'), 'richText'],
332
+ [tr('messageExamples/de-de.json'), 'yo'],
333
+ [tr('messageExamples/de-de.json'), 'nesting1'],
334
+ [tr('messageExamples/de-de.json'), 'nesting2'],
335
+ [tr('messageExamples/de-de.json'), 'nesting3'],
336
+ [tr('messageExamples/de-de.json'), 'key1'],
337
+ ],
338
+ ])}
279
339
 
280
340
  Found invalid keys!
281
- ┌────────┬───────────────────────────────────────────┐
282
- info result
283
- ├────────┼───────────────────────────────────────────┤
284
- file │ translations/messageExamples/de-de.json
285
- keymultipleVariables
286
- msgUnexpected date element
287
- └────────┴───────────────────────────────────────────┘
341
+ ${(0, errorReporters_1.formatTable)([
342
+ [['info', 'result']],
343
+ [
344
+ ['file', tr('messageExamples/de-de.json')],
345
+ ['key', 'multipleVariables'],
346
+ ['msg', 'Unexpected date element'],
347
+ ],
348
+ ])}
288
349
 
289
350
  `);
290
- done();
291
- });
292
351
  });
293
- it("should ignore the excluded multiple files", (done) => {
294
- (0, child_process_1.exec)("node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/de-de.json translations/messageExamples/de-de.json", (_error, stdout, _stderr) => {
295
- const result = stdout.split("Done")[0];
296
- expect(result).toEqual(`i18n translations checker
352
+ it('should ignore the excluded multiple files', async () => {
353
+ const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/de-de.json translations/messageExamples/de-de.json');
354
+ const result = stdout.split('Done')[0];
355
+ expect(result).toEqual(`i18n translations checker
297
356
  Source: en-US
298
357
 
299
358
  No missing keys found!
@@ -301,13 +360,11 @@ No missing keys found!
301
360
  No invalid translations found!
302
361
 
303
362
  `);
304
- done();
305
- });
306
363
  });
307
- it("should find unused and undefined keys for react-i18next applications", (done) => {
308
- (0, child_process_1.exec)("node dist/bin/index.js --source en --locales translations/codeExamples/reacti18next/locales -f i18next -u translations/codeExamples/reacti18next/src --parser-component-functions WrappedTransComponent", (_error, stdout, _stderr) => {
309
- const result = stdout.split("Done")[0];
310
- expect(result).toEqual(`i18n translations checker
364
+ it('should find unused and undefined keys for react-i18next applications', async () => {
365
+ const stdout = await execAsync('node dist/bin/index.js --source en --locales translations/codeExamples/reacti18next/locales -f i18next -u translations/codeExamples/reacti18next/src --parser-component-functions WrappedTransComponent');
366
+ const result = stdout.split('Done')[0];
367
+ expect(result).toEqual(`i18n translations checker
311
368
  Source: en
312
369
  Selected format is: i18next
313
370
 
@@ -316,28 +373,26 @@ No missing keys found!
316
373
  No invalid translations found!
317
374
 
318
375
  Found unused keys!
319
- ┌──────────────────────────────────────────────────────────────────────┬──────────────────┐
320
- file key
321
- ├──────────────────────────────────────────────────────────────────────┼──────────────────┤
322
- │ translations/codeExamples/reacti18next/locales/en/translation.jsonformat.ebook
323
- │ translations/codeExamples/reacti18next/locales/en/translation.jsonnonExistentKey
324
- └──────────────────────────────────────────────────────────────────────┴──────────────────┘
376
+ ${(0, errorReporters_1.formatTable)([
377
+ [['file', 'key']],
378
+ [
379
+ [codeEx('reacti18next/locales/en/translation.json'), 'format.ebook'],
380
+ [codeEx('reacti18next/locales/en/translation.json'), 'nonExistentKey'],
381
+ ],
382
+ ])}
325
383
 
326
384
  Found undefined keys!
327
- ┌──────────────────────────────────────────────────────┬────────────────────────────────┐
328
- file key
329
- ├──────────────────────────────────────────────────────┼────────────────────────────────┤
330
- │ translations/codeExamples/reacti18next/src/App.tsx │ some.key.that.is.not.defined │
331
- └──────────────────────────────────────────────────────┴────────────────────────────────┘
385
+ ${(0, errorReporters_1.formatTable)([
386
+ [['file', 'key']],
387
+ [[codeEx('reacti18next/src/App.tsx'), 'some.key.that.is.not.defined']],
388
+ ])}
332
389
 
333
390
  `);
334
- done();
335
- });
336
391
  });
337
- it("should find unused and undefined keys for react-i18next applications with multiple source folders", (done) => {
338
- (0, child_process_1.exec)("node dist/bin/index.js --source en --locales translations/codeExamples/reacti18next/locales -f i18next -u translations/codeExamples/reacti18next/src translations/codeExamples/reacti18next/secondSrcFolder --parser-component-functions WrappedTransComponent", (_error, stdout, _stderr) => {
339
- const result = stdout.split("Done")[0];
340
- expect(result).toEqual(`i18n translations checker
392
+ it('should find unused and undefined keys for react-i18next applications with multiple source folders', async () => {
393
+ const stdout = await execAsync('node dist/bin/index.js --source en --locales translations/codeExamples/reacti18next/locales -f i18next -u translations/codeExamples/reacti18next/src translations/codeExamples/reacti18next/secondSrcFolder --parser-component-functions WrappedTransComponent');
394
+ const result = stdout.split('Done')[0];
395
+ expect(result).toEqual(`i18n translations checker
341
396
  Source: en
342
397
  Selected format is: i18next
343
398
 
@@ -346,29 +401,32 @@ No missing keys found!
346
401
  No invalid translations found!
347
402
 
348
403
  Found unused keys!
349
- ┌──────────────────────────────────────────────────────────────────────┬──────────────────┐
350
- file key
351
- ├──────────────────────────────────────────────────────────────────────┼──────────────────┤
352
- │ translations/codeExamples/reacti18next/locales/en/translation.jsonformat.ebook
353
- │ translations/codeExamples/reacti18next/locales/en/translation.jsonnonExistentKey
354
- └──────────────────────────────────────────────────────────────────────┴──────────────────┘
404
+ ${(0, errorReporters_1.formatTable)([
405
+ [['file', 'key']],
406
+ [
407
+ [codeEx('reacti18next/locales/en/translation.json'), 'format.ebook'],
408
+ [codeEx('reacti18next/locales/en/translation.json'), 'nonExistentKey'],
409
+ ],
410
+ ])}
355
411
 
356
412
  Found undefined keys!
357
- ┌───────────────────────────────────────────────────────────────────┬───────────────────────────────────┐
358
- file key
359
- ├───────────────────────────────────────────────────────────────────┼───────────────────────────────────┤
360
- │ translations/codeExamples/reacti18next/src/App.tsxsome.key.that.is.not.defined
361
- │ translations/codeExamples/reacti18next/secondSrcFolder/Main.tsx │ another.key.that.is.not.defined │
362
- └───────────────────────────────────────────────────────────────────┴───────────────────────────────────┘
413
+ ${(0, errorReporters_1.formatTable)([
414
+ [['file', 'key']],
415
+ [
416
+ [codeEx('reacti18next/src/App.tsx'), 'some.key.that.is.not.defined'],
417
+ [
418
+ codeEx('reacti18next/secondSrcFolder/Main.tsx'),
419
+ 'another.key.that.is.not.defined',
420
+ ],
421
+ ],
422
+ ])}
363
423
 
364
424
  `);
365
- done();
366
- });
367
425
  });
368
- it("should find unused and undefined keys for react-intl applications", (done) => {
369
- (0, child_process_1.exec)("node dist/bin/index.js --source en-US --locales translations/codeExamples/react-intl/locales -f react-intl -u translations/codeExamples/react-intl/src", (_error, stdout, _stderr) => {
370
- const result = stdout.split("Done")[0];
371
- expect(result).toEqual(`i18n translations checker
426
+ it('should find unused and undefined keys for react-intl applications', async () => {
427
+ const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/codeExamples/react-intl/locales -f react-intl -u translations/codeExamples/react-intl/src');
428
+ const result = stdout.split('Done')[0];
429
+ expect(result).toEqual(`i18n translations checker
372
430
  Source: en-US
373
431
  Selected format is: react-intl
374
432
 
@@ -377,28 +435,26 @@ No missing keys found!
377
435
  No invalid translations found!
378
436
 
379
437
  Found unused keys!
380
- ┌─────────────────────────────────────────────────────────────────┬─────────────────────────┐
381
- file key
382
- ├─────────────────────────────────────────────────────────────────┼─────────────────────────┤
383
- │ translations/codeExamples/react-intl/locales/en-US/one.jsonmessage.number-format
384
- │ translations/codeExamples/react-intl/locales/en-US/three.jsonmultipleVariables
385
- └─────────────────────────────────────────────────────────────────┴─────────────────────────┘
438
+ ${(0, errorReporters_1.formatTable)([
439
+ [['file', 'key']],
440
+ [
441
+ [codeEx('react-intl/locales/en-US/one.json'), 'message.number-format'],
442
+ [codeEx('react-intl/locales/en-US/three.json'), 'multipleVariables'],
443
+ ],
444
+ ])}
386
445
 
387
446
  Found undefined keys!
388
- ┌────────────────────────────────────────────────────┬────────────────────────────────┐
389
- file key
390
- ├────────────────────────────────────────────────────┼────────────────────────────────┤
391
- │ translations/codeExamples/react-intl/src/App.tsx │ some.key.that.is.not.defined │
392
- └────────────────────────────────────────────────────┴────────────────────────────────┘
447
+ ${(0, errorReporters_1.formatTable)([
448
+ [['file', 'key']],
449
+ [[codeEx('react-intl/src/App.tsx'), 'some.key.that.is.not.defined']],
450
+ ])}
393
451
 
394
452
  `);
395
- done();
396
- });
397
453
  });
398
- it("should find unused and undefined keys for next-intl applications", (done) => {
399
- (0, child_process_1.exec)("node dist/bin/index.js --source en --locales translations/codeExamples/next-intl/locales/ -f next-intl -u translations/codeExamples/next-intl/src", (_error, stdout, _stderr) => {
400
- const result = stdout.split("Done")[0];
401
- expect(result).toEqual(`i18n translations checker
454
+ it('should find unused and undefined keys for next-intl applications', async () => {
455
+ const stdout = await execAsync('node dist/bin/index.js --source en --locales translations/codeExamples/next-intl/locales/ -f next-intl -u translations/codeExamples/next-intl/src');
456
+ const result = stdout.split('Done')[0];
457
+ expect(result).toEqual(`i18n translations checker
402
458
  Source: en
403
459
  Selected format is: next-intl
404
460
 
@@ -407,260 +463,292 @@ No missing keys found!
407
463
  No invalid translations found!
408
464
 
409
465
  Found unused keys!
410
- ┌───────────────────────────────────────────────────────────────────┬──────────────────┐
411
- file key
412
- ├───────────────────────────────────────────────────────────────────┼──────────────────┤
413
- │ translations/codeExamples/next-intl/locales/en/translation.jsonmessage.plural
414
- │ translations/codeExamples/next-intl/locales/en/translation.jsonnotUsedKey
415
- └───────────────────────────────────────────────────────────────────┴──────────────────┘
466
+ ${(0, errorReporters_1.formatTable)([
467
+ [['file', 'key']],
468
+ [
469
+ [codeEx('next-intl/locales/en/translation.json'), 'message.plural'],
470
+ [codeEx('next-intl/locales/en/translation.json'), 'notUsedKey'],
471
+ ],
472
+ ])}
416
473
 
417
474
  Found undefined keys!
418
- ┌──────────────────────────────────────────────────────────────────┬───────────────────┐
419
- file key
420
- ├──────────────────────────────────────────────────────────────────┼───────────────────┤
421
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxAbout.unknown
422
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxAbout.unknown
423
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxTest.title
424
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxTest.title
425
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxtitle
426
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxtitle
427
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxunknown
428
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxunknown
429
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxunknown.unknown
430
- │ translations/codeExamples/next-intl/src/StrictTypesExample.tsxunknown.unknown
431
- │ translations/codeExamples/next-intl/src/Basic.tsxmessage.select
432
- └──────────────────────────────────────────────────────────────────┴───────────────────┘
475
+ ${(0, errorReporters_1.formatTable)([
476
+ [['file', 'key']],
477
+ [
478
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'About.unknown'],
479
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'About.unknown'],
480
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'Test.title'],
481
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'Test.title'],
482
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'title'],
483
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'title'],
484
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'unknown'],
485
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'unknown'],
486
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'unknown.unknown'],
487
+ [codeEx('next-intl/src/StrictTypesExample.tsx'), 'unknown.unknown'],
488
+ [codeEx('next-intl/src/Basic.tsx'), 'message.select'],
489
+ ],
490
+ ])}
433
491
 
434
492
  `);
435
- done();
436
- });
437
493
  });
438
494
  });
439
- describe("YAML", () => {
440
- it("should return the missing keys for single folder translations", (done) => {
441
- (0, child_process_1.exec)("node dist/bin/index.js -s en-US -l translations/yaml/flattenExamples", (_error, stdout, _stderr) => {
442
- const result = stdout.split("Done")[0];
443
- expect(result).toEqual(`i18n translations checker
495
+ describe('YAML', () => {
496
+ it('should return the missing keys for single folder translations', async () => {
497
+ const stdout = await execAsync('node dist/bin/index.js -s en-US -l translations/yaml/flattenExamples');
498
+ const result = stdout.split('Done')[0];
499
+ expect(result).toEqual(`i18n translations checker
444
500
  Source: en-US
445
501
 
446
502
  Found missing keys!
447
- ┌────────────────────────────────────────────────┬────────────────────────────────┐
448
- file key
449
- ├────────────────────────────────────────────────┼────────────────────────────────┤
450
- │ translations/yaml/flattenExamples/de-de.yamlother.nested.three
451
- │ translations/yaml/flattenExamples/de-de.yamlother.nested.deep.more.final
452
- └────────────────────────────────────────────────┴────────────────────────────────┘
503
+ ${(0, errorReporters_1.formatTable)([
504
+ [['file', 'key']],
505
+ [
506
+ [tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
507
+ [tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
508
+ ],
509
+ ])}
453
510
 
454
511
  No invalid translations found!
455
512
 
456
513
  `);
457
- done();
458
- });
459
514
  });
460
- it("should return the missing/invalid keys for folder per locale with single file", (done) => {
461
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/yaml/folderExample/ -s en-US", (_error, stdout, _stderr) => {
462
- const result = stdout.split("Done")[0];
463
- expect(result).toEqual(`i18n translations checker
515
+ it('should return the missing/invalid keys for folder per locale with single file', async () => {
516
+ const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/folderExample/ -s en-US');
517
+ const result = stdout.split('Done')[0];
518
+ expect(result).toEqual(`i18n translations checker
464
519
  Source: en-US
465
520
 
466
521
  Found missing keys!
467
- ┌────────────────────────────────────────────────────┬───────────────────────┐
468
- file key
469
- ├────────────────────────────────────────────────────┼───────────────────────┤
470
- │ translations/yaml/folderExample/de-DE/index.yaml │ message.text-format │
471
- └────────────────────────────────────────────────────┴───────────────────────┘
522
+ ${(0, errorReporters_1.formatTable)([
523
+ [['file', 'key']],
524
+ [[tr('yaml/folderExample/de-DE/index.yaml'), 'message.text-format']],
525
+ ])}
472
526
 
473
527
  Found invalid keys!
474
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
475
- info result
476
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
477
- file │ translations/yaml/folderExample/de-DE/index.yaml
478
- keymessage.select
479
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
480
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
528
+ ${(0, errorReporters_1.formatTable)([
529
+ [['info', 'result']],
530
+ [
531
+ ['file', tr('yaml/folderExample/de-DE/index.yaml')],
532
+ ['key', 'message.select'],
533
+ [
534
+ 'msg',
535
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
536
+ ],
537
+ ],
538
+ ])}
481
539
 
482
540
  `);
483
- done();
484
- });
485
541
  });
486
- it("should return the missing/invalid keys for folder per locale with multiple files", (done) => {
487
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/yaml/multipleFilesFolderExample/ -s en-US", (_error, stdout, _stderr) => {
488
- const result = stdout.split("Done")[0];
489
- expect(result).toEqual(`i18n translations checker
542
+ it('should return the missing/invalid keys for folder per locale with multiple files', async () => {
543
+ const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFilesFolderExample/ -s en-US');
544
+ const result = stdout.split('Done')[0];
545
+ expect(result).toEqual(`i18n translations checker
490
546
  Source: en-US
491
547
 
492
548
  Found missing keys!
493
- ┌───────────────────────────────────────────────────────────────┬───────────────────────┐
494
- file key
495
- ├───────────────────────────────────────────────────────────────┼───────────────────────┤
496
- │ translations/yaml/multipleFilesFolderExample/de-DE/one.yaml │ message.text-format │
497
- │ translations/yaml/multipleFilesFolderExample/de-DE/two.yaml │ test.drive.four │
498
- └───────────────────────────────────────────────────────────────┴───────────────────────┘
549
+ ${(0, errorReporters_1.formatTable)([
550
+ [['file', 'key']],
551
+ [
552
+ [
553
+ tr('yaml/multipleFilesFolderExample/de-DE/one.yaml'),
554
+ 'message.text-format',
555
+ ],
556
+ [tr('yaml/multipleFilesFolderExample/de-DE/two.yaml'), 'test.drive.four'],
557
+ ],
558
+ ])}
499
559
 
500
560
  Found invalid keys!
501
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
502
- info result
503
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
504
- file │ translations/yaml/multipleFilesFolderExample/de-DE/one.yaml
505
- keymessage.select
506
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
507
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
508
- │ file │ translations/yaml/multipleFilesFolderExample/de-DE/three.yaml │
509
- │ key │ multipleVariables │
510
- │ msg │ Expected argument to contain "user" but received "name" │
511
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
561
+ ${(0, errorReporters_1.formatTable)([
562
+ [['info', 'result']],
563
+ [
564
+ ['file', tr('yaml/multipleFilesFolderExample/de-DE/one.yaml')],
565
+ ['key', 'message.select'],
566
+ [
567
+ 'msg',
568
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
569
+ ],
570
+ ],
571
+ [
572
+ ['file', tr('yaml/multipleFilesFolderExample/de-DE/three.yaml')],
573
+ ['key', 'multipleVariables'],
574
+ ['msg', 'Expected argument to contain "user" but received "name"'],
575
+ ],
576
+ ])}
512
577
 
513
578
  `);
514
- done();
515
- });
516
579
  });
517
- it("should return the missing/invalid keys for folder containing multiple locale folders", (done) => {
518
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/yaml/multipleFoldersExample -s en-US", (_error, stdout, _stderr) => {
519
- const result = stdout.split("Done")[0];
520
- expect(result).toEqual(`i18n translations checker
580
+ it('should return the missing/invalid keys for folder containing multiple locale folders', async () => {
581
+ const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFoldersExample -s en-US');
582
+ const result = stdout.split('Done')[0];
583
+ expect(result).toEqual(`i18n translations checker
521
584
  Source: en-US
522
585
 
523
586
  Found missing keys!
524
- ┌────────────────────────────────────────────────────────────────────────────┬───────────────────────┐
525
- file key
526
- ├────────────────────────────────────────────────────────────────────────────┼───────────────────────┤
527
- │ translations/yaml/multipleFoldersExample/spaceOne/locales/de-DE/one.yamlmessage.text-format
528
- │ translations/yaml/multipleFoldersExample/spaceOne/locales/de-DE/two.yamltest.drive.four
529
- │ translations/yaml/multipleFoldersExample/spaceTwo/locales/de-DE/one.yamlmessage.plural
530
- │ translations/yaml/multipleFoldersExample/spaceTwo/locales/de-DE/two.yamltest.drive.two
531
- └────────────────────────────────────────────────────────────────────────────┴───────────────────────┘
587
+ ${(0, errorReporters_1.formatTable)([
588
+ [['file', 'key']],
589
+ [
590
+ [ymlMultiFolders('spaceOne/locales/de-DE/one.yaml'), 'message.text-format'],
591
+ [ymlMultiFolders('spaceOne/locales/de-DE/two.yaml'), 'test.drive.four'],
592
+ [ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml'), 'message.plural'],
593
+ [ymlMultiFolders('spaceTwo/locales/de-DE/two.yaml'), 'test.drive.two'],
594
+ ],
595
+ ])}
532
596
 
533
597
  Found invalid keys!
534
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
535
- info result
536
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
537
- file │ translations/yaml/multipleFoldersExample/spaceOne/locales/de-DE/one.yaml
538
- keymessage.select
539
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
540
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
541
- │ file │ translations/yaml/multipleFoldersExample/spaceOne/locales/de-DE/three.yaml │
542
- │ key │ multipleVariables │
543
- │ msg │ Expected argument to contain "user" but received "name" │
544
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
545
- file │ translations/yaml/multipleFoldersExample/spaceTwo/locales/de-DE/one.yaml
546
- key │ message.text-format │
547
- msgExpected element of type "tag" but received "number", Unexpected tag element │
548
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
549
- │ file │ translations/yaml/multipleFoldersExample/spaceTwo/locales/de-DE/three.yaml │
550
- │ key │ numberFormat │
551
- │ msg │ Missing element number │
552
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
598
+ ${(0, errorReporters_1.formatTable)([
599
+ [['info', 'result']],
600
+ [
601
+ ['file', ymlMultiFolders('spaceOne/locales/de-DE/one.yaml')],
602
+ ['key', 'message.select'],
603
+ [
604
+ 'msg',
605
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
606
+ ],
607
+ ],
608
+ [
609
+ ['file', ymlMultiFolders('spaceOne/locales/de-DE/three.yaml')],
610
+ ['key', 'multipleVariables'],
611
+ ['msg', 'Expected argument to contain "user" but received "name"'],
612
+ ],
613
+ [
614
+ ['file', ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml')],
615
+ ['key', 'message.text-format'],
616
+ [
617
+ 'msg',
618
+ 'Expected element of type "tag" but received "number", Unexpected tag element',
619
+ ],
620
+ ],
621
+ [
622
+ ['file', ymlMultiFolders('spaceTwo/locales/de-DE/three.yaml')],
623
+ ['key', 'numberFormat'],
624
+ ['msg', 'Missing element number'],
625
+ ],
626
+ ])}
553
627
 
554
628
  `);
555
- done();
556
- });
557
629
  });
558
- it("should return the missing/invalid keys for multiple locale folders", (done) => {
559
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/yaml/multipleFoldersExample/spaceOne translations/yaml/multipleFoldersExample/spaceTwo -s en-US", (_error, stdout, _stderr) => {
560
- const result = stdout.split("Done")[0];
561
- expect(result).toEqual(`i18n translations checker
630
+ it('should return the missing/invalid keys for multiple locale folders', async () => {
631
+ const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFoldersExample/spaceOne translations/yaml/multipleFoldersExample/spaceTwo -s en-US');
632
+ const result = stdout.split('Done')[0];
633
+ expect(result).toEqual(`i18n translations checker
562
634
  Source: en-US
563
635
 
564
636
  Found missing keys!
565
- ┌────────────────────────────────────────────────────────────────────────────┬───────────────────────┐
566
- file key
567
- ├────────────────────────────────────────────────────────────────────────────┼───────────────────────┤
568
- │ translations/yaml/multipleFoldersExample/spaceOne/locales/de-DE/one.yamlmessage.text-format
569
- │ translations/yaml/multipleFoldersExample/spaceOne/locales/de-DE/two.yamltest.drive.four
570
- │ translations/yaml/multipleFoldersExample/spaceTwo/locales/de-DE/one.yamlmessage.plural
571
- │ translations/yaml/multipleFoldersExample/spaceTwo/locales/de-DE/two.yamltest.drive.two
572
- └────────────────────────────────────────────────────────────────────────────┴───────────────────────┘
637
+ ${(0, errorReporters_1.formatTable)([
638
+ [['file', 'key']],
639
+ [
640
+ [ymlMultiFolders('spaceOne/locales/de-DE/one.yaml'), 'message.text-format'],
641
+ [ymlMultiFolders('spaceOne/locales/de-DE/two.yaml'), 'test.drive.four'],
642
+ [ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml'), 'message.plural'],
643
+ [ymlMultiFolders('spaceTwo/locales/de-DE/two.yaml'), 'test.drive.two'],
644
+ ],
645
+ ])}
573
646
 
574
647
  Found invalid keys!
575
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
576
- info result
577
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
578
- file │ translations/yaml/multipleFoldersExample/spaceOne/locales/de-DE/one.yaml
579
- keymessage.select
580
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
581
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
582
- │ file │ translations/yaml/multipleFoldersExample/spaceOne/locales/de-DE/three.yaml │
583
- │ key │ multipleVariables │
584
- │ msg │ Expected argument to contain "user" but received "name" │
585
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
586
- file │ translations/yaml/multipleFoldersExample/spaceTwo/locales/de-DE/one.yaml
587
- key │ message.text-format │
588
- msgExpected element of type "tag" but received "number", Unexpected tag element │
589
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
590
- │ file │ translations/yaml/multipleFoldersExample/spaceTwo/locales/de-DE/three.yaml │
591
- │ key │ numberFormat │
592
- │ msg │ Missing element number │
593
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
648
+ ${(0, errorReporters_1.formatTable)([
649
+ [['info', 'result']],
650
+ [
651
+ ['file', ymlMultiFolders('spaceOne/locales/de-DE/one.yaml')],
652
+ ['key', 'message.select'],
653
+ [
654
+ 'msg',
655
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
656
+ ],
657
+ ],
658
+ [
659
+ ['file', ymlMultiFolders('spaceOne/locales/de-DE/three.yaml')],
660
+ ['key', 'multipleVariables'],
661
+ ['msg', 'Expected argument to contain "user" but received "name"'],
662
+ ],
663
+ [
664
+ ['file', ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml')],
665
+ ['key', 'message.text-format'],
666
+ [
667
+ 'msg',
668
+ 'Expected element of type "tag" but received "number", Unexpected tag element',
669
+ ],
670
+ ],
671
+ [
672
+ ['file', ymlMultiFolders('spaceTwo/locales/de-DE/three.yaml')],
673
+ ['key', 'numberFormat'],
674
+ ['msg', 'Missing element number'],
675
+ ],
676
+ ])}
594
677
 
595
678
  `);
596
- done();
597
- });
598
679
  });
599
- it("should return the missing/invalid keys for all files in the provided locale folders", (done) => {
600
- (0, child_process_1.exec)("node dist/bin/index.js --source en-US --locales translations/yaml/flattenExamples translations/yaml/messageExamples", (_error, stdout, _stderr) => {
601
- const result = stdout.split("Done")[0];
602
- expect(result).toEqual(`i18n translations checker
680
+ it('should return the missing/invalid keys for all files in the provided locale folders', async () => {
681
+ const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/yaml/flattenExamples translations/yaml/messageExamples');
682
+ const result = stdout.split('Done')[0];
683
+ expect(result).toEqual(`i18n translations checker
603
684
  Source: en-US
604
685
 
605
686
  Found missing keys!
606
- ┌────────────────────────────────────────────────┬────────────────────────────────┐
607
- file key
608
- ├────────────────────────────────────────────────┼────────────────────────────────┤
609
- │ translations/yaml/flattenExamples/de-de.yamlother.nested.three
610
- │ translations/yaml/flattenExamples/de-de.yamlother.nested.deep.more.final
611
- │ translations/yaml/messageExamples/de-de.yamlrichText
612
- │ translations/yaml/messageExamples/de-de.yamlyo
613
- │ translations/yaml/messageExamples/de-de.yamlnesting1
614
- │ translations/yaml/messageExamples/de-de.yamlnesting2
615
- │ translations/yaml/messageExamples/de-de.yamlnesting3
616
- │ translations/yaml/messageExamples/de-de.yamlkey1
617
- └────────────────────────────────────────────────┴────────────────────────────────┘
687
+ ${(0, errorReporters_1.formatTable)([
688
+ [['file', 'key']],
689
+ [
690
+ [tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
691
+ [tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
692
+ [tr('yaml/messageExamples/de-de.yaml'), 'richText'],
693
+ [tr('yaml/messageExamples/de-de.yaml'), 'yo'],
694
+ [tr('yaml/messageExamples/de-de.yaml'), 'nesting1'],
695
+ [tr('yaml/messageExamples/de-de.yaml'), 'nesting2'],
696
+ [tr('yaml/messageExamples/de-de.yaml'), 'nesting3'],
697
+ [tr('yaml/messageExamples/de-de.yaml'), 'key1'],
698
+ ],
699
+ ])}
618
700
 
619
701
  Found invalid keys!
620
- ┌────────┬────────────────────────────────────────────────┐
621
- info result
622
- ├────────┼────────────────────────────────────────────────┤
623
- file │ translations/yaml/messageExamples/de-de.yaml
624
- keymultipleVariables
625
- msgUnexpected date element
626
- └────────┴────────────────────────────────────────────────┘
702
+ ${(0, errorReporters_1.formatTable)([
703
+ [['info', 'result']],
704
+ [
705
+ ['file', tr('yaml/messageExamples/de-de.yaml')],
706
+ ['key', 'multipleVariables'],
707
+ ['msg', 'Unexpected date element'],
708
+ ],
709
+ ])}
627
710
 
628
711
  `);
629
- done();
630
- });
631
712
  });
632
- it("should return the missing/invalid keys for all files with source matching folder and source matching file", (done) => {
633
- (0, child_process_1.exec)("node dist/bin/index.js -l translations/yaml/multipleFilesFolderExample translations/yaml/flattenExamples -s en-US", (_error, stdout, _stderr) => {
634
- const result = stdout.split("Done")[0];
635
- expect(result).toEqual(`i18n translations checker
713
+ it('should return the missing/invalid keys for all files with source matching folder and source matching file', async () => {
714
+ const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFilesFolderExample translations/yaml/flattenExamples -s en-US');
715
+ const result = stdout.split('Done')[0];
716
+ expect(result).toEqual(`i18n translations checker
636
717
  Source: en-US
637
718
 
638
719
  Found missing keys!
639
- ┌───────────────────────────────────────────────────────────────┬────────────────────────────────┐
640
- file key
641
- ├───────────────────────────────────────────────────────────────┼────────────────────────────────┤
642
- │ translations/yaml/flattenExamples/de-de.yamlother.nested.three
643
- │ translations/yaml/flattenExamples/de-de.yamlother.nested.deep.more.final
644
- │ translations/yaml/multipleFilesFolderExample/de-DE/one.yaml │ message.text-format │
645
- │ translations/yaml/multipleFilesFolderExample/de-DE/two.yaml │ test.drive.four │
646
- └───────────────────────────────────────────────────────────────┴────────────────────────────────┘
720
+ ${(0, errorReporters_1.formatTable)([
721
+ [['file', 'key']],
722
+ [
723
+ [tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
724
+ [tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
725
+ [
726
+ tr('yaml/multipleFilesFolderExample/de-DE/one.yaml'),
727
+ 'message.text-format',
728
+ ],
729
+ [tr('yaml/multipleFilesFolderExample/de-DE/two.yaml'), 'test.drive.four'],
730
+ ],
731
+ ])}
647
732
 
648
733
  Found invalid keys!
649
- ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
650
- info result
651
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
652
- file │ translations/yaml/multipleFilesFolderExample/de-DE/one.yaml
653
- keymessage.select
654
- │ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
655
- ├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
656
- │ file │ translations/yaml/multipleFilesFolderExample/de-DE/three.yaml │
657
- │ key │ multipleVariables │
658
- │ msg │ Expected argument to contain "user" but received "name" │
659
- └────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
734
+ ${(0, errorReporters_1.formatTable)([
735
+ [['info', 'result']],
736
+ [
737
+ ['file', tr('yaml/multipleFilesFolderExample/de-DE/one.yaml')],
738
+ ['key', 'message.select'],
739
+ [
740
+ 'msg',
741
+ 'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
742
+ ],
743
+ ],
744
+ [
745
+ ['file', tr('yaml/multipleFilesFolderExample/de-DE/three.yaml')],
746
+ ['key', 'multipleVariables'],
747
+ ['msg', 'Expected argument to contain "user" but received "name"'],
748
+ ],
749
+ ])}
660
750
 
661
751
  `);
662
- done();
663
- });
664
752
  });
665
753
  });
666
754
  });