@steedos/metadata-core 3.0.7-beta.3 → 3.0.7
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.
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { BaseLoadMetadataFile } from "./_baseLoadFile";
|
|
2
|
+
interface TranslationFileInfo {
|
|
3
|
+
lang: string;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
}
|
|
2
6
|
export declare class LoadTranslationFile extends BaseLoadMetadataFile {
|
|
3
7
|
constructor();
|
|
4
|
-
|
|
5
|
-
load(filePath:
|
|
8
|
+
extractFileInfo(filePath: string): TranslationFileInfo | null;
|
|
9
|
+
load(filePath: string): any[];
|
|
6
10
|
}
|
|
11
|
+
export {};
|
|
@@ -8,40 +8,48 @@ const typeInfo_1 = require("../typeInfo");
|
|
|
8
8
|
const _baseLoadFile_1 = require("./_baseLoadFile");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const loadFile_1 = require("../loadFile");
|
|
11
|
-
const match_files_1 = require("
|
|
11
|
+
const match_files_1 = require("../util/match_files");
|
|
12
12
|
const lodash_1 = require("lodash");
|
|
13
13
|
class LoadTranslationFile extends _baseLoadFile_1.BaseLoadMetadataFile {
|
|
14
14
|
constructor() {
|
|
15
15
|
super(typeInfo_1.SteedosMetadataTypeInfoKeys.Page);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
extractFileInfo(filePath) {
|
|
18
18
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const filename = path_1.default.basename(filePath);
|
|
20
|
+
const regex = /^(?:(?<namespace>.+)\.)?(?<lang>[^.]+)\.translation\.yml$/;
|
|
21
|
+
const match = filename.match(regex);
|
|
22
|
+
if (match && match.groups) {
|
|
23
|
+
return {
|
|
24
|
+
lang: match.groups.lang,
|
|
25
|
+
namespace: match.groups.namespace,
|
|
26
|
+
};
|
|
26
27
|
}
|
|
27
|
-
console.
|
|
28
|
+
console.warn(`extractFileInfo warn: Invalid file format: ${filename}`);
|
|
29
|
+
return null;
|
|
28
30
|
}
|
|
29
31
|
catch (error) {
|
|
30
|
-
console.error(`
|
|
32
|
+
console.error(`extractFileInfo error: ${filePath}`, error);
|
|
33
|
+
return null;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
load(filePath) {
|
|
34
37
|
let results = [];
|
|
35
|
-
const
|
|
38
|
+
const filePattern = [
|
|
36
39
|
path_1.default.join(filePath, "*.translation.yml"),
|
|
37
40
|
"!" + path_1.default.join(filePath, "node_modules"),
|
|
38
41
|
];
|
|
39
|
-
const matchedPaths = (0, match_files_1.syncMatchFiles)(
|
|
42
|
+
const matchedPaths = (0, match_files_1.syncMatchFiles)(filePattern);
|
|
40
43
|
(0, lodash_1.each)(matchedPaths, (matchedPath) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
results.push({
|
|
44
|
+
const fileInfo = this.extractFileInfo(matchedPath);
|
|
45
|
+
if (fileInfo && fileInfo.lang) {
|
|
46
|
+
const json = (0, loadFile_1.loadFile)(matchedPath);
|
|
47
|
+
results.push({
|
|
48
|
+
lng: fileInfo.lang,
|
|
49
|
+
namespace: fileInfo.namespace,
|
|
50
|
+
__filename: matchedPath,
|
|
51
|
+
data: json,
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
});
|
|
47
55
|
return results;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTranslationFile.js","sourceRoot":"","sources":["../../src/load/loadTranslationFile.ts"],"names":[],"mappings":";;;;;;AAOA,0CAA0E;AAC1E,mDAAuD;AACvD,gDAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"loadTranslationFile.js","sourceRoot":"","sources":["../../src/load/loadTranslationFile.ts"],"names":[],"mappings":";;;;;;AAOA,0CAA0E;AAC1E,mDAAuD;AACvD,gDAAwB;AACxB,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I,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC9B,MAAM,IAAI,GAAG,IAAA,mBAAQ,EAAC,WAAW,CAAC,CAAC;gBACnC,OAAO,CAAC,IAAI,CAAC;oBACX,GAAG,EAAE,QAAQ,CAAC,IAAI;oBAClB,SAAS,EAAE,QAAQ,CAAC,SAAS;oBAC7B,UAAU,EAAE,WAAW;oBACvB,IAAI,EAAE,IAAI;iBACX,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA/DD,kDA+DC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/metadata-core",
|
|
3
|
-
"version": "3.0.7
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
-
"build": "rimraf lib && tsc"
|
|
12
|
+
"build": "npx rimraf lib && npx tsc"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@steedos/client": "3.0.7
|
|
15
|
+
"@steedos/client": "3.0.7",
|
|
16
16
|
"archiver": "^5.1.0",
|
|
17
17
|
"chalk": "^4.1.0",
|
|
18
18
|
"clone": "^2.1.2",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "313eb9122450ffaaa06b8d6c6f21795cc703b340"
|
|
42
42
|
}
|