mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
add yeoman-generator/yeoman-generator.d.ts
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
/// <reference path="yeoman-generator.d.ts" />
|
||||
import yeoman = require('yeoman-generator');
|
||||
|
||||
var base = yeoman.generators.Base;
|
||||
var namedBase = yeoman.generators.NamedBase;
|
||||
|
||||
var generator = base.extend({
|
||||
initializing: function() {
|
||||
return;
|
||||
},
|
||||
writing: {
|
||||
app: function() {
|
||||
return;
|
||||
},
|
||||
other: function() {
|
||||
return;
|
||||
}
|
||||
},
|
||||
end: function() {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
generator.argument('name', {
|
||||
desc: 'desc',
|
||||
required: true,
|
||||
optional: true,
|
||||
type: 'any',
|
||||
defaults: 'any',
|
||||
});
|
||||
|
||||
var compose = generator.composeWith('namespace', 'any', {
|
||||
local: 'local',
|
||||
link: 'link'
|
||||
});
|
||||
|
||||
compose.defaultFor('name');
|
||||
compose.destinationRoot('rootPath') === 'string';
|
||||
compose.determineAppname();
|
||||
compose.getCollisionFilter()('output');
|
||||
compose.hookFor('name', {
|
||||
as: 'string',
|
||||
args: 'any',
|
||||
options: 'any'
|
||||
});
|
||||
compose.option('name', {
|
||||
alias: 'string',
|
||||
defaults: 'any',
|
||||
desc: 'string',
|
||||
hide: true,
|
||||
type: 'any'
|
||||
});
|
||||
var returnString: boolean;
|
||||
returnString = compose.rootGeneratorName() === 'string';
|
||||
compose.run('args');
|
||||
compose.run('args', () => {
|
||||
return;
|
||||
});
|
||||
compose.runHooks(() => {
|
||||
return;
|
||||
});
|
||||
returnString = compose.sourceRoot('rootPath') === 'string';
|
||||
|
||||
var assert = yeoman.assert;
|
||||
|
||||
assert.file('path');
|
||||
assert.file(['paths', 'paths']);
|
||||
assert.fileContent('file', /.*/);
|
||||
assert.fileContent([
|
||||
['string', /.*/],
|
||||
['string', /.*/],
|
||||
['string', /.*/]
|
||||
]);
|
||||
assert.files([
|
||||
['string', /.*/],
|
||||
'string',
|
||||
['string', /.*/],
|
||||
'string'
|
||||
]);
|
||||
assert.implement('subject', 'methods');
|
||||
assert.noFile('file');
|
||||
assert.noFileContent('file', /.*/);
|
||||
assert.noFileContent([
|
||||
['string', /.*/],
|
||||
['string', /.*/],
|
||||
['string', /.*/]
|
||||
]);
|
||||
assert.noImplement('subject', 'methods');
|
||||
assert.textEqual('value', 'expected');
|
||||
|
||||
var test = yeoman.test;
|
||||
var dummyGen = test.createDummyGenerator();
|
||||
dummyGen.determineAppname();
|
||||
|
||||
var createdGen = test.createGenerator('name', ['any', 'amy'], 'args', 'options');
|
||||
createdGen.determineAppname();
|
||||
|
||||
test.decorate('context', 'method', () => {
|
||||
return; // replacement
|
||||
}, 'options');
|
||||
test.gruntfile('options', () => {
|
||||
return; // done
|
||||
});
|
||||
test.mockPrompt(createdGen, 'answers');
|
||||
test.registerDependencies(['dependencies', 'dependencies']);
|
||||
test.restore();
|
||||
var runContext = test.run('generator');
|
||||
|
||||
runContext.async()();
|
||||
runContext.inDir('dirPath')
|
||||
.withArguments('args')
|
||||
.withGenerators(['deps', 'deps'])
|
||||
.withOptions('opts')
|
||||
.withPrompts('answers');
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
// Type definitions for yeoman-generator
|
||||
// Project: https://github.com/yeoman/generator
|
||||
// Definitions by: Kentaro Okuno <http://github.com/armorik83>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module yo {
|
||||
export interface IYeomanGenerator {
|
||||
argument(name: string, config: IArgumentConfig): void;
|
||||
composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator;
|
||||
defaultFor(name: string): void;
|
||||
destinationRoot(rootPath: string): string;
|
||||
determineAppname(): void;
|
||||
getCollisionFilter(): (output: any) => void;
|
||||
hookFor(name: string, config: IHookConfig): void;
|
||||
option(name: string, config: IYeomanGeneratorOption): void;
|
||||
rootGeneratorName(): string;
|
||||
run(args?: any): void;
|
||||
run(args: any, callback?: Function): void;
|
||||
runHooks(callback?: Function): void;
|
||||
sourceRoot(rootPath: string): string;
|
||||
}
|
||||
|
||||
export interface IArgumentConfig {
|
||||
desc: string;
|
||||
required: boolean;
|
||||
optional: boolean;
|
||||
type: any;
|
||||
defaults: any;
|
||||
}
|
||||
|
||||
export interface IComposeSetting {
|
||||
local?: string;
|
||||
link?: string;
|
||||
}
|
||||
|
||||
export interface IHookConfig {
|
||||
as: string;
|
||||
args: any;
|
||||
options: any;
|
||||
}
|
||||
|
||||
export interface IYeomanGeneratorOption {
|
||||
alias: string;
|
||||
defaults: any;
|
||||
desc: string;
|
||||
hide: boolean;
|
||||
type: any;
|
||||
}
|
||||
|
||||
export interface IQueueProps {
|
||||
initializing: () => void;
|
||||
prompting?: () => void;
|
||||
configuring?: () => void;
|
||||
default?: () => void;
|
||||
writing: {
|
||||
[target: string]: () => void;
|
||||
};
|
||||
conflicts?: () => void;
|
||||
install?: () => void;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
export interface IBase {
|
||||
new(args: string, options: any): IYeomanGenerator;
|
||||
new(args: string[], options: any): IYeomanGenerator;
|
||||
extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator;
|
||||
}
|
||||
|
||||
export interface INamedBase {
|
||||
new(args: string, options: any): IYeomanGenerator;
|
||||
new(args: string[], options: any): IYeomanGenerator;
|
||||
}
|
||||
|
||||
export interface IAssert {
|
||||
file(path: string): void;
|
||||
file(paths: string[]): void;
|
||||
fileContent(file: string, reg: RegExp): void;
|
||||
|
||||
/** @param {[String, RegExp][]} pairs */
|
||||
fileContent(pairs: any[][]): void;
|
||||
|
||||
/** @param {[String, RegExp][]|String[]} pairs */
|
||||
files(pairs: any[]): void;
|
||||
|
||||
/**
|
||||
* @param {Object} subject
|
||||
* @param {Object|Array} methods
|
||||
*/
|
||||
implement(subject: any, methods: any): void;
|
||||
noFile(file: string): void;
|
||||
noFileContent(file: string, reg: RegExp): void;
|
||||
|
||||
/** @param {[String, RegExp][]} pairs */
|
||||
noFileContent(pairs: any[][]): void;
|
||||
|
||||
/**
|
||||
* @param {Object} subject
|
||||
* @param {Object|Array} methods
|
||||
*/
|
||||
noImplement(subject: any, methods: any): void;
|
||||
|
||||
textEqual(value: string, expected: string): void;
|
||||
}
|
||||
|
||||
export interface ITestHelper {
|
||||
createDummyGenerator(): IYeomanGenerator;
|
||||
createGenerator(name: string, dependencies: any[], args: any, options: any): IYeomanGenerator;
|
||||
decorate(context: any, method: string, replacement: Function, options: any): void;
|
||||
gruntfile(options: any, done: Function): void;
|
||||
mockPrompt(generator: IYeomanGenerator, answers: any): void;
|
||||
registerDependencies(dependencies: string[]): void;
|
||||
restore(): void;
|
||||
|
||||
/** @param {String|Function} generator */
|
||||
run(generator: any): IRunContext;
|
||||
}
|
||||
|
||||
export interface IRunContext {
|
||||
async(): Function;
|
||||
inDir(dirPath: string): IRunContext;
|
||||
|
||||
/** @param {String|String[]} args */
|
||||
withArguments(args: any): IRunContext;
|
||||
withGenerators(dependencies: string[]): IRunContext;
|
||||
withOptions(options: any): IRunContext;
|
||||
withPrompts(answers: any): IRunContext;
|
||||
}
|
||||
|
||||
/** @type file file-utils */
|
||||
var file: any;
|
||||
var assert: IAssert;
|
||||
var test: ITestHelper;
|
||||
var generators: {
|
||||
Base: IBase;
|
||||
NamedBase: INamedBase;
|
||||
};
|
||||
}
|
||||
|
||||
declare module "yeoman-generator" {
|
||||
export = yo;
|
||||
}
|
||||
Reference in New Issue
Block a user