@o3r/localization 9.3.0-alpha.49 → 9.3.0-alpha.50
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 +6 -6
- package/schematics/cms-adapter/index.d.ts +0 -1
- package/schematics/cms-adapter/index.d.ts.map +1 -1
- package/schematics/cms-adapter/index.js +5 -9
- package/schematics/localization-base/index.d.ts +2 -1
- package/schematics/localization-base/index.d.ts.map +1 -1
- package/schematics/localization-base/index.js +18 -25
- package/schematics/ng-add/index.d.ts +0 -1
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/localization",
|
|
3
|
-
"version": "9.3.0-alpha.
|
|
3
|
+
"version": "9.3.0-alpha.50",
|
|
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.
|
|
24
|
-
"@o3r/dynamic-content": "^9.3.0-alpha.
|
|
25
|
-
"@o3r/extractors": "^9.3.0-alpha.
|
|
26
|
-
"@o3r/logger": "^9.3.0-alpha.
|
|
27
|
-
"@o3r/schematics": "^9.3.0-alpha.
|
|
23
|
+
"@o3r/core": "^9.3.0-alpha.50",
|
|
24
|
+
"@o3r/dynamic-content": "^9.3.0-alpha.50",
|
|
25
|
+
"@o3r/extractors": "^9.3.0-alpha.50",
|
|
26
|
+
"@o3r/logger": "^9.3.0-alpha.50",
|
|
27
|
+
"@o3r/schematics": "^9.3.0-alpha.50",
|
|
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,EAAe,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAKvF
|
|
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;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,IAAI,CAoEpF"}
|
|
@@ -6,7 +6,6 @@ const schematics_2 = require("@o3r/schematics");
|
|
|
6
6
|
const path = require("node:path");
|
|
7
7
|
/**
|
|
8
8
|
* Update CMS adapter tools
|
|
9
|
-
*
|
|
10
9
|
* @param options @see RuleFactory.options
|
|
11
10
|
* @param options.projectName
|
|
12
11
|
* @param rootPath @see RuleFactory.rootPath
|
|
@@ -17,15 +16,14 @@ function updateCmsAdapter(options) {
|
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
18
|
* Add cms extractors builder into the angular.json
|
|
20
|
-
*
|
|
21
19
|
* @param tree
|
|
22
20
|
* @param _context
|
|
23
21
|
* @param context
|
|
24
22
|
*/
|
|
25
23
|
const editAngularJson = (tree, context) => {
|
|
26
|
-
const workspace = (0, schematics_2.
|
|
27
|
-
const workspaceProject =
|
|
28
|
-
if (!workspaceProject) {
|
|
24
|
+
const workspace = (0, schematics_2.getWorkspaceConfig)(tree);
|
|
25
|
+
const workspaceProject = options.projectName ? workspace?.projects[options.projectName] : undefined;
|
|
26
|
+
if (!workspace || !workspaceProject) {
|
|
29
27
|
context.logger.error('No project detected, the extractors will not be added');
|
|
30
28
|
return tree;
|
|
31
29
|
}
|
|
@@ -39,20 +37,18 @@ function updateCmsAdapter(options) {
|
|
|
39
37
|
libraries: []
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
|
-
|
|
43
|
-
workspace.projects[name] = newProject;
|
|
40
|
+
workspace.projects[options.projectName] = workspaceProject;
|
|
44
41
|
tree.overwrite('/angular.json', JSON.stringify(workspace, null, 2));
|
|
45
42
|
return tree;
|
|
46
43
|
};
|
|
47
44
|
/**
|
|
48
45
|
* Add cms extractors scripts into the package.json
|
|
49
|
-
*
|
|
50
46
|
* @param tree
|
|
51
47
|
* @param _context
|
|
52
48
|
* @param context
|
|
53
49
|
*/
|
|
54
50
|
const addExtractorsScripts = (tree, context) => {
|
|
55
|
-
const workspaceProject = (0, schematics_2.
|
|
51
|
+
const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
|
|
56
52
|
if (!workspaceProject) {
|
|
57
53
|
context.logger.error('No package detected, the extractor scripts will not be added');
|
|
58
54
|
return tree;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Rule } from '@angular-devkit/schematics';
|
|
2
2
|
/**
|
|
3
3
|
* Add Otter localization support
|
|
4
|
-
*
|
|
5
4
|
* @param options @see RuleFactory.options
|
|
6
5
|
* @param options.projectName
|
|
7
6
|
* @param rootPath @see RuleFactory.rootPath
|
|
@@ -11,6 +10,8 @@ export declare function updateLocalization(options: {
|
|
|
11
10
|
}, rootPath: string): Rule;
|
|
12
11
|
/**
|
|
13
12
|
*
|
|
13
|
+
* @param options
|
|
14
|
+
* @param options.projectName
|
|
14
15
|
*/
|
|
15
16
|
export declare function updateI18n(options: {
|
|
16
17
|
projectName?: string | undefined;
|
|
@@ -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;
|
|
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,CA6a/G;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,GAAG,IAAI,CAwC5E"}
|
|
@@ -14,7 +14,6 @@ const formatjsIntlNumberformatDep = '@formatjs/intl-numberformat';
|
|
|
14
14
|
const angularCdkDep = '@angular/cdk';
|
|
15
15
|
/**
|
|
16
16
|
* Add Otter localization support
|
|
17
|
-
*
|
|
18
17
|
* @param options @see RuleFactory.options
|
|
19
18
|
* @param options.projectName
|
|
20
19
|
* @param rootPath @see RuleFactory.rootPath
|
|
@@ -27,12 +26,11 @@ function updateLocalization(options, rootPath) {
|
|
|
27
26
|
const devResourcesFolder = 'dev-resources';
|
|
28
27
|
/**
|
|
29
28
|
* Generate locales folder
|
|
30
|
-
*
|
|
31
29
|
* @param tree
|
|
32
30
|
* @param context
|
|
33
31
|
*/
|
|
34
32
|
const generateLocalesFolder = (tree, context) => {
|
|
35
|
-
const workingDirectory = (0, schematics_2.
|
|
33
|
+
const workingDirectory = (options.projectName && (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName]?.root) || '.';
|
|
36
34
|
let gitIgnoreContent = '';
|
|
37
35
|
const gitIgnorePath = path.posix.join(workingDirectory, '.gitignore');
|
|
38
36
|
if (tree.exists(gitIgnorePath)) {
|
|
@@ -56,14 +54,13 @@ function updateLocalization(options, rootPath) {
|
|
|
56
54
|
};
|
|
57
55
|
/**
|
|
58
56
|
* Add translation generation builders into angular.json
|
|
59
|
-
*
|
|
60
57
|
* @param tree
|
|
61
58
|
* @param context
|
|
62
59
|
*/
|
|
63
60
|
const updateAngularJson = (tree, context) => {
|
|
64
|
-
const workspace = (0, schematics_2.
|
|
65
|
-
const projectName = options.projectName
|
|
66
|
-
const workspaceProject =
|
|
61
|
+
const workspace = (0, schematics_2.getWorkspaceConfig)(tree);
|
|
62
|
+
const projectName = options.projectName;
|
|
63
|
+
const workspaceProject = options.projectName ? workspace?.projects[options.projectName] : undefined;
|
|
67
64
|
const projectRoot = path.posix.join(workspaceProject?.root || '');
|
|
68
65
|
const distFolder = (workspaceProject &&
|
|
69
66
|
workspaceProject.architect &&
|
|
@@ -72,7 +69,7 @@ function updateLocalization(options, rootPath) {
|
|
|
72
69
|
(workspaceProject.architect.build.configurations && workspaceProject.architect.build.configurations.production && workspaceProject.architect.build.configurations.production.outputPath ||
|
|
73
70
|
workspaceProject.architect.build.options.outputPath)) || './dist';
|
|
74
71
|
// exit if not an application
|
|
75
|
-
if (!workspaceProject) {
|
|
72
|
+
if (!workspace || !projectName || !workspaceProject) {
|
|
76
73
|
context.logger.debug('No application project found to add translation extraction');
|
|
77
74
|
return tree;
|
|
78
75
|
}
|
|
@@ -167,16 +164,15 @@ function updateLocalization(options, rootPath) {
|
|
|
167
164
|
};
|
|
168
165
|
/**
|
|
169
166
|
* Changed package.json start script to run localization generation
|
|
170
|
-
*
|
|
171
167
|
* @param tree
|
|
172
168
|
* @param context
|
|
173
169
|
*/
|
|
174
170
|
const updatePackageJson = (tree, context) => {
|
|
175
|
-
const workspace = (0, schematics_2.
|
|
176
|
-
const projectName = options.projectName
|
|
177
|
-
const workspaceProject =
|
|
171
|
+
const workspace = (0, schematics_2.getWorkspaceConfig)(tree);
|
|
172
|
+
const projectName = options.projectName;
|
|
173
|
+
const workspaceProject = options.projectName ? workspace?.projects[options.projectName] : undefined;
|
|
178
174
|
const packageManagerRunner = (0, schematics_2.getPackageManagerRunner)((0, schematics_2.getWorkspaceConfig)(tree));
|
|
179
|
-
if (!workspaceProject) {
|
|
175
|
+
if (!projectName || !workspace || !workspaceProject) {
|
|
180
176
|
context.logger.debug('No application project found to add translation extraction');
|
|
181
177
|
return tree;
|
|
182
178
|
}
|
|
@@ -198,7 +194,6 @@ function updateLocalization(options, rootPath) {
|
|
|
198
194
|
};
|
|
199
195
|
/**
|
|
200
196
|
* Edit main module with the translation required configuration
|
|
201
|
-
*
|
|
202
197
|
* @param tree
|
|
203
198
|
* @param context
|
|
204
199
|
*/
|
|
@@ -252,7 +247,6 @@ function updateLocalization(options, rootPath) {
|
|
|
252
247
|
};
|
|
253
248
|
/**
|
|
254
249
|
* Set language as default on application bootstrap
|
|
255
|
-
*
|
|
256
250
|
* @param tree
|
|
257
251
|
* @param context
|
|
258
252
|
*/
|
|
@@ -302,7 +296,6 @@ function updateLocalization(options, rootPath) {
|
|
|
302
296
|
};
|
|
303
297
|
/**
|
|
304
298
|
* Add mockTranslationModule to application tests.
|
|
305
|
-
*
|
|
306
299
|
* @param tree
|
|
307
300
|
* @param context
|
|
308
301
|
*/
|
|
@@ -335,15 +328,15 @@ function updateLocalization(options, rootPath) {
|
|
|
335
328
|
};
|
|
336
329
|
/**
|
|
337
330
|
* Add location required dependencies
|
|
338
|
-
*
|
|
339
331
|
* @param tree
|
|
340
332
|
* @param _context
|
|
341
333
|
* @param context
|
|
342
334
|
*/
|
|
343
335
|
const addDependencies = (tree, context) => {
|
|
344
|
-
const
|
|
336
|
+
const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
|
|
337
|
+
const workingDirectory = workspaceProject?.root || '.';
|
|
338
|
+
const type = (0, schematics_2.getProjectNewDependenciesType)(workspaceProject);
|
|
345
339
|
const generatorDependencies = [ngxTranslateCoreDep, intlMessageFormatDep, formatjsIntlNumberformatDep, angularCdkDep];
|
|
346
|
-
const workingDirectory = (0, schematics_2.getProjectRootDir)(tree, options.projectName);
|
|
347
340
|
try {
|
|
348
341
|
return (0, schematics_2.ngAddPeerDependencyPackages)(generatorDependencies, packageJsonPath, type, { ...options, workingDirectory, skipNgAddSchematicRun: true })(tree, context);
|
|
349
342
|
}
|
|
@@ -370,6 +363,8 @@ function updateLocalization(options, rootPath) {
|
|
|
370
363
|
exports.updateLocalization = updateLocalization;
|
|
371
364
|
/**
|
|
372
365
|
*
|
|
366
|
+
* @param options
|
|
367
|
+
* @param options.projectName
|
|
373
368
|
*/
|
|
374
369
|
function updateI18n(options) {
|
|
375
370
|
if (!options.projectName) {
|
|
@@ -377,13 +372,12 @@ function updateI18n(options) {
|
|
|
377
372
|
}
|
|
378
373
|
/**
|
|
379
374
|
* Add i18n generation builders into angular.json
|
|
380
|
-
*
|
|
381
375
|
* @param tree
|
|
382
376
|
*/
|
|
383
377
|
const updateAngularJson = (tree) => {
|
|
384
|
-
const workspace = (0, schematics_2.
|
|
385
|
-
const workspaceProject =
|
|
386
|
-
if (!workspaceProject) {
|
|
378
|
+
const workspace = (0, schematics_2.getWorkspaceConfig)(tree);
|
|
379
|
+
const workspaceProject = options.projectName ? workspace?.projects[options.projectName] : undefined;
|
|
380
|
+
if (!workspace || !workspaceProject) {
|
|
387
381
|
return tree;
|
|
388
382
|
}
|
|
389
383
|
if (!workspaceProject.architect) {
|
|
@@ -401,8 +395,7 @@ function updateI18n(options) {
|
|
|
401
395
|
}
|
|
402
396
|
};
|
|
403
397
|
}
|
|
404
|
-
|
|
405
|
-
workspace.projects[name] = newProject;
|
|
398
|
+
workspace.projects[options.projectName] = workspaceProject;
|
|
406
399
|
return (0, schematics_2.writeAngularJson)(tree, workspace);
|
|
407
400
|
};
|
|
408
401
|
return (0, schematics_1.chain)([
|
|
@@ -2,7 +2,6 @@ import { Rule } from '@angular-devkit/schematics';
|
|
|
2
2
|
import type { NgAddSchematicsSchema } from './schema';
|
|
3
3
|
/**
|
|
4
4
|
* Add Otter localization to an Angular Project
|
|
5
|
-
*
|
|
6
5
|
* @param options for the dependencies installations
|
|
7
6
|
*/
|
|
8
7
|
export declare function ngAdd(options: NgAddSchematicsSchema): Rule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAKvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAKvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAoD1D"}
|
|
@@ -8,13 +8,12 @@ const schematics_2 = require("@o3r/schematics");
|
|
|
8
8
|
const cms_adapter_1 = require("../cms-adapter");
|
|
9
9
|
/**
|
|
10
10
|
* Add Otter localization to an Angular Project
|
|
11
|
-
*
|
|
12
11
|
* @param options for the dependencies installations
|
|
13
12
|
*/
|
|
14
13
|
function ngAdd(options) {
|
|
15
14
|
return async (tree, context) => {
|
|
16
15
|
try {
|
|
17
|
-
const { applyEsLintFix, install,
|
|
16
|
+
const { applyEsLintFix, install, getProjectNewDependenciesType, getWorkspaceConfig, ngAddPackages, ngAddPeerDependencyPackages, getO3rPeerDeps } = await Promise.resolve().then(() => require('@o3r/schematics'));
|
|
18
17
|
const { updateI18n, updateLocalization } = await Promise.resolve().then(() => require('../localization-base'));
|
|
19
18
|
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
|
|
20
19
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
|
|
@@ -23,7 +22,9 @@ function ngAdd(options) {
|
|
|
23
22
|
context.logger.info('Get information on https://github.com/AmadeusITGroup/otter/tree/main/docs/localization/LOCALIZATION.md#Debugging');
|
|
24
23
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
24
|
const { NodeDependencyType } = await Promise.resolve().then(() => require('@schematics/angular/utility/dependencies'));
|
|
26
|
-
const
|
|
25
|
+
const workspaceProject = options.projectName ? getWorkspaceConfig(tree)?.projects[options.projectName] : undefined;
|
|
26
|
+
const workingDirectory = workspaceProject?.root || '.';
|
|
27
|
+
const dependencyType = getProjectNewDependenciesType(workspaceProject);
|
|
27
28
|
return () => (0, schematics_1.chain)([
|
|
28
29
|
updateLocalization(options, __dirname),
|
|
29
30
|
updateI18n(options),
|
|
@@ -35,7 +36,7 @@ function ngAdd(options) {
|
|
|
35
36
|
version: depsInfo.packageVersion,
|
|
36
37
|
parentPackageInfo: `${depsInfo.packageName} - setup`,
|
|
37
38
|
projectName: options.projectName,
|
|
38
|
-
dependencyType
|
|
39
|
+
dependencyType,
|
|
39
40
|
workingDirectory
|
|
40
41
|
})(t, c),
|
|
41
42
|
ngAddPeerDependencyPackages(['chokidar'], packageJsonPath, NodeDependencyType.Dev, { ...options, workingDirectory, skipNgAddSchematicRun: true }, '@o3r/localization - install builder dependency'),
|