Skip to content

Commit e13bd00

Browse files
committed
fix windows and add more debugging
1 parent 755e346 commit e13bd00

2 files changed

Lines changed: 53 additions & 6 deletions

File tree

auth.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ export function createTrpcClient(debug: boolean, deployUrl: string) {
6262
errorLink,
6363
retryLink({
6464
retry({ error: err }) {
65-
if (!(err?.data?.code !== "NOT_AUTHENTICATED" && err?.data?.code !== "TOKEN_EXPIRED")) {
65+
if (
66+
!(err?.data?.code !== "NOT_AUTHENTICATED" &&
67+
err?.data?.code !== "TOKEN_EXPIRED")
68+
) {
6669
return false;
6770
}
6871

publish.ts

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { compile as gitignoreCompile } from "@cfa/gitignore-parser";
33
import { walk, type WalkEntry } from "@std/fs";
44
import { ProgressBar } from "@std/cli/unstable-progress-bar";
55
import { Spinner } from "@std/cli/unstable-spinner";
6-
import { join, relative, resolve } from "@std/path";
6+
import { join, relative, resolve, SEPARATOR } from "@std/path";
77
import { green, yellow } from "@std/fmt/colors";
88
import { type Config, writeConfig } from "./config.ts";
99
import { authedFetch, createTrpcClient } from "./auth.ts";
@@ -56,13 +56,31 @@ export async function publish(
5656
const path = relative(rootPath, chunk.path);
5757
const relativePath = join(
5858
"source",
59-
path + (chunk.isDirectory ? "/" : ""),
59+
path + (chunk.isDirectory ? SEPARATOR : ""),
6060
);
6161
if (gitignore.denies(relativePath)) {
62+
if (debug) {
63+
console.log(
64+
`skipping ${JSON.stringify(relativePath)} (${
65+
chunk.isDirectory ? "dir" : "file"
66+
})`,
67+
);
68+
}
6269
return;
6370
}
71+
if (debug) {
72+
console.log(
73+
`walking ${JSON.stringify(relativePath)} (${
74+
chunk.isDirectory ? "dir" : "file"
75+
})`,
76+
);
77+
}
6478

6579
if (!chunk.isDirectory) {
80+
if (debug) {
81+
console.log(`reading ${JSON.stringify(relativePath)}`);
82+
}
83+
6684
const data = await Deno.readFile(chunk.path);
6785

6886
const hashBuffer = await crypto.subtle.digest("SHA-256", data!);
@@ -72,14 +90,14 @@ export async function publish(
7290

7391
controller.enqueue({
7492
chunk,
75-
relativePath,
93+
relativePath: relativePath.replaceAll(SEPARATOR, "/"),
7694
data,
7795
hash,
7896
});
7997
} else {
8098
controller.enqueue({
8199
chunk,
82-
relativePath,
100+
relativePath: relativePath.replaceAll(SEPARATOR, "/"),
83101
});
84102
}
85103
},
@@ -105,6 +123,10 @@ export async function publish(
105123
}
106124
hashesSpinner.stop();
107125

126+
if (debug) {
127+
console.log("Manifest", manifest);
128+
}
129+
108130
const trpcClient = createTrpcClient(debug, deployUrl);
109131

110132
// deno-lint-ignore no-explicit-any
@@ -171,6 +193,10 @@ export async function publish(
171193
);
172194
}
173195

196+
if (debug) {
197+
console.log("Missing hashes", missingHashes);
198+
}
199+
174200
const progress = new ProgressBar({
175201
max: missingHashes.length,
176202
emptyChar: " ",
@@ -194,7 +220,7 @@ export async function publish(
194220
},
195221
});
196222

197-
const tarball = body
223+
let tarball = body
198224
.pipeThrough(
199225
new TransformStream({
200226
async transform({ chunk, relativePath, data, hash }, controller) {
@@ -219,12 +245,30 @@ export async function publish(
219245
} satisfies TarStreamFile,
220246
);
221247
}
248+
249+
if (debug) {
250+
console.log(
251+
`uploading ${JSON.stringify(relativePath)} (${
252+
chunk.isDirectory ? "dir" : "file"
253+
})`,
254+
);
255+
}
222256
},
223257
}),
224258
)
225259
.pipeThrough(new TarStream())
226260
.pipeThrough(new CompressionStream("gzip"));
227261

262+
if (debug) {
263+
const [tb1, tb2] = tarball.tee();
264+
tarball = tb1;
265+
const path = await Deno.makeTempFile({
266+
suffix: "debug.tar.gz",
267+
});
268+
await Deno.writeFile(path, tb2);
269+
console.log(`Created debug tarball at '${path}'`);
270+
}
271+
228272
const resp = await authedFetch(
229273
debug,
230274
deployUrl,

0 commit comments

Comments
 (0)