@yuuvis/client-cli 19.3.0 → 19.3.1
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
|
@@ -91,7 +91,7 @@ function updatePackageJsonRule(projectName, shellVersion) {
|
|
|
91
91
|
'@yuuvis/client-shell': `^${shellVersion}`,
|
|
92
92
|
'@yuuvis/material': `^${shellVersion}`
|
|
93
93
|
}),
|
|
94
|
-
new package_json_1.
|
|
94
|
+
new package_json_1.AddDevDependenciesCommand({
|
|
95
95
|
'@colsen1991/ngx-translate-extract-marker': '^3',
|
|
96
96
|
'@vendure/ngx-translate-extract': '^9.4.0'
|
|
97
97
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schematics/factories/new/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAUA,gCAkCC;AA5CD,2DAAoF;AACpF,gEAAuC;AACvC,0EAAiD;AACjD,kFAAuD;AACvD,+CAAiG;AACjG,2DAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schematics/factories/new/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAUA,gCAkCC;AA5CD,2DAAoF;AACpF,gEAAuC;AACvC,0EAAiD;AACjD,kFAAuD;AACvD,+CAAiG;AACjG,2DAAyD;AACzD,8DAAmK;AACnK,8DAA+S;AAC/S,+DAA2D;AAE3D,SAAgB,UAAU,CAAC,OAAY;IACrC,OAAO,CAAO,IAAS,EAAE,OAAY,EAAE,EAAE;QACvC,OAAO,CAAC,iBAAiB,GAAG,iCAAqB,CAAC;QAClD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;QAEjC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC1B,OAAO,CAAC,YAAY,GAAG,iCAAqB,CAAC;QAC/C,CAAC;QAED,IAAI,4BAAgB,CAAC,QAAQ,CAA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BAAqB,EAAE,SAAS;gBAChC,qBAAqB,EAAE,IAAI,YAAY,EAAE;gBACzC,2BAA2B,EAAE,IAAI,YAAY,EAAE;gBAC/C,0BAA0B,EAAE,IAAI,YAAY,EAAE;gBAC9C,sBAAsB,EAAE,IAAI,YAAY,EAAE;gBAC1C,kBAAkB,EAAE,IAAI,YAAY,EAAE;aACvC,CAAC;YACF,IAAI,wCAAyB,CAAC;gBAC5B,0CAA0C,EAAE,IAAI;gBAChD,gCAAgC,EAAE,QAAQ;aAC3C,CAAC;YACF,IAAI,gCAAiB,CAAC;gBACpB,UAAU,EAAE,sBAAsB;gBAClC,OAAO,EAAE,qEAAqE;gBAC9E,UAAU,EAAE,sFAAsF;gBAClG,cAAc,EAAE,gCAAgC;gBAChD,cAAc,EAAE,gCAAgC;gBAChD,cAAc,EAAE,gCAAgC;aACjD,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,gCAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,WAAW,eAAe,CAAC,CAAC;QACnF,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEpB,OAAO,IAAI,CAAC;IACd,CAAC,CAAA,CAAC;AACJ,CAAC"}
|
|
@@ -1,59 +1,83 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
function traverseDirectory(currentPath, i18nFolders, excludeList) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return i18nFolders;
|
|
4
|
+
const entries = fs.readdirSync(currentPath);
|
|
5
|
+
entries.forEach((entry) => {
|
|
6
|
+
const entryPath = path.join(currentPath, entry);
|
|
7
|
+
const isDirectory = fs.statSync(entryPath).isDirectory();
|
|
8
|
+
if (isDirectory) {
|
|
9
|
+
if (entry === 'i18n' && !excludeList.some((exclude) => entryPath.includes(exclude))) {
|
|
10
|
+
i18nFolders.push(entryPath);
|
|
11
|
+
} else {
|
|
12
|
+
traverseDirectory(entryPath, i18nFolders, excludeList);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return i18nFolders;
|
|
18
17
|
}
|
|
19
18
|
function findI18nFolders(base, excludeList) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
let i18nFolders = [];
|
|
20
|
+
if (fs.existsSync(base)) {
|
|
21
|
+
i18nFolders = traverseDirectory(base, i18nFolders, excludeList);
|
|
22
|
+
}
|
|
23
|
+
return i18nFolders;
|
|
25
24
|
}
|
|
26
25
|
function groupFilesByLanguageCode(files) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
return files.reduce((acc, { dir, file }) => {
|
|
27
|
+
const match = file.match(/^([a-z]{2})\.json$/);
|
|
28
|
+
if (match) {
|
|
29
|
+
const lang = match[1];
|
|
30
|
+
if (!acc[lang])
|
|
31
|
+
acc[lang] = [];
|
|
32
|
+
acc[lang].push(path.join(dir, file));
|
|
33
|
+
}
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
37
36
|
}
|
|
38
|
-
async function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
const outputFilePath = path.join(outputDir, `${lang}.json`);
|
|
53
|
-
fs.writeFileSync(outputFilePath, JSON.stringify(mergedData, null, 2), 'utf-8');
|
|
54
|
-
console.log(`Merged ${lang} files into ${outputFilePath}`);
|
|
37
|
+
async function copyTo(directories, outputDir) {
|
|
38
|
+
const files = directories.flatMap((dir) => fs.readdirSync(dir).map((file) => ({ dir, file })));
|
|
39
|
+
// Group files by language code
|
|
40
|
+
const languageFiles = groupFilesByLanguageCode(files);
|
|
41
|
+
// Merge files for each language
|
|
42
|
+
for (const lang in languageFiles) {
|
|
43
|
+
const mergedData = languageFiles[lang].reduce((acc, filePath) => {
|
|
44
|
+
const data = fs.existsSync(filePath) ? JSON.parse(fs.readFileSync(filePath, 'utf-8')) : {};
|
|
45
|
+
return { ...acc, ...data };
|
|
46
|
+
}, {});
|
|
47
|
+
if (!fs.existsSync(outputDir)) {
|
|
48
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
55
49
|
}
|
|
50
|
+
const outputFilePath = path.join(outputDir, `${lang}.json`);
|
|
51
|
+
fs.writeFileSync(outputFilePath, JSON.stringify(mergedData, null, 2), 'utf-8');
|
|
52
|
+
console.log(`Merged ${lang} files into ${outputFilePath}`);
|
|
53
|
+
}
|
|
56
54
|
}
|
|
57
55
|
(() => {
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
const externalFolders = findI18nFolders('./node_modules/@yuuvis', ['schematics',]);
|
|
57
|
+
// copy external libs translations to i18n-external
|
|
58
|
+
const externalOutputDir = path.join('.', 'i18n-external');
|
|
59
|
+
copyTo(externalFolders, externalOutputDir).catch(console.error);
|
|
60
|
+
// merge all external translations with collected en.json to get all the keys
|
|
61
|
+
let refFile = path.join(externalOutputDir, 'en.json');
|
|
62
|
+
if (fs.existsSync(refFile)) {
|
|
63
|
+
const en = fs.readFileSync(refFile, { encoding: 'utf-8' });
|
|
64
|
+
const refKeys = Object.keys(JSON.parse(en));
|
|
65
|
+
fs.readdirSync(externalOutputDir)
|
|
66
|
+
.filter((file) => file !== 'en.json')
|
|
67
|
+
.forEach((file) => {
|
|
68
|
+
const langFilePath = path.join(externalOutputDir, file);
|
|
69
|
+
const srcLangfile = JSON.parse(fs.readFileSync(langFilePath, {
|
|
70
|
+
encoding: 'utf-8',
|
|
71
|
+
}));
|
|
72
|
+
const targetLangFile = {};
|
|
73
|
+
refKeys.forEach((k) => {
|
|
74
|
+
targetLangFile[k] = srcLangfile[k] || '';
|
|
75
|
+
});
|
|
76
|
+
fs.writeFileSync(langFilePath, JSON.stringify(targetLangFile, null, 2));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const outputDir = path.join('.', 'src', 'assets', '_yuuvis', 'i18n');
|
|
80
|
+
const localFolders = findI18nFolders('./projects', []);
|
|
81
|
+
const clientFolders = findI18nFolders('./src', ['assets/_yuuvis']);
|
|
82
|
+
copyTo([...localFolders, ...clientFolders, externalOutputDir], outputDir).catch(console.error);
|
|
83
|
+
})();
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
const { execSync } = require(
|
|
2
|
-
const { readFileSync } = require(
|
|
3
|
-
const { join } = require(
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const { readFileSync, existsSync } = require('fs');
|
|
3
|
+
const { join } = require('path');
|
|
4
4
|
function extractTranslations(suportedLangs) {
|
|
5
5
|
// read tsconfig to get the paths for all the libs/apps
|
|
6
|
-
const angualrJSON = JSON.parse(readFileSync(join(
|
|
6
|
+
const angualrJSON = JSON.parse(readFileSync(join('angular.json'), 'utf-8'));
|
|
7
7
|
const filteredPaths = Object.entries(angualrJSON.projects)
|
|
8
|
-
.filter(([, project]) => project.projectType ===
|
|
8
|
+
.filter(([, project]) => project.projectType === 'library')
|
|
9
9
|
.map((lib) => {
|
|
10
10
|
return lib[1].root;
|
|
11
11
|
});
|
|
12
|
-
|
|
13
|
-
filteredPaths.
|
|
14
|
-
|
|
12
|
+
const extensions = filteredPaths.map((p) => `${p}/extensions`).filter(p => existsSync(p));
|
|
13
|
+
const shared = filteredPaths.map((p) => `${p}/shared`).filter(p => existsSync(p));
|
|
14
|
+
const applicationPaths = Object.entries(angualrJSON.projects)
|
|
15
|
+
.filter(([, project]) => project.projectType === 'application')
|
|
16
|
+
.map((app) => {
|
|
17
|
+
return app[1].root;
|
|
18
|
+
});
|
|
19
|
+
console.log('extracting translations ...');
|
|
20
|
+
[...filteredPaths, ...extensions, ...shared, ...applicationPaths].forEach((p) => {
|
|
21
|
+
console.log('processing: ' + (p || './'));
|
|
15
22
|
const translationsPath =
|
|
16
|
-
process.platform ===
|
|
23
|
+
process.platform === 'win32'
|
|
17
24
|
? `./${p}/src/assets/i18n{${suportedLangs
|
|
18
25
|
.map((lang) => `/${lang}`)
|
|
19
|
-
.join(
|
|
26
|
+
.join(',')}}.json`
|
|
20
27
|
: `./${p}/src/assets/i18n/{${suportedLangs
|
|
21
28
|
.map((lang) => `${lang}`)
|
|
22
|
-
.join(
|
|
29
|
+
.join(',')}}.json`;
|
|
23
30
|
execSync(
|
|
24
31
|
`ngx-translate-extract --input ./${p}/src --output ${translationsPath} --sort --clean --format json`
|
|
25
32
|
);
|
|
@@ -28,16 +35,16 @@ function extractTranslations(suportedLangs) {
|
|
|
28
35
|
(() => {
|
|
29
36
|
const args = process.argv.slice(2);
|
|
30
37
|
const langArgIndex = args.findIndex(
|
|
31
|
-
(arg) => arg.startsWith(
|
|
38
|
+
(arg) => arg.startsWith('--lang=') || arg.startsWith('--lang ')
|
|
32
39
|
);
|
|
33
40
|
if (langArgIndex !== -1) {
|
|
34
41
|
const lang = args[langArgIndex]
|
|
35
|
-
.replace(
|
|
36
|
-
.replace(
|
|
42
|
+
.replace('--lang=', '')
|
|
43
|
+
.replace('--lang ', '');
|
|
37
44
|
lang.length > 0
|
|
38
|
-
? extractTranslations(lang.split(
|
|
39
|
-
: extractTranslations([
|
|
45
|
+
? extractTranslations(lang.split(','))
|
|
46
|
+
: extractTranslations(['en', 'de']);
|
|
40
47
|
} else {
|
|
41
|
-
extractTranslations([
|
|
48
|
+
extractTranslations(['en', 'de']);
|
|
42
49
|
}
|
|
43
50
|
})();
|