trajectories-sh 1.18.6 → 1.18.8
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
|
@@ -98,7 +98,7 @@ async function uploadTrajectoryAction(pathArg, opts) {
|
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
100
|
if (isZip) {
|
|
101
|
-
const { uploadZip } = await import("./upload-
|
|
101
|
+
const { uploadZip } = await import("./upload-5RQ45JUQ.js");
|
|
102
102
|
const slug2 = opts.slug ?? pathArg.replace(/\.zip$/i, "").replace(/\/+$/, "").split("/").pop();
|
|
103
103
|
console.log(chalk.bold(`
|
|
104
104
|
Uploading ZIP ${pathArg} \u2192 ${chalk.cyan(slug2)}
|
|
@@ -127,7 +127,7 @@ async function uploadTrajectoryAction(pathArg, opts) {
|
|
|
127
127
|
Uploading trajectory ${pathArg} \u2192 ${chalk.cyan(slug)}
|
|
128
128
|
`));
|
|
129
129
|
try {
|
|
130
|
-
const { uploadJob } = await import("./upload-
|
|
130
|
+
const { uploadJob } = await import("./upload-5RQ45JUQ.js");
|
|
131
131
|
const result = await uploadJob(pathArg, {
|
|
132
132
|
slug,
|
|
133
133
|
name: opts.name
|
|
@@ -51,7 +51,7 @@ async function apiPost(path, body, timeout = 3e5) {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
async function uploadZip(zipPath, opts) {
|
|
54
|
-
const {
|
|
54
|
+
const { statSync: _statSync } = await import("fs");
|
|
55
55
|
const fileStat = _statSync(zipPath);
|
|
56
56
|
const sizeBytes = fileStat.size;
|
|
57
57
|
const sizeMB = (sizeBytes / (1024 * 1024)).toFixed(1);
|
|
@@ -60,30 +60,55 @@ async function uploadZip(zipPath, opts) {
|
|
|
60
60
|
const auth = await getAuthHeader();
|
|
61
61
|
if (!auth) throw new Error("Not authenticated. Run: trajectories auth login");
|
|
62
62
|
const apiUrl = getApiUrl();
|
|
63
|
-
console.log(" Requesting upload
|
|
64
|
-
const
|
|
63
|
+
console.log(" Requesting upload info...");
|
|
64
|
+
const infoResp = await fetch(`${apiUrl}/api/cli/push-zip/upload-url`, {
|
|
65
65
|
method: "POST",
|
|
66
66
|
headers: { Authorization: auth, "Content-Type": "application/json" },
|
|
67
67
|
body: "{}",
|
|
68
68
|
signal: AbortSignal.timeout(3e4)
|
|
69
69
|
});
|
|
70
|
-
if (!
|
|
71
|
-
throw new Error(`Failed to get upload
|
|
70
|
+
if (!infoResp.ok) {
|
|
71
|
+
throw new Error(`Failed to get upload info: ${await infoResp.text()}`);
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
const uploadInfo = await infoResp.json();
|
|
74
|
+
const task_id = uploadInfo.task_id;
|
|
75
|
+
console.log(" Uploading ZIP via resumable upload...");
|
|
76
|
+
const { createReadStream } = await import("fs");
|
|
77
|
+
const tus = await import("tus-js-client");
|
|
78
|
+
await new Promise((resolve, reject) => {
|
|
79
|
+
const fileStream = createReadStream(zipPath);
|
|
80
|
+
const upload = new tus.Upload(fileStream, {
|
|
81
|
+
endpoint: `${uploadInfo.supabase_url}/storage/v1/upload/resumable`,
|
|
82
|
+
uploadSize: sizeBytes,
|
|
83
|
+
retryDelays: [0, 3e3, 5e3, 1e4],
|
|
84
|
+
headers: {
|
|
85
|
+
authorization: `Bearer ${uploadInfo.service_key}`,
|
|
86
|
+
"x-upsert": "true"
|
|
87
|
+
},
|
|
88
|
+
uploadDataDuringCreation: true,
|
|
89
|
+
removeFingerprintOnSuccess: true,
|
|
90
|
+
metadata: {
|
|
91
|
+
bucketName: uploadInfo.bucket,
|
|
92
|
+
objectName: uploadInfo.storage_path,
|
|
93
|
+
contentType: "application/zip"
|
|
94
|
+
},
|
|
95
|
+
chunkSize: 6 * 1024 * 1024,
|
|
96
|
+
onError(error) {
|
|
97
|
+
reject(new Error(`TUS upload failed: ${error.message}`));
|
|
98
|
+
},
|
|
99
|
+
onProgress(bytesUploaded, bytesTotal) {
|
|
100
|
+
const pct = (bytesUploaded / bytesTotal * 100).toFixed(1);
|
|
101
|
+
const uploadedMB = (bytesUploaded / (1024 * 1024)).toFixed(1);
|
|
102
|
+
const totalMB = (bytesTotal / (1024 * 1024)).toFixed(1);
|
|
103
|
+
process.stdout.write(` \u2191 ${pct}% ${uploadedMB}/${totalMB} MB\r`);
|
|
104
|
+
},
|
|
105
|
+
onSuccess() {
|
|
106
|
+
console.log(` \u2191 100% \u2014 ZIP uploaded to storage.`);
|
|
107
|
+
resolve();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
upload.start();
|
|
81
111
|
});
|
|
82
|
-
if (!putResp.ok) {
|
|
83
|
-
const body = await putResp.text().catch(() => "");
|
|
84
|
-
throw new Error(`ZIP upload to storage failed (${putResp.status}): ${body.slice(0, 200)}`);
|
|
85
|
-
}
|
|
86
|
-
console.log(" ZIP uploaded to storage.");
|
|
87
112
|
console.log(" Enqueuing for server-side extraction...");
|
|
88
113
|
const enqueueResp = await fetch(`${apiUrl}/api/cli/push-zip/enqueue`, {
|
|
89
114
|
method: "POST",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trajectories-sh",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.8",
|
|
4
4
|
"description": "CLI for uploading trajectory jobs to trajectories.sh",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"chalk": "^5.0.0",
|
|
30
30
|
"commander": "^13.0.0",
|
|
31
|
-
"sharp": "^0.34.5",
|
|
32
31
|
"open": "^10.0.0",
|
|
33
32
|
"ora": "^8.0.0",
|
|
34
|
-
"
|
|
33
|
+
"sharp": "^0.34.5",
|
|
34
|
+
"tar": "^7.0.0",
|
|
35
|
+
"tus-js-client": "^4.3.1"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/node": "^22.0.0",
|