@o3r/localization 11.6.0-prerelease.3 → 11.6.0-prerelease.31

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 (125) hide show
  1. package/annotations/localization.d.ts.map +1 -1
  2. package/builders/helpers/localization.generator.d.ts +1 -1
  3. package/builders/helpers/localization.generator.d.ts.map +1 -1
  4. package/builders/helpers/localization.generator.js +20 -22
  5. package/builders/i18n/index.d.ts.map +1 -1
  6. package/builders/i18n/index.js +2 -2
  7. package/builders/i18n/schema.d.ts +0 -2
  8. package/builders/i18n/schema.d.ts.map +1 -1
  9. package/builders/localization/index.d.ts +0 -2
  10. package/builders/localization/index.d.ts.map +1 -1
  11. package/builders/localization/index.js +28 -41
  12. package/builders/localization/schema.d.ts.map +1 -1
  13. package/builders/localization-extractor/index.d.ts.map +1 -1
  14. package/builders/localization-extractor/index.js +19 -19
  15. package/builders/localization-extractor/schema.d.ts.map +1 -1
  16. package/builders/localization-extractor/validations.d.ts +0 -2
  17. package/builders/localization-extractor/validations.d.ts.map +1 -1
  18. package/builders/localization-extractor/validations.js +3 -7
  19. package/builders/metadata-check/helpers/localization-metadata-comparison.helper.d.ts +2 -2
  20. package/builders/metadata-check/helpers/localization-metadata-comparison.helper.d.ts.map +1 -1
  21. package/builders/metadata-check/index.d.ts.map +1 -1
  22. package/builders/metadata-check/schema.d.ts.map +1 -1
  23. package/core/localization.configuration.d.ts +1 -1
  24. package/core/localization.configuration.d.ts.map +1 -1
  25. package/core/translatable.d.ts.map +1 -1
  26. package/core/translate-messageformat-lazy.compiler.d.ts +1 -1
  27. package/core/translate-messageformat-lazy.compiler.d.ts.map +1 -1
  28. package/devkit/localization-devkit.interface.d.ts.map +1 -1
  29. package/devkit/localization-devtools.console.service.d.ts.map +1 -1
  30. package/devkit/localization-devtools.message.service.d.ts +3 -7
  31. package/devkit/localization-devtools.message.service.d.ts.map +1 -1
  32. package/devkit/localization-devtools.module.d.ts.map +1 -1
  33. package/devkit/localization-devtools.service.d.ts.map +1 -1
  34. package/devkit/localization-devtools.token.d.ts +1 -1
  35. package/devkit/localization-devtools.token.d.ts.map +1 -1
  36. package/esm2022/annotations/localization.mjs +3 -3
  37. package/esm2022/core/index.mjs +1 -1
  38. package/esm2022/core/localization.configuration.mjs +1 -1
  39. package/esm2022/core/translatable.mjs +1 -1
  40. package/esm2022/core/translate-messageformat-lazy.compiler.mjs +12 -13
  41. package/esm2022/devkit/index.mjs +1 -1
  42. package/esm2022/devkit/localization-devkit.interface.mjs +1 -1
  43. package/esm2022/devkit/localization-devtools.console.service.mjs +8 -10
  44. package/esm2022/devkit/localization-devtools.message.service.mjs +15 -19
  45. package/esm2022/devkit/localization-devtools.module.mjs +11 -11
  46. package/esm2022/devkit/localization-devtools.service.mjs +8 -8
  47. package/esm2022/devkit/localization-devtools.token.mjs +2 -2
  48. package/esm2022/public_api.mjs +1 -2
  49. package/esm2022/rules-engine/localization.handler-action.mjs +8 -8
  50. package/esm2022/rules-engine/localization.interfaces.mjs +1 -1
  51. package/esm2022/rules-engine/localization.rules-engine.module.mjs +8 -8
  52. package/esm2022/stores/index.mjs +1 -1
  53. package/esm2022/stores/localization-override/localization-override.actions.mjs +2 -2
  54. package/esm2022/stores/localization-override/localization-override.module.mjs +9 -9
  55. package/esm2022/stores/localization-override/localization-override.reducer.mjs +2 -2
  56. package/esm2022/stores/localization-override/localization-override.selectors.mjs +3 -3
  57. package/esm2022/stores/localization-override/localization-override.state.mjs +1 -1
  58. package/esm2022/stores/localization-override/localization-override.sync.mjs +2 -2
  59. package/esm2022/tools/index.mjs +1 -1
  60. package/esm2022/tools/localization-translate.directive.mjs +9 -9
  61. package/esm2022/tools/localization-translate.pipe.mjs +11 -11
  62. package/esm2022/tools/localization.module.mjs +27 -25
  63. package/esm2022/tools/localization.provider.mjs +7 -7
  64. package/esm2022/tools/localization.service.mjs +21 -26
  65. package/esm2022/tools/localization.token.mjs +2 -2
  66. package/esm2022/tools/localized-currency.pipe.mjs +7 -7
  67. package/esm2022/tools/localized-date.pipe.mjs +8 -13
  68. package/esm2022/tools/localized-decimal.pipe.mjs +7 -7
  69. package/esm2022/tools/text-direction.service.mjs +9 -9
  70. package/esm2022/tools/text-directionality.service.mjs +7 -7
  71. package/esm2022/tools/translations-loader.mjs +16 -16
  72. package/fesm2022/o3r-localization-rules-engine.mjs +7 -7
  73. package/fesm2022/o3r-localization-rules-engine.mjs.map +1 -1
  74. package/fesm2022/o3r-localization.mjs +92 -107
  75. package/fesm2022/o3r-localization.mjs.map +1 -1
  76. package/migration.json +5 -0
  77. package/package.json +6 -6
  78. package/public_api.d.ts +0 -1
  79. package/public_api.d.ts.map +1 -1
  80. package/rules-engine/localization.handler-action.d.ts +1 -1
  81. package/rules-engine/localization.handler-action.d.ts.map +1 -1
  82. package/rules-engine/localization.interfaces.d.ts.map +1 -1
  83. package/rules-engine/localization.rules-engine.module.d.ts.map +1 -1
  84. package/schematics/add-localization-key/index.d.ts.map +1 -1
  85. package/schematics/add-localization-key/index.js +34 -16
  86. package/schematics/add-localization-key/schema.d.ts.map +1 -1
  87. package/schematics/cms-adapter/index.d.ts.map +1 -1
  88. package/schematics/cms-adapter/index.js +1 -1
  89. package/schematics/localization-base/index.d.ts.map +1 -1
  90. package/schematics/localization-base/index.js +25 -26
  91. package/schematics/localization-to-component/index.d.ts.map +1 -1
  92. package/schematics/localization-to-component/index.js +10 -5
  93. package/schematics/localization-to-component/schema.d.ts.map +1 -1
  94. package/schematics/localization-to-component/templates/__name__.translation.ts.template +1 -1
  95. package/schematics/ng-add/helpers/devtools-registration.d.ts +0 -3
  96. package/schematics/ng-add/helpers/devtools-registration.d.ts.map +1 -1
  97. package/schematics/ng-add/helpers/devtools-registration.js +2 -5
  98. package/schematics/ng-add/index.d.ts.map +1 -1
  99. package/schematics/ng-add/index.js +2 -8
  100. package/schematics/ng-add/schema.d.ts.map +1 -1
  101. package/schematics/ng-update/v10-0/index.d.ts.map +1 -1
  102. package/schematics/ng-update/v10-0/index.js +2 -1
  103. package/schematics/ng-update/v11-6/index.d.ts +6 -0
  104. package/schematics/ng-update/v11-6/index.d.ts.map +1 -0
  105. package/schematics/ng-update/v11-6/index.js +22 -0
  106. package/stores/localization-override/localization-override.actions.d.ts.map +1 -1
  107. package/stores/localization-override/localization-override.module.d.ts.map +1 -1
  108. package/stores/localization-override/localization-override.reducer.d.ts.map +1 -1
  109. package/stores/localization-override/localization-override.selectors.d.ts.map +1 -1
  110. package/stores/localization-override/localization-override.state.d.ts.map +1 -1
  111. package/stores/localization-override/localization-override.sync.d.ts.map +1 -1
  112. package/tools/localization-translate.directive.d.ts.map +1 -1
  113. package/tools/localization-translate.pipe.d.ts.map +1 -1
  114. package/tools/localization.module.d.ts.map +1 -1
  115. package/tools/localization.provider.d.ts +1 -1
  116. package/tools/localization.provider.d.ts.map +1 -1
  117. package/tools/localization.service.d.ts.map +1 -1
  118. package/tools/localization.token.d.ts.map +1 -1
  119. package/tools/localized-currency.pipe.d.ts.map +1 -1
  120. package/tools/localized-date.pipe.d.ts.map +1 -1
  121. package/tools/localized-decimal.pipe.d.ts.map +1 -1
  122. package/tools/text-direction.service.d.ts.map +1 -1
  123. package/tools/text-directionality.service.d.ts.map +1 -1
  124. package/tools/translations-loader.d.ts +2 -2
  125. package/tools/translations-loader.d.ts.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"localization.d.ts","sourceRoot":"","sources":["../../src/annotations/localization.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,YACvB,GAAG,OAAO,MAAM,UAqBjC"}
1
+ {"version":3,"file":"localization.d.ts","sourceRoot":"","sources":["../../src/annotations/localization.ts"],"names":[],"mappings":"AAMA;;;GAGG;AAEH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,YACvB,GAAG,OAAO,MAAM,UAqBjC"}
@@ -1,6 +1,6 @@
1
1
  import { logging } from '@angular-devkit/core';
2
- import type { JSONLocalization, LocalizationMetadata } from '@o3r/localization';
3
2
  import type { LocalizationExtractorBuilderSchema } from '../localization-extractor/schema';
3
+ import type { JSONLocalization, LocalizationMetadata } from '@o3r/localization';
4
4
  /** Map of Localization Metadata base on localization key */
5
5
  export interface LocalizationMetadataAsMap {
6
6
  [key: string]: JSONLocalization;
@@ -1 +1 @@
1
- {"version":3,"file":"localization.generator.d.ts","sourceRoot":"","sources":["../../../builders/helpers/localization.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAMhF,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAC;AAK3F,4DAA4D;AAC5D,MAAM,WAAW,yBAAyB;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACjC;AAED,6BAA6B;AAC7B,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,kCAAkC;AAClC,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAC;CACtC;AAMD,gCAAgC;AAChC,MAAM,WAAW,mBAAmB;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,IAAI,EAAE,oBAAoB,CAAC;QAC3B,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAED,4BAA4B;AAC5B,MAAM,WAAW,kBAAkB;IACjC,CAAC,mBAAmB,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACrD;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAO6B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IALtF,sCAAsC;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;gBAE/B,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,EAAmB,OAAO,CAAC,EAAE,OAAO,CAAC,kCAAkC,CAAC,YAAA;IAKnI,8CAA8C;IAC9C,OAAO,CAAC,oBAAoB;IAK5B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA4B3B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;;OAGG;YACW,oBAAoB;IAQlC;;;OAGG;YACW,gBAAgB;IAI9B;;;;OAIG;IACH,OAAO,CAAC,oCAAoC;IAiC5C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAYnB,kDAAkD;IAC3C,uBAAuB;;;;;IAgB9B;;;;;OAKG;IACU,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAE,MAAM,EAAO,EAAE,YAAY,UAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA2BnJ;;;OAGG;IACU,+BAA+B,CAAC,sBAAsB,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA8BjH;;;OAGG;IACU,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE;IAQzD;;;OAGG;IACU,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE;IASzD;;;;;;;;OAQG;IACI,gBAAgB,CAAC,eAAe,EAAE,mBAAmB,EAAE,OAAO,EAAE;QACrE,mBAAmB,EAAE,OAAO,CAAC;QAC7B,eAAe,EAAE,kBAAkB,CAAC;QACpC,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,OAAO,CAAC;KACnB,GAAG,oBAAoB;CA0DzB"}
1
+ {"version":3,"file":"localization.generator.d.ts","sourceRoot":"","sources":["../../../builders/helpers/localization.generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EACR,MAAM,sBAAsB,CAAC;AAU9B,OAAO,KAAK,EACV,kCAAkC,EACnC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAK3B,4DAA4D;AAC5D,MAAM,WAAW,yBAAyB;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACjC;AAED,6BAA6B;AAC7B,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,kCAAkC;AAClC,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAC;CACtC;AAMD,gCAAgC;AAChC,MAAM,WAAW,mBAAmB;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,IAAI,EAAE,oBAAoB,CAAC;QAC3B,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAED,4BAA4B;AAC5B,MAAM,WAAW,kBAAkB;IACjC,CAAC,mBAAmB,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACrD;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAM6B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IALtF,sCAAsC;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;gBAE/B,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,EAAmB,OAAO,CAAC,EAAE,OAAO,CAAC,kCAAkC,CAAC,YAAA;IAKnI,8CAA8C;IAC9C,OAAO,CAAC,oBAAoB;IAK5B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA4B3B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;;OAGG;YACW,oBAAoB;IAQlC;;;OAGG;YACW,gBAAgB;IAI9B;;;;OAIG;IACH,OAAO,CAAC,oCAAoC;IA6B5C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAYnB,kDAAkD;IAC3C,uBAAuB;;;;;IAiB9B;;;;;OAKG;IACU,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAE,MAAM,EAAO,EAAE,YAAY,UAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA2BnJ;;;OAGG;IACU,+BAA+B,CAAC,sBAAsB,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA8BjH;;;OAGG;IACU,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE;IAQzD;;;OAGG;IACU,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE;IASzD;;;;;;;;OAQG;IACI,gBAAgB,CAAC,eAAe,EAAE,mBAAmB,EAAE,OAAO,EAAE;QACrE,mBAAmB,EAAE,OAAO,CAAC;QAC7B,eAAe,EAAE,kBAAkB,CAAC;QACpC,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,OAAO,CAAC;KACnB,GAAG,oBAAoB;CA4DzB"}
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LocalizationExtractor = void 0;
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
4
6
  const extractors_1 = require("@o3r/extractors");
5
7
  const schematics_1 = require("@o3r/schematics");
6
- const fs = require("node:fs");
7
8
  const glob = require("globby");
8
- const path = require("node:path");
9
9
  const ts = require("typescript");
10
10
  /** List of Angular decorator to look for */
11
11
  const ANGULAR_ANNOTATION = ['Component', 'Injectable', 'Pipe'];
@@ -49,7 +49,7 @@ class LocalizationExtractor {
49
49
  angularItems.push(item);
50
50
  }
51
51
  });
52
- return angularItems.length ? angularItems : undefined;
52
+ return angularItems.length > 0 ? angularItems : undefined;
53
53
  }
54
54
  /**
55
55
  * Get the list of referenced translation files
@@ -83,7 +83,7 @@ class LocalizationExtractor {
83
83
  return folder ? path.resolve(folder, ref) : ref;
84
84
  })
85
85
  .filter((ref) => !!ref);
86
- return referencedFiles.length ? referencedFiles : undefined;
86
+ return referencedFiles.length > 0 ? referencedFiles : undefined;
87
87
  }
88
88
  /**
89
89
  * Read a localization file
@@ -123,12 +123,7 @@ class LocalizationExtractor {
123
123
  }
124
124
  if (loc.$ref) {
125
125
  const [refPath, refKey] = loc.$ref.split('#/', 2);
126
- if (refPath.startsWith('.') || this.options?.libraries?.some((lib) => refPath.startsWith(lib))) {
127
- res.ref = refKey;
128
- }
129
- else {
130
- res.ref = loc.$ref;
131
- }
126
+ res.ref = refPath.startsWith('.') || this.options?.libraries?.some((lib) => refPath.startsWith(lib)) ? refKey : loc.$ref;
132
127
  }
133
128
  if (typeof loc.defaultValue === 'undefined' && typeof loc.$ref === 'undefined' && !loc.dictionary) {
134
129
  this.logger.error(`${key} has no default value or $ref defined`);
@@ -154,10 +149,11 @@ class LocalizationExtractor {
154
149
  }
155
150
  /** Get the list of patterns from tsconfig.json */
156
151
  getPatternsFromTsConfig() {
157
- const tsconfigResult = ts.readConfigFile(this.tsconfigPath, ts.sys.readFile);
152
+ const tsconfigResult = ts.readConfigFile(this.tsconfigPath, (p) => ts.sys.readFile(p));
158
153
  if (tsconfigResult.error) {
159
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
160
- const stringError = tsconfigResult.error.messageText.toString();
154
+ const stringError = typeof tsconfigResult.error.messageText === 'string'
155
+ ? tsconfigResult.error.messageText
156
+ : tsconfigResult.error.messageText.messageText;
161
157
  this.logger.error(stringError);
162
158
  throw new schematics_1.O3rCliError(stringError);
163
159
  }
@@ -184,10 +180,10 @@ class LocalizationExtractor {
184
180
  .map((file) => this.getReferencedFiles(mapLocalization[file].data, file))
185
181
  .filter((refs) => !!refs)
186
182
  .reduce((acc, refs) => {
187
- acc.push(...refs.filter((ref) => localizationFiles.indexOf(ref) === -1 && alreadyLoadedFiles.indexOf(ref) === -1));
183
+ acc.push(...refs.filter((ref) => !localizationFiles.includes(ref) && !alreadyLoadedFiles.includes(ref)));
188
184
  return acc;
189
185
  }, []);
190
- if (references.length) {
186
+ if (references.length > 0) {
191
187
  return {
192
188
  ...mapLocalization,
193
189
  ...await this.getLocalizationMap(references, [...localizationFiles, ...alreadyLoadedFiles], true)
@@ -213,15 +209,15 @@ class LocalizationExtractor {
213
209
  .map((classItem) => (0, extractors_1.getLocalizationFileFromAngularElement)(classItem))
214
210
  .filter((locFiles) => !!locFiles)
215
211
  .reduce((acc, locFiles) => {
216
- acc.push(...locFiles.filter((f) => acc.indexOf(f) === -1));
212
+ acc.push(...locFiles.filter((f) => !acc.includes(f)));
217
213
  return acc;
218
214
  }, [])
219
215
  .map((locFile) => path.resolve(path.dirname(file), locFile)))
220
216
  .reduce((acc, locFiles) => {
221
- acc.push(...locFiles.filter((f) => acc.indexOf(f) === -1));
217
+ acc.push(...locFiles.filter((f) => !acc.includes(f)));
222
218
  return acc;
223
219
  }, []);
224
- localizationFiles.push(...extraLocalizationFiles.filter((file) => localizationFiles.indexOf(file) === -1));
220
+ localizationFiles.push(...extraLocalizationFiles.filter((file) => !localizationFiles.includes(file)));
225
221
  return this.getLocalizationMap(localizationFiles);
226
222
  }
227
223
  /**
@@ -267,10 +263,12 @@ class LocalizationExtractor {
267
263
  this.logger.error(`The key ${data.key} from ${origin} try to override the previous value (${metadata[data.key].value || 'ref ' + metadata[data.key].ref} -> ${data.value || 'ref ' + data.ref})`);
268
264
  }
269
265
  }
270
- metadata[data.key] = data.ref && data.ref.includes('#/') && libraries.some((lib) => data.ref.startsWith(lib)) ? {
271
- ...data,
272
- ref: data.ref.split('#/')[1]
273
- } : data;
266
+ metadata[data.key] = data.ref && data.ref.includes('#/') && libraries.some((lib) => data.ref.startsWith(lib))
267
+ ? {
268
+ ...data,
269
+ ref: data.ref.split('#/')[1]
270
+ }
271
+ : data;
274
272
  };
275
273
  Object.keys(options.libraryMetadata)
276
274
  .forEach((lib) => options.libraryMetadata[lib].forEach((dataLoc) => addMetadata(dataLoc, lib, this.options?.libraries)));
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/i18n/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;;AAE3C,wBAsCI"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/i18n/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,iBAAiB,EAClB,MAAM,UAAU,CAAC;;AAElB,wBAsCI"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
3
5
  const architect_1 = require("@angular-devkit/architect");
4
6
  const extractors_1 = require("@o3r/extractors");
5
- const fs = require("node:fs");
6
7
  const globby_1 = require("globby");
7
- const path = require("node:path");
8
8
  exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderWithMetricsIfInstalled)((options, context) => {
9
9
  const posixWorkspaceRoot = context.workspaceRoot.split(path.sep).join(path.posix.sep);
10
10
  options.localizationConfigs.forEach((config) => {
@@ -6,7 +6,6 @@ export interface LocalizationConfig extends JsonObject {
6
6
  localizationFiles: string[];
7
7
  /**
8
8
  * Folder path for the i18n folder relative to the localization json file
9
- *
10
9
  * @default 'i18n'
11
10
  */
12
11
  i18nFolderPath: string;
@@ -18,7 +17,6 @@ export interface I18nBuilderSchema extends JsonObject {
18
17
  localizationConfigs: LocalizationConfig[];
19
18
  /**
20
19
  * Name of the file for the default language
21
- *
22
20
  * @default 'en-GB.json'
23
21
  */
24
22
  defaultLanguageFile: string;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/i18n/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAErD,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD;;OAEG;IACH,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD;;OAEG;IACH,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAE1C;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/i18n/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD;;OAEG;IACH,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD;;OAEG;IACH,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAE1C;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B"}
@@ -1,7 +1,6 @@
1
1
  import { LocalizationBuilderSchema } from './schema';
2
2
  /**
3
3
  * Load all the translation files in the given array and created a single Object that associated to each key its localized value.
4
- *
5
4
  * @param files
6
5
  */
7
6
  export declare function loadTranslations(files: string[]): {
@@ -9,7 +8,6 @@ export declare function loadTranslations(files: string[]): {
9
8
  };
10
9
  /**
11
10
  * Computes the translation bundle for a given language, by resolving overrides specified in defaultLanguageMapping
12
- *
13
11
  * @param language
14
12
  * @param filesPerLanguage
15
13
  * @param defaultLanguageMapping
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/localization/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAgFrD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,CAGvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAC1C,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC9C,cAAc,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BjE;;AAgLD,wBA+MI"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/localization/index.ts"],"names":[],"mappings":"AA+BA,OAAO,EACL,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AA+ElB;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAGzE;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAC1C,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC9C,cAAc,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BjE;;AA0KD,wBA0MI"}
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadTranslations = loadTranslations;
4
4
  exports.getTranslationsForLanguage = getTranslationsForLanguage;
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
5
7
  const architect_1 = require("@angular-devkit/architect");
6
8
  const extractors_1 = require("@o3r/extractors");
7
9
  const schematics_1 = require("@o3r/schematics");
8
- const fs = require("node:fs");
9
10
  const globby_1 = require("globby");
10
- const path = require("node:path");
11
11
  const rxjs_1 = require("rxjs");
12
12
  const operators_1 = require("rxjs/operators");
13
13
  /** Maximum number of steps */
@@ -16,7 +16,6 @@ const STEP_NUMBER = 5;
16
16
  const FS_DEBOUNCE_TIME = 200;
17
17
  /**
18
18
  * Get the list of translation files provided in the current package
19
- *
20
19
  * @param languages List of languages
21
20
  * @param assets Folder containing the package override translations bundles
22
21
  * @param context Ng Builder context
@@ -39,7 +38,6 @@ function getAppTranslationFiles(languages, assets, context) {
39
38
  }
40
39
  /**
41
40
  * Check if a translation has been overridden at application level but not defined in the metadata
42
- *
43
41
  * @param language Language
44
42
  * @param defaultBundle Default translation bundle
45
43
  * @param customTranslations Override of translations provided by assets
@@ -56,14 +54,13 @@ function checkUnusedTranslation(language, defaultBundle, customTranslations, con
56
54
  .filter((key) => defaultBundle[key] === undefined)
57
55
  .filter((key) => !dictionaryKeysPatterns.some((dictionaryKeyPattern) => key.startsWith(dictionaryKeyPattern)));
58
56
  missingMetadata.forEach((key) => context.logger[failIfMissingMetadata ? 'error' : 'warn'](`The key "${key}" from "${language}" is not part of the MetaData`));
59
- if (missingMetadata.length && failIfMissingMetadata) {
57
+ if (missingMetadata.length > 0 && failIfMissingMetadata) {
60
58
  throw new schematics_1.O3rCliError(`There is missing metadata for ${language}`);
61
59
  }
62
60
  }
63
61
  /**
64
62
  * Clean localization json file.
65
63
  * Note: it is used to remove $schema potentially added by the customization
66
- *
67
64
  * @param translationBundle Translation bundle
68
65
  */
69
66
  function sanitizeLocalization(translationBundle) {
@@ -72,7 +69,6 @@ function sanitizeLocalization(translationBundle) {
72
69
  }
73
70
  /**
74
71
  * Load all the translation files in the given array and created a single Object that associated to each key its localized value.
75
- *
76
72
  * @param files
77
73
  */
78
74
  function loadTranslations(files) {
@@ -81,7 +77,6 @@ function loadTranslations(files) {
81
77
  }
82
78
  /**
83
79
  * Computes the translation bundle for a given language, by resolving overrides specified in defaultLanguageMapping
84
- *
85
80
  * @param language
86
81
  * @param filesPerLanguage
87
82
  * @param defaultLanguageMapping
@@ -116,7 +111,6 @@ function getTranslationsForLanguage(language, filesPerLanguage, defaultLanguageM
116
111
  }
117
112
  /**
118
113
  * Get the translation bundle for each languages
119
- *
120
114
  * @param languages List of languages
121
115
  * @param defaultBundle Default translation bundle
122
116
  * @param fileMapping Mapping of translations per languages
@@ -138,10 +132,12 @@ function getBundlesPerLanguages(languages, defaultBundle, fileMapping, mapRefere
138
132
  if (shouldCheckUnusedTranslation) {
139
133
  checkUnusedTranslation(language, defaultBundle, translations, context, metadata, failIfMissingMetadata);
140
134
  }
141
- const bundle = useMetadataAsDefault ? {
142
- ...defaultBundle,
143
- ...translations
144
- } : translations;
135
+ const bundle = useMetadataAsDefault
136
+ ? {
137
+ ...defaultBundle,
138
+ ...translations
139
+ }
140
+ : translations;
145
141
  bundles[language] = bundle;
146
142
  Object.keys(mapReferencesDictionary)
147
143
  .forEach((key) => Object.keys(bundles[language])
@@ -163,7 +159,6 @@ function getBundlesPerLanguages(languages, defaultBundle, fileMapping, mapRefere
163
159
  }
164
160
  /**
165
161
  * Extract localization referred in metadata
166
- *
167
162
  * @param metaData Localization metadata
168
163
  * @param key Translation key
169
164
  */
@@ -178,7 +173,6 @@ function getExtractReferredTranslationValue(metaData, key) {
178
173
  }
179
174
  /**
180
175
  * Extract localization key referred in metadata
181
- *
182
176
  * @param metaData Localization metadata
183
177
  * @param key Translation key
184
178
  */
@@ -188,10 +182,9 @@ function getExtractReferredTranslationKey(metaData, key) {
188
182
  }
189
183
  /**
190
184
  * Extract some data from the provided localization metadata:
191
- * - The bundle containing default translations
192
- * - The map that associates to every key containing a reference, the key it resolves to
193
- * - The map that associated to every key being a dictionary reference, the key it resolves to
194
- *
185
+ * - The bundle containing default translations
186
+ * - The map that associates to every key containing a reference, the key it resolves to
187
+ * - The map that associated to every key being a dictionary reference, the key it resolves to
195
188
  * @param metadata
196
189
  */
197
190
  function processMetadata(metadata) {
@@ -218,7 +211,6 @@ function processMetadata(metadata) {
218
211
  }
219
212
  /**
220
213
  * Start the metadata generator in watch mode
221
- *
222
214
  * @param localizationExtractorTarget Target of the localization extractor builder
223
215
  * @param context Builder context
224
216
  */
@@ -229,7 +221,6 @@ function startMetadataGenerator(localizationExtractorTarget, context) {
229
221
  }
230
222
  /**
231
223
  * Regenerate the metadata if missing
232
- *
233
224
  * @param localizationMetaDataFile Path to the localization metadata file
234
225
  * @param localizationExtractorTarget Localization Extractor target configured in the angular.json
235
226
  * @param context Ng Builder context
@@ -241,10 +232,7 @@ async function checkMetadata(localizationMetaDataFile, localizationExtractorTarg
241
232
  context.reportProgress(2, STEP_NUMBER, 'Generating Localization metadata file');
242
233
  const extractorBuild = await context.scheduleTarget(localizationExtractorTarget, { watch: false });
243
234
  const extractorBuildResult = await extractorBuild.result;
244
- if (!extractorBuildResult.success) {
245
- return extractorBuildResult;
246
- }
247
- else {
235
+ if (extractorBuildResult.success) {
248
236
  metaDataExists = fs.existsSync(localizationMetaDataFile);
249
237
  if (!metaDataExists) {
250
238
  return {
@@ -253,6 +241,9 @@ async function checkMetadata(localizationMetaDataFile, localizationExtractorTarg
253
241
  };
254
242
  }
255
243
  }
244
+ else {
245
+ return extractorBuildResult;
246
+ }
256
247
  }
257
248
  }
258
249
  exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderWithMetricsIfInstalled)(async (options, context) => {
@@ -281,11 +272,11 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
281
272
  error: `The targetBrowser ${options.browserTarget} does not provide 'outputPath' option`
282
273
  };
283
274
  }
284
- else if (typeof browserTargetOptions.outputPath !== 'string') {
285
- browserTargetOptionsOutputPath = path.join(browserTargetOptions.outputPath.base, typeof browserTargetOptions.outputPath.browser === 'string' ? browserTargetOptions.outputPath.browser : '');
275
+ else if (typeof browserTargetOptions.outputPath === 'string') {
276
+ browserTargetOptionsOutputPath = browserTargetOptions.outputPath;
286
277
  }
287
278
  else {
288
- browserTargetOptionsOutputPath = browserTargetOptions.outputPath;
279
+ browserTargetOptionsOutputPath = path.join(browserTargetOptions.outputPath.base, typeof browserTargetOptions.outputPath.browser === 'string' ? browserTargetOptions.outputPath.browser : '');
289
280
  }
290
281
  if (typeof localizationExtracterTargetOptions.outputFile !== 'string') {
291
282
  return {
@@ -299,7 +290,6 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
299
290
  const localizationMetaDataFile = path.resolve(context.workspaceRoot, localizationExtracterTargetOptions.outputFile);
300
291
  /**
301
292
  * Generate translation bundles
302
- *
303
293
  * @param languageToRegenerate language to focus on
304
294
  */
305
295
  const execute = (languageToRegenerate) => {
@@ -339,11 +329,9 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
339
329
  }
340
330
  };
341
331
  /** Timeout to handle nodejs issue (#1970) */
342
- // eslint-disable-next-line no-undef
343
332
  const fsTimeout = {};
344
333
  /**
345
334
  * Run a translation generation and report the result
346
- *
347
335
  * @param language Language that has changed and requires a regeneration
348
336
  */
349
337
  const generateWithReport = (language) => {
@@ -375,7 +363,6 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
375
363
  };
376
364
  /**
377
365
  * Run a translation generation for asset change
378
- *
379
366
  * @param filename File that has changed and requires a regeneration
380
367
  * @param fullFilePath
381
368
  */
@@ -389,15 +376,7 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
389
376
  generateWithReport(path.parse(filename).name);
390
377
  }, FS_DEBOUNCE_TIME);
391
378
  };
392
- if (!options.watch) {
393
- // Execute the generation only once if not watch mode
394
- const metaDataGeneration = await checkMetadata(localizationMetaDataFile, localizationExtractorTarget, context);
395
- if (metaDataGeneration && !metaDataGeneration.success) {
396
- return metaDataGeneration;
397
- }
398
- return execute();
399
- }
400
- else {
379
+ if (options.watch) {
401
380
  const metaDataGeneration = await startMetadataGenerator(localizationExtractorTarget, context);
402
381
  const metaDataGenerationResult = metaDataGeneration && metaDataGeneration.output && metaDataGeneration.result;
403
382
  if (metaDataGenerationResult && !metaDataGenerationResult.success) {
@@ -425,5 +404,13 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
425
404
  metadataWatcher.once('error', (err) => reject(err));
426
405
  });
427
406
  }
407
+ else {
408
+ // Execute the generation only once if not watch mode
409
+ const metaDataGeneration = await checkMetadata(localizationMetaDataFile, localizationExtractorTarget, context);
410
+ if (metaDataGeneration && !metaDataGeneration.success) {
411
+ return metaDataGeneration;
412
+ }
413
+ return execute();
414
+ }
428
415
  }));
429
416
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/localization/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAE3D,sBAAsB;IACtB,aAAa,EAAE,MAAM,CAAC;IAEtB,mCAAmC;IACnC,2BAA2B,EAAE,MAAM,CAAC;IAEpC,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IAEnB,oCAAoC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,yGAAyG;IACzG,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/C,kHAAkH;IAClH,oBAAoB,EAAE,OAAO,CAAC;IAE9B,oIAAoI;IACpI,4BAA4B,EAAE,OAAO,CAAC;IAEtC,uDAAuD;IACvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAEjC,mFAAmF;IACnF,sBAAsB,EAAE,OAAO,CAAC;IAEhC,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAC;IAEf,mDAAmD;IACnD,qBAAqB,EAAE,OAAO,CAAC;CAChC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/localization/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAE3D,sBAAsB;IACtB,aAAa,EAAE,MAAM,CAAC;IAEtB,mCAAmC;IACnC,2BAA2B,EAAE,MAAM,CAAC;IAEpC,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IAEnB,oCAAoC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,yGAAyG;IACzG,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/C,kHAAkH;IAClH,oBAAoB,EAAE,OAAO,CAAC;IAE9B,oIAAoI;IACpI,4BAA4B,EAAE,OAAO,CAAC;IAEtC,uDAAuD;IACvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAEjC,mFAAmF;IACnF,sBAAsB,EAAE,OAAO,CAAC;IAEhC,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAC;IAEf,mDAAmD;IACnD,qBAAqB,EAAE,OAAO,CAAC;CAChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/localization-extractor/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAG9D,cAAc,UAAU,CAAC;;AAEzB,wBAkMI"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/localization-extractor/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,kCAAkC,EACnC,MAAM,UAAU,CAAC;AAKlB,cAAc,UAAU,CAAC;;AAEzB,wBAiMI"}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
4
6
  const architect_1 = require("@angular-devkit/architect");
5
7
  const extractors_1 = require("@o3r/extractors");
6
8
  const schematics_1 = require("@o3r/schematics");
7
9
  const chokidar = require("chokidar");
8
- const fs = require("node:fs");
9
10
  const globby_1 = require("globby");
10
- const path = require("node:path");
11
11
  const localization_generator_1 = require("../helpers/localization.generator");
12
12
  const validations_1 = require("./validations");
13
13
  tslib_1.__exportStar(require("./schema"), exports);
@@ -17,7 +17,7 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
17
17
  const cache = { libs: {}, locs: {} };
18
18
  const execute = async (isFirstLoad = true, files) => {
19
19
  /** Maximum number of steps */
20
- const STEP_NUMBER = !isFirstLoad && files ? (files.libs && files.libs.length ? 1 : 0) + (files.locs && files.locs.length ? 1 : 0) + 2 : 4;
20
+ const STEP_NUMBER = !isFirstLoad && files ? (files.libs && files.libs.length > 0 ? 1 : 0) + (files.locs && files.locs.length > 0 ? 1 : 0) + 2 : 4;
21
21
  let stepValue = 0;
22
22
  try {
23
23
  // load everything from TSConfig
@@ -60,9 +60,9 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
60
60
  });
61
61
  context.reportProgress(STEP_NUMBER, stepValue++, 'Check translations string validation');
62
62
  const translationsWithIssue = metadata
63
- .filter((metadataItem) => !!metadataItem.value &&
64
- validations_1.validators.reduce((isInvalid, validator) => isInvalid || !validator(metadataItem.value), false));
65
- if (translationsWithIssue.length) {
63
+ .filter((metadataItem) => !!metadataItem.value
64
+ && validations_1.validators.reduce((isInvalid, validator) => isInvalid || !validator(metadataItem.value), false));
65
+ if (translationsWithIssue.length > 0) {
66
66
  throw new schematics_1.O3rCliError(`The following translations are invalid: ${translationsWithIssue.map((translation) => translation.key).join(', ')}`);
67
67
  }
68
68
  (0, extractors_1.validateJson)(metadata, JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../schemas/localization.metadata.schema.json'), { encoding: 'utf8' })), 'The output of localization metadata is not valid regarding the json schema, please check the details below : \n', options.strictMode);
@@ -110,11 +110,8 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
110
110
  context.reportStatus('Waiting for changes...');
111
111
  return result;
112
112
  };
113
- const initialExtraLocs = options.extraFilePatterns.length ? (0, globby_1.sync)(options.extraFilePatterns, { cwd: context.currentDirectory }) : [];
114
- if (!options.watch) {
115
- return execute(true, { extraFiles: initialExtraLocs, libs: options.libraries });
116
- }
117
- else {
113
+ const initialExtraLocs = options.extraFilePatterns.length > 0 ? (0, globby_1.sync)(options.extraFilePatterns, { cwd: context.currentDirectory }) : [];
114
+ if (options.watch) {
118
115
  let currentProcess = generateWithReport(execute(true, { extraFiles: initialExtraLocs, libs: options.libraries }))
119
116
  .then(() => currentProcess = undefined);
120
117
  await currentProcess;
@@ -139,27 +136,27 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
139
136
  });
140
137
  metadataWatcher
141
138
  .on('all', async (eventName, filePath) => {
142
- if (!currentProcess) {
139
+ if (currentProcess) {
140
+ context.logger.debug(`Ignored action ${eventName} on ${filePath}`);
141
+ }
142
+ else {
143
143
  context.logger.debug(`Refreshed for action ${eventName} on ${filePath}`);
144
144
  currentProcess = generateWithReport(execute(false, { libs: [filePath] }));
145
145
  await currentProcess;
146
146
  currentProcess = undefined;
147
147
  }
148
- else {
149
- context.logger.debug(`Ignored action ${eventName} on ${filePath}`);
150
- }
151
148
  });
152
149
  watcher
153
150
  .on('all', async (eventName, filePath) => {
154
- if (!currentProcess) {
151
+ if (currentProcess) {
152
+ context.logger.debug(`Ignored action ${eventName} on ${filePath}`);
153
+ }
154
+ else {
155
155
  context.logger.debug(`Refreshed for action ${eventName} on ${filePath}`);
156
156
  currentProcess = generateWithReport(execute(false, { locs: [filePath] }));
157
157
  await currentProcess;
158
158
  currentProcess = undefined;
159
159
  }
160
- else {
161
- context.logger.debug(`Ignored action ${eventName} on ${filePath}`);
162
- }
163
160
  });
164
161
  context.addTeardown(async () => {
165
162
  await watcher.close();
@@ -173,5 +170,8 @@ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderW
173
170
  tsWatcher.on('error', (err) => reject(err));
174
171
  });
175
172
  }
173
+ else {
174
+ return execute(true, { extraFiles: initialExtraLocs, libs: options.libraries });
175
+ }
176
176
  }));
177
177
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/localization-extractor/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,kCAAmC,SAAQ,UAAU;IAEpE,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IAEjB,+EAA+E;IAC/E,mBAAmB,EAAE,OAAO,CAAC;IAE7B,iCAAiC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IAEnB,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAC;IAEf,4BAA4B;IAC5B,MAAM,EAAE,OAAO,CAAC;IAEhB,8DAA8D;IAC9D,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAElB,mIAAmI;IACnI,UAAU,EAAE,OAAO,CAAC;CACrB"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/localization-extractor/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,kCAAmC,SAAQ,UAAU;IAEpE,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IAEjB,+EAA+E;IAC/E,mBAAmB,EAAE,OAAO,CAAC;IAE7B,iCAAiC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IAEnB,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAC;IAEf,4BAA4B;IAC5B,MAAM,EAAE,OAAO,CAAC;IAEhB,8DAA8D;IAC9D,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAElB,mIAAmI;IACnI,UAAU,EAAE,OAAO,CAAC;CACrB"}
@@ -2,13 +2,11 @@
2
2
  export type ValidatorType = (str: string) => boolean;
3
3
  /**
4
4
  * Check that the opened parentheses are correctly closed
5
- *
6
5
  * @param str translation
7
6
  */
8
7
  export declare function checkParentheses(str: string): boolean;
9
8
  /**
10
9
  * Check if the plural instruction always include an "other" case
11
- *
12
10
  * @param str translation
13
11
  */
14
12
  export declare function checkOtherInPlural(str: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../../builders/localization-extractor/validations.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,WA2B3C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,WAK7C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,aAAa,EAGrC,CAAC"}
1
+ {"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../../builders/localization-extractor/validations.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAErD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,WAyB3C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,WAK7C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,aAAa,EAGrC,CAAC"}
@@ -5,24 +5,21 @@ exports.checkParentheses = checkParentheses;
5
5
  exports.checkOtherInPlural = checkOtherInPlural;
6
6
  /**
7
7
  * Check that the opened parentheses are correctly closed
8
- *
9
8
  * @param str translation
10
9
  */
11
10
  function checkParentheses(str) {
12
- /* eslint-disable @typescript-eslint/naming-convention */
13
11
  const mapBrackets = {
14
12
  '[': ']',
15
13
  '{': '}',
16
14
  '(': ')'
17
15
  };
18
- /* eslint-enable @typescript-eslint/naming-convention */
19
16
  const closureBrackets = Object.keys(mapBrackets).map((k) => mapBrackets[k]);
20
17
  const stack = [];
21
18
  for (const ch of str) {
22
19
  if (mapBrackets[ch]) {
23
20
  stack.push(ch);
24
21
  }
25
- else if (closureBrackets.indexOf(ch) >= 0) {
22
+ else if (closureBrackets.includes(ch)) {
26
23
  const tail = stack.pop();
27
24
  if (!tail) {
28
25
  return false;
@@ -37,12 +34,11 @@ function checkParentheses(str) {
37
34
  }
38
35
  /**
39
36
  * Check if the plural instruction always include an "other" case
40
- *
41
37
  * @param str translation
42
38
  */
43
39
  function checkOtherInPlural(str) {
44
- if (/\{[^,]*, *plural *, *.*\}/.test(str)) {
45
- return /\{.*other.*\}/.test(str);
40
+ if (/{[^,]*, *plural *, *.*}/.test(str)) {
41
+ return /{.*other.*}/.test(str);
46
42
  }
47
43
  return true;
48
44
  }
@@ -1,5 +1,5 @@
1
- import type { JSONLocalization, LocalizationMetadata } from '@o3r/localization';
2
1
  import type { MetadataComparator } from '@o3r/extractors';
2
+ import type { JSONLocalization, LocalizationMetadata } from '@o3r/localization';
3
3
  /**
4
4
  * Interface describing a localization migration element
5
5
  */
@@ -10,5 +10,5 @@ export interface MigrationLocalizationMetadata {
10
10
  /**
11
11
  * Comparator used to compare one version of localization metadata with another
12
12
  */
13
- export declare const localizationMetadataComparator: MetadataComparator<JSONLocalization, MigrationLocalizationMetadata, LocalizationMetadata>;
13
+ export declare const localizationMetadataComparator: Readonly<MetadataComparator<JSONLocalization, MigrationLocalizationMetadata, LocalizationMetadata>>;
14
14
  //# sourceMappingURL=localization-metadata-comparison.helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localization-metadata-comparison.helper.d.ts","sourceRoot":"","sources":["../../../../builders/metadata-check/helpers/localization-metadata-comparison.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAgBD;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,kBAAkB,CAAC,gBAAgB,EAAE,6BAA6B,EAAE,oBAAoB,CAKpI,CAAC"}
1
+ {"version":3,"file":"localization-metadata-comparison.helper.d.ts","sourceRoot":"","sources":["../../../../builders/metadata-check/helpers/localization-metadata-comparison.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAeD;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,6BAA6B,EAAE,oBAAoB,CAAC,CAKrI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/metadata-check/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,+CAA+C,EAAE,MAAM,UAAU,CAAC;;AAEhF,wBAEI"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/metadata-check/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,+CAA+C,EAChD,MAAM,UAAU,CAAC;;AAElB,wBAEI"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/metadata-check/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,iBAAiB,CAAC;AAE5E,8CAA8C;AAC9C,MAAM,WAAW,+CAAgD,SAAQ,oCAAoC;CAC5G"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/metadata-check/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACrC,MAAM,iBAAiB,CAAC;AAEzB,8CAA8C;AAC9C,MAAM,WAAW,+CAAgD,SAAQ,oCAAoC;CAC5G"}
@@ -52,5 +52,5 @@ export interface LocalizationConfiguration {
52
52
  /**
53
53
  * Default configuration for LocalizationModule
54
54
  */
55
- export declare const DEFAULT_LOCALIZATION_CONFIGURATION: LocalizationConfiguration;
55
+ export declare const DEFAULT_LOCALIZATION_CONFIGURATION: Readonly<LocalizationConfiguration>;
56
56
  //# sourceMappingURL=localization.configuration.d.ts.map