Skip to content

feat(cli): add --dry-run flag to generate sdl command #1571

@lisa-assistant

Description

@lisa-assistant

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:

  1. Run through all the SDL and service file generation logic as normal
  2. Print the files that would be created/modified (with their paths and optionally their contents)
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions