add yeoman-environment (#35174)

This commit is contained in:
c4605
2019-05-03 18:01:26 +08:00
committed by Wesley Wigham
parent 4ec0684aba
commit 64ffc666a2
5 changed files with 168 additions and 0 deletions

135
types/yeoman-environment/index.d.ts vendored Normal file
View File

@@ -0,0 +1,135 @@
// Type definitions for yeoman-environment 2.3
// Project: https://github.com/yeoman/environment, http://yeoman.io
// Definitions by: c4605 <https://github.com/bolasblack>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { EventEmitter } from "events";
import { Store as MemFsStore } from "mem-fs";
import * as inquirer from "inquirer";
import * as Generator from "yeoman-generator";
declare class Environment<
O extends Environment.Options = Environment.Options
> extends EventEmitter {
static createEnv<O extends Environment.Options = Environment.Options>(
args?: string | string[],
opts?: O,
adapter?: Environment.Adapter
): Environment<O>;
static enforceUpdate<E extends Environment>(env: E): E;
static namespaceToName(namespace: string): string;
arguments: string[];
options: O;
cwd: string;
store: Generator.Storage;
sharedFs: MemFsStore;
lookups: string[];
aliases: Environment.Alias[];
constructor(
args?: string | string[],
opts?: O,
adapter?: Environment.Adapter
);
alias(match: string | RegExp, value: string): void;
create(name: string, options: object): void;
error(err: Error | object): Error;
findGeneratorsIn(list: string[]): string[];
get(namespace: string): Generator | null;
getByPath(path: string): Generator | null;
getGeneratorNames(): string[];
getGeneratorsMeta(): { [namespace: string]: Environment.GeneratorMeta };
getNpmPaths(): string[];
help(name: string): string;
instantiate(
name: string,
options: Environment.InstantiateOptions
): Generator;
lookup(cb?: (err: null | Error) => void): void;
namespace(filepath: string): string;
namespaces(): string[];
register(name: string, namespace?: string): string;
registerStub(Generator: Generator, namespace: string): this;
resolveModulePath(moduleId: string): string;
run(done: Environment.RunDone): void;
run(args: string | string[], done: Environment.RunDone): void;
run(
args: string | string[],
options: object,
done: Environment.RunDone
): void;
private _tryRegistering(generatorReference: string): void;
}
declare namespace Environment {
interface Adapter {
prompt<T>(questions: Adapter.Questions<T>): Promise<T>;
prompt<T1, T2>(
questions: Adapter.Questions<T1>,
cb: (res: T1) => T2
): Promise<T2>;
diff(actual: string, expected: string): string;
}
namespace Adapter {
type Question<T> = inquirer.Question<T>;
type Questions<T> = inquirer.Questions<T>;
type Answers = inquirer.Answers;
}
interface Alias {
match: RegExp;
value: string;
}
interface Options {
cwd?: string;
[key: string]: any;
}
interface GeneratorMeta {
resolved: string;
namespace: string;
}
interface InstantiateOptions {
arguments: string | string[];
options: Options;
}
type RunDone = (err: null | Error) => void;
}
export = Environment;

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"rxjs": ">=6.4.0"
}
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"yeoman-environment-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -0,0 +1,3 @@
import * as Env from "yeoman-environment";
Env.createEnv();