@kubb/core 1.12.0 → 1.13.0-canary.20231018T144840
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 +431 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +82 -9
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var pc3 = require('picocolors');
|
|
6
6
|
var crypto = require('crypto');
|
|
7
|
-
var
|
|
7
|
+
var path2 = require('path');
|
|
8
8
|
var fs = require('fs-extra');
|
|
9
9
|
var jsRuntime = require('js-runtime');
|
|
10
10
|
var perf_hooks = require('perf_hooks');
|
|
@@ -18,20 +18,31 @@ var naturalOrderby = require('natural-orderby');
|
|
|
18
18
|
var parser = require('@kubb/parser');
|
|
19
19
|
var isEqual = require('lodash.isequal');
|
|
20
20
|
var events = require('events');
|
|
21
|
+
var process2 = require('process');
|
|
22
|
+
var fs3 = require('fs');
|
|
23
|
+
var semver = require('semver');
|
|
21
24
|
|
|
22
25
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
26
|
|
|
24
27
|
var pc3__default = /*#__PURE__*/_interopDefault(pc3);
|
|
25
28
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
26
|
-
var
|
|
29
|
+
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
27
30
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
28
31
|
var dirTree__default = /*#__PURE__*/_interopDefault(dirTree);
|
|
29
32
|
var mod__default = /*#__PURE__*/_interopDefault(mod);
|
|
30
33
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
31
34
|
var seedrandom__default = /*#__PURE__*/_interopDefault(seedrandom);
|
|
32
35
|
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
36
|
+
var process2__default = /*#__PURE__*/_interopDefault(process2);
|
|
37
|
+
var fs3__default = /*#__PURE__*/_interopDefault(fs3);
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
40
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
41
|
+
}) : x)(function(x) {
|
|
42
|
+
if (typeof require !== "undefined")
|
|
43
|
+
return require.apply(this, arguments);
|
|
44
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
45
|
+
});
|
|
35
46
|
|
|
36
47
|
// src/utils/isPromise.ts
|
|
37
48
|
function isPromise(result) {
|
|
@@ -43,37 +54,37 @@ function isPromiseFulfilledResult(result) {
|
|
|
43
54
|
function isPromiseRejectedResult(result) {
|
|
44
55
|
return result.status === "rejected";
|
|
45
56
|
}
|
|
46
|
-
async function saveCreateDirectory(
|
|
47
|
-
const passedPath =
|
|
57
|
+
async function saveCreateDirectory(path3) {
|
|
58
|
+
const passedPath = path2__default.default.dirname(path2__default.default.resolve(path3));
|
|
48
59
|
await fs__default.default.mkdir(passedPath, { recursive: true });
|
|
49
60
|
}
|
|
50
61
|
var writer = jsRuntime.switcher(
|
|
51
62
|
{
|
|
52
|
-
node: async (
|
|
63
|
+
node: async (path3, data) => {
|
|
53
64
|
try {
|
|
54
|
-
await fs__default.default.stat(
|
|
55
|
-
const oldContent = await fs__default.default.readFile(
|
|
65
|
+
await fs__default.default.stat(path3);
|
|
66
|
+
const oldContent = await fs__default.default.readFile(path3, { encoding: "utf-8" });
|
|
56
67
|
if (oldContent?.toString() === data) {
|
|
57
68
|
return;
|
|
58
69
|
}
|
|
59
70
|
} catch (_err) {
|
|
60
71
|
}
|
|
61
|
-
await saveCreateDirectory(
|
|
62
|
-
return fs__default.default.writeFile(
|
|
72
|
+
await saveCreateDirectory(path3);
|
|
73
|
+
return fs__default.default.writeFile(path2__default.default.resolve(path3), data, { encoding: "utf-8" });
|
|
63
74
|
},
|
|
64
|
-
bun: async (
|
|
75
|
+
bun: async (path3, data) => {
|
|
65
76
|
try {
|
|
66
|
-
await saveCreateDirectory(
|
|
67
|
-
await Bun.write(
|
|
77
|
+
await saveCreateDirectory(path3);
|
|
78
|
+
await Bun.write(path2__default.default.resolve(path3), data);
|
|
68
79
|
} catch (e) {
|
|
69
|
-
console.log(e,
|
|
80
|
+
console.log(e, path2__default.default.resolve(path3));
|
|
70
81
|
}
|
|
71
82
|
}
|
|
72
83
|
},
|
|
73
84
|
"node"
|
|
74
85
|
);
|
|
75
|
-
async function write(data,
|
|
76
|
-
return writer(
|
|
86
|
+
async function write(data, path3) {
|
|
87
|
+
return writer(path3, data);
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
// src/utils/cache.ts
|
|
@@ -103,37 +114,37 @@ function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
|
103
114
|
}
|
|
104
115
|
};
|
|
105
116
|
}
|
|
106
|
-
function slash(
|
|
107
|
-
const isWindowsPath = /^\\\\\?\\/.test(
|
|
117
|
+
function slash(path3, platform = "linux") {
|
|
118
|
+
const isWindowsPath = /^\\\\\?\\/.test(path3);
|
|
108
119
|
if (["linux", "mac"].includes(platform) && !isWindowsPath) {
|
|
109
|
-
return
|
|
120
|
+
return path3.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
110
121
|
}
|
|
111
|
-
return
|
|
122
|
+
return path3.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
112
123
|
}
|
|
113
124
|
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
114
125
|
if (!rootDir || !filePath) {
|
|
115
126
|
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
116
127
|
}
|
|
117
|
-
const relativePath =
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
return
|
|
128
|
+
const relativePath = path2__default.default.relative(rootDir, filePath);
|
|
129
|
+
const path3 = slash(relativePath, platform);
|
|
130
|
+
if (path3.startsWith("../")) {
|
|
131
|
+
return path3.replace(path2__default.default.basename(path3), path2__default.default.basename(path3, path2__default.default.extname(filePath)));
|
|
121
132
|
}
|
|
122
|
-
return `./${
|
|
133
|
+
return `./${path3.replace(path2__default.default.basename(path3), path2__default.default.basename(path3, path2__default.default.extname(filePath)))}`;
|
|
123
134
|
}
|
|
124
|
-
function getPathMode(
|
|
125
|
-
if (!
|
|
135
|
+
function getPathMode(path3) {
|
|
136
|
+
if (!path3) {
|
|
126
137
|
return "directory";
|
|
127
138
|
}
|
|
128
|
-
return
|
|
139
|
+
return path2__default.default.extname(path3) ? "file" : "directory";
|
|
129
140
|
}
|
|
130
141
|
var reader = jsRuntime.switcher(
|
|
131
142
|
{
|
|
132
|
-
node: async (
|
|
133
|
-
return fs__default.default.readFile(
|
|
143
|
+
node: async (path3) => {
|
|
144
|
+
return fs__default.default.readFile(path3, { encoding: "utf8" });
|
|
134
145
|
},
|
|
135
|
-
bun: async (
|
|
136
|
-
const file = Bun.file(
|
|
146
|
+
bun: async (path3) => {
|
|
147
|
+
const file = Bun.file(path3);
|
|
137
148
|
return file.text();
|
|
138
149
|
}
|
|
139
150
|
},
|
|
@@ -141,8 +152,8 @@ var reader = jsRuntime.switcher(
|
|
|
141
152
|
);
|
|
142
153
|
var syncReader = jsRuntime.switcher(
|
|
143
154
|
{
|
|
144
|
-
node: (
|
|
145
|
-
return fs__default.default.readFileSync(
|
|
155
|
+
node: (path3) => {
|
|
156
|
+
return fs__default.default.readFileSync(path3, { encoding: "utf8" });
|
|
146
157
|
},
|
|
147
158
|
bun: () => {
|
|
148
159
|
throw new Error("Bun cannot read sync");
|
|
@@ -150,11 +161,11 @@ var syncReader = jsRuntime.switcher(
|
|
|
150
161
|
},
|
|
151
162
|
"node"
|
|
152
163
|
);
|
|
153
|
-
async function read(
|
|
154
|
-
return reader(
|
|
164
|
+
async function read(path3) {
|
|
165
|
+
return reader(path3);
|
|
155
166
|
}
|
|
156
|
-
function readSync(
|
|
157
|
-
return syncReader(
|
|
167
|
+
function readSync(path3) {
|
|
168
|
+
return syncReader(path3);
|
|
158
169
|
}
|
|
159
170
|
|
|
160
171
|
// src/utils/nameSorter.ts
|
|
@@ -403,8 +414,8 @@ function renderTemplate(template, data = void 0) {
|
|
|
403
414
|
}).trim();
|
|
404
415
|
}, template) || "";
|
|
405
416
|
}
|
|
406
|
-
async function clean(
|
|
407
|
-
return fs.remove(
|
|
417
|
+
async function clean(path3) {
|
|
418
|
+
return fs.remove(path3);
|
|
408
419
|
}
|
|
409
420
|
var TreeNode = class _TreeNode {
|
|
410
421
|
data;
|
|
@@ -470,10 +481,10 @@ var TreeNode = class _TreeNode {
|
|
|
470
481
|
}
|
|
471
482
|
return this;
|
|
472
483
|
}
|
|
473
|
-
static build(
|
|
484
|
+
static build(path3, options = {}) {
|
|
474
485
|
try {
|
|
475
486
|
const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
|
|
476
|
-
const filteredTree = dirTree__default.default(
|
|
487
|
+
const filteredTree = dirTree__default.default(path3, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
|
|
477
488
|
if (!filteredTree) {
|
|
478
489
|
return null;
|
|
479
490
|
}
|
|
@@ -503,17 +514,17 @@ function normalizeDirectory(directory) {
|
|
|
503
514
|
}
|
|
504
515
|
return directory;
|
|
505
516
|
}
|
|
506
|
-
function getLocation(
|
|
507
|
-
let location =
|
|
517
|
+
function getLocation(path3, cwd) {
|
|
518
|
+
let location = path3;
|
|
508
519
|
if (cwd) {
|
|
509
520
|
const require2 = mod__default.default.createRequire(normalizeDirectory(cwd));
|
|
510
|
-
location = require2.resolve(
|
|
521
|
+
location = require2.resolve(path3);
|
|
511
522
|
}
|
|
512
523
|
return location;
|
|
513
524
|
}
|
|
514
|
-
async function importModule(
|
|
525
|
+
async function importModule(path3, cwd) {
|
|
515
526
|
try {
|
|
516
|
-
let location = getLocation(
|
|
527
|
+
let location = getLocation(path3, cwd);
|
|
517
528
|
if (os__default.default.platform() == "win32") {
|
|
518
529
|
location = url.pathToFileURL(location).href;
|
|
519
530
|
}
|
|
@@ -632,8 +643,8 @@ function randomPicoColour(text, colors = defaultColours) {
|
|
|
632
643
|
}
|
|
633
644
|
var URLPath = class _URLPath {
|
|
634
645
|
path;
|
|
635
|
-
constructor(
|
|
636
|
-
this.path =
|
|
646
|
+
constructor(path3) {
|
|
647
|
+
this.path = path3;
|
|
637
648
|
}
|
|
638
649
|
/**
|
|
639
650
|
* Convert Swagger path to URLPath(syntax of Express)
|
|
@@ -678,25 +689,25 @@ var URLPath = class _URLPath {
|
|
|
678
689
|
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
679
690
|
* @example /account/userID => `/account/${userId}`
|
|
680
691
|
*/
|
|
681
|
-
static toTemplateString(
|
|
692
|
+
static toTemplateString(path3, replacer) {
|
|
682
693
|
const regex = /{(\w|-)*}/g;
|
|
683
|
-
const found =
|
|
684
|
-
let newPath =
|
|
694
|
+
const found = path3.match(regex);
|
|
695
|
+
let newPath = path3.replaceAll("{", "${");
|
|
685
696
|
if (found) {
|
|
686
697
|
newPath = found.reduce((prev, curr) => {
|
|
687
698
|
const pathParam = replacer ? replacer(changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
688
699
|
const replacement = `\${${pathParam}}`;
|
|
689
700
|
return prev.replace(curr, replacement);
|
|
690
|
-
},
|
|
701
|
+
}, path3);
|
|
691
702
|
}
|
|
692
703
|
return `\`${newPath}\``;
|
|
693
704
|
}
|
|
694
705
|
getParams(replacer) {
|
|
695
706
|
return _URLPath.getParams(this.path, replacer);
|
|
696
707
|
}
|
|
697
|
-
static getParams(
|
|
708
|
+
static getParams(path3, replacer) {
|
|
698
709
|
const regex = /{(\w|-)*}/g;
|
|
699
|
-
const found =
|
|
710
|
+
const found = path3.match(regex);
|
|
700
711
|
if (!found) {
|
|
701
712
|
return void 0;
|
|
702
713
|
}
|
|
@@ -705,7 +716,7 @@ var URLPath = class _URLPath {
|
|
|
705
716
|
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
706
717
|
const pathParam = replacer ? replacer(changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
707
718
|
params[pathParam] = pathParam;
|
|
708
|
-
},
|
|
719
|
+
}, path3);
|
|
709
720
|
return params;
|
|
710
721
|
}
|
|
711
722
|
/**
|
|
@@ -715,13 +726,13 @@ var URLPath = class _URLPath {
|
|
|
715
726
|
toURLPath() {
|
|
716
727
|
return _URLPath.toURLPath(this.path);
|
|
717
728
|
}
|
|
718
|
-
static toURLPath(
|
|
719
|
-
return
|
|
729
|
+
static toURLPath(path3) {
|
|
730
|
+
return path3.replaceAll("{", ":").replaceAll("}", "");
|
|
720
731
|
}
|
|
721
|
-
static toObject(
|
|
732
|
+
static toObject(path3, { type = "path", replacer, stringify } = {}) {
|
|
722
733
|
const object = {
|
|
723
|
-
url: type === "path" ? _URLPath.toURLPath(
|
|
724
|
-
params: _URLPath.getParams(
|
|
734
|
+
url: type === "path" ? _URLPath.toURLPath(path3) : _URLPath.toTemplateString(path3, replacer),
|
|
735
|
+
params: _URLPath.getParams(path3)
|
|
725
736
|
};
|
|
726
737
|
if (stringify) {
|
|
727
738
|
if (type !== "template") {
|
|
@@ -731,9 +742,9 @@ var URLPath = class _URLPath {
|
|
|
731
742
|
}
|
|
732
743
|
return object;
|
|
733
744
|
}
|
|
734
|
-
static isURL(
|
|
745
|
+
static isURL(path3) {
|
|
735
746
|
try {
|
|
736
|
-
const url = new URL(
|
|
747
|
+
const url = new URL(path3);
|
|
737
748
|
if (url?.href) {
|
|
738
749
|
return true;
|
|
739
750
|
}
|
|
@@ -792,29 +803,29 @@ function getIndexes(root, options = {}) {
|
|
|
792
803
|
return [];
|
|
793
804
|
}
|
|
794
805
|
if (currentTree.children?.length > 1) {
|
|
795
|
-
const
|
|
806
|
+
const path3 = path2__default.default.resolve(currentTree.data.path, "index.ts");
|
|
796
807
|
const exports = currentTree.children.map((file) => {
|
|
797
808
|
if (!file) {
|
|
798
809
|
return void 0;
|
|
799
810
|
}
|
|
800
811
|
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
801
|
-
if (importPath.includes("index") &&
|
|
812
|
+
if (importPath.includes("index") && path3.includes("index")) {
|
|
802
813
|
return void 0;
|
|
803
814
|
}
|
|
804
815
|
return { path: importPath };
|
|
805
816
|
}).filter(Boolean);
|
|
806
817
|
files2.push({
|
|
807
|
-
path,
|
|
818
|
+
path: path3,
|
|
808
819
|
baseName: "index.ts",
|
|
809
820
|
source: "",
|
|
810
821
|
exports
|
|
811
822
|
});
|
|
812
823
|
} else {
|
|
813
824
|
currentTree.children?.forEach((child) => {
|
|
814
|
-
const
|
|
825
|
+
const path3 = path2__default.default.resolve(currentTree.data.path, "index.ts");
|
|
815
826
|
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
816
827
|
files2.push({
|
|
817
|
-
path,
|
|
828
|
+
path: path3,
|
|
818
829
|
baseName: "index.ts",
|
|
819
830
|
source: "",
|
|
820
831
|
exports: [{ path: importPath }]
|
|
@@ -1032,9 +1043,9 @@ ${file.source}` : "",
|
|
|
1032
1043
|
}
|
|
1033
1044
|
return this.add(file);
|
|
1034
1045
|
}
|
|
1035
|
-
append(
|
|
1036
|
-
const previousFiles = this.cache.get(
|
|
1037
|
-
this.cache.set(
|
|
1046
|
+
append(path3, file) {
|
|
1047
|
+
const previousFiles = this.cache.get(path3) || [];
|
|
1048
|
+
this.cache.set(path3, [...previousFiles, file]);
|
|
1038
1049
|
}
|
|
1039
1050
|
getCacheByUUID(UUID) {
|
|
1040
1051
|
let cache;
|
|
@@ -1043,15 +1054,15 @@ ${file.source}` : "",
|
|
|
1043
1054
|
});
|
|
1044
1055
|
return cache;
|
|
1045
1056
|
}
|
|
1046
|
-
get(
|
|
1047
|
-
return this.cache.get(
|
|
1057
|
+
get(path3) {
|
|
1058
|
+
return this.cache.get(path3);
|
|
1048
1059
|
}
|
|
1049
|
-
remove(
|
|
1050
|
-
const cacheItem = this.get(
|
|
1060
|
+
remove(path3) {
|
|
1061
|
+
const cacheItem = this.get(path3);
|
|
1051
1062
|
if (!cacheItem) {
|
|
1052
1063
|
return;
|
|
1053
1064
|
}
|
|
1054
|
-
this.cache.delete(
|
|
1065
|
+
this.cache.delete(path3);
|
|
1055
1066
|
}
|
|
1056
1067
|
async write(...params) {
|
|
1057
1068
|
if (this.queue) {
|
|
@@ -1117,8 +1128,8 @@ var definePlugin = createPlugin((options) => {
|
|
|
1117
1128
|
};
|
|
1118
1129
|
},
|
|
1119
1130
|
resolvePath(baseName) {
|
|
1120
|
-
const root =
|
|
1121
|
-
return
|
|
1131
|
+
const root = path2__default.default.resolve(this.config.root, this.config.output.path);
|
|
1132
|
+
return path2__default.default.resolve(root, baseName);
|
|
1122
1133
|
},
|
|
1123
1134
|
resolveName(name) {
|
|
1124
1135
|
return name;
|
|
@@ -1576,26 +1587,28 @@ async function transformReducer(_previousCode, result, _plugin) {
|
|
|
1576
1587
|
async function build(options) {
|
|
1577
1588
|
const { config, logLevel, logger = createLogger() } = options;
|
|
1578
1589
|
try {
|
|
1579
|
-
if (!URLPath.isURL(config.input.path)) {
|
|
1590
|
+
if ("path" in config.input && !URLPath.isURL(config.input.path)) {
|
|
1580
1591
|
await read(config.input.path);
|
|
1581
1592
|
}
|
|
1582
1593
|
} catch (e) {
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1594
|
+
if ("path" in config.input) {
|
|
1595
|
+
throw new Error(
|
|
1596
|
+
"Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config " + pc3__default.default.dim(config.input.path),
|
|
1597
|
+
{
|
|
1598
|
+
cause: e
|
|
1599
|
+
}
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1589
1602
|
}
|
|
1590
1603
|
if (config.output.clean) {
|
|
1591
1604
|
await clean(config.output.path);
|
|
1592
1605
|
}
|
|
1593
1606
|
const queueTask = async (file) => {
|
|
1594
|
-
const { path } = file;
|
|
1607
|
+
const { path: path3 } = file;
|
|
1595
1608
|
let code = createFileSource(file);
|
|
1596
1609
|
const { result: loadedResult } = await pluginManager.hookFirst({
|
|
1597
1610
|
hookName: "load",
|
|
1598
|
-
parameters: [
|
|
1611
|
+
parameters: [path3]
|
|
1599
1612
|
});
|
|
1600
1613
|
if (loadedResult && isPromise(loadedResult)) {
|
|
1601
1614
|
code = await loadedResult;
|
|
@@ -1606,13 +1619,13 @@ async function build(options) {
|
|
|
1606
1619
|
if (code) {
|
|
1607
1620
|
const transformedCode = await pluginManager.hookReduceArg0({
|
|
1608
1621
|
hookName: "transform",
|
|
1609
|
-
parameters: [code,
|
|
1622
|
+
parameters: [code, path3],
|
|
1610
1623
|
reduce: transformReducer
|
|
1611
1624
|
});
|
|
1612
1625
|
if (config.output.write || config.output.write === void 0) {
|
|
1613
1626
|
await pluginManager.hookParallel({
|
|
1614
1627
|
hookName: "writeFile",
|
|
1615
|
-
parameters: [transformedCode,
|
|
1628
|
+
parameters: [transformedCode, path3]
|
|
1616
1629
|
});
|
|
1617
1630
|
}
|
|
1618
1631
|
}
|
|
@@ -1655,6 +1668,334 @@ function defineConfig(options) {
|
|
|
1655
1668
|
return options;
|
|
1656
1669
|
}
|
|
1657
1670
|
|
|
1671
|
+
// ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
|
1672
|
+
var Node = class {
|
|
1673
|
+
value;
|
|
1674
|
+
next;
|
|
1675
|
+
constructor(value) {
|
|
1676
|
+
this.value = value;
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
var Queue2 = class {
|
|
1680
|
+
#head;
|
|
1681
|
+
#tail;
|
|
1682
|
+
#size;
|
|
1683
|
+
constructor() {
|
|
1684
|
+
this.clear();
|
|
1685
|
+
}
|
|
1686
|
+
enqueue(value) {
|
|
1687
|
+
const node = new Node(value);
|
|
1688
|
+
if (this.#head) {
|
|
1689
|
+
this.#tail.next = node;
|
|
1690
|
+
this.#tail = node;
|
|
1691
|
+
} else {
|
|
1692
|
+
this.#head = node;
|
|
1693
|
+
this.#tail = node;
|
|
1694
|
+
}
|
|
1695
|
+
this.#size++;
|
|
1696
|
+
}
|
|
1697
|
+
dequeue() {
|
|
1698
|
+
const current = this.#head;
|
|
1699
|
+
if (!current) {
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
this.#head = this.#head.next;
|
|
1703
|
+
this.#size--;
|
|
1704
|
+
return current.value;
|
|
1705
|
+
}
|
|
1706
|
+
clear() {
|
|
1707
|
+
this.#head = void 0;
|
|
1708
|
+
this.#tail = void 0;
|
|
1709
|
+
this.#size = 0;
|
|
1710
|
+
}
|
|
1711
|
+
get size() {
|
|
1712
|
+
return this.#size;
|
|
1713
|
+
}
|
|
1714
|
+
*[Symbol.iterator]() {
|
|
1715
|
+
let current = this.#head;
|
|
1716
|
+
while (current) {
|
|
1717
|
+
yield current.value;
|
|
1718
|
+
current = current.next;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
// ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
1724
|
+
function pLimit(concurrency) {
|
|
1725
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
1726
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
1727
|
+
}
|
|
1728
|
+
const queue = new Queue2();
|
|
1729
|
+
let activeCount = 0;
|
|
1730
|
+
const next = () => {
|
|
1731
|
+
activeCount--;
|
|
1732
|
+
if (queue.size > 0) {
|
|
1733
|
+
queue.dequeue()();
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
const run = async (fn, resolve, args) => {
|
|
1737
|
+
activeCount++;
|
|
1738
|
+
const result = (async () => fn(...args))();
|
|
1739
|
+
resolve(result);
|
|
1740
|
+
try {
|
|
1741
|
+
await result;
|
|
1742
|
+
} catch {
|
|
1743
|
+
}
|
|
1744
|
+
next();
|
|
1745
|
+
};
|
|
1746
|
+
const enqueue = (fn, resolve, args) => {
|
|
1747
|
+
queue.enqueue(run.bind(void 0, fn, resolve, args));
|
|
1748
|
+
(async () => {
|
|
1749
|
+
await Promise.resolve();
|
|
1750
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
1751
|
+
queue.dequeue()();
|
|
1752
|
+
}
|
|
1753
|
+
})();
|
|
1754
|
+
};
|
|
1755
|
+
const generator = (fn, ...args) => new Promise((resolve) => {
|
|
1756
|
+
enqueue(fn, resolve, args);
|
|
1757
|
+
});
|
|
1758
|
+
Object.defineProperties(generator, {
|
|
1759
|
+
activeCount: {
|
|
1760
|
+
get: () => activeCount
|
|
1761
|
+
},
|
|
1762
|
+
pendingCount: {
|
|
1763
|
+
get: () => queue.size
|
|
1764
|
+
},
|
|
1765
|
+
clearQueue: {
|
|
1766
|
+
value: () => {
|
|
1767
|
+
queue.clear();
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
return generator;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
|
1775
|
+
var EndError = class extends Error {
|
|
1776
|
+
constructor(value) {
|
|
1777
|
+
super();
|
|
1778
|
+
this.value = value;
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1781
|
+
var testElement = async (element, tester) => tester(await element);
|
|
1782
|
+
var finder = async (element) => {
|
|
1783
|
+
const values = await Promise.all(element);
|
|
1784
|
+
if (values[1] === true) {
|
|
1785
|
+
throw new EndError(values[0]);
|
|
1786
|
+
}
|
|
1787
|
+
return false;
|
|
1788
|
+
};
|
|
1789
|
+
async function pLocate(iterable, tester, {
|
|
1790
|
+
concurrency = Number.POSITIVE_INFINITY,
|
|
1791
|
+
preserveOrder = true
|
|
1792
|
+
} = {}) {
|
|
1793
|
+
const limit = pLimit(concurrency);
|
|
1794
|
+
const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
|
|
1795
|
+
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
|
1796
|
+
try {
|
|
1797
|
+
await Promise.all(items.map((element) => checkLimit(finder, element)));
|
|
1798
|
+
} catch (error) {
|
|
1799
|
+
if (error instanceof EndError) {
|
|
1800
|
+
return error.value;
|
|
1801
|
+
}
|
|
1802
|
+
throw error;
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
// ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
|
|
1807
|
+
var typeMappings = {
|
|
1808
|
+
directory: "isDirectory",
|
|
1809
|
+
file: "isFile"
|
|
1810
|
+
};
|
|
1811
|
+
function checkType(type) {
|
|
1812
|
+
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
throw new Error(`Invalid type specified: ${type}`);
|
|
1816
|
+
}
|
|
1817
|
+
var matchType = (type, stat) => stat[typeMappings[type]]();
|
|
1818
|
+
var toPath = (urlOrPath) => urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
|
|
1819
|
+
async function locatePath(paths, {
|
|
1820
|
+
cwd = process2__default.default.cwd(),
|
|
1821
|
+
type = "file",
|
|
1822
|
+
allowSymlinks = true,
|
|
1823
|
+
concurrency,
|
|
1824
|
+
preserveOrder
|
|
1825
|
+
} = {}) {
|
|
1826
|
+
checkType(type);
|
|
1827
|
+
cwd = toPath(cwd);
|
|
1828
|
+
const statFunction = allowSymlinks ? fs3.promises.stat : fs3.promises.lstat;
|
|
1829
|
+
return pLocate(paths, async (path_) => {
|
|
1830
|
+
try {
|
|
1831
|
+
const stat = await statFunction(path2__default.default.resolve(cwd, path_));
|
|
1832
|
+
return matchType(type, stat);
|
|
1833
|
+
} catch {
|
|
1834
|
+
return false;
|
|
1835
|
+
}
|
|
1836
|
+
}, { concurrency, preserveOrder });
|
|
1837
|
+
}
|
|
1838
|
+
function locatePathSync(paths, {
|
|
1839
|
+
cwd = process2__default.default.cwd(),
|
|
1840
|
+
type = "file",
|
|
1841
|
+
allowSymlinks = true
|
|
1842
|
+
} = {}) {
|
|
1843
|
+
checkType(type);
|
|
1844
|
+
cwd = toPath(cwd);
|
|
1845
|
+
const statFunction = allowSymlinks ? fs3__default.default.statSync : fs3__default.default.lstatSync;
|
|
1846
|
+
for (const path_ of paths) {
|
|
1847
|
+
try {
|
|
1848
|
+
const stat = statFunction(path2__default.default.resolve(cwd, path_), {
|
|
1849
|
+
throwIfNoEntry: false
|
|
1850
|
+
});
|
|
1851
|
+
if (!stat) {
|
|
1852
|
+
continue;
|
|
1853
|
+
}
|
|
1854
|
+
if (matchType(type, stat)) {
|
|
1855
|
+
return path_;
|
|
1856
|
+
}
|
|
1857
|
+
} catch {
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
// ../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js
|
|
1863
|
+
var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
|
|
1864
|
+
var findUpStop = Symbol("findUpStop");
|
|
1865
|
+
async function findUpMultiple(name, options = {}) {
|
|
1866
|
+
let directory = path2__default.default.resolve(toPath2(options.cwd) || "");
|
|
1867
|
+
const { root } = path2__default.default.parse(directory);
|
|
1868
|
+
const stopAt = path2__default.default.resolve(directory, options.stopAt || root);
|
|
1869
|
+
const limit = options.limit || Number.POSITIVE_INFINITY;
|
|
1870
|
+
const paths = [name].flat();
|
|
1871
|
+
const runMatcher = async (locateOptions) => {
|
|
1872
|
+
if (typeof name !== "function") {
|
|
1873
|
+
return locatePath(paths, locateOptions);
|
|
1874
|
+
}
|
|
1875
|
+
const foundPath = await name(locateOptions.cwd);
|
|
1876
|
+
if (typeof foundPath === "string") {
|
|
1877
|
+
return locatePath([foundPath], locateOptions);
|
|
1878
|
+
}
|
|
1879
|
+
return foundPath;
|
|
1880
|
+
};
|
|
1881
|
+
const matches = [];
|
|
1882
|
+
while (true) {
|
|
1883
|
+
const foundPath = await runMatcher({ ...options, cwd: directory });
|
|
1884
|
+
if (foundPath === findUpStop) {
|
|
1885
|
+
break;
|
|
1886
|
+
}
|
|
1887
|
+
if (foundPath) {
|
|
1888
|
+
matches.push(path2__default.default.resolve(directory, foundPath));
|
|
1889
|
+
}
|
|
1890
|
+
if (directory === stopAt || matches.length >= limit) {
|
|
1891
|
+
break;
|
|
1892
|
+
}
|
|
1893
|
+
directory = path2__default.default.dirname(directory);
|
|
1894
|
+
}
|
|
1895
|
+
return matches;
|
|
1896
|
+
}
|
|
1897
|
+
function findUpMultipleSync(name, options = {}) {
|
|
1898
|
+
let directory = path2__default.default.resolve(toPath2(options.cwd) || "");
|
|
1899
|
+
const { root } = path2__default.default.parse(directory);
|
|
1900
|
+
const stopAt = options.stopAt || root;
|
|
1901
|
+
const limit = options.limit || Number.POSITIVE_INFINITY;
|
|
1902
|
+
const paths = [name].flat();
|
|
1903
|
+
const runMatcher = (locateOptions) => {
|
|
1904
|
+
if (typeof name !== "function") {
|
|
1905
|
+
return locatePathSync(paths, locateOptions);
|
|
1906
|
+
}
|
|
1907
|
+
const foundPath = name(locateOptions.cwd);
|
|
1908
|
+
if (typeof foundPath === "string") {
|
|
1909
|
+
return locatePathSync([foundPath], locateOptions);
|
|
1910
|
+
}
|
|
1911
|
+
return foundPath;
|
|
1912
|
+
};
|
|
1913
|
+
const matches = [];
|
|
1914
|
+
while (true) {
|
|
1915
|
+
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
1916
|
+
if (foundPath === findUpStop) {
|
|
1917
|
+
break;
|
|
1918
|
+
}
|
|
1919
|
+
if (foundPath) {
|
|
1920
|
+
matches.push(path2__default.default.resolve(directory, foundPath));
|
|
1921
|
+
}
|
|
1922
|
+
if (directory === stopAt || matches.length >= limit) {
|
|
1923
|
+
break;
|
|
1924
|
+
}
|
|
1925
|
+
directory = path2__default.default.dirname(directory);
|
|
1926
|
+
}
|
|
1927
|
+
return matches;
|
|
1928
|
+
}
|
|
1929
|
+
async function findUp(name, options = {}) {
|
|
1930
|
+
const matches = await findUpMultiple(name, { ...options, limit: 1 });
|
|
1931
|
+
return matches[0];
|
|
1932
|
+
}
|
|
1933
|
+
function findUpSync(name, options = {}) {
|
|
1934
|
+
const matches = findUpMultipleSync(name, { ...options, limit: 1 });
|
|
1935
|
+
return matches[0];
|
|
1936
|
+
}
|
|
1937
|
+
var PackageManager = class {
|
|
1938
|
+
cwd;
|
|
1939
|
+
constructor(workspace = process.cwd()) {
|
|
1940
|
+
this.cwd = workspace;
|
|
1941
|
+
return this;
|
|
1942
|
+
}
|
|
1943
|
+
async getPackageJSON() {
|
|
1944
|
+
const pkgPath = await findUp(["package.json"], {
|
|
1945
|
+
cwd: this.cwd
|
|
1946
|
+
});
|
|
1947
|
+
if (!pkgPath) {
|
|
1948
|
+
return void 0;
|
|
1949
|
+
}
|
|
1950
|
+
return __require(pkgPath);
|
|
1951
|
+
}
|
|
1952
|
+
getPackageJSONSync() {
|
|
1953
|
+
const pkgPath = findUpSync(["package.json"], {
|
|
1954
|
+
cwd: this.cwd
|
|
1955
|
+
});
|
|
1956
|
+
if (!pkgPath) {
|
|
1957
|
+
return void 0;
|
|
1958
|
+
}
|
|
1959
|
+
return __require(pkgPath);
|
|
1960
|
+
}
|
|
1961
|
+
async getVersion(dependency) {
|
|
1962
|
+
const packageJSON = await this.getPackageJSON();
|
|
1963
|
+
if (!packageJSON) {
|
|
1964
|
+
return void 0;
|
|
1965
|
+
}
|
|
1966
|
+
return packageJSON["dependencies"]?.[dependency] || packageJSON["devDependencies"]?.[dependency];
|
|
1967
|
+
}
|
|
1968
|
+
getVersionSync(dependency) {
|
|
1969
|
+
const packageJSON = this.getPackageJSONSync();
|
|
1970
|
+
if (!packageJSON) {
|
|
1971
|
+
return void 0;
|
|
1972
|
+
}
|
|
1973
|
+
return packageJSON["dependencies"]?.[dependency] || packageJSON["devDependencies"]?.[dependency];
|
|
1974
|
+
}
|
|
1975
|
+
async isValid(dependency, version) {
|
|
1976
|
+
const packageVersion = await this.getVersion(dependency);
|
|
1977
|
+
if (!packageVersion) {
|
|
1978
|
+
return false;
|
|
1979
|
+
}
|
|
1980
|
+
const semVer = semver.coerce(packageVersion);
|
|
1981
|
+
if (!semVer) {
|
|
1982
|
+
throw new Error(`${packageVersion} is not valid`);
|
|
1983
|
+
}
|
|
1984
|
+
return semver.satisfies(semVer, version);
|
|
1985
|
+
}
|
|
1986
|
+
isValidSync(dependency, version) {
|
|
1987
|
+
const packageVersion = this.getVersionSync(dependency);
|
|
1988
|
+
if (!packageVersion) {
|
|
1989
|
+
return false;
|
|
1990
|
+
}
|
|
1991
|
+
const semVer = semver.coerce(packageVersion);
|
|
1992
|
+
if (!semVer) {
|
|
1993
|
+
throw new Error(`${packageVersion} is not valid`);
|
|
1994
|
+
}
|
|
1995
|
+
return semver.satisfies(semVer, version);
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1658
1999
|
// src/generators/Generator.ts
|
|
1659
2000
|
var Generator = class {
|
|
1660
2001
|
_options = {};
|
|
@@ -1687,6 +2028,7 @@ exports.FileManager = FileManager;
|
|
|
1687
2028
|
exports.FunctionParams = FunctionParams;
|
|
1688
2029
|
exports.Generator = Generator;
|
|
1689
2030
|
exports.LogLevel = LogLevel;
|
|
2031
|
+
exports.PackageManager = PackageManager;
|
|
1690
2032
|
exports.ParallelPluginError = ParallelPluginError;
|
|
1691
2033
|
exports.PluginError = PluginError;
|
|
1692
2034
|
exports.PluginManager = PluginManager;
|