From 64b7669fa1373ef7b2eb10d0acb5038b29c91dca Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Tue, 21 May 2024 09:24:30 -0600 Subject: [PATCH] fix: clarify types --- src/cache.ts | 6 +++--- src/config/config.ts | 6 +++--- src/interfaces/config.ts | 4 ++-- src/interfaces/index.ts | 2 +- src/interfaces/pjson.ts | 11 ++++++----- test/config/config.test.ts | 1 - 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cache.ts b/src/cache.ts index ca295421c..c056d2d2c 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -2,14 +2,14 @@ import {readFileSync} from 'node:fs' import {join} from 'node:path' import {Config} from './config/config' -import {Configuration, Plugin} from './interfaces' +import {OclifConfiguration, Plugin} from './interfaces' type OclifCoreInfo = {name: string; version: string} type CacheContents = { rootPlugin: Plugin config: Config - exitCodes: Configuration['exitCodes'] + exitCodes: OclifConfiguration['exitCodes'] '@oclif/core': OclifCoreInfo } @@ -36,7 +36,7 @@ export default class Cache extends Map | undefined { return super.get(key) } diff --git a/src/config/config.ts b/src/config/config.ts index 9440d03db..cf462431c 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -8,7 +8,7 @@ import Cache from '../cache' import {Command} from '../command' import {CLIError, error, exit, warn} from '../errors' import {getHelpFlagAdditions} from '../help/util' -import {Configuration, Hook, Hooks, PJSON, S3Templates, Topic, UserPJSON} from '../interfaces' +import {Hook, Hooks, OclifConfiguration, PJSON, S3Templates, Topic, UserPJSON} from '../interfaces' import {ArchTypes, Config as IConfig, LoadOptions, PlatformTypes, VersionDetails} from '../interfaces/config' import {Plugin as IPlugin, Options} from '../interfaces/plugin' import {Theme} from '../interfaces/theme' @@ -104,7 +104,7 @@ export class Config implements IConfig { public shell!: string public theme?: Theme | undefined public topicSeparator: ' ' | ':' = ':' - public updateConfig!: NonNullable + public updateConfig!: NonNullable public userAgent!: string public userPJSON?: UserPJSON | undefined public valid!: boolean @@ -601,7 +601,7 @@ export class Config implements IConfig { ): string { if (typeof ext === 'object') options = ext else if (ext) options.ext = ext - const template = this.updateConfig.s3.templates?.[options.platform ? 'target' : 'vanilla'][type] ?? '' + const template = this.updateConfig.s3?.templates?.[options.platform ? 'target' : 'vanilla'][type] ?? '' return ejs.render(template, {...(this as any), ...options}) } diff --git a/src/interfaces/config.ts b/src/interfaces/config.ts index 48e06a98a..c21b1d474 100644 --- a/src/interfaces/config.ts +++ b/src/interfaces/config.ts @@ -1,6 +1,6 @@ import {Command} from '../command' import {Hook, Hooks} from './hooks' -import {Configuration, PJSON, S3Templates} from './pjson' +import {OclifConfiguration, PJSON, S3Templates} from './pjson' import {Options, Plugin} from './plugin' import {Theme} from './theme' import {Topic} from './topic' @@ -115,7 +115,7 @@ export interface Config { readonly theme?: Theme | undefined topicSeparator: ' ' | ':' readonly topics: Topic[] - readonly updateConfig: NonNullable + readonly updateConfig: NonNullable /** * user agent to use for http calls * diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 9657ce800..2578d2565 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -8,7 +8,7 @@ export type {Hook, Hooks} from './hooks' export type {Logger} from './logger' export type {Manifest} from './manifest' export type {Arg, BooleanFlag, CustomOptions, Deprecation, Flag, FlagDefinition, OptionFlag} from './parser' -export type {Configuration, PJSON, S3, S3Templates, UserPJSON} from './pjson' +export type {OclifConfiguration, PJSON, S3, S3Templates, UserPJSON} from './pjson' export type {Options, Plugin, PluginOptions} from './plugin' export type {S3Manifest} from './s3-manifest' export type {Theme} from './theme' diff --git a/src/interfaces/pjson.ts b/src/interfaces/pjson.ts index c4430facf..1cb97f227 100644 --- a/src/interfaces/pjson.ts +++ b/src/interfaces/pjson.ts @@ -107,6 +107,7 @@ export type S3 = { folder?: string | undefined gz?: boolean | undefined host?: string | undefined + indexVersionLimit?: number | undefined templates?: | { target: S3Templates @@ -116,7 +117,7 @@ export type S3 = { xz?: boolean | undefined } -export type Configuration = { +export type OclifConfiguration = { /** * Flags in addition to --help that should trigger help output. */ @@ -241,7 +242,7 @@ export type Configuration = { [k: string]: { description?: string hidden?: boolean - subtopics?: Configuration['topics'] + subtopics?: OclifConfiguration['topics'] } } update?: { @@ -250,12 +251,12 @@ export type Configuration = { rollout?: number } disableNpmLookup?: boolean - node: { + node?: { targets?: string[] version?: string options?: string | string[] } - s3: S3 + s3?: S3 } 'warn-if-update-available'?: { authorization?: string @@ -299,6 +300,6 @@ export type PJSON = { dependencies?: {[name: string]: string} devDependencies?: {[name: string]: string} name: string - oclif: Configuration + oclif: OclifConfiguration version: string } diff --git a/test/config/config.test.ts b/test/config/config.test.ts index b10765e66..2726f5c4c 100644 --- a/test/config/config.test.ts +++ b/test/config/config.test.ts @@ -227,7 +227,6 @@ describe('Config', () => { ...pjson, oclif: { ...pjson.oclif, - // @ts-expect-error - not worth stubbing out every single required prop on s3 update: { s3: { host: 'https://bar.com/a/',