Skip to content

Commit

Permalink
PR feedback cleanup and basic bats test for build-lz-options version cli
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Goulding <goulding@layerzerolabs.org>
  • Loading branch information
ryandgoulding committed Jan 26, 2024
1 parent e5d2583 commit 3d0a667
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion packages/build-lz-options/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "build-lz-options",
"version": "0.0.1",
"private": true,
"description": "Build LayerZero options with one command",
"keywords": [
"LayerZero",
Expand Down
2 changes: 1 addition & 1 deletion packages/build-lz-options/src/components/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface OptionType1Props {
props: OptionType1Summary;
}

interface OptionType2Props extends OptionType1Props {
interface OptionType2Props {
props: OptionType2Summary;
}

Expand Down
1 change: 0 additions & 1 deletion packages/build-lz-options/src/components/outputOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ interface OptionOutputProps {
/**
* Render the options output to the user.
* @param {OptionOutputProps} props
* @constructor
*/
export const OutputOptions: React.FC<OptionOutputProps> = ({
props,
Expand Down
2 changes: 2 additions & 0 deletions packages/build-lz-options/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import {
} from "@/components/config";
import { OutputOptions } from "@/components/outputOptions";
import { printLogo } from "@layerzerolabs/io-devtools/swag";
import { version } from "../package.json";

new Command("build-lz-options")
.description("Create LayerZero OApp options with one command")
.version(version)
.action(async () => {
printLogo();

Expand Down
24 changes: 8 additions & 16 deletions packages/build-lz-options/src/utilities/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,17 @@ const promptExecutorComposeOption = async (options: Options): Promise<Options> =
const promptForExecutorOption = async (options: Options): Promise<Options> => {
const executorOptionType = await promptForExecutorOptionType()
switch (executorOptionType.type?.id) {
case ExecutorOptionType.LZ_RECEIVE: {
case ExecutorOptionType.LZ_RECEIVE:
return promptExecutorLzReceiveOption(options)
}
case ExecutorOptionType.NATIVE_DROP: {
case ExecutorOptionType.NATIVE_DROP:
return await promptExecutorNativeDropOption(options)
}
case ExecutorOptionType.COMPOSE: {
case ExecutorOptionType.COMPOSE:
return await promptExecutorComposeOption(options)
}
case ExecutorOptionType.ORDERED: {
case ExecutorOptionType.ORDERED:
return options.addExecutorOrderedExecutionOption()
}
default: {
default:
// unreachable in normal operations
throw new Error(`Unsupported executor option type: ${executorOptionType.type?.id}`)
}
}
}

Expand All @@ -181,16 +176,13 @@ export const promptForOptionType2 = (): Promise<OptionType2Summary> =>
const determineWorkerType = async (options: Options): Promise<Options> => {
const workerType = await promptForWorkerType()
switch (workerType.type?.id) {
case WorkerId.EXECUTOR: {
case WorkerId.EXECUTOR:
return promptForExecutorOption(options)
}
case WorkerId.VERIFIER: {
case WorkerId.VERIFIER:
return promptVerifierPrecrimeOption(options)
}
default: {
default:
// unreachable in normal operations
throw new Error(`Unsupported worker type: ${workerType.type?.id}`)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/build-lz-options/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"declaration": false,
"jsx": "react",
"lib": ["dom", "dom.Iterable", "es2022"],
"resolveJsonModule": false,
"resolveJsonModule": true,
"types": ["node"],
"paths": {
"@/*": ["./src/*"],
Expand Down
5 changes: 5 additions & 0 deletions tests-user/tests/build-lz-options.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


@test "should output version" {
npx --yes build-lz-options --version
}

0 comments on commit 3d0a667

Please sign in to comment.