mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-25 11:11:46 +08:00
More typing corrections and added tests
This commit is contained in:
@@ -112,3 +112,67 @@ runContext.inDir('dirPath')
|
||||
.withGenerators(['deps', 'deps'])
|
||||
.withOptions('opts')
|
||||
.withPrompts('answers');
|
||||
|
||||
// http://yeoman.io/generator/Base.html#destinationPath
|
||||
generator.destinationPath() === 'string';
|
||||
generator.destinationPath('path1') === 'string';
|
||||
generator.destinationPath('path1', 'path2') === 'string';
|
||||
generator.destinationPath('path1', 'path2', 'path3') === 'string';
|
||||
|
||||
// http://yeoman.io/generator/Base.html#templatePath
|
||||
generator.templatePath() === 'string';
|
||||
generator.templatePath('path1') === 'string';
|
||||
generator.templatePath('path1', 'path2') === 'string';
|
||||
generator.templatePath('path1', 'path2', 'path3') === 'string';
|
||||
|
||||
// http://yeoman.io/generator/Base.html#npmInstall
|
||||
generator.npmInstall();
|
||||
generator.npmInstall('pkg');
|
||||
generator.npmInstall([ 'pkg1', 'pkg2' ]);
|
||||
generator.npmInstall('pkg', {});
|
||||
generator.npmInstall('pkg', {}, () => {});
|
||||
|
||||
// http://yeoman.io/generator/Base.html#installDependencies
|
||||
generator.installDependencies();
|
||||
generator.installDependencies({});
|
||||
generator.installDependencies({ npm: true });
|
||||
generator.installDependencies({ bower: true });
|
||||
generator.installDependencies({ skipMessage: true });
|
||||
generator.installDependencies({ callback: () => {} });
|
||||
|
||||
// http://yeoman.io/generator/Base.html#spawnCommand
|
||||
generator.spawnCommand('command', []);
|
||||
generator.spawnCommand('command', [ '-arg' ]);
|
||||
generator.spawnCommand('command', [], {});
|
||||
|
||||
// http://yeoman.io/generator/Base.html#spawnCommandSync
|
||||
generator.spawnCommandSync('command', []);
|
||||
generator.spawnCommandSync('command', [ '-arg' ]);
|
||||
generator.spawnCommandSync('command', [], {});
|
||||
|
||||
// http://yeoman.io/generator/Base.html#option
|
||||
generator.options['opt'] === 'string';
|
||||
|
||||
// http://yeoman.io/generator/Base.html#prompt
|
||||
// https://github.com/SBoudrias/Inquirer.js
|
||||
generator.prompt({ name: 'Name', message: 'Message' }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: (answers) => 'Message' }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', choices: [ 'c1', 'c2' ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', choices: [ { name: 'Choice 1', value: 'c1' } ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', choices: (answers) => [ 'c1', 'c2' ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', choices: (answers) => [ { name: 'Choice 1', value: 'c1' } ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', choices: (answers) => [ { name: 'Choice 1', value: 'c1', short: '1' } ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', default: 'string' }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', default: 10 }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', default: [ 'string' ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', default: [ 10 ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', default: (answers) => [ 'string' ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', default: (answers) => [ 10 ] }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', default: (answers) => 'string' }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', default: (answers) => 10 }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', type: "list" }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', validate: (input) => true }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', validate: (input) => "Error" }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', filter: (input) => input }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', when: (answers) => true }, (answer) => {});
|
||||
generator.prompt({ name: 'Name', message: '', when: true }, (answer) => {});
|
||||
|
||||
+30
-13
@@ -10,6 +10,7 @@ declare module yo {
|
||||
composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator;
|
||||
defaultFor(name: string): void;
|
||||
destinationRoot(rootPath: string): string;
|
||||
destinationPath(...path: string[]): string;
|
||||
determineAppname(): void;
|
||||
getCollisionFilter(): (output: any) => void;
|
||||
hookFor(name: string, config: IHookConfig): void;
|
||||
@@ -19,8 +20,13 @@ declare module yo {
|
||||
run(args: any, callback?: Function): void;
|
||||
runHooks(callback?: Function): void;
|
||||
sourceRoot(rootPath: string): string;
|
||||
|
||||
|
||||
templatePath(...path: string[]): string;
|
||||
prompt(opt: IPromptOptions | IPromptOptions[], callback: (answers: any) => void): void;
|
||||
npmInstall(packages?: string[] | string, options?: any, cb?: Function): void;
|
||||
installDependencies(options?: IInstallDependencyOptions): void;
|
||||
spawnCommand(name: string, args?: string[], options?: Object): void;
|
||||
spawnCommandSync(name: string, args?: string[], options?: Object): void;
|
||||
options: { [key: string]: any };
|
||||
}
|
||||
|
||||
export class YeomanGeneratorBase implements IYeomanGenerator, NodeJS.EventEmitter {
|
||||
@@ -28,7 +34,7 @@ declare module yo {
|
||||
composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator;
|
||||
defaultFor(name: string): void;
|
||||
destinationRoot(rootPath: string): string;
|
||||
destinationPath(file: string): string;
|
||||
destinationPath(...path: string[]): string;
|
||||
determineAppname(): void;
|
||||
getCollisionFilter(): (output: any) => void;
|
||||
hookFor(name: string, config: IHookConfig): void;
|
||||
@@ -38,7 +44,7 @@ declare module yo {
|
||||
run(args: any, callback?: Function): void;
|
||||
runHooks(callback?: Function): void;
|
||||
sourceRoot(rootPath: string): string;
|
||||
templatePath(file: string): string;
|
||||
templatePath(...path: string[]): string;
|
||||
addListener(event: string, listener: Function): NodeJS.EventEmitter;
|
||||
on(event: string, listener: Function): NodeJS.EventEmitter;
|
||||
once(event: string, listener: Function): NodeJS.EventEmitter;
|
||||
@@ -49,17 +55,25 @@ declare module yo {
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
|
||||
async(): any;
|
||||
prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void;
|
||||
prompt(opt: IPromptOptions | IPromptOptions[], callback: (answers: any) => void): void;
|
||||
log(message: string) : void;
|
||||
npmInstall(packages: string[], options?: any, cb?: Function) :void;
|
||||
installDependencies(): void;
|
||||
spawnCommand(name: string, args?: string[]): void;
|
||||
installDependencies(options?: IInstallDependencyOptions): void;
|
||||
spawnCommand(name: string, args?: string[], options?: Object): void;
|
||||
spawnCommandSync(name: string, args?: string[], options?: Object): void;
|
||||
|
||||
appname: string;
|
||||
gruntfile: IGruntFileStatic;
|
||||
options: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface IInstallDependencyOptions {
|
||||
npm?: boolean;
|
||||
bower?: boolean;
|
||||
skipMessage?: boolean;
|
||||
callback?: Function;
|
||||
}
|
||||
|
||||
export interface IChoice {
|
||||
name: string;
|
||||
value: string;
|
||||
@@ -67,11 +81,14 @@ declare module yo {
|
||||
}
|
||||
|
||||
export interface IPromptOptions{
|
||||
type: string;
|
||||
type?: string;
|
||||
name: string;
|
||||
message: string;
|
||||
choices?: string[] | Function | IChoice[];
|
||||
default?: string;
|
||||
message: string | ((answers: Object) => string);
|
||||
choices?: string[] | IChoice[] | ((answers: Object) => (string[] | IChoice[]));
|
||||
default?: string | number | string[] | number[] | ((answers: Object) => (string | number | string[] | number[]));
|
||||
validate?: ((input: any) => boolean | string);
|
||||
filter?: ((input: any) => any);
|
||||
when?: ((answers: Object) => boolean) | boolean;
|
||||
store?: boolean;
|
||||
}
|
||||
|
||||
@@ -84,10 +101,10 @@ declare module yo {
|
||||
}
|
||||
|
||||
export interface IArgumentConfig {
|
||||
desc?: string;
|
||||
desc: string;
|
||||
required?: boolean;
|
||||
optional?: boolean;
|
||||
type?: any;
|
||||
type: any;
|
||||
defaults?: any;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user