hyd-front-template-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/index.js ADDED
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env node
2
+ const { program } = require('commander')
3
+ const help = require('../lib/core/help') // 引入帮助信息
4
+ const command = require('../lib/core/command') // 引入命令行命令
5
+
6
+ help(program)
7
+ command(program)
8
+
9
+ program.parse(process.argv) // 解析命令行参数
package/config.js ADDED
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ template: ['ruoyi-admin-template-ts', 'ruoyi-admin-template', 'h5-template-ts'],
3
+ templateUrl: {
4
+ 'ruoyi-admin-template-ts':
5
+ 'https://JerryCodeCloud:5f23c74d272c45f412ca2c70c58dd3af@gitee.com/JerryCodeCloud/my-ruoyi-admin-template-ts.git',
6
+ 'ruoyi-admin-template':
7
+ 'https://JerryCodeCloud:5f23c74d272c45f412ca2c70c58dd3af@gitee.com/JerryCodeCloud/my-ruoyi-admin-template.git',
8
+ /* 'h5-template':
9
+ 'https://JerryCodeCloud:5f23c74d272c45f412ca2c70c58dd3af@gitee.com/JerryCodeCloud/my-h5-template.git', */
10
+ 'h5-template-ts':
11
+ 'https://JerryCodeCloud:5f23c74d272c45f412ca2c70c58dd3af@gitee.com/JerryCodeCloud/my-h5-template-ts.git'
12
+ }
13
+ }
@@ -0,0 +1,10 @@
1
+ const config = require('../../config')
2
+ const inquirer = require('inquirer')
3
+ const download = require('./download')
4
+ module.exports = {
5
+ createAcitons: async (project, args) => {
6
+ const prompt = inquirer.createPromptModule()
7
+ const answer = await prompt([{ type: 'list', name: 'template', message: '请选择模版', choices: config.template }])
8
+ await download(config.templateUrl[answer.template], project)
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ const actions = require('./actions')
2
+ module.exports = program => {
3
+ program.command('create <project> [other...]').alias('crt').description('创建一个项目').action(actions.createAcitons)
4
+ }
@@ -0,0 +1,22 @@
1
+ const download = require('download-git-repo')
2
+ const ora = require('ora')
3
+ const chalk = require('chalk')
4
+
5
+ module.exports = (url, project) => {
6
+ return new Promise((resolve, reject) => {
7
+ const spinner = ora('正在下载模板...').start()
8
+ download(`direct:${url}`, project, { clone: true }, err => {
9
+ if (err) {
10
+ spinner.fail('下载模板失败')
11
+ return reject(err)
12
+ }
13
+ spinner.succeed('下载模板成功')
14
+ console.log(
15
+ `\n${chalk.green.bold(
16
+ '下载完成'
17
+ )},请执行以下命令安装依赖并启动项目:\n cd ${project}\n npm install\n npm run dev`
18
+ )
19
+ resolve()
20
+ })
21
+ })
22
+ }
@@ -0,0 +1,4 @@
1
+ // 帮助信息模块
2
+ module.exports = program => {
3
+ program.option('-t --template <template>', '选择模版') // 第一个参数表示命令 <****> 表示要引用安装的内容 , 第二个参数是描述
4
+ }
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "hyd-front-template-cli",
3
+ "version": "0.0.1",
4
+ "description": "适合本公司整体样式风格的若依后台管理框架模版,以及基于vue3的h5模版。仅限本公司内容使用。@copyright 2025 hyd",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "hyd-front-template-cli": "bin/index.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "author": "",
13
+ "license": "ISC",
14
+ "dependencies": {
15
+ "chalk": "^4.1.2",
16
+ "commander": "^13.1.0",
17
+ "download-git-repo": "^3.0.2",
18
+ "inquirer": "^12.6.1",
19
+ "ora": "^5.4.1"
20
+ }
21
+ }
package/test/chalk.js ADDED
@@ -0,0 +1,3 @@
1
+ const chalk = require('chalk')
2
+
3
+ console.log(chalk.green('green'), chalk.blue('blue'))
@@ -0,0 +1,5 @@
1
+ const download = require('download-git-repo')
2
+
3
+ download('direct:https://gitee.com/JerryCodeCloud/my-ruoyi-admin-template.git', './xxxx', { clone: true }, err => {
4
+ console.log(err)
5
+ })
@@ -0,0 +1,24 @@
1
+ const inquirer = require('inquirer')
2
+ const prompt = inquirer.createPromptModule()
3
+ prompt([
4
+ { type: 'input', name: 'name', message: 'What is your name?' },
5
+ { type: 'confirm', name: 'isCool', message: 'Are you cool?' },
6
+ { type: 'list', name: 'age', message: 'How old are you?', choices: ['18', '25', '30'] },
7
+ { type: 'password', name: 'password', message: 'What is your password?' },
8
+ { type: 'rawlist', name: 'gender', message: 'What is your gender?', choices: ['Male', 'Female'] },
9
+ { type: 'checkbox', name: 'hobbies', message: 'What are your hobbies?', choices: ['Coding', 'Reading'] },
10
+ { type: 'editor', name: 'bio', message: 'Write your bio:' },
11
+ { type: 'number', name: 'age2', message: 'How old are you?' },
12
+ {
13
+ type: 'expand',
14
+ name: 'agree',
15
+ message: 'Do you agree?',
16
+ choices: [
17
+ { key: 'y', name: 'Yes' },
18
+ { key: 'n', name: 'No' }
19
+ ]
20
+ },
21
+ { type: 'file', name: 'file', message: 'Select a file' }
22
+ ]).then(answers => {
23
+ console.log(answers)
24
+ })
package/test/ora.js ADDED
@@ -0,0 +1,7 @@
1
+ const ora = require('ora')
2
+ const spinner = ora('Loading unicorns').start()
3
+
4
+ setTimeout(() => {
5
+ spinner.color = 'yellow'
6
+ spinner.text = 'Loading rainbows'
7
+ }, 1000)