@playcraft/cli 0.1.38-beta → 0.1.40-beta
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.
|
@@ -55,45 +55,63 @@ export async function readWorkspaceFile(root, relativePath, revisions) {
|
|
|
55
55
|
export async function listWorkspaceFiles(root, revisions) {
|
|
56
56
|
const rootReal = await ensureWorkspaceRoot(root);
|
|
57
57
|
const files = [];
|
|
58
|
-
|
|
58
|
+
const unreadablePaths = new Set();
|
|
59
|
+
for (const relativePath of await walkWorkspaceFiles(rootReal, rootReal, unreadablePaths)) {
|
|
59
60
|
const target = join(rootReal, ...relativePath.split('/'));
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
try {
|
|
62
|
+
if ((await lstat(target)).size > LARGE_FILE_STREAM_THRESHOLD) {
|
|
63
|
+
const sampled = await sampleDiskFile(target);
|
|
64
|
+
files.push({ path: relativePath, revision: revisions[relativePath]?.revision ?? 0, contentHash: sampled.hash, size: sampled.size });
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const content = await readFile(target, 'utf8');
|
|
68
|
+
files.push({
|
|
69
|
+
path: relativePath,
|
|
70
|
+
revision: revisions[relativePath]?.revision ?? 0,
|
|
71
|
+
contentHash: hashWorkspaceFileContent(content),
|
|
72
|
+
size: Buffer.byteLength(content, 'utf8'),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (!isPermissionDenied(error))
|
|
77
|
+
throw error;
|
|
78
|
+
unreadablePaths.add(relativePath);
|
|
64
79
|
}
|
|
65
|
-
const content = await readFile(target, 'utf8');
|
|
66
|
-
files.push({
|
|
67
|
-
path: relativePath,
|
|
68
|
-
revision: revisions[relativePath]?.revision ?? 0,
|
|
69
|
-
contentHash: hashWorkspaceFileContent(content),
|
|
70
|
-
size: Buffer.byteLength(content, 'utf8'),
|
|
71
|
-
});
|
|
72
80
|
}
|
|
73
81
|
files.sort((left, right) => left.path.localeCompare(right.path));
|
|
74
|
-
return workspaceFileListSchema.parse({ files });
|
|
82
|
+
return workspaceFileListSchema.parse({ files, ...(unreadablePaths.size ? { unreadablePaths: [...unreadablePaths].sort() } : {}) });
|
|
75
83
|
}
|
|
76
|
-
async function walkWorkspaceFiles(rootReal, current) {
|
|
84
|
+
async function walkWorkspaceFiles(rootReal, current, unreadablePaths) {
|
|
77
85
|
const entries = await readdir(current, { withFileTypes: true });
|
|
78
86
|
const paths = [];
|
|
79
87
|
for (const entry of entries) {
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
const child = join(current, entry.name);
|
|
89
|
+
try {
|
|
90
|
+
if (entry.isDirectory()) {
|
|
91
|
+
if (SKIP_DIRECTORY_NAMES.has(entry.name) || entry.name === '.' || entry.name === '..')
|
|
92
|
+
continue;
|
|
93
|
+
const childReal = await realpath(child);
|
|
94
|
+
assertInsideRoot(rootReal, childReal);
|
|
95
|
+
paths.push(...(await walkWorkspaceFiles(rootReal, childReal, unreadablePaths)));
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (!entry.isFile())
|
|
82
99
|
continue;
|
|
83
|
-
const child = join(current, entry.name);
|
|
84
100
|
const childReal = await realpath(child);
|
|
85
101
|
assertInsideRoot(rootReal, childReal);
|
|
86
|
-
paths.push(
|
|
87
|
-
|
|
102
|
+
paths.push(toPosixRelative(rootReal, childReal));
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (!isPermissionDenied(error))
|
|
106
|
+
throw error;
|
|
107
|
+
unreadablePaths.add(toPosixRelative(rootReal, child));
|
|
88
108
|
}
|
|
89
|
-
if (!entry.isFile())
|
|
90
|
-
continue;
|
|
91
|
-
const childReal = await realpath(join(current, entry.name));
|
|
92
|
-
assertInsideRoot(rootReal, childReal);
|
|
93
|
-
paths.push(toPosixRelative(rootReal, childReal));
|
|
94
109
|
}
|
|
95
110
|
return paths;
|
|
96
111
|
}
|
|
112
|
+
function isPermissionDenied(error) {
|
|
113
|
+
return ['EACCES', 'EPERM'].includes(String(error?.code));
|
|
114
|
+
}
|
|
97
115
|
async function assertParentInsideRoot(rootReal, parent) {
|
|
98
116
|
if (parent === rootReal)
|
|
99
117
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcraft/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40-beta",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"@gltf-transform/core": "^4.3.0",
|
|
52
52
|
"@gltf-transform/extensions": "^4.3.0",
|
|
53
53
|
"@gltf-transform/functions": "^4.3.0",
|
|
54
|
-
"@playcraft/build": "^0.1.
|
|
55
|
-
"@playcraft/common": "^0.1.
|
|
54
|
+
"@playcraft/build": "^0.1.40-beta",
|
|
55
|
+
"@playcraft/common": "^0.1.40-beta",
|
|
56
56
|
"better-sqlite3-pinned": "npm:better-sqlite3@13.0.3",
|
|
57
57
|
"chokidar": "^4.0.3",
|
|
58
58
|
"commander": "^13.1.0",
|