Skip to content

docs/feat: clarify clean behavior and support generated-only cleanup #3538

@aqeelat

Description

@aqeelat

Problem

Orval's current output.clean behavior can be surprising when users generate into prepared package folders.

Observed behavior:

  • Default behavior: Orval merges into target/schema folders and preserves unrelated files.
  • Stale generated files may remain if tag filters shrink or generated paths change.
  • With output.clean: true, Orval removes files in configured target/schema folders, including sentinel/package files.

This is risky when target or schemas points at a package entrypoint root containing files such as:

ng-package.json
package.json
public-api.ts

Documentation suggestion

Document clearly that users should not point target or schemas directly at a package entrypoint root if that root contains prepared files that should not be deleted.

The docs should explain that output.clean: true cleans the configured output folders, not only files generated by Orval.

Potential API improvement

Support generated-only cleanup:

output: {
  clean: {
    generatedOnly: true,
  },
}

Alternative approach:

  • Generate a manifest file containing files emitted by the previous run.
  • On the next run, clean only files listed in the previous manifest.
  • Write a new manifest after generation.

Expected behavior

With generated-only cleanup enabled:

  • Stale generated files from previous Orval runs are removed.
  • Non-generated files such as package.json, ng-package.json, and public-api.ts are preserved.
  • Users can safely generate into package-oriented folders without risking sentinel files.

Why this helps

  • Avoids accidental deletion of package metadata.
  • Reduces stale generated files when filters or tags change.
  • Makes Orval safer for monorepos and package secondary entrypoints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    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