Skip to report

Named tasks connect the CLI and development runtime

Follow Nitro’s experimental task introduction through discovery, a shared runtime API, and CLI commands for listing and running development tasks.

nitrojs/nitro #1929 · PR by pi0 · Merged

nitrojs/nitro 081aa276..476bfcc9

base and head as given

  • Task definitions are now scanned from application task directories.
  • Development servers now expose endpoints for listing and running tasks.
  • The command line now supports listing and running development tasks.
  • Task APIs are now available through automatic imports.
files changed
18
in a component
15
lines in components
345
components
5
public routes changed
0
schema statements
0
new dependencies
0
excluded by role
3
Based on 12 of 15 eligible changed files

Development tasks

Added
Before
Tasks did not exist
After
Tasks are scanned and run in development

Projects can define named tasks that Nitro discovers at startup. During development, they can list and invoke those tasks through the command line or task endpoints, with query and request-body data passed as payload.

In favour

  • In favour: Loads task handlers only when invoked
  • In favour: Uses one generated registry for task discovery

The model found nothing to weigh against this.

Files changed in 5 components. Dependencies shown: 1 new, 9 unchanged
unchanged · 9new · 1

1 new dependency between components — Source Files → Runtime Code

What else could behave differently

8 components · 109 files

These components import changed code, directly or through other files. A traced dependency is a place to review, not a confirmed runtime failure. Some paths stopped at heavily imported files; inspect those consumers separately.

Reached 3

ComponentSymbolCited atFilesReached by
Type Definitionssrc/types/Signature changed src/types/nitro.ts:225-39221 direct · 1 at two steps
Trace path

Shortest component path from the changed symbol:

  1. Type Definitions

Later steps follow file imports; they do not prove this symbol is called.

Source Filessrc/Signature changed 1 of 7 changed symbols reaching itsrc/imports.ts:3-25125 direct · 1 at two steps · 6 at three steps
Trace path

Shortest component path from the changed symbol:

  1. Source Files

Later steps follow file imports; they do not prove this symbol is called.

src/rollup/Signature changed src/types/nitro.ts:225-39210none direct · 1 at two steps · 7 at three steps · 2 at four steps
Trace path

Shortest component path from the changed symbol:

  1. Type Definitions
  2. src/rollup/

Later steps follow file imports; they do not prove this symbol is called.

Held back 2

ComponentFilesReached byResolution
src/presets/34none direct · 12 at three steps · 22 at four stepsprecise
src/utils/1none direct · 1 at three stepsprecise

Ranked lower 3

ComponentFilesReached by
src/runtime/423 direct · 1 at two steps · 11 at three steps · 27 at four steps
src/dev/31 direct · 2 at three steps
src/cli/55 direct

Not traced past a hub 1

SymbolHub fileImported by
src/nitro.ts:createNitrosrc/runtime/app.ts34

Statements 3

NitroOptions’ signature changed and reached 2 files in src/types/. 11
src/types/nitro.ts:225-392
nitroImports’ signature changed and reached 12 files in src/. 516
src/imports.ts:3-25
NitroOptions’ signature changed and reached 10 files in src/rollup/. 172
src/types/nitro.ts:225-392

22 reached files belong to no component — tests, docs and config.

Routes, schema, dependencies

No public URL, no migration and no new package.

Inspect components, files and symbols

Component

Type DefinitionsModified
src/types/

1 file · 3 lines

7 dependents

Source FilesModified
src/

5 files · 146 lines

4 dependents

The public surface added listNitroTasks, runNitroTask, and scanTasks.
Runtime CodeModified
src/runtime/

4 files · 105 lines

2 dependents

The runtime public surface added NitroTask, NitroTaskContext, NitroTaskMeta, NitroTaskPayload, defineNitroTask, runNitroTask, and tasks.
Development ToolsModified
src/dev/

1 file · 6 lines

2 dependents

CLI CommandsModified
src/cli/

4 files · 85 lines

File

Type Definitionssrc/types/
src/types/nitro.ts

+2 −1

Source Filessrc/
src/task.ts

+78 −0

Source Filessrc/
src/nitro.ts

+52 −2

Source Filessrc/
src/scan.ts

+11 −0

Source Filessrc/
src/imports.ts

+2 −0

Source Filessrc/
src/options.ts

+1 −0

Runtime Codesrc/runtime/
src/runtime/task.ts

+62 −0

Runtime Codesrc/runtime/
src/runtime/entries/nitro-dev.ts

+35 −1

Runtime Codesrc/runtime/
src/runtime/virtual/tasks.ts

+6 −0

Runtime Codesrc/runtime/
src/runtime/index.ts

+1 −0

Development Toolssrc/dev/
src/dev/server.ts

+3 −3

CLI Commandssrc/cli/
src/cli/commands/tasks/run.ts

+46 −0

CLI Commandssrc/cli/
src/cli/commands/tasks/list.ts

+26 −0

CLI Commandssrc/cli/
src/cli/commands/tasks/index.ts

+12 −0

CLI Commandssrc/cli/
src/cli/index.ts

+1 −0

Function

imports what changeddownstream of it, one mark per step

createNitro()src/nitro.ts

reaches nothing past a hub

Analysis stopped tracing createNitro’s body change through src/runtime/app.ts at 3 hops because it has 34 importers.
src/nitro.ts:18-188
NitroTask()src/runtime/task.ts

reaches Runtime Code

NitroTask was added and reached 42 files in src/runtime/. 311127
src/runtime/task.ts:20-25
NitroBuildInfo()src/types/nitro.ts

reaches Development Tools

NitroBuildInfo’s signature changed and reached 3 files in src/dev/. 12
src/types/nitro.ts:207-223
NitroOptions()src/types/nitro.ts

reaches 2 components

NitroOptions’ signature changed and reached 34 files in src/presets/. 1222
src/types/nitro.ts:225-392
NitroOptions’ signature changed and reached 1 file in src/utils/. 1
src/types/nitro.ts:225-392

Diff

Type Definitionssrc/types/
src/types/nitro.ts

221–221, 299–299

Source Filessrc/
src/task.ts

1–78

Source Filessrc/
src/nitro.ts

2–2, 14–14, 110–159

Source Filessrc/
src/scan.ts

82–92

Source Filessrc/
src/imports.ts

20–21

Source Filessrc/
src/options.ts

57–57

Runtime Codesrc/runtime/
src/runtime/task.ts

1–62

Runtime Codesrc/runtime/
src/runtime/entries/nitro-dev.ts

8–14, 17–18, 52–77

Runtime Codesrc/runtime/
src/runtime/virtual/tasks.ts

1–6

Runtime Codesrc/runtime/
src/runtime/index.ts

5–5

Development Toolssrc/dev/
src/dev/server.ts

28–28, 100–100, 213–213

CLI Commandssrc/cli/
src/cli/commands/tasks/run.ts

1–46

CLI Commandssrc/cli/
src/cli/commands/tasks/list.ts

1–26

CLI Commandssrc/cli/
src/cli/commands/tasks/index.ts

1–12

CLI Commandssrc/cli/
src/cli/index.ts

15–15

Analysis scope

427 → 5
  1. 427
    files at head
  2. 12
    components
  3. 5
    changed by this change

Where the new files landed

6 new files
New fileBelongs toUsed byCallsServes
src/task.ts
Source Filesbase frame
CLI Commands
Runtime Code
src/runtime/2 new files
Runtime Codebase frame
Source Files
nothing outside its own component
src/cli/3 new filesnothing outside src/cli/commands/tasks/ imports any of it
CLI Commandsbase frame
nothing in the existing application
Source Files

2 added files carry no component — 2 test.

5components changed
3reached, not changed
0components added/removed
1dependencies added between components
0dependencies removed between components
0files moved to another path

18 files changed, 16 claims stated. 8 components reached in total.

naming: “model

narrative: “model

analyzer 0.1.0, config v1.9.0-phase8

Every line above is derived from 081aa276..476bfcc9 and nothing else.