|
1 | | -// Vercel provider. Uses the REST API: |
2 | | -// POST /v13/files upload each file (x-vercel-digest: sha256) |
| 1 | +// Vercel provider. Uses the REST API (contract verified 2026-08 against |
| 2 | +// vercel.com/docs/rest-api/deployments/upload-deployment-files): |
| 3 | +// POST /v2/files upload each file (x-vercel-digest: sha1) |
3 | 4 | // POST /v13/deployments create deployment referencing uploaded shas |
4 | 5 | // GET /v9/projects?name= resolve a project id by name |
5 | 6 | // POST /v9/projects/{id}/rollback/{deploymentId} instant rollback (as the Vercel CLI uses) |
@@ -70,22 +71,24 @@ export async function login({ flags }) { |
70 | 71 | } |
71 | 72 |
|
72 | 73 | /** |
73 | | - * Upload every file once via POST /v13/files, keyed by sha256, and return the |
74 | | - * manifest entries Vercel expects ({ file, sha, size }). Skipping unchanged |
75 | | - * files is handled by treating 409 (already exists) as success. |
| 74 | + * Upload every file once via POST /v2/files, keyed by SHA1 (the documented |
| 75 | + * digest for the upload API and for deployment file references), and return |
| 76 | + * the manifest entries Vercel expects ({ file, sha, size }). A 409 (already |
| 77 | + * exists) is treated as success, as is the 200 "file already uploaded" reply. |
76 | 78 | */ |
77 | 79 | async function uploadFiles(token, files) { |
78 | 80 | const manifest = []; |
79 | 81 | let done = 0; |
80 | 82 | for (const f of files) { |
81 | 83 | const content = await fs.promises.readFile(f.path); |
82 | | - const sha = crypto.createHash("sha256").update(content).digest("hex"); |
83 | | - const url = new URL(BASE() + "/v13/files"); |
| 84 | + const sha = crypto.createHash("sha1").update(content).digest("hex"); |
| 85 | + const url = new URL(BASE() + "/v2/files"); |
84 | 86 | const res = await apiFetch(url, { |
85 | 87 | method: "POST", |
86 | 88 | headers: { |
87 | 89 | Authorization: `Bearer ${token}`, |
88 | 90 | "Content-Type": "application/octet-stream", |
| 91 | + "Content-Length": String(content.length), |
89 | 92 | "x-vercel-digest": sha, |
90 | 93 | }, |
91 | 94 | body: content, |
|
0 commit comments