davsclaus opened a new pull request, #29813: URL: https://github.com/apache/camel/pull/29813
## Summary Second item of [CAMEL-26912](https://issues.apache.org/jira/browse/CAMEL-26912): **`camel export --dir=<dir>` to a directory other than the current one deleted whatever files that directory had, without asking.** Only `--clean-dir` asked for confirmation. Cleaning the export directory is deliberate (CAMEL-21104: "always clean export-dir to avoid stale data"), and re-exporting to the same directory relies on it. So instead of dropping it, the export now only cleans a directory that an earlier export created: - An export to a directory other than the current one writes a hidden `.camel-export` file in it. Its text says what it is for. - A later export to a directory with that file replaces it as before, so no stale files of the earlier export are left. - An empty or missing directory, one with only hidden files (such as a clone with only `.git`), and the current directory are exported to as before. - Any other directory with files: the export stops before it boots the integration, and keeps the files. ``` ERROR: Cannot export to /home/me/project because it has files that camel export did not create: use --clean-dir to delete them, or export to another directory ``` `--clean-dir` (with confirmation, or `--yes`) works as before. The three exporters (Camel Main, Spring Boot, Quarkus) had the same cleaning block; it is now in `Exporter` (`canExportTo`, `cleanExportDir`, `markExportDir`). ### Behaviour change (upgrade guide) - A directory that an earlier Camel version exported to has no marker yet: export to it once with `--clean-dir --yes`. - Exporting to the directory of the exported files from another directory (`camel export /work/route.camel.yaml --dir=/work`) deleted the source files. It now needs `--clean-dir --yes`; `DependencyUpdateTest` does exactly that after `camel init`, so it gets those options. The `--clean-dir` help text is not changed, which would regenerate nine files; the export page of the docs describes the marker. ### With the launcher The unpacked launcher with the new camel-jbang-run jar: 1. export to a new `../proj`: written, with `.camel-export` 2. export another route to `../proj`: only the new route is left 3. export to `../mine` with `TODO.txt` and `docs/notes.txt`: exit 1 with the message above, both kept 4. the same with `--clean-dir --yes`: exported ## Tests - `ProjectExporterTest`: replaces the directory of an earlier export; keeps the files of a directory that no export created (nothing is resolved), then exports with `--clean-dir`; exports to a directory with only hidden files. - The golden files list `.camel-export` among the exported files (23 files, one line each). - camel-jbang-run, camel-jbang-core (including `RunExportGoldenTest`) and camel-jbang-plugin-kubernetes (156 tests) pass locally. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
