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 +9 -0
- package/config.js +13 -0
- package/lib/core/actions.js +10 -0
- package/lib/core/command.js +4 -0
- package/lib/core/download.js +22 -0
- package/lib/core/help.js +4 -0
- package/package.json +21 -0
- package/test/chalk.js +3 -0
- package/test/download.js +5 -0
- package/test/inquirer.js +24 -0
- package/test/ora.js +7 -0
package/bin/index.js
ADDED
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,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
|
+
}
|
package/lib/core/help.js
ADDED
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
package/test/download.js
ADDED
package/test/inquirer.js
ADDED
|
@@ -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
|
+
})
|