ono-cli
v0.3.0
Published
A CLI tool for ono template
Readme
ono-cli - Project Scaffolding Tool
A powerful project scaffolding tool that provides two working modes: Dependency Selection Mode (Recommended) and Template Selection Mode (Advanced), meeting project creation needs for different scenarios.
✨ Features
- 🎯 Dual Mode Support: Dependency Selection Mode + Template Selection Mode
- 🚀 Zero Configuration Out-of-the-Box: The recommended mode can be used without any configuration
- 📦 Rich Technology Stack: Vue/React, TypeScript, ESLint, Routing, State Management, etc.
- 🔧 Highly Extensible: Advanced mode supports custom template repositories
- 🌿 Lightweight and Efficient: Uses shallow clone to speed up project creation
🚀 Quick Start (Recommended) ✨
No global installation required! Use any of the following commands to create a project:
npm users:
npm create ono-cli [YOUR PROJECT NAME]pnpm users:
pnpm create ono-cli [YOUR PROJECT NAME]yarn users:
yarn create ono-cli [YOUR PROJECT NAME]bun users:
bun create ono-cli [YOUR PROJECT NAME]📦 Global Installation (Optional)
If you want to install the CLI globally, you can also choose this way:
npm install -g ono-cliThen use:
ono-cli create [YOUR PROJECT NAME]📖 Getting Started - Dependency Selection Mode (Recommended) ✨
No configuration required, works out of the box! Select the technology stack you need through interactive prompts and quickly create your project.
Create Project
ono-cli create [YOUR PROJECT NAME]Optional Parameters:
-f, --force: Force overwrite existing directory
Configurable Technology Stack
Dependency Selection Mode supports flexible configuration of the following options:
- Framework: Vue / React
- Language: JavaScript / TypeScript
- Code Linting: ESLint
- Routing: Vue Router / React Router
- Automatic Routing: Optional
- State Management:
- Vue: Pinia / Vuex
- React: Redux / Zustand
- Atomic CSS: Tailwind CSS / Uno CSS
Examples
Using the create command (recommended):
# Create a project named my-vue-app
npm create ono-cli my-vue-app
# Follow the prompts to select your tech stack!Or use the global installed version:
ono-cli create my-vue-app🔧 Advanced Usage - Template Selection Mode
If you have your own template repository, you can use Template Selection Mode to pull templates from your GitHub/Gitee organization.
1. Configure the Scaffold
Before using Template Selection Mode, you need to first configure the code hosting platform, organization, access token, and other information:
Interactive Configuration:
Using the zero-install method:
npx ono-cli@latest config -sOr using the global installation method:
ono-cli config -sConfigurable items:
- User name
- Organization name
- Access token
- Code hosting platform (GitHub/Gitee)
- Work mode: Select "Template Selection Mode"
2. Create Project
After configuration, you can use the scaffold to create a new project:
Using the zero-install method:
npm create ono-cli [YOUR PROJECT NAME]Or using the global installation method:
ono-cli create [YOUR PROJECT NAME]Then select a template from your organization repository list, and select a branch or tag to clone.
3. Other Configuration Commands
View Configuration:
ono-cli config -gDelete Configuration Item:
ono-cli config -dClear Configuration:
ono-cli config -cThis command will clear all configuration items and restore the configuration file to its default state.
📦 Updating the CLI
When a new version is available, you can update using:
Create command users (recommended):
Every time you run npm create ono-cli, it will automatically use the latest version!
Global install users:
ono-cli update [version]If no version is specified, it will automatically detect and update to the latest version.
💡 Work Mode Comparison
| Feature | Dependency Selection Mode (Recommended) | Template Selection Mode (Advanced) | | -------------------------- | --------------------------------------- | ---------------------------------- | | Configuration Required | None required | Organization and token required | | Flexibility | High, can freely combine tech stack | Low, uses fixed templates | | Use Case | Quickly start new projects | Use team custom templates | | Template Source | Official template repository | Your own organization repository | | Learning Curve | Simple | Medium |
🔧 How to Create Organization and Access Token
(Only required for Template Selection Mode)
GitHub
Create Organization
- Log in to your GitHub account
- Click your avatar in the upper right corner, select "Your organizations"
- Click the "New organization" button
- Select organization type (Free or Team)
- Enter organization name and contact information
- Click "Create an organization" to complete creation
Create Access Token
- Log in to your GitHub account
- Click your avatar in the upper right corner, select "Settings"
- In the left sidebar, click "Developer settings"
- On the "Developer settings" page, click "Personal access tokens" → "Tokens (classic)"
- Click the "Generate new token" button
- Enter a token description (Note)
- Set expiration time (Expiration)
- Assign permissions to the token:
- For accessing private repositories, at least the
repopermission is required - For accessing organization repositories, the
read:orgpermission is also required
- For accessing private repositories, at least the
- Click the "Generate token" button
- Copy the generated token and save it securely (you won't be able to see it again after leaving the page)
Gitee
Create Organization
- Log in to your Gitee account
- Click your avatar in the upper right corner, select "组织" (Organization)
- Click "创建组织" (Create organization)
- Enter organization name, introduction, and other information
- Select organization type (Public or Private)
- Click "创建组织" (Create organization) to complete creation
Create Access Token
- Log in to your Gitee account
- Click your avatar in the upper right corner, select "设置" (Settings)
- In the left sidebar, click "私人令牌" (Personal access token)
- Click "生成新令牌" (Generate new token) button
- Enter token name and expiration time
- Assign permissions to the token:
- For accessing repositories, select the
projectspermission - For accessing organization information, select the
organizationspermission
- For accessing repositories, select the
- Click "生成令牌" (Generate token) button
- Copy the generated token and save it securely (you won't be able to see it again after leaving the page)
🔧 Troubleshooting
If you encounter problems, please check:
Dependency Selection Mode
- Check if the network connection is normal
- Ensure you can access gitee.com
Template Selection Mode
- Ensure the organization name and access token are correctly configured
- Ensure the template repository name matches the configured organization
- Check if the network connection is normal
- If using a private repository, ensure the access token has the required permissions
📦 Technology Stack
- Node.js + TypeScript
- Commander.js - Command line framework
- Inquirer.js - Interactive prompts
- Chalk - Terminal colored output
- Ora - Terminal loading animation
- FS-Extra - File system enhancement
- Ono-fetch - HTTP request
📄 License
MIT
