Skip to content

Commit

Permalink
Revert "Add serve_directly option to assets configuration (#7316)"
Browse files Browse the repository at this point in the history
This reverts commit 3cdf0e8.
  • Loading branch information
emily-shen committed Nov 26, 2024
1 parent 02a0e1e commit 986b09c
Show file tree
Hide file tree
Showing 12 changed files with 2 additions and 143 deletions.
7 changes: 0 additions & 7 deletions .changeset/six-coats-rule.md

This file was deleted.

1 change: 0 additions & 1 deletion fixtures/asset-config/html-handling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe.each(testSuites)("$title", ({ title, suite }) => {
return {
html_handling,
not_found_handling: "none",
serve_directly: true,
};
});
});
Expand Down
3 changes: 1 addition & 2 deletions fixtures/asset-config/redirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const existsMock = (fileList: Set<string>) => {
};
const BASE_URL = "http://example.com";

describe("[Asset Worker] `test location rewrite`", () => {
describe("[Asset Worker] `test url normalization`", () => {
afterEach(() => {
vi.mocked(getAssetWithMetadataFromKV).mockRestore();
});
Expand All @@ -41,7 +41,6 @@ describe("[Asset Worker] `test location rewrite`", () => {
return {
html_handling: "none",
not_found_handling: "none",
serve_directly: true,
};
});
});
Expand Down
3 changes: 1 addition & 2 deletions fixtures/asset-config/url-normalization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const existsMock = (fileList: Set<string>) => {
};
const BASE_URL = "http://example.com";

describe("[Asset Worker] `test slash normalization`", () => {
describe("[Asset Worker] `test redirects`", () => {
afterEach(() => {
vi.mocked(getAssetWithMetadataFromKV).mockRestore();
});
Expand All @@ -41,7 +41,6 @@ describe("[Asset Worker] `test slash normalization`", () => {
return {
html_handling: "none",
not_found_handling: "none",
serve_directly: true,
};
});
});
Expand Down
1 change: 0 additions & 1 deletion packages/workers-shared/asset-worker/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ export const applyConfigurationDefaults = (
return {
html_handling: configuration?.html_handling ?? "auto-trailing-slash",
not_found_handling: configuration?.not_found_handling ?? "none",
serve_directly: configuration?.serve_directly ?? true,
};
};
4 changes: 0 additions & 4 deletions packages/workers-shared/asset-worker/tests/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe("[Asset Worker] `handleRequest`", () => {
const configuration: Required<AssetConfig> = {
html_handling: "none",
not_found_handling: "none",
serve_directly: true,
};
const eTag = "some-etag";
const exists = vi.fn().mockReturnValue(eTag);
Expand All @@ -30,7 +29,6 @@ describe("[Asset Worker] `handleRequest`", () => {
const configuration: Required<AssetConfig> = {
html_handling: "none",
not_found_handling: "none",
serve_directly: true,
};
const eTag = "some-etag";
const exists = vi.fn().mockReturnValue(eTag);
Expand All @@ -55,7 +53,6 @@ describe("[Asset Worker] `handleRequest`", () => {
const configuration: Required<AssetConfig> = {
html_handling: "none",
not_found_handling: "none",
serve_directly: true,
};
const eTag = "some-etag";
const exists = vi.fn().mockReturnValue(eTag);
Expand All @@ -80,7 +77,6 @@ describe("[Asset Worker] `handleRequest`", () => {
const configuration: Required<AssetConfig> = {
html_handling: "none",
not_found_handling: "none",
serve_directly: true,
};
const eTag = "some-etag";
const exists = vi.fn().mockReturnValue(eTag);
Expand Down
1 change: 0 additions & 1 deletion packages/workers-shared/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const AssetConfigSchema = z.object({
not_found_handling: z
.enum(["single-page-application", "404-page", "none"])
.optional(),
serve_directly: z.boolean().optional(),
});

export type RoutingConfig = z.infer<typeof RoutingConfigSchema>;
Expand Down
112 changes: 0 additions & 112 deletions packages/wrangler/src/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4948,118 +4948,6 @@ addEventListener('fetch', event => {});`
await runWrangler("deploy");
});

it("serve_directly correctly overrides default if set to false", async () => {
const assets = [
{ filePath: "file-1.txt", content: "Content of file-1" },
{ filePath: "boop/file-2.txt", content: "Content of file-2" },
];
writeAssets(assets);
writeWorkerSource({ format: "js" });
writeWranglerConfig({
main: "index.js",
compatibility_date: "2024-09-27",
compatibility_flags: ["nodejs_compat"],
assets: {
directory: "assets",
binding: "ASSETS",
html_handling: "none",
not_found_handling: "404-page",
serve_directly: false,
},
});
await mockAUSRequest();
mockSubDomainRequest();
mockUploadWorkerRequest({
expectedAssets: {
jwt: "<<aus-completion-token>>",
config: {
html_handling: "none",
not_found_handling: "404-page",
serve_directly: false,
},
},
expectedBindings: [{ name: "ASSETS", type: "assets" }],
expectedMainModule: "index.js",
expectedCompatibilityDate: "2024-09-27",
expectedCompatibilityFlags: ["nodejs_compat"],
});
await runWrangler("deploy");
});

it("serve_directly omitted when not provided in config", async () => {
const assets = [
{ filePath: "file-1.txt", content: "Content of file-1" },
{ filePath: "boop/file-2.txt", content: "Content of file-2" },
];
writeAssets(assets);
writeWorkerSource({ format: "js" });
writeWranglerConfig({
main: "index.js",
compatibility_date: "2024-09-27",
compatibility_flags: ["nodejs_compat"],
assets: {
directory: "assets",
binding: "ASSETS",
html_handling: "none",
not_found_handling: "404-page",
},
});
await mockAUSRequest();
mockSubDomainRequest();
mockUploadWorkerRequest({
expectedAssets: {
jwt: "<<aus-completion-token>>",
config: {
html_handling: "none",
not_found_handling: "404-page",
},
},
expectedBindings: [{ name: "ASSETS", type: "assets" }],
expectedMainModule: "index.js",
expectedCompatibilityDate: "2024-09-27",
expectedCompatibilityFlags: ["nodejs_compat"],
});
await runWrangler("deploy");
});

it("serve_directly provided if set to true", async () => {
const assets = [
{ filePath: "file-1.txt", content: "Content of file-1" },
{ filePath: "boop/file-2.txt", content: "Content of file-2" },
];
writeAssets(assets);
writeWorkerSource({ format: "js" });
writeWranglerConfig({
main: "index.js",
compatibility_date: "2024-09-27",
compatibility_flags: ["nodejs_compat"],
assets: {
directory: "assets",
binding: "ASSETS",
html_handling: "none",
not_found_handling: "404-page",
serve_directly: true,
},
});
await mockAUSRequest();
mockSubDomainRequest();
mockUploadWorkerRequest({
expectedAssets: {
jwt: "<<aus-completion-token>>",
config: {
html_handling: "none",
not_found_handling: "404-page",
serve_directly: true,
},
},
expectedBindings: [{ name: "ASSETS", type: "assets" }],
expectedMainModule: "index.js",
expectedCompatibilityDate: "2024-09-27",
expectedCompatibilityFlags: ["nodejs_compat"],
});
await runWrangler("deploy");
});

it("should be able to upload an asset-only project", async () => {
const assets = [
{ filePath: "file-1.txt", content: "Content of file-1" },
Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ export function processAssetsArg(
const assetConfig = {
html_handling: config.assets?.html_handling,
not_found_handling: config.assets?.not_found_handling,
serve_directly: config.assets?.serve_directly,
};

return {
Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/config/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,6 @@ export type Assets = {
| "drop-trailing-slash"
| "none";
not_found_handling?: "single-page-application" | "404-page" | "none";
serve_directly?: boolean;
};

export interface Observability {
Expand Down
10 changes: 0 additions & 10 deletions packages/wrangler/src/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2168,22 +2168,12 @@ const validateAssetsConfig: ValidatorFn = (diagnostics, field, value) => {
["single-page-application", "404-page", "none"]
) && isValid;

isValid =
validateOptionalProperty(
diagnostics,
field,
"serve_directly",
(value as Assets).serve_directly,
"boolean"
) && isValid;

isValid =
validateAdditionalProperties(diagnostics, field, Object.keys(value), [
"directory",
"binding",
"html_handling",
"not_found_handling",
"serve_directly",
]) && isValid;

return isValid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export function createWorkerUploadForm(worker: CfWorkerInit): FormData {
const assetConfig = {
html_handling: assets?.assetConfig?.html_handling,
not_found_handling: assets?.assetConfig?.not_found_handling,
serve_directly: assets?.assetConfig?.serve_directly,
};

// short circuit if static assets upload only
Expand Down

0 comments on commit 986b09c

Please sign in to comment.