diff --git a/package.json b/package.json index 0afbf1b6e..fc5a5c418 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "packages/coinbase-ethers", "packages/ethers5", "packages/ethers", + "packages/cli", "apps/*" ], "scripts": { diff --git a/packages/cli/.npmignore b/packages/cli/.npmignore new file mode 100644 index 000000000..e203f76ad --- /dev/null +++ b/packages/cli/.npmignore @@ -0,0 +1,10 @@ +*.log +*.env +npm-debug.log* +node_modules +package-lock.json +src +tests +index.ts +.eslintrc.json +.turbo diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md new file mode 100644 index 000000000..9b59a41fe --- /dev/null +++ b/packages/cli/CHANGELOG.md @@ -0,0 +1,7 @@ +# @reown/appkit-react-native-cli + +## 1.3.0 + +### Minor Changes + +- [#414](https://github.com/reown-com/appkit-react-native/pull/414) [`c88fa8c`](https://github.com/reown-com/appkit-react-native/commit/c88fa8c29d0dcb7cc99392534b62bcb11b41e2cb) Thanks [@ignaciosantise](https://github.com/ignaciosantise)! - feat: added appkit cli for react native diff --git a/packages/cli/bob.config.js b/packages/cli/bob.config.js new file mode 100644 index 000000000..b7ca0ad66 --- /dev/null +++ b/packages/cli/bob.config.js @@ -0,0 +1,14 @@ +module.exports = { + source: 'src', + output: 'lib', + targets: [ + 'commonjs', + 'module', + [ + 'typescript', + { + tsc: '../../node_modules/.bin/tsc' + } + ] + ] +}; diff --git a/packages/cli/package.json b/packages/cli/package.json new file mode 100644 index 000000000..0cfbcf677 --- /dev/null +++ b/packages/cli/package.json @@ -0,0 +1,52 @@ +{ + "name": "@reown/appkit-react-native-cli", + "version": "1.3.0", + "sideEffects": false, + "description": "Reown AppKit CLI for React Native", + "main": "lib/commonjs/index.js", + "types": "lib/typescript/index.d.ts", + "module": "lib/module/index.js", + "bin": { + "appkit-react-native": "lib/commonjs/index.js" + }, + "repository": "https://github.com/reown-com/appkit-react-native", + "author": "Reown (https://discord.gg/reown)", + "homepage": "https://reown.com/appkit", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/reown-com/appkit-react-native/issues" + }, + "scripts": { + "build": "bob build", + "clean": "rm -rf lib", + "lint": "eslint . --ext .js,.jsx,.ts,.tsx" + }, + "files": [ + "src", + "lib", + "!**/__tests__", + "!**/__fixtures__", + "!**/__mocks__" + ], + "dependencies": { + "chalk": "5.4.1" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "access": "public" + }, + "eslintIgnore": [ + "node_modules/", + "lib/" + ], + "keywords": [ + "appkit", + "wallet", + "onboarding", + "reown", + "dapps", + "web3", + "wagmi", + "ethereum" + ] +} diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts new file mode 100644 index 000000000..53c786e22 --- /dev/null +++ b/packages/cli/src/index.ts @@ -0,0 +1,56 @@ +#!/usr/bin/env node +import chalk from 'chalk'; +import { spawn } from 'child_process'; + +import { banner } from './utils'; + +// Define styles +const redTip = chalk.hex('#C70039'); // Red for tips + +// Display CLI Banner +// eslint-disable-next-line no-console +console.log(banner); + +const TEMPLATE_URL = + 'https://github.com/reown-com/react-native-examples/tree/main/dapps/appkit-expo-wagmi'; + +function runExpoCreate() { + return new Promise((resolve, reject) => { + const child = spawn('npx', ['create-expo', '--template', TEMPLATE_URL], { + stdio: 'inherit', + shell: process.platform === 'win32' + }); + + child.on('error', reject); + child.on('close', code => { + if (code === 0) { + resolve(); + } else { + reject(new Error(`create-expo exited with code ${code}`)); + } + }); + }); +} + +export async function main() { + try { + await runExpoCreate(); + } catch (error: any) { + // eslint-disable-next-line no-console + console.error('Failed to run Expo initializer:', error?.message || error); + process.exitCode = 1; + + return; + } + + const url = 'https://dashboard.reown.com'; + // eslint-disable-next-line no-console + console.log(`Your ${redTip('Project Id')} will work only on the Expo Go environment`); + // eslint-disable-next-line no-console + console.log(` +Go to: ${url} +To create a personal ProjectId +`); +} + +main(); diff --git a/packages/cli/src/utils.ts b/packages/cli/src/utils.ts new file mode 100644 index 000000000..6c9cfc74e --- /dev/null +++ b/packages/cli/src/utils.ts @@ -0,0 +1,17 @@ +export const banner = ` + @@@@@@@ @@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@ + @@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@ + @@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@ Reown AppKit React Native CLI + @@@@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@ The easiest way to build dApps! + @@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@ + @@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@ @@@@@@@@@@@@@@@@@@ +`; diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json new file mode 100644 index 000000000..02d8b10ac --- /dev/null +++ b/packages/cli/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src"], + "exclude": ["lib", "node_modules"] +} diff --git a/yarn.lock b/yarn.lock index 4d00fd732..b7cb41ac2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7326,6 +7326,16 @@ __metadata: languageName: node linkType: hard +"@reown/appkit-react-native-cli@workspace:packages/cli": + version: 0.0.0-use.local + resolution: "@reown/appkit-react-native-cli@workspace:packages/cli" + dependencies: + chalk: "npm:5.4.1" + bin: + appkit-react-native: lib/commonjs/index.js + languageName: unknown + linkType: soft + "@reown/appkit-scaffold-react-native@npm:1.3.0, @reown/appkit-scaffold-react-native@workspace:packages/scaffold": version: 0.0.0-use.local resolution: "@reown/appkit-scaffold-react-native@workspace:packages/scaffold" @@ -11549,6 +11559,13 @@ __metadata: languageName: node linkType: hard +"chalk@npm:5.4.1": + version: 5.4.1 + resolution: "chalk@npm:5.4.1" + checksum: b23e88132c702f4855ca6d25cb5538b1114343e41472d5263ee8a37cccfccd9c4216d111e1097c6a27830407a1dc81fecdf2a56f2c63033d4dbbd88c10b0dcef + languageName: node + linkType: hard + "chalk@npm:^2.0.1, chalk@npm:^2.4.2": version: 2.4.2 resolution: "chalk@npm:2.4.2"