@kubb/core
Advanced tools
Comparing version
@@ -143,3 +143,3 @@ import { DirectoryTreeOptions } from 'directory-tree'; | ||
*/ | ||
resolveName: (this: PluginContext, name: string) => string | null; | ||
resolveName: (this: PluginContext, name: string) => string; | ||
/** | ||
@@ -164,3 +164,3 @@ * Makes it possible to run async logic to override the path defined previously by `resolvePath`. | ||
*/ | ||
buildEnd: (this: Omit<PluginContext, 'addFile'>) => MaybePromise<void>; | ||
buildEnd: (this: PluginContext) => MaybePromise<void>; | ||
}; | ||
@@ -193,5 +193,5 @@ type PluginLifecycleHooks = keyof PluginLifecycle; | ||
fileManager: FileManager; | ||
addFile: (file: File) => Promise<File>; | ||
addFile: (...file: File[]) => Promise<File[]>; | ||
resolvePath: (params: ResolvePathParams<TOptions>) => OptionalPath; | ||
resolveName: (params: ResolveNameParams) => string | null; | ||
resolveName: (params: ResolveNameParams) => string; | ||
load: (id: string) => MaybePromise<TransformResult | void>; | ||
@@ -381,3 +381,3 @@ }; | ||
resolvePath: (params: ResolvePathParams) => OptionalPath; | ||
resolveName: (params: ResolveNameParams) => string | null; | ||
resolveName: (params: ResolveNameParams) => string; | ||
load: (id: string) => Promise<TransformResult>; | ||
@@ -397,3 +397,3 @@ /** | ||
parameters: Parameters<PluginLifecycle[H]>; | ||
}): ReturnType<PluginLifecycle[H]> | null; | ||
}): ReturnType<PluginLifecycle[H]>; | ||
/** | ||
@@ -407,3 +407,3 @@ * | ||
skipped?: ReadonlySet<KubbPlugin> | null; | ||
}): Promise<ReturnType<PluginLifecycle[H]> | null>; | ||
}): Promise<ReturnType<PluginLifecycle[H]>>; | ||
/** | ||
@@ -417,3 +417,3 @@ * | ||
skipped?: ReadonlySet<KubbPlugin> | null; | ||
}): ReturnType<PluginLifecycle[H]> | null; | ||
}): ReturnType<PluginLifecycle[H]>; | ||
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, }: { | ||
@@ -420,0 +420,0 @@ hookName: H; |
@@ -91,3 +91,3 @@ import { createRequire } from 'module'; | ||
if (!rootDir || !filePath) { | ||
throw new Error("Root and file should be filled in when retrieving the relativePath"); | ||
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir} ${filePath}`); | ||
} | ||
@@ -240,4 +240,4 @@ const relativePath = pathParser2.relative(rootDir, filePath); | ||
fileManager, | ||
async addFile(file) { | ||
return fileManager.addOrAppend(file); | ||
async addFile(...files) { | ||
return Promise.all(files.map((file) => fileManager.addOrAppend(file))); | ||
}, | ||
@@ -253,7 +253,5 @@ resolvePath, | ||
api, | ||
resolvePath(fileName, directory) { | ||
if (!directory) { | ||
return null; | ||
} | ||
return pathParser2.resolve(directory, fileName); | ||
resolvePath(fileName) { | ||
const root = pathParser2.resolve(this.config.root, this.config.output.path); | ||
return pathParser2.resolve(root, fileName); | ||
}, | ||
@@ -260,0 +258,0 @@ resolveName(name2) { |
{ | ||
"name": "@kubb/core", | ||
"version": "1.0.0-beta.11", | ||
"version": "1.0.0-beta.12", | ||
"description": "Generator core", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -128,3 +128,3 @@ /* eslint-disable no-await-in-loop */ | ||
parameters: Parameters<PluginLifecycle[H]> | ||
}): ReturnType<PluginLifecycle[H]> | null { | ||
}): ReturnType<PluginLifecycle[H]> { | ||
const plugin = this.getPlugin(hookName, pluginName) | ||
@@ -152,4 +152,4 @@ | ||
skipped?: ReadonlySet<KubbPlugin> | null | ||
}): Promise<ReturnType<PluginLifecycle[H]> | null> { | ||
let promise: Promise<ReturnType<PluginLifecycle[H]> | null> = Promise.resolve(null) | ||
}): Promise<ReturnType<PluginLifecycle[H]>> { | ||
let promise: Promise<ReturnType<PluginLifecycle[H]>> = Promise.resolve(null as ReturnType<PluginLifecycle[H]>) | ||
for (const plugin of this.getSortedPlugins(hookName)) { | ||
@@ -182,3 +182,3 @@ if (skipped && skipped.has(plugin)) continue | ||
skipped?: ReadonlySet<KubbPlugin> | null | ||
}): ReturnType<PluginLifecycle[H]> | null { | ||
}): ReturnType<PluginLifecycle[H]> { | ||
let result = null | ||
@@ -189,3 +189,3 @@ | ||
result = this.runSync({ | ||
result = this.runSync<H>({ | ||
strategy: 'hookFirst', | ||
@@ -201,3 +201,3 @@ hookName, | ||
} | ||
return result | ||
return result as ReturnType<PluginLifecycle[H]> | ||
} | ||
@@ -212,3 +212,3 @@ | ||
parameters?: Parameters<PluginLifecycle[H]> | undefined | ||
}) { | ||
}): Promise<Awaited<TOuput>[]> { | ||
const parallelPromises: Promise<TOuput>[] = [] | ||
@@ -215,0 +215,0 @@ |
@@ -51,4 +51,4 @@ import pathParser from 'path' | ||
fileManager, | ||
async addFile(file) { | ||
return fileManager.addOrAppend(file) | ||
async addFile(...files) { | ||
return Promise.all(files.map((file) => fileManager.addOrAppend(file))) | ||
}, | ||
@@ -65,7 +65,6 @@ resolvePath, | ||
api, | ||
resolvePath(fileName, directory) { | ||
if (!directory) { | ||
return null | ||
} | ||
return pathParser.resolve(directory, fileName) | ||
resolvePath(fileName) { | ||
const root = pathParser.resolve(this.config.root, this.config.output.path) | ||
return pathParser.resolve(root, fileName) | ||
}, | ||
@@ -72,0 +71,0 @@ resolveName(name) { |
@@ -149,3 +149,3 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ | ||
*/ | ||
resolveName: (this: PluginContext, name: string) => string | null | ||
resolveName: (this: PluginContext, name: string) => string | ||
/** | ||
@@ -170,3 +170,3 @@ * Makes it possible to run async logic to override the path defined previously by `resolvePath`. | ||
*/ | ||
buildEnd: (this: Omit<PluginContext, 'addFile'>) => MaybePromise<void> | ||
buildEnd: (this: PluginContext) => MaybePromise<void> | ||
} | ||
@@ -203,5 +203,5 @@ | ||
fileManager: FileManager | ||
addFile: (file: File) => Promise<File> | ||
addFile: (...file: File[]) => Promise<File[]> | ||
resolvePath: (params: ResolvePathParams<TOptions>) => OptionalPath | ||
resolveName: (params: ResolveNameParams) => string | null | ||
resolveName: (params: ResolveNameParams) => string | ||
load: (id: string) => MaybePromise<TransformResult | void> | ||
@@ -208,0 +208,0 @@ } |
@@ -16,3 +16,3 @@ import pathParser from 'path' | ||
if (!rootDir || !filePath) { | ||
throw new Error('Root and file should be filled in when retrieving the relativePath') | ||
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir} ${filePath}`) | ||
} | ||
@@ -19,0 +19,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
214607
0.31%3547
-0.17%