@oracle/oraclejet-icu-l10n 17.0.3 → 17.0.4

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/Bundler.js CHANGED
@@ -275,7 +275,7 @@ function build({
275
275
  Object.assign(combinedBundle, perBundle);
276
276
  // combinedBundle should not have keys not in rootBundle
277
277
  if (rootBundleKeys) {
278
- const extraKeys = Object.keys(combinedBundle).filter((k) => !rootBundleKeys.has(k));
278
+ const extraKeys = Object.keys(combinedBundle).filter((k) => !rootBundleKeys.has(k) && !k.startsWith('@'));
279
279
  if (extraKeys.length) {
280
280
  throw Error(`${perBundlePath} has keys not found in ${rootBundleFile}: ${extraKeys}`);
281
281
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oracle/oraclejet-icu-l10n",
3
- "version": "17.0.3",
3
+ "version": "17.0.4",
4
4
  "description": "JET ICU Message Format Parser",
5
5
  "main": "l10nBundleBuilder.js",
6
6
  "scripts": {
package/test/l10nTest.ts CHANGED
@@ -6,7 +6,7 @@ import fsx from 'fs-extra';
6
6
  import vm from 'node:vm';
7
7
  import glob from 'glob';
8
8
 
9
- const rootDir = path.join(__dirname, 'resources/nls');
9
+ const resourcesDir = path.join(__dirname, 'resources/nls');
10
10
  const outputRoot = path.resolve(__dirname, 'built');
11
11
 
12
12
  type ExportType = 'default' | 'named';
@@ -187,7 +187,7 @@ function runTestCases(extractBundle: (bundle: string) => any) {
187
187
  let didFail = false;
188
188
  try {
189
189
  build({
190
- rootDir: path.join(`${rootDir}-bad-metadata`),
190
+ rootDir: path.join(`${resourcesDir}-bad-metadata`),
191
191
  locale: 'ro-MD',
192
192
  bundleName: 'app-strings-bad-root.json',
193
193
  outDir: path.join(outputRoot, 'nls-bad-metadata')
@@ -225,7 +225,7 @@ describe('Custom hooks', () => {
225
225
  const outDir = path.resolve(outputRoot, 'custom-hooks');
226
226
  fsx.removeSync(outDir);
227
227
  build({
228
- rootDir,
228
+ rootDir: resourcesDir,
229
229
  bundleName: 'app-strings.json',
230
230
  locale: 'en-US',
231
231
  outDir,
@@ -244,7 +244,7 @@ describe('Custom hooks', () => {
244
244
  const outDir = path.resolve(outputRoot, 'custom-hooks-no-def');
245
245
  fsx.removeSync(outDir);
246
246
  build({
247
- rootDir,
247
+ rootDir: resourcesDir,
248
248
  bundleName: 'app-strings.json',
249
249
  locale: 'en-US',
250
250
  outDir,
@@ -274,7 +274,7 @@ describe('CJS default export', () => {
274
274
 
275
275
  fsx.removeSync(outDir);
276
276
  build({
277
- rootDir,
277
+ rootDir: resourcesDir,
278
278
  bundleName: 'app-strings.json',
279
279
  locale: 'en-US',
280
280
  outDir,
@@ -323,7 +323,7 @@ describe('AMD', () => {
323
323
 
324
324
  fsx.removeSync(outDir);
325
325
  build({
326
- rootDir,
326
+ rootDir: resourcesDir,
327
327
  bundleName: 'app-strings.json',
328
328
  locale: 'en-US',
329
329
  outDir,
@@ -348,7 +348,7 @@ describe('AMD', () => {
348
348
  beforeAll(() => {
349
349
  fsx.removeSync(outDir);
350
350
  build({
351
- rootDir,
351
+ rootDir: resourcesDir,
352
352
  bundleName: 'app-strings-legacy-keys.json',
353
353
  locale: 'en-US',
354
354
  outDir,
@@ -373,12 +373,12 @@ describe('Extra locales', () => {
373
373
  const outDir = path.resolve(outputRoot, 'extra');
374
374
  const additionalLocales = ['de', 'de-DE', 'fr-FR', 'ru', 'ru-RU'];
375
375
  const allLocales = [
376
- ...new Set(fsx.readdirSync(rootDir).filter(isNlsDir).concat(additionalLocales).sort())
376
+ ...new Set(fsx.readdirSync(resourcesDir).filter(isNlsDir).concat(additionalLocales).sort())
377
377
  ];
378
378
 
379
379
  fsx.removeSync(outDir);
380
380
  build({
381
- rootDir,
381
+ rootDir: resourcesDir,
382
382
  bundleName: 'app-strings.json',
383
383
  locale: 'en-US',
384
384
  outDir,
@@ -416,7 +416,7 @@ describe('Override files', () => {
416
416
 
417
417
  describe('with root overrides', () => {
418
418
  build({
419
- rootDir,
419
+ rootDir: resourcesDir,
420
420
  bundleName: 'app-strings-x.json',
421
421
  locale: 'en-US',
422
422
  override: true,
@@ -463,7 +463,7 @@ describe('Override files', () => {
463
463
 
464
464
  describe('without root overrides', () => {
465
465
  build({
466
- rootDir,
466
+ rootDir: resourcesDir,
467
467
  bundleName: 'extra-app-strings-x.json',
468
468
  override: true,
469
469
  locale: 'en-US',
@@ -488,12 +488,13 @@ describe('Override files', () => {
488
488
 
489
489
  describe('extra keys', () => {
490
490
  const outDir = path.resolve(outputRoot, 'extra-keys');
491
+ const extractBundle = (fp: string) => extractCjsBundle(outDir, fp).default;
491
492
 
492
493
  it('should fail if locale bundle has extra keys', () => {
493
494
  let didFail = false;
494
495
  try {
495
496
  build({
496
- rootDir: `${rootDir}-extra-keys`,
497
+ rootDir: `${resourcesDir}-extra-keys`,
497
498
  bundleName: 'app-bundle-bad.json',
498
499
  locale: 'en-US',
499
500
  outDir
@@ -503,4 +504,16 @@ describe('extra keys', () => {
503
504
  }
504
505
  expect(didFail).toBeTruthy();
505
506
  });
507
+
508
+ it('should allow extra metadata keys', () => {
509
+ build({
510
+ rootDir: `${resourcesDir}-extra-metadata-keys`,
511
+ bundleName: 'app-bundle-metadata-keys.json',
512
+ locale: 'en-US',
513
+ outDir,
514
+ module: 'cjs'
515
+ });
516
+ const bundle = extractBundle('en/app-bundle-metadata-keys.js');
517
+ expect(bundle.welcome()).toEqual('Welcome');
518
+ });
506
519
  });
@@ -0,0 +1,3 @@
1
+ {
2
+ "@metadata-key": "This is a metadata key not found in the root, but should be excluded from the extra-keys check"
3
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "welcome": "Welcome",
3
+ "intro": "Intro"
4
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "@extra-metadata-key": "This is a metadata key not found in the root, and should pass the extra-keys check"
3
+ }