UNPKG

@bold-ai/create-product

Version:

CLI tool to create new products with Company Auth pre-configured

176 lines (137 loc) 4.98 kB
# @bold/create-product CLI tool to quickly scaffold new products with Company Auth pre-configured. ## Usage ### Create a new product interactively ```bash npx @bold/create-product ``` ### Create with project name ```bash npx @bold/create-product my-awesome-product ``` ### With options ```bash npx @bold/create-product my-product --skip-install ``` ## Options - `--template <type>` - Template to use (default: `default`) - `--skip-install` - Skip installing dependencies - `--skip-register` - Skip registering product with auth service ## What It Does 1. **Creates a new Next.js project** from the product template 2. **Configures authentication** with your auth service URL 3. **Sets up environment variables** with placeholder values 4. **Downloads Bold packages from GitHub** (agents, auth-sdk, logger, subscriptions) ⭐ NEW! 5. **Builds all packages** automatically so they're ready to use ⭐ NEW! 6. **Installs dependencies** (optional) 7. **Registers the product** with your auth service (optional) 8. **Automatically updates .env.local** with real credentials after registration ## Interactive Prompts The CLI will ask you for: - **Project name** - Lowercase with hyphens (e.g., `my-product`) - **Display name** - Human-readable name (e.g., `My Product`) - **Description** - Short description of your product - **Auth Service URL** - URL of your central auth service - **Supabase credentials** - Can be added later - **Download Bold packages?** - Automatically download from GitHub ⭐ NEW! - **GitHub Token** - Personal access token with `repo` access (only if downloading packages) ⭐ NEW! - **Register product?** - Automatically register with auth service - **Admin API Key** - If registering, provide your `ADMIN_API_KEY` from the auth service ## After Creation ### If you downloaded packages and registered during setup: ```bash cd my-product pnpm install # Install all dependencies pnpm dev # Everything is ready! ``` Your project includes: -**Real Product ID & API Key** (from registration) -**Built Bold packages** in `./packages/` folder -**All dependencies** configured in package.json -**Auth Service URL** configured ### Your project structure: ``` my-product/ ├── packages/ ⭐ Downloaded and built Bold packages │ ├── agents/ │ │ ├── dist/ ✅ Built and ready │ │ └── src/ │ ├── auth-sdk/ │ │ ├── dist/ ✅ Built and ready │ │ └── src/ │ ├── logger/ │ │ ├── dist/ ✅ Built and ready │ │ └── src/ │ └── subscriptions/ │ ├── dist/ ✅ Built and ready │ └── src/ ├── src/ ├── package.json ✅ Configured with file:./packages/* references └── .env.local ✅ Real credentials populated ``` ### If you skipped package download: ```bash cd my-product # Download packages manually from repository # Place them in ./packages/ # Then run: pnpm install pnpm dev ``` ### If you skipped registration: ```bash cd my-product # Update AGENCY_AUTH_PRODUCT_ID and AGENCY_AUTH_API_KEY in .env.local pnpm dev ``` Your new product will be running at `http://localhost:3001` with authentication fully configured! ## Manual Product Registration If you skipped registration during CLI setup, you have two options: ### Option 1: Via Web UI 1. Go to your Auth Service at `http://localhost:3000` 2. Login with admin credentials 3. Navigate to Developer Portal 4. Click "Create Product" 5. Fill in the details 6. Copy the Product ID and API Key 7. Update your `.env.local` ### Option 2: Via CLI/API ```bash curl -X POST http://localhost:3000/api/admin/products \ -H "X-Admin-Key: YOUR_ADMIN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "My Product", "slug": "my-product", "description": "A great product" }' ``` Then update your `.env.local` with the returned credentials. ## Template Structure The generated project includes: - ✅ Next.js 14 with App Router - ✅ TypeScript configured - ✅ Tailwind CSS - ✅ Auth SDK integrated - ✅ Login/Signup pages - ✅ Protected dashboard - ✅ Middleware for route protection - ✅ Example components ## How to Get a GitHub Personal Access Token To download Bold packages, you need a GitHub token with `repo` access: ### Steps: 1. Go to: https://github.com/settings/tokens 2. Click **"Generate new token"****"Generate new token (classic)"** 3. Give it a name: `Bold CLI Package Download` 4. Select scopes: -`repo` (Full control of private repositories) 5. Click **"Generate token"** 6. **Copy the token immediately** (you won't see it again!) 7. Use it when the CLI prompts for your GitHub token ### Security Note: - ✅ Token gives access to Bold repo (private) - ✅ Only team members with repo access can use it - ✅ Monorepo stays private - ✅ Can revoke token anytime at GitHub settings ## License MIT