Background
There is a TODO comment in packages/cli/src/commands/generate/sdl/sdlHandler.js at line 243:
// TODO: Add --dry-run command
export const handler = async ({
model,
crud,
force,
tests,
typescript,
docs,
rollback,
}) => {
What needs to be done
Add a --dry-run (or --dryRun) option to the generate sdl command. When passed, the command should:
- Run through all the SDL and service file generation logic as normal
- Print the files that would be created/modified (with their paths and optionally their contents)
- Exit without writing anything to disk
This pattern already exists in the codebase — packages/cli/src/commands/upgrade/upgradeHandler.ts implements dryRun by passing the flag down and using skip: () => !!dryRun on tasks that write to disk.
Why
The SDL generator creates multiple files (SDL schema, service, tests). A --dry-run flag lets developers preview exactly what would be generated before committing, which is especially useful when exploring a new model or when they're unsure about the --crud flag.
Files to change
packages/cli/src/commands/generate/sdl/sdl.js — add the yargs option definition (.option('dry-run', { type: 'boolean', default: false, description: 'Print files without writing them' }))
packages/cli/src/commands/generate/sdl/sdlHandler.js — accept dryRun in the handler signature; pass it to writeFilesTask or skip that Listr task when dryRun is true
References
packages/cli/src/commands/upgrade/upgradeHandler.ts — existing --dry-run implementation pattern
packages/cli/src/lib/index.js writeFilesTask — the file-writing step to conditionally skip
Background
There is a
TODOcomment inpackages/cli/src/commands/generate/sdl/sdlHandler.jsat line 243:What needs to be done
Add a
--dry-run(or--dryRun) option to thegenerate sdlcommand. When passed, the command should:This pattern already exists in the codebase —
packages/cli/src/commands/upgrade/upgradeHandler.tsimplementsdryRunby passing the flag down and usingskip: () => !!dryRunon tasks that write to disk.Why
The SDL generator creates multiple files (SDL schema, service, tests). A
--dry-runflag lets developers preview exactly what would be generated before committing, which is especially useful when exploring a new model or when they're unsure about the--crudflag.Files to change
packages/cli/src/commands/generate/sdl/sdl.js— add the yargs option definition (.option('dry-run', { type: 'boolean', default: false, description: 'Print files without writing them' }))packages/cli/src/commands/generate/sdl/sdlHandler.js— acceptdryRunin the handler signature; pass it towriteFilesTaskor skip that Listr task whendryRunis trueReferences
packages/cli/src/commands/upgrade/upgradeHandler.ts— existing--dry-runimplementation patternpackages/cli/src/lib/index.jswriteFilesTask— the file-writing step to conditionally skip