diff --git a/.changeset/dry-snakes-deliver.md b/.changeset/dry-snakes-deliver.md new file mode 100644 index 0000000000..b8f13f6885 --- /dev/null +++ b/.changeset/dry-snakes-deliver.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +fix(wrangler): fix wrangler config schema defaults diff --git a/packages/wrangler/src/__tests__/config/configSchema.test.ts b/packages/wrangler/src/__tests__/config/configSchema.test.ts new file mode 100644 index 0000000000..c969034a82 --- /dev/null +++ b/packages/wrangler/src/__tests__/config/configSchema.test.ts @@ -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); + }); + }); +}); diff --git a/packages/wrangler/src/config/environment.ts b/packages/wrangler/src/config/environment.ts index 56f309928f..b11b42895d 100644 --- a/packages/wrangler/src/config/environment.ts +++ b/packages/wrangler/src/config/environment.ts @@ -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[]; @@ -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 ..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 -..workers.dev to * serve Preview URLs for your Worker. * - * @default `true` + * @default true * @inheritable */ preview_urls: boolean | undefined; @@ -214,7 +216,7 @@ interface EnvironmentInheritable { /** * The function to use to replace jsx syntax. * - * @default `"React.createElement"` + * @default "React.createElement" * @inheritable */ jsx_factory: string; @@ -222,7 +224,7 @@ interface EnvironmentInheritable { /** * The function to use to replace jsx fragment syntax. * - * @default `"React.Fragment"` + * @default "React.Fragment" * @inheritable */ jsx_fragment: string; @@ -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[] }; @@ -340,7 +342,7 @@ interface EnvironmentInheritable { /** * List of bindings that you will send to logfwdr * - * @default `{bindings:[]}` + * @default {bindings:[]} * @inheritable */ logfwdr: { @@ -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; @@ -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; @@ -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: { @@ -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[]; @@ -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; @@ -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[]; @@ -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: { @@ -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: { @@ -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: { @@ -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: { @@ -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: { @@ -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: { @@ -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: { @@ -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: @@ -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: { @@ -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: @@ -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: @@ -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: { @@ -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: { @@ -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[]; @@ -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: { @@ -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: { @@ -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?: {