Skip to content

Commit

Permalink
feat: add support for include and exclude when publishing site assets
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Jan 24, 2022
1 parent 0289882 commit 2453577
Show file tree
Hide file tree
Showing 10 changed files with 635 additions and 129 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-buses-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

feat: add support for include and exclude when publishing site assets
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"finalhandler": "^1.1.2",
"find-up": "^6.2.0",
"formdata-node": "^4.3.1",
"ignore": "^5.2.0",
"ink": "^3.2.0",
"ink-select-input": "^4.2.1",
"ink-table": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/__tests__/dev.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function renderDev({
jsxFragment,
bindings = {},
public: publicDir,
site,
assetPaths,
compatibilityDate,
compatibilityFlags,
usageModel,
Expand All @@ -56,7 +56,7 @@ function renderDev({
jsxFactory={jsxFactory}
jsxFragment={jsxFragment}
accountId={accountId}
site={site}
assetPaths={assetPaths}
public={publicDir}
compatibilityDate={compatibilityDate}
compatibilityFlags={compatibilityFlags}
Expand Down
75 changes: 38 additions & 37 deletions packages/wrangler/src/__tests__/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,43 +681,6 @@ describe("wrangler", () => {
});

describe("list", () => {
function mockKeyListRequest(
expectedNamespaceId: string,
expectedKeys: string[],
keysPerRequest = 1000
) {
const requests = { count: 0 };
// See https://api.cloudflare.com/#workers-kv-namespace-list-a-namespace-s-keys
const expectedKeyObjects = expectedKeys.map((name) => ({
name,
expiration: 123456789,
metadata: {},
}));
setMockRawResponse(
"/accounts/:accountId/storage/kv/namespaces/:namespaceId/keys",
([_url, accountId, namespaceId], _init, query) => {
requests.count++;
expect(accountId).toEqual("some-account-id");
expect(namespaceId).toEqual(expectedNamespaceId);
if (expectedKeyObjects.length <= keysPerRequest) {
return createFetchResult(expectedKeyObjects);
} else {
const start = parseInt(query.get("cursor") ?? "0") || 0;
const end = start + keysPerRequest;
const cursor = end < expectedKeyObjects.length ? end : undefined;
return createFetchResult(
expectedKeyObjects.slice(start, end),
true,
[],
[],
{ cursor }
);
}
}
);
return requests;
}

it("should list the keys of a namespace specified by namespace-id", async () => {
const keys = ["key-1", "key-2", "key-3"];
mockKeyListRequest("some-namespace-id", keys);
Expand Down Expand Up @@ -1196,3 +1159,41 @@ function writeWranglerConfig() {
"utf-8"
);
}

export function mockKeyListRequest(
expectedNamespaceId: string,
expectedKeys: string[],
keysPerRequest = 1000
) {
const requests = { count: 0 };
// See https://api.cloudflare.com/#workers-kv-namespace-list-a-namespace-s-keys
const expectedKeyObjects = expectedKeys.map((name) => ({
name,
expiration: 123456789,
metadata: {},
}));
setMockRawResponse(
"/accounts/:accountId/storage/kv/namespaces/:namespaceId/keys",
"GET",
([_url, accountId, namespaceId], _init, query) => {
requests.count++;
expect(accountId).toEqual("some-account-id");
expect(namespaceId).toEqual(expectedNamespaceId);
if (expectedKeyObjects.length <= keysPerRequest) {
return createFetchResult(expectedKeyObjects);
} else {
const start = parseInt(query.get("cursor") ?? "0") || 0;
const end = start + keysPerRequest;
const cursor = end < expectedKeyObjects.length ? end : undefined;
return createFetchResult(
expectedKeyObjects.slice(start, end),
true,
[],
[],
{ cursor }
);
}
}
);
return requests;
}
Loading

0 comments on commit 2453577

Please sign in to comment.