Socket
Socket
Sign inDemoInstall

readme-md-generator

Package Overview
Dependencies
18
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0 to 1.0.0

.github/workflows/nodejs.yml

32

CHANGELOG.md
# Changelog
<a name="1.0.0"></a>
## 1.0.0 (2019-12-03)
### Added
- ✨ Ask for package manager when is JS project [[29986ce](https://github.com/kefranabg/readme-md-generator/commit/29986cea9acde108b9e167db5d0def67beaf7384)]
- ✨ Ask user for a link to contributing guide (fixes [#168](https://github.com/kefranabg/readme-md-generator/issues/168)) ([#179](https://github.com/kefranabg/readme-md-generator/issues/179)) [[310a8b1](https://github.com/kefranabg/readme-md-generator/commit/310a8b1f78154d9226c1267ccf18d0db9d9ea09f)]
- ✨ Ask author's linkedin username (fixes [#170](https://github.com/kefranabg/readme-md-generator/issues/170)) ([#177](https://github.com/kefranabg/readme-md-generator/issues/177)) [[10954d1](https://github.com/kefranabg/readme-md-generator/commit/10954d10739b995c431b751d63d5624c17397235)]
### Changed
- ⬆️ Update yargs to the latest version ([#186](https://github.com/kefranabg/readme-md-generator/issues/186)) [[16d7ceb](https://github.com/kefranabg/readme-md-generator/commit/16d7ceb8ec3040d63841397ded83dbdddc28da52)]
- ⬆️ Update ejs to the latest version ([#187](https://github.com/kefranabg/readme-md-generator/issues/187)) [[139e906](https://github.com/kefranabg/readme-md-generator/commit/139e906b1ed1b875ca96869fe8570ca03d9806c2)]
- 🔧 Update CI tiggers ([#184](https://github.com/kefranabg/readme-md-generator/issues/184)) [[6ef2be8](https://github.com/kefranabg/readme-md-generator/commit/6ef2be8ba8e00af16087f42eabd7e4b4ed2243b3)]
- ⬆️ Update ora to the latest version ([#181](https://github.com/kefranabg/readme-md-generator/issues/181)) [[c563d9d](https://github.com/kefranabg/readme-md-generator/commit/c563d9d473e5c17be6a45936b2f58f83b734c4e9)]
- 🔧 Move CI from CircleCI to GitHub actions [[a132525](https://github.com/kefranabg/readme-md-generator/commit/a132525ffe343629db2589378647665747e5cd4f)]
- 🔧 Update FUNDING.yml [[83be6c0](https://github.com/kefranabg/readme-md-generator/commit/83be6c00842eb4321b5c37a7f5617e28f1548cdb)]
### Fixed
- 🐛 Fix version badge label when contains \_ or - ([#190](https://github.com/kefranabg/readme-md-generator/issues/190)) [[6c345b5](https://github.com/kefranabg/readme-md-generator/commit/6c345b50caec810ef48f00dcbac0255f1db1f4a3)]
- 🐛 Execute default function to get default answer when -y flag is passed ([#185](https://github.com/kefranabg/readme-md-generator/issues/185)) [[89cd82d](https://github.com/kefranabg/readme-md-generator/commit/89cd82db18655bbb085eb72c339402f412dd3996)]
- 🐛 Escape markdown characters in social network questions answers ([#183](https://github.com/kefranabg/readme-md-generator/issues/183)) [[d96e310](https://github.com/kefranabg/readme-md-generator/commit/d96e310c5b54c573a139d01f4ad348f9456f7c3c)]
- ✏️ Use gender neutral in comment ([#174](https://github.com/kefranabg/readme-md-generator/issues/174)) [[9f78778](https://github.com/kefranabg/readme-md-generator/commit/9f78778002410c0b82f36015b86443fb366425a7)]
- 🐛 Fix InstallCommand test name [[279711f](https://github.com/kefranabg/readme-md-generator/commit/279711f1cdd18b2d53478c52f577041ea2186675)]
### Miscellaneous
- 📝 Add open collective to readme ([#192](https://github.com/kefranabg/readme-md-generator/issues/192)) [[81e3873](https://github.com/kefranabg/readme-md-generator/commit/81e387357c5c088714291b0a7f18b66cab8cd5c6)]
- 📝 Add anku255 as a contributor for test and bug ([#182](https://github.com/kefranabg/readme-md-generator/issues/182)) [[7624889](https://github.com/kefranabg/readme-md-generator/commit/76248890cf46ec7a27b6986add3d156095deb782)]
<a name="0.7.0"></a>

@@ -4,0 +36,0 @@

9

package.json
{
"name": "readme-md-generator",
"version": "0.7.0",
"version": "1.0.0",
"description": "CLI that generates beautiful README.md files.",

@@ -12,3 +12,3 @@ "main": "src/index.js",

"date-fns": "^2.0.1",
"ejs": "^2.6.1",
"ejs": "^3.0.1",
"git-repo-name": "^1.0.1",

@@ -18,5 +18,6 @@ "inquirer": "~7.0.0",

"lodash": "^4.17.11",
"ora": "4.0.1",
"markdown-escape": "^1.0.2",
"node-fetch": "^2.6.0",
"yargs": "^14.0.0"
"ora": "4.0.3",
"yargs": "^15.0.1"
},

@@ -23,0 +24,0 @@ "devDependencies": {

@@ -86,2 +86,29 @@ <h1 align="center">Welcome to readme-md-generator 👋</h1>

## Code Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
<a href="https://github.com/kefranabg/readme-md-generator/graphs/contributors"><img src="https://opencollective.com/readme-md-generator/contributors.svg?width=890&button=false" /></a>
## Financial Contributors
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/readme-md-generator/contribute)]
### Individuals
<a href="https://opencollective.com/readme-md-generator"><img src="https://opencollective.com/readme-md-generator/individuals.svg?width=890"></a>
### Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/readme-md-generator/contribute)]
<a href="https://opencollective.com/readme-md-generator/organization/0/website"><img src="https://opencollective.com/readme-md-generator/organization/0/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/1/website"><img src="https://opencollective.com/readme-md-generator/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/2/website"><img src="https://opencollective.com/readme-md-generator/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/3/website"><img src="https://opencollective.com/readme-md-generator/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/4/website"><img src="https://opencollective.com/readme-md-generator/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/5/website"><img src="https://opencollective.com/readme-md-generator/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/6/website"><img src="https://opencollective.com/readme-md-generator/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/7/website"><img src="https://opencollective.com/readme-md-generator/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/8/website"><img src="https://opencollective.com/readme-md-generator/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/readme-md-generator/organization/9/website"><img src="https://opencollective.com/readme-md-generator/organization/9/avatar.svg"></a>
## 🤝 Contributing

@@ -93,37 +120,2 @@

## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
<table>
<tr>
<td align="center"><a href="https://www.franck-abgrall.me/"><img src="https://avatars3.githubusercontent.com/u/9840435?v=4" width="75px;" alt="Franck Abgrall"/><br /><sub><b>Franck Abgrall</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=kefranabg" title="Code">💻</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=kefranabg" title="Documentation">📖</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=kefranabg" title="Tests">⚠️</a> <a href="#question-kefranabg" title="Answering Questions">💬</a> <a href="https://github.com/kefranabg/readme-md-generator/issues?q=author%3Akefranabg" title="Bug reports">🐛</a> <a href="#maintenance-kefranabg" title="Maintenance">🚧</a></td>
<td align="center"><a href="http://yann-bertrand.fr/"><img src="https://avatars0.githubusercontent.com/u/5855339?v=4" width="75px;" alt="Yann Bertrand"/><br /><sub><b>Yann Bertrand</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=yannbertrand" title="Code">💻</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=yannbertrand" title="Tests">⚠️</a></td>
<td align="center"><a href="https://nikx.io"><img src="https://avatars2.githubusercontent.com/u/3141005?v=4" width="75px;" alt="Nik"/><br /><sub><b>Nik</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=NikxDa" title="Code">💻</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=NikxDa" title="Documentation">📖</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=NikxDa" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/detectivequack"><img src="https://avatars3.githubusercontent.com/u/7631054?v=4" width="75px;" alt="Saffaanh Soobratty"/><br /><sub><b>Saffaanh Soobratty</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=detectivequack" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/samit4me"><img src="https://avatars3.githubusercontent.com/u/3248531?v=4" width="75px;" alt="Samuel Sharpe"/><br /><sub><b>Samuel Sharpe</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=samit4me" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/apatrascu"><img src="https://avatars3.githubusercontent.com/u/1193770?v=4" width="75px;" alt="Alecsandru Patrascu"/><br /><sub><b>Alecsandru Patrascu</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=apatrascu" title="Code">💻</a></td>
<td align="center"><a href="http://milad.nekofar.com"><img src="https://avatars3.githubusercontent.com/u/147401?v=4" width="75px;" alt="Milad Nekofar"/><br /><sub><b>Milad Nekofar</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=nekofar" title="Code">💻</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=nekofar" title="Tests">⚠️</a> <a href="#ideas-nekofar" title="Ideas, Planning, & Feedback">🤔</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/hgb123"><img src="https://avatars0.githubusercontent.com/u/18468577?v=4" width="75px;" alt="Bao Ho"/><br /><sub><b>Bao Ho</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=hgb123" title="Code">💻</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=hgb123" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/zizizi17"><img src="https://avatars0.githubusercontent.com/u/10571073?v=4" width="75px;" alt="Sasha Semanyuk"/><br /><sub><b>Sasha Semanyuk</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=zizizi17" title="Code">💻</a></td>
<td align="center"><a href="http://slashgear.github.io/"><img src="https://avatars0.githubusercontent.com/u/6263857?v=4" width="75px;" alt="Antoine Caron"/><br /><sub><b>Antoine Caron</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=Slashgear" title="Code">💻</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=Slashgear" title="Tests">⚠️</a> <a href="#ideas-Slashgear" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/SwapnikKatkoori"><img src="https://avatars2.githubusercontent.com/u/40907690?v=4" width="75px;" alt="Swapnik Katkoori"/><br /><sub><b>Swapnik Katkoori</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=SwapnikKatkoori" title="Code">💻</a></td>
<td align="center"><a href="https://errorna.me"><img src="https://avatars2.githubusercontent.com/u/6669733?v=4" width="75px;" alt="Thibaud Courtoison"/><br /><sub><b>Thibaud Courtoison</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=Errorname" title="Code">💻</a></td>
<td align="center"><a href="https://briandouglas.me/"><img src="https://avatars2.githubusercontent.com/u/5713670?v=4" width="75px;" alt="Brian Douglas"/><br /><sub><b>Brian Douglas</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=bdougie" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/kushagra-ag"><img src="https://avatars2.githubusercontent.com/u/31826645?v=4" width="75px;" alt="Kushagra"/><br /><sub><b>Kushagra</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=kushagra-ag" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/david-dasilva"><img src="https://avatars3.githubusercontent.com/u/372391?v=4" width="75px;" alt="David Da Silva"/><br /><sub><b>David Da Silva</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=david-dasilva" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/tbetous"><img src="https://avatars3.githubusercontent.com/u/4435536?v=4" width="75px;" alt="Thomas Betous"/><br /><sub><b>Thomas Betous</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=tbetous" title="Code">💻</a></td>
<td align="center"><a href="https://twitter.com/LucasHProcopio"><img src="https://avatars1.githubusercontent.com/u/26358642?v=4" width="75px;" alt="Lucas Henrique Procopio"/><br /><sub><b>Lucas Henrique Procopio</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=LucasProcopio" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/anku255"><img src="https://avatars1.githubusercontent.com/u/22813027?v=4" width="75px;" alt="Ankit Tiwari"/><br /><sub><b>Ankit Tiwari</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=anku255" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Zenigata"><img src="https://avatars1.githubusercontent.com/u/1022393?v=4" width="75px;" alt="Johan Bonneau"/><br /><sub><b>Johan Bonneau</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=Zenigata" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/hgwood/blog"><img src="https://avatars0.githubusercontent.com/u/1656170?v=4" width="75px;" alt="Hugo Wood"/><br /><sub><b>Hugo Wood</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=hgwood" title="Code">💻</a></td>
</tr>
</table>
<!-- ALL-CONTRIBUTORS-LIST:END -->
## Author

@@ -130,0 +122,0 @@

@@ -21,3 +21,3 @@ const inquirer = require('inquirer')

/**
* Ask user if he wants overwrite the existed README
* Ask users if they want to overwrite the existing README
*/

@@ -24,0 +24,0 @@ module.exports = async () => {

@@ -19,3 +19,3 @@ const inquirer = require('inquirer')

const answersContext = useDefaultAnswers
? utils.getDefaultAnswers(questions)
? await utils.getDefaultAnswers(questions)
: await inquirer.prompt(questions)

@@ -22,0 +22,0 @@

@@ -7,2 +7,4 @@ /**

module.exports = context => {
const cleanBadgeText = text => text.replace(/-/g, '--').replace(/_/g, '__')
// Why doing this?

@@ -13,7 +15,9 @@ // See https://github.com/kefranabg/readme-md-generator/pull/141

.replace(/_/g, '__')
const projectVersion = cleanBadgeText(context.projectVersion)
return {
...context,
licenseName
licenseName,
projectVersion
}
}
const cleanContext = require('./clean-context')
describe('cleanContext', () => {
it('should replace licenseName - and _ characters by -- and __', () => {
const context = { licenseName: 'Apache-2_0' }
const cleanedContext = { licenseName: 'Apache--2__0' }
it('should replace licenseName and projectVersion - and _ characters by -- and __', () => {
const context = {
licenseName: 'Apache-2_0',
projectVersion: '1.0_0-alpha'
}
const cleanedContext = {
licenseName: 'Apache--2__0',
projectVersion: '1.0__0--alpha'
}

@@ -8,0 +14,0 @@ const result = cleanContext(context)

@@ -10,3 +10,4 @@ const isNil = require('lodash/isNil')

getProjectName,
getAuthorWebsiteFromGithubAPI
getAuthorWebsiteFromGithubAPI,
getPackageManagerFromLockFile
} = require('./utils')

@@ -103,2 +104,5 @@

const getContributingUrlFromRepositoryUrl = repositoryUrl =>
`${repositoryUrl}/blob/master/CONTRIBUTING.md`
/**

@@ -130,2 +134,5 @@ * Get project author name from package.json

const isJSProject = !!packageJson
const packageManager = isJSProject
? getPackageManagerFromLockFile()
: undefined
const name = getProjectName(packageJson)

@@ -138,9 +145,10 @@ const description = get(packageJson, 'description', undefined)

const homepage = get(packageJson, 'homepage', undefined)
const usage = has(packageJson, 'scripts.start') ? 'npm run start' : undefined
const testCommand = has(packageJson, 'scripts.test')
? 'npm run test'
: undefined
const hasStartCommand = has(packageJson, 'scripts.start')
const hasTestCommand = has(packageJson, 'scripts.test')
const repositoryUrl = await getReposUrl(packageJson)
const contributingUrl = await getReposIssuesUrl(packageJson)
const issuesUrl = await getReposIssuesUrl(packageJson)
const isGithubRepos = isGithubRepository(repositoryUrl)
const contributingUrl = repositoryUrl
? getContributingUrlFromRepositoryUrl(repositoryUrl)
: undefined
const documentationUrl = isGithubRepos

@@ -169,2 +177,3 @@ ? getReadmeUrlFromGithubRepositoryUrl(repositoryUrl)

repositoryUrl,
issuesUrl,
contributingUrl,

@@ -177,5 +186,6 @@ githubUsername,

isGithubRepos,
usage,
testCommand,
isJSProject
hasStartCommand,
hasTestCommand,
isJSProject,
packageManager
}

@@ -182,0 +192,0 @@ }

@@ -14,3 +14,6 @@ const ora = require('ora')

getProjectName: jest.fn(() => 'readme-md-generator'),
getAuthorWebsiteFromGithubAPI: jest.fn(() => 'https://www.franck-abgrall.me/')
getAuthorWebsiteFromGithubAPI: jest.fn(
() => 'https://www.franck-abgrall.me/'
),
getPackageManagerFromLockFile: jest.fn(() => 'yarn')
}))

@@ -74,3 +77,3 @@

contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
authorWebsite: 'https://www.franck-abgrall.me/',

@@ -89,4 +92,6 @@ githubUsername: 'kefranabg',

isJSProject: true,
usage: undefined,
testCommand: undefined
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
hasStartCommand: false,
hasTestCommand: false,
packageManager: 'yarn'
})

@@ -129,3 +134,3 @@ })

contributingUrl:
'https://gitlab.com/kefranabg/readme-md-generator/issues',
'https://gitlab.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
homepage: 'https://gitlab.com/kefranabg/readme-md-generator',

@@ -143,4 +148,6 @@ githubUsername: undefined,

isJSProject: true,
usage: undefined,
testCommand: undefined
issuesUrl: 'https://gitlab.com/kefranabg/readme-md-generator/issues',
hasStartCommand: false,
hasTestCommand: false,
packageManager: 'yarn'
})

@@ -164,3 +171,3 @@ })

contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
homepage: undefined,

@@ -177,4 +184,5 @@ githubUsername: 'kefranabg',

isJSProject: false,
usage: undefined,
testCommand: undefined
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
hasStartCommand: false,
hasTestCommand: false
})

@@ -197,4 +205,5 @@ })

repositoryUrl: 'https://gitlab.com/kefranabg/readme-md-generator',
authorWebsite: undefined,
contributingUrl:
'https://gitlab.com/kefranabg/readme-md-generator/issues',
'https://gitlab.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
homepage: undefined,

@@ -208,4 +217,5 @@ githubUsername: undefined,

isJSProject: false,
usage: undefined,
testCommand: undefined
issuesUrl: 'https://gitlab.com/kefranabg/readme-md-generator/issues',
hasStartCommand: false,
hasTestCommand: false
})

@@ -238,4 +248,5 @@ })

isJSProject: false,
usage: undefined,
testCommand: undefined
testCommand: undefined,
hasStartCommand: false,
hasTestCommand: false
})

@@ -278,3 +289,3 @@ })

contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
homepage: 'https://github.com/kefranabg/readme-md-generator',

@@ -294,4 +305,6 @@ githubUsername: 'kefranabg',

isJSProject: true,
usage: undefined,
testCommand: undefined
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
hasStartCommand: false,
hasTestCommand: false,
packageManager: 'yarn'
})

@@ -339,3 +352,3 @@ })

contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
githubUsername: 'kefranabg',

@@ -354,7 +367,70 @@ authorWebsite: 'https://www.franck-abgrall.me/',

isJSProject: true,
usage: undefined,
testCommand: undefined
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
hasStartCommand: false,
hasTestCommand: false,
packageManager: 'yarn'
})
})
it('should return correct infos when lock file is found', async () => {
const packgeJsonInfos = {
name: 'readme-md-generator',
version: '0.1.3',
description: 'CLI that generates beautiful README.md files.',
author: 'Franck Abgrall',
license: 'MIT',
homepage: 'https://github.com/kefranabg/readme-md-generator',
repository: {
type: 'git',
url: 'git+https://github.com/kefranabg/readme-md-generator.git'
},
bugs: {
url: 'https://github.com/kefranabg/readme-md-generator/issues'
},
engines: {
npm: '>=5.5.0',
node: '>=9.3.0'
},
scripts: {
start: 'node src/index.js',
test: 'jest'
}
}
utils.getPackageJson.mockReturnValueOnce(Promise.resolve(packgeJsonInfos))
utils.getPackageManagerFromLockFile.mockReturnValueOnce('yarn')
childProcess.execSync.mockReturnValue(
'https://github.com/kefranabg/readme-md-generator.git'
)
const projectInfos = await getProjectInfos()
expect(projectInfos).toEqual({
name: 'readme-md-generator',
description: 'CLI that generates beautiful README.md files.',
version: '0.1.3',
author: 'Franck Abgrall',
repositoryUrl: 'https://github.com/kefranabg/readme-md-generator',
homepage: 'https://github.com/kefranabg/readme-md-generator',
contributingUrl:
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
authorWebsite: 'https://www.franck-abgrall.me/',
githubUsername: 'kefranabg',
engines: {
npm: '>=5.5.0',
node: '>=9.3.0'
},
licenseName: 'MIT',
licenseUrl:
'https://github.com/kefranabg/readme-md-generator/blob/master/LICENSE',
documentationUrl:
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: true,
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
hasStartCommand: true,
hasTestCommand: true,
packageManager: 'yarn'
})
})
})
})

@@ -0,5 +1,8 @@

const { cleanSocialNetworkUsername } = require('../utils')
module.exports = () => ({
type: 'input',
message: '❤️ Patreon username (use empty value to skip)',
name: 'authorPatreonUsername'
name: 'authorPatreonUsername',
filter: cleanSocialNetworkUsername
})

@@ -10,5 +10,6 @@ const askPatreonUsername = require('./author-patreon')

message: '❤️ Patreon username (use empty value to skip)',
name: 'authorPatreonUsername'
name: 'authorPatreonUsername',
filter: expect.any(Function)
})
})
})

@@ -6,2 +6,3 @@ /* eslint-disable global-require */

askProjectDescription: require('./project-description'),
askPackageManager: require('./package-manager'),
askProjectHomepage: require('./project-homepage'),

@@ -14,2 +15,3 @@ askProjectDemoUrl: require('./project-demo-url'),

askAuthorTwitter: require('./author-twitter'),
askAuthorLinkedIn: require('./author-linkedin'),
askAuthorPatreon: require('./author-patreon'),

@@ -19,3 +21,4 @@ askProjectPrerequisites: require('./project-prerequisites'),

askLicenseUrl: require('./license-url'),
askContributing: require('./contributing'),
askIssuesUrl: require('./issues-url'),
askContributingUrl: require('./contributing-url'),
askInstallCommand: require('./install-command'),

@@ -22,0 +25,0 @@ askUsage: require('./usage'),

@@ -11,2 +11,3 @@ const questions = require('./')

'askProjectDescription',
'askPackageManager',
'askProjectHomepage',

@@ -19,2 +20,3 @@ 'askProjectDemoUrl',

'askAuthorTwitter',
'askAuthorLinkedIn',
'askAuthorPatreon',

@@ -24,3 +26,4 @@ 'askProjectPrerequisites',

'askLicenseUrl',
'askContributing',
'askIssuesUrl',
'askContributingUrl',
'askInstallCommand',

@@ -27,0 +30,0 @@ 'askUsage',

@@ -0,1 +1,3 @@

const isNil = require('lodash/isNil')
module.exports = projectInfos => ({

@@ -5,3 +7,6 @@ type: 'input',

name: 'installCommand',
default: projectInfos.isJSProject ? 'npm install' : undefined
default: answers => {
const packageManager = answers.packageManager || projectInfos.packageManager
return isNil(packageManager) ? undefined : `${packageManager} install`
}
})
const askInstallCommand = require('./install-command')
describe('askInstallCommand', () => {
it('should return correct question format when project lang is js', () => {
const projectInfos = { isJSProject: true }
const result = askInstallCommand(projectInfos)
it('should return correct question format', () => {
const result = askInstallCommand()
expect(result).toEqual(
expect.objectContaining({
type: 'input',
message: '📦 Install command (use empty value to skip)',
name: 'installCommand'
})
)
})
expect(result).toEqual({
type: 'input',
message: '📦 Install command (use empty value to skip)',
name: 'installCommand',
default: 'npm install'
it('should return undefined default answer when package manager is not defined', () => {
const projectInfos = {}
const result = askInstallCommand(projectInfos).default({
packageManager: undefined
})
expect(result).toBeUndefined()
})
it('should return correct question format when project lang is js', () => {
const projectInfos = { isJSProject: false }
const result = askInstallCommand(projectInfos)
it('should return correct default answer when package manager is defined', () => {
const projectInfos = {}
expect(result).toEqual({
type: 'input',
message: '📦 Install command (use empty value to skip)',
name: 'installCommand',
default: undefined
const result = askInstallCommand(projectInfos).default({
packageManager: 'yarn'
})
expect(result).toEqual('yarn install')
})
})

@@ -0,1 +1,3 @@

const isNil = require('lodash/isNil')
module.exports = projectInfos => ({

@@ -5,3 +7,8 @@ type: 'input',

name: 'testCommand',
default: projectInfos.testCommand
default: answers => {
const packageManager = answers.packageManager || projectInfos.packageManager
return projectInfos.hasTestCommand && !isNil(packageManager)
? `${packageManager} run test`
: undefined
}
})

@@ -5,14 +5,41 @@ const askTestCommand = require('./test-command')

it('should return correct question format', () => {
const testCommand = 'npm run test'
const projectInfos = { testCommand }
const result = askTestCommand()
expect(result).toEqual(
expect.objectContaining({
type: 'input',
message: '✅ Test command (use empty value to skip)',
name: 'testCommand'
})
)
})
const result = askTestCommand(projectInfos)
it('should return undefined default answer when package manager does not exists', () => {
const projectInfos = { hasTestCommand: true }
expect(result).toEqual({
type: 'input',
message: '✅ Test command (use empty value to skip)',
name: 'testCommand',
default: testCommand
const result = askTestCommand(projectInfos).default({
packageManager: undefined
})
expect(result).toBeUndefined()
})
it('should return undefined default answer when test command does not exists', () => {
const projectInfos = { hasTestCommand: false }
const result = askTestCommand(projectInfos).default({
packageManager: 'yarn'
})
expect(result).toBeUndefined()
})
it('should return correct default answer when start command and package manager exists', () => {
const projectInfos = { hasTestCommand: true }
const result = askTestCommand(projectInfos).default({
packageManager: 'yarn'
})
expect(result).toEqual('yarn run test')
})
})

@@ -0,1 +1,3 @@

const isNil = require('lodash/isNil')
module.exports = projectInfos => ({

@@ -5,3 +7,8 @@ type: 'input',

name: 'usage',
default: projectInfos.usage
default: answers => {
const packageManager = answers.packageManager || projectInfos.packageManager
return projectInfos.hasStartCommand && !isNil(packageManager)
? `${packageManager} run start`
: undefined
}
})

@@ -5,14 +5,42 @@ const askUsage = require('./usage')

it('should return correct question format', () => {
const usage = 'npm start'
const projectInfos = { usage }
const result = askUsage()
const result = askUsage(projectInfos)
expect(result).toEqual(
expect.objectContaining({
type: 'input',
message: '🚀 Usage command or instruction (use empty value to skip)',
name: 'usage'
})
)
})
expect(result).toEqual({
type: 'input',
message: '🚀 Usage command or instruction (use empty value to skip)',
name: 'usage',
default: usage
it('should return undefined default answer when package manager does not exists', () => {
const projectInfos = { hasStartCommand: true }
const result = askUsage(projectInfos).default({
packageManager: undefined
})
expect(result).toBeUndefined()
})
it('should return undefined default answer when start command does not exists', () => {
const projectInfos = { hasStartCommand: false }
const result = askUsage(projectInfos).default({
packageManager: 'yarn'
})
expect(result).toBeUndefined()
})
it('should return correct default answer when start command and packageManager exists', () => {
const projectInfos = { hasStartCommand: true }
const result = askUsage(projectInfos).default({
packageManager: 'yarn'
})
expect(result).toEqual('yarn run start')
})
})

@@ -100,2 +100,3 @@ const fs = require('fs')

authorTwitterUsername: 'FranckAbgrall',
authorLinkedInUsername: 'franckabgrall',
authorPatreonUsername: 'FranckAbgrall',

@@ -105,4 +106,5 @@ licenseName: 'MIT',

'https://github.com/kefranabg/readme-md-generator/blob/master/LICENSE',
issuesUrl: 'https://github.com/kefranabg/readme-md-generator/issues',
contributingUrl:
'https://github.com/kefranabg/readme-md-generator/issues',
'https://github.com/kefranabg/readme-md-generator/blob/master/CONTRIBUTING.md',
installCommand: 'npm install',

@@ -109,0 +111,0 @@ usage: 'npm start',

@@ -8,2 +8,4 @@ const loadJsonFile = require('load-json-file')

const fetch = require('node-fetch')
const fs = require('fs')
const escapeMarkdown = require('markdown-escape')
const { execSync } = require('child_process')

@@ -77,3 +79,3 @@

*/
const getDefaultAnswer = (question, answersContext) => {
const getDefaultAnswer = async (question, answersContext) => {
if (question.when && !question.when(answersContext)) return undefined

@@ -83,3 +85,5 @@

case 'input':
return question.default || ''
return typeof question.default === 'function'
? question.default(answersContext)
: question.default || ''
case 'checkbox':

@@ -115,17 +119,20 @@ return question.choices

const getDefaultAnswers = questions =>
questions.reduce(
(answersContext, question) => ({
questions.reduce(async (answersContextProm, question) => {
const answersContext = await answersContextProm
return {
...answersContext,
[question.name]: getDefaultAnswer(question, answersContext)
}),
{}
)
[question.name]: await getDefaultAnswer(question, answersContext)
}
}, Promise.resolve({}))
/**
* Clean social network username by removing the @ prefix
* Clean social network username by removing the @ prefix and
* escaping markdown characters
*
* @param input social network username input
* @returns {*} input without the prefix
* @returns {*} escaped input without the prefix
*/
const cleanSocialNetworkUsername = input => input.replace(/^@/, '')
const cleanSocialNetworkUsername = input =>
escapeMarkdown(input.replace(/^@/, ''))

@@ -152,2 +159,31 @@ /**

/**
* Returns a boolean whether a file exists or not
*
* @param {String} filepath
* @returns {Boolean}
*/
const doesFileExist = filepath => {
try {
return fs.existsSync(filepath)
} catch (err) {
return false
}
}
/**
* Returns the package manager from the lock file
*
* @returns {String} packageManger or undefined
*/
const getPackageManagerFromLockFile = () => {
const packageLockExists = doesFileExist('package-lock.json')
const yarnLockExists = doesFileExist('yarn.lock')
if (packageLockExists && yarnLockExists) return undefined
if (packageLockExists) return 'npm'
if (yarnLockExists) return 'yarn'
return undefined
}
module.exports = {

@@ -163,3 +199,5 @@ getPackageJson,

isProjectAvailableOnNpm,
getAuthorWebsiteFromGithubAPI
getAuthorWebsiteFromGithubAPI,
getPackageManagerFromLockFile,
doesFileExist
}

@@ -6,2 +6,3 @@ const loadJsonFile = require('load-json-file')

const fetch = require('node-fetch')
const fs = require('fs')
const { isNil } = require('lodash')

@@ -22,3 +23,5 @@

isProjectAvailableOnNpm,
getAuthorWebsiteFromGithubAPI
getAuthorWebsiteFromGithubAPI,
doesFileExist,
getPackageManagerFromLockFile
} = require('./utils')

@@ -29,2 +32,3 @@

jest.mock('node-fetch')
jest.mock('fs')

@@ -52,3 +56,3 @@ describe('utils', () => {

expect(result).toBe(undefined)
expect(result).toBeUndefined()
})

@@ -92,3 +96,3 @@ })

const packageJson = { name: projectName }
getReposName.sync.mockReturnValue('readme-md-generator')
getReposName.sync.mockReturnValueOnce('readme-md-generator')

@@ -104,3 +108,3 @@ const result = getProjectName(packageJson)

const packageJson = undefined
getReposName.sync.mockReturnValue('readme-md-generator')
getReposName.sync.mockReturnValueOnce('readme-md-generator')

@@ -129,9 +133,9 @@ const result = getProjectName(packageJson)

describe('getDefaultAnswer', () => {
it('should handle input prompts correctly', () => {
it('should handle input prompts correctly', async () => {
const question = { type: 'input', default: 'default' }
const result = getDefaultAnswer(question)
const result = await getDefaultAnswer(question)
expect(result).toEqual(question.default)
})
it('should handle choices prompts correctly', () => {
it('should handle choices prompts correctly', async () => {
const value = { name: 'name', value: 'value' }

@@ -142,3 +146,3 @@ const question = {

}
const result = getDefaultAnswer(question)
const result = await getDefaultAnswer(question)

@@ -148,5 +152,5 @@ expect(result).toEqual([value])

it('should return empty string for non-defaulted fields', () => {
it('should return empty string for non-defaulted fields', async () => {
const question = { type: 'input' }
const result = getDefaultAnswer(question)
const result = await getDefaultAnswer(question)

@@ -156,5 +160,5 @@ expect(result).toEqual('')

it('should return undefined for invalid types', () => {
it('should return undefined for invalid types', async () => {
const question = { type: 'invalid' }
const result = getDefaultAnswer(question)
const result = await getDefaultAnswer(question)

@@ -164,3 +168,3 @@ expect(result).toEqual(undefined)

it('should return undefined if when function is defined and return false', () => {
it('should return undefined if when function is defined and return false', async () => {
const answersContext = {}

@@ -172,3 +176,3 @@ const question = {

const result = getDefaultAnswer(question, answersContext)
const result = await getDefaultAnswer(question, answersContext)

@@ -192,3 +196,3 @@ expect(result).toEqual(undefined)

it('should return correct value if when function is defined and return true', () => {
it('should return correct value if when function is defined and return true', async () => {
const answersContext = { licenseUrl: 'licenseUrl' }

@@ -201,3 +205,3 @@ const question = {

const result = getDefaultAnswer(question, answersContext)
const result = await getDefaultAnswer(question, answersContext)

@@ -209,3 +213,3 @@ expect(result).toEqual('default')

describe('getDefaultAnswers', () => {
it('should return default answers from questions', () => {
it('should return default answers from questions', async () => {
const questions = [

@@ -224,3 +228,3 @@ {

const result = getDefaultAnswers(questions)
const result = await getDefaultAnswers(questions)

@@ -236,8 +240,17 @@ expect(result).toEqual({

it('should remove prefixed @', () => {
expect(cleanSocialNetworkUsername('@Slashgear_')).toEqual('Slashgear_')
expect(cleanSocialNetworkUsername('@Slashgear')).toEqual('Slashgear')
})
it('should return the same string when string is not prefixed', () => {
expect(cleanSocialNetworkUsername('Slashgear_')).toEqual('Slashgear_')
it('should escape markdown characters', () => {
expect(cleanSocialNetworkUsername('Slashgear__')).toEqual(
'Slashgear\\_\\_'
)
expect(cleanSocialNetworkUsername('Slashgear**')).toEqual(
'Slashgear\\*\\*'
)
})
it('should return the same string when string is not prefixed or contains markdown chars', () => {
expect(cleanSocialNetworkUsername('Slashgear')).toEqual('Slashgear')
})
})

@@ -275,2 +288,59 @@

})
describe('doesFileExist', () => {
it('should return true when file exists for a given path', () => {
fs.existsSync.mockReturnValueOnce(true)
expect(doesFileExist('./file-path')).toBe(true)
})
it('should return false when file does not exist for a given path', () => {
fs.existsSync.mockReturnValueOnce(false)
expect(doesFileExist('./file-path')).toBe(false)
})
it('should return false if fs.existsSync throws an error', () => {
fs.existsSync.mockImplementationOnce(() => {
throw new Error('ERROR')
})
expect(doesFileExist('./file-path')).toBe(false)
})
})
describe('getPackageManagerFromLockFile', () => {
it('should return npm if only package-lock.json exists', () => {
fs.existsSync.mockImplementation(
filePath => filePath === 'package-lock.json'
)
const result = getPackageManagerFromLockFile()
expect(result).toEqual('npm')
})
it('should return yarn if only yarn.lock exists', () => {
fs.existsSync.mockImplementation(filePath => filePath === 'yarn.lock')
const result = getPackageManagerFromLockFile()
expect(result).toEqual('yarn')
})
it('should return undefined if only yarn.lock and package-lock.json exists', () => {
fs.existsSync.mockImplementation(
filePath => filePath === 'yarn.lock' || filePath === 'package-lock.json'
)
const result = getPackageManagerFromLockFile()
expect(result).toBeUndefined()
})
it('should return undefined if only no lock file exists', () => {
fs.existsSync.mockImplementation(() => false)
const result = getPackageManagerFromLockFile()
expect(result).toBeUndefined()
})
})
})

@@ -84,4 +84,7 @@ # Welcome to <%= projectName %> 👋

<% } -%>
<% if (authorLinkedInUsername) { -%>
* LinkedIn: [@<%= authorLinkedInUsername %>](https://linkedin.com/in/<%= authorLinkedInUsername %>)
<% } -%>
<% if (contributingUrl) { -%>
<% } -%>
<% if (issuesUrl) { -%>

@@ -92,3 +95,3 @@ ## 🤝 Contributing

Feel free to check [issues page](<%= contributingUrl %>).
Feel free to check [issues page](<%= issuesUrl %>). <%= contributingUrl ? `You can also take a look at the [contributing guide](${contributingUrl}).` : '' %>
<% } -%>

@@ -95,0 +98,0 @@

@@ -96,8 +96,11 @@ <h1 align="center">Welcome to <%= projectName %> 👋</h1>

<% } -%>
<% if (authorLinkedInUsername) { -%>
* LinkedIn: [@<%= authorLinkedInUsername %>](https://linkedin.com/in/<%= authorLinkedInUsername %>)
<% } -%>
<% if (contributingUrl) { -%>
<% } -%>
<% if (issuesUrl) { -%>
## 🤝 Contributing
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](<%= contributingUrl %>).
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](<%= issuesUrl %>). <%= contributingUrl ? `You can also take a look at the [contributing guide](${contributingUrl}).` : '' %>
<% } -%>

@@ -104,0 +107,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc