@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/cli/lint.js
CHANGED
|
@@ -5,9 +5,9 @@ import log from "../logger.js";
|
|
|
5
5
|
import { getComponentData } from "../mocks/index.js";
|
|
6
6
|
import validateMockData from "../validator/mocks.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
getSchemaValidationMode,
|
|
9
|
+
toSchemaValidationResult,
|
|
10
|
+
validateSchemas,
|
|
11
11
|
} from "../validator/schemas.js";
|
|
12
12
|
import { t } from "../i18n/index.js";
|
|
13
13
|
import { EXIT_CODES } from "../errors.js";
|
|
@@ -17,53 +17,53 @@ import { EXIT_CODES } from "../errors.js";
|
|
|
17
17
|
* @returns {Promise<object>}
|
|
18
18
|
*/
|
|
19
19
|
export default async function lint(args) {
|
|
20
|
-
|
|
20
|
+
process.env.NODE_ENV = "development";
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const componentArg = args.component;
|
|
23
|
+
const config = await getConfig(args);
|
|
24
|
+
process.env.MIYAGI_LOG_CONTEXT = "lint";
|
|
25
|
+
process.env.MIYAGI_LOG_LEVEL = config.lint?.logLevel || "error";
|
|
26
|
+
global.app = await init(config);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
if (componentArg) {
|
|
29
|
+
const component = global.state.routes.find(
|
|
30
|
+
({ alias }) =>
|
|
31
|
+
alias === path.relative(config.components.folder, componentArg),
|
|
32
|
+
);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (component) {
|
|
35
|
+
const schemaValidation = validateSchemas({
|
|
36
|
+
components: [component],
|
|
37
|
+
});
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
if (schemaValidation.errors.length > 0) {
|
|
40
|
+
reportSchemaErrors(schemaValidation.errors);
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
code: EXIT_CODES.VALIDATION_ERROR,
|
|
44
|
+
shouldExit: true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
log("success", "All schemas valid.");
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
50
|
+
return await validateComponentMockData({
|
|
51
|
+
component,
|
|
52
|
+
validSchemas: schemaValidation.validSchemas,
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
const message = `The component ${componentArg} does not seem to exist.`;
|
|
56
|
+
log("error", message);
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
code: EXIT_CODES.CLI_USAGE_ERROR,
|
|
60
|
+
shouldExit: true,
|
|
61
|
+
message,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
return await validateAllMockData();
|
|
66
|
+
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -75,21 +75,21 @@ export default async function lint(args) {
|
|
|
75
75
|
* @returns {object}
|
|
76
76
|
*/
|
|
77
77
|
function createLintResult({ success, shouldExit, valid, type }) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
const result = {
|
|
79
|
+
success,
|
|
80
|
+
code: success ? EXIT_CODES.SUCCESS : EXIT_CODES.VALIDATION_ERROR,
|
|
81
|
+
shouldExit,
|
|
82
|
+
};
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
if (valid !== undefined) {
|
|
85
|
+
result.valid = valid;
|
|
86
|
+
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
if (type) {
|
|
89
|
+
result.type = type;
|
|
90
|
+
}
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
return result;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
@@ -97,100 +97,100 @@ function createLintResult({ success, shouldExit, valid, type }) {
|
|
|
97
97
|
* @returns {Promise<object>}
|
|
98
98
|
*/
|
|
99
99
|
async function validateAllMockData(exitProcess = true) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
100
|
+
log("info", t("linter.all.start"));
|
|
101
|
+
const mode = getSchemaValidationMode();
|
|
102
|
+
const components = global.state.routes.filter(
|
|
103
|
+
(route) => route.type === "components" && route.paths.tpl,
|
|
104
|
+
);
|
|
105
|
+
const schemaValidation = validateSchemas({
|
|
106
|
+
components,
|
|
107
|
+
});
|
|
108
|
+
const invalidSchemaComponents = new Set(
|
|
109
|
+
schemaValidation.errors.map((entry) => entry.component),
|
|
110
|
+
);
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
if (schemaValidation.errors.length === 0) {
|
|
113
|
+
log("success", "All schemas valid.");
|
|
114
|
+
}
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
116
|
+
if (schemaValidation.errors.length > 0 && mode === "fail-fast") {
|
|
117
|
+
reportSchemaErrors(schemaValidation.errors);
|
|
118
|
+
log(
|
|
119
|
+
"error",
|
|
120
|
+
schemaValidation.errors.length === 1
|
|
121
|
+
? t("linter.all.schema.invalid.one")
|
|
122
|
+
: t("linter.all.schema.invalid.other").replace(
|
|
123
|
+
"{{amount}}",
|
|
124
|
+
schemaValidation.errors.length,
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
if (exitProcess) {
|
|
128
|
+
return {
|
|
129
|
+
success: false,
|
|
130
|
+
code: EXIT_CODES.VALIDATION_ERROR,
|
|
131
|
+
shouldExit: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
success: false,
|
|
136
|
+
code: EXIT_CODES.VALIDATION_ERROR,
|
|
137
|
+
shouldExit: false,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
141
|
+
const results = await Promise.all(
|
|
142
|
+
components
|
|
143
|
+
.filter((route) => !invalidSchemaComponents.has(route.paths.dir.short))
|
|
144
|
+
.map((component) =>
|
|
145
|
+
validateComponentMockData({
|
|
146
|
+
component,
|
|
147
|
+
silent: true,
|
|
148
|
+
exitProcess: false,
|
|
149
|
+
validSchemas: schemaValidation.validSchemas,
|
|
150
|
+
}),
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
const mockInvalidResults = results.filter(
|
|
154
|
+
(result) => result?.valid === false && result.type === "mocks",
|
|
155
|
+
);
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
157
|
+
if (mode === "collect-all" && schemaValidation.errors.length > 0) {
|
|
158
|
+
reportSchemaErrors(schemaValidation.errors);
|
|
159
|
+
log(
|
|
160
|
+
"error",
|
|
161
|
+
schemaValidation.errors.length === 1
|
|
162
|
+
? t("linter.all.schema.invalid.one")
|
|
163
|
+
: t("linter.all.schema.invalid.other").replace(
|
|
164
|
+
"{{amount}}",
|
|
165
|
+
schemaValidation.errors.length,
|
|
166
|
+
),
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
170
|
+
if (mockInvalidResults.length > 0) {
|
|
171
|
+
log(
|
|
172
|
+
"error",
|
|
173
|
+
mockInvalidResults.length === 1
|
|
174
|
+
? t("linter.all.mocks.invalid.one")
|
|
175
|
+
: t("linter.all.mocks.invalid.other").replace(
|
|
176
|
+
"{{amount}}",
|
|
177
|
+
mockInvalidResults.length,
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
if (mockInvalidResults.length === 0 && schemaValidation.errors.length === 0) {
|
|
183
|
+
log("success", t("linter.all.valid"));
|
|
184
|
+
return createLintResult({
|
|
185
|
+
success: true,
|
|
186
|
+
shouldExit: exitProcess,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
return createLintResult({
|
|
191
|
+
success: false,
|
|
192
|
+
shouldExit: exitProcess,
|
|
193
|
+
});
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
/**
|
|
@@ -202,71 +202,71 @@ async function validateAllMockData(exitProcess = true) {
|
|
|
202
202
|
* @returns {Promise<object|null>}
|
|
203
203
|
*/
|
|
204
204
|
async function validateComponentMockData({
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
component,
|
|
206
|
+
silent,
|
|
207
|
+
exitProcess = true,
|
|
208
|
+
validSchemas = [],
|
|
209
209
|
}) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
210
|
+
if (!silent) {
|
|
211
|
+
log(
|
|
212
|
+
"info",
|
|
213
|
+
t("linter.component.start").replace(
|
|
214
|
+
"{{component}}",
|
|
215
|
+
component.paths.dir.short,
|
|
216
|
+
),
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
const data = (await getComponentData(component)) || [];
|
|
221
221
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
if (data.length > 0) {
|
|
223
|
+
for (const { messages = [] } of data) {
|
|
224
|
+
for (const { type, text, verbose } of messages) {
|
|
225
|
+
log(type, text, verbose);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
const results = validateMockData(component, data, false, validSchemas);
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
if (!results) return null;
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
if (results.length === 0) {
|
|
235
|
+
if (!silent) {
|
|
236
|
+
log("success", t("linter.component.valid"));
|
|
237
|
+
}
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
239
|
+
return createLintResult({
|
|
240
|
+
valid: true,
|
|
241
|
+
success: true,
|
|
242
|
+
shouldExit: exitProcess,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
return createLintResult({
|
|
247
|
+
valid: false,
|
|
248
|
+
success: false,
|
|
249
|
+
shouldExit: exitProcess,
|
|
250
|
+
type: results[0].type,
|
|
251
|
+
});
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* @param {Array<object>} schemaErrors
|
|
256
256
|
*/
|
|
257
257
|
function reportSchemaErrors(schemaErrors) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
258
|
+
schemaErrors.forEach((entry) => {
|
|
259
|
+
const result = toSchemaValidationResult(entry);
|
|
260
|
+
log("error", `${entry.component}:\n${result.data[0].message}`);
|
|
261
|
+
log("error", `schema: ${entry.schemaFile}`);
|
|
262
|
+
if (entry.schemaPath || entry.instancePath) {
|
|
263
|
+
log(
|
|
264
|
+
"error",
|
|
265
|
+
`schemaPath: ${entry.schemaPath || "-"} | instancePath: ${entry.instancePath || "-"}`,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
if (entry.hint) {
|
|
269
|
+
log("warn", entry.hint);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
272
|
}
|