@kubb/core
Advanced tools
Comparing version 0.56.0 to 0.56.1
@@ -1,25 +0,13 @@ | ||
'use strict'; | ||
import { createRequire } from 'module'; | ||
import pathParser from 'path'; | ||
import { promises } from 'fs'; | ||
import rimraf from 'rimraf'; | ||
import { format as format$1 } from 'prettier'; | ||
import EventEmitter from 'eventemitter3'; | ||
import uniq from 'lodash.uniq'; | ||
import { v4 } from 'uuid'; | ||
import dirTree from 'directory-tree'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
createRequire(import.meta.url); | ||
var module$1 = require('module'); | ||
var pathParser = require('path'); | ||
var fs = require('fs'); | ||
var rimraf = require('rimraf'); | ||
var prettier = require('prettier'); | ||
var EventEmitter = require('eventemitter3'); | ||
var uniq = require('lodash.uniq'); | ||
var uuid = require('uuid'); | ||
var dirTree = require('directory-tree'); | ||
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } | ||
var pathParser__default = /*#__PURE__*/_interopDefault(pathParser); | ||
var rimraf__default = /*#__PURE__*/_interopDefault(rimraf); | ||
var EventEmitter__default = /*#__PURE__*/_interopDefault(EventEmitter); | ||
var uniq__default = /*#__PURE__*/_interopDefault(uniq); | ||
var dirTree__default = /*#__PURE__*/_interopDefault(dirTree); | ||
module$1.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('out.js', document.baseURI).href))); | ||
// src/utils/isURL.ts | ||
@@ -43,10 +31,10 @@ var isURL = (data) => { | ||
var safeWriteFileToPath = async (path, data) => { | ||
const passedPath = pathParser__default.default.dirname(pathParser__default.default.resolve(path)); | ||
await fs.promises.mkdir(passedPath, { recursive: true }); | ||
return fs.promises.writeFile(pathParser__default.default.resolve(path), data, { encoding: "utf-8" }); | ||
const passedPath = pathParser.dirname(pathParser.resolve(path)); | ||
await promises.mkdir(passedPath, { recursive: true }); | ||
return promises.writeFile(pathParser.resolve(path), data, { encoding: "utf-8" }); | ||
}; | ||
var write = async (data, path) => { | ||
try { | ||
await fs.promises.stat(path); | ||
const oldContent = await fs.promises.readFile(path, { encoding: "utf-8" }); | ||
await promises.stat(path); | ||
const oldContent = await promises.readFile(path, { encoding: "utf-8" }); | ||
if (oldContent?.toString() === data) { | ||
@@ -62,3 +50,3 @@ return; | ||
return new Promise((resolve, reject) => { | ||
rimraf__default.default(path, (err) => { | ||
rimraf(path, (err) => { | ||
if (err) { | ||
@@ -102,3 +90,3 @@ reject(err); | ||
} | ||
const newPath = pathParser__default.default.relative(root, file).replace("../", "").replace(".ts", "").trimEnd(); | ||
const newPath = pathParser.relative(root, file).replace("../", "").replace(".ts", "").trimEnd(); | ||
return `./${newPath}`; | ||
@@ -110,7 +98,7 @@ }; | ||
} | ||
return pathParser__default.default.extname(path) ? "file" : "directory"; | ||
return pathParser.extname(path) ? "file" : "directory"; | ||
}; | ||
var read = async (path) => { | ||
try { | ||
return fs.promises.readFile(path, { encoding: "utf8" }); | ||
return promises.readFile(path, { encoding: "utf8" }); | ||
} catch (err) { | ||
@@ -132,3 +120,3 @@ console.error(err); | ||
var format = (source) => { | ||
return prettier.format(source, formatOptions); | ||
return format$1(source, formatOptions); | ||
}; | ||
@@ -211,3 +199,3 @@ | ||
} | ||
return pathParser__default.default.resolve(directory, fileName); | ||
return pathParser.resolve(directory, fileName); | ||
} | ||
@@ -274,3 +262,3 @@ }; | ||
cache = /* @__PURE__ */ new Map(); | ||
emitter = new EventEmitter__default.default(); | ||
emitter = new EventEmitter(); | ||
events = getFileManagerEvents(this.emitter); | ||
@@ -317,3 +305,3 @@ constructor() { | ||
if (exists && Array.isArray(curr.name)) { | ||
exists.name = uniq__default.default([...exists.name, ...curr.name]); | ||
exists.name = uniq([...exists.name, ...curr.name]); | ||
} | ||
@@ -350,3 +338,3 @@ }); | ||
add(file) { | ||
const cacheItem = { id: uuid.v4(), file, status: "new" }; | ||
const cacheItem = { id: v4(), file, status: "new" }; | ||
this.cache.set(cacheItem.id, cacheItem); | ||
@@ -482,3 +470,3 @@ this.events.emitFile(cacheItem.id, file); | ||
static build(path, options = {}) { | ||
const filteredTree = dirTree__default.default(path, { extensions: options?.extensions, exclude: options.exclude }); | ||
const filteredTree = dirTree(path, { extensions: options?.extensions, exclude: options.exclude }); | ||
if (!filteredTree) { | ||
@@ -734,5 +722,5 @@ return; | ||
pluginManager.fileManager.add({ | ||
path: isURL(config.input.path) ? config.input.path : pathParser__default.default.resolve(config.root, config.input.path), | ||
path: isURL(config.input.path) ? config.input.path : pathParser.resolve(config.root, config.input.path), | ||
fileName: isURL(config.input.path) ? "input" : config.input.path, | ||
source: isURL(config.input.path) ? config.input.path : await read(pathParser__default.default.resolve(config.root, config.input.path)) | ||
source: isURL(config.input.path) ? config.input.path : await read(pathParser.resolve(config.root, config.input.path)) | ||
}); | ||
@@ -777,28 +765,4 @@ } | ||
exports.FileManager = FileManager; | ||
exports.Generator = Generator; | ||
exports.PluginManager = PluginManager; | ||
exports.SchemaGenerator = SchemaGenerator; | ||
exports.TreeNode = TreeNode; | ||
exports.ValidationPluginError = ValidationPluginError; | ||
exports.build = build; | ||
exports.clean = clean; | ||
exports.createJSDocBlockText = createJSDocBlockText; | ||
exports.createPlugin = createPlugin; | ||
exports.createPluginCache = createPluginCache; | ||
exports.default = src_default; | ||
exports.defineConfig = defineConfig; | ||
exports.format = format; | ||
exports.getPathMode = getPathMode; | ||
exports.getRelativePath = getRelativePath; | ||
exports.hooks = hooks; | ||
exports.isPromise = isPromise; | ||
exports.isURL = isURL; | ||
exports.name = name; | ||
exports.nameSorter = nameSorter; | ||
exports.objectToParameters = objectToParameters; | ||
exports.read = read; | ||
exports.validatePlugins = validatePlugins; | ||
exports.write = write; | ||
export { FileManager, Generator, PluginManager, SchemaGenerator, TreeNode, ValidationPluginError, build, clean, createJSDocBlockText, createPlugin, createPluginCache, src_default as default, defineConfig, format, getPathMode, getRelativePath, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, validatePlugins, write }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@kubb/core", | ||
"version": "0.56.0", | ||
"version": "0.56.1", | ||
"description": "Generator core", | ||
@@ -19,5 +19,6 @@ "repository": { | ||
"sideEffects": false, | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"unpkg": "dist/index.global.js", | ||
"module": "dist/index.mjs", | ||
"module": "dist/index.js", | ||
"browser": "build/index.global.js", | ||
@@ -28,5 +29,5 @@ "types": "./dist/index.d.ts", | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"default": "./dist/index.js" | ||
"import": "./dist/index.js", | ||
"module": "./dist/index.js", | ||
"default": "./dist/index.cjs" | ||
}, | ||
@@ -63,2 +64,5 @@ "./package.json": "./package.json" | ||
}, | ||
"engines": { | ||
"node": "^12.17.0 || ^14.13 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
@@ -70,5 +74,5 @@ "build": "tsup", | ||
"pre-push": "pnpm typecheck", | ||
"test": "jest --config ../../jest.config.js --passWithNoTests --runInBand --testPathPattern=packages/core/src", | ||
"test:local": "jest --config ../../jest.config.js --testPathPattern=packages/core/src --maxWorkers=50%", | ||
"test:watch": "jest --config ../../jest.config.js --testPathPattern=packages/core/src --maxWorkers=25% --watch", | ||
"test": "jest --config ../../jest.config.ts --passWithNoTests --runInBand --testPathPattern=packages/core/src", | ||
"test:local": "jest --config ../../jest.config.ts --testPathPattern=packages/core/src --maxWorkers=50%", | ||
"test:watch": "jest --config ../../jest.config.ts --testPathPattern=packages/core/src --maxWorkers=25% --watch", | ||
"upgrade": "ncu -u", | ||
@@ -75,0 +79,0 @@ "upgrade:local": "ncu --interactive --doctor", |
Sorry, the diff of this file is too big to display
3552894
Yes