Skip to content

Commit 11dd48c

Browse files
committed
publish, connect - fix tar bundle creation using temp context
1 parent 3c9950c commit 11dd48c

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/deno_ral/tar.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,46 @@
66
* Abstraction layer over Deno's `tar` utilities.
77
*/
88

9-
import { TarStream, type TarStreamInput } from "jsr:@std/tar/tar-stream";
9+
import { TarStream, type TarStreamInput } from "tar/tar-stream";
10+
import { join } from "../deno_ral/path.ts";
1011

1112
/**
1213
* Creates a tar archive from the specified files and directories.
1314
* @param outputPath The path where the tar archive will be created.
14-
* @param filePaths An array of file and directory paths to include in the tar archive. Paths are relative to outputPath.
15+
* @param filePaths An array of file and directory paths to include in the tar archive.
16+
* @param options Optional configuration for tar creation.
17+
* @param options.baseDir Base directory for resolving relative paths in the archive.
1518
* @returns A promise that resolves when the tar archive is created.
1619
*/
1720
export async function createTarFromFiles(
1821
outputPath: string,
1922
filePaths: string[],
23+
options?: { baseDir?: string },
2024
) {
25+
const baseDir = options?.baseDir;
26+
2127
// Create array of TarStreamInput objects from file paths
2228
const inputs: TarStreamInput[] = await Promise.all(
2329
filePaths.map(async (path) => {
24-
const stat = await Deno.stat(path);
30+
const fullPath = baseDir ? join(baseDir, path) : path;
31+
const stat = await Deno.stat(fullPath);
32+
33+
// Use original path for archive, full path for reading
34+
const archivePath = path;
2535

2636
if (stat.isDirectory) {
2737
// Handle directory
2838
return {
2939
type: "directory",
30-
path: path + (path.endsWith("/") ? "" : "/"),
40+
path: archivePath + (archivePath.endsWith("/") ? "" : "/"),
3141
};
3242
} else {
3343
// Handle file
3444
return {
3545
type: "file",
36-
path: path,
46+
path: archivePath,
3747
size: stat.size,
38-
readable: (await Deno.open(path)).readable,
48+
readable: (await Deno.open(fullPath)).readable,
3949
};
4050
}
4151
}),

src/publish/common/bundle.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import { ensureDirSync } from "../../deno_ral/fs.ts";
1010
import { PublishFiles } from "../provider-types.ts";
1111
import { TempContext } from "../../core/temp-types.ts";
1212
import { md5HashBytes } from "../../core/hash.ts";
13-
import { pathWithForwardSlashes } from "../../core/path.ts";
1413

15-
import { copy } from "io/copy";
16-
import { TarStream, type TarStreamInput } from "tar/tar-stream";
1714
import { createTarFromFiles } from "../../deno_ral/tar.ts";
1815

1916
interface ManifestMetadata {
@@ -110,7 +107,7 @@ export async function createBundle(
110107
// await copy(tar.getReader(), writer);
111108
// writer.close();
112109

113-
await createTarFromFiles(tarFile, tarFiles);
110+
await createTarFromFiles(tarFile, tarFiles, { baseDir: stageDir });
114111

115112
// compress to tar.gz
116113
const targzFile = `${tarFile}.gz`;

0 commit comments

Comments
 (0)