wrangler 0.0.0-e928f94 → 0.0.0-e9a1820
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 +13 -7
- package/src/__tests__/index.test.ts +254 -120
- package/src/__tests__/jest.setup.ts +18 -0
- package/src/__tests__/kv.test.ts +322 -0
- package/src/__tests__/mock-cfetch.ts +63 -0
- package/src/__tests__/mock-dialogs.ts +65 -0
- package/src/__tests__/run-in-tmp.ts +19 -0
- package/src/__tests__/run-wrangler.ts +32 -0
- package/src/api/form_data.ts +65 -75
- package/src/api/inspect.ts +0 -11
- package/src/api/worker.ts +33 -39
- package/src/cli.ts +6 -7
- package/src/config.ts +14 -5
- package/src/dev.tsx +264 -109
- package/src/dialogs.tsx +3 -11
- package/src/index.tsx +254 -210
- package/src/kv.tsx +65 -19
- package/src/pages.tsx +107 -99
- package/src/proxy.ts +103 -0
- package/src/publish.ts +37 -33
- package/src/user.tsx +9 -16
- package/wrangler-dist/cli.js +20754 -26926
- package/wrangler-dist/cli.js.map +3 -3
- package/src/__tests__/fixtures/init/.gitkeep +0 -0
- package/src/__tests__/mock-cfetch.js +0 -46
package/src/api/inspect.ts
CHANGED
|
@@ -140,17 +140,6 @@ export type DtEvent = DtLogEvent | DtExceptionEvent;
|
|
|
140
140
|
*/
|
|
141
141
|
export type DtListener = (event: DtEvent) => void;
|
|
142
142
|
|
|
143
|
-
interface DtProtocolRequest<T> {
|
|
144
|
-
id: number;
|
|
145
|
-
method: string;
|
|
146
|
-
params?: T;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
interface DtProtocolResponse<T> {
|
|
150
|
-
id: number;
|
|
151
|
-
result: T;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
143
|
/**
|
|
155
144
|
* A DevTools inspector that listens to logs and debug events from a Worker.
|
|
156
145
|
*
|
package/src/api/worker.ts
CHANGED
|
@@ -62,22 +62,40 @@ export interface CfModule {
|
|
|
62
62
|
type?: CfModuleType;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* A map of variable names to values.
|
|
67
|
+
*/
|
|
68
|
+
interface CfVars {
|
|
69
|
+
[key: string]: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
65
72
|
/**
|
|
66
73
|
* A KV namespace.
|
|
67
74
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*/
|
|
72
|
-
namespaceId: string;
|
|
75
|
+
interface CfKvNamespace {
|
|
76
|
+
binding: string;
|
|
77
|
+
id: string;
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
|
|
80
|
+
/**
|
|
81
|
+
* A Durable Object.
|
|
82
|
+
*/
|
|
83
|
+
interface CfDurableObject {
|
|
84
|
+
name: string;
|
|
76
85
|
class_name: string;
|
|
77
86
|
script_name?: string;
|
|
78
87
|
}
|
|
79
88
|
|
|
80
|
-
|
|
89
|
+
/**
|
|
90
|
+
* A Service.
|
|
91
|
+
*/
|
|
92
|
+
interface CfService {
|
|
93
|
+
name: string;
|
|
94
|
+
service: string;
|
|
95
|
+
environment: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface CfDurableObjectMigrations {
|
|
81
99
|
old_tag?: string;
|
|
82
100
|
new_tag: string;
|
|
83
101
|
steps: {
|
|
@@ -87,35 +105,6 @@ interface CfDOMigrations {
|
|
|
87
105
|
}[];
|
|
88
106
|
}
|
|
89
107
|
|
|
90
|
-
/**
|
|
91
|
-
* A `WebCrypto` key.
|
|
92
|
-
*
|
|
93
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey
|
|
94
|
-
*/
|
|
95
|
-
export interface CfCryptoKey {
|
|
96
|
-
/**
|
|
97
|
-
* The format.
|
|
98
|
-
*/
|
|
99
|
-
format: string;
|
|
100
|
-
/**
|
|
101
|
-
* The algorithm.
|
|
102
|
-
*/
|
|
103
|
-
algorithm: string;
|
|
104
|
-
/**
|
|
105
|
-
* The usages.
|
|
106
|
-
*/
|
|
107
|
-
usages: string[];
|
|
108
|
-
/**
|
|
109
|
-
* The data.
|
|
110
|
-
*/
|
|
111
|
-
data: BufferSource | JsonWebKey;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* A variable (aka. environment variable).
|
|
116
|
-
*/
|
|
117
|
-
export type CfVariable = string | CfKvNamespace | CfCryptoKey | CfDurableObject;
|
|
118
|
-
|
|
119
108
|
/**
|
|
120
109
|
* Options for creating a `CfWorker`.
|
|
121
110
|
*/
|
|
@@ -133,10 +122,15 @@ export interface CfWorkerInit {
|
|
|
133
122
|
*/
|
|
134
123
|
modules: void | CfModule[];
|
|
135
124
|
/**
|
|
136
|
-
*
|
|
125
|
+
* All the bindings
|
|
137
126
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
bindings: {
|
|
128
|
+
kv_namespaces?: CfKvNamespace[];
|
|
129
|
+
durable_objects?: { bindings: CfDurableObject[] };
|
|
130
|
+
vars?: CfVars;
|
|
131
|
+
services?: CfService[];
|
|
132
|
+
};
|
|
133
|
+
migrations: void | CfDurableObjectMigrations;
|
|
140
134
|
compatibility_date: string | void;
|
|
141
135
|
compatibility_flags: void | string[];
|
|
142
136
|
usage_model: void | "bundled" | "unbound";
|
package/src/cli.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { hideBin } from "yargs/helpers";
|
|
1
2
|
import { main } from ".";
|
|
2
3
|
|
|
3
|
-
main(process.argv
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
throw cause;
|
|
4
|
+
main(hideBin(process.argv)).catch(() => {
|
|
5
|
+
// The logging of any error that was thrown from `main()` is handled in the `yargs.fail()` handler.
|
|
6
|
+
// Here we just want to ensure that the process exits with a non-zero code.
|
|
7
|
+
// We don't want to do this inside the `main()` function, since that would kill the process when running our tests.
|
|
8
|
+
process.exit(1);
|
|
10
9
|
});
|
package/src/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// we're going to manually write both the type definition AND
|
|
2
2
|
// the validator for the config, so that we can give better error messages
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type DurableObjectMigration = {
|
|
5
5
|
tag: string;
|
|
6
6
|
new_classes?: string[];
|
|
7
7
|
renamed_classes?: string[];
|
|
@@ -25,13 +25,13 @@ type Dev = {
|
|
|
25
25
|
upstream_protocol?: string;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
type Vars = { [key: string]: string };
|
|
28
|
+
export type Vars = { [key: string]: string };
|
|
29
29
|
|
|
30
30
|
type Cron = string; // TODO: we should be able to parse a cron pattern with ts
|
|
31
31
|
|
|
32
32
|
type KVNamespace = {
|
|
33
|
-
binding
|
|
34
|
-
preview_id
|
|
33
|
+
binding: string;
|
|
34
|
+
preview_id?: string;
|
|
35
35
|
id: string;
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -41,6 +41,12 @@ type DurableObject = {
|
|
|
41
41
|
script_name?: string;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
type Service = {
|
|
45
|
+
name: string;
|
|
46
|
+
service: string;
|
|
47
|
+
environment: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
44
50
|
type Build = {
|
|
45
51
|
command?: string;
|
|
46
52
|
cwd?: string;
|
|
@@ -86,6 +92,8 @@ type Env = {
|
|
|
86
92
|
vars?: Vars;
|
|
87
93
|
durable_objects?: { bindings: DurableObject[] };
|
|
88
94
|
kv_namespaces?: KVNamespace[];
|
|
95
|
+
experimental_services?: Service[];
|
|
96
|
+
migrations?: DurableObjectMigration[];
|
|
89
97
|
usage_model?: UsageModel; // inherited
|
|
90
98
|
};
|
|
91
99
|
|
|
@@ -108,9 +116,10 @@ export type Config = {
|
|
|
108
116
|
jsx_factory?: string; // inherited
|
|
109
117
|
jsx_fragment?: string; // inherited
|
|
110
118
|
vars?: Vars;
|
|
111
|
-
migrations?: DOMigration[];
|
|
112
119
|
durable_objects?: { bindings: DurableObject[] };
|
|
113
120
|
kv_namespaces?: KVNamespace[];
|
|
121
|
+
experimental_services?: Service[];
|
|
122
|
+
migrations?: DurableObjectMigration[];
|
|
114
123
|
site?: Site; // inherited
|
|
115
124
|
// we should use typescript to parse cron patterns
|
|
116
125
|
triggers?: { crons: Cron[] }; // inherited
|