@kubb/core
Advanced tools
Comparing version 0.13.0 to 0.14.0
@@ -134,2 +134,3 @@ type WithPromise<T> = Promise<T> | T; | ||
root: string; | ||
clear?: boolean; | ||
mode?: 'single'; | ||
@@ -183,2 +184,3 @@ input: { | ||
load: (id: string) => WithPromise<TransformResult | void>; | ||
addToIndex: (emittedFile: EmittedFile) => void; | ||
}; | ||
@@ -185,0 +187,0 @@ type PluginContext = Api; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var path = require('path'); | ||
var path2 = require('path'); | ||
var fse = require('fs-extra'); | ||
@@ -158,3 +158,3 @@ var prettier = require('prettier'); | ||
} | ||
const newPath = path.relative(from, to).replace("../", "").replace(".ts", "").trimEnd(); | ||
const newPath = path2.relative(from, to).replace("../", "").replace(".ts", "").trimEnd(); | ||
return `./${newPath}`; | ||
@@ -181,2 +181,3 @@ }; | ||
const { fileEmitter, resolveId, load } = options; | ||
const indexFiles = []; | ||
const api = { | ||
@@ -194,2 +195,5 @@ get config() { | ||
}, | ||
addToIndex: (emittedFile) => { | ||
indexFiles.push(emittedFile); | ||
}, | ||
resolveId, | ||
@@ -202,2 +206,13 @@ load, | ||
api, | ||
async buildEnd() { | ||
if (!indexFiles.length) { | ||
return; | ||
} | ||
let index = ``; | ||
indexFiles.forEach((item) => { | ||
index += `export * from "${getRelativePath(path2.resolve(this.config.root, this.config.output.path), item.id)}"; | ||
`; | ||
}); | ||
await write(index, path2.resolve(this.config.root, this.config.output.path, "index.ts"), { format: true }); | ||
}, | ||
resolveId(importee, importer) { | ||
@@ -207,3 +222,3 @@ if (!importer) { | ||
} | ||
return path.resolve(importer, importee); | ||
return path2.resolve(importer, importee); | ||
} | ||
@@ -351,2 +366,5 @@ }; | ||
const { config, logger } = options; | ||
if (config.clear) { | ||
await fse.remove(config.output.path); | ||
} | ||
const pluginDriver = new PluginDriver( | ||
@@ -359,3 +377,3 @@ { | ||
); | ||
const input = fse.readFileSync(path.resolve(config.root, config.input.path), "utf-8"); | ||
const input = fse.readFileSync(path2.resolve(config.root, config.input.path), "utf-8"); | ||
const validations = await pluginDriver.hookParallel("validate", [pluginDriver.plugins]); | ||
@@ -362,0 +380,0 @@ const validationsWithMessage = validations.filter(Boolean); |
{ | ||
"name": "@kubb/core", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "Generator core", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -27,2 +27,6 @@ { | ||
}, | ||
"clear": { | ||
"type": "boolean", | ||
"description": "Clear previous generated files" | ||
}, | ||
"output": { | ||
@@ -29,0 +33,0 @@ "type": "object", |
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
98576
1096