///
///
import program from 'commander';
import fs, { WriteFileOptions } from 'fs-extra';
import inquirer, { Questions, Answers } from 'inquirer';
import ts from 'typescript';
import * as npm from './npm';
import prettier, { Options } from 'prettier';
import 'colors';
import { PkgConf } from './config';
import Handlebars from './handlebars';
/**
* Action
*/
export interface Action {
/**
* path to new file write to
*/
path: string;
/**
* path to template file
*/
templateFile: string;
/**
* format code
* - provide a prettier configurations if is an object
* - true use default options
*/
format?: Options | boolean;
}
export interface Package {
name: string;
version: string;
description: string;
dependencies: {
[key: string]: string;
};
devDependencies: {
[key: string]: string;
};
merry: PkgConf;
[key: string]: any;
}
export declare class Plugin {
private readonly program;
readonly conf: PkgConf;
/**
* absolutely package path
*/
pkgCwd: string;
readonly fs: typeof fs;
readonly ts: typeof ts;
readonly npm: typeof npm;
readonly prettier: typeof prettier;
readonly handlebars: typeof Handlebars;
readonly inquirer: inquirer.Inquirer;
readonly pkg: Package;
/**
* plugin current working directory
*/
readonly cwd: string;
constructor(program: program.CommanderStatic, conf: PkgConf,
/**
* absolutely package path
*/
pkgCwd: string);
/**
* register command with version and description builtin
* @param command
*/
command(command: string): program.Command;
/**
* compile Handlebars template
* @param templateOrFilePath path to templates
* @param data data
* @param options
*/
compile(templateOrFilePath: string, data: any, options?: CompileOptions): string;
/**
* write files to destination
* @param path
* @param data
* @param options
*/
write(path: string, data: any, options?: WriteFileOptions | string): Promise;
/**
* compile and write file to destination
* @param template path/to/hbs
* @param dist path/file/will/write/to
* @param data data will pass to templates
*/
tmpl(template: string, dist: string, data: any): Promise;
/**
* compile and write file to destination
* @param template path/to/hbs
* @param dist path/file/will/write/to
* @param data data will pass to templates
*/
tmplWithFormat(template: string, dist: string, data: any, options?: Options): Promise;
/**
* compile and write file to destination
* @param template path/to/hbs
* @param data data will pass to templates
*/
format(code: string, options?: Options): Promise;
/**
* questions
* @param questions
*/
prompt(questions: Questions): Promise;
expand(file: string): Promise<{
overwrite: "overwrite" | "diff" | "abort";
}>;
/**
* get pretty name
* @param name plugin name
*/
getPrettyName(name: string): string;
/**
* convert typescript file to esnext javascript or other version depends your options
* @param input typescript file you want transpile to
* @param options transpile options
*/
transpile(input: string, options?: ts.TranspileOptions): ts.TranspileOutput;
/**
* run actions with answers
*/
runActions: (actions: Action[], answers: T) => Promise;
}