create-jtemplate
v1.0.6
Published
Initialize a new project from jtemplate boilerplate
Maintainers
Readme
create-jtemplate
A CLI tool to initialize a new project from jtemplate boilerplate.
Usage
# Using npm init (recommended)
npm init jtemplate <project-name>
# Or with options (note the -- separator)
npm init jtemplate -- --h5 my-h5-project
npm init jtemplate -- --web --dev my-project
# Or using npx
npx create-jtemplate <project-name>
# Or install globally
npm install -g create-jtemplate
create-jtemplate <project-name>
# Show help
npm init jtemplate -- --helpOptions
| Option | Description |
|--------|-------------|
| --web | Initialize only web directory (no backend) |
| --h5 | Initialize H5 mobile template |
| --dev | Auto install dependencies and start dev server |
| --test | Test mode, output parsed arguments only |
| --help | Show help message |
Quick Start
# Initialize a full-stack project
npm init jtemplate my-project
# Initialize only web directory (no backend)
npm init jtemplate -- --web my-web-project
# Initialize H5 mobile template
npm init jtemplate -- --h5 my-h5-project
# Initialize and auto-start dev server
npm init jtemplate -- --dev my-project
npm init jtemplate -- --web --dev my-web-projectHow it works
First attempt: Tries to clone from the primary repository via SSH:
[email protected]:jvfe/base/template/boilerplate.gitFallback: If the primary repository is unavailable or you don't have SSH access, it automatically falls back to:
https://cnb.cool/yc_null/base/templateClean up: After cloning, the
.gitdirectory is removed to give you a fresh start.Options handling:
- --web: Only copies the
webdirectory content to the target directory, suitable for front-end only projects - --h5: Clones from the H5 template repository for mobile web projects
- --dev: Automatically installs dependencies and starts the development server after initialization
- --web: Only copies the
Option Details
--web
Initializes only the web directory from the template, excluding the backend part. This is ideal for front-end only projects where you don't need the backend code.
Example:
create-jtemplate --web my-web-project--h5
Initializes a project from the H5 template repository. This is designed for H5 mobile web projects.
Repository: [email protected]:js-group/base/h5-template.git
Requirements:
- SSH key must be configured (no fallback available)
Example:
create-jtemplate --h5 my-h5-project--dev
Automatically installs dependencies and starts the development server after initialization. It checks if pnpm is installed and uses it if available, otherwise falls back to npm.
Behavior:
- For regular projects: Executes
npm run install:allorpnpm run install:all:pnpm - For web-only projects: Executes
npm installorpnpm installdirectly in the web directory - After installation: Starts the development server with
npm run dev
Example:
create-jtemplate --dev my-dev-projectCombined usage
You can combine both options to create a web-only project and start the development server immediately:
Example:
create-jtemplate --web --dev my-web-dev-projectRequirements
- Node.js >= 14.0.0
- Git installed and available in PATH
Repository Priority
Default Mode
The tool attempts repositories in this order:
Primary (SSH):
[email protected]:jvfe/base/template/boilerplate.git- Requires SSH key configured
- Faster and more secure
Fallback (HTTPS):
https://cnb.cool/yc_null/base/template- No authentication required
- Public access
H5 Mode (--h5)
When using --h5 option, the tool clones from:
- H5 Template (SSH):
[email protected]:js-group/base/h5-template.git- Requires SSH key configured
- No fallback available
License
MIT
