🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

ylyx-cli

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ylyx-cli

公司内部代码生成模板脚手架工具,支持快速生成项目初始结构和代码模板

Source
npmnpm
Version
1.0.9
Version published
Weekly downloads
200
809.09%
Maintainers
1
Weekly downloads
 
Created
Source

YLYX CLI - 项目脚手架工具

公司内部使用的项目脚手架工具,快速生成项目初始结构和代码模板。

功能特性

  • 🚀 快速生成项目代码
  • 📦 模板化管理,易于维护和扩展
  • ⚙️ 支持自定义变量和配置
  • ☁️ 支持云端模板(GitHub/GitLab)
  • 📝 交互式命令行界面

安装

全局安装

npm install -g ylyx-cli

使用 npx(推荐,无需安装)

# 使用 npx 直接运行
npx ylyx-cli create

# 生成项目
npx ylyx-cli generate react-app -n my-project -o ./my-project

# 安装远程模板
npx ylyx-cli install owner/repo

本地开发

git clone <repository>
cd ylyx-cli
npm install
npm link  # 链接到全局,可以本地测试

使用方法

快速开始

使用交互式方式创建新项目(推荐):

ylyx create

或者直接指定模板和项目名:

# 创建一个 React 项目
ylyx generate react-app -n my-project -o ./my-project

查看可用模板

ylyx list

安装远程模板

从 GitHub/GitLab 安装模板:

# 使用简写格式(GitHub)
ylyx install owner/repo

# 使用完整 URL
ylyx install https://github.com/owner/repo

# 指定分支和模板名
ylyx install owner/repo -b develop -n my-template

添加本地模板

ylyx add template-name /path/to/template

查看模板详情

ylyx info template-name

写入配置(mode)

将当前目录的 .ylyxrc.json 写入/更新 mode(仅支持 dev / prod):

ylyx config --mode dev
# 或
ylyx config prod

初始化配置(init config)

初始化当前目录的配置文件与默认配置模板(会生成/补齐 .ylyxrc.json,并创建 config/default-dev.jsconfig/default-prod.js 等;默认不覆盖已有文件):

ylyx init config

# 指定初始模式
ylyx init config --mode prod

# 强制覆盖已存在文件
ylyx init config --force

init config 还会尝试在当前目录的 package.json 中写入 npm 前置脚本(可在 .ylyxrc.jsonpreScripts 配置脚本名):

  • 默认会写入 predevpostbuild:prod
  • 执行 npm run dev 前,会自动先执行 ylyx config dev(dev 使用 symlink 实时同步)
  • 执行 npm run build:prod 后,会自动执行 ylyx config prod(将 default-prod.js 复制到打包输出目录)

prod 输出目录规则:

  • 优先使用 .ylyxrc.jsonbuildDir
  • 否则读取当前项目 .env.productionVUE_APP_PUBLIC_URL,默认写入 <VUE_APP_PUBLIC_URL>/default.js(会去掉首尾 /

云端模板

模板可以放在 Git 仓库中(如 GitHub、GitLab),使用 ylyx install 命令安装。

模板仓库要求

模板仓库需要包含以下结构:

your-template/
  template.json      # 模板配置文件(可选)
  files/            # 模板文件目录
    ...

示例

# 从 GitHub 安装模板
ylyx install github-user/react-template

# 从私有仓库安装(需要配置 SSH 密钥)
ylyx install git@github.com:company/templates.git

# 指定分支
ylyx install owner/repo -b v2.0

模板配置

模板应放在 templates/ 目录下,结构如下:

templates/
  template-name/
    template.json      # 模板配置文件
    files/            # 模板文件目录
      example.js
      example.css

template.json 配置示例

{
	"name": "template-name",
	"description": "模板描述",
	"version": "1.0.0",
	"variables": {
		"projectName": {
			"type": "input",
			"message": "请输入项目名称",
			"default": "my-project"
		}
	},
	"processFiles": ["package.json", "README.md", "*.json"],
	"skipFiles": ["**/*.vue", "**/*.js"]
}

配置文件

可以在项目根目录创建 .ylyxrc.json 配置文件:

{
	"mode": "dev",
	"publicDir": "./public",
	"configDir": "./config",
	"preScripts": {
		"dev": "dev",
		"prod": "build:prod"
	},
	"templatesDir": "./templates",
	"outputDir": "./src",
	"defaultVariables": {
		"author": "Your Name",
		"company": "YLYX"
	}
}

示例

生成完整项目

# 生成 React 项目
ylyx generate react-app -n my-react-app -o ./my-react-app

# 生成后进入目录并安装依赖
cd my-react-app
npm install
npm start

License

ISC

Keywords

cli

FAQs

Package last updated on 12 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts