Skip to content

Commit

Permalink
add readme template, ejslint, looots of questions
Browse files Browse the repository at this point in the history
  • Loading branch information
elyseholladay committed Mar 1, 2019
1 parent 275e311 commit 6b93cf3
Show file tree
Hide file tree
Showing 5 changed files with 463 additions and 46 deletions.
16 changes: 8 additions & 8 deletions __tests__/app.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use strict';
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
"use strict";
const path = require("path");
const assert = require("yeoman-assert");
const helpers = require("yeoman-test");

describe('generator-standard-docs-templates:app', () => {
describe("generator-standard-docs-templates:app", () => {
beforeAll(() => {
return helpers
.run(path.join(__dirname, '../generators/app'))
.run(path.join(__dirname, "../generators/app"))
.withPrompts({ someAnswer: true });
});

it('creates files', () => {
assert.file(['dummyfile.txt']);
it("creates files", () => {
assert.file(["README.md"]);
});
});
109 changes: 95 additions & 14 deletions generators/app/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/* eslint-disable capitalized-comments */
/* eslint-disable lines-between-class-members */
var Generator = require("yeoman-generator");
var chalk = require("chalk");

module.exports = class extends Generator {
constructor(args, opts) {
Expand All @@ -13,30 +10,114 @@ module.exports = class extends Generator {
this.userAnswers = await this.prompt([
{
type: "input",
name: "repoName",
name: "projectName",
message: "What is your project's name?",
default: this.appname // Defaults to current folder name
// TODO: can we check to see if this matches the repo name, and fail if it doesn't? Do we _want_ to do that?
default: this.projectName // Defaults to current folder name
},
{
type: "input",
name: "shortDescription",
message: "What is a short, one-sentence description of this package?",
validate: x => x.length > 0 ? true : "Providing a short description is required. Don't worry, you can always edit it later."
validate: x =>
x.length > 0
? true
: "Providing a short description is required. Don't worry, you can always edit it later."
},
{
name: "banner",
message: "Do you have a banner image?",
type: "confirm",
default: false
},
{
name: "bannerPath",
message:
"What is the local file path to the banner image? For example: 'images/banner.jpg'",
type: "input",
when: answers => answers.banner
},
{
name: "badges",
message: "Do you want badges?",
type: "confirm",
default: false
},
{
name: "install",
message:
"Does installing this package have dev environment Prerequisites or package Dependencies?",
type: "list",
choices: ["None", "Prerequisites", "Dependencies"],
default: 0
},
{
name: "background",
message: "Do you need a Background section?",
type: "confirm",
default: false
},
{
name: "security",
message: "Do you need a prioritized Security section?",
type: "confirm",
default: false
},
{
name: "CLI",
message: "Do you need an CLI section?",
type: "confirm",
default: false
},
{
name: "extras",
message: "Do you need room for extra sections?",
type: "confirm",
default: false
},
{
name: "API",
message: "Do you need an API section?",
type: "confirm",
default: false
},
{
name: "maintainers",
message:
"What is the handle (GitHub/GitLab account) of a primary maintainer? @",
type: "input"
},
{
name: "oss",
message: "Is this an Open Source project?",
type: "confirm",
default: true
},
{
name: "prs",
message: "Are PRs and contributions accepted on this project?",
type: "confirm",
default: true
},
{
name: "license",
message: "What license do you want to use?",
type: "list",
choices: [
"MIT (recommended)",
"Apache2",
"ISC",
"None (not recommended)"
],
default: 0
}
]);
}

// configuring - save configs and create files like .editorconfig //#endregion

writing() {
this.fs.copyTpl(
this.templatePath('README.md'),
this.destinationPath('README.md'),
this.templatePath("README.md"),
this.destinationPath("README.md"),
this.userAnswers
);
}

// install, if anything
// end
};
112 changes: 110 additions & 2 deletions generators/app/templates/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,111 @@
# <%= repoName %>
# <%= projectName %>

> <%= shortDescription %>
> <%= shortDescription %>
<% if (banner) { %>
![banner](<%= bannerPath %>)
<% } %>

<% if (badges) { %>
TODO: Badges go here, if any.
<% } %>

TODO: Write an overview of the tool or package. This section should describe the tool in broad terms. A list of features or a description of the tool's value or selling points is most helpful. This section should answer the question, "Why should I care about or use this tool?"

Remember, the goal of the README is to help a consumer understand if this package will fulfill their need. Each section of the README should provide more detailed information, starting here with the broadest information, and moving deeper into specific details, such as usage, installation, history, or code examples.

Ideally, someone who's slightly familiar with this tool should be able to refresh their memory without further reading. The table of contents below should allow them to jump directly to relevant sections if necessary.

## Table of Contents

<% if (background) { %>* [Background](#background)<% } %>
<% if (security) { %>* [Security](#security)<% } %>
* [Install](#install)
* [Usage](#usage)
<% if (extras) { %>* [Extra Sections](#extra-sections)<% } %>
<% if (API) { %>* [API](#api)<% } %>
* [Releases](#releases)
* [Maintainers](#maintainers)
* [Contributing](#contributing)
<% if (license) { %>* [License](#license)<% } %>

<% if (background) { %>
## Background
This optional section can cover motivation for building the tool, domain specific knowledge that may be required, alternatives considered, or relevant historical knowledge. Be brief; this section should only be included if this information is important for a user of the tool to know before reading any other information.
<% } %>

<% if (security) { %>
## Security
This optional section should describe any important security concerns a user must know before continuing.
<% } %>

## Install
This required section should describe how to install this tool. Use code blocks to show installation instructions.

```
npm install this-package
```

<% if (!install) { %>
### Prerequisites
This optional section should describe any prerequisites or development environment dependencies. Prefer linking to existing documentation for environment setup or prerequisite package installation instructions.

### Dependencies
This optional section should describe any code or package dependencies required to use this tool. Prefer linking to existing documentation for installation instructions of dependencies.
<% } %>

## Usage
This required section should contain concise descriptions of how to use the tool, including code blocks illustrating common examples.

If available or relevant, point to a runnable file or demo app for the usage code.


```
module.exports = require('this-package')();
```

Briefly cover usage options that may affect usage, configurations, and other steps required to use the tool. If this section becomes extremely long, consider breaking it up into multiple files and linking them from this section.

Use the API section below for more detail.

<% if (CLI) { %>### CLI
If the tool has a CLI, add this optional section to describe CLI functionality.
<% } %>

<% if (extras) { %>## Extra Sections
Zero or more sections can be included after Usage but before API, each with their own H2 heading title. (This should not be called Extra Sections.)

Other sections might include: Configuration, Example or Skeleton App, Submodules, Security (if relevant but not important enough to be placed above), Polyfills/Fallbacks, Browser Support.
<% } %>

<% if (API) { %>## API
This required section should describe exported functions and objects. If using an external API generastor, point to an external API.md file. This can be the only item in the section, if present.
<% } %>

## Releases
This project follows [Semantic Versioning](https://semver.org/). Release versions can be found in the [Releases page](link/to/page) and on the [this-project website](link/to/url).

## Maintainers
This project is maintained by:
* [@<%= maintainers %>](<%= maintainers %>)

<% if (oss) { %>
If the project is Open Source, it should contain an [OSSMETADA file](https://github.com/Netflix/osstracker/blob/master/OSSMETADATA) containing machine readable that indicate the status of the project.
<% } %>

## Contributing
<% if (prs) { %>Contributions and PRs are accepted on this project.<% } %>

Please read the [CONTRIBUTING.md](CONTRIBUTING.md) for information on how to contribute.

To submit bugs or feature requests, [file an issue](link/to/issues). Describe responsiveness SLOs on this project, if any.

`this-project` is governed by the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).

### Local Development
Insert a link to a separate file containing detailed local development instructions.

## License
`this-project` is licensed under the [LICENSE_NAME](LICENSE.md).

<%= license %>
Loading

0 comments on commit 6b93cf3

Please sign in to comment.