create-push-universal-app
Version:
CLI tool to scaffold Push Chain universal applications with Next.js or Vite
172 lines (129 loc) ⢠3.87 kB
Markdown
# Create Push App
A CLI tool to scaffold Push Chain applications with your choice of framework and tooling.
## Quick Start
```bash
npm install -g create-push-app
create-push-app my-app
```
Or use npx:
```bash
npx create-push-app my-app
```
## Features
- ā” **Multiple Frameworks**: Choose between Next.js or Vite (React)
- šØ **UI Components**: Optional shadcn/ui integration
- š§ **ESLint**: Optional code linting setup
- š¦ **Push Chain Integration**: Pre-configured with @pushchain/core and @pushchain/ui-kit
- š **TypeScript**: Full TypeScript support out of the box
## Usage
### Interactive Mode
Run the CLI without arguments to enter interactive mode:
```bash
create-push-app
```
You'll be prompted to:
1. Choose your project name
2. Select a framework (Next.js or Vite)
3. Enable/disable ESLint
4. Enable/disable shadcn/ui
### Command Line Options
```bash
create-push-app my-app --framework nextjs --eslint --shadcn
```
Available options:
- `-f, --framework <framework>`: Choose 'nextjs' or 'vite'
- `--eslint / --no-eslint`: Include/exclude ESLint configuration
- `--shadcn / --no-shadcn`: Include/exclude shadcn/ui components
## Generated Project Structure
### Next.js Project
```
my-app/
āāā src/
ā āāā app/
ā ā āāā globals.css
ā ā āāā layout.tsx
ā ā āāā page.tsx
ā āāā components/
ā ā āāā ui/ # shadcn components (if enabled)
ā ā āāā push-chain-demo.tsx
ā āāā lib/
ā āāā pushchain.tsx # Push Chain provider
ā āāā utils.ts # Utility functions
āāā package.json
āāā next.config.js
āāā tsconfig.json
āāā tailwind.config.js # (if shadcn enabled)
```
### Vite Project
```
my-app/
āāā src/
ā āāā components/
ā ā āāā ui/ # shadcn components (if enabled)
ā ā āāā push-chain-demo.tsx
ā āāā lib/
ā ā āāā pushchain.tsx # Push Chain provider
ā ā āāā utils.ts # Utility functions
ā āāā App.tsx
ā āāā main.tsx
ā āāā index.css
āāā index.html
āāā package.json
āāā vite.config.ts
āāā tsconfig.json
āāā tailwind.config.js # (if shadcn enabled)
```
## Push Chain Integration
The generated project includes:
### 1. PushChain Provider
A React context provider that manages the Push Chain connection:
```typescript
import { usePushChain } from '@/lib/pushchain'
function MyComponent() {
const { pushChain, isConnected, connect, disconnect, error } = usePushChain()
// Use Push Chain methods here
}
```
### 2. Demo Component
A working example showing how to:
- Connect to Push Chain
- Send messages
- Handle errors
- Display connection status
### 3. Environment Variables
Configure your Push Chain settings:
```env
# Next.js
NEXT_PUBLIC_PUSHCHAIN_API_KEY=your_api_key_here
NEXT_PUBLIC_PUSHCHAIN_NETWORK=testnet
# Vite
VITE_PUSHCHAIN_API_KEY=your_api_key_here
VITE_PUSHCHAIN_NETWORK=testnet
```
## Development
To work on this CLI tool:
```bash
git clone <repository>
cd create-push-app
npm install
npm run build
npm link
```
Then you can test it:
```bash
create-push-app test-app
```
## Scripts
- `npm run build` - Build the CLI
- `npm run dev` - Run in development mode
- `npm start` - Run the built CLI
## Next Steps
After creating your project:
1. **Configure Environment Variables**: Set up your Push Chain API keys
2. **Customize the Integration**: Replace example code with your specific Push Chain functionality
3. **Add Features**: Build upon the generated structure
4. **Explore Push Chain**: Check out the @pushchain/ui-kit for additional components
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
MIT