From 64ffc666a2dc5285de8411eacea01e95dcf1f533 Mon Sep 17 00:00:00 2001 From: c4605 Date: Fri, 3 May 2019 18:01:26 +0800 Subject: [PATCH] add yeoman-environment (#35174) --- types/yeoman-environment/index.d.ts | 135 ++++++++++++++++++ types/yeoman-environment/package.json | 6 + types/yeoman-environment/tsconfig.json | 23 +++ types/yeoman-environment/tslint.json | 1 + .../yeoman-environment-tests.ts | 3 + 5 files changed, 168 insertions(+) create mode 100644 types/yeoman-environment/index.d.ts create mode 100644 types/yeoman-environment/package.json create mode 100644 types/yeoman-environment/tsconfig.json create mode 100644 types/yeoman-environment/tslint.json create mode 100644 types/yeoman-environment/yeoman-environment-tests.ts diff --git a/types/yeoman-environment/index.d.ts b/types/yeoman-environment/index.d.ts new file mode 100644 index 0000000000..fe8cc32dfb --- /dev/null +++ b/types/yeoman-environment/index.d.ts @@ -0,0 +1,135 @@ +// Type definitions for yeoman-environment 2.3 +// Project: https://github.com/yeoman/environment, http://yeoman.io +// Definitions by: c4605 +// 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( + args?: string | string[], + opts?: O, + adapter?: Environment.Adapter + ): Environment; + + static enforceUpdate(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(questions: Adapter.Questions): Promise; + prompt( + questions: Adapter.Questions, + cb: (res: T1) => T2 + ): Promise; + + diff(actual: string, expected: string): string; + } + + namespace Adapter { + type Question = inquirer.Question; + + type Questions = inquirer.Questions; + + 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; diff --git a/types/yeoman-environment/package.json b/types/yeoman-environment/package.json new file mode 100644 index 0000000000..021b40d754 --- /dev/null +++ b/types/yeoman-environment/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "rxjs": ">=6.4.0" + } +} diff --git a/types/yeoman-environment/tsconfig.json b/types/yeoman-environment/tsconfig.json new file mode 100644 index 0000000000..9287c4dd28 --- /dev/null +++ b/types/yeoman-environment/tsconfig.json @@ -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" + ] +} diff --git a/types/yeoman-environment/tslint.json b/types/yeoman-environment/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/yeoman-environment/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/yeoman-environment/yeoman-environment-tests.ts b/types/yeoman-environment/yeoman-environment-tests.ts new file mode 100644 index 0000000000..a790e33fe8 --- /dev/null +++ b/types/yeoman-environment/yeoman-environment-tests.ts @@ -0,0 +1,3 @@ +import * as Env from "yeoman-environment"; + +Env.createEnv();