@kubb/core 0.56.0 → 0.56.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.
@@ -1,14 +1,26 @@
1
- import { createRequire } from 'module';
2
- import pathParser from 'path';
3
- import { promises } from 'fs';
4
- import rimraf from 'rimraf';
5
- import { format as format$1 } from 'prettier';
6
- import EventEmitter from 'eventemitter3';
7
- import uniq from 'lodash.uniq';
8
- import { v4 } from 'uuid';
9
- import dirTree from 'directory-tree';
1
+ 'use strict';
10
2
 
11
- createRequire(import.meta.url);
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var module$1 = require('module');
6
+ var pathParser = require('path');
7
+ var fs = require('fs');
8
+ var rimraf = require('rimraf');
9
+ var prettier = require('prettier');
10
+ var EventEmitter = require('eventemitter3');
11
+ var uniq = require('lodash.uniq');
12
+ var uuid = require('uuid');
13
+ var dirTree = require('directory-tree');
14
+
15
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
+
17
+ var pathParser__default = /*#__PURE__*/_interopDefault(pathParser);
18
+ var rimraf__default = /*#__PURE__*/_interopDefault(rimraf);
19
+ var EventEmitter__default = /*#__PURE__*/_interopDefault(EventEmitter);
20
+ var uniq__default = /*#__PURE__*/_interopDefault(uniq);
21
+ var dirTree__default = /*#__PURE__*/_interopDefault(dirTree);
22
+
23
+ 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)));
12
24
 
13
25
  // src/utils/isURL.ts
14
26
  var isURL = (data) => {
@@ -28,14 +40,14 @@ var isPromise = (result) => {
28
40
  return typeof result?.then === "function";
29
41
  };
30
42
  var safeWriteFileToPath = async (path, data) => {
31
- const passedPath = pathParser.dirname(pathParser.resolve(path));
32
- await promises.mkdir(passedPath, { recursive: true });
33
- return promises.writeFile(pathParser.resolve(path), data, { encoding: "utf-8" });
43
+ const passedPath = pathParser__default.default.dirname(pathParser__default.default.resolve(path));
44
+ await fs.promises.mkdir(passedPath, { recursive: true });
45
+ return fs.promises.writeFile(pathParser__default.default.resolve(path), data, { encoding: "utf-8" });
34
46
  };
35
47
  var write = async (data, path) => {
36
48
  try {
37
- await promises.stat(path);
38
- const oldContent = await promises.readFile(path, { encoding: "utf-8" });
49
+ await fs.promises.stat(path);
50
+ const oldContent = await fs.promises.readFile(path, { encoding: "utf-8" });
39
51
  if (oldContent?.toString() === data) {
40
52
  return;
41
53
  }
@@ -46,7 +58,7 @@ var write = async (data, path) => {
46
58
  };
47
59
  var clean = async (path) => {
48
60
  return new Promise((resolve, reject) => {
49
- rimraf(path, (err) => {
61
+ rimraf__default.default(path, (err) => {
50
62
  if (err) {
51
63
  reject(err);
52
64
  } else {
@@ -85,18 +97,18 @@ var getRelativePath = (root, file) => {
85
97
  if (!root || !file) {
86
98
  throw new Error("Root and file should be filled in when retrieving the relativePath");
87
99
  }
88
- const newPath = pathParser.relative(root, file).replace("../", "").replace(".ts", "").trimEnd();
100
+ const newPath = pathParser__default.default.relative(root, file).replace("../", "").replace(".ts", "").trimEnd();
89
101
  return `./${newPath}`;
90
102
  };
91
103
  var getPathMode = (path) => {
92
104
  if (!path) {
93
105
  return "directory";
94
106
  }
95
- return pathParser.extname(path) ? "file" : "directory";
107
+ return pathParser__default.default.extname(path) ? "file" : "directory";
96
108
  };
97
109
  var read = async (path) => {
98
110
  try {
99
- return promises.readFile(path, { encoding: "utf8" });
111
+ return fs.promises.readFile(path, { encoding: "utf8" });
100
112
  } catch (err) {
101
113
  console.error(err);
102
114
  throw err;
@@ -113,7 +125,7 @@ var formatOptions = {
113
125
  // plugins: [parserTypescript],
114
126
  };
115
127
  var format = (source) => {
116
- return format$1(source, formatOptions);
128
+ return prettier.format(source, formatOptions);
117
129
  };
118
130
 
119
131
  // src/utils/objectToParameters.ts
@@ -191,7 +203,7 @@ var definePlugin = createPlugin((options) => {
191
203
  if (!directory) {
192
204
  return null;
193
205
  }
194
- return pathParser.resolve(directory, fileName);
206
+ return pathParser__default.default.resolve(directory, fileName);
195
207
  }
196
208
  };
197
209
  });
@@ -253,7 +265,7 @@ var getFileManagerEvents = (emitter) => {
253
265
  // src/managers/fileManager/FileManager.ts
254
266
  var FileManager = class {
255
267
  cache = /* @__PURE__ */ new Map();
256
- emitter = new EventEmitter();
268
+ emitter = new EventEmitter__default.default();
257
269
  events = getFileManagerEvents(this.emitter);
258
270
  constructor() {
259
271
  this.events.onStatusChange(() => {
@@ -295,7 +307,7 @@ var FileManager = class {
295
307
  return;
296
308
  }
297
309
  if (exists && Array.isArray(curr.name)) {
298
- exists.name = uniq([...exists.name, ...curr.name]);
310
+ exists.name = uniq__default.default([...exists.name, ...curr.name]);
299
311
  }
300
312
  });
301
313
  const importSource = imports.reduce((prev, curr) => {
@@ -327,7 +339,7 @@ ${file.source}`;
327
339
  return files;
328
340
  }
329
341
  add(file) {
330
- const cacheItem = { id: v4(), file, status: "new" };
342
+ const cacheItem = { id: uuid.v4(), file, status: "new" };
331
343
  this.cache.set(cacheItem.id, cacheItem);
332
344
  this.events.emitFile(cacheItem.id, file);
333
345
  return new Promise((resolve) => {
@@ -458,7 +470,7 @@ var TreeNode = class {
458
470
  return this;
459
471
  }
460
472
  static build(path, options = {}) {
461
- const filteredTree = dirTree(path, { extensions: options?.extensions, exclude: options.exclude });
473
+ const filteredTree = dirTree__default.default(path, { extensions: options?.extensions, exclude: options.exclude });
462
474
  if (!filteredTree) {
463
475
  return;
464
476
  }
@@ -709,9 +721,9 @@ async function buildImplementation(options, done) {
709
721
  });
710
722
  await pluginManager.hookParallel("buildStart", [config]);
711
723
  pluginManager.fileManager.add({
712
- path: isURL(config.input.path) ? config.input.path : pathParser.resolve(config.root, config.input.path),
724
+ path: isURL(config.input.path) ? config.input.path : pathParser__default.default.resolve(config.root, config.input.path),
713
725
  fileName: isURL(config.input.path) ? "input" : config.input.path,
714
- source: isURL(config.input.path) ? config.input.path : await read(pathParser.resolve(config.root, config.input.path))
726
+ source: isURL(config.input.path) ? config.input.path : await read(pathParser__default.default.resolve(config.root, config.input.path))
715
727
  });
716
728
  }
717
729
  function build(options) {
@@ -751,6 +763,30 @@ var SchemaGenerator = class extends Generator {
751
763
  // src/index.ts
752
764
  var src_default = build;
753
765
 
754
- 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 };
766
+ exports.FileManager = FileManager;
767
+ exports.Generator = Generator;
768
+ exports.PluginManager = PluginManager;
769
+ exports.SchemaGenerator = SchemaGenerator;
770
+ exports.TreeNode = TreeNode;
771
+ exports.ValidationPluginError = ValidationPluginError;
772
+ exports.build = build;
773
+ exports.clean = clean;
774
+ exports.createJSDocBlockText = createJSDocBlockText;
775
+ exports.createPlugin = createPlugin;
776
+ exports.createPluginCache = createPluginCache;
777
+ exports.default = src_default;
778
+ exports.defineConfig = defineConfig;
779
+ exports.format = format;
780
+ exports.getPathMode = getPathMode;
781
+ exports.getRelativePath = getRelativePath;
782
+ exports.hooks = hooks;
783
+ exports.isPromise = isPromise;
784
+ exports.isURL = isURL;
785
+ exports.name = name;
786
+ exports.nameSorter = nameSorter;
787
+ exports.objectToParameters = objectToParameters;
788
+ exports.read = read;
789
+ exports.validatePlugins = validatePlugins;
790
+ exports.write = write;
755
791
  //# sourceMappingURL=out.js.map
756
- //# sourceMappingURL=index.mjs.map
792
+ //# sourceMappingURL=index.cjs.map
@@ -28283,7 +28283,7 @@ ${n}`;
28283
28283
 
28284
28284
  // src/build.ts
28285
28285
  init_define_process();
28286
- var import_path4 = __toESM(require_path_browserify());
28286
+ var import_path4 = __toESM(require_path_browserify(), 1);
28287
28287
 
28288
28288
  // src/utils/isURL.ts
28289
28289
  init_define_process();
@@ -28304,7 +28304,7 @@ ${n}`;
28304
28304
 
28305
28305
  // src/plugin.ts
28306
28306
  init_define_process();
28307
- var import_path3 = __toESM(require_path_browserify());
28307
+ var import_path3 = __toESM(require_path_browserify(), 1);
28308
28308
 
28309
28309
  // src/utils/isPromise.ts
28310
28310
  init_define_process();
@@ -28314,9 +28314,9 @@ ${n}`;
28314
28314
 
28315
28315
  // src/utils/write.ts
28316
28316
  init_define_process();
28317
- var import_fs = __toESM(require_lib());
28318
- var import_path = __toESM(require_path_browserify());
28319
- var import_rimraf = __toESM(require_rimraf());
28317
+ var import_fs = __toESM(require_lib(), 1);
28318
+ var import_path = __toESM(require_path_browserify(), 1);
28319
+ var import_rimraf = __toESM(require_rimraf(), 1);
28320
28320
  var safeWriteFileToPath = async (path, data) => {
28321
28321
  const passedPath = import_path.default.dirname(import_path.default.resolve(path));
28322
28322
  await import_fs.promises.mkdir(passedPath, { recursive: true });
@@ -28375,8 +28375,8 @@ ${n}`;
28375
28375
 
28376
28376
  // src/utils/read.ts
28377
28377
  init_define_process();
28378
- var import_path2 = __toESM(require_path_browserify());
28379
- var import_fs2 = __toESM(require_lib());
28378
+ var import_path2 = __toESM(require_path_browserify(), 1);
28379
+ var import_fs2 = __toESM(require_lib(), 1);
28380
28380
  var getRelativePath = (root, file) => {
28381
28381
  if (!root || !file) {
28382
28382
  throw new Error("Root and file should be filled in when retrieving the relativePath");
@@ -28401,7 +28401,7 @@ ${n}`;
28401
28401
 
28402
28402
  // src/utils/format.ts
28403
28403
  init_define_process();
28404
- var import_prettier = __toESM(require_standalone());
28404
+ var import_prettier = __toESM(require_standalone(), 1);
28405
28405
  var formatOptions = {
28406
28406
  tabWidth: 2,
28407
28407
  printWidth: 160,
@@ -28508,7 +28508,7 @@ ${n}`;
28508
28508
  var eventemitter3_default = import_index.default;
28509
28509
 
28510
28510
  // src/managers/fileManager/FileManager.ts
28511
- var import_lodash = __toESM(require_lodash());
28511
+ var import_lodash = __toESM(require_lodash(), 1);
28512
28512
 
28513
28513
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/index.js
28514
28514
  init_define_process();
@@ -28771,7 +28771,7 @@ ${curr.source}`,
28771
28771
 
28772
28772
  // src/managers/fileManager/TreeNode.ts
28773
28773
  init_define_process();
28774
- var import_directory_tree = __toESM(require_directory_tree());
28774
+ var import_directory_tree = __toESM(require_directory_tree(), 1);
28775
28775
  var TreeNode = class {
28776
28776
  data;
28777
28777
  parent;
package/dist/index.js CHANGED
@@ -1,26 +1,14 @@
1
- 'use strict';
1
+ import { createRequire } from 'module';
2
+ import pathParser from 'path';
3
+ import { promises } from 'fs';
4
+ import rimraf from 'rimraf';
5
+ import { format as format$1 } from 'prettier';
6
+ import EventEmitter from 'eventemitter3';
7
+ import uniq from 'lodash.uniq';
8
+ import { v4 } from 'uuid';
9
+ import dirTree from 'directory-tree';
2
10
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var module$1 = require('module');
6
- var pathParser = require('path');
7
- var fs = require('fs');
8
- var rimraf = require('rimraf');
9
- var prettier = require('prettier');
10
- var EventEmitter = require('eventemitter3');
11
- var uniq = require('lodash.uniq');
12
- var uuid = require('uuid');
13
- var dirTree = require('directory-tree');
14
-
15
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
-
17
- var pathParser__default = /*#__PURE__*/_interopDefault(pathParser);
18
- var rimraf__default = /*#__PURE__*/_interopDefault(rimraf);
19
- var EventEmitter__default = /*#__PURE__*/_interopDefault(EventEmitter);
20
- var uniq__default = /*#__PURE__*/_interopDefault(uniq);
21
- var dirTree__default = /*#__PURE__*/_interopDefault(dirTree);
22
-
23
- 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)));
11
+ createRequire(import.meta.url);
24
12
 
25
13
  // src/utils/isURL.ts
26
14
  var isURL = (data) => {
@@ -40,14 +28,14 @@ var isPromise = (result) => {
40
28
  return typeof result?.then === "function";
41
29
  };
42
30
  var safeWriteFileToPath = async (path, data) => {
43
- const passedPath = pathParser__default.default.dirname(pathParser__default.default.resolve(path));
44
- await fs.promises.mkdir(passedPath, { recursive: true });
45
- return fs.promises.writeFile(pathParser__default.default.resolve(path), data, { encoding: "utf-8" });
31
+ const passedPath = pathParser.dirname(pathParser.resolve(path));
32
+ await promises.mkdir(passedPath, { recursive: true });
33
+ return promises.writeFile(pathParser.resolve(path), data, { encoding: "utf-8" });
46
34
  };
47
35
  var write = async (data, path) => {
48
36
  try {
49
- await fs.promises.stat(path);
50
- const oldContent = await fs.promises.readFile(path, { encoding: "utf-8" });
37
+ await promises.stat(path);
38
+ const oldContent = await promises.readFile(path, { encoding: "utf-8" });
51
39
  if (oldContent?.toString() === data) {
52
40
  return;
53
41
  }
@@ -58,7 +46,7 @@ var write = async (data, path) => {
58
46
  };
59
47
  var clean = async (path) => {
60
48
  return new Promise((resolve, reject) => {
61
- rimraf__default.default(path, (err) => {
49
+ rimraf(path, (err) => {
62
50
  if (err) {
63
51
  reject(err);
64
52
  } else {
@@ -97,18 +85,18 @@ var getRelativePath = (root, file) => {
97
85
  if (!root || !file) {
98
86
  throw new Error("Root and file should be filled in when retrieving the relativePath");
99
87
  }
100
- const newPath = pathParser__default.default.relative(root, file).replace("../", "").replace(".ts", "").trimEnd();
88
+ const newPath = pathParser.relative(root, file).replace("../", "").replace(".ts", "").trimEnd();
101
89
  return `./${newPath}`;
102
90
  };
103
91
  var getPathMode = (path) => {
104
92
  if (!path) {
105
93
  return "directory";
106
94
  }
107
- return pathParser__default.default.extname(path) ? "file" : "directory";
95
+ return pathParser.extname(path) ? "file" : "directory";
108
96
  };
109
97
  var read = async (path) => {
110
98
  try {
111
- return fs.promises.readFile(path, { encoding: "utf8" });
99
+ return promises.readFile(path, { encoding: "utf8" });
112
100
  } catch (err) {
113
101
  console.error(err);
114
102
  throw err;
@@ -125,7 +113,7 @@ var formatOptions = {
125
113
  // plugins: [parserTypescript],
126
114
  };
127
115
  var format = (source) => {
128
- return prettier.format(source, formatOptions);
116
+ return format$1(source, formatOptions);
129
117
  };
130
118
 
131
119
  // src/utils/objectToParameters.ts
@@ -203,7 +191,7 @@ var definePlugin = createPlugin((options) => {
203
191
  if (!directory) {
204
192
  return null;
205
193
  }
206
- return pathParser__default.default.resolve(directory, fileName);
194
+ return pathParser.resolve(directory, fileName);
207
195
  }
208
196
  };
209
197
  });
@@ -265,7 +253,7 @@ var getFileManagerEvents = (emitter) => {
265
253
  // src/managers/fileManager/FileManager.ts
266
254
  var FileManager = class {
267
255
  cache = /* @__PURE__ */ new Map();
268
- emitter = new EventEmitter__default.default();
256
+ emitter = new EventEmitter();
269
257
  events = getFileManagerEvents(this.emitter);
270
258
  constructor() {
271
259
  this.events.onStatusChange(() => {
@@ -307,7 +295,7 @@ var FileManager = class {
307
295
  return;
308
296
  }
309
297
  if (exists && Array.isArray(curr.name)) {
310
- exists.name = uniq__default.default([...exists.name, ...curr.name]);
298
+ exists.name = uniq([...exists.name, ...curr.name]);
311
299
  }
312
300
  });
313
301
  const importSource = imports.reduce((prev, curr) => {
@@ -339,7 +327,7 @@ ${file.source}`;
339
327
  return files;
340
328
  }
341
329
  add(file) {
342
- const cacheItem = { id: uuid.v4(), file, status: "new" };
330
+ const cacheItem = { id: v4(), file, status: "new" };
343
331
  this.cache.set(cacheItem.id, cacheItem);
344
332
  this.events.emitFile(cacheItem.id, file);
345
333
  return new Promise((resolve) => {
@@ -470,7 +458,7 @@ var TreeNode = class {
470
458
  return this;
471
459
  }
472
460
  static build(path, options = {}) {
473
- const filteredTree = dirTree__default.default(path, { extensions: options?.extensions, exclude: options.exclude });
461
+ const filteredTree = dirTree(path, { extensions: options?.extensions, exclude: options.exclude });
474
462
  if (!filteredTree) {
475
463
  return;
476
464
  }
@@ -721,9 +709,9 @@ async function buildImplementation(options, done) {
721
709
  });
722
710
  await pluginManager.hookParallel("buildStart", [config]);
723
711
  pluginManager.fileManager.add({
724
- path: isURL(config.input.path) ? config.input.path : pathParser__default.default.resolve(config.root, config.input.path),
712
+ path: isURL(config.input.path) ? config.input.path : pathParser.resolve(config.root, config.input.path),
725
713
  fileName: isURL(config.input.path) ? "input" : config.input.path,
726
- source: isURL(config.input.path) ? config.input.path : await read(pathParser__default.default.resolve(config.root, config.input.path))
714
+ source: isURL(config.input.path) ? config.input.path : await read(pathParser.resolve(config.root, config.input.path))
727
715
  });
728
716
  }
729
717
  function build(options) {
@@ -763,30 +751,6 @@ var SchemaGenerator = class extends Generator {
763
751
  // src/index.ts
764
752
  var src_default = build;
765
753
 
766
- exports.FileManager = FileManager;
767
- exports.Generator = Generator;
768
- exports.PluginManager = PluginManager;
769
- exports.SchemaGenerator = SchemaGenerator;
770
- exports.TreeNode = TreeNode;
771
- exports.ValidationPluginError = ValidationPluginError;
772
- exports.build = build;
773
- exports.clean = clean;
774
- exports.createJSDocBlockText = createJSDocBlockText;
775
- exports.createPlugin = createPlugin;
776
- exports.createPluginCache = createPluginCache;
777
- exports.default = src_default;
778
- exports.defineConfig = defineConfig;
779
- exports.format = format;
780
- exports.getPathMode = getPathMode;
781
- exports.getRelativePath = getRelativePath;
782
- exports.hooks = hooks;
783
- exports.isPromise = isPromise;
784
- exports.isURL = isURL;
785
- exports.name = name;
786
- exports.nameSorter = nameSorter;
787
- exports.objectToParameters = objectToParameters;
788
- exports.read = read;
789
- exports.validatePlugins = validatePlugins;
790
- exports.write = write;
754
+ 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 };
791
755
  //# sourceMappingURL=out.js.map
792
756
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/core",
3
- "version": "0.56.0",
3
+ "version": "0.56.1",
4
4
  "description": "Generator core",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,17 +16,18 @@
16
16
  "codegen"
17
17
  ],
18
18
  "sideEffects": false,
19
+ "type": "module",
19
20
  "main": "dist/index.js",
20
21
  "unpkg": "dist/index.global.js",
21
- "module": "dist/index.mjs",
22
+ "module": "dist/index.js",
22
23
  "browser": "build/index.global.js",
23
24
  "types": "./dist/index.d.ts",
24
25
  "exports": {
25
26
  ".": {
26
27
  "types": "./dist/index.d.ts",
27
- "import": "./dist/index.mjs",
28
- "module": "./dist/index.mjs",
29
- "default": "./dist/index.js"
28
+ "import": "./dist/index.js",
29
+ "module": "./dist/index.js",
30
+ "default": "./dist/index.cjs"
30
31
  },
31
32
  "./package.json": "./package.json"
32
33
  },
@@ -58,15 +59,18 @@
58
59
  "access": "public",
59
60
  "registry": "https://registry.npmjs.org/"
60
61
  },
62
+ "engines": {
63
+ "node": "^12.17.0 || ^14.13 || >=16.0.0"
64
+ },
61
65
  "scripts": {
62
66
  "build": "tsup",
63
67
  "start": "tsup --watch",
64
68
  "release": "pnpm publish --no-git-check",
65
69
  "pre-commit": "echo 'pre-commit not configured'",
66
70
  "pre-push": "pnpm typecheck",
67
- "test": "jest --config ../../jest.config.js --passWithNoTests --runInBand --testPathPattern=packages/core/src",
68
- "test:local": "jest --config ../../jest.config.js --testPathPattern=packages/core/src --maxWorkers=50%",
69
- "test:watch": "jest --config ../../jest.config.js --testPathPattern=packages/core/src --maxWorkers=25% --watch",
71
+ "test": "jest --config ../../jest.config.ts --passWithNoTests --runInBand --testPathPattern=packages/core/src",
72
+ "test:local": "jest --config ../../jest.config.ts --testPathPattern=packages/core/src --maxWorkers=50%",
73
+ "test:watch": "jest --config ../../jest.config.ts --testPathPattern=packages/core/src --maxWorkers=25% --watch",
70
74
  "upgrade": "ncu -u",
71
75
  "upgrade:local": "ncu --interactive --doctor",
72
76
  "typecheck": "tsc -p ./tsconfig.json --noEmit"
File without changes