wrangler 2.1.14 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/miniflare-dist/index.mjs +3 -1
- package/package.json +2 -1
- package/src/__tests__/access.test.ts +25 -0
- package/src/__tests__/api-dev.test.ts +1 -1
- package/src/__tests__/api-devregistry.test.js +2 -2
- package/src/__tests__/configuration.test.ts +119 -2
- package/src/__tests__/d1.test.ts +2 -0
- package/src/__tests__/deployments.test.ts +22 -22
- package/src/__tests__/dev.test.tsx +167 -15
- package/src/__tests__/helpers/msw/handlers/access.ts +13 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +22 -43
- package/src/__tests__/helpers/msw/handlers/zones.ts +22 -0
- package/src/__tests__/helpers/msw/index.ts +4 -0
- package/src/__tests__/index.test.ts +42 -33
- package/src/__tests__/init.test.ts +88 -4
- package/src/__tests__/jest.setup.ts +11 -0
- package/src/__tests__/kv.test.ts +400 -400
- package/src/__tests__/pages.test.ts +140 -28
- package/src/__tests__/publish.test.ts +1161 -647
- package/src/__tests__/pubsub.test.ts +3 -0
- package/src/__tests__/queues.test.ts +371 -0
- package/src/__tests__/r2.test.ts +57 -52
- package/src/__tests__/worker-namespace.test.ts +15 -10
- package/src/bundle-reporter.tsx +41 -2
- package/src/bundle.ts +59 -30
- package/src/cli.ts +0 -1
- package/src/config/environment.ts +50 -0
- package/src/config/index.ts +41 -0
- package/src/config/validation.ts +173 -0
- package/src/create-worker-preview.ts +10 -3
- package/src/create-worker-upload-form.ts +12 -0
- package/src/d1/backups.tsx +11 -5
- package/src/d1/execute.tsx +52 -47
- package/src/d1/index.ts +2 -1
- package/src/delete.ts +7 -10
- package/src/deployments.ts +73 -0
- package/src/deprecated/index.ts +9 -24
- package/src/dev/dev-vars.ts +11 -8
- package/src/dev/dev.tsx +12 -0
- package/src/dev/local.tsx +26 -0
- package/src/dev/remote.tsx +2 -0
- package/src/dev/start-server.ts +7 -0
- package/src/dev/use-esbuild.ts +12 -5
- package/src/dev.tsx +12 -9
- package/src/dispatch-namespace.ts +4 -3
- package/src/index.tsx +61 -45
- package/src/init.ts +4 -4
- package/src/inspect.ts +21 -1
- package/src/is-interactive.ts +4 -0
- package/src/kv/index.ts +5 -54
- package/src/logger.ts +12 -0
- package/src/pages/constants.ts +2 -0
- package/src/pages/upload.tsx +42 -15
- package/src/proxy.ts +38 -6
- package/src/publish/index.ts +11 -8
- package/src/publish/publish.ts +151 -30
- package/src/pubsub/pubsub-commands.tsx +3 -2
- package/src/queues/cli/commands/consumer/add.ts +71 -0
- package/src/queues/cli/commands/consumer/index.ts +22 -0
- package/src/queues/cli/commands/consumer/remove.ts +38 -0
- package/src/queues/cli/commands/create.ts +25 -0
- package/src/queues/cli/commands/delete.ts +26 -0
- package/src/queues/cli/commands/index.ts +33 -0
- package/src/queues/cli/commands/list.ts +25 -0
- package/src/queues/client.ts +135 -0
- package/src/secret/index.ts +14 -39
- package/src/tail/index.ts +5 -8
- package/src/user/access.ts +69 -0
- package/src/worker.ts +7 -0
- package/src/yargs-types.ts +15 -2
- package/src/zones.ts +31 -5
- package/templates/pages-template-plugin.ts +4 -0
- package/templates/pages-template-worker.ts +21 -4
- package/wrangler-dist/cli.d.ts +42 -0
- package/wrangler-dist/cli.js +4559 -3228
|
@@ -60,23 +60,24 @@ describe("pages", () => {
|
|
|
60
60
|
await endEventLoop();
|
|
61
61
|
|
|
62
62
|
expect(std.out).toMatchInlineSnapshot(`
|
|
63
|
-
|
|
63
|
+
"wrangler pages
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
⚡️ Configure Cloudflare Pages
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
Commands:
|
|
68
|
+
wrangler pages dev [directory] [-- command..] 🧑💻 Develop your full-stack Pages application locally
|
|
69
|
+
wrangler pages project ⚡️ Interact with your Pages projects
|
|
70
|
+
wrangler pages deployment 🚀 Interact with the deployments of a project
|
|
71
|
+
wrangler pages publish [directory] 🆙 Publish a directory of static assets as a Pages deployment
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
Flags:
|
|
74
|
+
-c, --config Path to .toml configuration file [string]
|
|
75
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
76
|
+
-h, --help Show help [boolean]
|
|
77
|
+
-v, --version Show version number [boolean]
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose"
|
|
80
|
+
`);
|
|
80
81
|
});
|
|
81
82
|
|
|
82
83
|
describe("beta message for subcommands", () => {
|
|
@@ -315,26 +316,27 @@ describe("pages", () => {
|
|
|
315
316
|
await endEventLoop();
|
|
316
317
|
|
|
317
318
|
expect(std.out).toMatchInlineSnapshot(`
|
|
318
|
-
|
|
319
|
+
"wrangler pages publish [directory]
|
|
319
320
|
|
|
320
|
-
|
|
321
|
+
🆙 Publish a directory of static assets as a Pages deployment
|
|
321
322
|
|
|
322
|
-
|
|
323
|
-
|
|
323
|
+
Positionals:
|
|
324
|
+
directory The directory of static files to upload [string]
|
|
324
325
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
Flags:
|
|
327
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
328
|
+
-h, --help Show help [boolean]
|
|
329
|
+
-v, --version Show version number [boolean]
|
|
328
330
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
Options:
|
|
332
|
+
--project-name The name of the project you want to deploy to [string]
|
|
333
|
+
--branch The name of the branch you want to deploy to [string]
|
|
334
|
+
--commit-hash The SHA to attach to this deployment [string]
|
|
335
|
+
--commit-message The commit message to attach to this deployment [string]
|
|
336
|
+
--commit-dirty Whether or not the workspace should be considered dirty for this deployment [boolean]
|
|
335
337
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
+
🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose"
|
|
339
|
+
`);
|
|
338
340
|
});
|
|
339
341
|
|
|
340
342
|
it("should upload a directory of files", async () => {
|
|
@@ -1905,6 +1907,116 @@ and that at least one include rule is provided.
|
|
|
1905
1907
|
`);
|
|
1906
1908
|
});
|
|
1907
1909
|
|
|
1910
|
+
it("should avoid uploading some files", async () => {
|
|
1911
|
+
mkdirSync("some_dir/node_modules", { recursive: true });
|
|
1912
|
+
mkdirSync("some_dir/functions", { recursive: true });
|
|
1913
|
+
|
|
1914
|
+
writeFileSync("logo.png", "foobar");
|
|
1915
|
+
writeFileSync("some_dir/functions/foo.js", "func");
|
|
1916
|
+
writeFileSync("some_dir/_headers", "headersfile");
|
|
1917
|
+
|
|
1918
|
+
writeFileSync("_headers", "headersfile");
|
|
1919
|
+
writeFileSync("_redirects", "redirectsfile");
|
|
1920
|
+
writeFileSync("_worker.js", "workerfile");
|
|
1921
|
+
writeFileSync("_routes.json", "routesfile");
|
|
1922
|
+
mkdirSync(".git");
|
|
1923
|
+
writeFileSync(".git/foo", "gitfile");
|
|
1924
|
+
writeFileSync("some_dir/node_modules/some_package", "nodefile");
|
|
1925
|
+
mkdirSync("functions");
|
|
1926
|
+
writeFileSync("functions/foo.js", "func");
|
|
1927
|
+
|
|
1928
|
+
setMockResponse(
|
|
1929
|
+
"/pages/assets/check-missing",
|
|
1930
|
+
"POST",
|
|
1931
|
+
async (_, init) => {
|
|
1932
|
+
const body = JSON.parse(init.body as string) as { hashes: string[] };
|
|
1933
|
+
assertLater(() => {
|
|
1934
|
+
expect(init.headers).toMatchObject({
|
|
1935
|
+
Authorization: "Bearer <<funfetti-auth-jwt>>",
|
|
1936
|
+
});
|
|
1937
|
+
expect(body).toMatchObject({
|
|
1938
|
+
hashes: [
|
|
1939
|
+
"2082190357cfd3617ccfe04f340c6247",
|
|
1940
|
+
"95dedb64e6d4940fc2e0f11f711cc2f4",
|
|
1941
|
+
"09a79777abda8ccc8bdd51dd3ff8e9e9",
|
|
1942
|
+
],
|
|
1943
|
+
});
|
|
1944
|
+
});
|
|
1945
|
+
return body.hashes;
|
|
1946
|
+
}
|
|
1947
|
+
);
|
|
1948
|
+
|
|
1949
|
+
// Accumulate multiple requests then assert afterwards
|
|
1950
|
+
const requests: RequestInit[] = [];
|
|
1951
|
+
setMockRawResponse("/pages/assets/upload", "POST", async (_, init) => {
|
|
1952
|
+
requests.push(init);
|
|
1953
|
+
|
|
1954
|
+
return createFetchResult(null, true);
|
|
1955
|
+
});
|
|
1956
|
+
|
|
1957
|
+
assertLater(() => {
|
|
1958
|
+
expect(requests.length).toBe(3);
|
|
1959
|
+
|
|
1960
|
+
expect(requests[0].headers).toMatchObject({
|
|
1961
|
+
Authorization: "Bearer <<funfetti-auth-jwt>>",
|
|
1962
|
+
});
|
|
1963
|
+
|
|
1964
|
+
let body = JSON.parse(
|
|
1965
|
+
requests[0].body as string
|
|
1966
|
+
) as UploadPayloadFile[];
|
|
1967
|
+
expect(body).toMatchObject([
|
|
1968
|
+
{
|
|
1969
|
+
key: "95dedb64e6d4940fc2e0f11f711cc2f4",
|
|
1970
|
+
value: Buffer.from("headersfile").toString("base64"),
|
|
1971
|
+
metadata: {
|
|
1972
|
+
contentType: "application/octet-stream",
|
|
1973
|
+
},
|
|
1974
|
+
base64: true,
|
|
1975
|
+
},
|
|
1976
|
+
]);
|
|
1977
|
+
|
|
1978
|
+
expect(requests[1].headers).toMatchObject({
|
|
1979
|
+
Authorization: "Bearer <<funfetti-auth-jwt>>",
|
|
1980
|
+
});
|
|
1981
|
+
|
|
1982
|
+
body = JSON.parse(requests[1].body as string) as UploadPayloadFile[];
|
|
1983
|
+
expect(body).toMatchObject([
|
|
1984
|
+
{
|
|
1985
|
+
key: "2082190357cfd3617ccfe04f340c6247",
|
|
1986
|
+
value: Buffer.from("foobar").toString("base64"),
|
|
1987
|
+
metadata: {
|
|
1988
|
+
contentType: "image/png",
|
|
1989
|
+
},
|
|
1990
|
+
base64: true,
|
|
1991
|
+
},
|
|
1992
|
+
]);
|
|
1993
|
+
|
|
1994
|
+
expect(requests[2].headers).toMatchObject({
|
|
1995
|
+
Authorization: "Bearer <<funfetti-auth-jwt>>",
|
|
1996
|
+
});
|
|
1997
|
+
|
|
1998
|
+
body = JSON.parse(requests[2].body as string) as UploadPayloadFile[];
|
|
1999
|
+
expect(body).toMatchObject([
|
|
2000
|
+
{
|
|
2001
|
+
key: "09a79777abda8ccc8bdd51dd3ff8e9e9",
|
|
2002
|
+
value: Buffer.from("func").toString("base64"),
|
|
2003
|
+
metadata: {
|
|
2004
|
+
contentType: "application/javascript",
|
|
2005
|
+
},
|
|
2006
|
+
base64: true,
|
|
2007
|
+
},
|
|
2008
|
+
]);
|
|
2009
|
+
});
|
|
2010
|
+
|
|
2011
|
+
await runWrangler("pages project upload .");
|
|
2012
|
+
|
|
2013
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
2014
|
+
"✨ Success! Uploaded 3 files (TIMINGS)
|
|
2015
|
+
|
|
2016
|
+
✨ Upload complete!"
|
|
2017
|
+
`);
|
|
2018
|
+
});
|
|
2019
|
+
|
|
1908
2020
|
it("should retry uploads", async () => {
|
|
1909
2021
|
writeFileSync("logo.txt", "foobar");
|
|
1910
2022
|
|