当前位置:网站首页>Scaffold development foundation
Scaffold development foundation
2022-07-05 10:48:00 【Code Bruce Lee】
Basics
The goal is
v create demo
The plugin is introduced
commander
Document address
explain : Command line plug-ins
Usage method :
const { program } = require(‘commander’)
program.version(‘0.0.1’)
program.option(“-n “, “ Output name ”)
// Parameters must use <> Wrapped in the form of
program.option(”-t --type ”, “ Project type ”)
// Output options
// const options = program.opts()
// console.log(“opts=>”, options)
program.opts()
program
// command
.command(“create ”)
// describe
.description(“ Create a standard Vue project ”)
// Behavior
.action(name => {
console.log(“ Creating Vue project , The name is :” + name)
})
// Must pass parse Only by analyzing the way , Need to be at the end
program.parse(process.argv)
figlet
Document address
explain : Large character - The terminal prints large text
Usage method :
// callback form
const figlet = require(“figlet”)
figlet(‘Hello World!!’, function (err, data) {
if (err) {
console.log(‘Something went wrong…’)
console.dir(err)
return
}
console.log(data)
});
// async form
let { promisify } = require(“util”)
let figlet = require(“figlet”)
let asyncFiglet = promisify(require(“figlet”))
async function run() {
try {
let data = await asyncFiglet(“Vue 3”)
console.log(data)
} catch (error) {
console.log(error)
}
}
run()
inquirer
Document address
explain : Command line parameter input interaction
Usage method :
let inquirer = require(“inquirer”)
// prompt Accept an array , You can ask multiple
inquirer.prompt([
{
name: “userName”,// Printed text
type: “input”, // type There are many types of list, input, checkbox…
message: “ What is your name? ?” // Options
},
{
name: “age”,
type: “checkbox”,
message: “ How old are you ?”,
choices: [“20-25”, “25-30”, “30-40”, “40 above ”]
}
]).then(answer => {
console.log(“ Answer content :”, answer)
}).catch((error) => {
if (error.isTryError) { } else { }
})
chalk
Document address
explain : Color text - Beautify terminal character display
Usage method :
let chalk = require(“chalk”)
const log = console.log
log(chalk.blue(‘hello’) + ’ world’ + chalk.red(‘!’))
ora
Document address
explain :loading effect
Usage method :
const ora = require(‘ora’)
const spinner = ora(‘Loading unicorns’).start()
setTimeout(() => {
spinner.color = ‘yellow’
spinner.text = ‘Loading rainbows’
setTimeout(() => {
spinner.stop()
}, 1000)
}, 2000)
download-git-repo
Document address
explain : Warehouse downloading
Usage method :
let download = require(“download-git-repo”)
// direct:git Address , demo1 It means where to put it
download(‘direct:https://xxx.git’, ‘Demo1’, { clone: true }, function (err) {
console.log(err ? ‘Error’ : ‘Success’)
})
Scaffold development process
Create an empty project / Folder
adopt npm/yarn initialization package file
npm init
yarn init
Installing a plug-in
npm install commander figlet inquirer chalk ora download-git-repo -S
yarn add commander figlet inquirer chalk ora download-git-repo -S
establish bin Catalog
|-bin
|–index.js
|–init.js
package.json
Development command line
/**
- Develop backstage scaffolding , Quickly generate standards Vue Background architecture
*/
let program = require(“commander”)
let { promisify } = require(‘util’)
let asyncFiglet = promisify(require(“figlet”))
let chalk = require(“chalk”)
let inquirer = require(“inquirer”)
let init = require(“./init”)
// Log print function
const log = content => console.log(chalk.yellow(content))
// Set version and parameters
program.version(“1.0.0”);
program.option(“-n --name ”, “output name”);
// Print LOGO
async function printLogo() {
let data = await asyncFiglet(“v-cli”);
log(data);
}
program
.command(“create ”)
.description(“ establish Vue project ”)
.action(async (name) => {
await printLogo()
log(“ Ready to create project …”)
let answer = await inquirer.prompt([
{
name: “language”,
type: “list”,
message: “ Please select the language version ”,
choices: [“Javascript”, “Typescript”]
}
])
if (answer.language == “Javascript”) {
// Download framework
log(“ You chose Javascript edition , About to enter download mode .”)
init(name);
} else {
log(“ Coming soon !!!”)
}
})
// Argument parsing
program.parse(process.argv)
// init.js
/**
- Project cloning
*/
let { promisify } = require(‘util’)
const ora = require(“ora”)
const download = promisify(require(“download-git-repo”))
const shell = require(“shelljs”)
let chalk = require(“chalk”)
// Log print function
const log = content => console.log(chalk.yellow(content))
module.exports = async (appName) => {
log( Create project ${appName})
shell.rm(“-rf”, appName);
const spinner = ora(“ In the download …”).start();
try {
await download(“direct:https://xxx.git”, appName, { clone: true })
spinner.succeed(“ Download complete ”)
log(`
Download complete , Please execute the following command to start the project :
cd ${appName}
yarn perhaps npm init
npm run dev
perhaps
yarn dev
) } catch (error) { log( Download failed `, error)
spinner.stop();
}
}
边栏推荐
- How can non-technical departments participate in Devops?
- Who is the "conscience" domestic brand?
- 关于vray 5.2的使用(自研笔记)
- csdn软件测试入门的测试基本流程
- Pseudo class elements -- before and after
- SqlServer定时备份数据库和定时杀死数据库死锁解决
- 谈谈对Flink框架中容错机制及状态的一致性的理解
- 变量///
- BOM//
- 【DNS】“Can‘t resolve host“ as non-root user, but works fine as root
猜你喜欢
![[paper reading] ckan: collaborative knowledge aware autonomous network for adviser systems](/img/6c/5b14f47503033bc2c85a259a968d94.png)
[paper reading] ckan: collaborative knowledge aware autonomous network for adviser systems

“军备竞赛”时期的对比学习

AD20 制作 Logo

32: Chapter 3: development of pass service: 15: Browser storage media, introduction; (cookie,Session Storage,Local Storage)

关于vray 5.2的使用(自研笔记)

Who is the "conscience" domestic brand?

重磅:国产IDE发布,由阿里研发,完全开源!

Go语言-1-开发环境配置

【js学习笔记五十四】BFC方式

【观察】跨境电商“独立站”模式崛起,如何抓住下一个红利爆发时代?
随机推荐
脚手架开发基础
In wechat applet, after jumping from one page to another, I found that the page scrolled synchronously after returning
数据类型、
Node の MongoDB Driver
Nine degrees 1480: maximum ascending subsequence sum (dynamic programming idea for the maximum value)
Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
flex4 和 flex3 combox 下拉框长度的解决办法
字符串、、
Implement the rising edge in C #, and simulate the PLC environment to verify the difference between if statement using the rising edge and not using the rising edge
C语言活期储蓄账户管理系统
2022年T电梯修理操作证考试题及答案
Go language-1-development environment configuration
[observation] with the rise of the "independent station" model of cross-border e-commerce, how to seize the next dividend explosion era?
Completion report of communication software development and Application
跨页面通讯
DOM//
想请教一下,十大券商有哪些?在线开户是安全么?
TSQL–标示列、GUID 、序列
Learning II of workmanager
How can gbase 8C database view the login information of the login user, such as the date, time and IP of the last login authentication?