trajectories-sh 1.16.0 → 1.17.0
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/cli.js
CHANGED
|
@@ -95,7 +95,7 @@ async function uploadTrajectoryAction(directory, opts) {
|
|
|
95
95
|
Uploading trajectory ${directory} \u2192 ${chalk.cyan(slug)}
|
|
96
96
|
`));
|
|
97
97
|
try {
|
|
98
|
-
const { uploadJob } = await import("./upload-
|
|
98
|
+
const { uploadJob } = await import("./upload-V5ZE557B.js");
|
|
99
99
|
const result = await uploadJob(directory, {
|
|
100
100
|
slug,
|
|
101
101
|
name: opts.name
|
|
@@ -16,6 +16,7 @@ var WEBP_CONCURRENCY = Number(process.env.TRAJECTORIES_CLI_WEBP_CONCURRENCY ?? "
|
|
|
16
16
|
var HASH_CONCURRENCY = Number(process.env.TRAJECTORIES_CLI_HASH_CONCURRENCY ?? "16");
|
|
17
17
|
function collectFiles(dir) {
|
|
18
18
|
const files = [];
|
|
19
|
+
const skipped = [];
|
|
19
20
|
function walk(current) {
|
|
20
21
|
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
21
22
|
if (SKIP.has(entry.name)) continue;
|
|
@@ -24,14 +25,17 @@ function collectFiles(dir) {
|
|
|
24
25
|
walk(full);
|
|
25
26
|
} else if (entry.isFile()) {
|
|
26
27
|
const st = statSync(full);
|
|
28
|
+
const collected = { absPath: full, relPath: relative(dir, full), size: st.size };
|
|
27
29
|
if (st.size <= MAX_FILE_SIZE) {
|
|
28
|
-
files.push(
|
|
30
|
+
files.push(collected);
|
|
31
|
+
} else {
|
|
32
|
+
skipped.push(collected);
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
walk(dir);
|
|
34
|
-
return files;
|
|
38
|
+
return { files, skipped };
|
|
35
39
|
}
|
|
36
40
|
async function apiPost(path, body, timeout = 3e5) {
|
|
37
41
|
const auth = await getAuthHeader();
|
|
@@ -44,7 +48,7 @@ async function apiPost(path, body, timeout = 3e5) {
|
|
|
44
48
|
});
|
|
45
49
|
}
|
|
46
50
|
async function convertToWebP(dir) {
|
|
47
|
-
const files = collectFiles(dir);
|
|
51
|
+
const { files } = collectFiles(dir);
|
|
48
52
|
const pngs = files.filter((f) => f.relPath.toLowerCase().endsWith(".png"));
|
|
49
53
|
if (pngs.length === 0) {
|
|
50
54
|
return { convertedDir: dir, pngsConverted: 0, savedBytes: 0 };
|
|
@@ -119,7 +123,7 @@ async function convertToWebP(dir) {
|
|
|
119
123
|
} catch {
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
|
-
const trajFiles = collectFiles(tmpDir).filter((f) => f.relPath.endsWith("trajectory.json"));
|
|
126
|
+
const trajFiles = collectFiles(tmpDir).files.filter((f) => f.relPath.endsWith("trajectory.json"));
|
|
123
127
|
for (const tf of trajFiles) {
|
|
124
128
|
try {
|
|
125
129
|
let content = readFileSync(tf.absPath, "utf-8");
|
|
@@ -174,7 +178,7 @@ async function computeContentHash(files) {
|
|
|
174
178
|
}
|
|
175
179
|
function validateAtifFormat(dir) {
|
|
176
180
|
const errors = [];
|
|
177
|
-
const files = collectFiles(dir);
|
|
181
|
+
const { files } = collectFiles(dir);
|
|
178
182
|
const relPaths = new Set(files.map((f) => f.relPath));
|
|
179
183
|
if (!relPaths.has("result.json")) {
|
|
180
184
|
errors.push("Missing result.json at the job root");
|
|
@@ -306,9 +310,24 @@ async function uploadJob(dir, opts) {
|
|
|
306
310
|
if (pngsConverted > 0) {
|
|
307
311
|
console.log(` \u2713 Converted ${pngsConverted} PNGs to WebP (saved ${(savedBytes / 1024 / 1024).toFixed(1)} MB)`);
|
|
308
312
|
}
|
|
309
|
-
const files = collectFiles(convertedDir);
|
|
313
|
+
const { files, skipped } = collectFiles(convertedDir);
|
|
310
314
|
const totalSize = files.reduce((s, f) => s + f.size, 0);
|
|
311
315
|
console.log(` ${files.length} files, ${(totalSize / 1024 / 1024).toFixed(1)} MB`);
|
|
316
|
+
if (skipped.length > 0) {
|
|
317
|
+
const skippedMB = skipped.reduce((s, f) => s + f.size, 0) / (1024 * 1024);
|
|
318
|
+
const limitMB = MAX_FILE_SIZE / (1024 * 1024);
|
|
319
|
+
const samples = skipped.sort((a, b) => b.size - a.size).slice(0, 5).map((f) => ` \u2022 ${f.relPath} (${(f.size / 1024 / 1024).toFixed(1)} MB)`).join("\n");
|
|
320
|
+
const more = skipped.length > 5 ? `
|
|
321
|
+
\u2026 and ${skipped.length - 5} more` : "";
|
|
322
|
+
console.warn(
|
|
323
|
+
`
|
|
324
|
+
\u26A0 Skipping ${skipped.length} file${skipped.length > 1 ? "s" : ""} larger than ${limitMB.toFixed(0)} MB (${skippedMB.toFixed(1)} MB total):
|
|
325
|
+
${samples}${more}
|
|
326
|
+
These won't appear in the uploaded trajectory. Split or
|
|
327
|
+
compress them first if you need them included.
|
|
328
|
+
`
|
|
329
|
+
);
|
|
330
|
+
}
|
|
312
331
|
process.stdout.write(` Hashing...\r`);
|
|
313
332
|
const t0 = Date.now();
|
|
314
333
|
const contentHash = await computeContentHash(files);
|