@schalkneethling/miyagi-core 4.4.2 → 4.4.3
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/README.md +7 -2
- package/api/app.js +16 -16
- package/api/index.js +263 -262
- package/bin/miyagi.js +1 -1
- package/dist/css/iframe.css +6 -30
- package/frontend/assets/css/iframe/accordion-tabs.css +39 -39
- package/frontend/assets/css/iframe/jsontree.js.css +149 -149
- package/frontend/assets/css/iframe/prism.css +45 -45
- package/frontend/assets/css/iframe/styleguide/colors.css +27 -27
- package/frontend/assets/css/iframe/styleguide/fonts.css +23 -23
- package/frontend/assets/css/iframe/styleguide/index.css +58 -58
- package/frontend/assets/css/iframe/styleguide/spacings.css +10 -10
- package/frontend/assets/css/iframe.css +191 -191
- package/frontend/assets/css/main/menu/config-switcher.css +21 -21
- package/frontend/assets/css/main/menu/config-switchers.css +34 -34
- package/frontend/assets/css/main/menu/goto.css +16 -16
- package/frontend/assets/css/main/menu/nav.css +49 -49
- package/frontend/assets/css/main/menu/search.css +34 -34
- package/frontend/assets/css/main/menu/title.css +18 -18
- package/frontend/assets/css/main/menu.css +89 -89
- package/frontend/assets/css/main/reset.css +47 -47
- package/frontend/assets/css/main.css +41 -41
- package/frontend/assets/css/shared.css +16 -16
- package/frontend/assets/css/tokens.css +108 -107
- package/frontend/assets/js/_accordion-tabs.js +392 -392
- package/frontend/assets/js/_goto.js +59 -59
- package/frontend/assets/js/_iframe-links.js +14 -14
- package/frontend/assets/js/_is-triggered.js +3 -3
- package/frontend/assets/js/_main.js +369 -369
- package/frontend/assets/js/_mock-data.js +8 -8
- package/frontend/assets/js/_prism.js +1082 -1081
- package/frontend/assets/js/_search.js +186 -186
- package/frontend/assets/js/_socket.js +44 -44
- package/frontend/assets/js/config-switcher/development-mode.js +38 -38
- package/frontend/assets/js/config-switcher/index.js +55 -55
- package/frontend/assets/js/config-switcher/text-direction.js +22 -22
- package/frontend/assets/js/config-switcher/theme.js +68 -68
- package/frontend/assets/js/iframe.build.js +25 -25
- package/frontend/assets/js/iframe.js +38 -38
- package/frontend/assets/js/jsontree.js +979 -976
- package/frontend/assets/js/main.build.js +29 -29
- package/frontend/assets/js/main.js +31 -31
- package/frontend/assets/js/styleguide/color-converter.js +652 -652
- package/frontend/assets/js/styleguide/index.js +100 -100
- package/lib/build/index.js +1014 -1020
- package/lib/cli/app.js +16 -16
- package/lib/cli/component.js +50 -50
- package/lib/cli/doctor.js +130 -121
- package/lib/cli/drupal-assets.js +163 -157
- package/lib/cli/lint.js +196 -196
- package/lib/cli/run.js +150 -146
- package/lib/config.js +86 -86
- package/lib/constants/lint-log-levels.js +6 -6
- package/lib/drupal/load-assets-config.js +59 -60
- package/lib/drupal/resolve-library-assets.js +132 -141
- package/lib/errors.js +20 -20
- package/lib/generator/component.js +124 -124
- package/lib/generator/mocks.js +156 -156
- package/lib/helpers.js +68 -68
- package/lib/i18n/en.js +93 -93
- package/lib/i18n/index.js +8 -8
- package/lib/index.js +13 -13
- package/lib/init/args.js +153 -153
- package/lib/init/config.js +452 -438
- package/lib/init/engines.js +41 -41
- package/lib/init/index.js +83 -83
- package/lib/init/rendering.js +3 -3
- package/lib/init/static.js +90 -90
- package/lib/init/twing/cache.js +27 -27
- package/lib/init/twing/functions.js +37 -37
- package/lib/init/views.js +5 -5
- package/lib/logger.js +72 -72
- package/lib/mocks/get.js +88 -88
- package/lib/mocks/index.js +2 -2
- package/lib/mocks/resolve/ref.js +447 -447
- package/lib/mocks/resolve/tpl.js +218 -218
- package/lib/mocks/resolve.js +154 -154
- package/lib/render/helpers/resolve-assets.js +29 -39
- package/lib/render/helpers.js +27 -27
- package/lib/render/index.js +18 -18
- package/lib/render/views/iframe/component.docs.js +50 -50
- package/lib/render/views/iframe/component.js +249 -248
- package/lib/render/views/iframe/design-tokens/colors.js +38 -38
- package/lib/render/views/iframe/design-tokens/index.js +3 -3
- package/lib/render/views/iframe/design-tokens/sizes.js +35 -35
- package/lib/render/views/iframe/design-tokens/typography.js +37 -37
- package/lib/render/views/iframe/docs.js +42 -42
- package/lib/render/views/iframe/index.js +28 -28
- package/lib/render/views/iframe/variation.js +89 -89
- package/lib/render/views/iframe/variation.standalone.js +69 -68
- package/lib/render/views/main/component.docs.js +38 -38
- package/lib/render/views/main/component.js +55 -55
- package/lib/render/views/main/design-tokens.js +38 -38
- package/lib/render/views/main/docs.js +33 -33
- package/lib/render/views/main/index.js +33 -33
- package/lib/state/components.js +99 -99
- package/lib/state/css.js +33 -33
- package/lib/state/docs.js +72 -72
- package/lib/state/file-contents.js +154 -154
- package/lib/state/helpers.js +53 -53
- package/lib/state/index.js +39 -39
- package/lib/state/menu/index.js +202 -202
- package/lib/state/menu/structure.js +84 -84
- package/lib/state/partials.js +12 -12
- package/lib/state/source-tree.js +51 -51
- package/lib/styleguide/color-names.js +148 -148
- package/lib/styleguide/colors.js +113 -113
- package/lib/styleguide/helpers.js +33 -33
- package/lib/styleguide/index.js +4 -4
- package/lib/styleguide/media-queries.js +18 -18
- package/lib/styleguide/spacings.js +22 -22
- package/lib/styleguide/typography.js +46 -46
- package/lib/validator/mocks.js +110 -83
- package/lib/validator/schemas.js +236 -227
- package/package.json +118 -117
package/lib/state/components.js
CHANGED
|
@@ -9,57 +9,57 @@ import * as helpers from "../helpers.js";
|
|
|
9
9
|
* @returns {Array}
|
|
10
10
|
*/
|
|
11
11
|
export default function getComponents(menu, isBuild) {
|
|
12
|
-
|
|
12
|
+
if (!menu) return [];
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const components = [];
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const partials = Object.keys(global.state.partials || []);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
(function iterate(arr) {
|
|
19
|
+
arr.forEach((entry) => {
|
|
20
|
+
if (entry.shortPath && entry.normalizedShortPath) {
|
|
21
|
+
const componentName = path.basename(entry.shortPath);
|
|
22
|
+
const assetNames = {
|
|
23
|
+
css: `${componentName}.miyagi.css`,
|
|
24
|
+
js: `${componentName}.miyagi.js`,
|
|
25
|
+
};
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
components.push({
|
|
28
|
+
shortPath: entry.shortPath,
|
|
29
|
+
value: isBuild ? entry.normalizedShortPath : entry.shortPath,
|
|
30
|
+
assets: {
|
|
31
|
+
css: fs.existsSync(path.join(entry.fullPath, assetNames.css))
|
|
32
|
+
? path.relative(
|
|
33
|
+
process.cwd(),
|
|
34
|
+
path.join(entry.fullPath, assetNames.css),
|
|
35
|
+
)
|
|
36
|
+
: false,
|
|
37
|
+
js: fs.existsSync(path.join(entry.fullPath, assetNames.js))
|
|
38
|
+
? path.relative(
|
|
39
|
+
process.cwd(),
|
|
40
|
+
path.join(entry.fullPath, assetNames.js),
|
|
41
|
+
)
|
|
42
|
+
: false,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
addToRoutes(
|
|
47
|
+
{
|
|
48
|
+
name: componentName,
|
|
49
|
+
shortPath: entry.shortPath,
|
|
50
|
+
fullPath: entry.fullPath,
|
|
51
|
+
},
|
|
52
|
+
partials,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
if (entry.children && entry.children.length > 0) {
|
|
57
|
+
iterate(entry.children);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
})(menu);
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
return components;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -70,63 +70,63 @@ export default function getComponents(menu, isBuild) {
|
|
|
70
70
|
* @param {Array} partials
|
|
71
71
|
*/
|
|
72
72
|
function addToRoutes({ name, shortPath, fullPath }, partials = []) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
if (!global.state.routes.includes(shortPath)) {
|
|
74
|
+
const fileName = `${path.basename(shortPath)}.${
|
|
75
|
+
global.config.files.templates.extension
|
|
76
|
+
}`;
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
const tplShortPath = path.join(shortPath, fileName);
|
|
79
|
+
const schemaFileName = `${global.config.files.schema.name}.${global.config.files.schema.extension}`;
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
81
|
+
const component = {
|
|
82
|
+
name,
|
|
83
|
+
route: {
|
|
84
|
+
default: global.config.isBuild
|
|
85
|
+
? `component-${helpers.normalizeString(shortPath)}.html`
|
|
86
|
+
: `/component?file=${shortPath}`,
|
|
87
|
+
embedded: global.config.isBuild
|
|
88
|
+
? `component-${helpers.normalizeString(shortPath)}-embedded.html`
|
|
89
|
+
: `/component?file=${shortPath}&embedded=true`,
|
|
90
|
+
},
|
|
91
|
+
alias: shortPath,
|
|
92
|
+
paths: {
|
|
93
|
+
dir: {
|
|
94
|
+
full: fullPath,
|
|
95
|
+
short: shortPath,
|
|
96
|
+
},
|
|
97
|
+
mocks: {
|
|
98
|
+
full(fileType) {
|
|
99
|
+
return path.join(
|
|
100
|
+
fullPath,
|
|
101
|
+
`${global.config.files.mocks.name}.${fileType}`,
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
short(fileType) {
|
|
105
|
+
return path.join(
|
|
106
|
+
shortPath,
|
|
107
|
+
`${global.config.files.mocks.name}.${fileType}`,
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
schema: {
|
|
112
|
+
full: path.join(fullPath, schemaFileName),
|
|
113
|
+
short: path.join(shortPath, schemaFileName),
|
|
114
|
+
},
|
|
115
|
+
docs: {
|
|
116
|
+
full: path.join(fullPath, "README.md"),
|
|
117
|
+
short: path.join(shortPath, "README.md"),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
type: "components",
|
|
121
|
+
};
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
123
|
+
if (partials.includes(tplShortPath)) {
|
|
124
|
+
component.paths.tpl = {
|
|
125
|
+
short: tplShortPath,
|
|
126
|
+
full: path.join(fullPath, fileName),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
global.state.routes.push(component);
|
|
131
|
+
}
|
|
132
132
|
}
|
package/lib/state/css.js
CHANGED
|
@@ -8,43 +8,43 @@ import { t } from "../i18n/index.js";
|
|
|
8
8
|
* @returns {object}
|
|
9
9
|
*/
|
|
10
10
|
export default function getCSS(fileContents) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const { assets } = global.config;
|
|
12
|
+
let cssObject = {};
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (assets?.customProperties?.files.length > 0) {
|
|
15
|
+
if (assets.customProperties.files.length > 1) {
|
|
16
|
+
cssObject = deepMerge.all(
|
|
17
|
+
assets.customProperties.files.map((file) => {
|
|
18
|
+
const fileContent = fileContents[file];
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
if (fileContent) {
|
|
21
|
+
return css.parse(fileContent);
|
|
22
|
+
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
log(
|
|
25
|
+
"warn",
|
|
26
|
+
t("customPropertyFileNotFound").replace("{{filePath}}", file),
|
|
27
|
+
);
|
|
28
|
+
return {};
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
const fileContent = fileContents[assets.customProperties.files[0]];
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
if (fileContent) {
|
|
35
|
+
return css.parse(fileContents[assets.customProperties.files[0]]);
|
|
36
|
+
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
log(
|
|
39
|
+
"warn",
|
|
40
|
+
t("customPropertyFileNotFound").replace(
|
|
41
|
+
"{{filePath}}",
|
|
42
|
+
assets.customProperties.files[0],
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
return cssObject;
|
|
50
50
|
}
|
package/lib/state/docs.js
CHANGED
|
@@ -3,9 +3,9 @@ import PATH from "path";
|
|
|
3
3
|
import * as helpers from "../helpers.js";
|
|
4
4
|
|
|
5
5
|
export const getMenu = (sourceTree) => {
|
|
6
|
-
|
|
6
|
+
if (!sourceTree) return null;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
return getMenuItem(sourceTree, {});
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -18,73 +18,73 @@ export const getMenu = (sourceTree) => {
|
|
|
18
18
|
* @returns {object}
|
|
19
19
|
*/
|
|
20
20
|
function getMenuItem({ name, type, path, children }, item) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const shortPath = PATH.relative(
|
|
22
|
+
process.cwd(),
|
|
23
|
+
type === "file"
|
|
24
|
+
? PATH.join(PATH.dirname(path), PATH.basename(path, PATH.extname(path)))
|
|
25
|
+
: path,
|
|
26
|
+
);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
item.topLevel = shortPath == global.config.docs.folder;
|
|
29
|
+
item.id = shortPath;
|
|
30
|
+
item.shortPath = shortPath;
|
|
31
|
+
item.name = type === "file" ? PATH.basename(name, PATH.extname(name)) : name;
|
|
32
|
+
item.type = type;
|
|
33
|
+
item.section = "docs";
|
|
34
|
+
item.route = {
|
|
35
|
+
default: global.config.isBuild
|
|
36
|
+
? `component-${helpers.normalizeString(shortPath)}.html`
|
|
37
|
+
: `/component?file=${shortPath}`,
|
|
38
|
+
embedded: global.config.isBuild
|
|
39
|
+
? `component-${helpers.normalizeString(shortPath)}-embedded.html`
|
|
40
|
+
: `/component?file=${shortPath}&embedded=true`,
|
|
41
|
+
};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
/**
|
|
44
|
+
* if the current item in the tree is a directory, we check if any of
|
|
45
|
+
* its children is a README.md or index.md. In that case, we want
|
|
46
|
+
* this directory to be linked, not the file.
|
|
47
|
+
*/
|
|
48
|
+
if (item.type === "directory") {
|
|
49
|
+
if (children) {
|
|
50
|
+
const indexFile = children.find(
|
|
51
|
+
(child) => child.name === "README.md" || child.name === "index.md",
|
|
52
|
+
);
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
item.isLink = !!indexFile;
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
if (indexFile) {
|
|
57
|
+
item.file = indexFile.path;
|
|
58
|
+
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
if (item.isLink) {
|
|
61
|
+
addToRoutes(item);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
item.isLink = true;
|
|
66
|
+
item.shortPath = shortPath;
|
|
67
|
+
item.file = path;
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
addToRoutes(item);
|
|
70
|
+
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
if (children) {
|
|
73
|
+
item.children = [];
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
children.forEach((child) => {
|
|
76
|
+
const fileName = PATH.basename(child.path);
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
if (
|
|
79
|
+
child.type === "directory" ||
|
|
80
|
+
!["README.md", "index.md"].includes(fileName)
|
|
81
|
+
) {
|
|
82
|
+
item.children.push(getMenuItem(child, {}));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
return item;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
@@ -95,17 +95,17 @@ function getMenuItem({ name, type, path, children }, item) {
|
|
|
95
95
|
* @param {string} item.route
|
|
96
96
|
*/
|
|
97
97
|
function addToRoutes({ name, shortPath, file, route }) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
if (!global.state.routes.includes(shortPath)) {
|
|
99
|
+
global.state.routes.push({
|
|
100
|
+
name,
|
|
101
|
+
route,
|
|
102
|
+
paths: {
|
|
103
|
+
dir: {
|
|
104
|
+
full: file,
|
|
105
|
+
short: shortPath,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
type: "docs",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
111
|
}
|