+79
| /* | ||
| * @Author: your name | ||
| * @Date: 2019-11-13 18:44:02 | ||
| * @LastEditTime: 2019-11-13 18:51:06 | ||
| * @LastEditors: your name | ||
| * @Description: In User Settings Edit | ||
| * @FilePath: \Svue-cli\lib\init.js | ||
| */ | ||
| const ora = require('ora') | ||
| const inquirer = require('inquirer') | ||
| const chalk = require('chalk') | ||
| const request = require('request') | ||
| const download = require('download-git-repo') | ||
| module.exports = () => { | ||
| request({ | ||
| url: 'https://api.github.com/users/template-organization/repos', | ||
| headers: { | ||
| 'User-Agent': 'edu-test-cli' | ||
| } | ||
| }, (err, res, body) =>{ | ||
| if (err) { | ||
| console.log(chalk.red('查询模版列表失败')) | ||
| console.log(chalk.red(err)) | ||
| process.exit(); | ||
| } | ||
| const requestBody = JSON.parse(body) | ||
| if (Array.isArray(requestBody)) { | ||
| let tplNames = []; | ||
| requestBody.forEach(repo => { | ||
| tplNames.push(repo.name); | ||
| }) | ||
| let promptList = [ | ||
| { | ||
| type: 'list', | ||
| message: '请选择模版', | ||
| name: 'tplName', | ||
| choices: tplNames | ||
| }, | ||
| { | ||
| type: 'input', | ||
| message: '请输入项目名字', | ||
| name: 'projectName', | ||
| validate (val) { | ||
| if (val !== '') { | ||
| return true | ||
| } | ||
| return '项目名称不能为空' | ||
| } | ||
| } | ||
| ] | ||
| inquirer.prompt(promptList).then(answers => { | ||
| let ind = requestBody.find(function (ele) { | ||
| return answers.tplName == ele.name; | ||
| }); | ||
| let gitUrl = `${ind.full_name}#${ind.default_branch}`, | ||
| defaultUrl = './', | ||
| projectUrl = `${defaultUrl}/${answers.projectName}`, | ||
| spinner = ora('\n 开始生成项目,请等待...'); | ||
| spinner.start(); | ||
| download(gitUrl, projectUrl, (error)=>{ | ||
| spinner.stop(); | ||
| if (error) { | ||
| console.log('模版下载失败……') | ||
| console.log(error) | ||
| process.exit() | ||
| } | ||
| console.log(chalk.green(`\n √ ${answers.projectName} 项目生成完毕!`)) | ||
| console.log(`\n cd ${answers.projectName} && npm install \n`) | ||
| }) | ||
| }) | ||
| } else { | ||
| console.error(requestBody.message) | ||
| } | ||
| }) | ||
| } |
+42
| /* | ||
| * @Author: your name | ||
| * @Date: 2019-11-13 18:43:55 | ||
| * @LastEditTime: 2019-11-13 18:51:31 | ||
| * @LastEditors: your name | ||
| * @Description: In User Settings Edit | ||
| * @FilePath: \Svue-cli\lib\list.js | ||
| */ | ||
| const request = require('request'); | ||
| const chalk = require('chalk') | ||
| const ora = require('ora') | ||
| module.exports = () => { | ||
| let spinner = ora('\n ' + chalk.yellow('正在查询模版列表,请等待...')); | ||
| spinner.start(); | ||
| request({ | ||
| url: 'https://api.github.com/users/template-organization/repos', | ||
| headers: { | ||
| 'User-Agent': 'edu-test-cli' | ||
| } | ||
| }, (err, res, body) => { | ||
| spinner.stop(); | ||
| if (err) { | ||
| console.log(chalk.red('查询模版列表失败')) | ||
| console.log(chalk.red(err)) | ||
| process.exit(); | ||
| } | ||
| const requestBody = JSON.parse(body) | ||
| if (Array.isArray(requestBody)) { | ||
| console.log() | ||
| console.log(chalk.green('可用的模版列表:')) | ||
| console.log() | ||
| requestBody.forEach(repo => { | ||
| console.log( | ||
| ' ' + chalk.yellow('★') + | ||
| ' ' + chalk.blue(repo.name) + | ||
| ' - ' + repo.description) | ||
| }) | ||
| } else { | ||
| console.error(requestBody.message) | ||
| } | ||
| }) | ||
| } |
+4
-1
| { | ||
| "name": "svue-cli", | ||
| "version": "0.0.4", | ||
| "version": "0.0.5", | ||
| "description": "svue-cli", | ||
| "bin": { | ||
| "svue": "bin/svue" | ||
| }, | ||
| "main": "index.js", | ||
@@ -6,0 +9,0 @@ "directories": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
75574
5.19%341
50.88%14
-6.67%