From 9b687ae5ea3bd0740d109ad5f5bce2c453cf1537 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 21 Mar 2024 08:41:35 +0000 Subject: [PATCH 1/4] fix: make scheduledTasks types consistent --- src/nitro.ts | 4 ++++ src/options.ts | 1 + src/types/nitro.ts | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nitro.ts b/src/nitro.ts index 24eb6ea39b..6bca539112 100644 --- a/src/nitro.ts +++ b/src/nitro.ts @@ -128,6 +128,10 @@ export async function createNitro( nitro.options.virtual["#internal/nitro/virtual/tasks"] = () => { const _scheduledTasks = Object.entries(nitro.options.scheduledTasks || {}) .map(([cron, _tasks]) => { + if (Array.isArray(_tasks)) { + nitro.logger.warn(`[DEPRECATION] \`scheduledTasks\` must be an array. This will be removed in a future release`); + } + // @todo: Remove isArray condition check when deprecation is effective const tasks = (Array.isArray(_tasks) ? _tasks : [_tasks]).filter( (name) => { if (!nitro.options.tasks[name]) { diff --git a/src/options.ts b/src/options.ts index e6ec41b9cc..281e2ada75 100644 --- a/src/options.ts +++ b/src/options.ts @@ -55,6 +55,7 @@ const NitroDefaults: NitroConfig = { serverAssets: [], plugins: [], tasks: {}, + scheduledTasks: {}, imports: { exclude: [], dirs: [], diff --git a/src/types/nitro.ts b/src/types/nitro.ts index 268106062f..cfb070d24a 100644 --- a/src/types/nitro.ts +++ b/src/types/nitro.ts @@ -339,7 +339,7 @@ export interface NitroOptions extends PresetOptions { modules?: NitroModuleInput[]; plugins: string[]; tasks: { [name: string]: { handler: string; description: string } }; - scheduledTasks: { [cron: string]: string | string[] }; + scheduledTasks: { [cron: string]: string[] }; virtual: Record string | Promise)>; compressPublicAssets: boolean | CompressOptions; ignore: string[]; From 31a81fffebf049d277ecd36c3529a2b4b65bd083 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 21 Mar 2024 09:45:52 +0100 Subject: [PATCH 2/4] fix: invert condition --- src/nitro.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nitro.ts b/src/nitro.ts index 6bca539112..ee07853807 100644 --- a/src/nitro.ts +++ b/src/nitro.ts @@ -128,7 +128,7 @@ export async function createNitro( nitro.options.virtual["#internal/nitro/virtual/tasks"] = () => { const _scheduledTasks = Object.entries(nitro.options.scheduledTasks || {}) .map(([cron, _tasks]) => { - if (Array.isArray(_tasks)) { + if (!Array.isArray(_tasks)) { nitro.logger.warn(`[DEPRECATION] \`scheduledTasks\` must be an array. This will be removed in a future release`); } // @todo: Remove isArray condition check when deprecation is effective From 514ec7027acb2ad47b71d41aeb5b5735b0ca873c Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:49:30 +0000 Subject: [PATCH 3/4] chore: apply automated fixes --- src/nitro.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nitro.ts b/src/nitro.ts index ee07853807..850cde72fb 100644 --- a/src/nitro.ts +++ b/src/nitro.ts @@ -129,7 +129,9 @@ export async function createNitro( const _scheduledTasks = Object.entries(nitro.options.scheduledTasks || {}) .map(([cron, _tasks]) => { if (!Array.isArray(_tasks)) { - nitro.logger.warn(`[DEPRECATION] \`scheduledTasks\` must be an array. This will be removed in a future release`); + nitro.logger.warn( + `[DEPRECATION] \`scheduledTasks\` must be an array. This will be removed in a future release` + ); } // @todo: Remove isArray condition check when deprecation is effective const tasks = (Array.isArray(_tasks) ? _tasks : [_tasks]).filter( From 92277466afa36d11979a515ad65d1474728bfb7c Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 21 Mar 2024 11:16:25 +0100 Subject: [PATCH 4/4] fix: nitro.config.ts scheduledTasks array --- test/fixture/nitro.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixture/nitro.config.ts b/test/fixture/nitro.config.ts index 069bb7eadc..93c3df2933 100644 --- a/test/fixture/nitro.config.ts +++ b/test/fixture/nitro.config.ts @@ -101,7 +101,7 @@ export default defineNitroConfig({ tasks: true, }, scheduledTasks: { - "* * * * *": "test", + "* * * * *": ["test"], }, cloudflare: { pages: {