@cydm/happy-elves 0.1.0-beta.47 → 0.1.0-beta.48
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.
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { MachineCommand } from "../../../../packages/shared/dist/index.js";
|
|
2
2
|
import type { DaemonConfig, DirectoryListResult } from "../types.js";
|
|
3
|
+
export declare function availableWindowsDriveRoots(options?: {
|
|
4
|
+
platform?: NodeJS.Platform;
|
|
5
|
+
access?: (target: string) => Promise<unknown>;
|
|
6
|
+
}): Promise<string[]>;
|
|
3
7
|
export declare function buildDirectoryList(config: DaemonConfig, requestedPath?: string): Promise<DirectoryListResult>;
|
|
4
8
|
export declare function handleListDirectory(ws: WebSocket, config: DaemonConfig, command: MachineCommand): Promise<void>;
|
|
@@ -5,6 +5,7 @@ import { claimCommandRequest, sendCommandResponse } from "../relay/send.js";
|
|
|
5
5
|
import { isUncPath, workspaceRealRoots } from "./workspace-paths.js";
|
|
6
6
|
const directoryEntryLimit = 500;
|
|
7
7
|
const directoryStatConcurrency = 16;
|
|
8
|
+
const windowsDriveLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
8
9
|
async function findRepoRoot(startPath) {
|
|
9
10
|
let current = startPath;
|
|
10
11
|
while (true) {
|
|
@@ -40,12 +41,38 @@ async function directoryRoots(workspaceRoots, currentPath) {
|
|
|
40
41
|
for (const root of workspaceRoots)
|
|
41
42
|
await add(root);
|
|
42
43
|
await add(os.homedir(), "home");
|
|
43
|
-
|
|
44
|
+
const currentRoot = path.parse(currentPath).root;
|
|
45
|
+
await add(currentRoot, filesystemRootName(currentRoot));
|
|
44
46
|
const homeRoot = path.parse(os.homedir()).root;
|
|
45
|
-
if (homeRoot !==
|
|
46
|
-
await add(homeRoot);
|
|
47
|
+
if (homeRoot !== currentRoot)
|
|
48
|
+
await add(homeRoot, filesystemRootName(homeRoot));
|
|
49
|
+
for (const driveRoot of await availableWindowsDriveRoots())
|
|
50
|
+
await add(driveRoot, filesystemRootName(driveRoot));
|
|
47
51
|
return roots;
|
|
48
52
|
}
|
|
53
|
+
export async function availableWindowsDriveRoots(options = {}) {
|
|
54
|
+
const platform = options.platform ?? process.platform;
|
|
55
|
+
if (platform !== "win32")
|
|
56
|
+
return [];
|
|
57
|
+
const access = options.access ?? ((target) => fs.access(target));
|
|
58
|
+
const roots = await Promise.all([...windowsDriveLetters].map(async (letter) => {
|
|
59
|
+
const root = `${letter}:\\`;
|
|
60
|
+
try {
|
|
61
|
+
await access(root);
|
|
62
|
+
return root;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
return roots.filter((root) => Boolean(root));
|
|
69
|
+
}
|
|
70
|
+
function filesystemRootName(root) {
|
|
71
|
+
const match = /^([A-Za-z]:)[\\/]*$/u.exec(root);
|
|
72
|
+
if (match)
|
|
73
|
+
return match[1];
|
|
74
|
+
return root;
|
|
75
|
+
}
|
|
49
76
|
export async function buildDirectoryList(config, requestedPath) {
|
|
50
77
|
if (requestedPath && isUncPath(requestedPath)) {
|
|
51
78
|
throw Object.assign(new Error("UNC paths are not supported for directory browsing."), { code: "DIRECTORY_UNSUPPORTED_PATH" });
|
package/apps/daemon/package.json
CHANGED
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cydm/happy-elves",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.48",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@cydm/happy-elves",
|
|
9
|
-
"version": "0.1.0-beta.
|
|
9
|
+
"version": "0.1.0-beta.48",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fastify/cors": "11.2.0",
|
|
@@ -1021,9 +1021,9 @@
|
|
|
1021
1021
|
}
|
|
1022
1022
|
},
|
|
1023
1023
|
"node_modules/fast-uri": {
|
|
1024
|
-
"version": "3.1.
|
|
1025
|
-
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.
|
|
1026
|
-
"integrity": "sha512-
|
|
1024
|
+
"version": "3.1.3",
|
|
1025
|
+
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.3.tgz",
|
|
1026
|
+
"integrity": "sha512-i70LwGWUduXqzicKXWshooq+sWL1K3WUU5rKZNG/0i3a1OSoX3HqhH5WbWwTmqWfor4urUakGPiRQcleRZTwOg==",
|
|
1027
1027
|
"funding": [
|
|
1028
1028
|
{
|
|
1029
1029
|
"type": "github",
|