From 52f3c344307b01d52385ed24fd5ff3bd5398af97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Jakub=20Nani=C5=A1ta?= Date: Tue, 14 Nov 2023 14:13:25 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Prepare=20for=20create-lz-oapp?= =?UTF-8?q?=20publishing=20(#12)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.prettierignore | 0 packages/create-lz-oapp/README.md | 31 +++++++++++++++++ .../{create-oapp => create-lz-oapp}/cli.cjs | 0 .../package.json | 7 ++-- .../src/components/branding.tsx | 0 .../src/components/placeholder.tsx | 0 packages/create-lz-oapp/src/index.tsx | 19 +++++++++++ .../create-lz-oapp/src/utilities/terminal.ts | 33 +++++++++++++++++++ .../tsconfig.json | 0 .../tsup.config.ts | 0 packages/create-oapp/src/index.tsx | 13 -------- packages/hardhat-utils/README.md | 2 -- packages/hardhat-utils/package.json | 1 + packages/ua-utils/README.md | 2 -- 14 files changed, 88 insertions(+), 20 deletions(-) rename packages/{create-oapp => create-lz-oapp}/.prettierignore (100%) create mode 100644 packages/create-lz-oapp/README.md rename packages/{create-oapp => create-lz-oapp}/cli.cjs (100%) rename packages/{create-oapp => create-lz-oapp}/package.json (89%) rename packages/{create-oapp => create-lz-oapp}/src/components/branding.tsx (100%) rename packages/{create-oapp => create-lz-oapp}/src/components/placeholder.tsx (100%) create mode 100644 packages/create-lz-oapp/src/index.tsx create mode 100644 packages/create-lz-oapp/src/utilities/terminal.ts rename packages/{create-oapp => create-lz-oapp}/tsconfig.json (100%) rename packages/{create-oapp => create-lz-oapp}/tsup.config.ts (100%) delete mode 100644 packages/create-oapp/src/index.tsx diff --git a/packages/create-oapp/.prettierignore b/packages/create-lz-oapp/.prettierignore similarity index 100% rename from packages/create-oapp/.prettierignore rename to packages/create-lz-oapp/.prettierignore diff --git a/packages/create-lz-oapp/README.md b/packages/create-lz-oapp/README.md new file mode 100644 index 000000000..64d4d7f22 --- /dev/null +++ b/packages/create-lz-oapp/README.md @@ -0,0 +1,31 @@ +

+ + LayerZero + +

+ +

create-lz-oapp

+ + +

+ + NPM Version + + Downloads + + NPM License +

+ +## Create LayerZero OApp Static Badge + +The easiest way to get started with LayerZero smart contract development. This CLI tool enables you to quickly start building on top of LayerZero omnichain interoperability protocol. To get started, use the following command: + +```bash +npx create-lz-oapp@latest +# or +yarn create lz-oapp +# or +pnpm create lz-oapp +# or +bunx create-lz-oapp +``` diff --git a/packages/create-oapp/cli.cjs b/packages/create-lz-oapp/cli.cjs similarity index 100% rename from packages/create-oapp/cli.cjs rename to packages/create-lz-oapp/cli.cjs diff --git a/packages/create-oapp/package.json b/packages/create-lz-oapp/package.json similarity index 89% rename from packages/create-oapp/package.json rename to packages/create-lz-oapp/package.json index 615023be0..9124cdac9 100644 --- a/packages/create-oapp/package.json +++ b/packages/create-lz-oapp/package.json @@ -1,7 +1,8 @@ { - "name": "create-oapp", + "name": "create-lz-oapp", "version": "0.0.1", "description": "Create LayerZero OApp with one command", + "license": "MIT", "type": "module", "publishConfig": { "access": "public" @@ -13,10 +14,10 @@ "repository": { "type": "git", "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", - "directory": "packages/create-oapp" + "directory": "packages/create-lz-oapp" }, "bin": { - "create-oapp": "./cli.cjs" + "create-lz-oapp": "./cli.cjs" }, "engines": { "node": ">=18" diff --git a/packages/create-oapp/src/components/branding.tsx b/packages/create-lz-oapp/src/components/branding.tsx similarity index 100% rename from packages/create-oapp/src/components/branding.tsx rename to packages/create-lz-oapp/src/components/branding.tsx diff --git a/packages/create-oapp/src/components/placeholder.tsx b/packages/create-lz-oapp/src/components/placeholder.tsx similarity index 100% rename from packages/create-oapp/src/components/placeholder.tsx rename to packages/create-lz-oapp/src/components/placeholder.tsx diff --git a/packages/create-lz-oapp/src/index.tsx b/packages/create-lz-oapp/src/index.tsx new file mode 100644 index 000000000..ed5493866 --- /dev/null +++ b/packages/create-lz-oapp/src/index.tsx @@ -0,0 +1,19 @@ +import React from "react" +import { render } from "ink" +import { Command } from "commander" +import { Placeholder } from "./components/placeholder.js" +import { altScreen } from "./utilities/terminal.js" + +new Command("create-lz-oapp") + .description("Create LayerZero OApp with one command") + .action(async () => { + const exitAltScreen = await altScreen() + + try { + const { waitUntilExit } = render() + await waitUntilExit() + } finally { + await exitAltScreen() + } + }) + .parseAsync() diff --git a/packages/create-lz-oapp/src/utilities/terminal.ts b/packages/create-lz-oapp/src/utilities/terminal.ts new file mode 100644 index 000000000..c5c42c2df --- /dev/null +++ b/packages/create-lz-oapp/src/utilities/terminal.ts @@ -0,0 +1,33 @@ +const ENTER_ALT_SCREEN_ANSI = "\x1b[?1049h" +const EXIT_ALT_SCREEN_ANSI = "\x1b[?1049l" + +/** + * Helper function that wraps socket writes with a promise + * + * @param socket `WriteStream` + * @returns `(content: string) => Promise` + */ +const createWrite = (socket: NodeJS.WriteStream) => (content: string) => { + return new Promise((resolve, reject) => { + socket.write(content, (error) => { + if (error != null) reject(error) + else resolve() + }) + }) +} + +/** + * Starts an alt screen and returns a callback that exits back to the default screen. + * This makes the app "full screen" + * + * See https://github.com/vadimdemedes/ink/issues/263 for more info + * + * @returns `Promise<() => void>` + */ +export const altScreen = async () => { + const write = createWrite(process.stdout) + + await write(ENTER_ALT_SCREEN_ANSI) + + return () => write(EXIT_ALT_SCREEN_ANSI) +} diff --git a/packages/create-oapp/tsconfig.json b/packages/create-lz-oapp/tsconfig.json similarity index 100% rename from packages/create-oapp/tsconfig.json rename to packages/create-lz-oapp/tsconfig.json diff --git a/packages/create-oapp/tsup.config.ts b/packages/create-lz-oapp/tsup.config.ts similarity index 100% rename from packages/create-oapp/tsup.config.ts rename to packages/create-lz-oapp/tsup.config.ts diff --git a/packages/create-oapp/src/index.tsx b/packages/create-oapp/src/index.tsx deleted file mode 100644 index 2315f37a4..000000000 --- a/packages/create-oapp/src/index.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from "react" -import { render } from "ink" -import { Command } from "commander" -import { Placeholder } from "./components/placeholder.js" - -new Command("create-oapp") - .description("Create LayerZero OApp with one command") - .action(async () => { - const { waitUntilExit } = render() - - await waitUntilExit() - }) - .parseAsync() diff --git a/packages/hardhat-utils/README.md b/packages/hardhat-utils/README.md index 8e9871eeb..dea8a59d6 100644 --- a/packages/hardhat-utils/README.md +++ b/packages/hardhat-utils/README.md @@ -12,8 +12,6 @@ NPM Version Downloads - - Snyk Vulnerabilities for npm package version NPM License

diff --git a/packages/hardhat-utils/package.json b/packages/hardhat-utils/package.json index 0e2d3982c..cdc381ef9 100644 --- a/packages/hardhat-utils/package.json +++ b/packages/hardhat-utils/package.json @@ -2,6 +2,7 @@ "name": "@layerzerolabs/hardhat-utils", "description": "Hardhat helpers for LayerZero EVM projects", "version": "0.0.1", + "license": "MIT", "private": true, "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/ua-utils/README.md b/packages/ua-utils/README.md index f05651554..ddec62c1e 100644 --- a/packages/ua-utils/README.md +++ b/packages/ua-utils/README.md @@ -12,8 +12,6 @@ NPM Version Downloads - - Snyk Vulnerabilities for repository NPM License