@jsenv/core 39.10.2 → 39.11.1
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/jsenv_core.js
CHANGED
|
@@ -19480,11 +19480,14 @@ const generateHtmlForDirectory = (directoryContentItems) => {
|
|
|
19480
19480
|
directoryUrl = assertAndNormalizeDirectoryUrl(directoryUrl);
|
|
19481
19481
|
|
|
19482
19482
|
const htmlForDirectory = String(readFileSync(htmlFileUrlForDirectory));
|
|
19483
|
-
const directoryRelativeUrl = urlToRelativeUrl(directoryUrl, rootDirectoryUrl);
|
|
19484
19483
|
const replacers = {
|
|
19485
19484
|
directoryUrl,
|
|
19486
19485
|
directoryNav: () =>
|
|
19487
|
-
generateDirectoryNav(
|
|
19486
|
+
generateDirectoryNav(directoryUrl, {
|
|
19487
|
+
rootDirectoryUrl,
|
|
19488
|
+
rootDirectoryUrlForServer:
|
|
19489
|
+
directoryContentItems.rootDirectoryUrlForServer,
|
|
19490
|
+
}),
|
|
19488
19491
|
directoryContent: () => generateDirectoryContent(directoryContentItems),
|
|
19489
19492
|
};
|
|
19490
19493
|
const html = replacePlaceholders$1(htmlForDirectory, replacers);
|
|
@@ -19514,47 +19517,64 @@ const generateHtmlForENOENT = (
|
|
|
19514
19517
|
ancestorDirectoryUrl,
|
|
19515
19518
|
ancestorDirectoryRelativeUrl,
|
|
19516
19519
|
ancestorDirectoryNav: () =>
|
|
19517
|
-
generateDirectoryNav(
|
|
19520
|
+
generateDirectoryNav(ancestorDirectoryUrl, {
|
|
19521
|
+
rootDirectoryUrl,
|
|
19522
|
+
rootDirectoryUrlForServer:
|
|
19523
|
+
directoryContentItems.rootDirectoryUrlForServer,
|
|
19524
|
+
}),
|
|
19518
19525
|
ancestorDirectoryContent: () =>
|
|
19519
19526
|
generateDirectoryContent(directoryContentItems),
|
|
19520
19527
|
};
|
|
19521
19528
|
const html = replacePlaceholders$1(htmlFor404AndAncestorDir, replacers);
|
|
19522
19529
|
return html;
|
|
19523
19530
|
};
|
|
19524
|
-
const generateDirectoryNav = (
|
|
19531
|
+
const generateDirectoryNav = (
|
|
19532
|
+
entryDirectoryUrl,
|
|
19533
|
+
{ rootDirectoryUrl, rootDirectoryUrlForServer },
|
|
19534
|
+
) => {
|
|
19535
|
+
const entryDirectoryRelativeUrl = urlToRelativeUrl(
|
|
19536
|
+
entryDirectoryUrl,
|
|
19537
|
+
rootDirectoryUrl,
|
|
19538
|
+
);
|
|
19539
|
+
const isDir =
|
|
19540
|
+
entryDirectoryRelativeUrl === "" || entryDirectoryRelativeUrl.endsWith("/");
|
|
19525
19541
|
const rootDirectoryUrlName = urlToFilename$1(rootDirectoryUrl);
|
|
19526
|
-
const relativeUrlWithRoot = relativeUrl
|
|
19527
|
-
? `${rootDirectoryUrlName}/${relativeUrl}`
|
|
19528
|
-
: `${rootDirectoryUrlName}/`;
|
|
19529
|
-
const isDir = relativeUrlWithRoot.endsWith("/");
|
|
19530
|
-
const parts = isDir
|
|
19531
|
-
? relativeUrlWithRoot.slice(0, -1).split("/")
|
|
19532
|
-
: relativeUrlWithRoot.split("/");
|
|
19533
19542
|
const items = [];
|
|
19534
|
-
items.push({
|
|
19535
|
-
href: "/",
|
|
19536
|
-
text: "/",
|
|
19537
|
-
});
|
|
19538
19543
|
let dirPartsHtml = "";
|
|
19544
|
+
const parts = entryDirectoryRelativeUrl
|
|
19545
|
+
? `${rootDirectoryUrlName}/${entryDirectoryRelativeUrl.slice(0, -1)}`.split(
|
|
19546
|
+
"/",
|
|
19547
|
+
)
|
|
19548
|
+
: [rootDirectoryUrlName];
|
|
19539
19549
|
let i = 0;
|
|
19540
19550
|
while (i < parts.length) {
|
|
19541
19551
|
const part = parts[i];
|
|
19542
|
-
const
|
|
19543
|
-
|
|
19544
|
-
|
|
19545
|
-
|
|
19552
|
+
const directoryRelativeUrl = `${parts.slice(1, i + 1).join("/")}`;
|
|
19553
|
+
const directoryUrl =
|
|
19554
|
+
directoryRelativeUrl === ""
|
|
19555
|
+
? rootDirectoryUrl
|
|
19556
|
+
: new URL(`${directoryRelativeUrl}/`, rootDirectoryUrl).href;
|
|
19557
|
+
let href =
|
|
19558
|
+
directoryUrl === rootDirectoryUrlForServer ||
|
|
19559
|
+
urlIsInsideOf(directoryUrl, rootDirectoryUrlForServer)
|
|
19560
|
+
? urlToRelativeUrl(directoryUrl, rootDirectoryUrlForServer)
|
|
19561
|
+
: directoryUrl;
|
|
19562
|
+
if (href === "") {
|
|
19563
|
+
href = `/${directoryContentMagicName}`;
|
|
19564
|
+
} else {
|
|
19565
|
+
href = `/${href}`;
|
|
19566
|
+
}
|
|
19546
19567
|
const text = part;
|
|
19547
|
-
const isLastPart = i === parts.length - 1;
|
|
19548
19568
|
items.push({
|
|
19549
19569
|
href,
|
|
19550
19570
|
text,
|
|
19551
|
-
isCurrent: isLastPart,
|
|
19552
19571
|
});
|
|
19553
19572
|
i++;
|
|
19554
19573
|
}
|
|
19555
19574
|
i = 0;
|
|
19556
|
-
for (const { href, text
|
|
19557
|
-
|
|
19575
|
+
for (const { href, text } of items) {
|
|
19576
|
+
const isLastPart = i === items.length - 1;
|
|
19577
|
+
if (isLastPart) {
|
|
19558
19578
|
dirPartsHtml += `
|
|
19559
19579
|
<span class="directory_nav_item" data-current>
|
|
19560
19580
|
${text}
|
|
@@ -19565,10 +19585,8 @@ const generateDirectoryNav = (relativeUrl, rootDirectoryUrl) => {
|
|
|
19565
19585
|
<a class="directory_nav_item" href="${href}">
|
|
19566
19586
|
${text}
|
|
19567
19587
|
</a>`;
|
|
19568
|
-
|
|
19569
|
-
dirPartsHtml += `
|
|
19588
|
+
dirPartsHtml += `
|
|
19570
19589
|
<span class="directory_separator">/</span>`;
|
|
19571
|
-
}
|
|
19572
19590
|
i++;
|
|
19573
19591
|
}
|
|
19574
19592
|
if (isDir) {
|
|
@@ -19577,12 +19595,15 @@ const generateDirectoryNav = (relativeUrl, rootDirectoryUrl) => {
|
|
|
19577
19595
|
}
|
|
19578
19596
|
return dirPartsHtml;
|
|
19579
19597
|
};
|
|
19580
|
-
const generateDirectoryContentItems = (
|
|
19598
|
+
const generateDirectoryContentItems = (
|
|
19599
|
+
directoryUrl,
|
|
19600
|
+
rootDirectoryUrlForServer,
|
|
19601
|
+
) => {
|
|
19581
19602
|
let firstExistingDirectoryUrl = new URL("./", directoryUrl);
|
|
19582
19603
|
while (!existsSync(firstExistingDirectoryUrl)) {
|
|
19583
19604
|
firstExistingDirectoryUrl = new URL("../", firstExistingDirectoryUrl);
|
|
19584
|
-
if (!urlIsInsideOf(firstExistingDirectoryUrl,
|
|
19585
|
-
firstExistingDirectoryUrl = new URL(
|
|
19605
|
+
if (!urlIsInsideOf(firstExistingDirectoryUrl, rootDirectoryUrlForServer)) {
|
|
19606
|
+
firstExistingDirectoryUrl = new URL(rootDirectoryUrlForServer);
|
|
19586
19607
|
break;
|
|
19587
19608
|
}
|
|
19588
19609
|
}
|
|
@@ -19592,37 +19613,42 @@ const generateDirectoryContentItems = (directoryUrl, rootDirectoryUrl) => {
|
|
|
19592
19613
|
const fileUrlObject = new URL(filename, firstExistingDirectoryUrl);
|
|
19593
19614
|
fileUrls.push(fileUrlObject);
|
|
19594
19615
|
}
|
|
19616
|
+
let rootDirectoryUrl = rootDirectoryUrlForServer;
|
|
19595
19617
|
package_workspaces: {
|
|
19596
|
-
|
|
19597
|
-
|
|
19598
|
-
|
|
19599
|
-
const packageDirectoryUrl = lookupPackageDirectory(rootDirectoryUrl);
|
|
19618
|
+
const packageDirectoryUrl = lookupPackageDirectory(
|
|
19619
|
+
rootDirectoryUrlForServer,
|
|
19620
|
+
);
|
|
19600
19621
|
if (!packageDirectoryUrl) {
|
|
19601
19622
|
break package_workspaces;
|
|
19602
19623
|
}
|
|
19603
|
-
if (String(packageDirectoryUrl) === String(
|
|
19604
|
-
break package_workspaces;
|
|
19605
|
-
}
|
|
19606
|
-
let packageContent;
|
|
19607
|
-
try {
|
|
19608
|
-
packageContent = JSON.parse(
|
|
19609
|
-
readFileSync(new URL("package.json", packageDirectoryUrl), "utf8"),
|
|
19610
|
-
);
|
|
19611
|
-
} catch {
|
|
19624
|
+
if (String(packageDirectoryUrl) === String(rootDirectoryUrlForServer)) {
|
|
19612
19625
|
break package_workspaces;
|
|
19613
19626
|
}
|
|
19614
|
-
|
|
19615
|
-
if (
|
|
19616
|
-
|
|
19617
|
-
|
|
19618
|
-
|
|
19619
|
-
|
|
19620
|
-
|
|
19621
|
-
|
|
19622
|
-
|
|
19623
|
-
|
|
19624
|
-
|
|
19625
|
-
|
|
19627
|
+
rootDirectoryUrl = packageDirectoryUrl;
|
|
19628
|
+
if (
|
|
19629
|
+
String(firstExistingDirectoryUrl) === String(rootDirectoryUrlForServer)
|
|
19630
|
+
) {
|
|
19631
|
+
let packageContent;
|
|
19632
|
+
try {
|
|
19633
|
+
packageContent = JSON.parse(
|
|
19634
|
+
readFileSync(new URL("package.json", packageDirectoryUrl), "utf8"),
|
|
19635
|
+
);
|
|
19636
|
+
} catch {
|
|
19637
|
+
break package_workspaces;
|
|
19638
|
+
}
|
|
19639
|
+
const { workspaces } = packageContent;
|
|
19640
|
+
if (Array.isArray(workspaces)) {
|
|
19641
|
+
for (const workspace of workspaces) {
|
|
19642
|
+
const workspaceUrlObject = new URL(workspace, packageDirectoryUrl);
|
|
19643
|
+
const workspaceUrl = workspaceUrlObject.href;
|
|
19644
|
+
if (workspaceUrl.endsWith("*")) {
|
|
19645
|
+
const directoryUrl = ensurePathnameTrailingSlash(
|
|
19646
|
+
workspaceUrl.slice(0, -1),
|
|
19647
|
+
);
|
|
19648
|
+
fileUrls.push(new URL(directoryUrl));
|
|
19649
|
+
} else {
|
|
19650
|
+
fileUrls.push(ensurePathnameTrailingSlash(workspaceUrlObject));
|
|
19651
|
+
}
|
|
19626
19652
|
}
|
|
19627
19653
|
}
|
|
19628
19654
|
}
|
|
@@ -19646,14 +19672,18 @@ const generateDirectoryContentItems = (directoryUrl, rootDirectoryUrl) => {
|
|
|
19646
19672
|
sortedUrl,
|
|
19647
19673
|
firstExistingDirectoryUrl,
|
|
19648
19674
|
);
|
|
19649
|
-
const
|
|
19675
|
+
const fileUrlRelativeToServer = urlToRelativeUrl(
|
|
19676
|
+
sortedUrl,
|
|
19677
|
+
rootDirectoryUrlForServer,
|
|
19678
|
+
);
|
|
19650
19679
|
const type = fileUrlRelativeToParent.endsWith("/") ? "dir" : "file";
|
|
19651
19680
|
items.push({
|
|
19652
19681
|
type,
|
|
19653
19682
|
fileUrlRelativeToParent,
|
|
19654
|
-
|
|
19683
|
+
fileUrlRelativeToServer,
|
|
19655
19684
|
});
|
|
19656
19685
|
}
|
|
19686
|
+
items.rootDirectoryUrlForServer = rootDirectoryUrlForServer;
|
|
19657
19687
|
items.rootDirectoryUrl = rootDirectoryUrl;
|
|
19658
19688
|
items.firstExistingDirectoryUrl = firstExistingDirectoryUrl;
|
|
19659
19689
|
return items;
|
|
@@ -19664,11 +19694,15 @@ const generateDirectoryContent = (directoryContentItems) => {
|
|
|
19664
19694
|
}
|
|
19665
19695
|
let html = `<ul class="directory_content">`;
|
|
19666
19696
|
for (const directoryContentItem of directoryContentItems) {
|
|
19667
|
-
const { type, fileUrlRelativeToParent,
|
|
19697
|
+
const { type, fileUrlRelativeToParent, fileUrlRelativeToServer } =
|
|
19668
19698
|
directoryContentItem;
|
|
19699
|
+
let href = fileUrlRelativeToServer;
|
|
19700
|
+
if (href === "") {
|
|
19701
|
+
href = `${directoryContentMagicName}`;
|
|
19702
|
+
}
|
|
19669
19703
|
html += `
|
|
19670
19704
|
<li class="directory_child" data-type="${type}">
|
|
19671
|
-
<a href="/${
|
|
19705
|
+
<a href="/${href}">${fileUrlRelativeToParent}</a>
|
|
19672
19706
|
</li>`;
|
|
19673
19707
|
}
|
|
19674
19708
|
html += `\n </ul>`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "39.
|
|
3
|
+
"version": "39.11.1",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -103,13 +103,13 @@
|
|
|
103
103
|
"@jsenv/plugin-as-js-classic": "workspace:*",
|
|
104
104
|
"@jsenv/snapshot": "workspace:*",
|
|
105
105
|
"@jsenv/test": "workspace:*",
|
|
106
|
-
"@playwright/browser-chromium": "1.
|
|
107
|
-
"@playwright/browser-firefox": "1.
|
|
108
|
-
"@playwright/browser-webkit": "1.
|
|
106
|
+
"@playwright/browser-chromium": "1.50.0",
|
|
107
|
+
"@playwright/browser-firefox": "1.50.0",
|
|
108
|
+
"@playwright/browser-webkit": "1.50.0",
|
|
109
109
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
110
|
-
"eslint": "9.
|
|
110
|
+
"eslint": "9.19.0",
|
|
111
111
|
"open": "10.1.0",
|
|
112
|
-
"playwright": "1.
|
|
112
|
+
"playwright": "1.50.0",
|
|
113
113
|
"prettier": "3.4.2",
|
|
114
114
|
"prettier-plugin-organize-imports": "4.1.0",
|
|
115
115
|
"strip-ansi": "7.1.0"
|
|
@@ -182,11 +182,14 @@ const generateHtmlForDirectory = (directoryContentItems) => {
|
|
|
182
182
|
directoryUrl = assertAndNormalizeDirectoryUrl(directoryUrl);
|
|
183
183
|
|
|
184
184
|
const htmlForDirectory = String(readFileSync(htmlFileUrlForDirectory));
|
|
185
|
-
const directoryRelativeUrl = urlToRelativeUrl(directoryUrl, rootDirectoryUrl);
|
|
186
185
|
const replacers = {
|
|
187
186
|
directoryUrl,
|
|
188
187
|
directoryNav: () =>
|
|
189
|
-
generateDirectoryNav(
|
|
188
|
+
generateDirectoryNav(directoryUrl, {
|
|
189
|
+
rootDirectoryUrl,
|
|
190
|
+
rootDirectoryUrlForServer:
|
|
191
|
+
directoryContentItems.rootDirectoryUrlForServer,
|
|
192
|
+
}),
|
|
190
193
|
directoryContent: () => generateDirectoryContent(directoryContentItems),
|
|
191
194
|
};
|
|
192
195
|
const html = replacePlaceholders(htmlForDirectory, replacers);
|
|
@@ -216,47 +219,64 @@ const generateHtmlForENOENT = (
|
|
|
216
219
|
ancestorDirectoryUrl,
|
|
217
220
|
ancestorDirectoryRelativeUrl,
|
|
218
221
|
ancestorDirectoryNav: () =>
|
|
219
|
-
generateDirectoryNav(
|
|
222
|
+
generateDirectoryNav(ancestorDirectoryUrl, {
|
|
223
|
+
rootDirectoryUrl,
|
|
224
|
+
rootDirectoryUrlForServer:
|
|
225
|
+
directoryContentItems.rootDirectoryUrlForServer,
|
|
226
|
+
}),
|
|
220
227
|
ancestorDirectoryContent: () =>
|
|
221
228
|
generateDirectoryContent(directoryContentItems),
|
|
222
229
|
};
|
|
223
230
|
const html = replacePlaceholders(htmlFor404AndAncestorDir, replacers);
|
|
224
231
|
return html;
|
|
225
232
|
};
|
|
226
|
-
const generateDirectoryNav = (
|
|
233
|
+
const generateDirectoryNav = (
|
|
234
|
+
entryDirectoryUrl,
|
|
235
|
+
{ rootDirectoryUrl, rootDirectoryUrlForServer },
|
|
236
|
+
) => {
|
|
237
|
+
const entryDirectoryRelativeUrl = urlToRelativeUrl(
|
|
238
|
+
entryDirectoryUrl,
|
|
239
|
+
rootDirectoryUrl,
|
|
240
|
+
);
|
|
241
|
+
const isDir =
|
|
242
|
+
entryDirectoryRelativeUrl === "" || entryDirectoryRelativeUrl.endsWith("/");
|
|
227
243
|
const rootDirectoryUrlName = urlToFilename(rootDirectoryUrl);
|
|
228
|
-
const relativeUrlWithRoot = relativeUrl
|
|
229
|
-
? `${rootDirectoryUrlName}/${relativeUrl}`
|
|
230
|
-
: `${rootDirectoryUrlName}/`;
|
|
231
|
-
const isDir = relativeUrlWithRoot.endsWith("/");
|
|
232
|
-
const parts = isDir
|
|
233
|
-
? relativeUrlWithRoot.slice(0, -1).split("/")
|
|
234
|
-
: relativeUrlWithRoot.split("/");
|
|
235
244
|
const items = [];
|
|
236
|
-
items.push({
|
|
237
|
-
href: "/",
|
|
238
|
-
text: "/",
|
|
239
|
-
});
|
|
240
245
|
let dirPartsHtml = "";
|
|
246
|
+
const parts = entryDirectoryRelativeUrl
|
|
247
|
+
? `${rootDirectoryUrlName}/${entryDirectoryRelativeUrl.slice(0, -1)}`.split(
|
|
248
|
+
"/",
|
|
249
|
+
)
|
|
250
|
+
: [rootDirectoryUrlName];
|
|
241
251
|
let i = 0;
|
|
242
252
|
while (i < parts.length) {
|
|
243
253
|
const part = parts[i];
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
254
|
+
const directoryRelativeUrl = `${parts.slice(1, i + 1).join("/")}`;
|
|
255
|
+
const directoryUrl =
|
|
256
|
+
directoryRelativeUrl === ""
|
|
257
|
+
? rootDirectoryUrl
|
|
258
|
+
: new URL(`${directoryRelativeUrl}/`, rootDirectoryUrl).href;
|
|
259
|
+
let href =
|
|
260
|
+
directoryUrl === rootDirectoryUrlForServer ||
|
|
261
|
+
urlIsInsideOf(directoryUrl, rootDirectoryUrlForServer)
|
|
262
|
+
? urlToRelativeUrl(directoryUrl, rootDirectoryUrlForServer)
|
|
263
|
+
: directoryUrl;
|
|
264
|
+
if (href === "") {
|
|
265
|
+
href = `/${directoryContentMagicName}`;
|
|
266
|
+
} else {
|
|
267
|
+
href = `/${href}`;
|
|
268
|
+
}
|
|
248
269
|
const text = part;
|
|
249
|
-
const isLastPart = i === parts.length - 1;
|
|
250
270
|
items.push({
|
|
251
271
|
href,
|
|
252
272
|
text,
|
|
253
|
-
isCurrent: isLastPart,
|
|
254
273
|
});
|
|
255
274
|
i++;
|
|
256
275
|
}
|
|
257
276
|
i = 0;
|
|
258
|
-
for (const { href, text
|
|
259
|
-
|
|
277
|
+
for (const { href, text } of items) {
|
|
278
|
+
const isLastPart = i === items.length - 1;
|
|
279
|
+
if (isLastPart) {
|
|
260
280
|
dirPartsHtml += `
|
|
261
281
|
<span class="directory_nav_item" data-current>
|
|
262
282
|
${text}
|
|
@@ -267,10 +287,8 @@ const generateDirectoryNav = (relativeUrl, rootDirectoryUrl) => {
|
|
|
267
287
|
<a class="directory_nav_item" href="${href}">
|
|
268
288
|
${text}
|
|
269
289
|
</a>`;
|
|
270
|
-
|
|
271
|
-
dirPartsHtml += `
|
|
290
|
+
dirPartsHtml += `
|
|
272
291
|
<span class="directory_separator">/</span>`;
|
|
273
|
-
}
|
|
274
292
|
i++;
|
|
275
293
|
}
|
|
276
294
|
if (isDir) {
|
|
@@ -279,12 +297,15 @@ const generateDirectoryNav = (relativeUrl, rootDirectoryUrl) => {
|
|
|
279
297
|
}
|
|
280
298
|
return dirPartsHtml;
|
|
281
299
|
};
|
|
282
|
-
const generateDirectoryContentItems = (
|
|
300
|
+
const generateDirectoryContentItems = (
|
|
301
|
+
directoryUrl,
|
|
302
|
+
rootDirectoryUrlForServer,
|
|
303
|
+
) => {
|
|
283
304
|
let firstExistingDirectoryUrl = new URL("./", directoryUrl);
|
|
284
305
|
while (!existsSync(firstExistingDirectoryUrl)) {
|
|
285
306
|
firstExistingDirectoryUrl = new URL("../", firstExistingDirectoryUrl);
|
|
286
|
-
if (!urlIsInsideOf(firstExistingDirectoryUrl,
|
|
287
|
-
firstExistingDirectoryUrl = new URL(
|
|
307
|
+
if (!urlIsInsideOf(firstExistingDirectoryUrl, rootDirectoryUrlForServer)) {
|
|
308
|
+
firstExistingDirectoryUrl = new URL(rootDirectoryUrlForServer);
|
|
288
309
|
break;
|
|
289
310
|
}
|
|
290
311
|
}
|
|
@@ -294,37 +315,42 @@ const generateDirectoryContentItems = (directoryUrl, rootDirectoryUrl) => {
|
|
|
294
315
|
const fileUrlObject = new URL(filename, firstExistingDirectoryUrl);
|
|
295
316
|
fileUrls.push(fileUrlObject);
|
|
296
317
|
}
|
|
318
|
+
let rootDirectoryUrl = rootDirectoryUrlForServer;
|
|
297
319
|
package_workspaces: {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const packageDirectoryUrl = lookupPackageDirectory(rootDirectoryUrl);
|
|
320
|
+
const packageDirectoryUrl = lookupPackageDirectory(
|
|
321
|
+
rootDirectoryUrlForServer,
|
|
322
|
+
);
|
|
302
323
|
if (!packageDirectoryUrl) {
|
|
303
324
|
break package_workspaces;
|
|
304
325
|
}
|
|
305
|
-
if (String(packageDirectoryUrl) === String(
|
|
326
|
+
if (String(packageDirectoryUrl) === String(rootDirectoryUrlForServer)) {
|
|
306
327
|
break package_workspaces;
|
|
307
328
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
329
|
+
rootDirectoryUrl = packageDirectoryUrl;
|
|
330
|
+
if (
|
|
331
|
+
String(firstExistingDirectoryUrl) === String(rootDirectoryUrlForServer)
|
|
332
|
+
) {
|
|
333
|
+
let packageContent;
|
|
334
|
+
try {
|
|
335
|
+
packageContent = JSON.parse(
|
|
336
|
+
readFileSync(new URL("package.json", packageDirectoryUrl), "utf8"),
|
|
337
|
+
);
|
|
338
|
+
} catch {
|
|
339
|
+
break package_workspaces;
|
|
340
|
+
}
|
|
341
|
+
const { workspaces } = packageContent;
|
|
342
|
+
if (Array.isArray(workspaces)) {
|
|
343
|
+
for (const workspace of workspaces) {
|
|
344
|
+
const workspaceUrlObject = new URL(workspace, packageDirectoryUrl);
|
|
345
|
+
const workspaceUrl = workspaceUrlObject.href;
|
|
346
|
+
if (workspaceUrl.endsWith("*")) {
|
|
347
|
+
const directoryUrl = ensurePathnameTrailingSlash(
|
|
348
|
+
workspaceUrl.slice(0, -1),
|
|
349
|
+
);
|
|
350
|
+
fileUrls.push(new URL(directoryUrl));
|
|
351
|
+
} else {
|
|
352
|
+
fileUrls.push(ensurePathnameTrailingSlash(workspaceUrlObject));
|
|
353
|
+
}
|
|
328
354
|
}
|
|
329
355
|
}
|
|
330
356
|
}
|
|
@@ -348,14 +374,18 @@ const generateDirectoryContentItems = (directoryUrl, rootDirectoryUrl) => {
|
|
|
348
374
|
sortedUrl,
|
|
349
375
|
firstExistingDirectoryUrl,
|
|
350
376
|
);
|
|
351
|
-
const
|
|
377
|
+
const fileUrlRelativeToServer = urlToRelativeUrl(
|
|
378
|
+
sortedUrl,
|
|
379
|
+
rootDirectoryUrlForServer,
|
|
380
|
+
);
|
|
352
381
|
const type = fileUrlRelativeToParent.endsWith("/") ? "dir" : "file";
|
|
353
382
|
items.push({
|
|
354
383
|
type,
|
|
355
384
|
fileUrlRelativeToParent,
|
|
356
|
-
|
|
385
|
+
fileUrlRelativeToServer,
|
|
357
386
|
});
|
|
358
387
|
}
|
|
388
|
+
items.rootDirectoryUrlForServer = rootDirectoryUrlForServer;
|
|
359
389
|
items.rootDirectoryUrl = rootDirectoryUrl;
|
|
360
390
|
items.firstExistingDirectoryUrl = firstExistingDirectoryUrl;
|
|
361
391
|
return items;
|
|
@@ -366,11 +396,15 @@ const generateDirectoryContent = (directoryContentItems) => {
|
|
|
366
396
|
}
|
|
367
397
|
let html = `<ul class="directory_content">`;
|
|
368
398
|
for (const directoryContentItem of directoryContentItems) {
|
|
369
|
-
const { type, fileUrlRelativeToParent,
|
|
399
|
+
const { type, fileUrlRelativeToParent, fileUrlRelativeToServer } =
|
|
370
400
|
directoryContentItem;
|
|
401
|
+
let href = fileUrlRelativeToServer;
|
|
402
|
+
if (href === "") {
|
|
403
|
+
href = `${directoryContentMagicName}`;
|
|
404
|
+
}
|
|
371
405
|
html += `
|
|
372
406
|
<li class="directory_child" data-type="${type}">
|
|
373
|
-
<a href="/${
|
|
407
|
+
<a href="/${href}">${fileUrlRelativeToParent}</a>
|
|
374
408
|
</li>`;
|
|
375
409
|
}
|
|
376
410
|
html += `\n </ul>`;
|