Skip to content

Conversation

@dario-piotrowicz
Copy link
Contributor

@dario-piotrowicz dario-piotrowicz commented Jan 26, 2026

This PR improves the opennextjs-cloudflare CLI by:

  • ensuring that unknown commands (e.g., opennextjs-cloudflare foo) display a clear and helpful error message
  • adding a -h|--help flag to display the CLI's help message
  • adding a -v|--version flag to display the package's version

@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2026

🦋 Changeset detected

Latest commit: f571523

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 26, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@1097

commit: f571523

@dario-piotrowicz dario-piotrowicz requested a review from vicb January 27, 2026 11:11
Co-authored-by: James Anderson <james@eli.cx>
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dario 🙏
LGTM with one suggestion

@dario-piotrowicz
Copy link
Contributor Author

oof... I guess I need to also instruct yargs to ignore the flags we forward to wrangler 😓
https://github.com/opennextjs/opennextjs-cloudflare/actions/runs/21395938691/job/61594141196?pr=1097#step:6:31

@james-elicx
Copy link
Collaborator

oof... I guess I need to also instruct yargs to ignore the flags we forward to wrangler 😓 opennextjs/opennextjs-cloudflare/actions/runs/21395938691/job/61594141196?pr=1097#step:6:31

I guess that's a result of where .strictCommands() is used perhaps?

@dario-piotrowicz
Copy link
Contributor Author

dario-piotrowicz commented Jan 28, 2026

I guess that's a result of where .strictCommands() is used perhaps?

No, I think that only checks commands and that's not the issue here 🤔

maybe...? but without it passing wrong stuff to the opennext CLI doesn't trigger the error message 😓

Co-authored-by: Victor Berchet <victor@suumit.com>
@dario-piotrowicz dario-piotrowicz marked this pull request as draft January 28, 2026 11:41
@james-elicx
Copy link
Collaborator

james-elicx commented Jan 28, 2026

Just pushed a change that should get the args working properly.

There's a couple things at play now:

  • we're asking yargs to treat unknown options as args instead of failing, and so yargs was treating them like positionals.
  • there's a syntax for "variadic positional arguments" that we weren't using that would turns the unrecognised flags into args.
  • since we're still stripping out the -- separator, all unrecognised flags that are treated as positionals should now get parsed into an args array.

You can see the args ending up in the expected properties in the below screenshot:

image

@james-elicx
Copy link
Collaborator

james-elicx commented Jan 28, 2026

Hmm I guess I broke something else with the e2es 😅 Should be working now.

@dario-piotrowicz
Copy link
Contributor Author

Thanks for the fix @james-elicx 🙂

With your fix I think that things are a bit un-ideal since any flag passed to a command won't trigger any error/warning, however I don't think we can reasonably do much better given how the CLI accepts arguments

Looks good to me 🙂👍

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review January 29, 2026 10:16
@dario-piotrowicz dario-piotrowicz requested a review from vicb January 29, 2026 10:16
@vicb
Copy link
Contributor

vicb commented Jan 29, 2026

@dario-piotrowicz

image

I won't at time to look at this before at least tomorrow.
Feel free to merge unless you think I really need to look at this.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants