Merged
Conversation
9ab7b86 to
8ddac06
Compare
This is probably still not ideal, but at least its broken up into smaller files.
Fixed it by moving the base command into its own file and moving everything out of the CLI file so that now there is only the execution call in there. fixes #11: CLI not executing on windows
The previous version searched for it in main cli file which now just executes the program.
26d8c53 to
314c97c
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the CLI code structure to fix Windows execution issues. The main problem was a guard check in src/cli.ts that compared import.meta.url with process.argv[1], which failed on Windows due to path format differences (backslashes vs forward slashes, drive letter format). The solution moves all CLI logic into separate command files and makes src/cli.ts a pure entry point that only imports and executes, removing the problematic guard entirely.
Changes:
- Removed Windows-incompatible execution guard from
src/cli.tsand simplified it to a pure entry point - Refactored CLI code into modular command structure with separate files for compile, serve, and enumerate commands
- Extracted shared utilities, middleware functions, and constants into separate files
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/cli.ts | Simplified to only import and execute CLI, removing the Windows-incompatible guard check |
| src/commands/base.ts | New file containing the main CLI argument parser and command setup |
| src/commands/compile.ts | Extracted compile command with flags and callback |
| src/commands/serve.ts | Extracted serve command with flags and callback |
| src/commands/enumerate.ts | Extracted enumerate command with flags and callback |
| src/utils.ts | Extracted utility functions (getStringOrLast, wrapZodForCleanerError, onFail) |
| src/middleware.ts | Extracted middleware functions for logging, color, and plugin loading |
| src/const.ts | Extracted package constants and epilogue text |
| lib/core/compiler/index.ts | Removed output field from CompileArgs interface (now handled by CLI layer) |
| test/src/commands/base.test.ts | Updated import path from #src/cli to #src/commands/base |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CI pipeline was failing, and copilot made some suggestions on my grammar, and variable naming which were fair points.
The program was allowed to continue executing even after a write error, which means that the program could exit with a 0 exit code, even though it did not finish execution as expected.
The compile subcommand would log the input file as the problem when an error happend instead of the output file. Which is wrong. This commit fixes that.
This was obviously because of a copy paste from the serve command that I forgot to change aferwards.
e06d340 to
97dec75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11: CLI not executing on windows
This has something to do with the guard at the bottom that sees if it is being sourced or executed, but it has flaws. This patch should fix that by moving everything into another file. Now the main CLI file only has the call to execute, no guard checks, no nothing. So don't import it.
Checklist
!if they were breaking changes.docs/when needed.test/for all new code.Meta data
Built on platform (select all applicable):
Add a 👍 reaction to pull requests you find important.