wrangler 0.0.0-d61ae84 → 0.0.0-d63d790
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/package.json +2 -1
- package/src/__tests__/configuration.test.ts +14 -3
- package/src/__tests__/dev.test.tsx +11 -2
- package/src/__tests__/kv.test.ts +8 -8
- package/src/__tests__/publish.test.ts +184 -69
- package/src/abort.d.ts +3 -0
- package/src/cfetch/index.ts +4 -2
- package/src/cfetch/internal.ts +4 -2
- package/src/config/index.ts +162 -0
- package/src/config/validation.ts +24 -2
- package/src/create-worker-preview.ts +17 -7
- package/src/dev/dev.tsx +5 -4
- package/src/dev/remote.tsx +15 -1
- package/src/durable.ts +102 -0
- package/src/index.tsx +7 -19
- package/src/inspect.ts +39 -0
- package/src/kv.ts +74 -25
- package/src/open-in-browser.ts +5 -12
- package/src/parse.ts +20 -3
- package/src/proxy.ts +38 -22
- package/src/publish.ts +18 -93
- package/src/sites.tsx +2 -7
- package/wrangler-dist/cli.js +11951 -351
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-d63d790",
|
|
4
4
|
"author": "wrangler@cloudflare.com",
|
|
5
5
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
6
|
"bin": {
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"find-up": "^6.3.0",
|
|
76
76
|
"get-port": "^6.1.2",
|
|
77
77
|
"glob-to-regexp": "0.4.1",
|
|
78
|
+
"http-terminator": "^3.2.0",
|
|
78
79
|
"ignore": "^5.2.0",
|
|
79
80
|
"ink": "^3.2.0",
|
|
80
81
|
"ink-select-input": "^4.2.1",
|
|
@@ -677,7 +677,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
677
677
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
678
678
|
"Processing wrangler configuration:
|
|
679
679
|
- \\"unsafe\\" fields are experimental and may change or break at any time.
|
|
680
|
-
- \\"services\\" fields are experimental and may change or break at any time.
|
|
680
|
+
- \\"services\\" fields are experimental and may change or break at any time.
|
|
681
|
+
- In wrangler.toml, you have configured [durable_objects] exported by this Worker (CLASS1), but no [migrations] for them. This may not work as expected until you add a [migrations] section to your wrangler.toml. Refer to https://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml for more details."
|
|
681
682
|
`);
|
|
682
683
|
});
|
|
683
684
|
|
|
@@ -1156,7 +1157,12 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1156
1157
|
durable_objects: { bindings: expect.anything },
|
|
1157
1158
|
})
|
|
1158
1159
|
);
|
|
1159
|
-
expect(diagnostics.hasWarnings()).toBe(
|
|
1160
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1161
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1162
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1163
|
+
"Processing wrangler configuration:
|
|
1164
|
+
- In wrangler.toml, you have configured [durable_objects] exported by this Worker ((unnamed), (unnamed), 1666, SomeClass, 1883), but no [migrations] for them. This may not work as expected until you add a [migrations] section to your wrangler.toml. Refer to https://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml for more details."
|
|
1165
|
+
`);
|
|
1160
1166
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1161
1167
|
"Processing wrangler configuration:
|
|
1162
1168
|
|
|
@@ -2468,7 +2474,12 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2468
2474
|
durable_objects: { bindings: expect.anything },
|
|
2469
2475
|
})
|
|
2470
2476
|
);
|
|
2471
|
-
expect(diagnostics.hasWarnings()).toBe(
|
|
2477
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
2478
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
2479
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2480
|
+
"Processing wrangler configuration:
|
|
2481
|
+
- In wrangler.toml, you have configured [durable_objects] exported by this Worker ((unnamed), (unnamed), 1666), but no [migrations] for them. This may not work as expected until you add a [migrations] section to your wrangler.toml. Refer to https://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml for more details."
|
|
2482
|
+
`);
|
|
2472
2483
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2473
2484
|
"Processing wrangler configuration:
|
|
2474
2485
|
|
|
@@ -675,7 +675,7 @@ describe("wrangler dev", () => {
|
|
|
675
675
|
});
|
|
676
676
|
|
|
677
677
|
describe("durable_objects", () => {
|
|
678
|
-
it("should warn if there
|
|
678
|
+
it("should warn if there are remote Durable Objects, or missing migrations for local Durable Objects", async () => {
|
|
679
679
|
writeWranglerToml({
|
|
680
680
|
main: "index.js",
|
|
681
681
|
durable_objects: {
|
|
@@ -700,7 +700,16 @@ describe("wrangler dev", () => {
|
|
|
700
700
|
expect((Dev as jest.Mock).mock.calls[0][0].ip).toEqual("localhost");
|
|
701
701
|
expect(std.out).toMatchInlineSnapshot(`""`);
|
|
702
702
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
703
|
-
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [
|
|
703
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
704
|
+
|
|
705
|
+
- In wrangler.toml, you have configured [durable_objects] exported by this Worker (CLASS_1,
|
|
706
|
+
CLASS_3), but no [migrations] for them. This may not work as expected until you add a [migrations]
|
|
707
|
+
section to your wrangler.toml. Refer to
|
|
708
|
+
[4mhttps://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml[0m
|
|
709
|
+
for more details.
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mWARNING: You have Durable Object bindings that are not defined locally in the worker being developed.[0m
|
|
704
713
|
|
|
705
714
|
Be aware that changes to the data stored in these Durable Objects will be permanent and affect the
|
|
706
715
|
live instances.
|
package/src/__tests__/kv.test.ts
CHANGED
|
@@ -1205,10 +1205,10 @@ describe("wrangler", () => {
|
|
|
1205
1205
|
);
|
|
1206
1206
|
expect(requests.count).toEqual(3);
|
|
1207
1207
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1208
|
-
"Uploaded 0 of
|
|
1209
|
-
Uploaded
|
|
1210
|
-
Uploaded
|
|
1211
|
-
Uploaded
|
|
1208
|
+
"Uploaded 0% (0 out of 12,000)
|
|
1209
|
+
Uploaded 41% (5,000 out of 12,000)
|
|
1210
|
+
Uploaded 83% (10,000 out of 12,000)
|
|
1211
|
+
Uploaded 100% (12,000 out of 12,000)
|
|
1212
1212
|
Success!"
|
|
1213
1213
|
`);
|
|
1214
1214
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -1358,10 +1358,10 @@ describe("wrangler", () => {
|
|
|
1358
1358
|
);
|
|
1359
1359
|
expect(requests.count).toEqual(3);
|
|
1360
1360
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1361
|
-
"Deleted 0 of
|
|
1362
|
-
Deleted
|
|
1363
|
-
Deleted
|
|
1364
|
-
Deleted
|
|
1361
|
+
"Deleted 0% (0 out of 12,000)
|
|
1362
|
+
Deleted 41% (5,000 out of 12,000)
|
|
1363
|
+
Deleted 83% (10,000 out of 12,000)
|
|
1364
|
+
Deleted 100% (12,000 out of 12,000)
|
|
1365
1365
|
Success!"
|
|
1366
1366
|
`);
|
|
1367
1367
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -471,7 +471,10 @@ describe("publish", () => {
|
|
|
471
471
|
mockSubDomainRequest();
|
|
472
472
|
await runWrangler("publish ./some-path/worker/index.js");
|
|
473
473
|
expect(std.out).toMatchInlineSnapshot(`
|
|
474
|
-
"
|
|
474
|
+
"Your worker has access to the following bindings:
|
|
475
|
+
- Vars:
|
|
476
|
+
- xyz: \\"123\\"
|
|
477
|
+
Uploaded test-name (TIMINGS)
|
|
475
478
|
Published test-name (TIMINGS)
|
|
476
479
|
test-name.test-sub-domain.workers.dev"
|
|
477
480
|
`);
|
|
@@ -2829,13 +2832,22 @@ addEventListener('fetch', event => {});`
|
|
|
2829
2832
|
mockUploadWorkerRequest();
|
|
2830
2833
|
await runWrangler("publish index.js");
|
|
2831
2834
|
expect(std.out).toMatchInlineSnapshot(`
|
|
2832
|
-
"
|
|
2835
|
+
"Your worker has access to the following bindings:
|
|
2836
|
+
- Durable Objects:
|
|
2837
|
+
- SOMENAME: SomeClass
|
|
2838
|
+
Uploaded test-name (TIMINGS)
|
|
2833
2839
|
Published test-name (TIMINGS)
|
|
2834
2840
|
test-name.test-sub-domain.workers.dev"
|
|
2835
2841
|
`);
|
|
2836
2842
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
2837
2843
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
2838
|
-
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [
|
|
2844
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
2845
|
+
|
|
2846
|
+
- In wrangler.toml, you have configured [durable_objects] exported by this Worker (SomeClass),
|
|
2847
|
+
but no [migrations] for them. This may not work as expected until you add a [migrations] section
|
|
2848
|
+
to your wrangler.toml. Refer to
|
|
2849
|
+
[4mhttps://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml[0m
|
|
2850
|
+
for more details.
|
|
2839
2851
|
|
|
2840
2852
|
"
|
|
2841
2853
|
`);
|
|
@@ -2861,7 +2873,10 @@ addEventListener('fetch', event => {});`
|
|
|
2861
2873
|
mockUploadWorkerRequest();
|
|
2862
2874
|
await runWrangler("publish index.js");
|
|
2863
2875
|
expect(std.out).toMatchInlineSnapshot(`
|
|
2864
|
-
"
|
|
2876
|
+
"Your worker has access to the following bindings:
|
|
2877
|
+
- Durable Objects:
|
|
2878
|
+
- SOMENAME: SomeClass (defined in some-script)
|
|
2879
|
+
Uploaded test-name (TIMINGS)
|
|
2865
2880
|
Published test-name (TIMINGS)
|
|
2866
2881
|
test-name.test-sub-domain.workers.dev"
|
|
2867
2882
|
`);
|
|
@@ -2900,7 +2915,11 @@ addEventListener('fetch', event => {});`
|
|
|
2900
2915
|
|
|
2901
2916
|
await runWrangler("publish index.js");
|
|
2902
2917
|
expect(std.out).toMatchInlineSnapshot(`
|
|
2903
|
-
"
|
|
2918
|
+
"Your worker has access to the following bindings:
|
|
2919
|
+
- Durable Objects:
|
|
2920
|
+
- SOMENAME: SomeClass
|
|
2921
|
+
- SOMEOTHERNAME: SomeOtherClass
|
|
2922
|
+
Uploaded test-name (TIMINGS)
|
|
2904
2923
|
Published test-name (TIMINGS)
|
|
2905
2924
|
test-name.test-sub-domain.workers.dev"
|
|
2906
2925
|
`);
|
|
@@ -2946,7 +2965,11 @@ addEventListener('fetch', event => {});`
|
|
|
2946
2965
|
Object {
|
|
2947
2966
|
"debug": "",
|
|
2948
2967
|
"err": "",
|
|
2949
|
-
"out": "
|
|
2968
|
+
"out": "Your worker has access to the following bindings:
|
|
2969
|
+
- Durable Objects:
|
|
2970
|
+
- SOMENAME: SomeClass
|
|
2971
|
+
- SOMEOTHERNAME: SomeOtherClass
|
|
2972
|
+
Uploaded test-name (TIMINGS)
|
|
2950
2973
|
Published test-name (TIMINGS)
|
|
2951
2974
|
test-name.test-sub-domain.workers.dev",
|
|
2952
2975
|
"warn": "",
|
|
@@ -2985,7 +3008,11 @@ addEventListener('fetch', event => {});`
|
|
|
2985
3008
|
Object {
|
|
2986
3009
|
"debug": "",
|
|
2987
3010
|
"err": "",
|
|
2988
|
-
"out": "
|
|
3011
|
+
"out": "Your worker has access to the following bindings:
|
|
3012
|
+
- Durable Objects:
|
|
3013
|
+
- SOMENAME: SomeClass
|
|
3014
|
+
- SOMEOTHERNAME: SomeOtherClass
|
|
3015
|
+
Uploaded test-name (TIMINGS)
|
|
2989
3016
|
Published test-name (TIMINGS)
|
|
2990
3017
|
test-name.test-sub-domain.workers.dev",
|
|
2991
3018
|
"warn": "",
|
|
@@ -3026,7 +3053,11 @@ addEventListener('fetch', event => {});`
|
|
|
3026
3053
|
|
|
3027
3054
|
await runWrangler("publish index.js --legacy-env false");
|
|
3028
3055
|
expect(std.out).toMatchInlineSnapshot(`
|
|
3029
|
-
"
|
|
3056
|
+
"Your worker has access to the following bindings:
|
|
3057
|
+
- Durable Objects:
|
|
3058
|
+
- SOMENAME: SomeClass
|
|
3059
|
+
- SOMEOTHERNAME: SomeOtherClass
|
|
3060
|
+
Uploaded test-name (TIMINGS)
|
|
3030
3061
|
Published test-name (TIMINGS)
|
|
3031
3062
|
test-name.test-sub-domain.workers.dev"
|
|
3032
3063
|
`);
|
|
@@ -3084,7 +3115,11 @@ addEventListener('fetch', event => {});`
|
|
|
3084
3115
|
|
|
3085
3116
|
await runWrangler("publish index.js --legacy-env false --env xyz");
|
|
3086
3117
|
expect(std.out).toMatchInlineSnapshot(`
|
|
3087
|
-
"
|
|
3118
|
+
"Your worker has access to the following bindings:
|
|
3119
|
+
- Durable Objects:
|
|
3120
|
+
- SOMENAME: SomeClass
|
|
3121
|
+
- SOMEOTHERNAME: SomeOtherClass
|
|
3122
|
+
Uploaded test-name (xyz) (TIMINGS)
|
|
3088
3123
|
Published test-name (xyz) (TIMINGS)
|
|
3089
3124
|
xyz.test-name.test-sub-domain.workers.dev"
|
|
3090
3125
|
`);
|
|
@@ -3138,7 +3173,11 @@ addEventListener('fetch', event => {});`
|
|
|
3138
3173
|
Object {
|
|
3139
3174
|
"debug": "",
|
|
3140
3175
|
"err": "",
|
|
3141
|
-
"out": "
|
|
3176
|
+
"out": "Your worker has access to the following bindings:
|
|
3177
|
+
- Durable Objects:
|
|
3178
|
+
- SOMENAME: SomeClass
|
|
3179
|
+
- SOMEOTHERNAME: SomeOtherClass
|
|
3180
|
+
Uploaded test-name (TIMINGS)
|
|
3142
3181
|
Published test-name (TIMINGS)
|
|
3143
3182
|
test-name.test-sub-domain.workers.dev",
|
|
3144
3183
|
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
@@ -3202,7 +3241,11 @@ addEventListener('fetch', event => {});`
|
|
|
3202
3241
|
Object {
|
|
3203
3242
|
"debug": "",
|
|
3204
3243
|
"err": "",
|
|
3205
|
-
"out": "
|
|
3244
|
+
"out": "Your worker has access to the following bindings:
|
|
3245
|
+
- Durable Objects:
|
|
3246
|
+
- SOMENAME: SomeClass
|
|
3247
|
+
- SOMEOTHERNAME: SomeOtherClass
|
|
3248
|
+
Uploaded test-name (xyz) (TIMINGS)
|
|
3206
3249
|
Published test-name (xyz) (TIMINGS)
|
|
3207
3250
|
xyz.test-name.test-sub-domain.workers.dev",
|
|
3208
3251
|
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
@@ -3366,7 +3409,32 @@ addEventListener('fetch', event => {});`
|
|
|
3366
3409
|
|
|
3367
3410
|
await expect(runWrangler("publish index.js")).resolves.toBeUndefined();
|
|
3368
3411
|
expect(std.out).toMatchInlineSnapshot(`
|
|
3369
|
-
"
|
|
3412
|
+
"Your worker has access to the following bindings:
|
|
3413
|
+
- Data Blobs:
|
|
3414
|
+
- DATA_BLOB_ONE: some-data-blob.bin
|
|
3415
|
+
- DATA_BLOB_TWO: more-data-blob.bin
|
|
3416
|
+
- Durable Objects:
|
|
3417
|
+
- DURABLE_OBJECT_ONE: SomeDurableObject (defined in some-durable-object-worker)
|
|
3418
|
+
- DURABLE_OBJECT_TWO: AnotherDurableObject (defined in another-durable-object-worker) - staging
|
|
3419
|
+
- KV Namespaces:
|
|
3420
|
+
- KV_NAMESPACE_ONE: kv-ns-one-id
|
|
3421
|
+
- KV_NAMESPACE_TWO: kv-ns-two-id
|
|
3422
|
+
- R2 Buckets:
|
|
3423
|
+
- R2_BUCKET_ONE: r2-bucket-one-name
|
|
3424
|
+
- R2_BUCKET_TWO: r2-bucket-two-name
|
|
3425
|
+
- Text Blobs:
|
|
3426
|
+
- TEXT_BLOB_ONE: my-entire-app-depends-on-this.cfg
|
|
3427
|
+
- TEXT_BLOB_TWO: the-entirety-of-human-knowledge.txt
|
|
3428
|
+
- Unsafe:
|
|
3429
|
+
- some unsafe thing: UNSAFE_BINDING_ONE
|
|
3430
|
+
- another unsafe thing: UNSAFE_BINDING_TWO
|
|
3431
|
+
- Vars:
|
|
3432
|
+
- ENV_VAR_ONE: \\"123\\"
|
|
3433
|
+
- ENV_VAR_TWO: \\"Hello, I'm an environment variable\\"
|
|
3434
|
+
- Wasm Modules:
|
|
3435
|
+
- WASM_MODULE_ONE: some_wasm.wasm
|
|
3436
|
+
- WASM_MODULE_TWO: more_wasm.wasm
|
|
3437
|
+
Uploaded test-name (TIMINGS)
|
|
3370
3438
|
Published test-name (TIMINGS)
|
|
3371
3439
|
test-name.test-sub-domain.workers.dev"
|
|
3372
3440
|
`);
|
|
@@ -3742,10 +3810,13 @@ addEventListener('fetch', event => {});`
|
|
|
3742
3810
|
mockSubDomainRequest();
|
|
3743
3811
|
await runWrangler("publish index.js");
|
|
3744
3812
|
expect(std.out).toMatchInlineSnapshot(`
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3813
|
+
"Your worker has access to the following bindings:
|
|
3814
|
+
- Wasm Modules:
|
|
3815
|
+
- TESTWASMNAME: path/to/test.wasm
|
|
3816
|
+
Uploaded test-name (TIMINGS)
|
|
3817
|
+
Published test-name (TIMINGS)
|
|
3818
|
+
test-name.test-sub-domain.workers.dev"
|
|
3819
|
+
`);
|
|
3749
3820
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
3750
3821
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
3751
3822
|
});
|
|
@@ -3808,10 +3879,13 @@ addEventListener('fetch', event => {});`
|
|
|
3808
3879
|
mockSubDomainRequest();
|
|
3809
3880
|
await runWrangler("publish index.js --config ./path/to/wrangler.toml");
|
|
3810
3881
|
expect(std.out).toMatchInlineSnapshot(`
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3882
|
+
"Your worker has access to the following bindings:
|
|
3883
|
+
- Wasm Modules:
|
|
3884
|
+
- TESTWASMNAME: path/to/and/the/path/to/test.wasm
|
|
3885
|
+
Uploaded test-name (TIMINGS)
|
|
3886
|
+
Published test-name (TIMINGS)
|
|
3887
|
+
test-name.test-sub-domain.workers.dev"
|
|
3888
|
+
`);
|
|
3815
3889
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
3816
3890
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
3817
3891
|
});
|
|
@@ -3873,10 +3947,13 @@ addEventListener('fetch', event => {});`
|
|
|
3873
3947
|
mockSubDomainRequest();
|
|
3874
3948
|
await runWrangler("publish index.js");
|
|
3875
3949
|
expect(std.out).toMatchInlineSnapshot(`
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3950
|
+
"Your worker has access to the following bindings:
|
|
3951
|
+
- Text Blobs:
|
|
3952
|
+
- TESTTEXTBLOBNAME: path/to/text.file
|
|
3953
|
+
Uploaded test-name (TIMINGS)
|
|
3954
|
+
Published test-name (TIMINGS)
|
|
3955
|
+
test-name.test-sub-domain.workers.dev"
|
|
3956
|
+
`);
|
|
3880
3957
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
3881
3958
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
3882
3959
|
});
|
|
@@ -3943,10 +4020,13 @@ addEventListener('fetch', event => {});`
|
|
|
3943
4020
|
mockSubDomainRequest();
|
|
3944
4021
|
await runWrangler("publish index.js --config ./path/to/wrangler.toml");
|
|
3945
4022
|
expect(std.out).toMatchInlineSnapshot(`
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
4023
|
+
"Your worker has access to the following bindings:
|
|
4024
|
+
- Text Blobs:
|
|
4025
|
+
- TESTTEXTBLOBNAME: path/to/and/the/path/to/text.file
|
|
4026
|
+
Uploaded test-name (TIMINGS)
|
|
4027
|
+
Published test-name (TIMINGS)
|
|
4028
|
+
test-name.test-sub-domain.workers.dev"
|
|
4029
|
+
`);
|
|
3950
4030
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
3951
4031
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
3952
4032
|
});
|
|
@@ -3976,10 +4056,13 @@ addEventListener('fetch', event => {});`
|
|
|
3976
4056
|
mockSubDomainRequest();
|
|
3977
4057
|
await runWrangler("publish index.js");
|
|
3978
4058
|
expect(std.out).toMatchInlineSnapshot(`
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4059
|
+
"Your worker has access to the following bindings:
|
|
4060
|
+
- Data Blobs:
|
|
4061
|
+
- TESTDATABLOBNAME: path/to/data.bin
|
|
4062
|
+
Uploaded test-name (TIMINGS)
|
|
4063
|
+
Published test-name (TIMINGS)
|
|
4064
|
+
test-name.test-sub-domain.workers.dev"
|
|
4065
|
+
`);
|
|
3983
4066
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
3984
4067
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
3985
4068
|
});
|
|
@@ -4046,10 +4129,13 @@ addEventListener('fetch', event => {});`
|
|
|
4046
4129
|
mockSubDomainRequest();
|
|
4047
4130
|
await runWrangler("publish index.js --config ./path/to/wrangler.toml");
|
|
4048
4131
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4132
|
+
"Your worker has access to the following bindings:
|
|
4133
|
+
- Data Blobs:
|
|
4134
|
+
- TESTDATABLOBNAME: path/to/and/the/path/to/data.bin
|
|
4135
|
+
Uploaded test-name (TIMINGS)
|
|
4136
|
+
Published test-name (TIMINGS)
|
|
4137
|
+
test-name.test-sub-domain.workers.dev"
|
|
4138
|
+
`);
|
|
4053
4139
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4054
4140
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
4055
4141
|
});
|
|
@@ -4080,10 +4166,15 @@ addEventListener('fetch', event => {});`
|
|
|
4080
4166
|
|
|
4081
4167
|
await runWrangler("publish index.js");
|
|
4082
4168
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4169
|
+
"Your worker has access to the following bindings:
|
|
4170
|
+
- Vars:
|
|
4171
|
+
- text: \\"plain ol' string\\"
|
|
4172
|
+
- count: \\"1\\"
|
|
4173
|
+
- complex: \\"[object Object]\\"
|
|
4174
|
+
Uploaded test-name (TIMINGS)
|
|
4175
|
+
Published test-name (TIMINGS)
|
|
4176
|
+
test-name.test-sub-domain.workers.dev"
|
|
4177
|
+
`);
|
|
4087
4178
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4088
4179
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
4089
4180
|
});
|
|
@@ -4104,10 +4195,13 @@ addEventListener('fetch', event => {});`
|
|
|
4104
4195
|
|
|
4105
4196
|
await runWrangler("publish index.js");
|
|
4106
4197
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4198
|
+
"Your worker has access to the following bindings:
|
|
4199
|
+
- R2 Buckets:
|
|
4200
|
+
- FOO: foo-bucket
|
|
4201
|
+
Uploaded test-name (TIMINGS)
|
|
4202
|
+
Published test-name (TIMINGS)
|
|
4203
|
+
test-name.test-sub-domain.workers.dev"
|
|
4204
|
+
`);
|
|
4111
4205
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4112
4206
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
4113
4207
|
});
|
|
@@ -4146,10 +4240,13 @@ addEventListener('fetch', event => {});`
|
|
|
4146
4240
|
|
|
4147
4241
|
await runWrangler("publish index.js");
|
|
4148
4242
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4243
|
+
"Your worker has access to the following bindings:
|
|
4244
|
+
- Durable Objects:
|
|
4245
|
+
- EXAMPLE_DO_BINDING: ExampleDurableObject
|
|
4246
|
+
Uploaded test-name (TIMINGS)
|
|
4247
|
+
Published test-name (TIMINGS)
|
|
4248
|
+
test-name.test-sub-domain.workers.dev"
|
|
4249
|
+
`);
|
|
4153
4250
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4154
4251
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
4155
4252
|
});
|
|
@@ -4182,10 +4279,13 @@ addEventListener('fetch', event => {});`
|
|
|
4182
4279
|
|
|
4183
4280
|
await runWrangler("publish index.js");
|
|
4184
4281
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4282
|
+
"Your worker has access to the following bindings:
|
|
4283
|
+
- Durable Objects:
|
|
4284
|
+
- EXAMPLE_DO_BINDING: ExampleDurableObject (defined in example-do-binding-worker)
|
|
4285
|
+
Uploaded test-name (TIMINGS)
|
|
4286
|
+
Published test-name (TIMINGS)
|
|
4287
|
+
test-name.test-sub-domain.workers.dev"
|
|
4288
|
+
`);
|
|
4189
4289
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4190
4290
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
4191
4291
|
});
|
|
@@ -4223,10 +4323,13 @@ addEventListener('fetch', event => {});`
|
|
|
4223
4323
|
|
|
4224
4324
|
await runWrangler("publish index.js");
|
|
4225
4325
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4326
|
+
"Your worker has access to the following bindings:
|
|
4327
|
+
- Durable Objects:
|
|
4328
|
+
- EXAMPLE_DO_BINDING: ExampleDurableObject
|
|
4329
|
+
Uploaded test-name (TIMINGS)
|
|
4330
|
+
Published test-name (TIMINGS)
|
|
4331
|
+
test-name.test-sub-domain.workers.dev"
|
|
4332
|
+
`);
|
|
4230
4333
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4231
4334
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
4232
4335
|
});
|
|
@@ -4282,10 +4385,13 @@ addEventListener('fetch', event => {});`
|
|
|
4282
4385
|
|
|
4283
4386
|
await runWrangler("publish index.js");
|
|
4284
4387
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4388
|
+
"Your worker has access to the following bindings:
|
|
4389
|
+
- Services:
|
|
4390
|
+
- FOO: foo-service - production
|
|
4391
|
+
Uploaded test-name (TIMINGS)
|
|
4392
|
+
Published test-name (TIMINGS)
|
|
4393
|
+
test-name.test-sub-domain.workers.dev"
|
|
4394
|
+
`);
|
|
4289
4395
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4290
4396
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
4291
4397
|
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
@@ -4324,10 +4430,13 @@ addEventListener('fetch', event => {});`
|
|
|
4324
4430
|
|
|
4325
4431
|
await runWrangler("publish index.js");
|
|
4326
4432
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4433
|
+
"Your worker has access to the following bindings:
|
|
4434
|
+
- Unsafe:
|
|
4435
|
+
- binding-type: my-binding
|
|
4436
|
+
Uploaded test-name (TIMINGS)
|
|
4437
|
+
Published test-name (TIMINGS)
|
|
4438
|
+
test-name.test-sub-domain.workers.dev"
|
|
4439
|
+
`);
|
|
4331
4440
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4332
4441
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
4333
4442
|
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
@@ -4363,10 +4472,13 @@ addEventListener('fetch', event => {});`
|
|
|
4363
4472
|
|
|
4364
4473
|
await runWrangler("publish index.js");
|
|
4365
4474
|
expect(std.out).toMatchInlineSnapshot(`
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4475
|
+
"Your worker has access to the following bindings:
|
|
4476
|
+
- Unsafe:
|
|
4477
|
+
- plain_text: my-binding
|
|
4478
|
+
Uploaded test-name (TIMINGS)
|
|
4479
|
+
Published test-name (TIMINGS)
|
|
4480
|
+
test-name.test-sub-domain.workers.dev"
|
|
4481
|
+
`);
|
|
4370
4482
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4371
4483
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
4372
4484
|
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
@@ -4814,7 +4926,10 @@ addEventListener('fetch', event => {});`
|
|
|
4814
4926
|
Object {
|
|
4815
4927
|
"debug": "",
|
|
4816
4928
|
"err": "",
|
|
4817
|
-
"out": "
|
|
4929
|
+
"out": "Your worker has access to the following bindings:
|
|
4930
|
+
- Durable Objects:
|
|
4931
|
+
- NAME: SomeClass
|
|
4932
|
+
--dry-run: exiting now.",
|
|
4818
4933
|
"warn": "",
|
|
4819
4934
|
}
|
|
4820
4935
|
`);
|
package/src/abort.d.ts
ADDED
package/src/cfetch/index.ts
CHANGED
|
@@ -27,12 +27,14 @@ export { fetchKVGetValue } from "./internal";
|
|
|
27
27
|
export async function fetchResult<ResponseType>(
|
|
28
28
|
resource: string,
|
|
29
29
|
init: RequestInit = {},
|
|
30
|
-
queryParams?: URLSearchParams
|
|
30
|
+
queryParams?: URLSearchParams,
|
|
31
|
+
abortSignal?: AbortSignal
|
|
31
32
|
): Promise<ResponseType> {
|
|
32
33
|
const json = await fetchInternal<FetchResult<ResponseType>>(
|
|
33
34
|
resource,
|
|
34
35
|
init,
|
|
35
|
-
queryParams
|
|
36
|
+
queryParams,
|
|
37
|
+
abortSignal
|
|
36
38
|
);
|
|
37
39
|
if (json.success) {
|
|
38
40
|
return json.result;
|
package/src/cfetch/internal.ts
CHANGED
|
@@ -26,7 +26,8 @@ export const getCloudflareAPIBaseURL = getEnvironmentVariableFactory({
|
|
|
26
26
|
export async function fetchInternal<ResponseType>(
|
|
27
27
|
resource: string,
|
|
28
28
|
init: RequestInit = {},
|
|
29
|
-
queryParams?: URLSearchParams
|
|
29
|
+
queryParams?: URLSearchParams,
|
|
30
|
+
abortSignal?: AbortSignal
|
|
30
31
|
): Promise<ResponseType> {
|
|
31
32
|
await requireLoggedIn();
|
|
32
33
|
const apiToken = requireApiToken();
|
|
@@ -41,11 +42,12 @@ export async function fetchInternal<ResponseType>(
|
|
|
41
42
|
method,
|
|
42
43
|
...init,
|
|
43
44
|
headers,
|
|
45
|
+
signal: abortSignal,
|
|
44
46
|
}
|
|
45
47
|
);
|
|
46
48
|
const jsonText = await response.text();
|
|
47
49
|
try {
|
|
48
|
-
return parseJSON(jsonText)
|
|
50
|
+
return parseJSON<ResponseType>(jsonText);
|
|
49
51
|
} catch (err) {
|
|
50
52
|
throw new ParseError({
|
|
51
53
|
text: "Received a malformed response from the API",
|