@beinformed/ui 1.34.0 → 1.34.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/CHANGELOG.md +7 -0
- package/esm/builder/mergeLayoutHintConfigurations.js +29 -28
- package/esm/builder/mergeLayoutHintConfigurations.js.map +1 -1
- package/lib/builder/__tests__/mergeLayoutHintConfigurations.spec.js.flow +24 -17
- package/lib/builder/mergeLayoutHintConfigurations.js +29 -28
- package/lib/builder/mergeLayoutHintConfigurations.js.flow +33 -37
- package/lib/builder/mergeLayoutHintConfigurations.js.map +1 -1
- package/package.json +1 -2
- package/src/builder/__tests__/LayoutHintConfig.json +11 -0
- package/src/builder/__tests__/mergeLayoutHintConfigurations.spec.js +24 -17
- package/src/builder/__tests__/subdir/LayoutHintConfig.json +11 -0
- package/src/builder/mergeLayoutHintConfigurations.js +33 -37
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.34.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.34.0...v1.34.1) (2023-09-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **layout-hint-json:** replace glob with node packages ([c25b89f](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/c25b89f811a934cf2ce57254e5d06a574b674561))
|
|
11
|
+
|
|
5
12
|
## [1.34.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.33.0...v1.34.0) (2023-09-13)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
2
|
-
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
3
2
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
4
3
|
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
5
|
-
|
|
6
|
-
const fs = require("fs");
|
|
4
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
7
5
|
const path = require("path");
|
|
6
|
+
const {
|
|
7
|
+
readdirSync,
|
|
8
|
+
statSync,
|
|
9
|
+
readFileSync,
|
|
10
|
+
writeFileSync
|
|
11
|
+
} = require("fs");
|
|
8
12
|
const {
|
|
9
13
|
LayoutHintConfiguration
|
|
10
14
|
} = require("../constants/LayoutHintConfig");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const findFiles = dir => {
|
|
16
|
+
const matchedFiles = [];
|
|
17
|
+
const files = readdirSync(dir);
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
const absolute = path.join(dir, file);
|
|
20
|
+
if (statSync(absolute).isDirectory()) {
|
|
21
|
+
const foundFiles = findFiles(absolute);
|
|
22
|
+
matchedFiles.push(...foundFiles);
|
|
23
|
+
} else {
|
|
24
|
+
const filename = path.basename(file);
|
|
25
|
+
if (filename === "LayoutHintConfig.json") {
|
|
26
|
+
matchedFiles.push(absolute);
|
|
18
27
|
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return matchedFiles;
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
/**
|
|
@@ -28,21 +37,13 @@ const readFiles = files => {
|
|
|
28
37
|
*/
|
|
29
38
|
exports.mergeLayoutHintConfigurations = async (srcFolder, outputFolder) => {
|
|
30
39
|
const escapedSrcFolder = srcFolder.replace(/\\/g, "/");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
readFiles(files).then(jsons => {
|
|
37
|
-
const newConfig = _Object$assign(LayoutHintConfiguration, ...jsons);
|
|
38
|
-
fs.writeFile(path.join(outputFolder, "LayoutHintConfig.json"), _JSON$stringify(newConfig), writeErr => {
|
|
39
|
-
if (writeErr) {
|
|
40
|
-
return reject(writeErr);
|
|
41
|
-
}
|
|
42
|
-
return resolve();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
40
|
+
const files = findFiles(escapedSrcFolder);
|
|
41
|
+
const jsons = _mapInstanceProperty(files).call(files, file => {
|
|
42
|
+
const content = readFileSync(file, "utf-8");
|
|
43
|
+
return JSON.parse(content);
|
|
46
44
|
});
|
|
45
|
+
const newConfig = _Object$assign(LayoutHintConfiguration, ...jsons);
|
|
46
|
+
writeFileSync(path.join(outputFolder, "LayoutHintConfig.json"), _JSON$stringify(newConfig));
|
|
47
|
+
return _Promise.resolve();
|
|
47
48
|
};
|
|
48
49
|
//# sourceMappingURL=mergeLayoutHintConfigurations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeLayoutHintConfigurations.js","names":["
|
|
1
|
+
{"version":3,"file":"mergeLayoutHintConfigurations.js","names":["path","require","readdirSync","statSync","readFileSync","writeFileSync","LayoutHintConfiguration","findFiles","dir","matchedFiles","files","file","absolute","join","isDirectory","foundFiles","push","filename","basename","exports","mergeLayoutHintConfigurations","srcFolder","outputFolder","escapedSrcFolder","replace","jsons","_mapInstanceProperty","call","content","JSON","parse","newConfig","_Object$assign","_JSON$stringify","_Promise","resolve"],"sources":["../../src/builder/mergeLayoutHintConfigurations.js"],"sourcesContent":["// @flow\nconst path = require(\"path\");\nconst { readdirSync, statSync, readFileSync, writeFileSync } = require(\"fs\");\n\nconst { LayoutHintConfiguration } = require(\"../constants/LayoutHintConfig\");\n\nconst findFiles = (dir: string): Array<string> => {\n const matchedFiles = [];\n\n const files = readdirSync(dir);\n\n for (const file of files) {\n const absolute = path.join(dir, file);\n if (statSync(absolute).isDirectory()) {\n const foundFiles = findFiles(absolute);\n matchedFiles.push(...foundFiles);\n } else {\n const filename = path.basename(file);\n if (filename === \"LayoutHintConfig.json\") {\n matchedFiles.push(absolute);\n }\n }\n }\n\n return matchedFiles;\n};\n\n/**\n * Merge all LayoutHintConfig.json files from this library and in the srcFolder\n * together into one config file, and copies it to the outputFolder.<br/>\n * This file is consumed by Be Informed studio to give layout hint information\n */\nexports.mergeLayoutHintConfigurations = async (\n srcFolder: string,\n outputFolder: string,\n): Promise<void> => {\n const escapedSrcFolder = srcFolder.replace(/\\\\/g, \"/\");\n\n const files = findFiles(escapedSrcFolder);\n\n const jsons = files.map((file) => {\n const content = readFileSync(file, \"utf-8\");\n return JSON.parse(content);\n });\n\n const newConfig = Object.assign(LayoutHintConfiguration, ...jsons);\n\n writeFileSync(\n path.join(outputFolder, \"LayoutHintConfig.json\"),\n JSON.stringify(newConfig),\n );\n\n return Promise.resolve();\n};\n"],"mappings":";;;;AACA,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAM;EAAEC,WAAW;EAAEC,QAAQ;EAAEC,YAAY;EAAEC;AAAc,CAAC,GAAGJ,OAAO,CAAC,IAAI,CAAC;AAE5E,MAAM;EAAEK;AAAwB,CAAC,GAAGL,OAAO,CAAC,+BAA+B,CAAC;AAE5E,MAAMM,SAAS,GAAIC,GAAW,IAAoB;EAChD,MAAMC,YAAY,GAAG,EAAE;EAEvB,MAAMC,KAAK,GAAGR,WAAW,CAACM,GAAG,CAAC;EAE9B,KAAK,MAAMG,IAAI,IAAID,KAAK,EAAE;IACxB,MAAME,QAAQ,GAAGZ,IAAI,CAACa,IAAI,CAACL,GAAG,EAAEG,IAAI,CAAC;IACrC,IAAIR,QAAQ,CAACS,QAAQ,CAAC,CAACE,WAAW,CAAC,CAAC,EAAE;MACpC,MAAMC,UAAU,GAAGR,SAAS,CAACK,QAAQ,CAAC;MACtCH,YAAY,CAACO,IAAI,CAAC,GAAGD,UAAU,CAAC;IAClC,CAAC,MAAM;MACL,MAAME,QAAQ,GAAGjB,IAAI,CAACkB,QAAQ,CAACP,IAAI,CAAC;MACpC,IAAIM,QAAQ,KAAK,uBAAuB,EAAE;QACxCR,YAAY,CAACO,IAAI,CAACJ,QAAQ,CAAC;MAC7B;IACF;EACF;EAEA,OAAOH,YAAY;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACAU,OAAO,CAACC,6BAA6B,GAAG,OACtCC,SAAiB,EACjBC,YAAoB,KACF;EAClB,MAAMC,gBAAgB,GAAGF,SAAS,CAACG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EAEtD,MAAMd,KAAK,GAAGH,SAAS,CAACgB,gBAAgB,CAAC;EAEzC,MAAME,KAAK,GAAGC,oBAAA,CAAAhB,KAAK,EAAAiB,IAAA,CAALjB,KAAK,EAAMC,IAAI,IAAK;IAChC,MAAMiB,OAAO,GAAGxB,YAAY,CAACO,IAAI,EAAE,OAAO,CAAC;IAC3C,OAAOkB,IAAI,CAACC,KAAK,CAACF,OAAO,CAAC;EAC5B,CAAC,CAAC;EAEF,MAAMG,SAAS,GAAGC,cAAA,CAAc1B,uBAAuB,EAAE,GAAGmB,KAAK,CAAC;EAElEpB,aAAa,CACXL,IAAI,CAACa,IAAI,CAACS,YAAY,EAAE,uBAAuB,CAAC,EAChDW,eAAA,CAAeF,SAAS,CAC1B,CAAC;EAED,OAAOG,QAAA,CAAQC,OAAO,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mergeLayoutHintConfigurations } from "../mergeLayoutHintConfigurations";
|
|
2
2
|
import { LayoutHintConfiguration } from "../../constants/LayoutHintConfig";
|
|
3
3
|
const fs = require("fs");
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
//
|
|
5
|
+
const projectJson1 = {
|
|
6
6
|
MOCK: {
|
|
7
7
|
hint: "mock",
|
|
8
8
|
description: {
|
|
@@ -14,31 +14,38 @@ const projectJson = {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
const projectJson2 = {
|
|
18
|
+
MOCK2: {
|
|
19
|
+
hint: "mock2",
|
|
20
|
+
description: {
|
|
21
|
+
NL: "mock2 dutch description",
|
|
22
|
+
EN: "mock2 english description",
|
|
23
|
+
},
|
|
24
|
+
link: "",
|
|
25
|
+
component: ["attribute"],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
17
29
|
jest.mock("fs", () => ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
),
|
|
21
|
-
writeFile: jest.fn((path, options, callback) => callback(null)),
|
|
30
|
+
...jest.requireActual("fs"),
|
|
31
|
+
writeFileSync: jest.fn(),
|
|
22
32
|
}));
|
|
23
33
|
|
|
24
|
-
jest.mock("glob", () =>
|
|
25
|
-
jest.fn((pattern, options, callback) =>
|
|
26
|
-
callback(null, ["/input/LayoutHintConfig.json"]),
|
|
27
|
-
),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
34
|
describe("mergeLayoutHintConfigurations", () => {
|
|
31
35
|
it("generates layouthint.json", async () => {
|
|
32
36
|
expect.assertions(1);
|
|
33
37
|
|
|
34
|
-
const expectedJson = {
|
|
38
|
+
const expectedJson = {
|
|
39
|
+
...LayoutHintConfiguration,
|
|
40
|
+
...projectJson1,
|
|
41
|
+
...projectJson2,
|
|
42
|
+
};
|
|
35
43
|
|
|
36
|
-
await mergeLayoutHintConfigurations("
|
|
44
|
+
await mergeLayoutHintConfigurations("./src", "/output");
|
|
37
45
|
|
|
38
|
-
expect(fs.
|
|
39
|
-
|
|
46
|
+
expect(fs.writeFileSync).toHaveBeenCalledWith(
|
|
47
|
+
"\\output\\LayoutHintConfig.json",
|
|
40
48
|
JSON.stringify(expectedJson),
|
|
41
|
-
expect.anything(),
|
|
42
49
|
);
|
|
43
50
|
});
|
|
44
51
|
});
|
|
@@ -2,26 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
4
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
5
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
6
5
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
7
6
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
8
|
-
|
|
9
|
-
const fs = require("fs");
|
|
7
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
10
8
|
const path = require("path");
|
|
9
|
+
const {
|
|
10
|
+
readdirSync,
|
|
11
|
+
statSync,
|
|
12
|
+
readFileSync,
|
|
13
|
+
writeFileSync
|
|
14
|
+
} = require("fs");
|
|
11
15
|
const {
|
|
12
16
|
LayoutHintConfiguration
|
|
13
17
|
} = require("../constants/LayoutHintConfig");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const findFiles = dir => {
|
|
19
|
+
const matchedFiles = [];
|
|
20
|
+
const files = readdirSync(dir);
|
|
21
|
+
for (const file of files) {
|
|
22
|
+
const absolute = path.join(dir, file);
|
|
23
|
+
if (statSync(absolute).isDirectory()) {
|
|
24
|
+
const foundFiles = findFiles(absolute);
|
|
25
|
+
matchedFiles.push(...foundFiles);
|
|
26
|
+
} else {
|
|
27
|
+
const filename = path.basename(file);
|
|
28
|
+
if (filename === "LayoutHintConfig.json") {
|
|
29
|
+
matchedFiles.push(absolute);
|
|
21
30
|
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return matchedFiles;
|
|
25
34
|
};
|
|
26
35
|
|
|
27
36
|
/**
|
|
@@ -31,21 +40,13 @@ const readFiles = files => {
|
|
|
31
40
|
*/
|
|
32
41
|
exports.mergeLayoutHintConfigurations = async (srcFolder, outputFolder) => {
|
|
33
42
|
const escapedSrcFolder = srcFolder.replace(/\\/g, "/");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
readFiles(files).then(jsons => {
|
|
40
|
-
const newConfig = (0, _assign.default)(LayoutHintConfiguration, ...jsons);
|
|
41
|
-
fs.writeFile(path.join(outputFolder, "LayoutHintConfig.json"), (0, _stringify.default)(newConfig), writeErr => {
|
|
42
|
-
if (writeErr) {
|
|
43
|
-
return reject(writeErr);
|
|
44
|
-
}
|
|
45
|
-
return resolve();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
});
|
|
43
|
+
const files = findFiles(escapedSrcFolder);
|
|
44
|
+
const jsons = (0, _map.default)(files).call(files, file => {
|
|
45
|
+
const content = readFileSync(file, "utf-8");
|
|
46
|
+
return JSON.parse(content);
|
|
49
47
|
});
|
|
48
|
+
const newConfig = (0, _assign.default)(LayoutHintConfiguration, ...jsons);
|
|
49
|
+
writeFileSync(path.join(outputFolder, "LayoutHintConfig.json"), (0, _stringify.default)(newConfig));
|
|
50
|
+
return _promise.default.resolve();
|
|
50
51
|
};
|
|
51
52
|
//# sourceMappingURL=mergeLayoutHintConfigurations.js.map
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
const glob = require("glob");
|
|
3
|
-
const fs = require("fs");
|
|
4
2
|
const path = require("path");
|
|
3
|
+
const { readdirSync, statSync, readFileSync, writeFileSync } = require("fs");
|
|
5
4
|
|
|
6
5
|
const { LayoutHintConfiguration } = require("../constants/LayoutHintConfig");
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fs.readFile(file, "utf-8", (err, data) => {
|
|
13
|
-
if (err) {
|
|
14
|
-
return reject(err);
|
|
15
|
-
} else {
|
|
16
|
-
return resolve(JSON.parse(data));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}),
|
|
20
|
-
);
|
|
7
|
+
const findFiles = (dir: string): Array<string> => {
|
|
8
|
+
const matchedFiles = [];
|
|
9
|
+
|
|
10
|
+
const files = readdirSync(dir);
|
|
21
11
|
|
|
22
|
-
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
const absolute = path.join(dir, file);
|
|
14
|
+
if (statSync(absolute).isDirectory()) {
|
|
15
|
+
const foundFiles = findFiles(absolute);
|
|
16
|
+
matchedFiles.push(...foundFiles);
|
|
17
|
+
} else {
|
|
18
|
+
const filename = path.basename(file);
|
|
19
|
+
if (filename === "LayoutHintConfig.json") {
|
|
20
|
+
matchedFiles.push(absolute);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return matchedFiles;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -32,27 +35,20 @@ exports.mergeLayoutHintConfigurations = async (
|
|
|
32
35
|
outputFolder: string,
|
|
33
36
|
): Promise<void> => {
|
|
34
37
|
const escapedSrcFolder = srcFolder.replace(/\\/g, "/");
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
glob(escapedSrcFolder + "/**/LayoutHintConfig.json", {}, (err, files) => {
|
|
37
|
-
if (err) {
|
|
38
|
-
return reject(err);
|
|
39
|
-
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(writeErr) => {
|
|
48
|
-
if (writeErr) {
|
|
49
|
-
return reject(writeErr);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return resolve();
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
39
|
+
const files = findFiles(escapedSrcFolder);
|
|
40
|
+
|
|
41
|
+
const jsons = files.map((file) => {
|
|
42
|
+
const content = readFileSync(file, "utf-8");
|
|
43
|
+
return JSON.parse(content);
|
|
57
44
|
});
|
|
45
|
+
|
|
46
|
+
const newConfig = Object.assign(LayoutHintConfiguration, ...jsons);
|
|
47
|
+
|
|
48
|
+
writeFileSync(
|
|
49
|
+
path.join(outputFolder, "LayoutHintConfig.json"),
|
|
50
|
+
JSON.stringify(newConfig),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return Promise.resolve();
|
|
58
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeLayoutHintConfigurations.js","names":["
|
|
1
|
+
{"version":3,"file":"mergeLayoutHintConfigurations.js","names":["path","require","readdirSync","statSync","readFileSync","writeFileSync","LayoutHintConfiguration","findFiles","dir","matchedFiles","files","file","absolute","join","isDirectory","foundFiles","push","filename","basename","exports","mergeLayoutHintConfigurations","srcFolder","outputFolder","escapedSrcFolder","replace","jsons","_map","default","call","content","JSON","parse","newConfig","_assign","_stringify","_promise","resolve"],"sources":["../../src/builder/mergeLayoutHintConfigurations.js"],"sourcesContent":["// @flow\nconst path = require(\"path\");\nconst { readdirSync, statSync, readFileSync, writeFileSync } = require(\"fs\");\n\nconst { LayoutHintConfiguration } = require(\"../constants/LayoutHintConfig\");\n\nconst findFiles = (dir: string): Array<string> => {\n const matchedFiles = [];\n\n const files = readdirSync(dir);\n\n for (const file of files) {\n const absolute = path.join(dir, file);\n if (statSync(absolute).isDirectory()) {\n const foundFiles = findFiles(absolute);\n matchedFiles.push(...foundFiles);\n } else {\n const filename = path.basename(file);\n if (filename === \"LayoutHintConfig.json\") {\n matchedFiles.push(absolute);\n }\n }\n }\n\n return matchedFiles;\n};\n\n/**\n * Merge all LayoutHintConfig.json files from this library and in the srcFolder\n * together into one config file, and copies it to the outputFolder.<br/>\n * This file is consumed by Be Informed studio to give layout hint information\n */\nexports.mergeLayoutHintConfigurations = async (\n srcFolder: string,\n outputFolder: string,\n): Promise<void> => {\n const escapedSrcFolder = srcFolder.replace(/\\\\/g, \"/\");\n\n const files = findFiles(escapedSrcFolder);\n\n const jsons = files.map((file) => {\n const content = readFileSync(file, \"utf-8\");\n return JSON.parse(content);\n });\n\n const newConfig = Object.assign(LayoutHintConfiguration, ...jsons);\n\n writeFileSync(\n path.join(outputFolder, \"LayoutHintConfig.json\"),\n JSON.stringify(newConfig),\n );\n\n return Promise.resolve();\n};\n"],"mappings":";;;;;;;AACA,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAM;EAAEC,WAAW;EAAEC,QAAQ;EAAEC,YAAY;EAAEC;AAAc,CAAC,GAAGJ,OAAO,CAAC,IAAI,CAAC;AAE5E,MAAM;EAAEK;AAAwB,CAAC,GAAGL,OAAO,CAAC,+BAA+B,CAAC;AAE5E,MAAMM,SAAS,GAAIC,GAAW,IAAoB;EAChD,MAAMC,YAAY,GAAG,EAAE;EAEvB,MAAMC,KAAK,GAAGR,WAAW,CAACM,GAAG,CAAC;EAE9B,KAAK,MAAMG,IAAI,IAAID,KAAK,EAAE;IACxB,MAAME,QAAQ,GAAGZ,IAAI,CAACa,IAAI,CAACL,GAAG,EAAEG,IAAI,CAAC;IACrC,IAAIR,QAAQ,CAACS,QAAQ,CAAC,CAACE,WAAW,CAAC,CAAC,EAAE;MACpC,MAAMC,UAAU,GAAGR,SAAS,CAACK,QAAQ,CAAC;MACtCH,YAAY,CAACO,IAAI,CAAC,GAAGD,UAAU,CAAC;IAClC,CAAC,MAAM;MACL,MAAME,QAAQ,GAAGjB,IAAI,CAACkB,QAAQ,CAACP,IAAI,CAAC;MACpC,IAAIM,QAAQ,KAAK,uBAAuB,EAAE;QACxCR,YAAY,CAACO,IAAI,CAACJ,QAAQ,CAAC;MAC7B;IACF;EACF;EAEA,OAAOH,YAAY;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACAU,OAAO,CAACC,6BAA6B,GAAG,OACtCC,SAAiB,EACjBC,YAAoB,KACF;EAClB,MAAMC,gBAAgB,GAAGF,SAAS,CAACG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EAEtD,MAAMd,KAAK,GAAGH,SAAS,CAACgB,gBAAgB,CAAC;EAEzC,MAAME,KAAK,GAAG,IAAAC,IAAA,CAAAC,OAAA,EAAAjB,KAAK,EAAAkB,IAAA,CAALlB,KAAK,EAAMC,IAAI,IAAK;IAChC,MAAMkB,OAAO,GAAGzB,YAAY,CAACO,IAAI,EAAE,OAAO,CAAC;IAC3C,OAAOmB,IAAI,CAACC,KAAK,CAACF,OAAO,CAAC;EAC5B,CAAC,CAAC;EAEF,MAAMG,SAAS,GAAG,IAAAC,OAAA,CAAAN,OAAA,EAAcrB,uBAAuB,EAAE,GAAGmB,KAAK,CAAC;EAElEpB,aAAa,CACXL,IAAI,CAACa,IAAI,CAACS,YAAY,EAAE,uBAAuB,CAAC,EAChD,IAAAY,UAAA,CAAAP,OAAA,EAAeK,SAAS,CAC1B,CAAC;EAED,OAAOG,QAAA,CAAAR,OAAA,CAAQS,OAAO,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.1",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
"dequal": "^2.0.3",
|
|
90
90
|
"file-size": "^1.0.0",
|
|
91
91
|
"format-message": "^6.2.4",
|
|
92
|
-
"glob": "^10.3.4",
|
|
93
92
|
"html-entities": "^2.4.0",
|
|
94
93
|
"iban": "^0.0.14",
|
|
95
94
|
"js-cookie": "^3.0.5",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mergeLayoutHintConfigurations } from "../mergeLayoutHintConfigurations";
|
|
2
2
|
import { LayoutHintConfiguration } from "../../constants/LayoutHintConfig";
|
|
3
3
|
const fs = require("fs");
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
//
|
|
5
|
+
const projectJson1 = {
|
|
6
6
|
MOCK: {
|
|
7
7
|
hint: "mock",
|
|
8
8
|
description: {
|
|
@@ -14,31 +14,38 @@ const projectJson = {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
const projectJson2 = {
|
|
18
|
+
MOCK2: {
|
|
19
|
+
hint: "mock2",
|
|
20
|
+
description: {
|
|
21
|
+
NL: "mock2 dutch description",
|
|
22
|
+
EN: "mock2 english description",
|
|
23
|
+
},
|
|
24
|
+
link: "",
|
|
25
|
+
component: ["attribute"],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
17
29
|
jest.mock("fs", () => ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
),
|
|
21
|
-
writeFile: jest.fn((path, options, callback) => callback(null)),
|
|
30
|
+
...jest.requireActual("fs"),
|
|
31
|
+
writeFileSync: jest.fn(),
|
|
22
32
|
}));
|
|
23
33
|
|
|
24
|
-
jest.mock("glob", () =>
|
|
25
|
-
jest.fn((pattern, options, callback) =>
|
|
26
|
-
callback(null, ["/input/LayoutHintConfig.json"]),
|
|
27
|
-
),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
34
|
describe("mergeLayoutHintConfigurations", () => {
|
|
31
35
|
it("generates layouthint.json", async () => {
|
|
32
36
|
expect.assertions(1);
|
|
33
37
|
|
|
34
|
-
const expectedJson = {
|
|
38
|
+
const expectedJson = {
|
|
39
|
+
...LayoutHintConfiguration,
|
|
40
|
+
...projectJson1,
|
|
41
|
+
...projectJson2,
|
|
42
|
+
};
|
|
35
43
|
|
|
36
|
-
await mergeLayoutHintConfigurations("
|
|
44
|
+
await mergeLayoutHintConfigurations("./src", "/output");
|
|
37
45
|
|
|
38
|
-
expect(fs.
|
|
39
|
-
|
|
46
|
+
expect(fs.writeFileSync).toHaveBeenCalledWith(
|
|
47
|
+
"\\output\\LayoutHintConfig.json",
|
|
40
48
|
JSON.stringify(expectedJson),
|
|
41
|
-
expect.anything(),
|
|
42
49
|
);
|
|
43
50
|
});
|
|
44
51
|
});
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
const glob = require("glob");
|
|
3
|
-
const fs = require("fs");
|
|
4
2
|
const path = require("path");
|
|
3
|
+
const { readdirSync, statSync, readFileSync, writeFileSync } = require("fs");
|
|
5
4
|
|
|
6
5
|
const { LayoutHintConfiguration } = require("../constants/LayoutHintConfig");
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fs.readFile(file, "utf-8", (err, data) => {
|
|
13
|
-
if (err) {
|
|
14
|
-
return reject(err);
|
|
15
|
-
} else {
|
|
16
|
-
return resolve(JSON.parse(data));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}),
|
|
20
|
-
);
|
|
7
|
+
const findFiles = (dir: string): Array<string> => {
|
|
8
|
+
const matchedFiles = [];
|
|
9
|
+
|
|
10
|
+
const files = readdirSync(dir);
|
|
21
11
|
|
|
22
|
-
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
const absolute = path.join(dir, file);
|
|
14
|
+
if (statSync(absolute).isDirectory()) {
|
|
15
|
+
const foundFiles = findFiles(absolute);
|
|
16
|
+
matchedFiles.push(...foundFiles);
|
|
17
|
+
} else {
|
|
18
|
+
const filename = path.basename(file);
|
|
19
|
+
if (filename === "LayoutHintConfig.json") {
|
|
20
|
+
matchedFiles.push(absolute);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return matchedFiles;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -32,27 +35,20 @@ exports.mergeLayoutHintConfigurations = async (
|
|
|
32
35
|
outputFolder: string,
|
|
33
36
|
): Promise<void> => {
|
|
34
37
|
const escapedSrcFolder = srcFolder.replace(/\\/g, "/");
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
glob(escapedSrcFolder + "/**/LayoutHintConfig.json", {}, (err, files) => {
|
|
37
|
-
if (err) {
|
|
38
|
-
return reject(err);
|
|
39
|
-
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(writeErr) => {
|
|
48
|
-
if (writeErr) {
|
|
49
|
-
return reject(writeErr);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return resolve();
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
39
|
+
const files = findFiles(escapedSrcFolder);
|
|
40
|
+
|
|
41
|
+
const jsons = files.map((file) => {
|
|
42
|
+
const content = readFileSync(file, "utf-8");
|
|
43
|
+
return JSON.parse(content);
|
|
57
44
|
});
|
|
45
|
+
|
|
46
|
+
const newConfig = Object.assign(LayoutHintConfiguration, ...jsons);
|
|
47
|
+
|
|
48
|
+
writeFileSync(
|
|
49
|
+
path.join(outputFolder, "LayoutHintConfig.json"),
|
|
50
|
+
JSON.stringify(newConfig),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return Promise.resolve();
|
|
58
54
|
};
|