wrangler 2.0.11 → 2.0.12

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.
Files changed (55) hide show
  1. package/kv-asset-handler.js +1 -0
  2. package/package.json +3 -1
  3. package/src/__tests__/configuration.test.ts +221 -142
  4. package/src/__tests__/dev.test.tsx +27 -0
  5. package/src/__tests__/index.test.ts +2 -1
  6. package/src/__tests__/kv.test.ts +23 -2
  7. package/src/__tests__/publish.test.ts +173 -54
  8. package/src/bundle.ts +9 -5
  9. package/src/config/environment.ts +1 -1
  10. package/src/config/validation.ts +22 -13
  11. package/src/dev/dev.tsx +29 -45
  12. package/src/dev/local.tsx +10 -7
  13. package/src/dev/remote.tsx +4 -1
  14. package/src/dev/use-esbuild.ts +1 -4
  15. package/src/index.tsx +236 -180
  16. package/src/kv.ts +1 -1
  17. package/src/parse.ts +21 -1
  18. package/src/proxy.ts +19 -6
  19. package/src/publish.ts +6 -1
  20. package/src/sites.tsx +1 -3
  21. package/templates/static-asset-facade.js +1 -5
  22. package/wrangler-dist/cli.js +73310 -73243
  23. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  24. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  25. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  26. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  27. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  28. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  29. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  30. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  31. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  32. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  33. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  34. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  35. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  36. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  37. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  38. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  39. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  40. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  41. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  42. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  43. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  44. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  45. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  46. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  47. package/vendor/wrangler-mime/LICENSE +0 -21
  48. package/vendor/wrangler-mime/Mime.js +0 -97
  49. package/vendor/wrangler-mime/README.md +0 -187
  50. package/vendor/wrangler-mime/cli.js +0 -46
  51. package/vendor/wrangler-mime/index.js +0 -4
  52. package/vendor/wrangler-mime/lite.js +0 -4
  53. package/vendor/wrangler-mime/package.json +0 -52
  54. package/vendor/wrangler-mime/types/other.js +0 -1
  55. package/vendor/wrangler-mime/types/standard.js +0 -1
@@ -0,0 +1 @@
1
+ export * from "@cloudflare/kv-asset-handler";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "author": "wrangler@cloudflare.com",
5
5
  "description": "Command-line interface for all things Cloudflare Workers",
6
6
  "bin": {
@@ -36,6 +36,7 @@
36
36
  "cli"
37
37
  ],
38
38
  "dependencies": {
39
+ "@cloudflare/kv-asset-handler": "^0.2.0",
39
40
  "@esbuild-plugins/node-globals-polyfill": "^0.1.1",
40
41
  "@esbuild-plugins/node-modules-polyfill": "^0.1.4",
41
42
  "blake3-wasm": "^2.1.5",
@@ -113,6 +114,7 @@
113
114
  "templates",
114
115
  "vendor",
115
116
  "import_meta_url.js",
117
+ "kv-asset-handler.js",
116
118
  "Cloudflare_CA.pem"
117
119
  ],
118
120
  "scripts": {
@@ -19,7 +19,7 @@ describe("normalizeAndValidateConfig()", () => {
19
19
  build: {
20
20
  command: undefined,
21
21
  cwd: undefined,
22
- watch_dir: undefined,
22
+ watch_dir: "./src",
23
23
  },
24
24
  compatibility_date: undefined,
25
25
  compatibility_flags: [],
@@ -879,171 +879,250 @@ describe("normalizeAndValidateConfig()", () => {
879
879
  `);
880
880
  });
881
881
 
882
- it("should error on invalid `name` value with spaces", () => {
883
- const expectedConfig: RawEnvironment = {
884
- name: "NCC 1701 D",
885
- } as unknown as RawEnvironment;
882
+ describe("name", () => {
883
+ it("should error on invalid `name` value with spaces", () => {
884
+ const expectedConfig: RawEnvironment = {
885
+ name: "NCC 1701 D",
886
+ } as unknown as RawEnvironment;
886
887
 
887
- const { config, diagnostics } = normalizeAndValidateConfig(
888
- expectedConfig,
889
- undefined,
890
- { env: undefined }
891
- );
888
+ const { config, diagnostics } = normalizeAndValidateConfig(
889
+ expectedConfig,
890
+ undefined,
891
+ { env: undefined }
892
+ );
892
893
 
893
- expect(config).toEqual(expect.objectContaining(expectedConfig));
894
- expect(diagnostics.hasWarnings()).toBe(false);
895
- expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
896
- "Processing wrangler configuration:
897
- - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"NCC 1701 D\\"."
898
- `);
899
- });
894
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
895
+ expect(diagnostics.hasWarnings()).toBe(false);
896
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
897
+ "Processing wrangler configuration:
898
+ - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"NCC 1701 D\\"."
899
+ `);
900
+ });
900
901
 
901
- it("should be valid `name` with underscores", () => {
902
- const expectedConfig: RawEnvironment = {
903
- name: "enterprise_nx_01",
904
- } as unknown as RawEnvironment;
902
+ it("should be valid `name` with underscores", () => {
903
+ const expectedConfig: RawEnvironment = {
904
+ name: "enterprise_nx_01",
905
+ } as unknown as RawEnvironment;
905
906
 
906
- const { config, diagnostics } = normalizeAndValidateConfig(
907
- expectedConfig,
908
- undefined,
909
- { env: undefined }
910
- );
907
+ const { config, diagnostics } = normalizeAndValidateConfig(
908
+ expectedConfig,
909
+ undefined,
910
+ { env: undefined }
911
+ );
911
912
 
912
- expect(config).toEqual(expect.objectContaining(expectedConfig));
913
- expect(diagnostics.hasWarnings()).toBe(false);
914
- expect(diagnostics.hasErrors()).toBe(false);
915
- });
913
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
914
+ expect(diagnostics.hasWarnings()).toBe(false);
915
+ expect(diagnostics.hasErrors()).toBe(false);
916
+ });
916
917
 
917
- it("should error on invalid `name` value with special characters", () => {
918
- const expectedConfig: RawEnvironment = {
919
- name: "Thy'lek-Shran",
920
- } as unknown as RawEnvironment;
918
+ it("should error on invalid `name` value with special characters", () => {
919
+ const expectedConfig: RawEnvironment = {
920
+ name: "Thy'lek-Shran",
921
+ } as unknown as RawEnvironment;
921
922
 
922
- const { config, diagnostics } = normalizeAndValidateConfig(
923
- expectedConfig,
924
- undefined,
925
- { env: undefined }
926
- );
923
+ const { config, diagnostics } = normalizeAndValidateConfig(
924
+ expectedConfig,
925
+ undefined,
926
+ { env: undefined }
927
+ );
927
928
 
928
- expect(config).toEqual(expect.objectContaining(expectedConfig));
929
- expect(diagnostics.hasWarnings()).toBe(false);
930
- expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
931
- "Processing wrangler configuration:
932
- - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"Thy'lek-Shran\\"."
933
- `);
934
- });
929
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
930
+ expect(diagnostics.hasWarnings()).toBe(false);
931
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
932
+ "Processing wrangler configuration:
933
+ - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"Thy'lek-Shran\\"."
934
+ `);
935
+ });
935
936
 
936
- it("should error on invalid `name` value with only special characters", () => {
937
- const expectedConfig: RawEnvironment = {
938
- name: "!@#$%^&*(()",
939
- } as unknown as RawEnvironment;
937
+ it("should error on invalid `name` value with only special characters", () => {
938
+ const expectedConfig: RawEnvironment = {
939
+ name: "!@#$%^&*(()",
940
+ } as unknown as RawEnvironment;
940
941
 
941
- const { config, diagnostics } = normalizeAndValidateConfig(
942
- expectedConfig,
943
- undefined,
944
- { env: undefined }
945
- );
942
+ const { config, diagnostics } = normalizeAndValidateConfig(
943
+ expectedConfig,
944
+ undefined,
945
+ { env: undefined }
946
+ );
946
947
 
947
- expect(config).toEqual(expect.objectContaining(expectedConfig));
948
- expect(diagnostics.hasWarnings()).toBe(false);
949
- expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
950
- "Processing wrangler configuration:
951
- - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"!@#$%^&*(()\\"."
952
- `);
948
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
949
+ expect(diagnostics.hasWarnings()).toBe(false);
950
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
951
+ "Processing wrangler configuration:
952
+ - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"!@#$%^&*(()\\"."
953
+ `);
954
+ });
953
955
  });
954
956
 
955
- it("should override build.upload config defaults with provided values and warn about deprecations", () => {
956
- const expectedConfig: RawEnvironment = {
957
- build: {
958
- upload: {
959
- dir: "src",
960
- format: "modules",
961
- main: "index.ts",
962
- rules: [{ type: "Text", globs: ["GLOB"], fallthrough: true }],
957
+ describe("build", () => {
958
+ it("should override build.upload config defaults with provided values and warn about deprecations", () => {
959
+ const expectedConfig: RawEnvironment = {
960
+ build: {
961
+ upload: {
962
+ dir: "src",
963
+ format: "modules",
964
+ main: "index.ts",
965
+ rules: [{ type: "Text", globs: ["GLOB"], fallthrough: true }],
966
+ },
963
967
  },
964
- },
965
- };
968
+ };
966
969
 
967
- const { config, diagnostics } = normalizeAndValidateConfig(
968
- expectedConfig,
969
- path.resolve("project/wrangler.toml"),
970
- { env: undefined }
971
- );
970
+ const { config, diagnostics } = normalizeAndValidateConfig(
971
+ expectedConfig,
972
+ path.resolve("project/wrangler.toml"),
973
+ { env: undefined }
974
+ );
972
975
 
973
- expect(config.main).toEqual(path.resolve("project/src/index.ts"));
974
- expect(config.build.upload).toBeUndefined();
975
- expect(diagnostics.hasErrors()).toBe(false);
976
- expect(diagnostics.hasWarnings()).toBe(true);
977
- expect(normalizePath(diagnostics.renderWarnings()))
978
- .toMatchInlineSnapshot(`
979
- "Processing project/wrangler.toml configuration:
980
- - Deprecation: \\"build.upload.format\\":
981
- The format is inferred automatically from the code.
982
- - Deprecation: \\"build.upload.main\\":
983
- Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
984
- Then add the top level \`main\` field to your configuration file:
985
- \`\`\`
986
- main = \\"src/index.ts\\"
987
- \`\`\`
988
- - Deprecation: \\"build.upload.dir\\":
989
- Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
990
- - Deprecation: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
991
- \`\`\`
992
- [[rules]]
993
- type = \\"Text\\"
994
- globs = [ \\"GLOB\\" ]
995
- fallthrough = true
996
- \`\`\`"
997
- `);
998
- });
976
+ expect(config.main).toEqual(path.resolve("project/src/index.ts"));
977
+ expect(config.build.upload).toBeUndefined();
978
+ expect(diagnostics.hasErrors()).toBe(false);
979
+ expect(diagnostics.hasWarnings()).toBe(true);
980
+ expect(normalizePath(diagnostics.renderWarnings()))
981
+ .toMatchInlineSnapshot(`
982
+ "Processing project/wrangler.toml configuration:
983
+ - Deprecation: \\"build.upload.format\\":
984
+ The format is inferred automatically from the code.
985
+ - Deprecation: \\"build.upload.main\\":
986
+ Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
987
+ Then add the top level \`main\` field to your configuration file:
988
+ \`\`\`
989
+ main = \\"src/index.ts\\"
990
+ \`\`\`
991
+ - Deprecation: \\"build.upload.dir\\":
992
+ Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
993
+ - Deprecation: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
994
+ \`\`\`
995
+ [[rules]]
996
+ type = \\"Text\\"
997
+ globs = [ \\"GLOB\\" ]
998
+ fallthrough = true
999
+ \`\`\`"
1000
+ `);
1001
+ });
999
1002
 
1000
- it("should default custom build watch directories to src", () => {
1001
- const expectedConfig: RawEnvironment = {
1002
- build: {
1003
- command: "execute some --build",
1004
- },
1005
- };
1003
+ it("should default custom build watch directories to src", () => {
1004
+ const expectedConfig: RawEnvironment = {
1005
+ build: {
1006
+ command: "execute some --build",
1007
+ },
1008
+ };
1006
1009
 
1007
- const { config, diagnostics } = normalizeAndValidateConfig(
1008
- expectedConfig,
1009
- undefined,
1010
- { env: undefined }
1011
- );
1010
+ const { config, diagnostics } = normalizeAndValidateConfig(
1011
+ expectedConfig,
1012
+ undefined,
1013
+ { env: undefined }
1014
+ );
1012
1015
 
1013
- expect(config.build).toEqual(
1014
- expect.objectContaining({
1015
- command: "execute some --build",
1016
- watch_dir: "./src",
1017
- })
1018
- );
1016
+ expect(config.build).toEqual(
1017
+ expect.objectContaining({
1018
+ command: "execute some --build",
1019
+ watch_dir: "./src",
1020
+ })
1021
+ );
1019
1022
 
1020
- expect(diagnostics.hasErrors()).toBe(false);
1021
- expect(diagnostics.hasWarnings()).toBe(false);
1022
- });
1023
+ expect(diagnostics.hasErrors()).toBe(false);
1024
+ expect(diagnostics.hasWarnings()).toBe(false);
1025
+ });
1023
1026
 
1024
- it("should resolve custom build watch directories relative to wrangler.toml", async () => {
1025
- const expectedConfig: RawEnvironment = {
1026
- build: {
1027
- command: "execute some --build",
1028
- watch_dir: "some/path",
1029
- },
1030
- };
1027
+ it("should resolve custom build watch directories relative to wrangler.toml", async () => {
1028
+ const expectedConfig: RawEnvironment = {
1029
+ build: {
1030
+ command: "execute some --build",
1031
+ watch_dir: "some/path",
1032
+ },
1033
+ };
1031
1034
 
1032
- const { config, diagnostics } = normalizeAndValidateConfig(
1033
- expectedConfig,
1034
- "project/wrangler.toml",
1035
- { env: undefined }
1036
- );
1035
+ const { config, diagnostics } = normalizeAndValidateConfig(
1036
+ expectedConfig,
1037
+ "project/wrangler.toml",
1038
+ { env: undefined }
1039
+ );
1037
1040
 
1038
- expect(config.build).toEqual(
1039
- expect.objectContaining({
1040
- command: "execute some --build",
1041
- watch_dir: path.normalize("project/some/path"),
1042
- })
1043
- );
1041
+ expect(config.build).toEqual(
1042
+ expect.objectContaining({
1043
+ command: "execute some --build",
1044
+ watch_dir: path.normalize("project/some/path"),
1045
+ })
1046
+ );
1044
1047
 
1045
- expect(diagnostics.hasErrors()).toBe(false);
1046
- expect(diagnostics.hasWarnings()).toBe(false);
1048
+ expect(diagnostics.hasErrors()).toBe(false);
1049
+ expect(diagnostics.hasWarnings()).toBe(false);
1050
+ });
1051
+
1052
+ it("should allow watch_dir to be an array of paths", () => {
1053
+ const expectedConfig: RawEnvironment = {
1054
+ build: {
1055
+ command: "execute some --build",
1056
+ watch_dir: ["some/path/a", "some/path/b", "some/path/c"],
1057
+ },
1058
+ };
1059
+
1060
+ const { config, diagnostics } = normalizeAndValidateConfig(
1061
+ expectedConfig,
1062
+ "project/wrangler.toml",
1063
+ { env: undefined }
1064
+ );
1065
+
1066
+ expect(config.build).toEqual(
1067
+ expect.objectContaining({
1068
+ command: "execute some --build",
1069
+ watch_dir: [
1070
+ path.normalize("project/some/path/a"),
1071
+ path.normalize("project/some/path/b"),
1072
+ path.normalize("project/some/path/c"),
1073
+ ],
1074
+ })
1075
+ );
1076
+
1077
+ expect(diagnostics.hasErrors()).toBe(false);
1078
+ expect(diagnostics.hasWarnings()).toBe(false);
1079
+ });
1080
+
1081
+ it("should error when the watch_dir array isn't an array of strings", () => {
1082
+ const expectedConfig: RawEnvironment = {
1083
+ build: {
1084
+ command: "execute some --build",
1085
+ watch_dir: [
1086
+ "some/path/a",
1087
+ "some/path/b",
1088
+ // @ts-expect-error intentionally bad "paths"
1089
+ 123,
1090
+ "some/path/c",
1091
+ // @ts-expect-error intentionally bad "paths"
1092
+ false,
1093
+ ],
1094
+ },
1095
+ };
1096
+
1097
+ const { config, diagnostics } = normalizeAndValidateConfig(
1098
+ expectedConfig,
1099
+ "project/wrangler.toml",
1100
+ { env: undefined }
1101
+ );
1102
+
1103
+ expect(config.build).toEqual(
1104
+ expect.objectContaining({
1105
+ command: "execute some --build",
1106
+ watch_dir: [
1107
+ path.normalize("project/some/path/a"),
1108
+ path.normalize("project/some/path/b"),
1109
+ path.normalize("project/123"),
1110
+ path.normalize("project/some/path/c"),
1111
+ path.normalize("project/false"),
1112
+ ],
1113
+ })
1114
+ );
1115
+
1116
+ expect(diagnostics.hasWarnings()).toBe(false);
1117
+ expect(diagnostics.hasErrors()).toBe(true);
1118
+
1119
+ expect(normalizePath(diagnostics.renderErrors()))
1120
+ .toMatchInlineSnapshot(`
1121
+ "Processing project/wrangler.toml configuration:
1122
+ - Expected \\"build.watch_dir.[2]\\" to be of type string but got 123.
1123
+ - Expected \\"build.watch_dir.[4]\\" to be of type string but got false."
1124
+ `);
1125
+ });
1047
1126
  });
1048
1127
 
1049
1128
  describe("durable_objects field", () => {
@@ -856,6 +856,33 @@ describe("wrangler dev", () => {
856
856
  }
857
857
  `);
858
858
  });
859
+
860
+ it("should error if --experimental-public and --site are used together", async () => {
861
+ writeWranglerToml({
862
+ main: "./index.js",
863
+ });
864
+ fs.writeFileSync("index.js", `export default {};`);
865
+ await expect(
866
+ runWrangler("dev --experimental-public abc --site xyz")
867
+ ).rejects.toThrowErrorMatchingInlineSnapshot(
868
+ `"Cannot use --experimental-public and a Site configuration together."`
869
+ );
870
+ });
871
+
872
+ it("should error if --experimental-public and config.site are used together", async () => {
873
+ writeWranglerToml({
874
+ main: "./index.js",
875
+ site: {
876
+ bucket: "xyz",
877
+ },
878
+ });
879
+ fs.writeFileSync("index.js", `export default {};`);
880
+ await expect(
881
+ runWrangler("dev --experimental-public abc")
882
+ ).rejects.toThrowErrorMatchingInlineSnapshot(
883
+ `"Cannot use --experimental-public and a Site configuration together."`
884
+ );
885
+ });
859
886
  });
860
887
 
861
888
  describe("--inspect", () => {
@@ -242,7 +242,8 @@ describe("wrangler", () => {
242
242
  expect(std.out).toMatchInlineSnapshot(`
243
243
  "â–² [WARNING] Deprecation: \`wrangler build\` has been deprecated.
244
244
 
245
- Please refer to https://developers.cloudflare.com/workers/wrangler/migration/deprecations/#build for more information.
245
+ Please refer to https://developers.cloudflare.com/workers/wrangler/migration/deprecations/#build
246
+ for more information.
246
247
  Attempting to run \`wrangler publish --dry-run --outdir=dist\` for you instead:
247
248
 
248
249
 
@@ -448,10 +448,11 @@ describe("wrangler", () => {
448
448
  });
449
449
 
450
450
  it("should put a key with a value loaded from a given path", async () => {
451
- writeFileSync("foo.txt", "file-contents", "utf-8");
451
+ const buf = Buffer.from("file-contents", "utf-8");
452
+ writeFileSync("foo.txt", buf);
452
453
  const requests = mockKeyPutRequest("some-namespace-id", {
453
454
  key: "my-key",
454
- value: "file-contents",
455
+ value: buf,
455
456
  });
456
457
  await runWrangler(
457
458
  "kv:key put my-key --namespace-id some-namespace-id --path foo.txt"
@@ -463,6 +464,26 @@ describe("wrangler", () => {
463
464
  expect(requests.count).toEqual(1);
464
465
  });
465
466
 
467
+ it("should put a key with a binary value loaded from a given path", async () => {
468
+ const buf = Buffer.from(
469
+ "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAiSURBVHgB7coxEQAACMPAgH/PgAM6dGwu49fA/deIBXrgAj2cAhIFT4QxAAAAAElFTkSuQmCC",
470
+ "base64"
471
+ );
472
+ writeFileSync("test.png", buf);
473
+ const requests = mockKeyPutRequest("another-namespace-id", {
474
+ key: "my-key",
475
+ value: buf,
476
+ });
477
+ await runWrangler(
478
+ "kv:key put my-key --namespace-id another-namespace-id --path test.png"
479
+ );
480
+ expect(std.out).toMatchInlineSnapshot(
481
+ `"Writing the contents of test.png to the key \\"my-key\\" on namespace another-namespace-id."`
482
+ );
483
+ expect(std.err).toMatchInlineSnapshot(`""`);
484
+ expect(requests.count).toEqual(1);
485
+ });
486
+
466
487
  it("should error if no key is provided", async () => {
467
488
  await expect(
468
489
  runWrangler("kv:key put")