2020-06-27 19:50:34 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) SapphireCode - All Rights Reserved
|
|
|
|
* This file is part of Snippeteer which is released under BSD-3-Clause.
|
|
|
|
* See file 'LICENSE' for full license details.
|
|
|
|
* Created by Timo Hocker <timo@scode.ovh>, June 2020
|
|
|
|
*/
|
|
|
|
|
2020-05-11 11:34:16 +02:00
|
|
|
import { Confirm } from 'enquirer';
|
2020-05-11 11:33:34 +02:00
|
|
|
import { Snippet } from '../../Snippet';
|
|
|
|
import { modify_json, apply_template } from '../../Helper';
|
|
|
|
import { get_readme } from './Assets';
|
|
|
|
|
|
|
|
export default class Readme implements Snippet {
|
2020-05-11 12:01:39 +02:00
|
|
|
public is_active (): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-11 11:33:34 +02:00
|
|
|
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;
|
2020-07-25 18:57:35 +02:00
|
|
|
if (typeof json.author === 'object')
|
|
|
|
package_data.author = `${json.author.name} <${json.author.email}>`;
|
|
|
|
else
|
|
|
|
package_data.author = json.author;
|
2020-05-11 11:33:34 +02:00
|
|
|
});
|
|
|
|
const readme = get_readme (
|
|
|
|
package_data.software,
|
|
|
|
package_data.description,
|
|
|
|
dev,
|
|
|
|
package_data.license,
|
|
|
|
package_data.author
|
|
|
|
);
|
|
|
|
await apply_template (readme, 'README.md');
|
|
|
|
}
|
|
|
|
}
|