@schalkneethling/miyagi-core 4.9.1 → 4.10.0
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/lib/default-config.js +1 -0
- package/lib/init/config.js +6 -0
- package/lib/render/helpers.js +56 -0
- package/lib/render/views/main/component.docs.js +8 -3
- package/lib/render/views/main/component.js +8 -3
- package/lib/render/views/main/design-tokens.js +8 -3
- package/lib/render/views/main/docs.js +8 -3
- package/lib/render/views/main/index.js +8 -3
- package/lib/validator/mocks.js +20 -15
- package/package.json +1 -1
package/lib/default-config.js
CHANGED
package/lib/init/config.js
CHANGED
|
@@ -500,6 +500,12 @@ export default (userConfig = {}) => {
|
|
|
500
500
|
sanitizePath,
|
|
501
501
|
);
|
|
502
502
|
}
|
|
503
|
+
|
|
504
|
+
if (config.components.hidden) {
|
|
505
|
+
config.components.hidden = arrayfy(config.components.hidden).map(
|
|
506
|
+
sanitizePath,
|
|
507
|
+
);
|
|
508
|
+
}
|
|
503
509
|
}
|
|
504
510
|
|
|
505
511
|
if (!config.ui) config.ui = {};
|
package/lib/render/helpers.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import path from "path";
|
|
7
|
+
import anymatch from "anymatch";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @param {object} config - the user configuration object
|
|
@@ -49,3 +50,58 @@ export const getThemeMode = (cookies = {}) => {
|
|
|
49
50
|
`miyagi_${global.config.projectName.replaceAll(" ", "-")}_theme`
|
|
50
51
|
];
|
|
51
52
|
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {Array} menu
|
|
56
|
+
* @returns {Array} menu with hidden components removed
|
|
57
|
+
*/
|
|
58
|
+
export function getDisplayMenu(menu) {
|
|
59
|
+
const hidden = global.config.components.hidden;
|
|
60
|
+
|
|
61
|
+
if (!menu || !hidden?.length) {
|
|
62
|
+
return menu;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!Array.isArray(menu)) {
|
|
66
|
+
return menu;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return menu.reduce((acc, item) => {
|
|
70
|
+
if (
|
|
71
|
+
item.shortPath &&
|
|
72
|
+
anymatch(hidden, item.shortPath.replaceAll("\\", "/"))
|
|
73
|
+
) {
|
|
74
|
+
return acc;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (item.children) {
|
|
78
|
+
const filteredChildren = getDisplayMenu(item.children);
|
|
79
|
+
|
|
80
|
+
if (filteredChildren.length === 0) {
|
|
81
|
+
return acc;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
acc.push({ ...item, children: filteredChildren });
|
|
85
|
+
} else {
|
|
86
|
+
acc.push(item);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return acc;
|
|
90
|
+
}, []);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {Array} components
|
|
95
|
+
* @returns {Array} components with hidden entries removed
|
|
96
|
+
*/
|
|
97
|
+
export function getDisplayComponents(components) {
|
|
98
|
+
const hidden = global.config.components.hidden;
|
|
99
|
+
|
|
100
|
+
if (!components || !hidden?.length) {
|
|
101
|
+
return components;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return components.filter(
|
|
105
|
+
(c) => !anymatch(hidden, c.shortPath.replaceAll("\\", "/")),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import config from "../../../default-config.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getUserUiConfig,
|
|
4
|
+
getThemeMode,
|
|
5
|
+
getDisplayMenu,
|
|
6
|
+
getDisplayComponents,
|
|
7
|
+
} from "../../helpers.js";
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* @param {object} object - parameter object
|
|
@@ -21,8 +26,8 @@ export default async function renderMainComponentDocs({
|
|
|
21
26
|
"main.twig.miyagi",
|
|
22
27
|
{
|
|
23
28
|
lang: global.config.ui.lang,
|
|
24
|
-
folders: global.state.menu,
|
|
25
|
-
components: global.state.components,
|
|
29
|
+
folders: getDisplayMenu(global.state.menu),
|
|
30
|
+
components: getDisplayComponents(global.state.components),
|
|
26
31
|
flatUrlPattern: global.config.isBuild
|
|
27
32
|
? "/show-{{component}}.html"
|
|
28
33
|
: "/show?file={{component}}",
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import config from "../../../default-config.js";
|
|
2
2
|
import * as helpers from "../../../helpers.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getUserUiConfig,
|
|
5
|
+
getThemeMode,
|
|
6
|
+
getDisplayMenu,
|
|
7
|
+
getDisplayComponents,
|
|
8
|
+
} from "../../helpers.js";
|
|
4
9
|
import { runPerformance } from "../../../performance/index.js";
|
|
5
10
|
import { buildPagePerfBanner } from "../../../performance/view-data.js";
|
|
6
11
|
import { renderPageHtml } from "../../../performance/render-page.js";
|
|
@@ -64,8 +69,8 @@ export default async function renderMainComponent({
|
|
|
64
69
|
{
|
|
65
70
|
perfBanner,
|
|
66
71
|
lang: global.config.ui.lang,
|
|
67
|
-
folders: global.state.menu,
|
|
68
|
-
components: global.state.components,
|
|
72
|
+
folders: getDisplayMenu(global.state.menu),
|
|
73
|
+
components: getDisplayComponents(global.state.components),
|
|
69
74
|
flatUrlPattern: global.config.isBuild
|
|
70
75
|
? "/show-{{component}}.html"
|
|
71
76
|
: "/show?file={{component}}",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import config from "../../../default-config.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getUserUiConfig,
|
|
4
|
+
getThemeMode,
|
|
5
|
+
getDisplayMenu,
|
|
6
|
+
getDisplayComponents,
|
|
7
|
+
} from "../../helpers.js";
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* @param {object} object - parameter object
|
|
@@ -17,8 +22,8 @@ export default function renderMainDesignTokens({ res, cb, cookies, type }) {
|
|
|
17
22
|
"main.twig.miyagi",
|
|
18
23
|
{
|
|
19
24
|
lang: global.config.ui.lang,
|
|
20
|
-
folders: global.state.menu,
|
|
21
|
-
components: global.state.components,
|
|
25
|
+
folders: getDisplayMenu(global.state.menu),
|
|
26
|
+
components: getDisplayComponents(global.state.components),
|
|
22
27
|
flatUrlPattern: global.config.isBuild
|
|
23
28
|
? "/show-{{component}}.html"
|
|
24
29
|
: "/show?file={{component}}",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import config from "../../../default-config.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getUserUiConfig,
|
|
4
|
+
getThemeMode,
|
|
5
|
+
getDisplayMenu,
|
|
6
|
+
getDisplayComponents,
|
|
7
|
+
} from "../../helpers.js";
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* @param {object} object - parameter object
|
|
@@ -15,8 +20,8 @@ export default async function renderMainDocs({ res, doc, cb, cookies }) {
|
|
|
15
20
|
"main.twig.miyagi",
|
|
16
21
|
{
|
|
17
22
|
lang: global.config.ui.lang,
|
|
18
|
-
folders: global.state.menu,
|
|
19
|
-
components: global.state.components,
|
|
23
|
+
folders: getDisplayMenu(global.state.menu),
|
|
24
|
+
components: getDisplayComponents(global.state.components),
|
|
20
25
|
flatUrlPattern: global.config.isBuild
|
|
21
26
|
? "/show-{{component}}.html"
|
|
22
27
|
: "/show?file={{component}}",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import config from "../../../default-config.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getUserUiConfig,
|
|
4
|
+
getThemeMode,
|
|
5
|
+
getDisplayMenu,
|
|
6
|
+
getDisplayComponents,
|
|
7
|
+
} from "../../helpers.js";
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* @param {object} object - parameter object
|
|
@@ -14,8 +19,8 @@ export default function renderMainIndex({ res, cb, cookies }) {
|
|
|
14
19
|
"main.twig.miyagi",
|
|
15
20
|
{
|
|
16
21
|
lang: global.config.ui.lang,
|
|
17
|
-
folders: global.state.menu,
|
|
18
|
-
components: global.state.components,
|
|
22
|
+
folders: getDisplayMenu(global.state.menu),
|
|
23
|
+
components: getDisplayComponents(global.state.components),
|
|
19
24
|
flatUrlPattern: global.config.isBuild
|
|
20
25
|
? "/show-{{component}}.html"
|
|
21
26
|
: "/show?file={{component}}",
|
package/lib/validator/mocks.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import jsYaml from "js-yaml";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import deepMerge from "deepmerge";
|
|
4
|
+
import anymatch from "anymatch";
|
|
4
5
|
import log from "../logger.js";
|
|
5
6
|
import { t } from "../i18n/index.js";
|
|
6
7
|
import { loadGlobalSchemas } from "./schemas.js";
|
|
@@ -116,21 +117,25 @@ export default function validateMockData(
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
if (!global.config.isBuild && !noCli) {
|
|
119
|
-
const
|
|
120
|
-
global.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
120
|
+
const isHidden = anymatch(
|
|
121
|
+
global.config.components.hidden ?? [],
|
|
122
|
+
component.paths.dir.short.replaceAll("\\", "/"),
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
if (!isHidden) {
|
|
126
|
+
const parseError =
|
|
127
|
+
global.state.fileReadErrors?.[component.paths.schema.full];
|
|
128
|
+
const schemaExistsOnDisk = existsSync(component.paths.schema.full);
|
|
129
|
+
const warningMessage =
|
|
130
|
+
parseError || schemaExistsOnDisk
|
|
131
|
+
? t("validator.mocks.schemaParseFailed")
|
|
132
|
+
.replace("{{schemaFile}}", component.paths.schema.short)
|
|
133
|
+
.replace("{{format}}", "JSON or YAML")
|
|
134
|
+
: t("validator.mocks.schemaMissing")
|
|
135
|
+
.replace("{{component}}", component.paths.dir.short)
|
|
136
|
+
.replace("{{schemaFile}}", component.paths.schema.short);
|
|
137
|
+
log("warn", warningMessage);
|
|
138
|
+
}
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schalkneethling/miyagi-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "miyagi is a component development tool for JavaScript template engines.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Schalk Neethling <schalkneethling@duck.com>, Michael Großklaus <mail@mgrossklaus.de> (https://www.mgrossklaus.de)",
|