Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import {
} from "../../../../../tests/helpers/legacy-mocks.ts";
import { mockOutput, mockRuntimeInfo } from "../../../../../tests/helpers/mocks.ts";
import { mockChildProcessSpawner } from "../../../../../../../packages/process-compose/tests/helpers/mocks.ts";
import { deployFunctions } from "../../../../shared/functions/deploy.ts";
import {
deployFunctions,
shouldChmodBundleOutputDirectory,
} from "../../../../shared/functions/deploy.ts";
import {
ConflictingFunctionDeployFlagsError,
NoFunctionsToDeployError,
Expand Down Expand Up @@ -1125,6 +1128,16 @@ describe("legacy functions deploy", () => {
});
});

describe("Docker bundle output permissions", () => {
it.live("skips the POSIX chmod on Windows only", () =>
Effect.sync(() => {
expect(shouldChmodBundleOutputDirectory("win32")).toBe(false);
expect(shouldChmodBundleOutputDirectory("darwin")).toBe(true);
expect(shouldChmodBundleOutputDirectory("linux")).toBe(true);
}),
);
});

describe("no-functions error styling (Go parity: deploy.go:35; structured output stays plain)", () => {
// Calls the shared `deployFunctions` with a marker `styleEmphasis` instead of
// going through `legacyFunctionsDeploy`: the real hook (`legacyBold`) is
Expand Down
13 changes: 12 additions & 1 deletion apps/cli/src/shared/functions/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const WINDOWS_ABSOLUTE_PATH = /^[A-Za-z]:\//;
const importPathPattern =
/(?:import|export)\s+(?:type\s+)?(?:{[^{}]+}|.*?)\s*(?:from)?\s*['"](.*?)['"]|import\(\s*['"](.*?)['"]\)/gi;

export function shouldChmodBundleOutputDirectory(platform: NodeJS.Platform) {
return platform !== "win32";
}

interface FunctionsDeployFlags {
readonly functionNames: ReadonlyArray<string>;
readonly projectRef: Option.Option<string>;
Expand Down Expand Up @@ -1414,7 +1418,14 @@ const bundleFunctionWithDocker = Effect.fnUntraced(function* (
mkdtemp(join(outputRoot, `.supabase-output-${config.slug}-`)),
);
try {
yield* Effect.tryPromise(() => chmod(outputDir, 0o777));
// Go passes 0777 to MkdirAll, which Windows ignores. Calling chmod separately
// adds an NTFS WRITE_ATTRIBUTES requirement that the Go CLI does not have.
if (shouldChmodBundleOutputDirectory(process.platform)) {
yield* Effect.tryPromise({
try: () => chmod(outputDir, 0o777),
catch: (cause) => (cause instanceof Error ? cause : new Error(String(cause))),
});
}
const outputPath = join(outputDir, "output.eszip");
const binds = yield* Effect.promise(() =>
buildDockerBinds(projectId, functionsDir, outputDir, config),
Expand Down
Loading