UNPKG

@appnest/readme

Version:

Automatically generate a beautiful best-practice README file based on the contents of your repository

760 lines (759 loc) 18.3 kB
import { TransformerConfig } from "web-component-analyzer"; declare enum LineColor { AQUA = "aqua", CLOUDY = "cloudy", COLORED = "colored", CUT = "cut", DARK = "dark", FIRE = "fire", GRASS = "grass", RAINBOW = "rainbow", SOLAR = "solar", VINTAGE = "vintage", WATER = "water", NONE = "none" } interface IBadge { alt: string; url: string; img: string; } interface IGeneratorParamsError { error: string; } interface IUserTemplate { name: string; template: string; params?: Params; } type PlaceholderSyntax = [string, string]; // export interface IConfig { // lineBreak: string; // tab: string; // blueprintName: string; // pkgName: string; // outputName: string; // placeholder: PlaceholderSyntax; // dry: boolean; // silent: boolean; // line: LineColor; // generators: IGenerator<Params>[]; // templates: IUserTemplate[]; // } // export interface IConfig { // lineBreak: string; // tab: string; // blueprintName: string; // pkgName: string; // outputName: string; // placeholder: PlaceholderSyntax; // dry: boolean; // silent: boolean; // line: LineColor; // generators: IGenerator<Params>[]; // templates: IUserTemplate[]; // } interface IConfig { input: string; output: string; package: string; help: boolean; text?: string; demo?: string; lineBreak: string; checkLinks: boolean; tab: string; silent: boolean; dry: boolean; logo?: ILogo; placeholder: PlaceholderSyntax; line: LineColor; templates?: IUserTemplate[]; headingPrefix: { [key: number]: string; }; badges?: IBadge[]; contributorsPerRow: number; pkg: IPackage; documentationConfig: Partial<TransformerConfig>; extend?: string; } interface IPackage { name?: string; contributors?: IContributor[]; license?: License; } interface IGeneratorArgs { config: IConfig; blueprint: string; configPath: string; generateReadme: GenerateReadmeFunction; } type Params = { [key: string]: string; } | { optional?: { [key: string]: string; }; }; type GenerateReadmeFunction = ({ config, blueprint, generators, configPath }: { config: IConfig; blueprint: string; generators: IGenerator<any>[]; configPath: string; }) => Promise<string>; interface IGeneratorParamsArgs extends IGeneratorArgs { match: RegExpMatchArray; } interface IGenerator<T> { name: string; regex: (args: IGeneratorArgs) => RegExp; template: (args: T) => string | Promise<string>; params?: Params | ((args: IGeneratorParamsArgs) => T | IGeneratorParamsError | Promise<T | IGeneratorParamsError>); } interface ILogo { src: string; alt?: string; width?: number; height?: number; } interface IContributor { name: string; url?: string; email?: string; img?: string; info?: string[]; } type Options = { [key: string]: any; }; type Bullet = string; type License = string; type LoadTemplateArgs = { content: string; generateReadme: GenerateReadmeFunction; configPath: string; config: IConfig; }; type LogoTemplateArgs = { logo: ILogo; }; type LineTemplateArgs = { config: IConfig; }; type TitleTemplateArgs = { title: string; level: number; config: IConfig; }; type MainTitleTemplateArgs = { name: string; }; type BadgesTemplateArgs = { badges: IBadge[]; config: IConfig; }; type DocumentationTemplateArgs = { glob: string; config: IConfig; }; type DescriptionTemplateArgs = { description: string; text?: string; demo?: string; }; type BulletsTemplateArgs = { bullets: Bullet[]; config: IConfig; }; type TableTemplateArgs = { rows: string[][]; config: IConfig; centered?: boolean; }; type TableOfContentsTemplateArgs = { titles: string[]; config: IConfig; }; type ContributorsTemplateArgs = { contributors: IContributor[]; config: IConfig; }; type LicenseTemplateArgs = { license: License; }; type DemoTemplateArgs = { url: string; }; /** * Runs the check links command. * @param options */ declare function checkLinksCommand(options: Options): Promise<void>; /** * Generate npm badges. * @param npmId */ declare function npmBadges({ npmId }: { npmId: string; }): IBadge[]; /** * Generate github badges. * @param githubId */ /** * Generate github badges. * @param githubId */ declare function githubBadges({ githubId }: { githubId: string; }): IBadge[]; /** * Generates the webcomponents badges. * @param webcomponentsId */ /** * Generates the webcomponents badges. * @param webcomponentsId */ declare function webcomponentsBadges({ webcomponentsId }: { webcomponentsId: string; }): IBadge[]; /** * Generates a readme. * @param pkg * @param blueprint * @param configPath * @param generators */ declare function generateReadme({ config, blueprint, configPath, generators }: { config: IConfig; blueprint: string; configPath: string; generators: IGenerator<any>[]; }): Promise<string>; /** * Generates the readme. */ /** * Generates the readme. */ declare function generate({ config, configPath, generators }: { config: IConfig; configPath: string; generators: IGenerator<any>[]; }): Promise<void>; /** * Runs the readme command. * @param options */ /** * Runs the readme command. * @param options */ declare function generateCommand(options: Options): Promise<void>; /** * Creates a simple template. * @param name * @param template * @param params */ declare function simpleTemplateGenerator({ name, template, params }: IUserTemplate): IGenerator<{}>; /** * Loads markdown. */ /** * Loads markdown. */ declare const generateLoad: IGenerator<LoadTemplateArgs>; /** * Generates a logo. */ /** * Generates a logo. */ declare const generateLogo: IGenerator<LogoTemplateArgs>; /** * Generates a title. */ /** * Generates a title. */ declare const generateMainTitle: IGenerator<MainTitleTemplateArgs>; /** * Generates badges. */ /** * Generates badges. */ declare const generateBadges: IGenerator<BadgesTemplateArgs>; /** * Generates a description. */ /** * Generates a description. */ declare const generateDescription: IGenerator<DescriptionTemplateArgs>; /** * Generates a line. */ /** * Generates a line. */ declare const generateLine: IGenerator<LineTemplateArgs>; /** * Generates contributors. */ /** * Generates contributors. */ declare const generateContributors: IGenerator<ContributorsTemplateArgs>; /** * Generates license. */ /** * Generates license. */ declare const generateLicense: IGenerator<LicenseTemplateArgs>; /** * Generates the titles. */ /** * Generates the titles. */ declare const generateTitle: IGenerator<TitleTemplateArgs>; /** * Generates the interpolation. */ /** * Generates the interpolation. */ declare const generateInterpolate: IGenerator<{ config: IConfig; text: string; }>; /** * Generates the toc. */ /** * Generates the toc. */ declare const generateToc: IGenerator<TableOfContentsTemplateArgs>; /** * Generates documentation. */ /** * Generates documentation. */ declare const generateDocumentation: IGenerator<DocumentationTemplateArgs>; /** * Creates the template for the logo. * @param logo */ declare function logoTemplate({ logo }: LogoTemplateArgs): string; /** * Creates the template for the title. * @param name */ /** * Creates the template for the title. * @param name */ declare function mainTitleTemplate({ name }: MainTitleTemplateArgs): string; /** * Creates a line template. * @param config */ /** * Creates a line template. * @param config */ declare function lineTemplate({ config }: LineTemplateArgs): string; /** * Creates a template for the title. * @param title * @param level * @param config */ /** * Creates a template for the title. * @param title * @param level * @param config */ declare function titleTemplate({ title, level, config }: TitleTemplateArgs): string; /** * Creates a template for the badges. * @param badges * @param config */ /** * Creates a template for the badges. * @param badges * @param config */ declare function badgesTemplate({ badges, config }: BadgesTemplateArgs): string; /** * Creates a template for the license. * @param license * @returns {string} */ /** * Creates a template for the license. * @param license * @returns {string} */ declare function licenseTemplate({ license }: LicenseTemplateArgs): string; /** * Creates a template for the demo link. * @param url */ /** * Creates a template for the demo link. * @param url */ declare function demoTemplate({ url }: DemoTemplateArgs): string; /** * Creates a description template. * @param description * @param text * @param demo */ /** * Creates a description template. * @param description * @param text * @param demo */ declare function descriptionTemplate({ description, text, demo }: DescriptionTemplateArgs): string; /** * Creates a bullets template. * @param bullets * @param pkg */ /** * Creates a bullets template. * @param bullets * @param pkg */ declare function bulletsTemplate({ bullets, config }: BulletsTemplateArgs): string; /** * Creates a table template. * @param rows * @param config * @param centered */ /** * Creates a table template. * @param rows * @param config * @param centered */ declare function tableTemplate({ rows, config, centered }: TableTemplateArgs): string; /** * Creates the table of contents. * @param titles * @param pkg */ /** * Creates the table of contents. * @param titles * @param pkg */ declare function tocTemplate({ titles, config }: TableOfContentsTemplateArgs): string; /** * Creates the authors template. * @param contributors * @param config */ /** * Creates the authors template. * @param contributors * @param config */ declare function contributorsTemplate({ contributors, config }: ContributorsTemplateArgs): string; /** * Generates documentation for a glob. * @param glob * @param config */ /** * Generates documentation for a glob. * @param glob * @param config */ declare function documentationTemplate({ glob: globString, config }: DocumentationTemplateArgs): Promise<string>; declare const defaultGenerators: IGenerator<any>[]; declare const defaultDocumentationConfig: Partial<TransformerConfig>; /** * Default name of the blueprint configuration. */ /** * Default name of the blueprint configuration. */ declare const defaultConfigName = "blueprint.json"; /** * Default configuration. */ declare const defaultConfig: IConfig; /** * Converts a value to a boolean. * @param v */ /** * Converts a value to a boolean. * @param v */ /** * Converts a value to a boolean. * @param v */ /** * Constructs a config using the extend path if one is defined. * @param config */ declare function extendConfigWithExtendConfig({ config }: { config: IConfig; }): IConfig; /** * Constructs a configuration object with defaults. * @param pkg * @param options * @param config */ /** * Constructs a configuration object with defaults. * @param pkg * @param options * @param config */ declare function extendConfigWithDefaults({ options, config }: { config: IConfig; options: Options; }): IConfig; declare const URL_PATTERN: RegExp; /** * Returns whether the URL is valid. * @param url */ /** * Returns whether the URL is valid. * @param url */ declare function isValidURL(url: string): boolean; /** * Determines whether an object has the specified key. * @param obj * @param key */ /** * Determines whether an object has the specified key. * @param obj * @param key */ declare function hasKey(obj: Object, key: string): boolean; /** * Returns the license url. * @param license */ /** * Returns the license url. * @param license */ declare function getLicenseUrl(license: string): string; /** * Returns a key from from an object for a key path. * @param obj * @param keyPath */ /** * Returns a key from from an object for a key path. * @param obj * @param keyPath */ declare function getValue<T>(obj: { [key: string]: any; }, keyPath: string): T | null; /** * Sets a value for a key path (".") * @param obj * @param keyPath * @param value */ /** * Sets a value for a key path (".") * @param obj * @param keyPath * @param value */ declare function setValue<T>(obj: any, keyPath: string, value: T): void; /** * Validates the package. * @param obj * @param fileName */ /** * Validates the package. * @param obj * @param fileName */ declare function validateObject({ obj, requiredFields }: { obj: Object; requiredFields: string[]; }): boolean; /** * Returns whether the func is a function. * @param func */ /** * Returns whether the func is a function. * @param func */ declare function isFunction(func: unknown): boolean; /** * Returns whether the obj is an object. * @param obj */ /** * Returns whether the obj is an object. * @param obj */ declare function isObject(obj: unknown): boolean; /** * Extracts values from an object. * @param map * @param obj */ /** * Extracts values from an object. * @param map * @param obj */ declare function extractValues({ map, obj }: { map: { [key: string]: any; }; obj: Object; }): {}; /** * Returns available badges. * @param pkg */ /** * Returns available badges. * @param pkg */ declare function getBadges({ config }: { config: IConfig; }): IBadge[]; /** * Reads a file. * @param name */ /** * Reads a file. * @param name */ declare function readFile(name: string): string | null; /** * Reads the contents of a json file. * @param name */ /** * Reads the contents of a json file. * @param name */ declare function readJSONFile(name: string): Object | null; /** * Escapes a regex. * @param text */ /** * Escapes a regex. * @param text */ declare function escapeRegex(text: string): string; /** * Returns a placeholder regex. * @param text */ /** * Returns a placeholder regex. * @param text */ declare function placeholderRegexCallback(text: string): (({ config }: { config: IConfig; }) => RegExp); /** * Writes a file to a path. * @param target * @param content */ /** * Writes a file to a path. * @param target * @param content */ declare function writeFile({ target, content }: { target: string; content: string; }): Promise<void>; /** * Returns the title for a level. * @param title * @param level * @param config */ /** * Returns the title for a level. * @param title * @param level * @param config */ declare function getTitle({ title, level, config }: { title: string; level: number; config: IConfig; }): string; /** * Cleans the title from weird symbols. * @param title */ /** * Cleans the title from weird symbols. * @param title */ declare function getCleanTitle(title: string): string; /** * Returns the title link. * @param title * @param index */ /** * Returns the title link. * @param title * @param index */ declare function getTitleLink(title: string, index?: number): string; /** * Determines whether the file at the path exists. * @param absolutePath */ /** * Determines whether the file at the path exists. * @param absolutePath */ declare function fileExists(absolutePath: string): boolean; /** * Splits an array into smaller arrays. * @param arr * @param count */ /** * Splits an array into smaller arrays. * @param arr * @param count */ declare function splitArrayIntoArrays<T>(arr: T[], count: number): T[][]; /** * Replaces content in string between two indicies. * @param string * @param start * @param end * @param content */ /** * Replaces content in string between two indicies. * @param string * @param start * @param end * @param content */ declare function replaceInString(string: string, content: string, { start, end }: { start: number; end: number; }): string; /** * Loads the package file. * @param pkgPath */ /** * Loads the package file. * @param pkgPath */ declare function loadPackage(pkgPath: string): IPackage | null; /** * Loads the config file. * @param configPath */ /** * Loads the config file. * @param configPath */ declare function loadConfig(configPath: string): IConfig | null; /** * Returns links from a text. * @param text */ /** * Returns links from a text. * @param text */ declare function getLinks(text: string): string[]; /** * Checks all links in the text for aliveness. * @param text */ /** * Checks all links in the text for aliveness. * @param text */ declare function checkLinksAliveness(text: string): Promise<void>; /** * Runs the cli. * @param argv */ declare function run(argv: string[]): Promise<void>; export { checkLinksCommand, npmBadges, githubBadges, webcomponentsBadges, generateReadme, generate, generateCommand, simpleTemplateGenerator, generateLoad, generateLogo, generateMainTitle, generateBadges, generateDescription, generateLine, generateContributors, generateLicense, generateTitle, generateInterpolate, generateToc, generateDocumentation, logoTemplate, mainTitleTemplate, lineTemplate, titleTemplate, badgesTemplate, licenseTemplate, demoTemplate, descriptionTemplate, bulletsTemplate, tableTemplate, tocTemplate, contributorsTemplate, documentationTemplate, defaultGenerators, defaultDocumentationConfig, defaultConfigName, defaultConfig, extendConfigWithExtendConfig, extendConfigWithDefaults, URL_PATTERN, isValidURL, hasKey, getLicenseUrl, getValue, setValue, validateObject, isFunction, isObject, extractValues, getBadges, readFile, readJSONFile, escapeRegex, placeholderRegexCallback, writeFile, getTitle, getCleanTitle, getTitleLink, fileExists, splitArrayIntoArrays, replaceInString, loadPackage, loadConfig, getLinks, checkLinksAliveness, LineColor, IBadge, IGeneratorParamsError, IUserTemplate, PlaceholderSyntax, IConfig, IPackage, IGeneratorArgs, Params, GenerateReadmeFunction, IGeneratorParamsArgs, IGenerator, ILogo, IContributor, Options, Bullet, License, LoadTemplateArgs, LogoTemplateArgs, LineTemplateArgs, TitleTemplateArgs, MainTitleTemplateArgs, BadgesTemplateArgs, DocumentationTemplateArgs, DescriptionTemplateArgs, BulletsTemplateArgs, TableTemplateArgs, TableOfContentsTemplateArgs, ContributorsTemplateArgs, LicenseTemplateArgs, DemoTemplateArgs, run };