@o3r/localization 9.3.0-alpha.2 → 9.3.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/localization",
3
- "version": "9.3.0-alpha.2",
3
+ "version": "9.3.0-alpha.4",
4
4
  "description": "This module provides a runtime dynamic language/translation support and debug tools.",
5
5
  "keywords": [
6
6
  "localization",
@@ -20,11 +20,11 @@
20
20
  "@formatjs/intl-numberformat": "^8.0.2",
21
21
  "@ngrx/store": "~16.2.0",
22
22
  "@ngx-translate/core": "~15.0.0",
23
- "@o3r/core": "^9.3.0-alpha.2",
24
- "@o3r/dynamic-content": "^9.3.0-alpha.2",
25
- "@o3r/extractors": "^9.3.0-alpha.2",
26
- "@o3r/logger": "^9.3.0-alpha.2",
27
- "@o3r/schematics": "^9.3.0-alpha.2",
23
+ "@o3r/core": "^9.3.0-alpha.4",
24
+ "@o3r/dynamic-content": "^9.3.0-alpha.4",
25
+ "@o3r/extractors": "^9.3.0-alpha.4",
26
+ "@o3r/logger": "^9.3.0-alpha.4",
27
+ "@o3r/schematics": "^9.3.0-alpha.4",
28
28
  "@schematics/angular": "~16.2.0",
29
29
  "chokidar": "^3.5.2",
30
30
  "intl-messageformat": "~10.5.0",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/cms-adapter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAKjF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,IAAI,CAoEpF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/cms-adapter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAKvF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,IAAI,CAuEpF"}
@@ -12,6 +12,9 @@ const path = require("node:path");
12
12
  * @param rootPath @see RuleFactory.rootPath
13
13
  */
14
14
  function updateCmsAdapter(options) {
15
+ if (!options.projectName) {
16
+ return schematics_1.noop;
17
+ }
15
18
  /**
16
19
  * Add cms extractors builder into the angular.json
17
20
  *
@@ -12,5 +12,7 @@ export declare function updateLocalization(options: {
12
12
  /**
13
13
  *
14
14
  */
15
- export declare function updateI18n(): Rule;
15
+ export declare function updateI18n(options: {
16
+ projectName?: string | undefined;
17
+ }): Rule;
16
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/localization-base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,IAAI,EAAyC,MAAM,4BAA4B,CAAC;AAoCjI;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CA8a/G;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAwCjC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/localization-base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsD,IAAI,EAAyC,MAAM,4BAA4B,CAAC;AAoC7I;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAmb/G;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,GAAG,IAAI,CA0C5E"}
@@ -20,6 +20,9 @@ const angularCdkDep = '@angular/cdk';
20
20
  * @param rootPath @see RuleFactory.rootPath
21
21
  */
22
22
  function updateLocalization(options, rootPath) {
23
+ if (!options.projectName) {
24
+ return schematics_1.noop;
25
+ }
23
26
  const mainAssetsFolder = 'src/assets';
24
27
  const devResourcesFolder = 'dev-resources';
25
28
  /**
@@ -29,13 +32,15 @@ function updateLocalization(options, rootPath) {
29
32
  * @param context
30
33
  */
31
34
  const generateLocalesFolder = (tree, context) => {
35
+ const workingDirectory = (0, schematics_2.getProjectRootDir)(tree, options.projectName) || '.';
32
36
  let gitIgnoreContent = '';
33
- if (tree.exists('.gitignore')) {
34
- gitIgnoreContent = tree.read('.gitignore').toString();
37
+ const gitIgnorePath = path.posix.join(workingDirectory, '.gitignore');
38
+ if (tree.exists(gitIgnorePath)) {
39
+ gitIgnoreContent = tree.read(gitIgnorePath).toString();
35
40
  if (gitIgnoreContent.indexOf('/*.metadata.json')) {
36
41
  return tree;
37
42
  }
38
- tree.delete('.gitignore');
43
+ tree.delete(gitIgnorePath);
39
44
  }
40
45
  const templateSource = (0, schematics_1.apply)((0, schematics_1.url)((0, schematics_2.getTemplateFolder)(rootPath, __dirname)), [
41
46
  (0, schematics_1.template)({
@@ -43,7 +48,8 @@ function updateLocalization(options, rootPath) {
43
48
  devResourcesFolder,
44
49
  gitIgnoreContent,
45
50
  mainAssetsFolder
46
- })
51
+ }),
52
+ (0, schematics_1.move)(workingDirectory)
47
53
  ]);
48
54
  const rule = (0, schematics_1.mergeWith)(templateSource, schematics_1.MergeStrategy.Overwrite);
49
55
  return rule(tree, context);
@@ -58,7 +64,7 @@ function updateLocalization(options, rootPath) {
58
64
  const workspace = (0, schematics_2.readAngularJson)(tree);
59
65
  const projectName = options.projectName || Object.keys(workspace.projects)[0];
60
66
  const workspaceProject = (0, schematics_2.getProjectFromTree)(tree, projectName, 'application');
61
- const projectRoot = path.posix.join('/', workspaceProject?.root || '');
67
+ const projectRoot = path.posix.join(workspaceProject?.root || '');
62
68
  const distFolder = (workspaceProject &&
63
69
  workspaceProject.architect &&
64
70
  workspaceProject.architect.build &&
@@ -365,7 +371,10 @@ exports.updateLocalization = updateLocalization;
365
371
  /**
366
372
  *
367
373
  */
368
- function updateI18n() {
374
+ function updateI18n(options) {
375
+ if (!options.projectName) {
376
+ return schematics_1.noop;
377
+ }
369
378
  /**
370
379
  * Add i18n generation builders into angular.json
371
380
  *
@@ -373,7 +382,7 @@ function updateI18n() {
373
382
  */
374
383
  const updateAngularJson = (tree) => {
375
384
  const workspace = (0, schematics_2.readAngularJson)(tree);
376
- const workspaceProject = (0, schematics_2.getProjectFromTree)(tree);
385
+ const workspaceProject = (0, schematics_2.getProjectFromTree)(tree, options.projectName);
377
386
  if (!workspaceProject) {
378
387
  return tree;
379
388
  }
@@ -23,10 +23,10 @@ function ngAdd(options) {
23
23
  context.logger.info('Get information on https://github.com/AmadeusITGroup/otter/tree/main/docs/localization/LOCALIZATION.md#Debugging');
24
24
  // eslint-disable-next-line @typescript-eslint/naming-convention
25
25
  const { NodeDependencyType } = await Promise.resolve().then(() => require('@schematics/angular/utility/dependencies'));
26
- const workingDirectory = getProjectRootDir(tree, options.projectName);
26
+ const workingDirectory = options.projectName ? getProjectRootDir(tree, options.projectName) : '.';
27
27
  return () => (0, schematics_1.chain)([
28
28
  updateLocalization(options, __dirname),
29
- updateI18n(),
29
+ updateI18n(options),
30
30
  options.skipLinter ? (0, schematics_1.noop)() : applyEsLintFix(),
31
31
  // install ngx-translate and message format dependencies
32
32
  options.skipInstall ? schematics_1.noop : install,