@thi.ng/transclude
Version:
Extensible functional template engine for text document generation, incl. various high-level Markdown features
87 lines • 2.74 kB
TypeScript
import type { Fn, IObjectOf } from "@thi.ng/api";
import type { TemplateFn } from "../api.js";
export interface Package {
name: string;
description: string;
version: string;
author: string | User;
license: string;
homepage: string;
contributors?: (string | User)[];
dependencies?: IObjectOf<string>;
devDependencies?: IObjectOf<string>;
keywords?: string[];
}
export interface User {
name: string;
email?: string;
url?: string;
}
export declare const LICENSES: IObjectOf<{
name: string;
url: string;
}>;
/**
* Returns the unscoped name of a package, i.e. the name without the package's
* group ID (if any).
*
* @param name
*/
export declare const shortName: (name: string) => string;
/**
* Returns name of the author, given in any format supported by NPM.
*
* @param author
*/
export declare const author: (author: string | User) => string;
/**
* Similar to {@link author}, but if an URL is available, returns a Markdown
* link to the author's URL, else just the name.
*
* @param author
*/
export declare const authorLink: (author: string | User) => string;
/**
* Formats the {@link Package.contributors} as Markdown list.
*
* @param people
* @param eol
*/
export declare const contributors: (people: (string | User)[], eol?: string) => string;
/**
* Similar to {@link contributors}, but formatted as list of links.
*
* @param people
* @param eol
*/
export declare const contributorLinks: (people: (string | User)[], eol?: string) => string;
/**
* Returns the name for given SPDX license ID (only those in
* {@link LICENSES} are supported).
*
* @param spdxID
*/
export declare const license: (spdxID: string) => string;
/**
* Similar to {@link license}, but returns Markdown link to license.
*
* @param spdxID
*/
export declare const licenseLink: (spdxID: string) => string;
export interface PackageTemplateOpts {
/**
* Headline for list of contributors (only used if any present).
*/
hdContributors: string;
}
export type PackageTemplates<T> = Record<"pkg.name" | "pkg.shortName" | "pkg.version" | "pkg.description" | "pkg.link" | "pkg.author" | "pkg.authorLink" | "pkg.contributors" | "pkg.contributorLinks" | "pkg.allAuthors" | "pkg.allAuthorLinks" | "pkg.license" | "pkg.licenseLink", TemplateFn<T>>;
/**
* Higher order function returning various useful NPM package.json related
* templates. The user provided `pkg` function is used to look up the loaded
* {@link Package} data within the {@link TranscludeCtx.user} object.
*
* @param pkg
* @param opts
*/
export declare const packageTemplates: <T = any>(pkg: Fn<T, Package>, opts?: Partial<PackageTemplateOpts>) => PackageTemplates<T>;
//# sourceMappingURL=pkg.d.ts.map