@kubb/core 2.0.0-beta.11 → 2.0.0-beta.12

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/index.cjs CHANGED
@@ -2,10 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var pc2 = require('picocolors');
5
+ var tty = require('tty');
6
6
  var path4 = require('path');
7
7
  var jsRuntime = require('js-runtime');
8
- var changeCase = require('change-case');
9
8
  var crypto2 = require('crypto');
10
9
  var parser = require('@kubb/parser');
11
10
  var factory = require('@kubb/parser/factory');
@@ -41,7 +40,6 @@ function _interopNamespace(e) {
41
40
  return Object.freeze(n);
42
41
  }
43
42
 
44
- var pc2__default = /*#__PURE__*/_interopDefault(pc2);
45
43
  var path4__default = /*#__PURE__*/_interopDefault(path4);
46
44
  var crypto2__default = /*#__PURE__*/_interopDefault(crypto2);
47
45
  var factory__namespace = /*#__PURE__*/_interopNamespace(factory);
@@ -59,12 +57,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
59
57
  var __getProtoOf = Object.getPrototypeOf;
60
58
  var __hasOwnProp = Object.prototype.hasOwnProperty;
61
59
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
62
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
63
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
64
- }) : x)(function(x) {
60
+ var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
61
+ get: (a, b2) => (typeof require !== "undefined" ? require : a)[b2]
62
+ }) : x2)(function(x2) {
65
63
  if (typeof require !== "undefined")
66
64
  return require.apply(this, arguments);
67
- throw Error('Dynamic require of "' + x + '" is not supported');
65
+ throw Error('Dynamic require of "' + x2 + '" is not supported');
68
66
  });
69
67
  var __esm = (fn, res) => function __init() {
70
68
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -152,7 +150,7 @@ var require_universalify = __commonJS({
152
150
  return fn.apply(this, args);
153
151
  else {
154
152
  args.pop();
155
- fn.apply(this, args).then((r) => cb(null, r), cb);
153
+ fn.apply(this, args).then((r2) => cb(null, r2), cb);
156
154
  }
157
155
  }, "name", { value: fn.name });
158
156
  };
@@ -178,9 +176,9 @@ var require_polyfills = __commonJS({
178
176
  }
179
177
  if (typeof process.chdir === "function") {
180
178
  chdir = process.chdir;
181
- process.chdir = function(d) {
179
+ process.chdir = function(d2) {
182
180
  cwd = null;
183
- chdir.call(process, d);
181
+ chdir.call(process, d2);
184
182
  };
185
183
  if (Object.setPrototypeOf)
186
184
  Object.setPrototypeOf(process.chdir, chdir);
@@ -3041,6 +3039,71 @@ init_cjs_shims();
3041
3039
  // src/build.ts
3042
3040
  init_cjs_shims();
3043
3041
 
3042
+ // ../../node_modules/.pnpm/tinyrainbow@1.1.1/node_modules/tinyrainbow/dist/node.js
3043
+ init_cjs_shims();
3044
+
3045
+ // ../../node_modules/.pnpm/tinyrainbow@1.1.1/node_modules/tinyrainbow/dist/chunk-5WCZOS7T.js
3046
+ init_cjs_shims();
3047
+ var b = {
3048
+ reset: [0, 0],
3049
+ bold: [1, 22, "\x1B[22m\x1B[1m"],
3050
+ dim: [2, 22, "\x1B[22m\x1B[2m"],
3051
+ italic: [3, 23],
3052
+ underline: [4, 24],
3053
+ inverse: [7, 27],
3054
+ hidden: [8, 28],
3055
+ strikethrough: [9, 29],
3056
+ black: [30, 39],
3057
+ red: [31, 39],
3058
+ green: [32, 39],
3059
+ yellow: [33, 39],
3060
+ blue: [34, 39],
3061
+ magenta: [35, 39],
3062
+ cyan: [36, 39],
3063
+ white: [37, 39],
3064
+ gray: [90, 39],
3065
+ bgBlack: [40, 49],
3066
+ bgRed: [41, 49],
3067
+ bgGreen: [42, 49],
3068
+ bgYellow: [43, 49],
3069
+ bgBlue: [44, 49],
3070
+ bgMagenta: [45, 49],
3071
+ bgCyan: [46, 49],
3072
+ bgWhite: [47, 49]
3073
+ };
3074
+ var C = Object.entries(b);
3075
+ function d(r2) {
3076
+ return String(r2);
3077
+ }
3078
+ d.open = "";
3079
+ d.close = "";
3080
+ function p(r2 = false) {
3081
+ let n = typeof process != "undefined" ? process : void 0, t = (n == null ? void 0 : n.env) || {}, a = (n == null ? void 0 : n.argv) || [];
3082
+ return !("NO_COLOR" in t || a.includes("--no-color")) && !("GITHUB_ACTIONS" in t) && ("FORCE_COLOR" in t || a.includes("--color") || (n == null ? void 0 : n.platform) === "win32" || r2 && t.TERM !== "dumb" || "CI" in t) || typeof window != "undefined" && !!window.chrome;
3083
+ }
3084
+ function w(r2 = false) {
3085
+ let n = p(r2), t = (e, o, c, i) => {
3086
+ let u = e.substring(0, i) + c, s = e.substring(i + o.length), l = s.indexOf(o);
3087
+ return ~l ? u + t(s, o, c, l) : u + s;
3088
+ }, a = (e, o, c = e) => {
3089
+ let i = (u) => {
3090
+ let s = String(u), l = s.indexOf(o, e.length);
3091
+ return ~l ? e + t(s, o, c, l) + o : e + s + o;
3092
+ };
3093
+ return i.open = e, i.close = o, i;
3094
+ }, g = {
3095
+ isColorSupported: n
3096
+ }, f = (e) => `\x1B[${e}m`;
3097
+ for (let [e, o] of C)
3098
+ g[e] = n ? a(
3099
+ f(o[0]),
3100
+ f(o[1]),
3101
+ o[2]
3102
+ ) : d;
3103
+ return g;
3104
+ }
3105
+ var p2 = w(tty.isatty(1));
3106
+
3044
3107
  // src/fs/clean.ts
3045
3108
  init_cjs_shims();
3046
3109
  var import_fs_extra = __toESM(require_lib(), 1);
@@ -3104,11 +3167,86 @@ init_cjs_shims();
3104
3167
 
3105
3168
  // src/transformers/casing.ts
3106
3169
  init_cjs_shims();
3107
- function camelCase(text) {
3108
- return changeCase.camelCase(text, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: changeCase.camelCaseTransformMerge });
3170
+
3171
+ // ../../node_modules/.pnpm/change-case@5.2.0/node_modules/change-case/dist/index.js
3172
+ init_cjs_shims();
3173
+ var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
3174
+ var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
3175
+ var SPLIT_NUMBER_LOWER_RE = /(\d)(\p{Ll})/gu;
3176
+ var SPLIT_LETTER_NUMBER_RE = /(\p{L})(\d)/gu;
3177
+ var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
3178
+ var SPLIT_REPLACE_VALUE = "$1\0$2";
3179
+ var DEFAULT_PREFIX_CHARACTERS = "";
3180
+ function split(input, options) {
3181
+ let result = input.trim();
3182
+ result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
3183
+ if (options?.separateNumbers) {
3184
+ result = result.replace(SPLIT_NUMBER_LOWER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_LETTER_NUMBER_RE, SPLIT_REPLACE_VALUE);
3185
+ }
3186
+ result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
3187
+ let start = 0;
3188
+ let end = result.length;
3189
+ while (result.charAt(start) === "\0")
3190
+ start++;
3191
+ if (start === end)
3192
+ return [];
3193
+ while (result.charAt(end - 1) === "\0")
3194
+ end--;
3195
+ return result.slice(start, end).split(/\0/g);
3196
+ }
3197
+ function camelCase(input, options) {
3198
+ const prefix = getPrefix(input, options?.prefixCharacters);
3199
+ const lower = lowerFactory(options?.locale);
3200
+ const upper = upperFactory(options?.locale);
3201
+ const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
3202
+ return prefix + split(input, options).map((word, index) => {
3203
+ if (index === 0)
3204
+ return lower(word);
3205
+ return transform(word, index);
3206
+ }).join(options?.delimiter ?? "");
3207
+ }
3208
+ function pascalCase(input, options) {
3209
+ const prefix = getPrefix(input, options?.prefixCharacters);
3210
+ const lower = lowerFactory(options?.locale);
3211
+ const upper = upperFactory(options?.locale);
3212
+ const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
3213
+ return prefix + split(input, options).map(transform).join(options?.delimiter ?? "");
3214
+ }
3215
+ function lowerFactory(locale) {
3216
+ return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
3217
+ }
3218
+ function upperFactory(locale) {
3219
+ return locale === false ? (input) => input.toUpperCase() : (input) => input.toLocaleUpperCase(locale);
3109
3220
  }
3110
- function pascalCase(text) {
3111
- return changeCase.pascalCase(text, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: changeCase.pascalCaseTransformMerge });
3221
+ function capitalCaseTransformFactory(lower, upper) {
3222
+ return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
3223
+ }
3224
+ function pascalCaseTransformFactory(lower, upper) {
3225
+ return (word, index) => {
3226
+ const char0 = word[0];
3227
+ const initial = index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0);
3228
+ return initial + lower(word.slice(1));
3229
+ };
3230
+ }
3231
+ function getPrefix(input, prefixCharacters = DEFAULT_PREFIX_CHARACTERS) {
3232
+ let prefix = "";
3233
+ for (let i = 0; i < input.length; i++) {
3234
+ const char = input.charAt(i);
3235
+ if (prefixCharacters.includes(char)) {
3236
+ prefix += char;
3237
+ } else {
3238
+ break;
3239
+ }
3240
+ }
3241
+ return prefix;
3242
+ }
3243
+
3244
+ // src/transformers/casing.ts
3245
+ function camelCase2(text) {
3246
+ return camelCase(text, { delimiter: "", mergeAmbiguousCharacters: true });
3247
+ }
3248
+ function pascalCase2(text) {
3249
+ return pascalCase(text, { delimiter: "", mergeAmbiguousCharacters: true });
3112
3250
  }
3113
3251
 
3114
3252
  // src/transformers/combineCodes.ts
@@ -3163,11 +3301,11 @@ function createIndent(size) {
3163
3301
 
3164
3302
  // src/transformers/nameSorter.ts
3165
3303
  init_cjs_shims();
3166
- function nameSorter(a, b) {
3167
- if (a.name < b.name) {
3304
+ function nameSorter(a, b2) {
3305
+ if (a.name < b2.name) {
3168
3306
  return -1;
3169
3307
  }
3170
- if (a.name > b.name) {
3308
+ if (a.name > b2.name) {
3171
3309
  return 1;
3172
3310
  }
3173
3311
  return 0;
@@ -3308,8 +3446,8 @@ var transformers_default = {
3308
3446
  JSDoc: {
3309
3447
  createJSDocBlockText
3310
3448
  },
3311
- camelCase,
3312
- pascalCase
3449
+ camelCase: camelCase2,
3450
+ pascalCase: pascalCase2
3313
3451
  };
3314
3452
 
3315
3453
  // src/utils/URLPath.ts
@@ -3974,7 +4112,7 @@ function createLogger({ logLevel, name, spinner }) {
3974
4112
  };
3975
4113
  const warn = (message) => {
3976
4114
  if (message && spinner) {
3977
- spinner.warn(pc2__default.default.yellow(message));
4115
+ spinner.warn(p2.yellow(message));
3978
4116
  logs.push(message);
3979
4117
  }
3980
4118
  };
@@ -4005,8 +4143,8 @@ function randomColour(text, colours = defaultColours) {
4005
4143
  const colour = colours.at(Math.floor(random() * colours.length)) || "white";
4006
4144
  return colour;
4007
4145
  }
4008
- function randomPicoColour(text, colors = defaultColours) {
4009
- const colours = pc2__default.default.createColors(true);
4146
+ function randomCliColour(text, colors = defaultColours) {
4147
+ const colours = w(true);
4010
4148
  if (!text) {
4011
4149
  return colours.white(text);
4012
4150
  }
@@ -4015,7 +4153,7 @@ function randomPicoColour(text, colors = defaultColours) {
4015
4153
  const key = colour.replace("dark", "").toLowerCase();
4016
4154
  const formatter = colours[key];
4017
4155
  if (isDark) {
4018
- return pc2__default.default.bold(formatter(text));
4156
+ return p2.bold(formatter(text));
4019
4157
  }
4020
4158
  if (typeof formatter !== "function") {
4021
4159
  throw new Error("Formatter for picoColor is not of type function/Formatter");
@@ -4615,11 +4753,11 @@ getSortedPlugins_fn = function(hookName) {
4615
4753
  }
4616
4754
  }
4617
4755
  return plugin;
4618
- }).sort((a, b) => {
4619
- if (b.pre?.includes(a.name)) {
4756
+ }).sort((a, b2) => {
4757
+ if (b2.pre?.includes(a.name)) {
4620
4758
  return 1;
4621
4759
  }
4622
- if (b.post?.includes(a.name)) {
4760
+ if (b2.post?.includes(a.name)) {
4623
4761
  return -1;
4624
4762
  }
4625
4763
  return 0;
@@ -4750,7 +4888,7 @@ async function setup(options) {
4750
4888
  } catch (e) {
4751
4889
  if (isInputPath(config)) {
4752
4890
  throw new Error(
4753
- "Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config " + pc2__default.default.dim(config.input.path),
4891
+ "Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config " + p2.dim(config.input.path),
4754
4892
  {
4755
4893
  cause: e
4756
4894
  }
@@ -4803,7 +4941,7 @@ async function setup(options) {
4803
4941
  logger.spinner.start(`\u{1F4BE} Writing`);
4804
4942
  }
4805
4943
  if (logger.logLevel === LogLevel.debug) {
4806
- logger.info(`PluginKey ${pc2__default.default.dim(JSON.stringify(plugin.key))}
4944
+ logger.info(`PluginKey ${p2.dim(JSON.stringify(plugin.key))}
4807
4945
  with source
4808
4946
 
4809
4947
  ${code}`);
@@ -4812,11 +4950,11 @@ ${code}`);
4812
4950
  });
4813
4951
  pluginManager.on("executed", (executer) => {
4814
4952
  const { hookName, plugin, output, parameters } = executer;
4815
- const messsage = `${randomPicoColour(plugin.name)} Executing ${hookName}`;
4953
+ const messsage = `${randomCliColour(plugin.name)} Executing ${hookName}`;
4816
4954
  if (logger.logLevel === LogLevel.info && logger.spinner) {
4817
4955
  if (hookName === "writeFile") {
4818
4956
  const [_code, path5] = parameters;
4819
- logger.spinner.suffixText = pc2__default.default.dim(path5);
4957
+ logger.spinner.suffixText = p2.dim(path5);
4820
4958
  } else {
4821
4959
  logger.spinner.suffixText = messsage;
4822
4960
  }
@@ -4824,9 +4962,9 @@ ${code}`);
4824
4962
  if (logger.logLevel === LogLevel.debug) {
4825
4963
  logger.info(messsage);
4826
4964
  const logs = [
4827
- parameters && `${pc2__default.default.bgWhite(`Parameters`)} ${randomPicoColour(plugin.name)} ${hookName}`,
4965
+ parameters && `${p2.bgWhite(`Parameters`)} ${randomCliColour(plugin.name)} ${hookName}`,
4828
4966
  JSON.stringify(parameters, void 0, 2),
4829
- output && `${pc2__default.default.bgWhite("Output")} ${randomPicoColour(plugin.name)} ${hookName}`,
4967
+ output && `${p2.bgWhite("Output")} ${randomCliColour(plugin.name)} ${hookName}`,
4830
4968
  output
4831
4969
  ].filter(Boolean);
4832
4970
  console.log(logs.join("\n"));
@@ -4898,7 +5036,7 @@ _context = new WeakMap();
4898
5036
  // src/PackageManager.ts
4899
5037
  init_cjs_shims();
4900
5038
 
4901
- // ../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js
5039
+ // ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
4902
5040
  init_cjs_shims();
4903
5041
 
4904
5042
  // ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
@@ -5106,17 +5244,22 @@ function locatePathSync(paths, {
5106
5244
  }
5107
5245
  }
5108
5246
 
5247
+ // ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
5248
+ init_cjs_shims();
5249
+ function toPath2(urlOrPath) {
5250
+ return urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
5251
+ }
5252
+
5109
5253
  // ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
5110
5254
  init_cjs_shims();
5111
5255
 
5112
- // ../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js
5113
- var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
5256
+ // ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
5114
5257
  var findUpStop = Symbol("findUpStop");
5115
5258
  async function findUpMultiple(name, options = {}) {
5116
- let directory = path4__default.default.resolve(toPath2(options.cwd) || "");
5259
+ let directory = path4__default.default.resolve(toPath2(options.cwd) ?? "");
5117
5260
  const { root } = path4__default.default.parse(directory);
5118
- const stopAt = path4__default.default.resolve(directory, options.stopAt || root);
5119
- const limit = options.limit || Number.POSITIVE_INFINITY;
5261
+ const stopAt = path4__default.default.resolve(directory, toPath2(options.stopAt ?? root));
5262
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
5120
5263
  const paths = [name].flat();
5121
5264
  const runMatcher = async (locateOptions) => {
5122
5265
  if (typeof name !== "function") {
@@ -5145,10 +5288,10 @@ async function findUpMultiple(name, options = {}) {
5145
5288
  return matches;
5146
5289
  }
5147
5290
  function findUpMultipleSync(name, options = {}) {
5148
- let directory = path4__default.default.resolve(toPath2(options.cwd) || "");
5291
+ let directory = path4__default.default.resolve(toPath2(options.cwd) ?? "");
5149
5292
  const { root } = path4__default.default.parse(directory);
5150
- const stopAt = options.stopAt || root;
5151
- const limit = options.limit || Number.POSITIVE_INFINITY;
5293
+ const stopAt = path4__default.default.resolve(directory, toPath2(options.stopAt) ?? root);
5294
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
5152
5295
  const paths = [name].flat();
5153
5296
  const runMatcher = (locateOptions) => {
5154
5297
  if (typeof name !== "function") {