@hitachivantara/app-shell-vite-plugin 1.10.4 → 1.10.6
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/dist/vite-generate-base-plugin.js +0 -9
- package/package.json +6 -6
- package/dist/tests/automatic-utils.test.d.ts +0 -1
- package/dist/tests/automatic-utils.test.js +0 -446
- package/dist/tests/config-utils.test.d.ts +0 -1
- package/dist/tests/config-utils.test.js +0 -143
- package/dist/tests/mocks/path.mock.d.ts +0 -4
- package/dist/tests/mocks/path.mock.js +0 -5
- package/dist/tests/vite-configuration-processor-plugin.test.d.ts +0 -1
- package/dist/tests/vite-configuration-processor-plugin.test.js +0 -71
- package/dist/tests/vite-crossorigin-fix-plugin.test.d.ts +0 -1
- package/dist/tests/vite-crossorigin-fix-plugin.test.js +0 -103
- package/dist/tests/vite-generate-base-plugin.test.d.ts +0 -1
- package/dist/tests/vite-generate-base-plugin.test.js +0 -11
- package/dist/tests/vite-metadata-plugin.test.d.ts +0 -1
- package/dist/tests/vite-metadata-plugin.test.js +0 -47
|
@@ -36,15 +36,6 @@ export default function generateBaseTag(appShellConfig, generateEmptyShell) {
|
|
|
36
36
|
},
|
|
37
37
|
injectTo: "head-prepend",
|
|
38
38
|
},
|
|
39
|
-
{
|
|
40
|
-
tag: "link",
|
|
41
|
-
injectTo: "head-prepend",
|
|
42
|
-
attrs: {
|
|
43
|
-
rel: "preload",
|
|
44
|
-
as: "image",
|
|
45
|
-
href: "./icons/icons.svg",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
39
|
],
|
|
49
40
|
}),
|
|
50
41
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/app-shell-vite-plugin",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Hitachi Vantara UI Kit Team",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"@emotion/cache": "^11.11.0",
|
|
22
22
|
"@emotion/react": "^11.11.1",
|
|
23
23
|
"@hitachivantara/app-shell-services": "^1.1.3",
|
|
24
|
-
"@hitachivantara/app-shell-shared": "^1.7.
|
|
25
|
-
"@hitachivantara/app-shell-ui": "^1.
|
|
26
|
-
"@hitachivantara/uikit-react-icons": "^5.16.
|
|
27
|
-
"@hitachivantara/uikit-react-shared": "^5.5.
|
|
24
|
+
"@hitachivantara/app-shell-shared": "^1.7.11",
|
|
25
|
+
"@hitachivantara/app-shell-ui": "^1.14.0",
|
|
26
|
+
"@hitachivantara/uikit-react-icons": "^5.16.9",
|
|
27
|
+
"@hitachivantara/uikit-react-shared": "^5.5.9",
|
|
28
28
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
29
29
|
"@rollup/plugin-json": "^6.0.0",
|
|
30
30
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
},
|
|
60
60
|
"./package.json": "./package.json"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "6d8da4ec057c2815bbf32ca60f9464d82443ab8f"
|
|
63
63
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
// @ts-expect-error no types
|
|
2
|
-
import mock from "mock-fs";
|
|
3
|
-
import { expect } from "vitest";
|
|
4
|
-
import { applyAutomaticMenu, applyAutomaticViewsAndRoutes, mapFolderIndexFilesToRoutes, } from "../automatic-utils";
|
|
5
|
-
describe.skip("test automatic utils", () => {
|
|
6
|
-
const pagesFolderContent = {
|
|
7
|
-
"/dummy/path/app/src/pages": {},
|
|
8
|
-
"/dummy/path/app/src/pages/Page1": {
|
|
9
|
-
"index.tsx": "dummy content",
|
|
10
|
-
},
|
|
11
|
-
"/dummy/path/app/src/pages/Page2": {
|
|
12
|
-
"something.else": "dummy content",
|
|
13
|
-
},
|
|
14
|
-
"/dummy/path/app/src/pages/Page3": {
|
|
15
|
-
"index.tsx": "dummy content",
|
|
16
|
-
},
|
|
17
|
-
"/dummy/path/app/src/pages/Page4": {
|
|
18
|
-
/** empty directory */
|
|
19
|
-
},
|
|
20
|
-
"/dummy/path/app/src/pages/Page5/$id": {
|
|
21
|
-
"index.tsx": "dummy content",
|
|
22
|
-
},
|
|
23
|
-
"/dummy/path/app/src/pages/Page5/$id/Page5_1": {
|
|
24
|
-
"index.tsx": "dummy content",
|
|
25
|
-
},
|
|
26
|
-
"/dummy/path/app/src/pages/Page5/$id/Page5_1/$name": {
|
|
27
|
-
/** empty directory */
|
|
28
|
-
},
|
|
29
|
-
"/dummy/path/app/src/pages/Page5/$id/Page5_1/$name/Page5_2": {
|
|
30
|
-
"index.tsx": "dummy content",
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
const noIndexFilesInPagesFolderContent = {
|
|
34
|
-
"/dummy/path/app/src/pages": {},
|
|
35
|
-
"/dummy/path/app/src/pages/Page3": {
|
|
36
|
-
"something.else": "dummy content",
|
|
37
|
-
},
|
|
38
|
-
"/dummy/path/app/src/pages/Page4": {
|
|
39
|
-
/** empty directory */
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
describe("test `mapFolderIndexFilesToRoutes` method", () => {
|
|
43
|
-
afterEach(() => {
|
|
44
|
-
mock.restore();
|
|
45
|
-
});
|
|
46
|
-
it("should return an empty array when resolved views folder does not exist", () => {
|
|
47
|
-
const root = "/some/other/root";
|
|
48
|
-
const viewsFolder = "src/pages";
|
|
49
|
-
mock(noIndexFilesInPagesFolderContent);
|
|
50
|
-
expect(mapFolderIndexFilesToRoutes(root, viewsFolder)).toEqual([]);
|
|
51
|
-
});
|
|
52
|
-
it("should return an empty array when there are no index files in the resolved views folder", () => {
|
|
53
|
-
const root = "/dummy/path/app";
|
|
54
|
-
const viewsFolder = "src/pages";
|
|
55
|
-
mock(noIndexFilesInPagesFolderContent);
|
|
56
|
-
expect(mapFolderIndexFilesToRoutes(root, viewsFolder)).toEqual([]);
|
|
57
|
-
});
|
|
58
|
-
test.each([
|
|
59
|
-
["/dummy/path/app", "src/pages"],
|
|
60
|
-
["/dummy/path/app", "src/pages/"],
|
|
61
|
-
["/dummy/path/app", "/src/pages/"],
|
|
62
|
-
["/dummy/path/app", "/src/pages"],
|
|
63
|
-
])("should return all mapped main view configs and corresponding modules", (viewsFolderPath, viewsFolder) => {
|
|
64
|
-
mock(pagesFolderContent);
|
|
65
|
-
expect(mapFolderIndexFilesToRoutes(viewsFolderPath, viewsFolder)).toEqual([
|
|
66
|
-
{
|
|
67
|
-
viewConfig: {
|
|
68
|
-
bundle: "@self/pages/Page1.js",
|
|
69
|
-
route: "/page1",
|
|
70
|
-
},
|
|
71
|
-
module: "src/pages/Page1",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
viewConfig: {
|
|
75
|
-
bundle: "@self/pages/Page3.js",
|
|
76
|
-
route: "/page3",
|
|
77
|
-
},
|
|
78
|
-
module: "src/pages/Page3",
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
viewConfig: {
|
|
82
|
-
bundle: "@self/pages/Page5/_id/Page5_1/_name/Page5_2.js",
|
|
83
|
-
route: "/page5/:id/page5_1/:name/page5_2",
|
|
84
|
-
},
|
|
85
|
-
module: "src/pages/Page5/$id/Page5_1/$name/Page5_2",
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
viewConfig: {
|
|
89
|
-
bundle: "@self/pages/Page5/_id/Page5_1.js",
|
|
90
|
-
route: "/page5/:id/page5_1",
|
|
91
|
-
},
|
|
92
|
-
module: "src/pages/Page5/$id/Page5_1",
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
viewConfig: {
|
|
96
|
-
bundle: "@self/pages/Page5/_id.js",
|
|
97
|
-
route: "/page5/:id",
|
|
98
|
-
},
|
|
99
|
-
module: "src/pages/Page5/$id",
|
|
100
|
-
},
|
|
101
|
-
]);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe("test `applyAutomaticMenu` method", () => {
|
|
105
|
-
it("should create correct menu labels for simple routes", () => {
|
|
106
|
-
const config = {
|
|
107
|
-
mainPanel: {
|
|
108
|
-
views: [
|
|
109
|
-
{ bundle: "@self/pages/Page1.js", route: "/page1" },
|
|
110
|
-
{ bundle: "@self/pages/Page2.js", route: "/page2" },
|
|
111
|
-
{ bundle: "@self/pages/helloToWorld.js", route: "/hello" },
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
applyAutomaticMenu(config);
|
|
116
|
-
const expectedMenu = [
|
|
117
|
-
{ label: "Page1", target: "/page1" },
|
|
118
|
-
{ label: "Page2", target: "/page2" },
|
|
119
|
-
{ label: "Hello To World", target: "/hello" },
|
|
120
|
-
];
|
|
121
|
-
expect(config.menu).toEqual(expectedMenu);
|
|
122
|
-
});
|
|
123
|
-
it("should handle nested routes correctly", () => {
|
|
124
|
-
const config = {
|
|
125
|
-
mainPanel: {
|
|
126
|
-
views: [
|
|
127
|
-
{ bundle: "@self/pages/Section/Page1.js", route: "/section/page1" },
|
|
128
|
-
{ bundle: "@self/pages/Section/Page2.js", route: "/section/page2" },
|
|
129
|
-
{
|
|
130
|
-
bundle: "@self/pages/Planets/helloToEarth.js",
|
|
131
|
-
route: "/planets/earth",
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
bundle: "@self/pages/Planets/HelloToMars.js",
|
|
135
|
-
route: "/planets/mars",
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
bundle: "@self/pages/someOtherFolder/ToImportantStuff.js",
|
|
139
|
-
route: "/other/important",
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
bundle: "@self/pages/SomeOtherFolder/thisIsOnTheSameMenu.js",
|
|
143
|
-
route: "/other/same",
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
applyAutomaticMenu(config);
|
|
149
|
-
const expectedMenu = [
|
|
150
|
-
{
|
|
151
|
-
label: "Section",
|
|
152
|
-
submenus: [
|
|
153
|
-
{ label: "Page1", target: "/section/page1" },
|
|
154
|
-
{ label: "Page2", target: "/section/page2" },
|
|
155
|
-
],
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
label: "Planets",
|
|
159
|
-
submenus: [
|
|
160
|
-
{ label: "Hello To Earth", target: "/planets/earth" },
|
|
161
|
-
{ label: "Hello To Mars", target: "/planets/mars" },
|
|
162
|
-
],
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
label: "Some Other Folder",
|
|
166
|
-
submenus: [
|
|
167
|
-
{ label: "To Important Stuff", target: "/other/important" },
|
|
168
|
-
{ label: "This Is On The Same Menu", target: "/other/same" },
|
|
169
|
-
],
|
|
170
|
-
},
|
|
171
|
-
];
|
|
172
|
-
expect(config.menu).toEqual(expectedMenu);
|
|
173
|
-
});
|
|
174
|
-
it("should skip dynamic routes", () => {
|
|
175
|
-
const config = {
|
|
176
|
-
mainPanel: {
|
|
177
|
-
views: [
|
|
178
|
-
{ bundle: "@self/pages/Page1.js", route: "/page1" },
|
|
179
|
-
{ bundle: "@self/pages/Page2/:id.js", route: "/page2/:id" },
|
|
180
|
-
{ bundle: "@self/pages/Page3.js", route: "/page3" },
|
|
181
|
-
],
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
applyAutomaticMenu(config);
|
|
185
|
-
const expectedMenu = [
|
|
186
|
-
{ label: "Page1", target: "/page1" },
|
|
187
|
-
// Note: Page2 is skipped because it's a dynamic route
|
|
188
|
-
{ label: "Page3", target: "/page3" },
|
|
189
|
-
];
|
|
190
|
-
expect(config.menu).toEqual(expectedMenu);
|
|
191
|
-
});
|
|
192
|
-
it("should handle special characters and capitalization in routes", () => {
|
|
193
|
-
const config = {
|
|
194
|
-
mainPanel: {
|
|
195
|
-
views: [
|
|
196
|
-
{
|
|
197
|
-
bundle: "@self/pages/lowerUpper/Look🙄ingAbóve/SomeSpÉcialPage.js",
|
|
198
|
-
route: "/l1/l2/someSpecialPage",
|
|
199
|
-
},
|
|
200
|
-
],
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
applyAutomaticMenu(config);
|
|
204
|
-
const expectedMenu = [
|
|
205
|
-
{
|
|
206
|
-
label: "Lower Upper",
|
|
207
|
-
submenus: [
|
|
208
|
-
{
|
|
209
|
-
label: "Look🙄ing Abóve",
|
|
210
|
-
submenus: [
|
|
211
|
-
{
|
|
212
|
-
label: "Some SpÉcial Page",
|
|
213
|
-
target: "/l1/l2/someSpecialPage",
|
|
214
|
-
},
|
|
215
|
-
],
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
},
|
|
219
|
-
];
|
|
220
|
-
expect(config.menu).toEqual(expectedMenu);
|
|
221
|
-
});
|
|
222
|
-
it("should return undefined for empty views", () => {
|
|
223
|
-
const config = {
|
|
224
|
-
mainPanel: {
|
|
225
|
-
views: [],
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
applyAutomaticMenu(config);
|
|
229
|
-
expect(config.menu).toBe(undefined);
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
describe("test applyAutomaticViewsAndRoutes", () => {
|
|
233
|
-
const selfAppName = "@hv-tests/some-app";
|
|
234
|
-
const root = "/dummy/path/app";
|
|
235
|
-
const viewsFolder = "src/pages";
|
|
236
|
-
afterEach(() => {
|
|
237
|
-
mock.restore();
|
|
238
|
-
});
|
|
239
|
-
it("should return an empty array when there are neither automatic or manual views", () => {
|
|
240
|
-
mock(noIndexFilesInPagesFolderContent);
|
|
241
|
-
const config = {};
|
|
242
|
-
const result = applyAutomaticViewsAndRoutes(config, selfAppName, root, viewsFolder);
|
|
243
|
-
expect(result.length).toEqual(0);
|
|
244
|
-
expect(config.mainPanel?.views?.length ?? 0).toBe(0);
|
|
245
|
-
});
|
|
246
|
-
it("should return an empty array when there are no automatic views and keep the manual ones", () => {
|
|
247
|
-
mock(noIndexFilesInPagesFolderContent);
|
|
248
|
-
const config = {
|
|
249
|
-
mainPanel: {
|
|
250
|
-
views: [
|
|
251
|
-
{ bundle: "@self/pages/Home.js", route: "/" },
|
|
252
|
-
{ bundle: "@hv-tests/some-app/pages/Page0.js", route: "/page0" },
|
|
253
|
-
{ bundle: "@self/pages/Other.js", route: "/some-path" },
|
|
254
|
-
{
|
|
255
|
-
bundle: "@hv-tests/other-app/pages/HelloFromOther.js",
|
|
256
|
-
route: "/other",
|
|
257
|
-
},
|
|
258
|
-
],
|
|
259
|
-
},
|
|
260
|
-
};
|
|
261
|
-
const result = applyAutomaticViewsAndRoutes(config, selfAppName, root, viewsFolder);
|
|
262
|
-
expect(result.length).toEqual(0);
|
|
263
|
-
expect(config.mainPanel?.views?.length).toEqual(4);
|
|
264
|
-
expect(config.mainPanel?.views).toEqual(expect.arrayContaining([
|
|
265
|
-
{ bundle: "@self/pages/Home.js", route: "/" },
|
|
266
|
-
{ bundle: "@hv-tests/some-app/pages/Page0.js", route: "/page0" },
|
|
267
|
-
{ bundle: "@self/pages/Other.js", route: "/some-path" },
|
|
268
|
-
{
|
|
269
|
-
bundle: "@hv-tests/other-app/pages/HelloFromOther.js",
|
|
270
|
-
route: "/other",
|
|
271
|
-
},
|
|
272
|
-
]));
|
|
273
|
-
});
|
|
274
|
-
it("should return modules of found automatic views and add them to the configuration when there are no manual views", () => {
|
|
275
|
-
mock(pagesFolderContent);
|
|
276
|
-
const config = {};
|
|
277
|
-
const result = applyAutomaticViewsAndRoutes(config, selfAppName, root, viewsFolder);
|
|
278
|
-
expect(result.length).toEqual(5);
|
|
279
|
-
expect(result).toEqual(expect.arrayContaining([
|
|
280
|
-
"src/pages/Page1",
|
|
281
|
-
"src/pages/Page3",
|
|
282
|
-
"src/pages/Page5/$id/Page5_1/$name/Page5_2",
|
|
283
|
-
"src/pages/Page5/$id/Page5_1",
|
|
284
|
-
"src/pages/Page5/$id",
|
|
285
|
-
]));
|
|
286
|
-
expect(config.mainPanel?.views?.length).toEqual(5);
|
|
287
|
-
expect(config.mainPanel?.views).toEqual(expect.arrayContaining([
|
|
288
|
-
{ bundle: "@self/pages/Page1.js", route: "/page1" },
|
|
289
|
-
{ bundle: "@self/pages/Page3.js", route: "/page3" },
|
|
290
|
-
{
|
|
291
|
-
bundle: "@self/pages/Page5/_id.js",
|
|
292
|
-
route: "/page5/:id",
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
bundle: "@self/pages/Page5/_id/Page5_1.js",
|
|
296
|
-
route: "/page5/:id/page5_1",
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
bundle: "@self/pages/Page5/_id/Page5_1/_name/Page5_2.js",
|
|
300
|
-
route: "/page5/:id/page5_1/:name/page5_2",
|
|
301
|
-
},
|
|
302
|
-
]));
|
|
303
|
-
});
|
|
304
|
-
it("should return modules of found automatic views and append them to the configuration when there are manual views", () => {
|
|
305
|
-
mock(pagesFolderContent);
|
|
306
|
-
const config = {
|
|
307
|
-
mainPanel: {
|
|
308
|
-
views: [
|
|
309
|
-
{ bundle: "@self/pages/Home.js", route: "/" },
|
|
310
|
-
{ bundle: "@hv-tests/some-app/pages/Page0.js", route: "/page0" },
|
|
311
|
-
{ bundle: "@self/pages/Other.js", route: "/some-path" },
|
|
312
|
-
{
|
|
313
|
-
bundle: "@hv-tests/other-app/pages/HelloFromOther.js",
|
|
314
|
-
route: "/other",
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
|
-
},
|
|
318
|
-
};
|
|
319
|
-
const result = applyAutomaticViewsAndRoutes(config, selfAppName, root, viewsFolder);
|
|
320
|
-
expect(result.length).toEqual(5);
|
|
321
|
-
expect(result).toEqual(expect.arrayContaining([
|
|
322
|
-
"src/pages/Page1",
|
|
323
|
-
"src/pages/Page3",
|
|
324
|
-
"src/pages/Page5/$id/Page5_1/$name/Page5_2",
|
|
325
|
-
"src/pages/Page5/$id/Page5_1",
|
|
326
|
-
"src/pages/Page5/$id",
|
|
327
|
-
]));
|
|
328
|
-
expect(config.mainPanel?.views?.length).toEqual(9);
|
|
329
|
-
expect(config.mainPanel?.views).toEqual(expect.arrayContaining([
|
|
330
|
-
{ bundle: "@self/pages/Home.js", route: "/" },
|
|
331
|
-
{ bundle: "@hv-tests/some-app/pages/Page0.js", route: "/page0" },
|
|
332
|
-
{ bundle: "@self/pages/Other.js", route: "/some-path" },
|
|
333
|
-
{
|
|
334
|
-
bundle: "@hv-tests/other-app/pages/HelloFromOther.js",
|
|
335
|
-
route: "/other",
|
|
336
|
-
},
|
|
337
|
-
{ bundle: "@self/pages/Page1.js", route: "/page1" },
|
|
338
|
-
{ bundle: "@self/pages/Page3.js", route: "/page3" },
|
|
339
|
-
{
|
|
340
|
-
bundle: "@self/pages/Page5/_id.js",
|
|
341
|
-
route: "/page5/:id",
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
bundle: "@self/pages/Page5/_id/Page5_1.js",
|
|
345
|
-
route: "/page5/:id/page5_1",
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
bundle: "@self/pages/Page5/_id/Page5_1/_name/Page5_2.js",
|
|
349
|
-
route: "/page5/:id/page5_1/:name/page5_2",
|
|
350
|
-
},
|
|
351
|
-
]));
|
|
352
|
-
});
|
|
353
|
-
it("should skip overlapping routes and bundles", () => {
|
|
354
|
-
mock(pagesFolderContent);
|
|
355
|
-
const config = {
|
|
356
|
-
mainPanel: {
|
|
357
|
-
views: [
|
|
358
|
-
{ bundle: "@self/pages/Page1.js", route: "/other-path" },
|
|
359
|
-
{ bundle: "@hv-tests/some-app/pages/Page3.js", route: "/page3" },
|
|
360
|
-
{ bundle: "@self/pages/Other.js", route: "/page5/:id" },
|
|
361
|
-
{
|
|
362
|
-
bundle: "@hv-tests/other-app/pages/HelloFromOther.js",
|
|
363
|
-
route: "/other",
|
|
364
|
-
},
|
|
365
|
-
],
|
|
366
|
-
},
|
|
367
|
-
};
|
|
368
|
-
const result = applyAutomaticViewsAndRoutes(config, selfAppName, root, viewsFolder);
|
|
369
|
-
expect(result.length).toEqual(5);
|
|
370
|
-
expect(result).toEqual(expect.arrayContaining([
|
|
371
|
-
"src/pages/Page1",
|
|
372
|
-
"src/pages/Page3",
|
|
373
|
-
"src/pages/Page5/$id/Page5_1/$name/Page5_2",
|
|
374
|
-
"src/pages/Page5/$id/Page5_1",
|
|
375
|
-
"src/pages/Page5/$id",
|
|
376
|
-
]));
|
|
377
|
-
expect(config.mainPanel?.views?.length).toEqual(6);
|
|
378
|
-
expect(config.mainPanel?.views).toEqual(expect.arrayContaining([
|
|
379
|
-
{
|
|
380
|
-
bundle: "@hv-tests/other-app/pages/HelloFromOther.js",
|
|
381
|
-
route: "/other",
|
|
382
|
-
},
|
|
383
|
-
{ bundle: "@self/pages/Page1.js", route: "/other-path" },
|
|
384
|
-
{ bundle: "@hv-tests/some-app/pages/Page3.js", route: "/page3" },
|
|
385
|
-
{ bundle: "@self/pages/Other.js", route: "/page5/:id" },
|
|
386
|
-
{
|
|
387
|
-
bundle: "@self/pages/Page5/_id/Page5_1.js",
|
|
388
|
-
route: "/page5/:id/page5_1",
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
bundle: "@self/pages/Page5/_id/Page5_1/_name/Page5_2.js",
|
|
392
|
-
route: "/page5/:id/page5_1/:name/page5_2",
|
|
393
|
-
},
|
|
394
|
-
]));
|
|
395
|
-
});
|
|
396
|
-
it("should skip overlapping routes and bundles, including nested views", () => {
|
|
397
|
-
mock(pagesFolderContent);
|
|
398
|
-
const config = {
|
|
399
|
-
mainPanel: {
|
|
400
|
-
views: [
|
|
401
|
-
{
|
|
402
|
-
bundle: "@self/pages/Page1.js",
|
|
403
|
-
route: "/other-path",
|
|
404
|
-
views: [{ bundle: "@self/pages/Page3.js", route: "/subpage3" }],
|
|
405
|
-
},
|
|
406
|
-
{ bundle: "@self/pages/Other.js", route: "/page5/:id" },
|
|
407
|
-
{
|
|
408
|
-
bundle: "@hv-tests/other-app/pages/HelloFromOther.js",
|
|
409
|
-
route: "/other",
|
|
410
|
-
},
|
|
411
|
-
],
|
|
412
|
-
},
|
|
413
|
-
};
|
|
414
|
-
const result = applyAutomaticViewsAndRoutes(config, selfAppName, root, viewsFolder);
|
|
415
|
-
expect(result.length).toEqual(5);
|
|
416
|
-
expect(result).toEqual(expect.arrayContaining([
|
|
417
|
-
"src/pages/Page1",
|
|
418
|
-
"src/pages/Page3",
|
|
419
|
-
"src/pages/Page5/$id/Page5_1/$name/Page5_2",
|
|
420
|
-
"src/pages/Page5/$id/Page5_1",
|
|
421
|
-
"src/pages/Page5/$id",
|
|
422
|
-
]));
|
|
423
|
-
expect(config.mainPanel?.views?.length).toEqual(5);
|
|
424
|
-
expect(config.mainPanel?.views).toEqual(expect.arrayContaining([
|
|
425
|
-
{
|
|
426
|
-
bundle: "@hv-tests/other-app/pages/HelloFromOther.js",
|
|
427
|
-
route: "/other",
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
bundle: "@self/pages/Page1.js",
|
|
431
|
-
route: "/other-path",
|
|
432
|
-
views: [{ bundle: "@self/pages/Page3.js", route: "/subpage3" }],
|
|
433
|
-
},
|
|
434
|
-
{ bundle: "@self/pages/Other.js", route: "/page5/:id" },
|
|
435
|
-
{
|
|
436
|
-
bundle: "@self/pages/Page5/_id/Page5_1.js",
|
|
437
|
-
route: "/page5/:id/page5_1",
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
bundle: "@self/pages/Page5/_id/Page5_1/_name/Page5_2.js",
|
|
441
|
-
route: "/page5/:id/page5_1/:name/page5_2",
|
|
442
|
-
},
|
|
443
|
-
]));
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { vi } from "vitest";
|
|
3
|
-
import { findAppShellConfigFile, getAppModules, getBasePath, getFinalModuleName, loadConfigFile, } from "../config-utils";
|
|
4
|
-
vi.mock("path", async () => vi.importActual("./mocks/path.mock.ts"));
|
|
5
|
-
const existsSyncMock = vi.fn();
|
|
6
|
-
const readFileSyncMock = vi.fn();
|
|
7
|
-
fs.existsSync = existsSyncMock;
|
|
8
|
-
fs.readFileSync = readFileSyncMock;
|
|
9
|
-
describe("test app-shell-vite-generate-base plugin", () => {
|
|
10
|
-
describe("test `findAppShellConfigFile`", () => {
|
|
11
|
-
it("returns the config file location (and its content) if exists", () => {
|
|
12
|
-
existsSyncMock.mockImplementation((file) => {
|
|
13
|
-
return file.match("/dummyPath/dummyRootProject/app-shell.config.json");
|
|
14
|
-
});
|
|
15
|
-
const filePath = findAppShellConfigFile("/dummyPath/dummyRootProject");
|
|
16
|
-
expect(filePath).toBe("/dummyPath/dummyRootProject/app-shell.config.json");
|
|
17
|
-
});
|
|
18
|
-
it("returns undefined if config file don't exists", () => {
|
|
19
|
-
existsSyncMock.mockImplementation(() => {
|
|
20
|
-
return false;
|
|
21
|
-
});
|
|
22
|
-
const filePath = findAppShellConfigFile("/dummyPath/dummyRootProject");
|
|
23
|
-
expect(filePath).toBeUndefined();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe("test `loadConfigFile`", () => {
|
|
27
|
-
it("returns an empty config if the config file is not defined", () => {
|
|
28
|
-
const appShellConfig = loadConfigFile(undefined, {}, {});
|
|
29
|
-
expect(appShellConfig).toMatchObject({});
|
|
30
|
-
});
|
|
31
|
-
it("returns the config if config file exists", () => {
|
|
32
|
-
const config = {
|
|
33
|
-
baseUrl: "dummyBaseUrl",
|
|
34
|
-
};
|
|
35
|
-
existsSyncMock.mockImplementation((file) => {
|
|
36
|
-
return file.match("/dummyPath/dummyRootProject/app-shell.config.json");
|
|
37
|
-
});
|
|
38
|
-
readFileSyncMock.mockImplementation(() => {
|
|
39
|
-
return JSON.stringify(config);
|
|
40
|
-
});
|
|
41
|
-
const appShellConfig = loadConfigFile("/dummyPath/dummyRootProject/app-shell.config.json", {}, {});
|
|
42
|
-
expect(appShellConfig).toMatchObject(config);
|
|
43
|
-
});
|
|
44
|
-
it("replaces tokens at configurations defined at json files", () => {
|
|
45
|
-
const config = {
|
|
46
|
-
baseUrl: "@@BASE_URL@@",
|
|
47
|
-
};
|
|
48
|
-
existsSyncMock.mockImplementation((file) => {
|
|
49
|
-
return file.match("/dummyPath/dummyRootProject/app-shell.config.json");
|
|
50
|
-
});
|
|
51
|
-
readFileSyncMock.mockImplementation(() => {
|
|
52
|
-
return JSON.stringify(config);
|
|
53
|
-
});
|
|
54
|
-
const appShellConfig = loadConfigFile("/dummyPath/dummyRootProject/app-shell.config.json", {
|
|
55
|
-
configReplacements: [
|
|
56
|
-
{ token: "BASE_URL", value: "dummyBaseUrlWithTokens" },
|
|
57
|
-
],
|
|
58
|
-
}, {});
|
|
59
|
-
expect(appShellConfig).toMatchObject({
|
|
60
|
-
baseUrl: "dummyBaseUrlWithTokens",
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
describe("getFinalModuleName", () => {
|
|
65
|
-
it("removes leading 'src/' and file extension from module path", () => {
|
|
66
|
-
const modulePath = "/src/pages/DummyPath.tsx";
|
|
67
|
-
const finalModuleName = getFinalModuleName(modulePath);
|
|
68
|
-
expect(finalModuleName).toBe("pages/DummyPath");
|
|
69
|
-
});
|
|
70
|
-
it("replaces '$' with '_' in the module path", () => {
|
|
71
|
-
const modulePath = "/src/pages/DummyPath/$id/HelloWorld.tsx";
|
|
72
|
-
const finalModuleName = getFinalModuleName(modulePath);
|
|
73
|
-
expect(finalModuleName).toBe("pages/DummyPath/_id/HelloWorld");
|
|
74
|
-
});
|
|
75
|
-
it("handles module paths without 'src/' prefix", () => {
|
|
76
|
-
// this use case is not expected to happen, but let's test it anyway
|
|
77
|
-
const modulePath = "/other/pages/DummyPath.tsx";
|
|
78
|
-
const finalModuleName = getFinalModuleName(modulePath);
|
|
79
|
-
expect(finalModuleName).toBe("other/pages/DummyPath");
|
|
80
|
-
});
|
|
81
|
-
it("handles module paths without file extension", () => {
|
|
82
|
-
const modulePath = "/src/pages/DummyPath";
|
|
83
|
-
const finalModuleName = getFinalModuleName(modulePath);
|
|
84
|
-
expect(finalModuleName).toBe("pages/DummyPath");
|
|
85
|
-
});
|
|
86
|
-
it("handles module paths with '.ts' file extension", () => {
|
|
87
|
-
const modulePath = "/src/pages/DummyPath.ts";
|
|
88
|
-
const finalModuleName = getFinalModuleName(modulePath);
|
|
89
|
-
expect(finalModuleName).toBe("pages/DummyPath");
|
|
90
|
-
});
|
|
91
|
-
it("handles module paths with '.jsx' file extension", () => {
|
|
92
|
-
const modulePath = "/src/pages/DummyPath.jsx";
|
|
93
|
-
const finalModuleName = getFinalModuleName(modulePath);
|
|
94
|
-
expect(finalModuleName).toBe("pages/DummyPath");
|
|
95
|
-
});
|
|
96
|
-
it("handles module paths with '.tsx' file extension", () => {
|
|
97
|
-
const modulePath = "/src/pages/DummyPath.tsx";
|
|
98
|
-
const finalModuleName = getFinalModuleName(modulePath);
|
|
99
|
-
expect(finalModuleName).toBe("pages/DummyPath");
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
describe("getAppModules", () => {
|
|
103
|
-
it("modules are correctly mapped", () => {
|
|
104
|
-
expect(getAppModules("dummyPath", [
|
|
105
|
-
"src/pages/DummyPath",
|
|
106
|
-
"src/pages/DummyPath-2",
|
|
107
|
-
"src/pages/DummyPath/$id/HelloWorld",
|
|
108
|
-
"src/modules/DummyModule1",
|
|
109
|
-
"src/modules/DummyModule2.ts",
|
|
110
|
-
"src/modules/DummyModule3.tsx",
|
|
111
|
-
"src/modules/DummyModule4.js",
|
|
112
|
-
"src/modules/DummyModule5.jsx",
|
|
113
|
-
"altSrc/customModules/DummyAltSource",
|
|
114
|
-
"altSrc/customModules/DummyAlt/File.tsx",
|
|
115
|
-
])).toEqual({
|
|
116
|
-
"pages/DummyPath": "dummyPath/src/pages/DummyPath",
|
|
117
|
-
"pages/DummyPath-2": "dummyPath/src/pages/DummyPath-2",
|
|
118
|
-
"pages/DummyPath/_id/HelloWorld": "dummyPath/src/pages/DummyPath/$id/HelloWorld",
|
|
119
|
-
"modules/DummyModule1": "dummyPath/src/modules/DummyModule1",
|
|
120
|
-
"modules/DummyModule2": "dummyPath/src/modules/DummyModule2.ts",
|
|
121
|
-
"modules/DummyModule3": "dummyPath/src/modules/DummyModule3.tsx",
|
|
122
|
-
"modules/DummyModule4": "dummyPath/src/modules/DummyModule4.js",
|
|
123
|
-
"modules/DummyModule5": "dummyPath/src/modules/DummyModule5.jsx",
|
|
124
|
-
"altSrc/customModules/DummyAltSource": "dummyPath/altSrc/customModules/DummyAltSource",
|
|
125
|
-
"altSrc/customModules/DummyAlt/File": "dummyPath/altSrc/customModules/DummyAlt/File.tsx",
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
describe("getBasePath", () => {
|
|
130
|
-
it("config url is defined", () => {
|
|
131
|
-
expect(getBasePath("/baseUrl")).toBe("/baseUrl");
|
|
132
|
-
});
|
|
133
|
-
it("config url and vite base are defined", () => {
|
|
134
|
-
expect(getBasePath("/baseUrl", "/viteBase/")).toBe("/viteBase/");
|
|
135
|
-
});
|
|
136
|
-
it("config url is undefined, vite base is defined", () => {
|
|
137
|
-
expect(getBasePath(undefined, "/viteBase")).toBe("/viteBase");
|
|
138
|
-
});
|
|
139
|
-
it("config url and vite base are undefined", () => {
|
|
140
|
-
expect(getBasePath(undefined, undefined)).toBe("/");
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { replaceReferencesToSelf } from "../vite-configuration-processor-plugin";
|
|
2
|
-
describe("replaceReferencesToSelf", () => {
|
|
3
|
-
it("should replace references to self in bundle definitions", () => {
|
|
4
|
-
const bundles = [
|
|
5
|
-
{
|
|
6
|
-
bundle: "@self/pages/Page1.js",
|
|
7
|
-
views: [
|
|
8
|
-
{
|
|
9
|
-
bundle: "@self/pages/Page2.js",
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
bundle: "@other-app/pages/Page3.js",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
bundle: "@other-app/pages/Page4.js",
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
const selfAppName = "@hv-tests/some-app";
|
|
21
|
-
const expectedBundles = [
|
|
22
|
-
{
|
|
23
|
-
bundle: "@hv-tests/some-app/pages/Page1.js",
|
|
24
|
-
views: [
|
|
25
|
-
{
|
|
26
|
-
bundle: "@hv-tests/some-app/pages/Page2.js",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
bundle: "@other-app/pages/Page3.js",
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
bundle: "@other-app/pages/Page4.js",
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
const result = replaceReferencesToSelf(bundles, selfAppName);
|
|
38
|
-
expect(result).toEqual(expectedBundles);
|
|
39
|
-
});
|
|
40
|
-
it("should not modify bundle definitions without references to self", () => {
|
|
41
|
-
const bundles = [
|
|
42
|
-
{
|
|
43
|
-
bundle: "@other-app/pages/Page1.js",
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
bundle: "@other-app/pages/Page2.js",
|
|
47
|
-
views: [
|
|
48
|
-
{
|
|
49
|
-
bundle: "@other-app/pages/Page3.js",
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
];
|
|
54
|
-
const selfAppName = "@hv-tests/some-app";
|
|
55
|
-
const expectedBundles = [
|
|
56
|
-
{
|
|
57
|
-
bundle: "@other-app/pages/Page1.js",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
bundle: "@other-app/pages/Page2.js",
|
|
61
|
-
views: [
|
|
62
|
-
{
|
|
63
|
-
bundle: "@other-app/pages/Page3.js",
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
];
|
|
68
|
-
const result = replaceReferencesToSelf(bundles, selfAppName);
|
|
69
|
-
expect(result).toEqual(expectedBundles);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { addUseCredentials, checkCrossOrigin, } from "../vite-crossorigin-fix-plugin";
|
|
3
|
-
describe("vite-crossorigin-fix", () => {
|
|
4
|
-
describe("checkCrossOrigin", () => {
|
|
5
|
-
it('should return an empty array if no scripts have crossorigin="use-credentials"', () => {
|
|
6
|
-
const html = `
|
|
7
|
-
<!DOCTYPE html>
|
|
8
|
-
<html lang="en">
|
|
9
|
-
<head>
|
|
10
|
-
<title>Test</title>
|
|
11
|
-
</head>
|
|
12
|
-
<body>
|
|
13
|
-
<script src="/assets/main.js"></script>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
16
|
-
`;
|
|
17
|
-
const result = checkCrossOrigin(html);
|
|
18
|
-
expect(result).toEqual([]);
|
|
19
|
-
});
|
|
20
|
-
it('should return an array of script sources with crossorigin="use-credentials"', () => {
|
|
21
|
-
const html = `
|
|
22
|
-
<!DOCTYPE html>
|
|
23
|
-
<html lang="en">
|
|
24
|
-
<head>
|
|
25
|
-
<title>Test</title>
|
|
26
|
-
</head>
|
|
27
|
-
<body>
|
|
28
|
-
<script src="/assets/main.js" crossorigin="use-credentials" type="module"></script>
|
|
29
|
-
</body>
|
|
30
|
-
</html>
|
|
31
|
-
`;
|
|
32
|
-
const result = checkCrossOrigin(html);
|
|
33
|
-
expect(result).toEqual(["/assets/main.js"]);
|
|
34
|
-
});
|
|
35
|
-
it("should ignore scripts that are not modules", () => {
|
|
36
|
-
const html = `
|
|
37
|
-
<!DOCTYPE html>
|
|
38
|
-
<html lang="en">
|
|
39
|
-
<head>
|
|
40
|
-
<title>Test</title>
|
|
41
|
-
</head>
|
|
42
|
-
<body>
|
|
43
|
-
<script src="/assets/main.js" crossorigin="use-credentials"></script>
|
|
44
|
-
</body>
|
|
45
|
-
</html>
|
|
46
|
-
`;
|
|
47
|
-
const result = checkCrossOrigin(html);
|
|
48
|
-
expect(result).toEqual([]);
|
|
49
|
-
});
|
|
50
|
-
it("should ignore external and data URLs", () => {
|
|
51
|
-
const html = `
|
|
52
|
-
<!DOCTYPE html>
|
|
53
|
-
<html lang="en">
|
|
54
|
-
<head>
|
|
55
|
-
<title>Test</title>
|
|
56
|
-
</head>
|
|
57
|
-
<body>
|
|
58
|
-
<script src="https://external.com/main.js" crossorigin="use-credentials" type="module"></script>
|
|
59
|
-
<script src="data:text/javascript;base64,abcd" crossorigin="use-credentials" type="module"></script>
|
|
60
|
-
</body>
|
|
61
|
-
</html>
|
|
62
|
-
`;
|
|
63
|
-
const result = checkCrossOrigin(html);
|
|
64
|
-
expect(result).toEqual([]);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
describe("addUseCredentials", () => {
|
|
68
|
-
it('should add crossorigin="use-credentials" to all script tags', () => {
|
|
69
|
-
const html = `
|
|
70
|
-
<!DOCTYPE html>
|
|
71
|
-
<html lang="en">
|
|
72
|
-
<head>
|
|
73
|
-
<title>Test</title>
|
|
74
|
-
</head>
|
|
75
|
-
<body>
|
|
76
|
-
<script
|
|
77
|
-
src="/assets/main.js"
|
|
78
|
-
crossorigin type="module"></script>
|
|
79
|
-
</body>
|
|
80
|
-
</html>
|
|
81
|
-
`;
|
|
82
|
-
const result = addUseCredentials("main.js", html);
|
|
83
|
-
expect(result).toContain('crossorigin="use-credentials"');
|
|
84
|
-
});
|
|
85
|
-
it('should handle link rel="modulepreload" tags', () => {
|
|
86
|
-
const html = `
|
|
87
|
-
<!DOCTYPE html>
|
|
88
|
-
<html lang="en">
|
|
89
|
-
<head>
|
|
90
|
-
<title>Test</title>
|
|
91
|
-
<link rel="modulepreload"
|
|
92
|
-
href="/assets/main.js"
|
|
93
|
-
crossorigin>
|
|
94
|
-
</head>
|
|
95
|
-
<body>
|
|
96
|
-
</body>
|
|
97
|
-
</html>
|
|
98
|
-
`;
|
|
99
|
-
const result = addUseCredentials("main.js", html);
|
|
100
|
-
expect(result).toContain('crossorigin="use-credentials"');
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getAppTitle } from "../vite-generate-base-plugin";
|
|
2
|
-
describe("test vite-generate-base plugin", () => {
|
|
3
|
-
describe("test `getAppTitle` method", () => {
|
|
4
|
-
test.each([
|
|
5
|
-
[false, { name: "dummyName" }, "dummyName"],
|
|
6
|
-
[true, {}, "%%APPSHELL_TITLE%%"],
|
|
7
|
-
])("At mode %b, %j, app title matches %s", (value, config, expected) => {
|
|
8
|
-
expect(getAppTitle(value, config)).toBe(expected);
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { vi } from "vitest";
|
|
3
|
-
import injectMetadata from "../vite-metadata-plugin";
|
|
4
|
-
describe("test vite-metadata plugin", () => {
|
|
5
|
-
it.skip("returns the injectMetadata information", () => {
|
|
6
|
-
const fsTmp = fs.existsSync;
|
|
7
|
-
fs.existsSync = vi.fn().mockImplementation((file) => {
|
|
8
|
-
return file.match("/dummyPath/dummyRootProject/app-shell.config.json");
|
|
9
|
-
});
|
|
10
|
-
const readFileSyncTmp = fs.readFileSync;
|
|
11
|
-
fs.readFileSync = vi.fn().mockImplementation((file) => {
|
|
12
|
-
const version = (packageFile) => {
|
|
13
|
-
if (packageFile.indexOf("/client/packages/app-shell-ui/package.json") >= 0) {
|
|
14
|
-
return "appShellUIDummyVersion";
|
|
15
|
-
}
|
|
16
|
-
if (packageFile.indexOf("/client/packages/app-shell-vite-plugin/package.json") >= 0) {
|
|
17
|
-
return "appShellVitePluginDummyVersion";
|
|
18
|
-
}
|
|
19
|
-
return "dummyVersion";
|
|
20
|
-
};
|
|
21
|
-
return JSON.stringify({ version: version(file) });
|
|
22
|
-
});
|
|
23
|
-
const metadata = injectMetadata();
|
|
24
|
-
const { transformIndexHtml } = metadata;
|
|
25
|
-
// @ts-expect-error This is a function and is callable
|
|
26
|
-
expect(transformIndexHtml()).toMatchObject([
|
|
27
|
-
{
|
|
28
|
-
attrs: {
|
|
29
|
-
content: "appShellUIDummyVersion",
|
|
30
|
-
name: "app-shell-ui-version",
|
|
31
|
-
},
|
|
32
|
-
tag: "meta",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
attrs: {
|
|
36
|
-
content: "appShellVitePluginDummyVersion",
|
|
37
|
-
name: "app-shell-vite-plugin-version",
|
|
38
|
-
},
|
|
39
|
-
tag: "meta",
|
|
40
|
-
},
|
|
41
|
-
]);
|
|
42
|
-
// Restore the original fs.existsSync
|
|
43
|
-
fs.existsSync = fsTmp;
|
|
44
|
-
// Restore the original fs.existsSync
|
|
45
|
-
fs.readFileSync = readFileSyncTmp;
|
|
46
|
-
});
|
|
47
|
-
});
|