@kubb/core 2.4.1 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OYDUQYAK.cjs → chunk-3J25BT5A.cjs} +15 -41
- package/dist/chunk-3J25BT5A.cjs.map +1 -0
- package/dist/{chunk-HI4PB2AG.js → chunk-DJBEBMX6.js} +10 -36
- package/dist/chunk-DJBEBMX6.js.map +1 -0
- package/dist/{chunk-JSJ3NRBQ.cjs → chunk-SSD2TXQZ.cjs} +51 -32
- package/dist/chunk-SSD2TXQZ.cjs.map +1 -0
- package/dist/{chunk-V6AVJEQC.js → chunk-W3NDP3K4.js} +52 -34
- package/dist/chunk-W3NDP3K4.js.map +1 -0
- package/dist/index.cjs +44 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -56
- package/dist/index.d.ts +54 -56
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/dist/logger-wryz32Ex.d.cts +44 -0
- package/dist/logger-wryz32Ex.d.ts +44 -0
- package/dist/logger.cjs +5 -5
- package/dist/logger.d.cts +2 -32
- package/dist/logger.d.ts +2 -32
- package/dist/logger.js +1 -1
- package/dist/mocks.cjs +5 -11
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +5 -11
- package/dist/mocks.js.map +1 -1
- package/package.json +3 -3
- package/src/FileManager.ts +2 -2
- package/src/PluginManager.ts +39 -39
- package/src/build.ts +11 -13
- package/src/config.ts +5 -5
- package/src/index.ts +3 -15
- package/src/kubb.ts +11 -0
- package/src/logger.ts +37 -37
- package/src/plugin.ts +5 -5
- package/src/types.ts +23 -23
- package/dist/chunk-HI4PB2AG.js.map +0 -1
- package/dist/chunk-JSJ3NRBQ.cjs.map +0 -1
- package/dist/chunk-OYDUQYAK.cjs.map +0 -1
- package/dist/chunk-V6AVJEQC.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { URLPath } from './chunk-STP2UI5Q.js';
|
|
2
2
|
import { clean } from './chunk-IQBEGX4Z.js';
|
|
3
|
-
import { FileManager, PluginManager, isPromise } from './chunk-
|
|
4
|
-
export { FileManager, KubbFile, PluginManager, PromiseManager, Warning, createPlugin, pluginName as name, pluginName } from './chunk-
|
|
3
|
+
import { FileManager, PluginManager, isPromise } from './chunk-DJBEBMX6.js';
|
|
4
|
+
export { FileManager, KubbFile, PluginManager, PromiseManager, Warning, createPlugin, pluginName as name, pluginName } from './chunk-DJBEBMX6.js';
|
|
5
5
|
import './chunk-GKW5TTFV.js';
|
|
6
6
|
import './chunk-YW33IVCC.js';
|
|
7
7
|
import './chunk-GLL5G5KY.js';
|
|
8
|
-
import { LogLevel, createLogger, p, randomCliColour } from './chunk-
|
|
8
|
+
import { LogLevel, createLogger, p, randomCliColour } from './chunk-W3NDP3K4.js';
|
|
9
9
|
import { read, readSync } from './chunk-YUTCMBUY.js';
|
|
10
10
|
import './chunk-MYC5HIA5.js';
|
|
11
11
|
import { init_esm_shims, __privateAdd, __privateSet, __privateGet, __privateMethod } from './chunk-ETA3LCRB.js';
|
|
@@ -95,13 +95,13 @@ async function setup(options) {
|
|
|
95
95
|
const pluginManager = new PluginManager(config, { logger, task });
|
|
96
96
|
pluginManager.on("execute", (executer) => {
|
|
97
97
|
const { hookName, parameters, plugin } = executer;
|
|
98
|
-
if (hookName === "writeFile"
|
|
98
|
+
if (hookName === "writeFile") {
|
|
99
99
|
const [code] = parameters;
|
|
100
100
|
if (logger.logLevel === LogLevel.debug) {
|
|
101
|
-
logger.debug
|
|
101
|
+
logger.emit("debug", [`PluginKey ${p.dim(JSON.stringify(plugin.key))}
|
|
102
102
|
with source
|
|
103
103
|
|
|
104
|
-
${code}`);
|
|
104
|
+
${code}`]);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
});
|
|
@@ -109,8 +109,8 @@ ${code}`);
|
|
|
109
109
|
if (logger.logLevel !== LogLevel.info) {
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
|
-
if (
|
|
113
|
-
logger.
|
|
112
|
+
if (count === 0) {
|
|
113
|
+
logger.emit("start", `\u{1F4BE} Writing`);
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
pluginManager.queue.on("active", () => {
|
|
@@ -142,7 +142,7 @@ ${code}`);
|
|
|
142
142
|
output && `${p.bgWhite("Output")} ${randomCliColour(plugin.name)} ${hookName}`,
|
|
143
143
|
output
|
|
144
144
|
].filter(Boolean);
|
|
145
|
-
logger.
|
|
145
|
+
logger.emit("debug", logs);
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
return pluginManager;
|
|
@@ -155,9 +155,8 @@ async function build(options) {
|
|
|
155
155
|
parameters: [options.config]
|
|
156
156
|
});
|
|
157
157
|
await pluginManager.hookParallel({ hookName: "buildEnd" });
|
|
158
|
-
if (logger.logLevel === LogLevel.info
|
|
159
|
-
logger.
|
|
160
|
-
logger.spinner.succeed(`\u{1F4BE} Writing completed`);
|
|
158
|
+
if (logger.logLevel === LogLevel.info) {
|
|
159
|
+
logger.emit("end", `\u{1F4BE} Writing completed`);
|
|
161
160
|
}
|
|
162
161
|
return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager };
|
|
163
162
|
}
|
|
@@ -170,9 +169,8 @@ async function safeBuild(options) {
|
|
|
170
169
|
parameters: [options.config]
|
|
171
170
|
});
|
|
172
171
|
await pluginManager.hookParallel({ hookName: "buildEnd" });
|
|
173
|
-
if (logger.logLevel === LogLevel.info
|
|
174
|
-
logger.
|
|
175
|
-
logger.spinner.succeed(`\u{1F4BE} Writing completed`);
|
|
172
|
+
if (logger.logLevel === LogLevel.info) {
|
|
173
|
+
logger.emit("end", `\u{1F4BE} Writing completed`);
|
|
176
174
|
}
|
|
177
175
|
} catch (e) {
|
|
178
176
|
return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager, error: e };
|
|
@@ -341,9 +339,10 @@ match_fn = function(packageJSON, dependency) {
|
|
|
341
339
|
__privateAdd(_PackageManager, _cache, {});
|
|
342
340
|
var PackageManager = _PackageManager;
|
|
343
341
|
|
|
344
|
-
// src/
|
|
345
|
-
var
|
|
342
|
+
// src/kubb.ts
|
|
343
|
+
var kubb_exports = {};
|
|
344
|
+
init_esm_shims();
|
|
346
345
|
|
|
347
|
-
export { Generator, PackageManager, build,
|
|
346
|
+
export { Generator, kubb_exports as Kubb, PackageManager, build, build as default, defineConfig, isInputPath, safeBuild };
|
|
348
347
|
//# sourceMappingURL=out.js.map
|
|
349
348
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/build.ts","../src/config.ts","../src/Generator.ts","../src/PackageManager.ts"],"names":["require"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACAA;;;ACAA;AAQO,SAAS,aACd,SAMgB;AAChB,SAAO;AACT;AAEO,SAAS,YAAY,QAAiE;AAC3F,SAAO,CAAC,CAAC,UAAU,UAAW;AAChC;;;ADWA,eAAe,iBAEb,eACA,QACA,SACwB;AACxB,SAAO;AACT;AAEA,eAAe,MAAM,SAA+C;AAClE,QAAM,EAAE,QAAQ,SAAS,aAAa,EAAE,UAAU,SAAS,OAAO,CAAC,EAAE,IAAI;AACzE,MAAI,QAAQ;AAEZ,MAAI;AACF,QAAI,YAAY,MAAM,KAAK,CAAC,IAAI,QAAQ,OAAO,MAAM,IAAI,EAAE,OAAO;AAChE,YAAM,KAAK,OAAO,MAAM,IAAI;AAAA,IAC9B;AAAA,EACF,SAAS,GAAG;AACV,QAAI,YAAY,MAAM,GAAG;AACvB,YAAM,IAAI;AAAA,QACR,kHAAkH,EAAE,IAAI,OAAO,MAAM,IAAI;AAAA,QACzI;AAAA,UACE,OAAO;AAAA,QACT;AAAA,MACF;A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AAU,GAAG;AAC9D,WAAO,aAAa,UAAU;AAAA,EAChC;AAEA,QAAM,oBAAoB,OAAO,KAAK,YAAY,EAAE,KAAK,SAAO,IAAI,MAAM,UAAU,CAAC;AAErF,SAAO,oBAAoB,aAAa,iBAAiB,IAAI;AAC/D;AArGA,aADW,iBACJ,QAAoD,CAAC;AADvD,IAAM,iBAAN;;;AJQP,IAAO,cAAQ","sourcesContent":["import { build } from './build.ts'\n\nimport type { ObjValueTuple, TupleToUnion } from '@kubb/types'\n\nexport { build, safeBuild } from './build.ts'\nexport { defineConfig, isInputPath } from './config.ts'\nexport { Warning } from './errors.ts'\nexport { FileManager, KubbFile } from './FileManager.ts'\nexport { Generator } from './Generator.ts'\nexport { PackageManager } from './PackageManager.ts'\n// dprint-ignore\nexport { createPlugin, pluginName as name, pluginName } from './plugin.ts'\nexport { PluginManager } from './PluginManager.ts'\nexport { PromiseManager } from './PromiseManager.ts'\nexport type * from './types.ts'\n\nexport interface _Register {}\nexport type Plugins = _Register\nexport type OptionsPlugins = { [K in keyof Plugins]: Plugins[K]['options'] }\n\nexport type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options']\n\nexport type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>\n\nexport type Plugin = keyof Plugins\n\nexport default build\n","import c from 'tinyrainbow'\n\nimport { clean } from './fs/clean.ts'\nimport { read } from './fs/read.ts'\nimport { URLPath } from './utils/URLPath.ts'\nimport { isInputPath } from './config.ts'\nimport { FileManager } from './FileManager.ts'\nimport { createLogger, LogLevel, randomCliColour } from './logger.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isPromise } from './PromiseManager.ts'\n\nimport type { KubbFile } from './FileManager.ts'\nimport type { Logger } from './logger.ts'\nimport type { KubbPlugin, PluginContext, PluginParameter, TransformResult } from './types.ts'\n\ntype BuildOptions = {\n config: PluginContext['config']\n /**\n * @default Logger without the spinner\n */\n logger?: Logger\n}\n\ntype BuildOutput = {\n files: FileManager['files']\n pluginManager: PluginManager\n /**\n * Only for safeBuild\n */\n error?: Error\n}\n\nasync function transformReducer(\n this: PluginContext,\n _previousCode: string,\n result: TransformResult | Promise<TransformResult>,\n _plugin: KubbPlugin,\n): Promise<string | null> {\n return result\n}\n\nasync function setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger({ logLevel: LogLevel.silent }) } = options\n let count = 0\n\n try {\n if (isInputPath(config) && !new URLPath(config.input.path).isURL) {\n await read(config.input.path)\n }\n } catch (e) {\n if (isInputPath(config)) {\n throw new Error(\n 'Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config ' + c.dim(config.input.path),\n {\n cause: e,\n },\n )\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n const task = async (file: KubbFile.ResolvedFile): Promise<KubbFile.ResolvedFile> => {\n const { path } = file\n\n let source: string | null = FileManager.getSource(file)\n\n const { result: loadedResult } = await pluginManager.hookFirst({\n hookName: 'load',\n parameters: [path],\n })\n if (loadedResult && isPromise(loadedResult)) {\n source = await loadedResult\n }\n if (loadedResult && !isPromise(loadedResult)) {\n source = loadedResult\n }\n\n if (source) {\n source = await pluginManager.hookReduceArg0({\n hookName: 'transform',\n parameters: [source, path],\n reduce: transformReducer,\n })\n\n if (config.output.write || config.output.write === undefined) {\n if (file.meta?.pluginKey) {\n // run only for pluginKey defined in the meta of the file\n await pluginManager.hookForPlugin({\n pluginKey: file.meta?.pluginKey,\n hookName: 'writeFile',\n parameters: [source, path],\n })\n }\n\n await pluginManager.hookFirst({\n hookName: 'writeFile',\n parameters: [source, path],\n })\n }\n }\n\n return {\n ...file,\n source: source || '',\n }\n }\n\n const pluginManager = new PluginManager(config, { logger, task })\n\n pluginManager.on('execute', (executer) => {\n const { hookName, parameters, plugin } = executer\n\n if (hookName === 'writeFile' && logger.spinner) {\n const [code] = parameters as PluginParameter<'writeFile'>\n\n if (logger.logLevel === LogLevel.debug) {\n logger.debug(`PluginKey ${c.dim(JSON.stringify(plugin.key))} \\nwith source\\n\\n${code}`)\n }\n }\n })\n\n pluginManager.queue.on('add', () => {\n if (logger.logLevel !== LogLevel.info) {\n return\n }\n\n if (logger.spinner && count === 0) {\n logger.spinner?.start(`💾 Writing`)\n }\n })\n\n pluginManager.queue.on('active', () => {\n if (logger.logLevel !== LogLevel.info) {\n return\n }\n\n if (logger.spinner && pluginManager.queue.size > 0) {\n const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`\n\n logger.spinner.suffixText = c.dim(text)\n }\n ;++count\n })\n\n pluginManager.queue.on('completed', () => {\n if (logger.logLevel !== LogLevel.info) {\n return\n }\n\n if (logger.spinner) {\n const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`\n\n logger.spinner.suffixText = c.dim(text)\n }\n })\n\n pluginManager.on('executed', (executer) => {\n const { hookName, plugin, output, parameters } = executer\n\n if (logger.logLevel === LogLevel.debug) {\n const logs = [\n `${randomCliColour(plugin.name)} Executing ${hookName}`,\n parameters && `${c.bgWhite(`Parameters`)} ${randomCliColour(plugin.name)} ${hookName}`,\n JSON.stringify(parameters, undefined, 2),\n output && `${c.bgWhite('Output')} ${randomCliColour(plugin.name)} ${hookName}`,\n output,\n ].filter(Boolean)\n\n logger.debug(logs.join('\\n'))\n }\n })\n\n return pluginManager\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n const { fileManager, logger } = pluginManager\n\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n if (logger.logLevel === LogLevel.info && logger.spinner) {\n logger.spinner.suffixText = ''\n logger.spinner.succeed(`💾 Writing completed`)\n }\n\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n const { fileManager, logger } = pluginManager\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n if (logger.logLevel === LogLevel.info && logger.spinner) {\n logger.spinner.suffixText = ''\n logger.spinner.succeed(`💾 Writing completed`)\n }\n } catch (e) {\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager, error: e as Error }\n }\n\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager }\n}\n","import type { PossiblePromise } from '@kubb/types'\nimport type { CLIOptions, InputPath, KubbConfig, KubbUserConfig } from './types.ts'\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link KubbConfig} object, or a function that returns it.\n * The function receives a {@link ConfigEnv} object that exposes two properties:\n */\nexport function defineConfig(\n options:\n | PossiblePromise<KubbUserConfig | Array<KubbUserConfig>>\n | ((\n /** The options derived from the CLI flags */\n cliOptions: CLIOptions,\n ) => PossiblePromise<KubbUserConfig | Array<KubbUserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: KubbConfig | undefined): result is KubbConfig<InputPath> {\n return !!result && 'path' in (result as any)\n}\n","/**\n * Abstract class that contains the building blocks for plugins to create their own Generator\n * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137\n */\nexport abstract class Generator<TOptions = unknown, TContext = unknown> {\n #options: TOptions = {} as TOptions\n #context: TContext = {} as TContext\n\n constructor(options?: TOptions, context?: TContext) {\n if (context) {\n this.#context = context\n }\n\n if (options) {\n this.#options = options\n }\n\n return this\n }\n\n get options(): TOptions {\n return this.#options\n }\n\n get context(): TContext {\n return this.#context\n }\n\n set options(options: TOptions) {\n this.#options = { ...this.#options, ...options }\n }\n\n abstract build(...params: unknown[]): unknown\n}\n","import mod from 'node:module'\nimport os from 'node:os'\nimport { pathToFileURL } from 'node:url'\n\nimport { findUp, findUpSync } from 'find-up'\nimport { coerce, satisfies } from 'semver'\n\nimport { read, readSync } from './fs/read'\n\ntype PackageJSON = {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n}\n\ntype DependencyName = string\n\ntype DependencyVersion = string\n\nexport class PackageManager {\n static #cache: Record<DependencyName, DependencyVersion> = {}\n\n #cwd?: string\n #SLASHES = new Set(['/', '\\\\'])\n constructor(workspace?: string) {\n if (workspace) {\n this.#cwd = workspace\n }\n\n return this\n }\n\n set workspace(workspace: string) {\n this.#cwd = workspace\n }\n\n get workspace(): string | undefined {\n return this.#cwd\n }\n\n normalizeDirectory(directory: string): string {\n if (!this.#SLASHES.has(directory[directory.length - 1]!)) {\n return `${directory}/`\n }\n\n return directory\n }\n\n getLocation(path: string): string {\n let location = path\n\n if (this.#cwd) {\n const require = mod.createRequire(this.normalizeDirectory(this.#cwd))\n location = require.resolve(path)\n }\n\n return location\n }\n\n async import(path: string): Promise<any | undefined> {\n try {\n let location = this.getLocation(path)\n\n if (os.platform() == 'win32') {\n location = pathToFileURL(location).href\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const module = await import(location)\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n return module?.default ?? module\n } catch (e) {\n console.log(e)\n return undefined\n }\n }\n\n async getPackageJSON(): Promise<PackageJSON | undefined> {\n const pkgPath = await findUp(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n const json = await read(pkgPath)\n\n return JSON.parse(json) as PackageJSON\n }\n\n getPackageJSONSync(): PackageJSON | undefined {\n const pkgPath = findUpSync(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n const json = readSync(pkgPath)\n\n return JSON.parse(json) as PackageJSON\n }\n\n static setVersion(dependency: DependencyName, version: DependencyVersion): void {\n PackageManager.#cache[dependency] = version\n }\n\n #match(packageJSON: PackageJSON, dependency: DependencyName | RegExp): string | undefined {\n const dependencies = {\n ...packageJSON['dependencies'] || {},\n ...packageJSON['devDependencies'] || {},\n }\n\n if (typeof dependency === 'string' && dependencies[dependency]) {\n return dependencies[dependency]\n }\n\n const matchedDependency = Object.keys(dependencies).find(dep => dep.match(dependency))\n\n return matchedDependency ? dependencies[matchedDependency] : undefined\n }\n\n async getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined> {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = await this.getPackageJSON()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = this.getPackageJSONSync()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n async isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean> {\n const packageVersion = await this.getVersion(dependency)\n\n if (!packageVersion) {\n return false\n }\n\n if (packageVersion === version) {\n return true\n }\n\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean {\n const packageVersion = this.getVersionSync(dependency)\n\n if (!packageVersion) {\n return false\n }\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/build.ts","../src/config.ts","../src/Generator.ts","../src/PackageManager.ts","../src/kubb.ts"],"names":["require"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACAA;;;ACAA;AAQO,SAAS,aACd,SAMgB;AAChB,SAAO;AACT;AAEO,SAAS,YAAY,QAAyD;AACnF,SAAO,CAAC,CAAC,U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AAC,gBAAgB;AACnB,aAAO;AAAA,IACT;AACA,UAAM,SAAS,OAAO,cAAc;AAEpC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,GAAG,cAAc,eAAe;AAAA,IAClD;AAEA,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AACF;AApKS;AAEP;AACA;AAqFA;AAAA,WAAM,SAAC,aAA0B,YAAyD;AACxF,QAAM,eAAe;AAAA,IACnB,GAAG,YAAY,cAAc,KAAK,CAAC;AAAA,IACnC,GAAG,YAAY,iBAAiB,KAAK,CAAC;AAAA,EACxC;AAEA,MAAI,OAAO,eAAe,YAAY,aAAa,UAAU,GAAG;AAC9D,WAAO,aAAa,UAAU;AAAA,EAChC;AAEA,QAAM,oBAAoB,OAAO,KAAK,YAAY,EAAE,KAAK,SAAO,IAAI,MAAM,UAAU,CAAC;AAErF,SAAO,oBAAoB,aAAa,iBAAiB,IAAI;AAC/D;AArGA,aADW,iBACJ,QAAoD,CAAC;AADvD,IAAM,iBAAN;;;AClBP;AAAA","sourcesContent":["export { build, build as default, safeBuild } from './build.ts'\nexport { defineConfig, isInputPath } from './config.ts'\nexport { Warning } from './errors.ts'\nexport { FileManager, KubbFile } from './FileManager.ts'\nexport { Generator } from './Generator.ts'\nexport { PackageManager } from './PackageManager.ts'\n// dprint-ignore\nexport { createPlugin, pluginName as name, pluginName } from './plugin.ts'\nexport { PluginManager } from './PluginManager.ts'\nexport { PromiseManager } from './PromiseManager.ts'\nexport type { CLIOptions, Config, Plugin, PluginFactoryOptions, ResolveNameParams, ResolvePathParams, UserConfig } from './types.ts'\n\nexport interface _Register {}\n\nexport * as Kubb from './kubb.ts'\n","import c from 'tinyrainbow'\n\nimport { clean } from './fs/clean.ts'\nimport { read } from './fs/read.ts'\nimport { URLPath } from './utils/URLPath.ts'\nimport { isInputPath } from './config.ts'\nimport { FileManager } from './FileManager.ts'\nimport { createLogger, LogLevel, randomCliColour } from './logger.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isPromise } from './PromiseManager.ts'\n\nimport type { KubbFile } from './FileManager.ts'\nimport type { Logger } from './logger.ts'\nimport type { Plugin, PluginContext, PluginParameter, TransformResult } from './types.ts'\n\ntype BuildOptions = {\n config: PluginContext['config']\n /**\n * @default Logger without the spinner\n */\n logger?: Logger\n}\n\ntype BuildOutput = {\n files: FileManager['files']\n pluginManager: PluginManager\n /**\n * Only for safeBuild\n */\n error?: Error\n}\n\nasync function transformReducer(\n this: PluginContext,\n _previousCode: string,\n result: TransformResult | Promise<TransformResult>,\n _plugin: Plugin,\n): Promise<string | null> {\n return result\n}\n\nasync function setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger({ logLevel: LogLevel.silent }) } = options\n let count = 0\n\n try {\n if (isInputPath(config) && !new URLPath(config.input.path).isURL) {\n await read(config.input.path)\n }\n } catch (e) {\n if (isInputPath(config)) {\n throw new Error(\n 'Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config ' + c.dim(config.input.path),\n {\n cause: e,\n },\n )\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n const task = async (file: KubbFile.ResolvedFile): Promise<KubbFile.ResolvedFile> => {\n const { path } = file\n\n let source: string | null = FileManager.getSource(file)\n\n const { result: loadedResult } = await pluginManager.hookFirst({\n hookName: 'load',\n parameters: [path],\n })\n if (loadedResult && isPromise(loadedResult)) {\n source = await loadedResult\n }\n if (loadedResult && !isPromise(loadedResult)) {\n source = loadedResult\n }\n\n if (source) {\n source = await pluginManager.hookReduceArg0({\n hookName: 'transform',\n parameters: [source, path],\n reduce: transformReducer,\n })\n\n if (config.output.write || config.output.write === undefined) {\n if (file.meta?.pluginKey) {\n // run only for pluginKey defined in the meta of the file\n await pluginManager.hookForPlugin({\n pluginKey: file.meta?.pluginKey,\n hookName: 'writeFile',\n parameters: [source, path],\n })\n }\n\n await pluginManager.hookFirst({\n hookName: 'writeFile',\n parameters: [source, path],\n })\n }\n }\n\n return {\n ...file,\n source: source || '',\n }\n }\n\n const pluginManager = new PluginManager(config, { logger, task })\n\n pluginManager.on('execute', (executer) => {\n const { hookName, parameters, plugin } = executer\n\n if (hookName === 'writeFile') {\n const [code] = parameters as PluginParameter<'writeFile'>\n\n if (logger.logLevel === LogLevel.debug) {\n logger.emit('debug', [`PluginKey ${c.dim(JSON.stringify(plugin.key))} \\nwith source\\n\\n${code}`])\n }\n }\n })\n\n pluginManager.queue.on('add', () => {\n if (logger.logLevel !== LogLevel.info) {\n return\n }\n\n if (count === 0) {\n logger.emit('start', `💾 Writing`)\n }\n })\n\n pluginManager.queue.on('active', () => {\n if (logger.logLevel !== LogLevel.info) {\n return\n }\n\n if (logger.spinner && pluginManager.queue.size > 0) {\n const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`\n\n logger.spinner.suffixText = c.dim(text)\n }\n ;++count\n })\n\n pluginManager.queue.on('completed', () => {\n if (logger.logLevel !== LogLevel.info) {\n return\n }\n\n if (logger.spinner) {\n const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`\n\n logger.spinner.suffixText = c.dim(text)\n }\n })\n\n pluginManager.on('executed', (executer) => {\n const { hookName, plugin, output, parameters } = executer\n\n if (logger.logLevel === LogLevel.debug) {\n const logs = [\n `${randomCliColour(plugin.name)} Executing ${hookName}`,\n parameters && `${c.bgWhite(`Parameters`)} ${randomCliColour(plugin.name)} ${hookName}`,\n JSON.stringify(parameters, undefined, 2),\n output && `${c.bgWhite('Output')} ${randomCliColour(plugin.name)} ${hookName}`,\n output,\n ].filter(Boolean)\n\n logger.emit('debug', logs as string[])\n }\n })\n\n return pluginManager\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n const { fileManager, logger } = pluginManager\n\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n if (logger.logLevel === LogLevel.info) {\n logger.emit('end', `💾 Writing completed`)\n }\n\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n const { fileManager, logger } = pluginManager\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n if (logger.logLevel === LogLevel.info) {\n logger.emit('end', `💾 Writing completed`)\n }\n } catch (e) {\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager, error: e as Error }\n }\n\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager }\n}\n","import type { PossiblePromise } from '@kubb/types'\nimport type { CLIOptions, Config, InputPath, UserConfig } from './types.ts'\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link Config} object, or a function that returns it.\n * The function receives a {@link ConfigEnv} object that exposes two properties:\n */\nexport function defineConfig(\n options:\n | PossiblePromise<UserConfig | Array<UserConfig>>\n | ((\n /** The options derived from the CLI flags */\n cliOptions: CLIOptions,\n ) => PossiblePromise<UserConfig | Array<UserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: Config | undefined): result is Config<InputPath> {\n return !!result && 'path' in (result as any)\n}\n","/**\n * Abstract class that contains the building blocks for plugins to create their own Generator\n * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137\n */\nexport abstract class Generator<TOptions = unknown, TContext = unknown> {\n #options: TOptions = {} as TOptions\n #context: TContext = {} as TContext\n\n constructor(options?: TOptions, context?: TContext) {\n if (context) {\n this.#context = context\n }\n\n if (options) {\n this.#options = options\n }\n\n return this\n }\n\n get options(): TOptions {\n return this.#options\n }\n\n get context(): TContext {\n return this.#context\n }\n\n set options(options: TOptions) {\n this.#options = { ...this.#options, ...options }\n }\n\n abstract build(...params: unknown[]): unknown\n}\n","import mod from 'node:module'\nimport os from 'node:os'\nimport { pathToFileURL } from 'node:url'\n\nimport { findUp, findUpSync } from 'find-up'\nimport { coerce, satisfies } from 'semver'\n\nimport { read, readSync } from './fs/read'\n\ntype PackageJSON = {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n}\n\ntype DependencyName = string\n\ntype DependencyVersion = string\n\nexport class PackageManager {\n static #cache: Record<DependencyName, DependencyVersion> = {}\n\n #cwd?: string\n #SLASHES = new Set(['/', '\\\\'])\n constructor(workspace?: string) {\n if (workspace) {\n this.#cwd = workspace\n }\n\n return this\n }\n\n set workspace(workspace: string) {\n this.#cwd = workspace\n }\n\n get workspace(): string | undefined {\n return this.#cwd\n }\n\n normalizeDirectory(directory: string): string {\n if (!this.#SLASHES.has(directory[directory.length - 1]!)) {\n return `${directory}/`\n }\n\n return directory\n }\n\n getLocation(path: string): string {\n let location = path\n\n if (this.#cwd) {\n const require = mod.createRequire(this.normalizeDirectory(this.#cwd))\n location = require.resolve(path)\n }\n\n return location\n }\n\n async import(path: string): Promise<any | undefined> {\n try {\n let location = this.getLocation(path)\n\n if (os.platform() == 'win32') {\n location = pathToFileURL(location).href\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const module = await import(location)\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n return module?.default ?? module\n } catch (e) {\n console.log(e)\n return undefined\n }\n }\n\n async getPackageJSON(): Promise<PackageJSON | undefined> {\n const pkgPath = await findUp(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n const json = await read(pkgPath)\n\n return JSON.parse(json) as PackageJSON\n }\n\n getPackageJSONSync(): PackageJSON | undefined {\n const pkgPath = findUpSync(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n const json = readSync(pkgPath)\n\n return JSON.parse(json) as PackageJSON\n }\n\n static setVersion(dependency: DependencyName, version: DependencyVersion): void {\n PackageManager.#cache[dependency] = version\n }\n\n #match(packageJSON: PackageJSON, dependency: DependencyName | RegExp): string | undefined {\n const dependencies = {\n ...packageJSON['dependencies'] || {},\n ...packageJSON['devDependencies'] || {},\n }\n\n if (typeof dependency === 'string' && dependencies[dependency]) {\n return dependencies[dependency]\n }\n\n const matchedDependency = Object.keys(dependencies).find(dep => dep.match(dependency))\n\n return matchedDependency ? dependencies[matchedDependency] : undefined\n }\n\n async getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined> {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = await this.getPackageJSON()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = this.getPackageJSONSync()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n async isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean> {\n const packageVersion = await this.getVersion(dependency)\n\n if (!packageVersion) {\n return false\n }\n\n if (packageVersion === version) {\n return true\n }\n\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean {\n const packageVersion = this.getVersionSync(dependency)\n\n if (!packageVersion) {\n return false\n }\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n}\n","import type { ObjValueTuple, TupleToUnion } from '@kubb/types'\nimport type { _Register } from './index.ts'\n\nexport type Plugins = _Register\nexport type OptionsPlugins = { [K in keyof Plugins]: Plugins[K]['options'] }\n\nexport type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options']\n\nexport type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>\n\nexport type Plugin = keyof Plugins\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Ora } from 'ora';
|
|
2
|
+
|
|
3
|
+
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor();
|
|
6
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
7
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
8
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
9
|
+
removeAll(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const LogLevel: {
|
|
13
|
+
readonly silent: "silent";
|
|
14
|
+
readonly info: "info";
|
|
15
|
+
readonly debug: "debug";
|
|
16
|
+
};
|
|
17
|
+
type LogLevel = keyof typeof LogLevel;
|
|
18
|
+
type Events = {
|
|
19
|
+
start: [message: string];
|
|
20
|
+
end: [message: string];
|
|
21
|
+
error: [message: string];
|
|
22
|
+
warning: [message: string];
|
|
23
|
+
debug: [logs: string[]];
|
|
24
|
+
};
|
|
25
|
+
type Logger = {
|
|
26
|
+
/**
|
|
27
|
+
* Optional config name to show in CLI output
|
|
28
|
+
*/
|
|
29
|
+
name?: string;
|
|
30
|
+
logLevel: LogLevel;
|
|
31
|
+
spinner?: Ora;
|
|
32
|
+
on: EventEmitter<Events>['on'];
|
|
33
|
+
emit: EventEmitter<Events>['emit'];
|
|
34
|
+
};
|
|
35
|
+
type Props = {
|
|
36
|
+
name?: string;
|
|
37
|
+
logLevel: LogLevel;
|
|
38
|
+
spinner?: Ora;
|
|
39
|
+
};
|
|
40
|
+
declare function createLogger({ logLevel, name, spinner }: Props): Logger;
|
|
41
|
+
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
42
|
+
declare function randomCliColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
43
|
+
|
|
44
|
+
export { EventEmitter as E, type Logger as L, LogLevel as a, randomCliColour as b, createLogger as c, randomColour as r };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Ora } from 'ora';
|
|
2
|
+
|
|
3
|
+
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor();
|
|
6
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
7
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
8
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
9
|
+
removeAll(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const LogLevel: {
|
|
13
|
+
readonly silent: "silent";
|
|
14
|
+
readonly info: "info";
|
|
15
|
+
readonly debug: "debug";
|
|
16
|
+
};
|
|
17
|
+
type LogLevel = keyof typeof LogLevel;
|
|
18
|
+
type Events = {
|
|
19
|
+
start: [message: string];
|
|
20
|
+
end: [message: string];
|
|
21
|
+
error: [message: string];
|
|
22
|
+
warning: [message: string];
|
|
23
|
+
debug: [logs: string[]];
|
|
24
|
+
};
|
|
25
|
+
type Logger = {
|
|
26
|
+
/**
|
|
27
|
+
* Optional config name to show in CLI output
|
|
28
|
+
*/
|
|
29
|
+
name?: string;
|
|
30
|
+
logLevel: LogLevel;
|
|
31
|
+
spinner?: Ora;
|
|
32
|
+
on: EventEmitter<Events>['on'];
|
|
33
|
+
emit: EventEmitter<Events>['emit'];
|
|
34
|
+
};
|
|
35
|
+
type Props = {
|
|
36
|
+
name?: string;
|
|
37
|
+
logLevel: LogLevel;
|
|
38
|
+
spinner?: Ora;
|
|
39
|
+
};
|
|
40
|
+
declare function createLogger({ logLevel, name, spinner }: Props): Logger;
|
|
41
|
+
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
42
|
+
declare function randomCliColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
43
|
+
|
|
44
|
+
export { EventEmitter as E, type Logger as L, LogLevel as a, randomCliColour as b, createLogger as c, randomColour as r };
|
package/dist/logger.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSSD2TXQZ_cjs = require('./chunk-SSD2TXQZ.cjs');
|
|
4
4
|
require('./chunk-DM53DOLW.cjs');
|
|
5
5
|
require('./chunk-KAA3L7N6.cjs');
|
|
6
6
|
|
|
@@ -8,19 +8,19 @@ require('./chunk-KAA3L7N6.cjs');
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "LogLevel", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkSSD2TXQZ_cjs.LogLevel; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "createLogger", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkSSD2TXQZ_cjs.createLogger; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "randomCliColour", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkSSD2TXQZ_cjs.randomCliColour; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "randomColour", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkSSD2TXQZ_cjs.randomColour; }
|
|
24
24
|
});
|
|
25
25
|
//# sourceMappingURL=out.js.map
|
|
26
26
|
//# sourceMappingURL=logger.cjs.map
|
package/dist/logger.d.cts
CHANGED
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const LogLevel: {
|
|
4
|
-
readonly silent: "silent";
|
|
5
|
-
readonly info: "info";
|
|
6
|
-
readonly debug: "debug";
|
|
7
|
-
};
|
|
8
|
-
type LogLevel = keyof typeof LogLevel;
|
|
9
|
-
type Logger = {
|
|
10
|
-
/**
|
|
11
|
-
* Optional config name to show in CLI output
|
|
12
|
-
*/
|
|
13
|
-
name?: string;
|
|
14
|
-
logLevel: LogLevel;
|
|
15
|
-
log: (message: string | null) => void;
|
|
16
|
-
error: (message: string | null) => void;
|
|
17
|
-
info: (message: string | null) => void;
|
|
18
|
-
warn: (message: string | null) => void;
|
|
19
|
-
debug: (message: string | null) => Promise<void>;
|
|
20
|
-
spinner?: Ora;
|
|
21
|
-
logs: string[];
|
|
22
|
-
};
|
|
23
|
-
type Props = {
|
|
24
|
-
name?: string;
|
|
25
|
-
logLevel: LogLevel;
|
|
26
|
-
spinner?: Ora;
|
|
27
|
-
};
|
|
28
|
-
declare function createLogger({ logLevel, name, spinner }: Props): Logger;
|
|
29
|
-
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
30
|
-
declare function randomCliColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
31
|
-
|
|
32
|
-
export { LogLevel, type Logger, createLogger, randomCliColour, randomColour };
|
|
1
|
+
export { a as LogLevel, L as Logger, c as createLogger, b as randomCliColour, r as randomColour } from './logger-wryz32Ex.cjs';
|
|
2
|
+
import 'ora';
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const LogLevel: {
|
|
4
|
-
readonly silent: "silent";
|
|
5
|
-
readonly info: "info";
|
|
6
|
-
readonly debug: "debug";
|
|
7
|
-
};
|
|
8
|
-
type LogLevel = keyof typeof LogLevel;
|
|
9
|
-
type Logger = {
|
|
10
|
-
/**
|
|
11
|
-
* Optional config name to show in CLI output
|
|
12
|
-
*/
|
|
13
|
-
name?: string;
|
|
14
|
-
logLevel: LogLevel;
|
|
15
|
-
log: (message: string | null) => void;
|
|
16
|
-
error: (message: string | null) => void;
|
|
17
|
-
info: (message: string | null) => void;
|
|
18
|
-
warn: (message: string | null) => void;
|
|
19
|
-
debug: (message: string | null) => Promise<void>;
|
|
20
|
-
spinner?: Ora;
|
|
21
|
-
logs: string[];
|
|
22
|
-
};
|
|
23
|
-
type Props = {
|
|
24
|
-
name?: string;
|
|
25
|
-
logLevel: LogLevel;
|
|
26
|
-
spinner?: Ora;
|
|
27
|
-
};
|
|
28
|
-
declare function createLogger({ logLevel, name, spinner }: Props): Logger;
|
|
29
|
-
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
30
|
-
declare function randomCliColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
31
|
-
|
|
32
|
-
export { LogLevel, type Logger, createLogger, randomCliColour, randomColour };
|
|
1
|
+
export { a as LogLevel, L as Logger, c as createLogger, b as randomCliColour, r as randomColour } from './logger-wryz32Ex.js';
|
|
2
|
+
import 'ora';
|
package/dist/logger.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { LogLevel, createLogger, randomCliColour, randomColour } from './chunk-
|
|
1
|
+
export { LogLevel, createLogger, randomCliColour, randomColour } from './chunk-W3NDP3K4.js';
|
|
2
2
|
import './chunk-MYC5HIA5.js';
|
|
3
3
|
import './chunk-ETA3LCRB.js';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
package/dist/mocks.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./chunk-
|
|
3
|
+
require('./chunk-3J25BT5A.cjs');
|
|
4
4
|
require('./chunk-2UXXYHS6.cjs');
|
|
5
5
|
require('./chunk-KXP7HD6Z.cjs');
|
|
6
6
|
var chunkN7XIQXXQ_cjs = require('./chunk-N7XIQXXQ.cjs');
|
|
7
|
-
require('./chunk-
|
|
7
|
+
require('./chunk-SSD2TXQZ.cjs');
|
|
8
8
|
require('./chunk-XX56SVPB.cjs');
|
|
9
9
|
require('./chunk-DM53DOLW.cjs');
|
|
10
10
|
var chunkKAA3L7N6_cjs = require('./chunk-KAA3L7N6.cjs');
|
|
@@ -20,18 +20,12 @@ var mockedPluginManager = {
|
|
|
20
20
|
},
|
|
21
21
|
resolvePath: ({ baseName }) => baseName,
|
|
22
22
|
logger: {
|
|
23
|
-
|
|
23
|
+
emit(message) {
|
|
24
24
|
console.log(message);
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
console.log(message);
|
|
28
|
-
},
|
|
29
|
-
warn(message) {
|
|
30
|
-
console.log(message);
|
|
26
|
+
on(eventName, args) {
|
|
31
27
|
},
|
|
32
|
-
|
|
33
|
-
console.log(message);
|
|
34
|
-
}
|
|
28
|
+
logLevel: "info"
|
|
35
29
|
}
|
|
36
30
|
};
|
|
37
31
|
|
package/dist/mocks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AAGO,IAAM,sBAAsB;AAAA,EACjC,aAAa,CAAC,EAAE,MAAM,KAAK,MAAM;AAC/B,QAAI,SAAS,QAAQ;AACnB,aAAO,WAAW,IAAI;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AAAA,EACA,aAAa,CAAC,EAAE,SAAS,MAAM;AAAA,EAC/B,QAAQ;AAAA,IACN,KAAK,SAAS;AACZ,cAAQ,IAAI,OAAO;AAAA,IACrB;AAAA,IACA,
|
|
1
|
+
{"version":3,"sources":["../mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AAGO,IAAM,sBAAsB;AAAA,EACjC,aAAa,CAAC,EAAE,MAAM,KAAK,MAAM;AAC/B,QAAI,SAAS,QAAQ;AACnB,aAAO,WAAW,IAAI;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AAAA,EACA,aAAa,CAAC,EAAE,SAAS,MAAM;AAAA,EAC/B,QAAQ;AAAA,IACN,KAAK,SAAS;AACZ,cAAQ,IAAI,OAAO;AAAA,IACrB;AAAA,IACA,GAAG,WAAW,MAAM;AAAA,IACpB;AAAA,IACA,UAAU;AAAA,EACZ;AACF","sourcesContent":["import { pascalCase } from '../src/transformers/casing.ts'\n\nimport { PluginManager } from '../src/PluginManager.ts'\nexport const mockedPluginManager = {\n resolveName: ({ name, type }) => {\n if (type === 'type') {\n return pascalCase(name)\n }\n\n return name\n },\n resolvePath: ({ baseName }) => baseName,\n logger: {\n emit(message) {\n console.log(message)\n },\n on(eventName, args) {\n },\n logLevel: 'info',\n },\n} as PluginManager\n"]}
|
package/dist/mocks.d.cts
CHANGED
package/dist/mocks.d.ts
CHANGED
package/dist/mocks.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import './chunk-
|
|
1
|
+
import './chunk-DJBEBMX6.js';
|
|
2
2
|
import './chunk-GKW5TTFV.js';
|
|
3
3
|
import './chunk-YW33IVCC.js';
|
|
4
4
|
import { pascalCase } from './chunk-GLL5G5KY.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-W3NDP3K4.js';
|
|
6
6
|
import './chunk-YUTCMBUY.js';
|
|
7
7
|
import './chunk-MYC5HIA5.js';
|
|
8
8
|
import { init_esm_shims } from './chunk-ETA3LCRB.js';
|
|
@@ -18,18 +18,12 @@ var mockedPluginManager = {
|
|
|
18
18
|
},
|
|
19
19
|
resolvePath: ({ baseName }) => baseName,
|
|
20
20
|
logger: {
|
|
21
|
-
|
|
21
|
+
emit(message) {
|
|
22
22
|
console.log(message);
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
console.log(message);
|
|
26
|
-
},
|
|
27
|
-
warn(message) {
|
|
28
|
-
console.log(message);
|
|
24
|
+
on(eventName, args) {
|
|
29
25
|
},
|
|
30
|
-
|
|
31
|
-
console.log(message);
|
|
32
|
-
}
|
|
26
|
+
logLevel: "info"
|
|
33
27
|
}
|
|
34
28
|
};
|
|
35
29
|
|
package/dist/mocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AAGO,IAAM,sBAAsB;AAAA,EACjC,aAAa,CAAC,EAAE,MAAM,KAAK,MAAM;AAC/B,QAAI,SAAS,QAAQ;AACnB,aAAO,WAAW,IAAI;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AAAA,EACA,aAAa,CAAC,EAAE,SAAS,MAAM;AAAA,EAC/B,QAAQ;AAAA,IACN,KAAK,SAAS;AACZ,cAAQ,IAAI,OAAO;AAAA,IACrB;AAAA,IACA,
|
|
1
|
+
{"version":3,"sources":["../mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AAGO,IAAM,sBAAsB;AAAA,EACjC,aAAa,CAAC,EAAE,MAAM,KAAK,MAAM;AAC/B,QAAI,SAAS,QAAQ;AACnB,aAAO,WAAW,IAAI;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AAAA,EACA,aAAa,CAAC,EAAE,SAAS,MAAM;AAAA,EAC/B,QAAQ;AAAA,IACN,KAAK,SAAS;AACZ,cAAQ,IAAI,OAAO;AAAA,IACrB;AAAA,IACA,GAAG,WAAW,MAAM;AAAA,IACpB;AAAA,IACA,UAAU;AAAA,EACZ;AACF","sourcesContent":["import { pascalCase } from '../src/transformers/casing.ts'\n\nimport { PluginManager } from '../src/PluginManager.ts'\nexport const mockedPluginManager = {\n resolveName: ({ name, type }) => {\n if (type === 'type') {\n return pascalCase(name)\n }\n\n return name\n },\n resolvePath: ({ baseName }) => baseName,\n logger: {\n emit(message) {\n console.log(message)\n },\n on(eventName, args) {\n },\n logLevel: 'info',\n },\n} as PluginManager\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Generator core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"p-queue": "^8.0.1",
|
|
77
77
|
"seedrandom": "^3.0.5",
|
|
78
78
|
"semver": "^7.5.4",
|
|
79
|
-
"@kubb/parser": "2.
|
|
80
|
-
"@kubb/types": "2.
|
|
79
|
+
"@kubb/parser": "2.5.1",
|
|
80
|
+
"@kubb/types": "2.5.1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@types/fs-extra": "^11.0.4",
|
package/src/FileManager.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { BarrelManager } from './BarrelManager.ts'
|
|
|
17
17
|
|
|
18
18
|
import type { GreaterThan } from '@kubb/types'
|
|
19
19
|
import type { BarrelManagerOptions } from './BarrelManager.ts'
|
|
20
|
-
import type {
|
|
20
|
+
import type { Plugin } from './types.ts'
|
|
21
21
|
|
|
22
22
|
type BasePath<T extends string = string> = `${T}/`
|
|
23
23
|
|
|
@@ -106,7 +106,7 @@ export namespace KubbFile {
|
|
|
106
106
|
export type OptionalPath = Path | undefined | null
|
|
107
107
|
|
|
108
108
|
export type FileMetaBase = {
|
|
109
|
-
pluginKey?:
|
|
109
|
+
pluginKey?: Plugin['key']
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
export type File<
|