@@ -3,7 +3,7 @@ import { compile as gitignoreCompile } from "@cfa/gitignore-parser";
33import { walk , type WalkEntry } from "@std/fs" ;
44import { ProgressBar } from "@std/cli/unstable-progress-bar" ;
55import { Spinner } from "@std/cli/unstable-spinner" ;
6- import { join , relative , resolve } from "@std/path" ;
6+ import { join , relative , resolve , SEPARATOR } from "@std/path" ;
77import { green , yellow } from "@std/fmt/colors" ;
88import { type Config , writeConfig } from "./config.ts" ;
99import { 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