@o3r/localization 11.1.0-prerelease.30 → 11.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/localization",
3
- "version": "11.1.0-prerelease.30",
3
+ "version": "11.1.0-prerelease.31",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -44,11 +44,11 @@
44
44
  "@formatjs/intl-numberformat": "^8.0.2",
45
45
  "@ngrx/store": "~18.0.0",
46
46
  "@ngx-translate/core": "~15.0.0",
47
- "@o3r/core": "^11.1.0-prerelease.30",
48
- "@o3r/dynamic-content": "^11.1.0-prerelease.30",
49
- "@o3r/extractors": "^11.1.0-prerelease.30",
50
- "@o3r/logger": "^11.1.0-prerelease.30",
51
- "@o3r/schematics": "^11.1.0-prerelease.30",
47
+ "@o3r/core": "^11.1.0-prerelease.31",
48
+ "@o3r/dynamic-content": "^11.1.0-prerelease.31",
49
+ "@o3r/extractors": "^11.1.0-prerelease.31",
50
+ "@o3r/logger": "^11.1.0-prerelease.31",
51
+ "@o3r/schematics": "^11.1.0-prerelease.31",
52
52
  "@schematics/angular": "~18.0.0",
53
53
  "@yarnpkg/cli": "^4.3.1",
54
54
  "@yarnpkg/core": "^4.1.1",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/localization-base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsD,IAAI,EAAyC,MAAM,4BAA4B,CAAC;AAgC7I;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAga/G;AAiDD,eAAO,MAAM,UAAU;kBA1CuB,MAAM,GAAG,SAAS;UA0Ca,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/localization-base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsE,IAAI,EAAyC,MAAM,4BAA4B,CAAC;AAgC7J;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAwZ/G;AAiDD,eAAO,MAAM,UAAU;kBA1CuB,MAAM,GAAG,SAAS;UA0Ca,CAAC"}
@@ -18,9 +18,6 @@ const ownPackageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: '
18
18
  * @param rootPath @see RuleFactory.rootPath
19
19
  */
20
20
  function updateLocalization(options, rootPath) {
21
- if (!options.projectName) {
22
- return schematics_1.noop;
23
- }
24
21
  const mainAssetsFolder = 'src/assets';
25
22
  const devResourcesFolder = 'dev-resources';
26
23
  /**
@@ -28,28 +25,17 @@ function updateLocalization(options, rootPath) {
28
25
  * @param tree
29
26
  * @param context
30
27
  */
31
- const generateLocalesFolder = (tree, context) => {
32
- const workingDirectory = (options.projectName && (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName]?.root) || '.';
33
- let gitIgnoreContent = '';
34
- const gitIgnorePath = path.posix.join(workingDirectory, '.gitignore');
35
- if (tree.exists(gitIgnorePath)) {
36
- gitIgnoreContent = tree.read(gitIgnorePath).toString();
37
- if (gitIgnoreContent.indexOf('/*.metadata.json')) {
38
- return tree;
39
- }
40
- tree.delete(gitIgnorePath);
28
+ const generateLocalesFolder = (tree) => {
29
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
30
+ const projectType = workspaceProject?.projectType || 'application';
31
+ if (projectType === 'library') {
32
+ return tree;
41
33
  }
42
- const templateSource = (0, schematics_1.apply)((0, schematics_1.url)((0, schematics_2.getTemplateFolder)(rootPath, __dirname)), [
43
- (0, schematics_1.template)({
44
- empty: '',
45
- devResourcesFolder,
46
- gitIgnoreContent,
47
- mainAssetsFolder
48
- }),
34
+ const workingDirectory = (options.projectName && (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName]?.root) || '.';
35
+ return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)((0, schematics_2.getTemplateFolder)(rootPath, __dirname)), [
36
+ (0, schematics_1.template)({ empty: '' }),
49
37
  (0, schematics_1.move)(workingDirectory)
50
- ]);
51
- const rule = (0, schematics_1.mergeWith)(templateSource, schematics_1.MergeStrategy.Overwrite);
52
- return rule(tree, context);
38
+ ]), schematics_1.MergeStrategy.Overwrite);
53
39
  };
54
40
  /**
55
41
  * Add translation generation builders into angular.json
@@ -68,7 +54,7 @@ function updateLocalization(options, rootPath) {
68
54
  (workspaceProject.architect.build.configurations && workspaceProject.architect.build.configurations.production && workspaceProject.architect.build.configurations.production.outputPath ||
69
55
  workspaceProject.architect.build.options.outputPath)) || './dist';
70
56
  // exit if not an application
71
- if (!workspace || !projectName || !workspaceProject) {
57
+ if (!workspace || !projectName || !workspaceProject || workspaceProject.projectType === 'library') {
72
58
  context.logger.debug('No application project found to add translation extraction');
73
59
  return tree;
74
60
  }
@@ -105,11 +91,12 @@ function updateLocalization(options, rootPath) {
105
91
  input: `${devResourcesFolder}/localizations`,
106
92
  output: '/localizations'
107
93
  };
108
- if (workspaceProject.architect.build) {
94
+ const projectType = workspaceProject?.projectType || 'application';
95
+ if (projectType === 'application' && workspaceProject.architect.build) {
109
96
  const alreadyExistingBuildOption = workspaceProject.architect.build.options?.assets?.map((a) => a.output).find((output) => output === '/localizations');
110
97
  if (!alreadyExistingBuildOption) {
111
98
  workspaceProject.architect.build.options ||= {};
112
- workspaceProject.architect.build ||= [];
99
+ workspaceProject.architect.build.options.assets ||= [];
113
100
  workspaceProject.architect.build.options.assets.push(localizationAssetsConfig);
114
101
  }
115
102
  }
@@ -151,7 +138,7 @@ function updateLocalization(options, rootPath) {
151
138
  const projectName = options.projectName;
152
139
  const workspaceProject = options.projectName ? workspace?.projects[options.projectName] : undefined;
153
140
  const packageManagerRunner = (0, schematics_2.getPackageManagerRunner)((0, schematics_2.getWorkspaceConfig)(tree));
154
- if (!projectName || !workspace || !workspaceProject) {
141
+ if (!projectName || !workspace || !workspaceProject || workspaceProject.projectType === 'library') {
155
142
  context.logger.debug('No application project found to add translation extraction');
156
143
  return tree;
157
144
  }
@@ -332,7 +319,13 @@ function updateLocalization(options, rootPath) {
332
319
  };
333
320
  // Ignore generated CMS metadata
334
321
  const ignoreDevResourcesFiles = (tree, _context) => {
335
- return (0, schematics_2.ignorePatterns)(tree, [{ description: 'Local Development resources files', patterns: ['/dev-resources'] }]);
322
+ const workingDirectory = (options.projectName && (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName]?.root) || '.';
323
+ return (0, schematics_1.applyToSubtree)(workingDirectory, [
324
+ (subTree) => (0, schematics_2.ignorePatterns)(subTree, [
325
+ { description: 'Local Development resources files', patterns: [`/${devResourcesFolder}`] },
326
+ { description: 'CMS metadata files', patterns: ['/*.metadata.json'] }
327
+ ])
328
+ ]);
336
329
  };
337
330
  return (0, schematics_1.chain)([
338
331
  registerModules,
@@ -1,7 +0,0 @@
1
- <%= gitIgnoreContent %>
2
-
3
- # Otter dev files
4
- /<%= devResourcesFolder %>
5
-
6
- # CMS adapters generated files
7
- /*.metadata.json