-
Notifications
You must be signed in to change notification settings - Fork 67
refactor: use yargs for the cli #791
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
21f01ae
refactor: use yargs for the cli
james-elicx dd5ffd6
fix e2e environment passing now that `--env` is a proper first class …
james-elicx bd6e314
remove accidental aliases
james-elicx 1da65f2
passthrough -> wranglerArgs
james-elicx b2795b5
jsdoc comments
james-elicx df1cf00
move adding commands to their own files
james-elicx c7b998a
remove args.ts file
james-elicx 8c1e059
bump eslint due to typescript-eslint/issues/10353
james-elicx 0776a97
config -> configPath
james-elicx b7354bb
improve jsdoc and consolidate to single steup cli func
james-elicx 0c7ad47
add an extra jsdoc
james-elicx 871f1ba
updates
vicb c4c33a0
refactor
vicb 69a09a7
misc updates
vicb 02ac82e
filter out '--'
james-elicx 380aa23
break up the setupCli functions
james-elicx 55b2e64
setup-cli.ts -> utils.ts
james-elicx d02a59e
lint
james-elicx 50dd17e
Update packages/cloudflare/src/cli/commands/utils.ts
james-elicx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@opennextjs/cloudflare": minor | ||
--- | ||
|
||
refactor: use yargs for the cli |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import type yargs from "yargs"; | ||
|
||
import { build as buildImpl } from "../build/build.js"; | ||
import type { WithWranglerArgs } from "./utils.js"; | ||
import { | ||
compileConfig, | ||
getNormalizedOptions, | ||
nextAppDir, | ||
printHeaders, | ||
readWranglerConfig, | ||
withWranglerOptions, | ||
withWranglerPassthroughArgs, | ||
} from "./utils.js"; | ||
|
||
/** | ||
* Implementation of the `opennextjs-cloudflare build` command. | ||
* | ||
* @param args | ||
*/ | ||
async function buildCommand( | ||
args: WithWranglerArgs<{ | ||
skipNextBuild: boolean; | ||
noMinify: boolean; | ||
skipWranglerConfigCheck: boolean; | ||
}> | ||
): Promise<void> { | ||
printHeaders("build"); | ||
|
||
const { config, buildDir } = await compileConfig(); | ||
const options = getNormalizedOptions(config, buildDir); | ||
|
||
const wranglerConfig = readWranglerConfig(args); | ||
|
||
await buildImpl( | ||
options, | ||
config, | ||
{ ...args, minify: !args.noMinify, sourceDir: nextAppDir }, | ||
wranglerConfig | ||
); | ||
} | ||
|
||
/** | ||
* Add the `build` command to yargs configuration. | ||
* | ||
* Consumes 1 positional parameter. | ||
*/ | ||
export function addBuildCommand<T extends yargs.Argv>(y: T) { | ||
return y.command( | ||
"build", | ||
"Build an OpenNext Cloudflare worker", | ||
(c) => | ||
withWranglerOptions(c) | ||
.option("skipNextBuild", { | ||
type: "boolean", | ||
alias: ["skipBuild", "s"], | ||
default: ["1", "true", "yes"].includes(String(process.env.SKIP_NEXT_APP_BUILD)), | ||
desc: "Skip building the Next.js app", | ||
}) | ||
.option("noMinify", { | ||
type: "boolean", | ||
default: false, | ||
desc: "Disable worker minification", | ||
}) | ||
.option("skipWranglerConfigCheck", { | ||
type: "boolean", | ||
default: ["1", "true", "yes"].includes(String(process.env.SKIP_WRANGLER_CONFIG_CHECK)), | ||
desc: "Skip checking for a Wrangler config", | ||
}), | ||
(args) => buildCommand(withWranglerPassthroughArgs(args)) | ||
); | ||
} |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.