From a7147cf86a03a8f1c24bda5a4e24d1155ec6acb1 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 6 Sep 2024 23:32:38 -0300 Subject: [PATCH] improve types --- package-lock.json | 72 ++++++++++------------------------------ package.json | 3 +- src/actions/lifecycle.ts | 9 ++--- src/types.d.ts | 20 +++++++---- 4 files changed, 39 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index 43e747d0..d610f4a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,8 @@ "semver": "^7.5.4", "simple-git": "^3.20.0", "sort-keys": "^5.0.0", - "text-table": "^0.2.0" + "text-table": "^0.2.0", + "type-fest": "^4.26.0" }, "devDependencies": { "@types/debug": "^4.1.9", @@ -2544,6 +2545,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/ansi-escapes/node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -7512,18 +7525,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parse-json/node_modules/type-fest": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", - "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -7952,18 +7953,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/read-package-up/node_modules/type-fest": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", - "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/read-pkg": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-9.0.1.tgz", @@ -8162,18 +8151,6 @@ "node": ">=8" } }, - "node_modules/read-pkg/node_modules/type-fest": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", - "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/readable-stream": { "version": "4.5.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", @@ -9260,12 +9237,12 @@ } }, "node_modules/type-fest": { - "version": "0.21.3", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", - "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "version": "4.26.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", + "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", "license": "(MIT OR CC0-1.0)", "engines": { - "node": ">=10" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -10491,19 +10468,6 @@ } } }, - "node_modules/yeoman-test/node_modules/type-fest": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", - "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/yocto-queue": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", diff --git a/package.json b/package.json index 0c5dc510..53cd926b 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,8 @@ "semver": "^7.5.4", "simple-git": "^3.20.0", "sort-keys": "^5.0.0", - "text-table": "^0.2.0" + "text-table": "^0.2.0", + "type-fest": "^4.26.0" }, "devDependencies": { "@types/debug": "^4.1.9", diff --git a/src/actions/lifecycle.ts b/src/actions/lifecycle.ts index e7648206..7eaeb36d 100644 --- a/src/actions/lifecycle.ts +++ b/src/actions/lifecycle.ts @@ -455,12 +455,12 @@ export abstract class TasksMixin { async composeWith(generator: string[], immediately?: boolean): Promise; async composeWith( generator: string | { Generator: any; path: string }, - options: Partial>, + options: { generatorOptions: never; generatorArgs: never } & Partial>, immediately?: boolean, ): Promise; async composeWith( generator: string[], - options: Partial>, + options: { generatorOptions: never; generatorArgs: never } & Partial>, immediately?: boolean, ): Promise; async composeWith( @@ -475,9 +475,10 @@ export abstract class TasksMixin { options?: Partial>, immediately?: boolean, ): Promise; - async composeWith( + async composeWith( + this: G, generator: string, - options?: ComposeOptions, + options: ComposeOptions, ): Promise; async composeWith( diff --git a/src/types.d.ts b/src/types.d.ts index c4cadd54..acb6dbeb 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -2,9 +2,11 @@ import type { BaseGenerator, ComposeOptions as EnvironmentComposeOptions, GeneratorFeatures as FeaturesApi, + GetGeneratorOptions, GeneratorOptions as OptionsApi, ProgressOptions, } from '@yeoman/types'; +import type { Simplify } from 'type-fest'; import type { JSONSchema7Type } from 'json-schema'; import type { PipelineOptions } from 'mem-fs'; import type { MemFsEditorFile } from 'mem-fs-editor'; @@ -174,9 +176,15 @@ export type CliOptionSpec = { storage?: string | Storage; }; -export type ComposeOptions = EnvironmentComposeOptions & { - destinationRoot?: string; - skipEnvRegister?: boolean; - forceResolve?: boolean; - forwardOptions?: boolean; -}; +export type ComposeOptions = Simplify< + EnvironmentComposeOptions & + { + generatorOptions?: { + destinationRoot?: string; + } & Partial>; + skipEnvRegister?: boolean; + forceResolve?: boolean; + forwardOptions?: boolean; + } + +>;