From 1f725ddd27b3e0d9cd872a833fc170ac80986206 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 23 Sep 2025 15:35:46 +0200 Subject: [PATCH 1/3] publish, connect - fix tar bundle creation using temp context (cherry picked from commit 11dd48cca7dff3fadd9fefc86dc19c8cc075f3e7) --- src/deno_ral/tar.ts | 22 ++++++++++++++++------ src/publish/common/bundle.ts | 5 +---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/deno_ral/tar.ts b/src/deno_ral/tar.ts index f9065c3a445..65e4bb2b0ac 100644 --- a/src/deno_ral/tar.ts +++ b/src/deno_ral/tar.ts @@ -6,36 +6,46 @@ * Abstraction layer over Deno's `tar` utilities. */ -import { TarStream, type TarStreamInput } from "jsr:@std/tar/tar-stream"; +import { TarStream, type TarStreamInput } from "tar/tar-stream"; +import { join } from "../deno_ral/path.ts"; /** * Creates a tar archive from the specified files and directories. * @param outputPath The path where the tar archive will be created. - * @param filePaths An array of file and directory paths to include in the tar archive. Paths are relative to outputPath. + * @param filePaths An array of file and directory paths to include in the tar archive. + * @param options Optional configuration for tar creation. + * @param options.baseDir Base directory for resolving relative paths in the archive. * @returns A promise that resolves when the tar archive is created. */ export async function createTarFromFiles( outputPath: string, filePaths: string[], + options?: { baseDir?: string }, ) { + const baseDir = options?.baseDir; + // Create array of TarStreamInput objects from file paths const inputs: TarStreamInput[] = await Promise.all( filePaths.map(async (path) => { - const stat = await Deno.stat(path); + const fullPath = baseDir ? join(baseDir, path) : path; + const stat = await Deno.stat(fullPath); + + // Use original path for archive, full path for reading + const archivePath = path; if (stat.isDirectory) { // Handle directory return { type: "directory", - path: path + (path.endsWith("/") ? "" : "/"), + path: archivePath + (archivePath.endsWith("/") ? "" : "/"), }; } else { // Handle file return { type: "file", - path: path, + path: archivePath, size: stat.size, - readable: (await Deno.open(path)).readable, + readable: (await Deno.open(fullPath)).readable, }; } }), diff --git a/src/publish/common/bundle.ts b/src/publish/common/bundle.ts index b3d2f70c80e..5d8c7c20a7a 100644 --- a/src/publish/common/bundle.ts +++ b/src/publish/common/bundle.ts @@ -10,10 +10,7 @@ import { ensureDirSync } from "../../deno_ral/fs.ts"; import { PublishFiles } from "../provider-types.ts"; import { TempContext } from "../../core/temp-types.ts"; import { md5HashBytes } from "../../core/hash.ts"; -import { pathWithForwardSlashes } from "../../core/path.ts"; -import { copy } from "io/copy"; -import { TarStream, type TarStreamInput } from "tar/tar-stream"; import { createTarFromFiles } from "../../deno_ral/tar.ts"; interface ManifestMetadata { @@ -110,7 +107,7 @@ export async function createBundle( // await copy(tar.getReader(), writer); // writer.close(); - await createTarFromFiles(tarFile, tarFiles); + await createTarFromFiles(tarFile, tarFiles, { baseDir: stageDir }); // compress to tar.gz const targzFile = `${tarFile}.gz`; From 004f7f4681153caf6f2e306208bc3699d94f5436 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 23 Sep 2025 16:37:21 +0200 Subject: [PATCH 2/3] Correctly normalize to forward slash the path when creating tar.gz for Connect deploys std/tar will create folders based on file paths used, but it requires using / and not \\ in path. This is a problem on Windows, where the path separator is \\. This commit normalize the path to use / instead of \\ when creating the tar.gz file for Connect deploys. (cherry picked from commit ffb74591f7484c247b59c51b0e0dc972a834f1df) --- src/deno_ral/tar.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/deno_ral/tar.ts b/src/deno_ral/tar.ts index 65e4bb2b0ac..522d9577c7c 100644 --- a/src/deno_ral/tar.ts +++ b/src/deno_ral/tar.ts @@ -8,6 +8,7 @@ import { TarStream, type TarStreamInput } from "tar/tar-stream"; import { join } from "../deno_ral/path.ts"; +import { pathWithForwardSlashes } from "../core/path.ts"; /** * Creates a tar archive from the specified files and directories. @@ -31,7 +32,7 @@ export async function createTarFromFiles( const stat = await Deno.stat(fullPath); // Use original path for archive, full path for reading - const archivePath = path; + const archivePath = pathWithForwardSlashes(path); if (stat.isDirectory) { // Handle directory From a6162b947082ee544683b9b680aff1e8e4e3f314 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 24 Sep 2025 11:20:07 +0200 Subject: [PATCH 3/3] Add to changelog the regression fix --- news/changelog-1.8.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/news/changelog-1.8.md b/news/changelog-1.8.md index 25a2f738b6a..9b0fb66634f 100644 --- a/news/changelog-1.8.md +++ b/news/changelog-1.8.md @@ -1,4 +1,10 @@ -All changes included in 1.8: +# v1.9 backports + +## In this release + +- ([#13396](https://github.com/quarto-dev/quarto-cli/issues/13396)): Fix `quarto publish connect` regression. + +# v1.8 changes ## Regression fixes