-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add 'readme' generator, templates
- Loading branch information
Showing
5 changed files
with
276 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { resolve as pathResolve } from 'path'; | ||
import * as Base from 'yeoman-generator'; | ||
|
||
import yoOptionOrPrompt from '../shared/yo-option-or-prompt'; | ||
import prompting from './prompting'; | ||
|
||
export class RepoReadmeGenerator extends Base { | ||
|
||
answers: Base.Answers; | ||
context: {}; | ||
optionOrPrompt: any; | ||
|
||
constructor(args, opts) { | ||
super(args, opts); | ||
this.sourceRoot(pathResolve(__dirname, './templates')); | ||
} | ||
|
||
async initializing() { | ||
this.optionOrPrompt = yoOptionOrPrompt; | ||
} | ||
|
||
async prompting() { | ||
return prompting(this); | ||
} | ||
|
||
async configuring() { | ||
this.destinationRoot(this.answers.destination); | ||
} | ||
|
||
async writing() { | ||
this.fs.copyTpl( | ||
this.templatePath('README.md'), | ||
this.destinationPath('README.md'), | ||
this.context, | ||
); | ||
} | ||
|
||
} | ||
|
||
export default RepoReadmeGenerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { resolve as pathResolve } from 'path'; | ||
import YoRepoPrompts from '../shared/yo-repo-prompts'; | ||
|
||
export async function prompting(yo) { | ||
const { | ||
username, | ||
profileName, | ||
repositoryName, | ||
packageName, | ||
destination, | ||
description, | ||
license, | ||
authorName, | ||
authorEmail, | ||
authorUrl, | ||
repositoryUrl, | ||
homepageUrl, | ||
} = await new YoRepoPrompts(yo).prompt({ | ||
username: true, | ||
profileName: true, | ||
repositoryName: true, | ||
packageName: true, | ||
destination: true, | ||
description: true, | ||
license: true, | ||
authorName: true, | ||
authorEmail: true, | ||
authorUrl: true, | ||
repositoryUrl: true, | ||
homepageUrl: true, | ||
}); | ||
const features = []; | ||
while (true) { | ||
const { feature } = await yo.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'feature', | ||
message: 'Feature:', | ||
}, | ||
]); | ||
if (feature === '') break; | ||
features.push(feature); | ||
} | ||
const { installation, demo } = await yo.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'installation', | ||
message: 'Installation command:', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'demo', | ||
message: 'Demo URL:', | ||
}, | ||
]); | ||
const dependencies = []; | ||
while (true) { | ||
const { dependencyName } = await yo.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'dependencyName', | ||
message: 'Dependency:', | ||
}, | ||
]); | ||
if (dependencyName === '') break; | ||
const { dependencyUrl } = await yo.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'dependencyUrl', | ||
message: 'Dependency URL:', | ||
default: 'https://example.com', | ||
}, | ||
]); | ||
dependencies.push({ | ||
name: dependencyName, | ||
url: dependencyUrl, | ||
}); | ||
} | ||
yo.answers = { | ||
authorEmail, | ||
authorName, | ||
authorUrl, | ||
demo, | ||
dependencies, | ||
description, | ||
destination, | ||
features, | ||
homepageUrl, | ||
installation, | ||
license, | ||
packageName, | ||
profileName, | ||
repositoryName, | ||
repositoryUrl, | ||
username, | ||
}; | ||
yo.context = { ...yo.context, ...yo.answers }; | ||
} | ||
|
||
export default prompting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# <%= packageName %> | ||
|
||
> <%= description %> | ||
<!-- markdownlint-disable --> | ||
<% | ||
if (typeof badges !== 'undefined' && badges.length > 0) { | ||
%><% | ||
if (badges.indexOf('travis') !== -1) { | ||
%>[](https://travis-ci.com/<%= profile %>/<%= repositoryName %>) <% | ||
} %><% | ||
if (badges.indexOf('codecov') !== -1) { | ||
%>[](https://codecov.io/gh/<%= profile %>/<%= repositoryName %>) <% | ||
} %><% | ||
if (badges.indexOf('coveralls') !== -1) { | ||
%>[](https://coveralls.io/github/<%= profile %>/<%= repositoryName %>?branch=master) <% | ||
} %><% | ||
if (badges.indexOf('david') !== -1) { | ||
%>[](https://david-dm.org/<%= profile %>/<%= repositoryName %>) <% | ||
} %><% | ||
if (badges.indexOf('davidDev') !== -1) { | ||
%>[](https://david-dm.org/<%= profile %>/<%= repositoryName %>?type=dev) <% | ||
} %><% | ||
if (badges.indexOf('greenkeeper') !== -1) { | ||
%>[](https://greenkeeper.io/) <% | ||
} %><% | ||
if (badges.indexOf('commitizen') !== -1) { | ||
%>[](http://commitizen.github.io/cz-cli/) <% | ||
} %><% | ||
if (badges.indexOf('semantic-release') !== -1) { | ||
%>[](https://github.com/semantic-release/semantic-release) <% | ||
} %> | ||
|
||
<% | ||
if (badges.indexOf('npm') !== -1) { | ||
%>[](https://www.npmjs.com/package/<%= scopedEncoded || repositoryName %>) [](https://www.npmjs.com/package/<%= scopedEncoded || repositoryName %>) [](https://www.npmjs.com/package/<%= scopedEncoded || repositoryName %>) [](https://www.npmjs.com/package/<%= scopedEncoded || repositoryName %>) <% | ||
} %><% | ||
if (badges.indexOf('gitter') !== -1) { | ||
%>[](https://gitter.im/<%= profile %>?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) <% | ||
} %><% | ||
} %> | ||
|
||
## Table of Contents | ||
|
||
- [About](#about)<% if (typeof features !== 'undefined' && features.length > 0) { %> | ||
- [Features](#features)<% } %><% if (typeof demo !== 'undefined' && demo.length > 0) { %> | ||
- [Demo](#demo)<% } %><% if (typeof installation !== 'undefined' && installation.length > 0) { %> | ||
- [Install](#install)<% } %><% if (typeof dependencies !== 'undefined' && dependencies.length > 0) { %> | ||
- [Dependencies](#dependencies)<% } %> | ||
- [Usage](#usage) | ||
- [Support](#support) | ||
- [Contributing](#contributing) | ||
- [Changelog](#changelog) | ||
- [License](#license) | ||
|
||
--- | ||
|
||
## About the App <a id="about"></a> | ||
<% if (typeof features !== 'undefined' && features.length > 0) { %> | ||
### Features <a id="features"></a> | ||
|
||
<% for (var i in features) { %> | ||
- <%= features[i] %><% } %> | ||
<% } %><% if (typeof demo !== 'undefined' && demo.length > 0) { %> | ||
### Demo <a id="demo"></a> | ||
|
||
See a [demo](<%= demo %>) | ||
|
||
<% } %> | ||
<% if (typeof installation !== 'undefined' && installation.length > 0) { %> | ||
## Install <a id="install"></a> | ||
|
||
```sh | ||
<%= installation %> | ||
``` | ||
<% } %> | ||
<% if (typeof dependencies !== 'undefined' && dependencies.length > 0) { %> | ||
### Dependencies <a id="dependencies"></a> | ||
|
||
<% for (var i in dependencies) { %> | ||
- [<%= dependencies[i].name %>](<%= dependencies[i].url %>)<% } %> | ||
<% } %> | ||
|
||
## Usage <a id="usage"></a> | ||
|
||
```sh | ||
# CLI: | ||
``` | ||
|
||
> :point_up: _more instructions coming soon._ | ||
--- | ||
|
||
## Support <a id="support"></a> | ||
|
||
Submit an [issue](<%= repositoryUrl %>/issues/new) | ||
|
||
## Contributing <a id="contributing"></a> | ||
|
||
Contributions are always appreciated. Read [CONTRIBUTING.md](<%= repositoryUrl %>/blob/master/CONTRIBUTING.md) documentation to learn more. | ||
|
||
## Changelog <a id="changelog"></a> | ||
|
||
Release details are documented in the [CHANGELOG.md](<%= repositoryUrl %>/blob/master/CHANGELOG.md) file, and on the [GitHub Releases page](<%= repositoryUrl %>/releases). | ||
|
||
--- | ||
|
||
## License <a id="license"></a> | ||
|
||
[<%= license %> License](<%= repositoryUrl %>/blob/master/LICENSE) | ||
<% | ||
author_name = typeof authorName !== 'undefined' ? authorName : username | ||
author_url = typeof authorUrl !== 'undefined' ? authorUrl : repositoryUrl | ||
%> | ||
Copyright (c) <%= new Date().getFullYear() %> [<%= author_name %>](<%= author_url %>) |