init command

Create a new AO-powered application with ao-forge.

Syntax

ao-forge init <project-name> [options]

Arguments

  • <project-name> - The name of your project (required)

Options

OptionDescriptionDefault
--framework <framework>Framework to use (nextjs, nuxtjs)Interactive prompt
--package-manager <manager>Package manager (npm, pnpm, yarn)pnpm
--template <template>Template to usedefault
--path <path>Path to create projectCurrent directory
--skip-installSkip package installationfalse
--forceOverwrite existing filesfalse
--helpShow help information-

Examples

Basic Usage

# Create a new project
ao-forge init my-app

# Specify framework
ao-forge init my-app --framework nextjs
ao-forge init my-app --framework nuxtjs

Advanced Usage

# Use specific package manager
ao-forge init my-app --package-manager npm

# Use custom template
ao-forge init my-app --template dao

# Create in specific directory
ao-forge init my-app --path ./projects/

# Skip installation
ao-forge init my-app --skip-install

# Overwrite existing files
ao-forge init my-app --force

Interactive Mode

When you run ao-forge init without specifying options, it will prompt you for:

  1. Framework selection
    ? Select framework:
    ❯ Next.js
      Nuxt.js
    
  2. Package manager selection
    ? Select package manager:
    ❯ pnpm
      npm
      yarn
    
  3. Template selection
    ? Select template:
    ❯ Default
      DAO
      NFT Marketplace
      DeFi Protocol
    

Templates

Default Template

ao-forge init my-app --template default

Creates a basic AO application with:

  • Counter process
  • Basic frontend integration
  • Development configuration

DAO Template

ao-forge init my-dao --template dao

Creates a DAO application with:

  • Voting system
  • Proposal management
  • Member management
  • Governance features

NFT Marketplace Template

ao-forge init my-nft --template nft

Creates an NFT marketplace with:

  • NFT minting
  • Trading functionality
  • Marketplace features
  • User management

DeFi Protocol Template

ao-forge init my-defi --template defi

Creates a DeFi protocol with:

  • Token contracts
  • Liquidity pools
  • Staking mechanisms
  • Yield farming

Generated Structure

Next.js Project

my-app/
├── README.md
├── package.json
├── ao.config.yml
├── tsconfig.json
├── next.config.js
├── tailwind.config.js
├── src/
│   ├── app/
│   │   ├── layout.tsx
│   │   ├── page.tsx
│   │   └── globals.css
│   └── ao/
│       └── counter.lua
└── public/
    └── favicon.ico

Nuxt.js Project

my-app/
├── README.md
├── package.json
├── ao.config.yml
├── tsconfig.json
├── nuxt.config.ts
├── tailwind.config.js
├── app.vue
├── ao/
│   └── counter.lua
└── public/
    └── favicon.ico

Configuration

The init command creates an ao.config.yml file with default settings:

name: 'my-app'
version: '1.0.0'
description: 'My AO-powered application'
framework: 'nextjs'
packageManager: 'pnpm'
luaFiles: ['counter.lua']
autoStart: false
ports:
  dev: 3000

Dependencies

The init command installs the following dependencies:

Next.js Dependencies

  • next - Next.js framework
  • react - React library
  • react-dom - React DOM
  • typescript - TypeScript support
  • tailwindcss - CSS framework
  • @types/node - Node.js types
  • @types/react - React types

Nuxt.js Dependencies

  • nuxt - Nuxt.js framework
  • vue - Vue.js library
  • typescript - TypeScript support
  • tailwindcss - CSS framework
  • @nuxt/typescript-build - TypeScript build module

Error Handling

Common Errors

  1. Project name already exists
    Error: Directory 'my-app' already exists
    Solution: Use --force to overwrite or choose a different name
    
  2. Invalid framework
    Error: Invalid framework 'invalid'
    Solution: Use 'nextjs' or 'nuxtjs'
    
  3. Package manager not found
    Error: Package manager 'yarn' not found
    Solution: Install yarn or use 'npm' or 'pnpm'
    

Best Practices

  1. Use descriptive names for your projects
  2. Choose the right framework for your needs
  3. Use consistent package managers across projects
  4. Review generated files before starting development
  5. Customize configuration after creation