Skip to content

Resolve configuration file against the current working directory#146

Merged
marcospassos merged 1 commit into
masterfrom
fix-configuration-file-resolution
Jul 16, 2026
Merged

Resolve configuration file against the current working directory#146
marcospassos merged 1 commit into
masterfrom
fix-configuration-file-resolution

Conversation

@marcospassos

Copy link
Copy Markdown
Member

Summary

Running a template that scaffolds a project and changes into it (e.g. croct use croct://integration/sanity in an empty folder) created croct.json in the folder the CLI was launched from instead of the project folder.

The cause: JsonConfigurationFileManager received the configuration file as an absolute path pre-joined with the working directory at instantiation time. Since the manager is a memoized singleton wired at startup, the path was frozen at the invocation directory — while the template's change-directory action only mutates the shared VirtualizedWorkingDirectory, which the manager never consulted again. Notably, the manager already declared a projectDirectory dependency that was never used.

The fix:

  • JsonConfigurationFileManager now resolves the configuration file per operation: absolute paths are used as-is, relative ones are joined with projectDirectory.get() at call time.
  • The CLI wiring passes the configured file name (default croct.json) through instead of pre-joining it.

Test plan

  • New regression tests: reads and writes follow the current project directory; absolute path overrides stay pinned
  • Full suite passes (37 suites, 614 tests) and typecheck/lint clean
  • Verified with the built CLI in a temp directory: a template using change-directory now loads croct.json from the target folder; before the fix the same run failed to find the configuration and fell into the init flow at the launch directory

🤖 Generated with Claude Code

The croct.json path was joined with the working directory once, when
the configuration manager was instantiated at CLI startup. Templates
that scaffold a project and change into it (e.g. change-directory)
ended up reading and writing croct.json in the folder the CLI was
launched from instead of the project folder.

The manager now resolves the configuration file against the live
project directory on each operation, keeping absolute path overrides
untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

👋 @marcospassos
Thanks for your contribution!
The approval and merge process is almost fully automated 🧙
Here's how it works:

  1. You open a new pull request
  2. Automated tests check the code
  3. Maintainers review the code
  4. Once approved, the PR is ready to merge.

👉 Omit the extended description
Please remove the commit body before merging the pull request.
Instead, include the pull request number in the title to provide the full context
about the change.

☝️ Lastly, the title for the commit will come from the pull request title. So please provide a descriptive title that summarizes the changes in 50 characters or less using the imperative mood.
Happy coding! 🎉

@marcospassos marcospassos added the bug Something isn't working label Jul 16, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/croct@146

commit: dc3aa28

@marcospassos
marcospassos merged commit 5ebacd3 into master Jul 16, 2026
8 of 9 checks passed
@marcospassos
marcospassos deleted the fix-configuration-file-resolution branch July 16, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant