How to write your own scaffolding tool creepate-react-app @vue/cli source code interpretation

Principle: Quickly build the complete structure of a project
Common scaffolding tools: yeoman, express-genereator, vue-cli

npm link
npm unlink

Node does not support es6 mode
https://javascript.ruanyifeng.com/nodejs/module.html

git clone ${gitUrl} ${folderName}
from the remote warehouse to a custom directory

1. Entry file

/bin

Second, the class library used

co library

Usage of generator function

Similar to async /await

co-prompt library

Return the user terminal input of nodejs

chalk

Beautify output

execute

execa is a javascript package that can call shell and local external programs. Will start the execution of the child process. Support multiple operating systems, including windows. If the parent process exits, all child processes generated are killed.

dns

DNS

commander

Complete node.js command line solution

envinfo

semver

Semantic version number

validate-npm-package-name

Check whether it is a valid npm package name

fs-extra

fs.ensureDirSync(name); //Create folder

life

Compare the differences between strings

slash

Window backslash path conversion

minimist

Command line parameter analysis

inquirer

Command line interactive tool

this

lru-cache

A cache object used to delete the least recently used items

strip-ansi

Remove the ANIS escape code from the string

ejs

js template engine

deepmerge

Deeply merge objects

Three, node

child_process

child_process.spawn(command[, args][, options])
execute command command

subprocess.stderr
subprocess readable stream

stdio stream
data event
close event

stream

When writable.write(chunk), the data will be buffered in the writable stream.

process

process.cwd()
returns the current process directory

The process.stderr property returns a duplex stream

resolve

isbinaryfile

Check whether it is a binary file

Four, linux command

ls
ls -lh can view the size of the file while listing the file
ls -lh /usr to view the uer directory

Five, js

str.match(/[.*] (\d+)/(\d+)/)
match version number

Class private method


class cjrApi{
    
    
  constructor(cjr){
    
    
    this.cjr=cjr
  }
  init(){
    
    
    this.cjr.cjrArray=[1,3]
  }
}
class cjr{
    
    
  constructor(){
    
    
    // super()
    this.cjrArray=[]
  }
  init(){
    
    
    let api=new cjrApi(this)
    console.log(api,this.cjrArray)
  }
}

Guess you like

Origin blog.csdn.net/cs18335818140/article/details/111479277
Recommended