readme template

This commit is contained in:
2020-05-11 11:33:34 +02:00
parent 8880a72560
commit be004c5e02
3 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,33 @@
/* eslint-disable max-len */
export function get_readme (
software: string,
description: string,
dev: boolean,
license: string,
author: string
): string {
return `# ${software}
[![Package quality](https://packagequality.com/shield/${software}.svg)](https://packagequality.com/#?package=${software})
> ${description}
## Installation
npm:
> npm i --save${dev ? '-dev' : ''} ${software}
yarn:
> yarn add ${dev ? '--dev' : ''} ${software}
## Usage
TODO: Add usage
## License
${license} © ${author}
`;
}

View File

@ -0,0 +1,33 @@
import { Snippet } from '../../Snippet';
import { modify_json, apply_template } from '../../Helper';
import { get_readme } from './Assets';
export default class Readme implements Snippet {
public async start (): Promise<void> {
const dev = await new Confirm ({
message: 'is the package used as dev dependency?',
default: false
})
.run ();
const package_data = {
software: '',
description: '',
license: '',
author: ''
};
await modify_json ((json) => {
package_data.software = json.name;
package_data.description = json.description;
package_data.license = json.license;
package_data.author = json.author;
});
const readme = get_readme (
package_data.software,
package_data.description,
dev,
package_data.license,
package_data.author
);
await apply_template (readme, 'README.md');
}
}