Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dry-snakes-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

fix(wrangler): fix wrangler config schema defaults
17 changes: 17 additions & 0 deletions packages/wrangler/src/__tests__/config/configSchema.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import fs from "node:fs";
import path from "node:path";

describe("src/config/environment.ts", () => {
// `@default` values must not be escaped in order to generate a valid schema.
test("default values are not escaped", () => {
const srcFile = path.join(__dirname, "../../config/environment.ts");
const srcLines = fs.readFileSync(srcFile, "utf-8").split("\n");
const hasEscapedDefaultRegex = /@default\s+`/;
srcLines.forEach((line, lineNumber) => {
const hasEscapedDefault = hasEscapedDefaultRegex.test(line);
expect
.soft(hasEscapedDefault, `On line ${lineNumber + 1}: "${line}"`)
.toEqual(false);
});
});
});
70 changes: 36 additions & 34 deletions packages/wrangler/src/config/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ interface EnvironmentInheritable {

/**
* A list of flags that enable features from upcoming features of
* the Workers runtime, usually used together with compatibility_flags.
* the Workers runtime, usually used together with compatibility_date.
*
* More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
* More details at https://developers.cloudflare.com/workers/platform/compatibility-flags
*
* @default `[]`
* @default []
* @inheritable
*/
compatibility_flags: string[];
Expand Down Expand Up @@ -162,23 +162,25 @@ interface EnvironmentInheritable {
*/
base_dir: string | undefined;

// Carmen according to our tests the default is undefined
// warning: you must force "workers_dev: true" in tests to match expected behavior
/**
* Whether we use <name>.<subdomain>.workers.dev to
* test and deploy your Worker.
*
* // Carmen according to our tests the default is undefined
* // warning: you must force "workers_dev: true" in tests to match expected behavior
* @default `true` (This is a breaking change from Wrangler v1)
*
* @default true
* @breaking
* @inheritable
*/

workers_dev: boolean | undefined;

/**
* Whether we use <version>-<name>.<subdomain>.workers.dev to
* serve Preview URLs for your Worker.
*
* @default `true`
* @default true
* @inheritable
*/
preview_urls: boolean | undefined;
Expand Down Expand Up @@ -214,15 +216,15 @@ interface EnvironmentInheritable {
/**
* The function to use to replace jsx syntax.
*
* @default `"React.createElement"`
* @default "React.createElement"
* @inheritable
*/
jsx_factory: string;

/**
* The function to use to replace jsx fragment syntax.
*
* @default `"React.Fragment"`
* @default "React.Fragment"
* @inheritable
*/
jsx_fragment: string;
Expand All @@ -246,7 +248,7 @@ interface EnvironmentInheritable {
*
* More details here https://developers.cloudflare.com/workers/platform/cron-triggers
*
* @default `{crons:[]}`
* @default {crons:[]}
* @inheritable
*/
triggers: { crons: string[] };
Expand Down Expand Up @@ -340,7 +342,7 @@ interface EnvironmentInheritable {
/**
* List of bindings that you will send to logfwdr
*
* @default `{bindings:[]}`
* @default {bindings:[]}
* @inheritable
*/
logfwdr: {
Expand Down Expand Up @@ -432,7 +434,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{}`
* @default {}
* @nonInheritable
*/
define: Record<string, string>;
Expand All @@ -442,7 +444,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{}`
* @default {}
* @nonInheritable
*/
vars: Record<string, string | Json>;
Expand All @@ -456,7 +458,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{bindings:[]}`
* @default {bindings:[]}
* @nonInheritable
*/
durable_objects: {
Expand All @@ -469,7 +471,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
workflows: WorkflowBinding[];
Expand All @@ -480,7 +482,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{}`
* @default {}
* @nonInheritable
*/
cloudchamber: CloudchamberConfig;
Expand All @@ -495,7 +497,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{}`
* @default {}
* @nonInheritable
*/
app: ContainerApp[];
Expand All @@ -511,7 +513,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
kv_namespaces: {
Expand All @@ -529,7 +531,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
send_email: {
Expand All @@ -547,7 +549,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{consumers:[],producers:[]}`
* @default {consumers:[],producers:[]}
* @nonInheritable
*/
queues: {
Expand Down Expand Up @@ -600,7 +602,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
r2_buckets: {
Expand All @@ -620,7 +622,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
d1_databases: {
Expand All @@ -646,7 +648,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
vectorize: {
Expand All @@ -662,7 +664,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
hyperdrive: {
Expand All @@ -680,7 +682,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
services:
Expand All @@ -702,7 +704,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
analytics_engine_datasets: {
Expand All @@ -718,7 +720,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{}`
* @default {}
* @nonInheritable
*/
browser:
Expand All @@ -733,7 +735,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{}`
* @default {}
* @nonInheritable
*/
ai:
Expand All @@ -758,7 +760,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `{}`
* @default {}
* @nonInheritable
*/
unsafe: {
Expand Down Expand Up @@ -803,7 +805,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
mtls_certificates: {
Expand All @@ -819,7 +821,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
tail_consumers?: TailConsumer[];
Expand All @@ -830,7 +832,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
dispatch_namespaces: {
Expand All @@ -848,7 +850,7 @@ export interface EnvironmentNonInheritable {
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default `[]`
* @default []
* @nonInheritable
*/
pipelines: {
Expand Down Expand Up @@ -882,7 +884,7 @@ interface EnvironmentDeprecated {
/**
* A list of services that your Worker should be bound to.
*
* @default `[]`
* @default []
* @deprecated DO NOT USE. We'd added this to test the new service binding system, but the proper way to test experimental features is to use `unsafe.bindings` configuration.
*/
experimental_services?: {
Expand Down