Status: Deferred to future version
Goal: Implement a complete CLI tool that enables npx emberdocs init my-docs and other commands, preparing the package for npm publishing.
Implement a complete CLI tool that allows users to initialize, develop, build, and deploy EmberDocs projects via npx emberdocs. The CLI will scaffold new projects, proxy development commands, and provide deployment helpers.
graph TD
A[npx emberdocs] --> B[bin/emberdocs.js]
B --> C[Commander.js CLI]
C --> D[init command]
C --> E[dev command]
C --> F[build command]
C --> G[deploy command]
D --> H[Scaffold Project]
H --> I[Copy Templates]
H --> J[Install Dependencies]
E --> K[Proxy to Next.js dev]
F --> L[Proxy to Next.js build]
G --> M[Platform-specific deploy]
bin/emberdocs.js- CLI entry point (executable)src/cli/index.ts- Main CLI logic and command registrationsrc/cli/commands/init.ts- Init command implementationsrc/cli/commands/dev.ts- Dev command implementationsrc/cli/commands/build.ts- Build command implementationsrc/cli/commands/deploy.ts- Deploy command implementationsrc/cli/utils/scaffold.ts- Project scaffolding utilitiessrc/cli/utils/templates.ts- Template file managementtemplates/minimal/- Minimal project template filestemplates/full/- Full project template with examplestemplates/integrate/- Integration template for existing Next.js projects
package.json- Addbinfield, CLI dependencies, removeprivate: truetsconfig.json- Include CLI source files.gitignore- Ensure CLI build output is handled
Add bin field:
"bin": {
"emberdocs": "./bin/emberdocs.js"
}Add CLI dependencies:
commander- Command parsinginquirer- Interactive promptschalk- Terminal colorsora- Progress spinnersfs-extra- Enhanced file operationsexeca- Process execution
Remove or make conditional:
"private": true- Remove to allow publishing
Simple Node.js wrapper that:
- Checks Node.js version (>=18)
- Loads and executes the compiled CLI from
dist/cli/index.js - Handles errors gracefully
- Sets up Commander.js with program name, version, description
- Registers all commands (init, dev, build, deploy)
- Handles global error handling
- Provides help text
Options:
--minimal- Minimal setup (no examples)--integrate- Add to existing Next.js project--template <name>- Use specific template
Flow:
- Validate target directory (check if exists, prompt if needed)
- Choose template type (minimal/full/integrate) via prompt if not specified
- Copy template files to target directory
- Generate
package.jsonwith correct dependencies - Create
.env.exampleand.env.local - Install dependencies via npm/yarn/pnpm (detect package manager)
- Build search index
- Display success message with next steps
Template Structure:
- Copy essential Next.js config files
- Copy EmberDocs source code (or reference as dependency)
- Create minimal
docs/directory with example - Set up TypeScript config
- Include Tailwind config
- Add necessary scripts to package.json
Options:
--port <number>- Port number (default: 3000)--host <string>- Host address
Flow:
- Check if in EmberDocs project (look for
next.config.mjsoremberdocs.config.js) - Run
npm run devwith port/host options - Proxy Next.js dev server
Options:
--output <dir>- Output directory (default:.next)--static- Static export only
Flow:
- Build search index first
- Run Next.js build
- Optionally run static export if
--staticflag
Platforms:
vercel- Deploy to Vercelnetlify- Deploy to Netlifygithub-pages- Deploy to GitHub Pages
Flow:
- Build project first
- Run platform-specific deployment commands
- Provide deployment URLs
Functions:
createDirectory(path)- Create directory with error handlingcopyTemplate(templateName, targetDir)- Copy template filesgeneratePackageJson(options)- Generate package.jsoninstallDependencies(targetDir, packageManager)- Install depsdetectPackageManager()- Detect npm/yarn/pnpmcreateEnvFiles(targetDir)- Create .env.example and .env.local
Minimal Template:
- Basic Next.js setup
- EmberDocs integration
- Single example doc
- Minimal config
Full Template:
- Complete Next.js setup
- Multiple example docs (getting-started, guides, api-reference)
- All features enabled
- Example configuration
Integration Template:
- Files to add to existing Next.js project
- Instructions for manual integration
- Minimal file changes
- CLI code needs to be compiled to
dist/cli/ - Add build script:
"build:cli": "tsc -p tsconfig.cli.json" - Create
tsconfig.cli.jsonfor CLI-specific compilation
- Ensure
bin/emberdocs.jshas executable permissions - Add to
.gitattributes:bin/emberdocs.js linguist-generated=false
- Unit Tests - Test individual command functions
- Integration Tests - Test full init flow in temp directory
- E2E Tests - Test actual
npxusage (manual for now)
- Version Management - Set initial version (0.1.0)
- README Updates - Add CLI usage documentation
- npmignore - Exclude unnecessary files from package
- Pre-publish Checklist - Document steps for future publishing
{
"commander": "^11.0.0",
"inquirer": "^9.2.0",
"chalk": "^5.3.0",
"ora": "^7.0.0",
"fs-extra": "^11.2.0",
"execa": "^8.0.0"
}- Set up package.json (bin, dependencies)
- Create CLI entry point (bin/emberdocs.js)
- Set up TypeScript config for CLI
- Implement main CLI structure (src/cli/index.ts)
- Implement init command (most complex)
- Create template files
- Implement dev, build, deploy commands
- Add error handling and user feedback
- Test locally with npm link
- Update documentation
npx emberdocs init my-docscreates working project in < 30 seconds- All commands work as expected
- Clear error messages and progress indicators
- Cross-platform compatibility (macOS, Linux, Windows)
- Package is ready for npm publishing (but not published yet)
- Update package.json: add bin field, CLI dependencies, remove private flag
- Create bin/emberdocs.js executable entry point
- Create tsconfig.cli.json for CLI compilation and update main tsconfig
- Create src/cli/index.ts with Commander.js setup and command registration
- Implement src/cli/utils/scaffold.ts with directory creation, template copying, and dependency installation
- Create template directories (minimal, full, integrate) with necessary files
- Implement src/cli/commands/init.ts with options (--minimal, --integrate, --template) and interactive prompts
- Implement src/cli/commands/dev.ts to proxy Next.js dev server with port/host options
- Implement src/cli/commands/build.ts with search index building and Next.js build
- Implement src/cli/commands/deploy.ts with platform support (vercel, netlify, github-pages)
- Add comprehensive error handling, progress indicators (ora), and user-friendly messages (chalk)
- Test CLI locally using npm link and verify all commands work
- Update README.md and create CLI usage documentation
- Create .npmignore, update version, add pre-publish checklist documentation