37

image.png

Preface: The inspiration for the article comes from the fact that someone in the community shared a github project awesome-nodejs that he maintained for several months. Maybe you have a doubt like me. There is already an awesome-nodejs library of the same type on github and it's as high as 41k⭐. What's the point of maintaining a new one? When you compare them in depth, there are still differences in essence. One is that the classification system has a finer granularity, and the second is the more friendly translation maintenance for Chinese, and it also includes the inclusion of some excellent open source libraries in China. Finally, I personally think that by sorting out by myself, I can better review and summarize.

image.png

By reading the awesome-nodejs library, I extracted some of the classifications with more application scenarios, and shared the tools with you through the application scenarios involved in the classification.

1.Git

1.1 Application Scenario 1: To achieve the standard verification of eslint check and commit information before git submission?

The following tools can be used:

  • husky -Modern local Git hooks make operation easier
  • pre-commit -automatically installs the git pre-commit script in your git repository, which runs your npm test on pre-commit.
  • yorkie especially rewritten Yorkie, Yorkie is actually fork husky, which makes Git hooks simple (used in vue-cli 3x)

1.2 Application Scenario 2: How to pull git repository through node? (Can be used to develop scaffolding)

The following tools can be used:

1.3 Application scenario 3: How to see the git flow chart in the terminal?

The following tools can be used:

  • gitgraph -Draw git flow chart in Terminal (support browser, React).

1.4 Other

2. Environment

2.1 Application scenario 1: How to write different environment variables according to different environments?

The following tools can be used:

  • cross-env -Setting of cross-platform environment script, you can pass a simple command (set environment variable) without worrying about setting or using environment variable platform.
  • dotenv -Load the environment variables for the nodejs project from the .env file.
  • vue-cli --mode -You can override the default mode for the command line by passing the --mode option parameter

3.NPM

3.1 Application scenario 1: How to switch between different npm sources?

The following tools can be used:

  • nrm -Quickly switch npm registrars, such as npm, cnpm, nj, taobao, etc., or switch to the internal npm source
  • pnpm -Comparable to yarn and npm, it saves a lot of hard disk space proportional to the project and dependencies

3.2 Application Scenario 2: How to read package.json information?

The following tools can be used:

3.3 Application Scenario 3: How to view the updated version allowed by the current package.json dependency

The following tools can be used:

image.png

3.4 Application scenario 4: How to run multiple npm scripts at the same time

Usually we have to run multiple scripts like this npm run build:css && npm run build:js , and the setting will be longer. Use & to splice

The following tools can be used:

  • npm-run-all -command line tool to run multiple npm scripts at the same time (parallel or serial)

npm-run-all provides three commands, npm-run-all run-s run-p, the latter two are shorthand for npm-run-all with parameters, corresponding to serial and parallel respectively. It also supports matching delimiters, which can simplify script configuration

Or use

  • concurrently -execute commands in parallel, similar to npm run watch-js & npm run watch-less but better. (But it can only be parallel)

3.5 Application Scenario 5: How to check the unused dependencies of the NPM module.

The following tools can be used:

  • depcheck -Check the unused dependencies of your NPM module.
    image.png

3.6 Other:

  • npminstall -Make npm install faster and easier, cnpm uses by default
  • semver -JavaScript semantic version number parser used by NPM.

Regarding the online query of npm packages, recommend a weapon npm.devtool.tech
image.png

4. Document generation

4.1 Application scenario 1: How to automatically generate api documents?

  • docsify -API document generator.
  • jsdoc -API documentation generator, similar to JavaDoc or PHPDoc.

5. Log tool

5.1 Application Scenario 1: How to implement log classification?

  • log4js-nodey -a logging library different from Java log4j.
  • consola -Elegant Node.js and browser logging library.
  • winston -Multi-transport asynchronous logging library (ancient)

6. Command line tools

6.1 Application Scenario 1: How to parse the command line input?

Our first impression will think of process.argv , so is there any tool to analyze it?

The following tools can be used:

  • minimist -command line parameter parsing engine
  • arg -simple parameter analysis
  • nopt -Node/npm parameter analysis

6.2 Application Scenario 2: How to enable users to interact with the command line?

image.png

The following tools can be used:

  • Inquirer.js -A collection of general interactive command line tools.
  • prompts -Lightweight, beautiful, and user-friendly interactive command line prompts.
  • Enquirer -User-friendly, intuitive and stylish CLI prompts that are easy to create.

6.3 Application Scenario 3: How to display the progress bar in the command line?

image.png
The following tools can be used:

  • progress -Flexible ascii progress bar for Node.js.
  • progress-estimator -record the progress bar and estimate the time required to complete the promise.

6.4 Application Scenario 4: How to perform multitasking on the command line?

image.png

The following tools can be used:

6.5 Application Scenario 5: How to "Ice on the Cake" on the command line?

image.png

The following tools can be used:

  • chalk -command line string style beautification tool.
  • ora -Elegant command line loading effect.
  • colors.js -Get the color of the Node.js console.
  • qrcode-terminal -Display the QR code in the command line.
  • treeify -beautifully print javascript objects as trees.
  • kleur -The fastest Node.js library that uses ANSI colors to format command line text.

7. Encryption and decryption

In general, for project security considerations, we usually encrypt account passwords, usually through MD5, AES, SHA1, and SM. What libraries are there in the open source community that are convenient for us to use?

The following tools can be used:

  • crypto-js -JavaScript encryption standard library. Support the most algorithms
  • node-rsa -Node.js version of Bcrypt.
  • node-md5 -A JavaScript function used to hash messages using MD5.
  • aes-js -Pure JavaScript implementation of AES.
  • sm-crypto -JavaScript implementation of national secret sm2, sm3, sm4.
  • sha.js -Use streaming SHA hashing in pure JavaScript.

8. Static website generation & blog

Isn’t it good to generate a website with one click? Quickly build your own blog website based on the node system, you deserve it, and it can also be displayed as a component library document

image.png

The following tools can be used:

  • hexo -A fast, simple and powerful blog framework using Node.js.
  • vuepress -A minimalist Vue static website generator. (Based on nuxt SSR)
  • netlify-cms -Git-based static website generation tool.
  • vitepress -Vite & Vue.js static website generation tool.

9. Data verification tool

Data verification, the closest thing to us is the verification of form data. In the component libraries we usually use, such as element, iview, etc., we will see the use of an open source verification tool async-validator . Is there anything else?

The following tools can be used:

  • validator.js -string verification library.
  • joi -Object pattern description language and validator based on JavaScript objects.
  • async-validator -asynchronous check.
  • ajv -the fastest JSON Schema validator
  • superstruct -Verify data in JavaScript and TypeScript in a simple and composable way.

10.Analysis tools

10.1 Application Scenario 1: How to parse markdown?

The following tools can be used:

  • marked -Markdown parser and compiler, designed to increase speed.
  • remark -Markdown processing tool.
  • markdown-it -An extension & grammar plug-in that supports 100% general Markdown tag analysis.

10.2 Application Scenario 2: How to parse csv?

The following tools can be used:

  • PapaParse -A fast and powerful CSV (delimited text) parser that can handle large files and malformed input gracefully.
  • node-csv -Full-featured CSV parser with simple api, and tested against large data sets.
  • csv-parser -A streaming CSV parser designed to be faster than anyone else.

10.3 Application Scenario 3: How to parse xml?

The following tools can be used:

At last

If you like this library, also give the author huaize2020 a star warehouse address: awesome-nodejs
I saw a paragraph yesterday and wanted to share it with everyone

For a daily R&D test:

  • 1. The first thing to start working is to plan today's work content arrangement (it is recommended to have a clear ToDolist and sort by priority)
  • 2. Confirm the workload and the risks associated with upstream and downstream (such as relying on others, can they be provided on time); if there are any risks, expose them as soon as possible
  • 3. Pay attention to the cost of time, not everything is worth all your time to do, distinguish the primary and secondary relationship
  • 4. Collaborate tasks, clarify boundary responsibilities, don’t leave it alone, and synchronize to relevant people in time after completing the task
  • 5. Summing up experience in time, accumulating technical output to realize ability reuse, same type of tasks, no need to start from scratch, avoid duplication of work

Hello, I am 🌲 tree sauce, please have a drink🍵 Remember Sanlian~

1. After reading, remember to like it, there is 👍 motivated

2. Pay attention to those interesting things on the front end of the official account, and chat with you about the interesting things

3. The article is included in Github frontendThings, thanks to Star✨


树酱
457 声望953 粉丝

95年程序猿,搞前端,爱音乐,唱跳rap工程🌲