@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
|
@@ -16,8 +16,8 @@ import log from "../logger.js";
|
|
|
16
16
|
* @returns {boolean}
|
|
17
17
|
*/
|
|
18
18
|
function isSchemaFile(fileName) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const schemaFileName = `${global.config.files.schema.name}.${global.config.files.schema.extension}`;
|
|
20
|
+
return path.basename(fileName) === schemaFileName;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -25,15 +25,15 @@ function isSchemaFile(fileName) {
|
|
|
25
25
|
* @param {Error & { code?: string }} err
|
|
26
26
|
*/
|
|
27
27
|
function markFileReadError(fileName, err) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
if (!global.state?.fileReadErrors || !isSchemaFile(fileName)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
global.state.fileReadErrors[fileName] = {
|
|
33
|
+
type: "schema-parse",
|
|
34
|
+
code: err?.code || null,
|
|
35
|
+
message: err?.message || String(err),
|
|
36
|
+
};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -43,7 +43,7 @@ function markFileReadError(fileName, err) {
|
|
|
43
43
|
* @returns {boolean} is true if given array includes given file path
|
|
44
44
|
*/
|
|
45
45
|
function checkIfFileNamesIncludeFile(file, fileNames) {
|
|
46
|
-
|
|
46
|
+
return fileNames.includes(path.basename(file));
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -52,46 +52,46 @@ function checkIfFileNamesIncludeFile(file, fileNames) {
|
|
|
52
52
|
* @returns {Promise<string[]>}
|
|
53
53
|
*/
|
|
54
54
|
async function getFilePaths(sourceTree) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
55
|
+
const { assets, components, files } = global.config;
|
|
56
|
+
|
|
57
|
+
const paths = [...assets.customProperties.files];
|
|
58
|
+
|
|
59
|
+
if (sourceTree.components) {
|
|
60
|
+
(function getPaths(entry) {
|
|
61
|
+
if (!anymatch(components.ignores, entry.path)) {
|
|
62
|
+
if (entry.type === "file") {
|
|
63
|
+
if (
|
|
64
|
+
checkIfFileNamesIncludeFile(entry.path, [
|
|
65
|
+
`${helpers.getResolvedFileName(
|
|
66
|
+
files.templates.name,
|
|
67
|
+
path.basename(entry.path, `.${files.templates.extension}`),
|
|
68
|
+
)}.${files.templates.extension}`,
|
|
69
|
+
`${files.mocks.name}.${files.mocks.extension[0]}`,
|
|
70
|
+
`${files.mocks.name}.${files.mocks.extension[1]}`,
|
|
71
|
+
`${files.schema.name}.${files.schema.extension}`,
|
|
72
|
+
]) ||
|
|
73
|
+
helpers.fileIsDocumentationFile(entry.path)
|
|
74
|
+
) {
|
|
75
|
+
paths.push(entry.path);
|
|
76
|
+
}
|
|
77
|
+
} else if (entry.type === "directory") {
|
|
78
|
+
entry.children.forEach((item) => getPaths(item));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
})(sourceTree.components);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (sourceTree.docs) {
|
|
85
|
+
(function getPaths(entry) {
|
|
86
|
+
if (entry.type === "file") {
|
|
87
|
+
paths.push(entry.path);
|
|
88
|
+
} else if (entry.type === "directory") {
|
|
89
|
+
entry.children.forEach((item) => getPaths(item));
|
|
90
|
+
}
|
|
91
|
+
})(sourceTree.docs);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return paths;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -101,9 +101,9 @@ async function getFilePaths(sourceTree) {
|
|
|
101
101
|
* @returns {Promise<string>} - the default export of the ES module
|
|
102
102
|
*/
|
|
103
103
|
async function getJsFileContent(fileName) {
|
|
104
|
-
|
|
104
|
+
const file = await import(path.resolve(`${fileName}?time=${Date.now()}`));
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
return file.default();
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -112,12 +112,12 @@ async function getJsFileContent(fileName) {
|
|
|
112
112
|
* @returns {Promise<object>} the content of the given file as an object
|
|
113
113
|
*/
|
|
114
114
|
async function getYamlFileContent(fileName) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
try {
|
|
116
|
+
const result = await readFileFs(fileName, "utf8");
|
|
117
|
+
return yaml.load(result);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
return Promise.reject(err);
|
|
120
|
+
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
@@ -126,12 +126,12 @@ async function getYamlFileContent(fileName) {
|
|
|
126
126
|
* @returns {Promise<object>} the parsed content of the given file
|
|
127
127
|
*/
|
|
128
128
|
async function getParsedJsonFileContent(fileName) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
try {
|
|
130
|
+
const result = await readFileFs(fileName, "utf8");
|
|
131
|
+
return JSON.parse(result);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
return Promise.reject(err);
|
|
134
|
+
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
@@ -140,12 +140,12 @@ async function getParsedJsonFileContent(fileName) {
|
|
|
140
140
|
* @returns {Promise<string>} the markdown of the given file converted into HTML
|
|
141
141
|
*/
|
|
142
142
|
async function getConvertedMarkdownFileContent(fileName) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
try {
|
|
144
|
+
const result = await readFileFs(fileName, "utf8");
|
|
145
|
+
return Markdown.parse(result);
|
|
146
|
+
} catch (err) {
|
|
147
|
+
return Promise.reject(err);
|
|
148
|
+
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
|
@@ -155,67 +155,67 @@ async function getConvertedMarkdownFileContent(fileName) {
|
|
|
155
155
|
* @returns {Promise<string|object|Array>} content of the given file based on its type
|
|
156
156
|
*/
|
|
157
157
|
export const readFile = async function (fileName) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
158
|
+
switch (true) {
|
|
159
|
+
case [".yaml", ".yml"].includes(path.extname(fileName)):
|
|
160
|
+
{
|
|
161
|
+
try {
|
|
162
|
+
const content = await getYamlFileContent(fileName);
|
|
163
|
+
if (global.state?.fileReadErrors) {
|
|
164
|
+
delete global.state.fileReadErrors[fileName];
|
|
165
|
+
}
|
|
166
|
+
return content;
|
|
167
|
+
} catch (err) {
|
|
168
|
+
markFileReadError(fileName, err);
|
|
169
|
+
log("error", `Error when reading file ${fileName}`, err);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
case helpers.fileIsDocumentationFile(fileName):
|
|
174
|
+
{
|
|
175
|
+
try {
|
|
176
|
+
return await getConvertedMarkdownFileContent(fileName);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
log("error", `Error when reading file ${fileName}`, err);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
case helpers.fileIsDataFile(fileName) &&
|
|
183
|
+
[".js", ".mjs"].includes(path.extname(fileName)):
|
|
184
|
+
{
|
|
185
|
+
try {
|
|
186
|
+
const content = await getJsFileContent(fileName);
|
|
187
|
+
if (global.state?.fileReadErrors) {
|
|
188
|
+
delete global.state.fileReadErrors[fileName];
|
|
189
|
+
}
|
|
190
|
+
return content;
|
|
191
|
+
} catch (err) {
|
|
192
|
+
markFileReadError(fileName, err);
|
|
193
|
+
log("error", `Error when reading file ${fileName}`, err);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
case fileName.endsWith(".json"):
|
|
198
|
+
{
|
|
199
|
+
try {
|
|
200
|
+
const content = await getParsedJsonFileContent(fileName);
|
|
201
|
+
if (global.state?.fileReadErrors) {
|
|
202
|
+
delete global.state.fileReadErrors[fileName];
|
|
203
|
+
}
|
|
204
|
+
return content;
|
|
205
|
+
} catch (err) {
|
|
206
|
+
markFileReadError(fileName, err);
|
|
207
|
+
log("error", `Error when reading file ${fileName}`, err);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
break;
|
|
211
|
+
default: {
|
|
212
|
+
try {
|
|
213
|
+
return await readFileFs(fileName, { encoding: "utf8" });
|
|
214
|
+
} catch (err) {
|
|
215
|
+
log("error", `Error when reading file ${fileName}`, err);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
/**
|
|
@@ -226,25 +226,25 @@ export const readFile = async function (fileName) {
|
|
|
226
226
|
* @returns {Promise} gets resolved with the content of all docs, mocks, schema files
|
|
227
227
|
*/
|
|
228
228
|
export const getFileContents = async function (sourceTree) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
229
|
+
const fileContents = {};
|
|
230
|
+
if (global.state) {
|
|
231
|
+
global.state.fileReadErrors = {};
|
|
232
|
+
}
|
|
233
|
+
const paths = await getFilePaths(sourceTree);
|
|
234
|
+
|
|
235
|
+
if (paths) {
|
|
236
|
+
await Promise.all(
|
|
237
|
+
paths.map(async (fullPath) => {
|
|
238
|
+
try {
|
|
239
|
+
fileContents[fullPath] = await readFile(fullPath.replace(/\0/g, ""));
|
|
240
|
+
} catch (err) {
|
|
241
|
+
return err;
|
|
242
|
+
}
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
return fileContents;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {};
|
|
250
250
|
};
|
package/lib/state/helpers.js
CHANGED
|
@@ -18,55 +18,55 @@ import { EXIT_CODES, MiyagiError } from "../errors.js";
|
|
|
18
18
|
* @returns {Promise<string[]>} an array with file paths
|
|
19
19
|
*/
|
|
20
20
|
async function getFiles(dir, ignores, configPath, type, check) {
|
|
21
|
-
|
|
21
|
+
if (dir === null) return [];
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
try {
|
|
24
|
+
var entries = await readdir(path.join(process.cwd(), dir), {
|
|
25
|
+
withFileTypes: true,
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error.code === "ENOENT") {
|
|
29
|
+
const message = t("srcFolderNotFound")
|
|
30
|
+
.replaceAll("{{directory}}", dir)
|
|
31
|
+
.replaceAll("{{type}}", type)
|
|
32
|
+
.replaceAll("{{config}}", configPath);
|
|
33
|
+
log("error", message);
|
|
34
|
+
throw new MiyagiError(message, {
|
|
35
|
+
code: EXIT_CODES.CONFIG_ERROR,
|
|
36
|
+
logged: true,
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
log("error", error.toString(), error);
|
|
40
|
+
throw new MiyagiError(error.toString(), {
|
|
41
|
+
code: EXIT_CODES.GENERAL_ERROR,
|
|
42
|
+
logged: true,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const files = await Promise.all(
|
|
48
|
+
entries.map(async (entry) => {
|
|
49
|
+
const res = path.resolve(dir, entry.name);
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
if (isNotIgnored(res, ignores)) {
|
|
52
|
+
if (entry.isDirectory() || entry.isSymbolicLink()) {
|
|
53
|
+
return await getFiles(
|
|
54
|
+
path.join(dir, entry.name),
|
|
55
|
+
ignores,
|
|
56
|
+
configPath,
|
|
57
|
+
type,
|
|
58
|
+
check,
|
|
59
|
+
);
|
|
60
|
+
} else {
|
|
61
|
+
return check(res);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
return Array.prototype.concat(...files).filter((file) => file !== null);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -76,16 +76,16 @@ async function getFiles(dir, ignores, configPath, type, check) {
|
|
|
76
76
|
* @returns {boolean} returns true if the given file is not inside any of the given ignoredFolders
|
|
77
77
|
*/
|
|
78
78
|
function isNotIgnored(file, ignoredFolders) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
for (let i = 0; i < ignoredFolders.length; i += 1) {
|
|
80
|
+
if (file.includes(ignoredFolders[i])) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
return true;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export default {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
getFiles,
|
|
90
|
+
isNotIgnored,
|
|
91
91
|
};
|
package/lib/state/index.js
CHANGED
|
@@ -15,43 +15,43 @@ import { getSourceTree } from "./source-tree.js";
|
|
|
15
15
|
* @returns {Promise<object>}
|
|
16
16
|
*/
|
|
17
17
|
export default async function setState(methods) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
18
|
+
if (!global.state) {
|
|
19
|
+
global.state = {
|
|
20
|
+
routes: [],
|
|
21
|
+
fileReadErrors: {},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (methods.sourceTree) {
|
|
26
|
+
global.state.routes = [];
|
|
27
|
+
global.state.sourceTree = getSourceTree();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (methods.fileContents) {
|
|
31
|
+
if (typeof methods.fileContents === "object") {
|
|
32
|
+
global.state.fileContents = methods.fileContents;
|
|
33
|
+
} else {
|
|
34
|
+
global.state.fileContents = await getFileContents(
|
|
35
|
+
global.state.sourceTree,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (methods.partials) {
|
|
41
|
+
global.state.partials = getPartials(global.state.sourceTree);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (methods.menu) {
|
|
45
|
+
global.state.menu = getMenu(global.state.sourceTree);
|
|
46
|
+
global.state.components = getComponents(
|
|
47
|
+
global.state.menu,
|
|
48
|
+
global.config.isBuild,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (methods.css) {
|
|
53
|
+
global.state.css = getCSS(global.state.fileContents);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return global.state;
|
|
57
57
|
}
|