Skip to content

Instantly share code, notes, and snippets.

@nicejade
Last active December 20, 2022 14:00
Show Gist options
  • Save nicejade/406f154e882a836de1b2e12d02b84aab to your computer and use it in GitHub Desktop.
Save nicejade/406f154e882a836de1b2e12d02b84aab to your computer and use it in GitHub Desktop.
Generate a good README

Generate a good README

Generate a good README use `npx` commmd.

Goal and Philosophy

Generate a good README use npx commmd.

Prerequisites

You Need install or upgrade Node.js (>= 8.*, Npm version >= 5.2.0).

Usage

# English by default
npx https://gist.github.com/nicejade/406f154e882a836de1b2e12d02b84aab

# Generate chinese README
npx https://gist.github.com/nicejade/406f154e882a836de1b2e12d02b84aab zh

License

MIT

Copyright (c) 2019-present, nicejade.

#!/usr/bin/env node
const fs = require('fs')
const EN_README_STR = `
<p align="center">
<a href="https://arya.lovejade.cn/" target="_blank">
<img width="100"src="https://raw.githubusercontent.com/nicejade/arya-jarvis/master/assets/images/logo.png">
</a>
</p>
<h1 align="center">Your Project Name</h1>
<div align="center">
<strong>
Description, Let people know what your project can do specifically.
</strong>
</div>
<br>
<div align="center">
<a href="https://nodejs.org/en/">
<img src="https://img.shields.io/badge/node-%3E%3D%208.0.0-green.svg" alt="Node Version">
</a>
<a href="https://nicelinks.site/post/5c16083e819ae45de1453caa">
<img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat" alt="Prettier">
</a>
</div>
## Goal and Philosophy
Write your original intention, philosophy, and goals for the project what you design. A short description of the motivation behind the creation and maintenance of the project. This should explain why the project exists.
## Prerequisites
Explain some prerequisites that users need to prepare before installation and use, such as:You Need install or upgrade [Node.js](https://nodejs.org/en/) (>= \`8.*\`, Npm version >= \`5.2.0\`, [Yarn](https://www.jeffjade.com/2017/12/30/135-npm-vs-yarn-detial-memo/) preferred).
## Installation
\`\`\`bash
npm i
\`\`\`
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance.
## Usage
\`\`\`bash
npm start
\`\`\`
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Screenshots (Optional)
Include logo/demo screenshot etc.
## Support (Optional)
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Tests (Optional)
\`\`\`bash
npm test
\`\`\`
Describe and show how to run the tests with code examples.
## Roadmap (Optional)
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing (Optional)
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.
## Authors and acknowledgment (Optional)
Show your appreciation to those who have contributed to the project.
## License
[MIT](http://opensource.org/licenses/MIT)
Copyright (c) #DATE#-present, [your-name](your-homepage-url).
## Project status (Optional)
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
`
const ZH_README_STR = `
<p align="center">
<a href="https://arya.lovejade.cn/" target="_blank">
<img width="100"src="https://raw.githubusercontent.com/nicejade/arya-jarvis/master/assets/images/logo.png">
</a>
</p>
<h1 align="center">您的项目名称</h1>
<div align="center">
<strong>
简短描述,让人们知道您的项目可以专门做什么。
</strong>
</div>
<br>
<div align="center">
<a href="https://nodejs.org/en/">
<img src="https://img.shields.io/badge/node-%3E%3D%208.0.0-green.svg" alt="Node Version">
</a>
<a href="https://nicelinks.site/post/5c16083e819ae45de1453caa">
<img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat" alt="Prettier">
</a>
</div>
## 目标与哲学
为您设计的项目,写下初衷、理念和目标。对创建和维护项目背后的动机,作简短的阐述,这应该可以解释为什么该项目存在。
## 先决条件
说明用户在安装和使用前,需要准备的一些先决条件,譬如:您需要安装或升级 [Node.js](https://nodejs.org/en/)(> = \`8。* \`,Npm 版本 >= \`5.2.0 \`,[Yarn](https://www.jeffjade.com/2017/12/30/135-npm-vs-yarn-detial-memo/) 作为首选)。
## 安装
\`\`\`bash
npm i
\`\`\`
在特定的生态系统中,可能存在一种通用的安装方式,例如使用Yarn,NuGet或Homebrew。但是,请考虑是否有可能正在阅读README的人是新手,并且需要更多指导。
## 用法
\`\`\`bash
npm start
\`\`\`
自由地使用示例,并尽可能显示预期的输出。内联您可以演示的最小用法示例很有帮助,同时提供指向更复杂示例的链接(如果它们太长而无法合理地包含在自述文件中)。
## 屏幕截图(可选)
包括 logo / demo 截图等。
## 支持(可选)
告诉人们他们可以去哪里寻求帮助。它可以是 issue 跟踪器,聊天室,电子邮件地址等的任意组合。
## 测试(可选)
\`\`\`bash
npm test
\`\`\`
用代码示例描述并展示如何运行测试。
## 路线图(可选)
如果您对将来的发行版有任何想法,最好在 README 文件中列出它们。
## 贡献(可选)
欢迎提出请求。对于重大更改,请先打开一个 issue,以讨论您要更改的内容。请确保适当更新测试。
## 作者和致谢(可选)
向那些为该项目做出贡献的人表示感谢。
## 执照
[MIT](http://opensource.org/licenses/MIT)
版权所有 (c) #DATE#-至今,[您的名字](您的主页网址)。
## 项目状态(可选)
如果您没有足够的精力或时间来完成项目,请在 README 文件的顶部添加注释,指出开发速度已减慢或完全停止。可能有人会选择 fork 您的项目,或者,以维护者或所有者的身份自愿加入,从而使您的项目继续进行下去。您也可以明确要求维护者。
`
const README_STR = process.argv[2] === 'zh' ? ZH_README_STR : EN_README_STR
const readmeStr = README_STR.replace('#DATE#', new Date().getFullYear())
const savedPath = process.cwd() + '/README.md'
fs.writeFile(savedPath, readmeStr, err => {
if (err) return console.error(err)
console.log('✔️ README.md has been successfully generated for you.')
})
{
"name": "generate-good-readme",
"version": "2.0.0",
"bin": "./index.js"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment