39 lines
		
	
	
		
			1022 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1022 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { Confirm } from 'enquirer';
 | |
| import { Snippet } from '../../Snippet';
 | |
| import { modify_json, apply_template } from '../../Helper';
 | |
| import { get_readme } from './Assets';
 | |
| 
 | |
| export default class Readme implements Snippet {
 | |
|   public is_active (): boolean {
 | |
|     return true;
 | |
|   }
 | |
| 
 | |
|   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');
 | |
|   }
 | |
| }
 |