-
Notifications
You must be signed in to change notification settings - Fork 77
feat: export cli internals for programmatic usage #853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 3b7b35b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
How come you need to call the command programmatically via importing instead of using something like exec? Is there a benefit that is gained with that? I'm thinking from the POV of those imports are not going to be considered stable and would be subject to breaking changes without notice, whereas running the CLI commands with the CLI will not be subject to breaking changes unless we release a major version. |
|
@james-elicx Fair point! For context, I was fighting some of the commands that expect certain configuration files to be present inside the user's Next.js project (example). We were hoping to obfuscate those configuration files behind a CLI we're building on top of This PR allowed us to skip the It would be awesome if these types of build configs could be passed as objects to the underlying Node API's as an alternative to configuration files present in the project files. I'm still getting familiar with this repository so maybe that's more complicated than I'm anticipating. To your point, I think we can go ahead and close this PR, but we're super interested in finding out if there's an appetite for passing configurations as objects. We'd be open to helping out with that, if the team is open to the overall direction! |
Would it help if you were able to pass a custom path for the open next config instead, and you could then reference one in your own build dir? We support that with the Wrangler config, so I don't see why we shouldn't with the OpenNext config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review 🙇
Looks good to me, although as I commented maybe we should stick with /api for now 🤔
Also the Cloudflare open-next docs should be updated to use these new endpoint, would you have some extra cycles to do it? or if not I can give it a go please let me know 🙂
(Oh I see you thought of keeping this undocumented for now? 🤔, ok that could be ok too I guess 🤔)
| "types": "./dist/api/*.d.ts", | ||
| "default": "./dist/api/*.js" | ||
| }, | ||
| "./lib/*": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I suggested lib but by looking at the PR it looks to me like we might as well stick with api since that's already used 🙂
|
Oh, I just noticed the previous conversation in the PR 😓 I agree with @james-elicx that exporting I feel like this is however not fully in line with the team's preference? I'd be keen to hear what @james-elicx , @conico974 and @vicb think. |
|
We cannot make this work unfortunately, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewvolk what's the status on your side here?
I read the comments and agree that exporting i.e. api/*.js is probably not a good idea.
Depending on what your need are, we could export a few functions with documented/stable APIs. Maybe that can be discussed in a separate issue and we can close this PR for now?
I ran into this issue ultimately, and agree that James's solution is probably the best for now. We've actually even been able to work around this for now by writing the I think best path forward for this PR is to close it, and I can either open an issue or a different PR helping push the "custom config path" solution forward 😄 Thank you all a bunch for your help 🙏 |
I'll look at making the necessary changes for it this week. |
This PR adds two more entry points to the
@opennextjs/cloudflare package:"./cli/*""./lib/*""./cli/*"is intended to be an entry point used by developers who are looking to use theopennextjs-cloudflareCLI programmatically, which is a use case especially relevant for using@opennextjs/cloudflarewith Workers for Platforms."./lib/*"is an entry point that intentionally duplicates the existing catch-all ("./*") entry point; undocumented for now, but in the future can be used to more explicitly differentiate between exports intended for the Next.js app being deployed to Cloudflare, vs. exports related to programmatic usage of the CLI.