diff --git a/src/cli/domain/clean.ts b/src/cli/domain/clean.ts index 609cbfb3b..a584e2392 100644 --- a/src/cli/domain/clean.ts +++ b/src/cli/domain/clean.ts @@ -5,19 +5,27 @@ import path from 'path'; const getComponentsByDir = makeGetComponentsByDir(); -export function fetchList(dirPath: string, callback: Callback): void { +export function fetchList( + dirPath: string, + callback: (err: Error | null, data: string[]) => void +): void { return getComponentsByDir(dirPath, (err, list) => { if (err) return (callback as any)(err); if (list.length === 0) return callback(null, []); const toRemove = list.map(folder => path.join(folder, 'node_modules')); - const folderExists = (folder: string, cb: Callback) => - fs.exists(folder, exists => cb(null, exists)); + const folderExists = ( + folder: string, + cb: (err: Error | null, data: boolean) => void + ) => fs.exists(folder, exists => cb(null, exists)); async.filterSeries(toRemove, folderExists, callback as any); }); } -export function remove(list: string[], callback: Callback): void { +export function remove( + list: string[], + callback: (err: Error | null, data: string) => void +): void { return async.eachSeries(list, fs.remove, callback as any); } diff --git a/src/cli/domain/get-components-by-dir.ts b/src/cli/domain/get-components-by-dir.ts index 7abc90c90..8a4cc7baf 100644 --- a/src/cli/domain/get-components-by-dir.ts +++ b/src/cli/domain/get-components-by-dir.ts @@ -3,7 +3,10 @@ import path from 'path'; import { Component } from '../../types'; export default function getComponentsByDir() { - return (componentsDir: string, callback: Callback): void => { + return ( + componentsDir: string, + callback: (err: Error | null, data: string[]) => void + ): void => { const isOcComponent = function (file: string) { const filePath = path.resolve(componentsDir, file); const packagePath = path.join(filePath, 'package.json'); diff --git a/src/cli/domain/get-mocked-plugins.ts b/src/cli/domain/get-mocked-plugins.ts index aae8dbd01..d4364c961 100644 --- a/src/cli/domain/get-mocked-plugins.ts +++ b/src/cli/domain/get-mocked-plugins.ts @@ -45,7 +45,7 @@ const defaultRegister = ( }; const registerStaticMocks = ( - mocks: Dictionary, + mocks: Record, logger: Logger ): PluginMock[] => _.map(mocks, (mockedValue, pluginName) => { @@ -62,7 +62,7 @@ const registerStaticMocks = ( const registerDynamicMocks = ( ocJsonLocation: string, - mocks: Dictionary, + mocks: Record, logger: Logger ) => _.map(mocks, (source, pluginName) => { diff --git a/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts b/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts index 49d511d16..06bbb34ce 100644 --- a/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts +++ b/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts @@ -7,7 +7,7 @@ export default function ensureCompilerIsDeclaredAsDevDependency( pkg: Component; template: string; }, - cb: Callback + cb: (err: string | null, data: string) => void ): void { const { componentPath, pkg, template } = options; const compilerDep = `${template}-compiler`; diff --git a/src/cli/domain/handle-dependencies/get-compiler.ts b/src/cli/domain/handle-dependencies/get-compiler.ts index 03cc434fd..120ae11dc 100644 --- a/src/cli/domain/handle-dependencies/get-compiler.ts +++ b/src/cli/domain/handle-dependencies/get-compiler.ts @@ -10,9 +10,9 @@ export default function getCompiler( compilerDep: string; componentPath: string; logger: Logger; - pkg: { devDependencies: Dictionary }; + pkg: { devDependencies: Record }; }, - cb: Callback + cb: (err: string | number | null, data: Template) => void ): void { const { compilerDep, componentPath, logger, pkg } = options; const compilerPath = path.join(componentPath, 'node_modules', compilerDep); diff --git a/src/cli/domain/handle-dependencies/index.ts b/src/cli/domain/handle-dependencies/index.ts index 7d6a1cbf0..6230048fa 100644 --- a/src/cli/domain/handle-dependencies/index.ts +++ b/src/cli/domain/handle-dependencies/index.ts @@ -14,7 +14,7 @@ import { Component } from '../../../types'; const getComponentPackageJson = ( componentPath: string, - cb: Callback + cb: (err: Error | null, data: Component) => void ) => fs.readJson(path.join(componentPath, 'package.json'), cb); const union = (a: ReadonlyArray, b: ReadonlyArray) => [ @@ -27,25 +27,25 @@ export default function handleDependencies( logger: Logger; useComponentDependencies?: boolean; }, - callback: Callback< - { + callback: ( + err: string | null, + data: { modules: string[]; templates: Array<(...args: unknown[]) => unknown>; - }, - string - > + } + ) => void ): void { const { components, logger, useComponentDependencies } = options; - const dependencies: Dictionary = {}; - const addDependencies = (componentDependencies?: Dictionary) => + const dependencies: Record = {}; + const addDependencies = (componentDependencies?: Record) => Object.entries(componentDependencies || {}).forEach( ([dependency, version]) => { dependencies[dependency] = version; } ); - const templates: Dictionary<(...args: unknown[]) => unknown> = {}; + const templates: Record unknown> = {}; const addTemplate = ( templateName: string, template: (...args: unknown[]) => unknown @@ -59,15 +59,19 @@ export default function handleDependencies( ) => async.waterfall( [ - (cb: Callback) => getComponentPackageJson(componentPath, cb), + (cb: (err: Error | null, data: Component) => void) => + getComponentPackageJson(componentPath, cb), ( pkg: Component, - cb: Callback<{ - componentPath: string; - logger: Logger; - pkg: Component; - template: string; - }> + cb: ( + err: Error | null, + data: { + componentPath: string; + logger: Logger; + pkg: Component; + template: string; + } + ) => void ) => { addDependencies(pkg.dependencies); @@ -96,7 +100,7 @@ export default function handleDependencies( options: { componentPath: string; logger: Logger; - pkg: Component & { devDependencies: Dictionary }; + pkg: Component & { devDependencies: Record }; template: string; compilerDep: string; }, diff --git a/src/cli/domain/handle-dependencies/install-compiler.ts b/src/cli/domain/handle-dependencies/install-compiler.ts index 22e989cbe..9035ee73f 100644 --- a/src/cli/domain/handle-dependencies/install-compiler.ts +++ b/src/cli/domain/handle-dependencies/install-compiler.ts @@ -12,7 +12,7 @@ export default function installCompiler( dependency: string; logger: Logger; }, - cb: Callback + cb: (err: string | number | null, data: Template) => void ): void { const { compilerPath, componentPath, dependency, logger } = options; diff --git a/src/cli/domain/handle-dependencies/install-missing-dependencies.ts b/src/cli/domain/handle-dependencies/install-missing-dependencies.ts index 202977ec2..315f80aaf 100644 --- a/src/cli/domain/handle-dependencies/install-missing-dependencies.ts +++ b/src/cli/domain/handle-dependencies/install-missing-dependencies.ts @@ -6,7 +6,7 @@ import strings from '../../../resources/index'; import { Logger } from '../../logger'; export default function installMissingDependencies( - options: { dependencies: Dictionary; logger: Logger }, + options: { dependencies: Record; logger: Logger }, callback: (err: string | null) => void ): void { const { dependencies, logger } = options; diff --git a/src/cli/domain/handle-dependencies/link-missing-dependencies.ts b/src/cli/domain/handle-dependencies/link-missing-dependencies.ts index fb6bf2f81..39704ad63 100644 --- a/src/cli/domain/handle-dependencies/link-missing-dependencies.ts +++ b/src/cli/domain/handle-dependencies/link-missing-dependencies.ts @@ -8,7 +8,7 @@ import { Logger } from '../../logger'; export default function linkMissingDependencies( options: { componentPath: string; - dependencies: Dictionary; + dependencies: Record; logger: Logger; }, callback: (err: string | null) => void diff --git a/src/cli/domain/handle-dependencies/require-template.ts b/src/cli/domain/handle-dependencies/require-template.ts index 16d8bcb4c..ed9a9b16e 100644 --- a/src/cli/domain/handle-dependencies/require-template.ts +++ b/src/cli/domain/handle-dependencies/require-template.ts @@ -17,7 +17,7 @@ interface Template { verbose: boolean; production: boolean | undefined; }, - cb: Callback + cb: (err: Error | null, data: Component) => void ) => void; } diff --git a/src/cli/domain/init-template/index.ts b/src/cli/domain/init-template/index.ts index c9e58821d..5322fda4c 100644 --- a/src/cli/domain/init-template/index.ts +++ b/src/cli/domain/init-template/index.ts @@ -15,7 +15,7 @@ export default function initTemplate( compiler: string; logger: Logger; }, - callback: Callback<{ ok: true }, string> + callback: (err: string | null, data: { ok: true }) => void ): void { const { compiler, componentPath } = options; const compilerPath = path.join(componentPath, 'node_modules', compiler); diff --git a/src/cli/domain/init-template/install-template.ts b/src/cli/domain/init-template/install-template.ts index 7eaa39ea7..91471b6fa 100644 --- a/src/cli/domain/init-template/install-template.ts +++ b/src/cli/domain/init-template/install-template.ts @@ -14,7 +14,7 @@ interface Options { export default function installTemplate( options: Options, - callback: Callback<{ ok: true }, string> + callback: (err: string | null, data: { ok: true }) => void ): void { const { compiler, componentPath, logger, templateType } = options; diff --git a/src/cli/domain/init-template/scaffold.ts b/src/cli/domain/init-template/scaffold.ts index 3aa69e351..c3491dd83 100644 --- a/src/cli/domain/init-template/scaffold.ts +++ b/src/cli/domain/init-template/scaffold.ts @@ -13,7 +13,7 @@ interface ScaffoldOptions { export default function scaffold( options: ScaffoldOptions, - callback: Callback<{ ok: true }, string> + callback: (err: string | null, data: { ok: true }) => void ): void { const { compiler, compilerPath, componentName, componentPath, templateType } = options; diff --git a/src/cli/domain/package-components.ts b/src/cli/domain/package-components.ts index 93e5fee60..0a4780a52 100644 --- a/src/cli/domain/package-components.ts +++ b/src/cli/domain/package-components.ts @@ -14,7 +14,10 @@ interface PackageOptions { const packageComponents = () => - (options: PackageOptions, callback: Callback): void => { + ( + options: PackageOptions, + callback: (err: Error | null, data: Component) => void + ): void => { const production = options.production; const componentPath = options.componentPath; const minify = options.minify === true; diff --git a/src/cli/domain/registry.ts b/src/cli/domain/registry.ts index 968385011..367c10cf7 100644 --- a/src/cli/domain/registry.ts +++ b/src/cli/domain/registry.ts @@ -28,7 +28,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli { }; return { - add(registry: string, callback: Callback) { + add(registry: string, callback: (err: string | null, data: null) => void) { if (registry.slice(registry.length - 1) !== '/') { registry += '/'; } @@ -64,7 +64,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli { } ); }, - get(callback: Callback) { + get(callback: (err: string | null, data: string[]) => void) { if (opts.registry) { return callback(null, [opts.registry]); } @@ -79,7 +79,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli { }, getApiComponentByHref( href: string, - callback: Callback + callback: (err: Error | number | null, data: unknown) => void ) { request( { @@ -92,7 +92,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli { }, getComponentPreviewUrlByUrl( componentHref: string, - callback: Callback + callback: (err: Error | number | null, data: string) => void ) { request( { @@ -120,7 +120,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli { route: string; path: string; }, - callback: Callback + callback: (err: string | null, data: unknown) => void ) { if (!!options.username && !!options.password) { requestsHeaders = Object.assign(requestsHeaders, { @@ -157,7 +157,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli { callback(err, res); }); }, - remove(registry: string, callback: Callback) { + remove(registry: string, callback: (err: Error | null) => void) { if (registry.slice(registry.length - 1) !== '/') { registry += '/'; } diff --git a/src/cli/facade/dev.ts b/src/cli/facade/dev.ts index b020aaa4a..4425ab9d6 100644 --- a/src/cli/facade/dev.ts +++ b/src/cli/facade/dev.ts @@ -32,7 +32,7 @@ const dev = verbose?: boolean; production?: boolean; }, - callback: Callback + callback: (err: Error | string | null, data: Registry) => void ): void => { const componentsDir = opts.dirPath; const port = opts.port || 3000; diff --git a/src/cli/facade/init.ts b/src/cli/facade/init.ts index 6b057ec8e..c4dfd2d78 100644 --- a/src/cli/facade/init.ts +++ b/src/cli/facade/init.ts @@ -12,7 +12,7 @@ const init = componentPath: string; templateType: string; }, - callback: Callback + callback: (err: Error | null, data: string) => void ): void => { const templateType = typeof opts.templateType === 'undefined' diff --git a/src/cli/facade/package.ts b/src/cli/facade/package.ts index c5cdfd379..5129f1fe9 100644 --- a/src/cli/facade/package.ts +++ b/src/cli/facade/package.ts @@ -12,7 +12,7 @@ const cliPackage = useComponentDependencies?: boolean; compress?: boolean; }, - callback: Callback + callback: (err: string | null, data: Component) => void ): void => { const componentPath = opts.componentPath; const useComponentDependencies = opts.useComponentDependencies; diff --git a/src/cli/facade/preview.ts b/src/cli/facade/preview.ts index 5a0e54bc3..f2f46ee88 100644 --- a/src/cli/facade/preview.ts +++ b/src/cli/facade/preview.ts @@ -8,7 +8,7 @@ const preview = ({ logger, registry }: { logger: Logger; registry: RegistryCli }) => ( opts: { componentHref: string }, - callback: Callback + callback: (err: string | null, data: string) => void ): void => { registry.getComponentPreviewUrlByUrl(opts.componentHref, (err, href) => { if (err) { diff --git a/src/cli/facade/publish.ts b/src/cli/facade/publish.ts index 16c19671c..12769dd6a 100644 --- a/src/cli/facade/publish.ts +++ b/src/cli/facade/publish.ts @@ -36,11 +36,15 @@ const publish = let errorMessage; - const readPackageJson = (cb: Callback) => - fs.readJson(path.join(packageDir, 'package.json'), cb); + const readPackageJson = ( + cb: (err: Error | null, data: Component) => void + ) => fs.readJson(path.join(packageDir, 'package.json'), cb); const getCredentials = ( - cb: Callback<{ username: string; password: string }> + cb: ( + err: Error | null, + data: { username: string; password: string } + ) => void ) => { if (opts.username && opts.password) { logger.ok(strings.messages.cli.USING_CREDS); @@ -62,7 +66,9 @@ const publish = local.compress(packageDir, compressedPackagePath, cb); }; - const packageAndCompress = (cb: Callback) => { + const packageAndCompress = ( + cb: (err: Error | string | null, data: Component) => void + ) => { logger.warn(strings.messages.cli.PACKAGING(packageDir)); const packageOptions = { production: true, @@ -92,7 +98,7 @@ const publish = username?: string; password?: string; }, - cb: Callback<'ok', string> + cb: (err: string | null, data: 'ok') => void ) => { logger.warn(strings.messages.cli.PUBLISHING(options.route)); diff --git a/src/cli/facade/registry-add.ts b/src/cli/facade/registry-add.ts index dae724044..942ca60d7 100644 --- a/src/cli/facade/registry-add.ts +++ b/src/cli/facade/registry-add.ts @@ -4,7 +4,10 @@ import { Logger } from '../logger'; const registryAdd = ({ registry, logger }: { logger: Logger; registry: RegistryCli }) => - (opts: { registryUrl: string }, callback: Callback): void => { + ( + opts: { registryUrl: string }, + callback: (err: string | null, data: string) => void + ): void => { registry.add(opts.registryUrl, err => { if (err) { logger.err(err); diff --git a/src/cli/facade/registry-ls.ts b/src/cli/facade/registry-ls.ts index 82b392922..dc653f5c5 100644 --- a/src/cli/facade/registry-ls.ts +++ b/src/cli/facade/registry-ls.ts @@ -4,7 +4,10 @@ import { Logger } from '../logger'; const registryLs = ({ registry, logger }: { logger: Logger; registry: RegistryCli }) => - (_opts: unknown, callback: Callback): void => { + ( + _opts: unknown, + callback: (err: string | null, data: string[]) => void + ): void => { registry.get((err, registries) => { if (err) { logger.err(strings.errors.generic(err)); diff --git a/src/cli/facade/registry-remove.ts b/src/cli/facade/registry-remove.ts index f9d9e1921..8a7bb9c52 100644 --- a/src/cli/facade/registry-remove.ts +++ b/src/cli/facade/registry-remove.ts @@ -4,7 +4,10 @@ import { Logger } from '../logger'; const registryRemove = ({ registry, logger }: { logger: Logger; registry: RegistryCli }) => - (opts: { registryUrl: string }, callback: Callback): void => { + ( + opts: { registryUrl: string }, + callback: (err: Error | null, data: string) => void + ): void => { registry.remove(opts.registryUrl, err => { if (err) { logger.err(String(err)); diff --git a/src/cli/facade/registry.ts b/src/cli/facade/registry.ts index 250ea3a1e..95f6ad83e 100644 --- a/src/cli/facade/registry.ts +++ b/src/cli/facade/registry.ts @@ -1,6 +1,6 @@ const registry = () => - (_opts: unknown, callback: Callback<'ok'>): void => { + (_opts: unknown, callback: (err: Error | null, data: 'ok') => void): void => { callback(null, 'ok'); }; diff --git a/src/cli/index.ts b/src/cli/index.ts index 6e8f049cc..6ed0f9ce6 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -61,7 +61,7 @@ type Command = { cmd: string; }; options?: any; - commands?: Dictionary; + commands?: Record; }; function processCommand( diff --git a/src/globals.d.ts b/src/globals.d.ts index c6dcbaa5b..154f162b7 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -20,9 +20,10 @@ declare module 'require-package-name' { export = requirePackageName; } declare module 'getport' { - function getPort(cb: Callback): void; - function getPort(start: number, cb: Callback): void; - function getPort(start: number, end: number, cb: Callback): void; + function getPort( + start: number, + cb: (err: unknown, data: number) => void + ): void; export = getPort; } @@ -44,7 +45,7 @@ declare module 'minimal-request' { method?: string; body?: unknown; url: string; - headers?: Dictionary; + headers?: Record; json?: boolean; }, cb: ( @@ -52,7 +53,7 @@ declare module 'minimal-request' { body: T, details: { response: { - headers: Dictionary; + headers: Record; }; } ) => void @@ -62,10 +63,3 @@ declare module 'minimal-request' { export = request; } - -declare type Callback = ( - err: E | null, - data: T -) => void; - -declare type Dictionary = Record; diff --git a/src/registry/app-start.ts b/src/registry/app-start.ts index 91f596b4d..b96931f31 100644 --- a/src/registry/app-start.ts +++ b/src/registry/app-start.ts @@ -18,7 +18,7 @@ const packageInfo = fs.readJsonSync( export default function appStart( repository: Repository, options: Config, - callback: Callback + callback: (err: any | null, data: ComponentsDetails | string) => void ): void { if (options.local) { return callback(null, 'ok'); diff --git a/src/registry/domain/authentication.ts b/src/registry/domain/authentication.ts index bfc5548ec..4ee99864b 100644 --- a/src/registry/domain/authentication.ts +++ b/src/registry/domain/authentication.ts @@ -35,7 +35,7 @@ const basicAuthentication: Authentication<{ } }; -const builtin: Dictionary = { +const builtin: Record = { basic: basicAuthentication }; diff --git a/src/registry/domain/components-cache/components-list.ts b/src/registry/domain/components-cache/components-list.ts index 306c7e9ae..7199a7214 100644 --- a/src/registry/domain/components-cache/components-list.ts +++ b/src/registry/domain/components-cache/components-list.ts @@ -8,15 +8,17 @@ export default function componentsList(conf: Config, cdn: Cdn) { `${conf.storage.options.componentsDir}/components.json`; const componentsList = { - getFromJson: (callback: Callback) => + getFromJson: (callback: (err: string | null, data: any) => void) => cdn.getJson(filePath(), true, callback), - getFromDirectories: (callback: Callback) => { - const componentsInfo: Dictionary = {}; + getFromDirectories: ( + callback: (err: string | null, data: ComponentsList) => void + ) => { + const componentsInfo: Record = {}; const getVersionsForComponent = ( componentName: string, - cb: Callback + cb: (err: Error | null, data: string[]) => void ) => { cdn.listSubDirectories( `${conf.storage.options.componentsDir}/${componentName}`, @@ -66,7 +68,7 @@ export default function componentsList(conf: Config, cdn: Cdn) { ); }, - refresh(callback: Callback) { + refresh(callback: (err: string | null, data: ComponentsList) => void) { componentsList.getFromDirectories((err, components) => { if (err) { return callback(err, undefined as any); @@ -80,8 +82,10 @@ export default function componentsList(conf: Config, cdn: Cdn) { }); }, - save: (data: ComponentsList, callback: Callback) => - cdn.putFileContent(JSON.stringify(data), filePath(), true, callback) + save: ( + data: ComponentsList, + callback: (err: string | null, data: unknown) => void + ) => cdn.putFileContent(JSON.stringify(data), filePath(), true, callback) }; return componentsList; diff --git a/src/registry/domain/components-cache/index.ts b/src/registry/domain/components-cache/index.ts index 9fb40231e..e40f739e1 100644 --- a/src/registry/domain/components-cache/index.ts +++ b/src/registry/domain/components-cache/index.ts @@ -41,14 +41,14 @@ export default function componentsCache(conf: Config, cdn: Cdn) { const returnError = ( code: string, message: string, - callback: Callback + callback: (err: any | null, data: any) => void ) => { eventsHandler.fire('error', { code, message }); return callback(code, undefined as any); }; return { - get(callback: Callback) { + get(callback: (err: Error | null, data: ComponentsList) => void) { if (!cachedComponentsList) { return returnError( 'components_cache_empty', @@ -60,7 +60,7 @@ export default function componentsCache(conf: Config, cdn: Cdn) { callback(null, cachedComponentsList); }, - load(callback: Callback) { + load(callback: (err: Error | null, data: ComponentsList) => void) { componentsList.getFromJson((jsonErr, jsonComponents) => { componentsList.getFromDirectories((dirErr, dirComponents) => { if (dirErr) { @@ -81,7 +81,7 @@ export default function componentsCache(conf: Config, cdn: Cdn) { }); }); }, - refresh(callback: Callback) { + refresh(callback: (err: Error | null, data: ComponentsList) => void) { clearTimeout(refreshLoop); componentsList.refresh((err, components) => { if (err) { diff --git a/src/registry/domain/components-details.ts b/src/registry/domain/components-details.ts index 6a159d917..8f89e132a 100644 --- a/src/registry/domain/components-details.ts +++ b/src/registry/domain/components-details.ts @@ -26,12 +26,13 @@ export default function componentsDetails(conf: Config, cdn: Cdn) { const filePath = (): string => `${conf.storage.options.componentsDir}/components-details.json`; - const getFromJson = (callback: Callback) => - cdn.getJson(filePath(), true, callback); + const getFromJson = ( + callback: (err: string | null, data: ComponentsDetails) => void + ) => cdn.getJson(filePath(), true, callback); const getFromDirectories = ( options: { componentsList: ComponentsList; details: ComponentsDetails }, - callback: Callback + callback: (err: Error | undefined | null, data: ComponentsDetails) => void ) => { const details = Object.assign({}, _.cloneDeep(options.details)); details.components = details.components || {}; @@ -72,12 +73,14 @@ export default function componentsDetails(conf: Config, cdn: Cdn) { ); }; - const save = (data: ComponentsDetails, callback: Callback) => - cdn.putFileContent(JSON.stringify(data), filePath(), true, callback); + const save = ( + data: ComponentsDetails, + callback: (err: string | null, data: unknown) => void + ) => cdn.putFileContent(JSON.stringify(data), filePath(), true, callback); const refresh = ( componentsList: ComponentsList, - callback: Callback + callback: (err: Error | null, data: ComponentsDetails) => void ) => { getFromJson((jsonErr, details: ComponentsDetails) => { getFromDirectories( diff --git a/src/registry/domain/extract-package.ts b/src/registry/domain/extract-package.ts index 864762be6..d4b75f1dc 100644 --- a/src/registry/domain/extract-package.ts +++ b/src/registry/domain/extract-package.ts @@ -10,10 +10,13 @@ export default function extractPackage( | { [fieldname: string]: Express.Multer.File[]; }, - callback: Callback<{ - outputFolder: string; - packageJson: PackageJson; - }> + callback: ( + err: Error | null, + data: { + outputFolder: string; + packageJson: PackageJson; + } + ) => void ): void { const packageFile: Express.Multer.File = (files as any)[0]; const packagePath = path.resolve(packageFile.path); diff --git a/src/registry/domain/get-package-json-from-temp-dir.ts b/src/registry/domain/get-package-json-from-temp-dir.ts index 729050477..103f88fba 100644 --- a/src/registry/domain/get-package-json-from-temp-dir.ts +++ b/src/registry/domain/get-package-json-from-temp-dir.ts @@ -4,7 +4,7 @@ import { PackageJson } from 'type-fest'; export default function getPackageJsonFromTempDir( tempDirPath: string, - callback: Callback + callback: (err: Error | null, data: PackageJson) => void ): void { return fs.readJson(path.join(tempDirPath, 'package.json'), callback); } diff --git a/src/registry/domain/nested-renderer.ts b/src/registry/domain/nested-renderer.ts index e4bd81644..8622782ea 100644 --- a/src/registry/domain/nested-renderer.ts +++ b/src/registry/domain/nested-renderer.ts @@ -5,12 +5,12 @@ import settings from '../../resources/settings'; import strings from '../../resources'; import { Config } from '../../types'; -type Cb = Callback; +type Cb = (err: string | null, data: string) => void; type Options = { version?: string; name?: string; - headers?: Dictionary; - parameters?: Dictionary; + headers?: Record; + parameters?: Record; }; type Params = { components: Options[]; diff --git a/src/registry/domain/plugins-initialiser.ts b/src/registry/domain/plugins-initialiser.ts index 0b8f5160e..065395842 100644 --- a/src/registry/domain/plugins-initialiser.ts +++ b/src/registry/domain/plugins-initialiser.ts @@ -55,9 +55,12 @@ const defer = function (plugin: Plugin, cb: (err?: Error) => void) { export function init( pluginsToRegister: unknown[], - callback: Callback void>, unknown> + callback: ( + err: unknown, + data: Record void> + ) => void ): void { - const registered: Dictionary<(...args: unknown[]) => void> = {}; + const registered: Record void> = {}; try { validatePlugins(pluginsToRegister); diff --git a/src/registry/domain/register-templates.ts b/src/registry/domain/register-templates.ts index 820ca36fc..524c16c6b 100644 --- a/src/registry/domain/register-templates.ts +++ b/src/registry/domain/register-templates.ts @@ -5,7 +5,7 @@ import { Template, TemplateInfo } from '../../types'; import _ from 'lodash'; export default function registerTemplates(extraTemplates: Template[]): { - templatesHash: Dictionary