wrangler 0.0.0-bb8dc5c → 0.0.0-c738c6e
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 +1 -1
- package/src/api/form_data.ts +31 -4
- package/src/api/worker.ts +9 -3
- package/src/config.ts +12 -0
- package/src/dev.tsx +18 -1
- package/src/index.tsx +49 -3
- package/src/publish.ts +12 -0
- package/wrangler-dist/cli.js +89 -11
- package/wrangler-dist/cli.js.map +2 -2
package/package.json
CHANGED
package/src/api/form_data.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
CfModule,
|
|
6
6
|
CfKvNamespace,
|
|
7
7
|
CfCryptoKey,
|
|
8
|
+
CfDurableObject,
|
|
8
9
|
} from "./worker.js";
|
|
9
10
|
import { FormData, Blob } from "formdata-node";
|
|
10
11
|
|
|
@@ -27,9 +28,23 @@ function toBinding(
|
|
|
27
28
|
return { name, type: "plain_text", text: variable };
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if ((variable as CfKvNamespace).namespaceId) {
|
|
32
|
+
return {
|
|
33
|
+
name,
|
|
34
|
+
type: "kv_namespace",
|
|
35
|
+
namespace_id: (variable as CfKvNamespace).namespaceId,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if ((variable as CfDurableObject).class_name) {
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
type: "durable_object_namespace",
|
|
43
|
+
class_name: (variable as CfDurableObject).class_name,
|
|
44
|
+
...((variable as CfDurableObject).script_name && {
|
|
45
|
+
script_name: (variable as CfDurableObject).script_name,
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
const { format, algorithm, usages, data } = variable as CfCryptoKey;
|
|
@@ -84,7 +99,14 @@ function toModule(module: CfModule, entryType?: CfModuleType): Blob {
|
|
|
84
99
|
*/
|
|
85
100
|
export function toFormData(worker: CfWorkerInit): FormData {
|
|
86
101
|
const formData = new FormData();
|
|
87
|
-
const {
|
|
102
|
+
const {
|
|
103
|
+
main,
|
|
104
|
+
modules,
|
|
105
|
+
variables,
|
|
106
|
+
usage_model,
|
|
107
|
+
compatibility_date,
|
|
108
|
+
compatibility_flags,
|
|
109
|
+
} = worker;
|
|
88
110
|
const { name, type: mainType } = main;
|
|
89
111
|
|
|
90
112
|
const bindings = [];
|
|
@@ -103,10 +125,15 @@ export function toFormData(worker: CfWorkerInit): FormData {
|
|
|
103
125
|
// @ts-expect-error - we should type metadata
|
|
104
126
|
metadata.compatibility_date = compatibility_date;
|
|
105
127
|
}
|
|
128
|
+
if (compatibility_flags) {
|
|
129
|
+
// @ts-expect-error - we should type metadata
|
|
130
|
+
metadata.compatibility_flags = compatibility_flags;
|
|
131
|
+
}
|
|
106
132
|
if (usage_model) {
|
|
107
133
|
// @ts-expect-error - we should type metadata
|
|
108
134
|
metadata.usage_model = usage_model;
|
|
109
135
|
}
|
|
136
|
+
|
|
110
137
|
formData.set("metadata", JSON.stringify(metadata));
|
|
111
138
|
|
|
112
139
|
if (singleton && modules && modules.length > 0) {
|
package/src/api/worker.ts
CHANGED
|
@@ -72,6 +72,11 @@ export interface CfKvNamespace {
|
|
|
72
72
|
namespaceId: string;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
export interface CfDurableObject {
|
|
76
|
+
class_name: string;
|
|
77
|
+
script_name?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
75
80
|
/**
|
|
76
81
|
* A `WebCrypto` key.
|
|
77
82
|
*
|
|
@@ -99,7 +104,7 @@ export interface CfCryptoKey {
|
|
|
99
104
|
/**
|
|
100
105
|
* A variable (aka. environment variable).
|
|
101
106
|
*/
|
|
102
|
-
export type CfVariable = string | CfKvNamespace | CfCryptoKey;
|
|
107
|
+
export type CfVariable = string | CfKvNamespace | CfCryptoKey | CfDurableObject;
|
|
103
108
|
|
|
104
109
|
/**
|
|
105
110
|
* Options for creating a `CfWorker`.
|
|
@@ -117,8 +122,9 @@ export interface CfWorkerInit {
|
|
|
117
122
|
* The map of names to variables. (aka. environment variables)
|
|
118
123
|
*/
|
|
119
124
|
variables?: { [name: string]: CfVariable };
|
|
120
|
-
compatibility_date
|
|
121
|
-
|
|
125
|
+
compatibility_date: string | void;
|
|
126
|
+
compatibility_flags: void | string[];
|
|
127
|
+
usage_model: void | "bundled" | "unbound";
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
/**
|
package/src/config.ts
CHANGED
|
@@ -28,6 +28,12 @@ type KVNamespace = {
|
|
|
28
28
|
id: string;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
type DurableObject = {
|
|
32
|
+
name: string;
|
|
33
|
+
class_name: string;
|
|
34
|
+
script_name?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
31
37
|
type Build = {
|
|
32
38
|
command?: string;
|
|
33
39
|
cwd?: string;
|
|
@@ -59,6 +65,8 @@ type Env = {
|
|
|
59
65
|
name?: string; // inherited
|
|
60
66
|
account_id?: string; // inherited
|
|
61
67
|
workers_dev?: boolean; // inherited
|
|
68
|
+
compatibility_date?: string; // inherited
|
|
69
|
+
compatibility_flags?: string[]; // inherited
|
|
62
70
|
zone_id?: string; // inherited
|
|
63
71
|
routes?: string[]; // inherited
|
|
64
72
|
route?: string; // inherited
|
|
@@ -69,6 +77,7 @@ type Env = {
|
|
|
69
77
|
// we should use typescript to parse cron patterns
|
|
70
78
|
triggers?: { crons: Cron[] }; // inherited
|
|
71
79
|
kv_namespaces?: KVNamespace[];
|
|
80
|
+
usage_model?: UsageModel; // inherited
|
|
72
81
|
};
|
|
73
82
|
|
|
74
83
|
export type Config = {
|
|
@@ -76,6 +85,8 @@ export type Config = {
|
|
|
76
85
|
account_id?: string; // inherited
|
|
77
86
|
// @deprecated Don't use this
|
|
78
87
|
type?: Project; // top level
|
|
88
|
+
compatibility_date?: string; // inherited
|
|
89
|
+
compatibility_flags?: string[]; // inherited
|
|
79
90
|
// -- there's some mutually exclusive logic for this next block,
|
|
80
91
|
// but I didn't bother for now
|
|
81
92
|
workers_dev?: boolean; // inherited
|
|
@@ -88,6 +99,7 @@ export type Config = {
|
|
|
88
99
|
jsxFactory?: string; // inherited
|
|
89
100
|
jsxFragment?: string; // inherited
|
|
90
101
|
vars?: Vars;
|
|
102
|
+
durable_objects?: { bindings: DurableObject[] };
|
|
91
103
|
kv_namespaces?: KVNamespace[];
|
|
92
104
|
site?: Site; // inherited
|
|
93
105
|
// we should use typescript to parse cron patterns
|
package/src/dev.tsx
CHANGED
|
@@ -37,6 +37,9 @@ type Props = {
|
|
|
37
37
|
variables: { [name: string]: CfVariable };
|
|
38
38
|
public: void | string;
|
|
39
39
|
site: void | string;
|
|
40
|
+
compatibilityDate: void | string;
|
|
41
|
+
compatibilityFlags: void | string[];
|
|
42
|
+
usageModel: void | "bundled" | "unbound";
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
export function Dev(props: Props): JSX.Element {
|
|
@@ -98,6 +101,9 @@ export function Dev(props: Props): JSX.Element {
|
|
|
98
101
|
site={props.site}
|
|
99
102
|
public={props.public}
|
|
100
103
|
port={props.port}
|
|
104
|
+
compatibilityDate={props.compatibilityDate}
|
|
105
|
+
compatibilityFlags={props.compatibilityFlags}
|
|
106
|
+
usageModel={props.usageModel}
|
|
101
107
|
/>
|
|
102
108
|
)}
|
|
103
109
|
<Box borderStyle="round" paddingLeft={1} paddingRight={1}>
|
|
@@ -153,6 +159,9 @@ function Remote(props: {
|
|
|
153
159
|
accountId: void | string;
|
|
154
160
|
apiToken: void | string;
|
|
155
161
|
variables: { [name: string]: CfVariable };
|
|
162
|
+
compatibilityDate: string | void;
|
|
163
|
+
compatibilityFlags: void | string[];
|
|
164
|
+
usageModel: void | "bundled" | "unbound";
|
|
156
165
|
}) {
|
|
157
166
|
assert(props.accountId, "accountId is required");
|
|
158
167
|
assert(props.apiToken, "apiToken is required");
|
|
@@ -166,6 +175,9 @@ function Remote(props: {
|
|
|
166
175
|
variables: props.variables,
|
|
167
176
|
sitesFolder: props.site,
|
|
168
177
|
port: props.port,
|
|
178
|
+
compatibilityDate: props.compatibilityDate,
|
|
179
|
+
compatibilityFlags: props.compatibilityFlags,
|
|
180
|
+
usageModel: props.usageModel,
|
|
169
181
|
});
|
|
170
182
|
|
|
171
183
|
useProxy({ token, publicRoot: props.public, port: props.port });
|
|
@@ -399,6 +411,9 @@ function useWorker(props: {
|
|
|
399
411
|
variables: { [name: string]: CfVariable };
|
|
400
412
|
sitesFolder: void | string;
|
|
401
413
|
port: number;
|
|
414
|
+
compatibilityDate: string | void;
|
|
415
|
+
compatibilityFlags: string[] | void;
|
|
416
|
+
usageModel: void | "bundled" | "unbound";
|
|
402
417
|
}): CfPreviewToken | void {
|
|
403
418
|
const {
|
|
404
419
|
name,
|
|
@@ -447,7 +462,6 @@ function useWorker(props: {
|
|
|
447
462
|
}; // TODO: cancellable?
|
|
448
463
|
|
|
449
464
|
const content = await readFile(bundle.path, "utf-8");
|
|
450
|
-
console.log(content);
|
|
451
465
|
const init: CfWorkerInit = {
|
|
452
466
|
main: {
|
|
453
467
|
name: name || path.basename(bundle.path),
|
|
@@ -471,6 +485,9 @@ function useWorker(props: {
|
|
|
471
485
|
__STATIC_CONTENT: { namespaceId: assets.namespace },
|
|
472
486
|
}
|
|
473
487
|
: variables,
|
|
488
|
+
compatibility_date: props.compatibilityDate,
|
|
489
|
+
compatibility_flags: props.compatibilityFlags,
|
|
490
|
+
usage_model: props.usageModel,
|
|
474
491
|
};
|
|
475
492
|
setToken(
|
|
476
493
|
await createWorker(init, {
|
package/src/index.tsx
CHANGED
|
@@ -55,6 +55,44 @@ async function readConfig(path?: string): Promise<Config> {
|
|
|
55
55
|
Object.assign(config, parsed);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
const inheritedFields = [
|
|
59
|
+
"name",
|
|
60
|
+
"account_id",
|
|
61
|
+
"workers_dev",
|
|
62
|
+
"compatibility_date",
|
|
63
|
+
"compatibility_flags",
|
|
64
|
+
"zone_id",
|
|
65
|
+
"routes",
|
|
66
|
+
"route",
|
|
67
|
+
"jsxFactory",
|
|
68
|
+
"jsxFragment",
|
|
69
|
+
"site",
|
|
70
|
+
"triggers",
|
|
71
|
+
"usage_model",
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
Object.keys(config.env || {}).forEach((env) => {
|
|
75
|
+
inheritedFields.forEach((field) => {
|
|
76
|
+
if (config[field] !== undefined && config.env[env][field] === undefined) {
|
|
77
|
+
config.env[env][field] = config[field]; // TODO: - shallow copy?
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const mirroredFields = ["vars", "kv_namespaces", "durable_objects"];
|
|
83
|
+
Object.keys(config.env || {}).forEach((env) => {
|
|
84
|
+
mirroredFields.forEach((field) => {
|
|
85
|
+
// if it exists on top level, it should exist on env defns
|
|
86
|
+
Object.keys(config[field] || {}).forEach((fieldKey) => {
|
|
87
|
+
if (!config.env[env][field]?.[fieldKey]) {
|
|
88
|
+
console.error(
|
|
89
|
+
`In your configuration, "${field}.${fieldKey}" exists at a top level, but not on "env.${env}". This is not what you probably want, since the field "${field}" is not inherited by environments. Please add "${field}.${fieldKey}" to "env.${env}".`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
58
96
|
// todo: validate, add defaults
|
|
59
97
|
// let's just do some basics for now
|
|
60
98
|
|
|
@@ -155,8 +193,7 @@ export async function main(argv: string[]): Promise<void> {
|
|
|
155
193
|
try {
|
|
156
194
|
await writeFile(
|
|
157
195
|
destination,
|
|
158
|
-
`compatibility_date = "${compatibilityDate}"
|
|
159
|
-
`
|
|
196
|
+
`compatibility_date = "${compatibilityDate}"` + "\n"
|
|
160
197
|
);
|
|
161
198
|
console.log(`✨ Succesfully created wrangler.toml`);
|
|
162
199
|
// TODO: suggest next steps?
|
|
@@ -410,7 +447,7 @@ export async function main(argv: string[]): Promise<void> {
|
|
|
410
447
|
|
|
411
448
|
// -- snip, end --
|
|
412
449
|
|
|
413
|
-
const envRootObj = args.env ? config[`env.${args.env}`] : config;
|
|
450
|
+
const envRootObj: Config = args.env ? config[`env.${args.env}`] : config;
|
|
414
451
|
|
|
415
452
|
render(
|
|
416
453
|
<Dev
|
|
@@ -424,6 +461,9 @@ export async function main(argv: string[]): Promise<void> {
|
|
|
424
461
|
site={args.site || config.site?.bucket}
|
|
425
462
|
port={args.port || config.dev?.port}
|
|
426
463
|
public={args.public}
|
|
464
|
+
compatibilityDate={config.compatibility_date}
|
|
465
|
+
compatibilityFlags={config.compatibility_flags}
|
|
466
|
+
usageModel={config.usage_model}
|
|
427
467
|
variables={{
|
|
428
468
|
...(envRootObj?.vars || {}),
|
|
429
469
|
...(envRootObj?.kv_namespaces || []).reduce(
|
|
@@ -439,6 +479,12 @@ export async function main(argv: string[]): Promise<void> {
|
|
|
439
479
|
},
|
|
440
480
|
{}
|
|
441
481
|
),
|
|
482
|
+
...(envRootObj?.durable_objects?.bindings || []).reduce(
|
|
483
|
+
(obj, { name, class_name, script_name }) => {
|
|
484
|
+
return { ...obj, [name]: { class_name, script_name } };
|
|
485
|
+
},
|
|
486
|
+
{}
|
|
487
|
+
),
|
|
442
488
|
}}
|
|
443
489
|
/>
|
|
444
490
|
);
|
package/src/publish.ts
CHANGED
|
@@ -160,6 +160,15 @@ export default async function publish(props: Props): Promise<void> {
|
|
|
160
160
|
},
|
|
161
161
|
{}
|
|
162
162
|
),
|
|
163
|
+
...(envRootObj?.durable_objects?.bindings || []).reduce(
|
|
164
|
+
(obj, { name, class_name, script_name }) => {
|
|
165
|
+
return {
|
|
166
|
+
...obj,
|
|
167
|
+
[name]: { class_name, ...(script_name && { script_name }) },
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
{}
|
|
171
|
+
),
|
|
163
172
|
...(assets.namespace
|
|
164
173
|
? { __STATIC_CONTENT: { namespaceId: assets.namespace } }
|
|
165
174
|
: {}),
|
|
@@ -171,6 +180,9 @@ export default async function publish(props: Props): Promise<void> {
|
|
|
171
180
|
type: "text",
|
|
172
181
|
})
|
|
173
182
|
: [],
|
|
183
|
+
compatibility_date: config.compatibility_date,
|
|
184
|
+
compatibility_flags: config.compatibility_flags,
|
|
185
|
+
usage_model: config.usage_model,
|
|
174
186
|
};
|
|
175
187
|
|
|
176
188
|
const start = Date.now();
|
package/wrangler-dist/cli.js
CHANGED
|
@@ -128151,9 +128151,22 @@ function toBinding(name, variable) {
|
|
|
128151
128151
|
if (typeof variable === "string") {
|
|
128152
128152
|
return { name, type: "plain_text", text: variable };
|
|
128153
128153
|
}
|
|
128154
|
-
|
|
128155
|
-
|
|
128156
|
-
|
|
128154
|
+
if (variable.namespaceId) {
|
|
128155
|
+
return {
|
|
128156
|
+
name,
|
|
128157
|
+
type: "kv_namespace",
|
|
128158
|
+
namespace_id: variable.namespaceId
|
|
128159
|
+
};
|
|
128160
|
+
}
|
|
128161
|
+
if (variable.class_name) {
|
|
128162
|
+
return {
|
|
128163
|
+
name,
|
|
128164
|
+
type: "durable_object_namespace",
|
|
128165
|
+
class_name: variable.class_name,
|
|
128166
|
+
...variable.script_name && {
|
|
128167
|
+
script_name: variable.script_name
|
|
128168
|
+
}
|
|
128169
|
+
};
|
|
128157
128170
|
}
|
|
128158
128171
|
const { format: format3, algorithm, usages, data } = variable;
|
|
128159
128172
|
if (format3) {
|
|
@@ -128199,7 +128212,14 @@ function toModule(module2, entryType) {
|
|
|
128199
128212
|
}
|
|
128200
128213
|
function toFormData2(worker) {
|
|
128201
128214
|
const formData = new FormData3();
|
|
128202
|
-
const {
|
|
128215
|
+
const {
|
|
128216
|
+
main: main2,
|
|
128217
|
+
modules,
|
|
128218
|
+
variables,
|
|
128219
|
+
usage_model,
|
|
128220
|
+
compatibility_date,
|
|
128221
|
+
compatibility_flags
|
|
128222
|
+
} = worker;
|
|
128203
128223
|
const { name, type: mainType } = main2;
|
|
128204
128224
|
const bindings = [];
|
|
128205
128225
|
for (const [name2, variable] of Object.entries(variables ?? {})) {
|
|
@@ -128215,6 +128235,9 @@ function toFormData2(worker) {
|
|
|
128215
128235
|
if (compatibility_date) {
|
|
128216
128236
|
metadata.compatibility_date = compatibility_date;
|
|
128217
128237
|
}
|
|
128238
|
+
if (compatibility_flags) {
|
|
128239
|
+
metadata.compatibility_flags = compatibility_flags;
|
|
128240
|
+
}
|
|
128218
128241
|
if (usage_model) {
|
|
128219
128242
|
metadata.usage_model = usage_model;
|
|
128220
128243
|
}
|
|
@@ -128691,7 +128714,10 @@ function Dev(props) {
|
|
|
128691
128714
|
variables: props.variables,
|
|
128692
128715
|
site: props.site,
|
|
128693
128716
|
public: props.public,
|
|
128694
|
-
port: props.port
|
|
128717
|
+
port: props.port,
|
|
128718
|
+
compatibilityDate: props.compatibilityDate,
|
|
128719
|
+
compatibilityFlags: props.compatibilityFlags,
|
|
128720
|
+
usageModel: props.usageModel
|
|
128695
128721
|
}), /* @__PURE__ */ import_react2.default.createElement(import_ink2.Box, {
|
|
128696
128722
|
borderStyle: "round",
|
|
128697
128723
|
paddingLeft: 1,
|
|
@@ -128733,7 +128759,10 @@ function Remote(props) {
|
|
|
128733
128759
|
apiToken: props.apiToken,
|
|
128734
128760
|
variables: props.variables,
|
|
128735
128761
|
sitesFolder: props.site,
|
|
128736
|
-
port: props.port
|
|
128762
|
+
port: props.port,
|
|
128763
|
+
compatibilityDate: props.compatibilityDate,
|
|
128764
|
+
compatibilityFlags: props.compatibilityFlags,
|
|
128765
|
+
usageModel: props.usageModel
|
|
128737
128766
|
});
|
|
128738
128767
|
useProxy({ token, publicRoot: props.public, port: props.port });
|
|
128739
128768
|
useInspector(token ? token.inspectorUrl.href : void 0);
|
|
@@ -128932,7 +128961,6 @@ function useWorker(props) {
|
|
|
128932
128961
|
namespace: void 0
|
|
128933
128962
|
};
|
|
128934
128963
|
const content = await (0, import_promises3.readFile)(bundle.path, "utf-8");
|
|
128935
|
-
console.log(content);
|
|
128936
128964
|
const init = {
|
|
128937
128965
|
main: {
|
|
128938
128966
|
name: name || import_path.default.basename(bundle.path),
|
|
@@ -128947,7 +128975,10 @@ function useWorker(props) {
|
|
|
128947
128975
|
variables: assets.namespace ? {
|
|
128948
128976
|
...variables,
|
|
128949
128977
|
__STATIC_CONTENT: { namespaceId: assets.namespace }
|
|
128950
|
-
} : variables
|
|
128978
|
+
} : variables,
|
|
128979
|
+
compatibility_date: props.compatibilityDate,
|
|
128980
|
+
compatibility_flags: props.compatibilityFlags,
|
|
128981
|
+
usage_model: props.usageModel
|
|
128951
128982
|
};
|
|
128952
128983
|
setToken(await createWorker(init, {
|
|
128953
128984
|
accountId,
|
|
@@ -134193,7 +134224,7 @@ async function prompt(text, type2 = "text") {
|
|
|
134193
134224
|
}
|
|
134194
134225
|
|
|
134195
134226
|
// package.json
|
|
134196
|
-
var version = "0.0.0-
|
|
134227
|
+
var version = "0.0.0-c738c6e";
|
|
134197
134228
|
|
|
134198
134229
|
// src/pages.tsx
|
|
134199
134230
|
init_import_meta_url();
|
|
@@ -134515,13 +134546,22 @@ async function publish(props) {
|
|
|
134515
134546
|
...(envRootObj?.kv_namespaces || []).reduce((obj, { binding, preview_id, id }) => {
|
|
134516
134547
|
return { ...obj, [binding]: { namespaceId: id } };
|
|
134517
134548
|
}, {}),
|
|
134549
|
+
...(envRootObj?.durable_objects?.bindings || []).reduce((obj, { name, class_name, script_name }) => {
|
|
134550
|
+
return {
|
|
134551
|
+
...obj,
|
|
134552
|
+
[name]: { class_name, ...script_name && { script_name } }
|
|
134553
|
+
};
|
|
134554
|
+
}, {}),
|
|
134518
134555
|
...assets.namespace ? { __STATIC_CONTENT: { namespaceId: assets.namespace } } : {}
|
|
134519
134556
|
},
|
|
134520
134557
|
modules: assets.manifest ? [].concat({
|
|
134521
134558
|
name: "__STATIC_CONTENT_MANIFEST",
|
|
134522
134559
|
content: JSON.stringify(assets.manifest),
|
|
134523
134560
|
type: "text"
|
|
134524
|
-
}) : []
|
|
134561
|
+
}) : [],
|
|
134562
|
+
compatibility_date: config.compatibility_date,
|
|
134563
|
+
compatibility_flags: config.compatibility_flags,
|
|
134564
|
+
usage_model: config.usage_model
|
|
134525
134565
|
};
|
|
134526
134566
|
const start = Date.now();
|
|
134527
134567
|
function formatTime(duration) {
|
|
@@ -134637,6 +134677,38 @@ async function readConfig(path10) {
|
|
|
134637
134677
|
const parsed = import_toml2.default.parse(tml);
|
|
134638
134678
|
Object.assign(config, parsed);
|
|
134639
134679
|
}
|
|
134680
|
+
const inheritedFields = [
|
|
134681
|
+
"name",
|
|
134682
|
+
"account_id",
|
|
134683
|
+
"workers_dev",
|
|
134684
|
+
"compatibility_date",
|
|
134685
|
+
"compatibility_flags",
|
|
134686
|
+
"zone_id",
|
|
134687
|
+
"routes",
|
|
134688
|
+
"route",
|
|
134689
|
+
"jsxFactory",
|
|
134690
|
+
"jsxFragment",
|
|
134691
|
+
"site",
|
|
134692
|
+
"triggers",
|
|
134693
|
+
"usage_model"
|
|
134694
|
+
];
|
|
134695
|
+
Object.keys(config.env || {}).forEach((env3) => {
|
|
134696
|
+
inheritedFields.forEach((field) => {
|
|
134697
|
+
if (config[field] !== void 0 && config.env[env3][field] === void 0) {
|
|
134698
|
+
config.env[env3][field] = config[field];
|
|
134699
|
+
}
|
|
134700
|
+
});
|
|
134701
|
+
});
|
|
134702
|
+
const mirroredFields = ["vars", "kv_namespaces", "durable_objects"];
|
|
134703
|
+
Object.keys(config.env || {}).forEach((env3) => {
|
|
134704
|
+
mirroredFields.forEach((field) => {
|
|
134705
|
+
Object.keys(config[field] || {}).forEach((fieldKey) => {
|
|
134706
|
+
if (!config.env[env3][field]?.[fieldKey]) {
|
|
134707
|
+
console.error(`In your configuration, "${field}.${fieldKey}" exists at a top level, but not on "env.${env3}". This is not what you probably want, since the field "${field}" is not inherited by environments. Please add "${field}.${fieldKey}" to "env.${env3}".`);
|
|
134708
|
+
}
|
|
134709
|
+
});
|
|
134710
|
+
});
|
|
134711
|
+
});
|
|
134640
134712
|
config.__path__ = path10;
|
|
134641
134713
|
return config;
|
|
134642
134714
|
}
|
|
@@ -134681,7 +134753,7 @@ async function main(argv) {
|
|
|
134681
134753
|
const compatibilityDate = new Date().toISOString().substring(0, 10);
|
|
134682
134754
|
try {
|
|
134683
134755
|
await (0, import_promises6.writeFile)(destination, `compatibility_date = "${compatibilityDate}"
|
|
134684
|
-
|
|
134756
|
+
`);
|
|
134685
134757
|
console.log(`\u2728 Succesfully created wrangler.toml`);
|
|
134686
134758
|
} catch (err2) {
|
|
134687
134759
|
console.error(`Failed to create wrangler.toml`);
|
|
@@ -134836,6 +134908,9 @@ async function main(argv) {
|
|
|
134836
134908
|
site: args2.site || config.site?.bucket,
|
|
134837
134909
|
port: args2.port || config.dev?.port,
|
|
134838
134910
|
public: args2.public,
|
|
134911
|
+
compatibilityDate: config.compatibility_date,
|
|
134912
|
+
compatibilityFlags: config.compatibility_flags,
|
|
134913
|
+
usageModel: config.usage_model,
|
|
134839
134914
|
variables: {
|
|
134840
134915
|
...envRootObj?.vars || {},
|
|
134841
134916
|
...(envRootObj?.kv_namespaces || []).reduce((obj, { binding, preview_id }) => {
|
|
@@ -134843,6 +134918,9 @@ async function main(argv) {
|
|
|
134843
134918
|
throw new Error("kv namespaces need a preview id during dev mode");
|
|
134844
134919
|
}
|
|
134845
134920
|
return { ...obj, [binding]: { namespaceId: preview_id } };
|
|
134921
|
+
}, {}),
|
|
134922
|
+
...(envRootObj?.durable_objects?.bindings || []).reduce((obj, { name, class_name, script_name }) => {
|
|
134923
|
+
return { ...obj, [name]: { class_name, script_name } };
|
|
134846
134924
|
}, {})
|
|
134847
134925
|
}
|
|
134848
134926
|
}));
|