@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.
Files changed (115) hide show
  1. package/README.md +7 -2
  2. package/api/app.js +16 -16
  3. package/api/index.js +263 -262
  4. package/bin/miyagi.js +1 -1
  5. package/dist/css/iframe.css +6 -30
  6. package/frontend/assets/css/iframe/accordion-tabs.css +39 -39
  7. package/frontend/assets/css/iframe/jsontree.js.css +149 -149
  8. package/frontend/assets/css/iframe/prism.css +45 -45
  9. package/frontend/assets/css/iframe/styleguide/colors.css +27 -27
  10. package/frontend/assets/css/iframe/styleguide/fonts.css +23 -23
  11. package/frontend/assets/css/iframe/styleguide/index.css +58 -58
  12. package/frontend/assets/css/iframe/styleguide/spacings.css +10 -10
  13. package/frontend/assets/css/iframe.css +191 -191
  14. package/frontend/assets/css/main/menu/config-switcher.css +21 -21
  15. package/frontend/assets/css/main/menu/config-switchers.css +34 -34
  16. package/frontend/assets/css/main/menu/goto.css +16 -16
  17. package/frontend/assets/css/main/menu/nav.css +49 -49
  18. package/frontend/assets/css/main/menu/search.css +34 -34
  19. package/frontend/assets/css/main/menu/title.css +18 -18
  20. package/frontend/assets/css/main/menu.css +89 -89
  21. package/frontend/assets/css/main/reset.css +47 -47
  22. package/frontend/assets/css/main.css +41 -41
  23. package/frontend/assets/css/shared.css +16 -16
  24. package/frontend/assets/css/tokens.css +108 -107
  25. package/frontend/assets/js/_accordion-tabs.js +392 -392
  26. package/frontend/assets/js/_goto.js +59 -59
  27. package/frontend/assets/js/_iframe-links.js +14 -14
  28. package/frontend/assets/js/_is-triggered.js +3 -3
  29. package/frontend/assets/js/_main.js +369 -369
  30. package/frontend/assets/js/_mock-data.js +8 -8
  31. package/frontend/assets/js/_prism.js +1082 -1081
  32. package/frontend/assets/js/_search.js +186 -186
  33. package/frontend/assets/js/_socket.js +44 -44
  34. package/frontend/assets/js/config-switcher/development-mode.js +38 -38
  35. package/frontend/assets/js/config-switcher/index.js +55 -55
  36. package/frontend/assets/js/config-switcher/text-direction.js +22 -22
  37. package/frontend/assets/js/config-switcher/theme.js +68 -68
  38. package/frontend/assets/js/iframe.build.js +25 -25
  39. package/frontend/assets/js/iframe.js +38 -38
  40. package/frontend/assets/js/jsontree.js +979 -976
  41. package/frontend/assets/js/main.build.js +29 -29
  42. package/frontend/assets/js/main.js +31 -31
  43. package/frontend/assets/js/styleguide/color-converter.js +652 -652
  44. package/frontend/assets/js/styleguide/index.js +100 -100
  45. package/lib/build/index.js +1014 -1020
  46. package/lib/cli/app.js +16 -16
  47. package/lib/cli/component.js +50 -50
  48. package/lib/cli/doctor.js +130 -121
  49. package/lib/cli/drupal-assets.js +163 -157
  50. package/lib/cli/lint.js +196 -196
  51. package/lib/cli/run.js +150 -146
  52. package/lib/config.js +86 -86
  53. package/lib/constants/lint-log-levels.js +6 -6
  54. package/lib/drupal/load-assets-config.js +59 -60
  55. package/lib/drupal/resolve-library-assets.js +132 -141
  56. package/lib/errors.js +20 -20
  57. package/lib/generator/component.js +124 -124
  58. package/lib/generator/mocks.js +156 -156
  59. package/lib/helpers.js +68 -68
  60. package/lib/i18n/en.js +93 -93
  61. package/lib/i18n/index.js +8 -8
  62. package/lib/index.js +13 -13
  63. package/lib/init/args.js +153 -153
  64. package/lib/init/config.js +452 -438
  65. package/lib/init/engines.js +41 -41
  66. package/lib/init/index.js +83 -83
  67. package/lib/init/rendering.js +3 -3
  68. package/lib/init/static.js +90 -90
  69. package/lib/init/twing/cache.js +27 -27
  70. package/lib/init/twing/functions.js +37 -37
  71. package/lib/init/views.js +5 -5
  72. package/lib/logger.js +72 -72
  73. package/lib/mocks/get.js +88 -88
  74. package/lib/mocks/index.js +2 -2
  75. package/lib/mocks/resolve/ref.js +447 -447
  76. package/lib/mocks/resolve/tpl.js +218 -218
  77. package/lib/mocks/resolve.js +154 -154
  78. package/lib/render/helpers/resolve-assets.js +29 -39
  79. package/lib/render/helpers.js +27 -27
  80. package/lib/render/index.js +18 -18
  81. package/lib/render/views/iframe/component.docs.js +50 -50
  82. package/lib/render/views/iframe/component.js +249 -248
  83. package/lib/render/views/iframe/design-tokens/colors.js +38 -38
  84. package/lib/render/views/iframe/design-tokens/index.js +3 -3
  85. package/lib/render/views/iframe/design-tokens/sizes.js +35 -35
  86. package/lib/render/views/iframe/design-tokens/typography.js +37 -37
  87. package/lib/render/views/iframe/docs.js +42 -42
  88. package/lib/render/views/iframe/index.js +28 -28
  89. package/lib/render/views/iframe/variation.js +89 -89
  90. package/lib/render/views/iframe/variation.standalone.js +69 -68
  91. package/lib/render/views/main/component.docs.js +38 -38
  92. package/lib/render/views/main/component.js +55 -55
  93. package/lib/render/views/main/design-tokens.js +38 -38
  94. package/lib/render/views/main/docs.js +33 -33
  95. package/lib/render/views/main/index.js +33 -33
  96. package/lib/state/components.js +99 -99
  97. package/lib/state/css.js +33 -33
  98. package/lib/state/docs.js +72 -72
  99. package/lib/state/file-contents.js +154 -154
  100. package/lib/state/helpers.js +53 -53
  101. package/lib/state/index.js +39 -39
  102. package/lib/state/menu/index.js +202 -202
  103. package/lib/state/menu/structure.js +84 -84
  104. package/lib/state/partials.js +12 -12
  105. package/lib/state/source-tree.js +51 -51
  106. package/lib/styleguide/color-names.js +148 -148
  107. package/lib/styleguide/colors.js +113 -113
  108. package/lib/styleguide/helpers.js +33 -33
  109. package/lib/styleguide/index.js +4 -4
  110. package/lib/styleguide/media-queries.js +18 -18
  111. package/lib/styleguide/spacings.js +22 -22
  112. package/lib/styleguide/typography.js +46 -46
  113. package/lib/validator/mocks.js +110 -83
  114. package/lib/validator/schemas.js +236 -227
  115. package/package.json +118 -117
@@ -13,26 +13,26 @@ import { getMenu as getDocsMenu } from "../docs.js";
13
13
  * @returns {Array} file tree object of the component file in the given directory
14
14
  */
15
15
  function getComponentFiles(directory) {
16
- return directory.children.filter((child) => {
17
- const baseName =
18
- global.config.files.templates.name === "<component>"
19
- ? child.name.replace(`.${global.config.files.templates.extension}`, "")
20
- : global.config.files.templates.name;
21
-
22
- if (helpers.docFileIsIndexFile(child.path)) return true;
23
-
24
- if (helpers.fileIsTemplateFile(child.name)) {
25
- if (
26
- global.config.files.templates.name === "<component>" &&
27
- directory.name === baseName
28
- )
29
- return true;
30
-
31
- if (global.config.files.templates.name === baseName) return true;
32
- }
33
-
34
- return false;
35
- });
16
+ return directory.children.filter((child) => {
17
+ const baseName =
18
+ global.config.files.templates.name === "<component>"
19
+ ? child.name.replace(`.${global.config.files.templates.extension}`, "")
20
+ : global.config.files.templates.name;
21
+
22
+ if (helpers.docFileIsIndexFile(child.path)) return true;
23
+
24
+ if (helpers.fileIsTemplateFile(child.name)) {
25
+ if (
26
+ global.config.files.templates.name === "<component>" &&
27
+ directory.name === baseName
28
+ )
29
+ return true;
30
+
31
+ if (global.config.files.templates.name === baseName) return true;
32
+ }
33
+
34
+ return false;
35
+ });
36
36
  }
37
37
 
38
38
  /**
@@ -40,11 +40,11 @@ function getComponentFiles(directory) {
40
40
  * @returns {boolean} returns true if the given directory has a component file with the same name
41
41
  */
42
42
  function hasComponentFileWithCorrectNameAsChild(directory) {
43
- return (
44
- directory.children &&
45
- directory.children.length &&
46
- getComponentFiles(directory).length > 0
47
- );
43
+ return (
44
+ directory.children &&
45
+ directory.children.length &&
46
+ getComponentFiles(directory).length > 0
47
+ );
48
48
  }
49
49
 
50
50
  /**
@@ -52,38 +52,38 @@ function hasComponentFileWithCorrectNameAsChild(directory) {
52
52
  * @returns {object} adapted file tree object
53
53
  */
54
54
  function getDataForLinkedDirectory(directory) {
55
- const shortPath = helpers.getShortPathFromFullPath(directory.path);
56
- const normalizedShortPath = helpers.normalizeString(shortPath);
57
- const name = directory.name.replaceAll("-", " ");
58
-
59
- return {
60
- type: directory.type,
61
- section: "components",
62
- name,
63
- fullPath: directory.path,
64
- shortPath,
65
- normalizedShortPath,
66
- url: global.config.isBuild
67
- ? `/component-${normalizedShortPath}-embedded.html`
68
- : `/component?file=${shortPath}&embedded=true`,
69
- variations:
70
- directory.variations.map((variation) => {
71
- const normalizedName = helpers.normalizeString(variation.name);
72
-
73
- return {
74
- ...variation,
75
- normalizedName,
76
- parentShortPath: shortPath,
77
- url: global.config.isBuild
78
- ? `component-${normalizedShortPath}-variation-${normalizedName}-embedded.html`
79
- : `/component?file=${shortPath}&variation=${encodeURIComponent(
80
- variation.name,
81
- )}&embedded=true`,
82
- };
83
- }) || [],
84
- index: directory.index,
85
- id: normalizedShortPath,
86
- };
55
+ const shortPath = helpers.getShortPathFromFullPath(directory.path);
56
+ const normalizedShortPath = helpers.normalizeString(shortPath);
57
+ const name = directory.name.replaceAll("-", " ");
58
+
59
+ return {
60
+ type: directory.type,
61
+ section: "components",
62
+ name,
63
+ fullPath: directory.path,
64
+ shortPath,
65
+ normalizedShortPath,
66
+ url: global.config.isBuild
67
+ ? `/component-${normalizedShortPath}-embedded.html`
68
+ : `/component?file=${shortPath}&embedded=true`,
69
+ variations:
70
+ directory.variations.map((variation) => {
71
+ const normalizedName = helpers.normalizeString(variation.name);
72
+
73
+ return {
74
+ ...variation,
75
+ normalizedName,
76
+ parentShortPath: shortPath,
77
+ url: global.config.isBuild
78
+ ? `component-${normalizedShortPath}-variation-${normalizedName}-embedded.html`
79
+ : `/component?file=${shortPath}&variation=${encodeURIComponent(
80
+ variation.name,
81
+ )}&embedded=true`,
82
+ };
83
+ }) || [],
84
+ index: directory.index,
85
+ id: normalizedShortPath,
86
+ };
87
87
  }
88
88
 
89
89
  /**
@@ -91,26 +91,26 @@ function getDataForLinkedDirectory(directory) {
91
91
  * @returns {object}
92
92
  */
93
93
  function getDataForDocumentationFile(file) {
94
- const shortPath = helpers
95
- .getShortPathFromFullPath(file.path)
96
- .replace(".md", "");
97
- const normalizedShortPath = helpers.normalizeString(shortPath);
98
-
99
- return {
100
- type: file.type,
101
- name: path
102
- .basename(file.name, ".md")
103
- .replaceAll("-", " ")
104
- .replaceAll("_", " "),
105
- fullPath: file.path,
106
- shortPath,
107
- normalizedShortPath,
108
- url: global.config.isBuild
109
- ? `/component-${normalizedShortPath}-embedded.html`
110
- : `/component?file=${shortPath}&embedded=true`,
111
- index: file.index,
112
- id: normalizedShortPath,
113
- };
94
+ const shortPath = helpers
95
+ .getShortPathFromFullPath(file.path)
96
+ .replace(".md", "");
97
+ const normalizedShortPath = helpers.normalizeString(shortPath);
98
+
99
+ return {
100
+ type: file.type,
101
+ name: path
102
+ .basename(file.name, ".md")
103
+ .replaceAll("-", " ")
104
+ .replaceAll("_", " "),
105
+ fullPath: file.path,
106
+ shortPath,
107
+ normalizedShortPath,
108
+ url: global.config.isBuild
109
+ ? `/component-${normalizedShortPath}-embedded.html`
110
+ : `/component?file=${shortPath}&embedded=true`,
111
+ index: file.index,
112
+ id: normalizedShortPath,
113
+ };
114
114
  }
115
115
 
116
116
  /**
@@ -118,19 +118,19 @@ function getDataForDocumentationFile(file) {
118
118
  * @returns {object} adapted file tree object
119
119
  */
120
120
  function getDataForDirectory(directory) {
121
- const shortPath = path.relative(
122
- path.join(process.cwd(), global.config.components.folder),
123
- directory.path,
124
- );
125
-
126
- return {
127
- type: directory.type,
128
- name: directory.name.replaceAll("-", " "),
129
- fullPath: directory.path,
130
- shortPath,
131
- index: directory.index,
132
- id: helpers.normalizeString(shortPath),
133
- };
121
+ const shortPath = path.relative(
122
+ path.join(process.cwd(), global.config.components.folder),
123
+ directory.path,
124
+ );
125
+
126
+ return {
127
+ type: directory.type,
128
+ name: directory.name.replaceAll("-", " "),
129
+ fullPath: directory.path,
130
+ shortPath,
131
+ index: directory.index,
132
+ id: helpers.normalizeString(shortPath),
133
+ };
134
134
  }
135
135
 
136
136
  /**
@@ -138,15 +138,15 @@ function getDataForDirectory(directory) {
138
138
  * @returns {object} adapted file tree object
139
139
  */
140
140
  function restructureDirectory(directory) {
141
- let item;
141
+ let item;
142
142
 
143
- if (hasComponentFileWithCorrectNameAsChild(directory)) {
144
- item = getDataForLinkedDirectory(directory);
145
- } else {
146
- item = getDataForDirectory(directory);
147
- }
143
+ if (hasComponentFileWithCorrectNameAsChild(directory)) {
144
+ item = getDataForLinkedDirectory(directory);
145
+ } else {
146
+ item = getDataForDirectory(directory);
147
+ }
148
148
 
149
- return item;
149
+ return item;
150
150
  }
151
151
 
152
152
  /**
@@ -154,7 +154,7 @@ function restructureDirectory(directory) {
154
154
  * @returns {boolean} returns true if the given file tree object has children
155
155
  */
156
156
  function hasChildren(item) {
157
- return item.children && item.children.length > 0;
157
+ return item.children && item.children.length > 0;
158
158
  }
159
159
 
160
160
  /**
@@ -162,114 +162,114 @@ function hasChildren(item) {
162
162
  * @returns {object[]} array with adapted menu items
163
163
  */
164
164
  export const getMenu = function (sourceTree) {
165
- const srcStructure = getSourceStructure();
166
- const arr = [];
167
- let componentsMenu;
168
-
169
- (function restructure(structure, array) {
170
- for (const item of structure) {
171
- if (item.type === "directory") {
172
- const restructured = restructureDirectory(item);
173
-
174
- if (hasChildren(item)) {
175
- restructured.children = [];
176
- restructure(item.children, restructured.children);
177
-
178
- if (restructured.children.length === 0) {
179
- delete restructured.children;
180
- }
181
-
182
- if (restructured.children) {
183
- restructured.children.sort(function (a, b) {
184
- const nameA = a.name.toLowerCase();
185
- const nameB = b.name.toLowerCase();
186
-
187
- if (nameA < nameB) return -1;
188
- if (nameA > nameB) return 1;
189
-
190
- return 0;
191
- });
192
- }
193
- }
194
- array.push(restructured);
195
- } else if (
196
- helpers.fileIsDocumentationFile(item.path) &&
197
- !item.path.endsWith("index.md") &&
198
- !item.path.endsWith("README.md") &&
199
- path.basename(item.path, ".md") !==
200
- path.dirname(item.path).split("/")[
201
- path.dirname(item.path).split("/").length - 1
202
- ]
203
- ) {
204
- array.push(getDataForDocumentationFile(item));
205
- }
206
- }
207
- })(srcStructure, arr);
208
-
209
- if (arr.length > 0) {
210
- componentsMenu = {
211
- topLevel: true,
212
- section: "components",
213
- name: "components",
214
- type: "directory",
215
- shortPath: "components",
216
- file: null,
217
- children: arr,
218
- id: "components",
219
- };
220
- }
221
-
222
- const docsMenu = getDocsMenu(sourceTree.docs);
223
- const designTokensMenu = getDesignTokensMenu();
224
-
225
- if (!docsMenu && !designTokensMenu && componentsMenu)
226
- return componentsMenu.children;
227
-
228
- const menus = [];
229
- if (designTokensMenu) menus.push(designTokensMenu);
230
- if (componentsMenu) menus.push(componentsMenu);
231
- if (docsMenu) menus.push(docsMenu);
232
-
233
- return menus;
165
+ const srcStructure = getSourceStructure();
166
+ const arr = [];
167
+ let componentsMenu;
168
+
169
+ (function restructure(structure, array) {
170
+ for (const item of structure) {
171
+ if (item.type === "directory") {
172
+ const restructured = restructureDirectory(item);
173
+
174
+ if (hasChildren(item)) {
175
+ restructured.children = [];
176
+ restructure(item.children, restructured.children);
177
+
178
+ if (restructured.children.length === 0) {
179
+ delete restructured.children;
180
+ }
181
+
182
+ if (restructured.children) {
183
+ restructured.children.sort(function (a, b) {
184
+ const nameA = a.name.toLowerCase();
185
+ const nameB = b.name.toLowerCase();
186
+
187
+ if (nameA < nameB) return -1;
188
+ if (nameA > nameB) return 1;
189
+
190
+ return 0;
191
+ });
192
+ }
193
+ }
194
+ array.push(restructured);
195
+ } else if (
196
+ helpers.fileIsDocumentationFile(item.path) &&
197
+ !item.path.endsWith("index.md") &&
198
+ !item.path.endsWith("README.md") &&
199
+ path.basename(item.path, ".md") !==
200
+ path.dirname(item.path).split("/")[
201
+ path.dirname(item.path).split("/").length - 1
202
+ ]
203
+ ) {
204
+ array.push(getDataForDocumentationFile(item));
205
+ }
206
+ }
207
+ })(srcStructure, arr);
208
+
209
+ if (arr.length > 0) {
210
+ componentsMenu = {
211
+ topLevel: true,
212
+ section: "components",
213
+ name: "components",
214
+ type: "directory",
215
+ shortPath: "components",
216
+ file: null,
217
+ children: arr,
218
+ id: "components",
219
+ };
220
+ }
221
+
222
+ const docsMenu = getDocsMenu(sourceTree.docs);
223
+ const designTokensMenu = getDesignTokensMenu();
224
+
225
+ if (!docsMenu && !designTokensMenu && componentsMenu)
226
+ return componentsMenu.children;
227
+
228
+ const menus = [];
229
+ if (designTokensMenu) menus.push(designTokensMenu);
230
+ if (componentsMenu) menus.push(componentsMenu);
231
+ if (docsMenu) menus.push(docsMenu);
232
+
233
+ return menus;
234
234
  };
235
235
 
236
236
  /**
237
237
  * @returns {object}
238
238
  */
239
239
  function getDesignTokensMenu() {
240
- if (global.config.assets.customProperties.files.length === 0) return null;
241
-
242
- return {
243
- topLevel: true,
244
- name: "Design Tokens",
245
- id: "design-tokens",
246
- type: "directory",
247
- shortPath: "design-tokens",
248
- children: [
249
- {
250
- section: "design-tokens",
251
- type: "file",
252
- name: "colors",
253
- url: global.config.isBuild
254
- ? "iframe-design-tokens-colors.html"
255
- : "/iframe/design-tokens/colors",
256
- },
257
- {
258
- section: "design-tokens",
259
- type: "file",
260
- name: "sizes",
261
- url: global.config.isBuild
262
- ? "iframe-design-tokens-sizes.html"
263
- : "/iframe/design-tokens/sizes",
264
- },
265
- {
266
- section: "design-tokens",
267
- type: "file",
268
- name: "typography",
269
- url: global.config.isBuild
270
- ? "iframe-design-tokens-typography.html"
271
- : "/iframe/design-tokens/typography",
272
- },
273
- ],
274
- };
240
+ if (global.config.assets.customProperties.files.length === 0) return null;
241
+
242
+ return {
243
+ topLevel: true,
244
+ name: "Design Tokens",
245
+ id: "design-tokens",
246
+ type: "directory",
247
+ shortPath: "design-tokens",
248
+ children: [
249
+ {
250
+ section: "design-tokens",
251
+ type: "file",
252
+ name: "colors",
253
+ url: global.config.isBuild
254
+ ? "iframe-design-tokens-colors.html"
255
+ : "/iframe/design-tokens/colors",
256
+ },
257
+ {
258
+ section: "design-tokens",
259
+ type: "file",
260
+ name: "sizes",
261
+ url: global.config.isBuild
262
+ ? "iframe-design-tokens-sizes.html"
263
+ : "/iframe/design-tokens/sizes",
264
+ },
265
+ {
266
+ section: "design-tokens",
267
+ type: "file",
268
+ name: "typography",
269
+ url: global.config.isBuild
270
+ ? "iframe-design-tokens-typography.html"
271
+ : "/iframe/design-tokens/typography",
272
+ },
273
+ ],
274
+ };
275
275
  }
@@ -14,46 +14,46 @@ import * as helpers from "../../helpers.js";
14
14
  * @returns {Array} all valid variation objects
15
15
  */
16
16
  function getAllValidVariations(json, fullPath) {
17
- let arr = [];
18
-
19
- if (json) {
20
- const variations = json.$variants;
21
- const rootData = helpers.removeInternalKeys(json);
22
-
23
- if (Object.keys(rootData).length > 0 && !json.$hidden) {
24
- arr.push({
25
- name: json.$name || config.defaultVariationName,
26
- data: rootData,
27
- });
28
- }
29
-
30
- if (variations) {
31
- for (const [i, variation] of variations.entries()) {
32
- const variationData = helpers.removeInternalKeys(variation);
33
- if (variation.$name) {
34
- arr.push({
35
- name: variation.$name,
36
- data: variationData,
37
- });
38
- } else if (fullPath) {
39
- const shortPath = helpers.getShortPathFromFullPath(fullPath);
40
- log(
41
- "warn",
42
- t("noNameSetForVariation")
43
- .replace("{{i}}", i)
44
- .replace("{{file}}", shortPath),
45
- );
46
- }
47
- }
48
- }
49
- } else {
50
- arr.push({
51
- name: config.defaultVariationName,
52
- data: {},
53
- });
54
- }
55
-
56
- return arr;
17
+ let arr = [];
18
+
19
+ if (json) {
20
+ const variations = json.$variants;
21
+ const rootData = helpers.removeInternalKeys(json);
22
+
23
+ if (Object.keys(rootData).length > 0 && !json.$hidden) {
24
+ arr.push({
25
+ name: json.$name || config.defaultVariationName,
26
+ data: rootData,
27
+ });
28
+ }
29
+
30
+ if (variations) {
31
+ for (const [i, variation] of variations.entries()) {
32
+ const variationData = helpers.removeInternalKeys(variation);
33
+ if (variation.$name) {
34
+ arr.push({
35
+ name: variation.$name,
36
+ data: variationData,
37
+ });
38
+ } else if (fullPath) {
39
+ const shortPath = helpers.getShortPathFromFullPath(fullPath);
40
+ log(
41
+ "warn",
42
+ t("noNameSetForVariation")
43
+ .replace("{{i}}", i)
44
+ .replace("{{file}}", shortPath),
45
+ );
46
+ }
47
+ }
48
+ }
49
+ } else {
50
+ arr.push({
51
+ name: config.defaultVariationName,
52
+ data: {},
53
+ });
54
+ }
55
+
56
+ return arr;
57
57
  }
58
58
 
59
59
  /**
@@ -61,13 +61,13 @@ function getAllValidVariations(json, fullPath) {
61
61
  * @returns {object[]} all valid variations for the given mock file
62
62
  */
63
63
  function getData(mockFilePath) {
64
- let result;
64
+ let result;
65
65
 
66
- if (mockFilePath && global.state.fileContents[mockFilePath]) {
67
- result = global.state.fileContents[mockFilePath];
68
- }
66
+ if (mockFilePath && global.state.fileContents[mockFilePath]) {
67
+ result = global.state.fileContents[mockFilePath];
68
+ }
69
69
 
70
- return getAllValidVariations(result, mockFilePath);
70
+ return getAllValidVariations(result, mockFilePath);
71
71
  }
72
72
 
73
73
  /**
@@ -75,27 +75,27 @@ function getData(mockFilePath) {
75
75
  * @returns {Array} all variations for the mock file of the given file tree object
76
76
  */
77
77
  function getVariations(obj) {
78
- const { mocks } = global.config.files;
79
- const tplChild = obj.children.find(
80
- (o) =>
81
- o.name ===
82
- `${helpers.getResolvedFileName(
83
- global.config.files.templates.name,
84
- obj.name,
85
- )}.${global.config.files.templates.extension}`,
86
- );
87
- const jsonChild = obj.children.find((o) =>
88
- [
89
- `${mocks.name}.${mocks.extension[0]}`,
90
- `${mocks.name}.${mocks.extension[1]}`,
91
- ].includes(o.name),
92
- );
93
-
94
- if (tplChild) {
95
- return getData(jsonChild ? jsonChild.path : null);
96
- }
97
-
98
- return [];
78
+ const { mocks } = global.config.files;
79
+ const tplChild = obj.children.find(
80
+ (o) =>
81
+ o.name ===
82
+ `${helpers.getResolvedFileName(
83
+ global.config.files.templates.name,
84
+ obj.name,
85
+ )}.${global.config.files.templates.extension}`,
86
+ );
87
+ const jsonChild = obj.children.find((o) =>
88
+ [
89
+ `${mocks.name}.${mocks.extension[0]}`,
90
+ `${mocks.name}.${mocks.extension[1]}`,
91
+ ].includes(o.name),
92
+ );
93
+
94
+ if (tplChild) {
95
+ return getData(jsonChild ? jsonChild.path : null);
96
+ }
97
+
98
+ return [];
99
99
  }
100
100
 
101
101
  /**
@@ -103,14 +103,14 @@ function getVariations(obj) {
103
103
  * @returns {object} the updated object
104
104
  */
105
105
  function updateSourceObject(obj) {
106
- const o = { ...obj };
106
+ const o = { ...obj };
107
107
 
108
- if (o.children) {
109
- o.variations = getVariations(o);
110
- o.children = o.children.map((child) => updateSourceObject(child));
111
- }
108
+ if (o.children) {
109
+ o.variations = getVariations(o);
110
+ o.children = o.children.map((child) => updateSourceObject(child));
111
+ }
112
112
 
113
- return o;
113
+ return o;
114
114
  }
115
115
 
116
116
  /**
@@ -121,26 +121,26 @@ function updateSourceObject(obj) {
121
121
  * @returns {object} the updated object
122
122
  */
123
123
  function addIndices(obj, index) {
124
- const o = { ...obj };
125
- o.index = index;
124
+ const o = { ...obj };
125
+ o.index = index;
126
126
 
127
- if (o.children) {
128
- o.children = o.children.map((child) => {
129
- delete child.size;
130
- return addIndices(child, child.type === "directory" ? index + 1 : index);
131
- });
132
- }
127
+ if (o.children) {
128
+ o.children = o.children.map((child) => {
129
+ delete child.size;
130
+ return addIndices(child, child.type === "directory" ? index + 1 : index);
131
+ });
132
+ }
133
133
 
134
- return o;
134
+ return o;
135
135
  }
136
136
 
137
137
  /**
138
138
  * @returns {object}
139
139
  */
140
140
  export default function setMenuStructure() {
141
- let result = updateSourceObject(global.state.sourceTree.components);
141
+ let result = updateSourceObject(global.state.sourceTree.components);
142
142
 
143
- result = addIndices(result, -1);
143
+ result = addIndices(result, -1);
144
144
 
145
- return result && result.children ? result.children : [];
145
+ return result && result.children ? result.children : [];
146
146
  }