start
Create-react-app and VUe-CLI are all scaffolding. Here are the tools needed to develop such a scaffold
1. Commander
Commander is a lightweight NodeJS module that provides powerful user command line input and parameter parsing
2. Chalk
Beautify the style of terminal commands
const chalk = require('chalk');
const log = console.log;
const error = chalk.bold.red;
const warning = chalk.hex('#FFA500');
log(error('Error! '));
log(warning('Warning! '));
log(chalk.blue('Hello') + ' World' + chalk.red('! '));
log(chalk.blue.bgRed.bold('Hello world! '));
Copy the code
Effect:
3. node-semver
Specification version number control, Semver here details how to specification version
Common methods:
- Valid Indicates whether the version number meets standards. If the version number is correct, the value is returned. If the version number is incorrect, the value is null
- Coerce forces the string to the correct version number
- Clean converts the string to the correct version number if possible
- No distribution was found for receiving 2 parameters, determining whether the first parameter meets the requirements of the second parameter. It is generally used for determining whether the current version number is the desired version number
4. didyoumean
Simple JS matching engine
The simple idea is to prepare a command list in advance, and then match your input to the list to determine if you want the command if you make a mistake
An 🌰
// Prepare a command list data list
var list = ['facebook'.'twitter'.'instagram'.'linkedin'];
// Enter a value insargrm
var input = 'insargrm'
// Use didYouMean to match
console.log(didYouMean(input, list));
// Get results instagram
> 'instagram'
Copy the code
Configurable parameters:
- Threshold Search threshold The default value is 0.4. If the value is larger, the search scope is larger. If the value is smaller, the search scope is smaller
- ThresholdAbsolute Indicates the absolute threshold. Default value: 20
- CaseSensitive controls case; if set to true, case differences will not match. Ignore case by default
5. is-git-url
Verifying git address
isGitUrl('git://github.com/jonschlinkert/is-git-url.git'); = >true
isGitUrl('https://github.com/jonschlinkert/'); = >false
Copy the code
6. ora
Elegant terminal rotator
const ora = require('ora');
const chalk = require('chalk');
const { red } = require('chalk');
const spinner = ora({
text: 'Loading'.prefixText: 'Prefix text ->'.color: 'gray'}); spinner.start();setTimeout(() = > {
spinner.color = 'yellow';
spinner.text = 'Load discoloration';
}, 1000);
setTimeout(() = > {
// spinner.stop();
// spinner. Succeed (chalk. Green (' load successfully '));
// spinner. Fail (chalk. Green (' load failed '));
spinner.warn(chalk.green('Load Warning'));
}, 2000);
Copy the code
7. execa
Execa is A better child_process management tool. Essentially, you spawn a shell in which the incoming command string is processed directly.
For example, NPM initialization:
const execa = require('execa')
execa('npm'['init'.'-y'])
Copy the code
8. node-fs-extra
File manipulation tool library
9. node-lru-cache
Lru cache tool
10. inquirer
Command line interactive tools are more commonly used tools to learn if you want to see the official website Demo
11. validate-npm-package-name
Verify that the NPM package name is valid
conclusion
That’s all I’m using so far, and I’m going to reorganize how to develop a scaffold Cli from 0 to 1.
I am an unknown brick remover 🧱