@kubb/core 3.0.0-alpha.10 → 3.0.0-alpha.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/{FileManager-CpuFz6eH.d.ts → FileManager-B-fP5y5O.d.ts} +5 -10
- package/dist/{FileManager-BbUCeEyv.d.cts → FileManager-CL52wQgR.d.cts} +5 -10
- package/dist/chunk-2EU7DMPM.js +2 -3
- package/dist/chunk-2EU7DMPM.js.map +1 -1
- package/dist/chunk-4X5FFJPJ.js +8 -13
- package/dist/chunk-4X5FFJPJ.js.map +1 -1
- package/dist/{chunk-SEH6NUCX.cjs → chunk-ADFKVVPE.cjs} +10 -10
- package/dist/chunk-ADFKVVPE.cjs.map +1 -0
- package/dist/{chunk-MU3CBCQT.js → chunk-E6CN2CZC.js} +12 -27
- package/dist/chunk-E6CN2CZC.js.map +1 -0
- package/dist/chunk-HBQM723K.js +12 -26
- package/dist/chunk-HBQM723K.js.map +1 -1
- package/dist/{chunk-A6PCLWEY.cjs → chunk-JRU2D5E6.cjs} +28 -29
- package/dist/chunk-JRU2D5E6.cjs.map +1 -0
- package/dist/{chunk-NB4JMN75.cjs → chunk-OJRKV365.cjs} +156 -173
- package/dist/chunk-OJRKV365.cjs.map +1 -0
- package/dist/{chunk-5E2I6KH4.cjs → chunk-PJLUPV3P.cjs} +54 -37
- package/dist/chunk-PJLUPV3P.cjs.map +1 -0
- package/dist/{chunk-DID47EQD.cjs → chunk-TTDCUWK7.cjs} +6 -7
- package/dist/chunk-TTDCUWK7.cjs.map +1 -0
- package/dist/{chunk-L6YLVCKM.js → chunk-WDYNXEYV.js} +45 -88
- package/dist/chunk-WDYNXEYV.js.map +1 -0
- package/dist/{chunk-M7NLNCSM.cjs → chunk-YEVCYV36.cjs} +33 -36
- package/dist/chunk-YEVCYV36.cjs.map +1 -0
- package/dist/index.cjs +157 -186
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -87
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +25 -14
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.js +3 -13
- package/dist/logger.js.map +1 -1
- package/dist/mocks.cjs +13 -18
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +5 -12
- package/dist/mocks.js.map +1 -1
- package/dist/{prompt-DVQN7JTN.cjs → prompt-L5KFKY73.cjs} +89 -89
- package/dist/prompt-L5KFKY73.cjs.map +1 -0
- package/dist/prompt-WQQUN22Z.js +8 -13
- package/dist/prompt-WQQUN22Z.js.map +1 -1
- package/dist/transformers.cjs +62 -52
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.js +9 -37
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +65 -34
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +3 -33
- package/dist/utils.js.map +1 -1
- package/package.json +7 -7
- package/src/BarrelManager.ts +1 -1
- package/src/FileManager.ts +29 -39
- package/src/PluginManager.ts +7 -8
- package/src/build.ts +1 -1
- package/src/index.ts +1 -1
- package/src/logger.ts +3 -3
- package/src/plugin.ts +0 -3
- package/src/types.ts +0 -2
- package/src/utils/parser.ts +3 -3
- package/dist/chunk-5E2I6KH4.cjs.map +0 -1
- package/dist/chunk-A6PCLWEY.cjs.map +0 -1
- package/dist/chunk-DID47EQD.cjs.map +0 -1
- package/dist/chunk-L6YLVCKM.js.map +0 -1
- package/dist/chunk-M7NLNCSM.cjs.map +0 -1
- package/dist/chunk-MU3CBCQT.js.map +0 -1
- package/dist/chunk-NB4JMN75.cjs.map +0 -1
- package/dist/chunk-SEH6NUCX.cjs.map +0 -1
- package/dist/prompt-DVQN7JTN.cjs.map +0 -1
- package/src/utils/cache.ts +0 -35
package/dist/index.cjs
CHANGED
|
@@ -1,37 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var chunkTTDCUWK7_cjs = require('./chunk-TTDCUWK7.cjs');
|
|
6
|
+
var chunkYEVCYV36_cjs = require('./chunk-YEVCYV36.cjs');
|
|
7
|
+
var chunkOJRKV365_cjs = require('./chunk-OJRKV365.cjs');
|
|
8
|
+
require('./chunk-JRU2D5E6.cjs');
|
|
9
|
+
require('./chunk-PJLUPV3P.cjs');
|
|
10
|
+
var chunkADFKVVPE_cjs = require('./chunk-ADFKVVPE.cjs');
|
|
11
|
+
var fs = require('@kubb/fs');
|
|
12
|
+
var path3 = require('path');
|
|
13
|
+
var mod = require('module');
|
|
14
|
+
var os = require('os');
|
|
15
|
+
var url = require('url');
|
|
16
|
+
var process = require('process');
|
|
17
|
+
var fs$1 = require('fs');
|
|
18
|
+
var semver = require('semver');
|
|
5
19
|
|
|
20
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
21
|
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _chunkNB4JMN75cjs = require('./chunk-NB4JMN75.cjs');
|
|
14
|
-
require('./chunk-A6PCLWEY.cjs');
|
|
15
|
-
require('./chunk-5E2I6KH4.cjs');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
|
|
22
|
+
var path3__default = /*#__PURE__*/_interopDefault(path3);
|
|
23
|
+
var mod__default = /*#__PURE__*/_interopDefault(mod);
|
|
24
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
25
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
26
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs$1);
|
|
19
27
|
|
|
20
28
|
// src/index.ts
|
|
21
|
-
|
|
29
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
22
30
|
|
|
23
31
|
// src/build.ts
|
|
24
|
-
|
|
25
|
-
var _fs = require('@kubb/fs');
|
|
32
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
26
33
|
|
|
27
34
|
// src/PluginManager.ts
|
|
28
|
-
|
|
35
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
29
36
|
|
|
30
37
|
// src/PromiseManager.ts
|
|
31
|
-
|
|
38
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
32
39
|
|
|
33
40
|
// src/utils/executeStrategies.ts
|
|
34
|
-
|
|
41
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
35
42
|
function hookSeq(promises) {
|
|
36
43
|
return promises.filter(Boolean).reduce(
|
|
37
44
|
(promise, func) => {
|
|
@@ -86,51 +93,19 @@ var PromiseManager = class {
|
|
|
86
93
|
}
|
|
87
94
|
};
|
|
88
95
|
function isPromise(result) {
|
|
89
|
-
return !!result && typeof
|
|
96
|
+
return !!result && typeof result?.then === "function";
|
|
90
97
|
}
|
|
91
98
|
function isPromiseRejectedResult(result) {
|
|
92
99
|
return result.status === "rejected";
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
// src/errors.ts
|
|
96
|
-
|
|
103
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
97
104
|
var ValidationPluginError = class extends Error {
|
|
98
105
|
};
|
|
99
106
|
|
|
100
107
|
// src/plugin.ts
|
|
101
|
-
|
|
102
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
103
|
-
|
|
104
|
-
// src/utils/cache.ts
|
|
105
|
-
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
106
|
-
function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
107
|
-
return {
|
|
108
|
-
set(id, value) {
|
|
109
|
-
Store[id] = [0, value];
|
|
110
|
-
},
|
|
111
|
-
get(id) {
|
|
112
|
-
const item = Store[id];
|
|
113
|
-
if (!item) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
item[0] = 0;
|
|
117
|
-
return item[1];
|
|
118
|
-
},
|
|
119
|
-
has(id) {
|
|
120
|
-
const item = Store[id];
|
|
121
|
-
if (!item) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
item[0] = 0;
|
|
125
|
-
return true;
|
|
126
|
-
},
|
|
127
|
-
delete(id) {
|
|
128
|
-
return delete Store[id];
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/plugin.ts
|
|
108
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
134
109
|
function createPlugin(factory) {
|
|
135
110
|
return (options = {}) => {
|
|
136
111
|
return factory(options);
|
|
@@ -164,13 +139,12 @@ var pluginCore = createPlugin((options) => {
|
|
|
164
139
|
return resolvedFiles;
|
|
165
140
|
},
|
|
166
141
|
resolvePath,
|
|
167
|
-
resolveName
|
|
168
|
-
cache: createPluginCache()
|
|
142
|
+
resolveName
|
|
169
143
|
};
|
|
170
144
|
},
|
|
171
145
|
resolvePath(baseName) {
|
|
172
|
-
const root =
|
|
173
|
-
return
|
|
146
|
+
const root = path3__default.default.resolve(options.config.root, options.config.output.path);
|
|
147
|
+
return path3__default.default.resolve(root, baseName);
|
|
174
148
|
},
|
|
175
149
|
resolveName(name) {
|
|
176
150
|
return name;
|
|
@@ -179,26 +153,25 @@ var pluginCore = createPlugin((options) => {
|
|
|
179
153
|
});
|
|
180
154
|
|
|
181
155
|
// src/PluginManager.ts
|
|
182
|
-
var PluginManager =
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
156
|
+
var PluginManager = class {
|
|
157
|
+
plugins = /* @__PURE__ */ new Set();
|
|
158
|
+
fileManager;
|
|
159
|
+
events = new chunkYEVCYV36_cjs.EventEmitter();
|
|
160
|
+
config;
|
|
161
|
+
executed = [];
|
|
162
|
+
logger;
|
|
163
|
+
options;
|
|
190
164
|
#core;
|
|
191
165
|
#usedPluginNames = {};
|
|
192
166
|
#promiseManager;
|
|
193
|
-
constructor(config, options) {
|
|
167
|
+
constructor(config, options) {
|
|
194
168
|
this.config = config;
|
|
195
169
|
this.options = options;
|
|
196
170
|
this.logger = options.logger;
|
|
197
|
-
this.fileManager = new
|
|
171
|
+
this.fileManager = new chunkOJRKV365_cjs.FileManager();
|
|
198
172
|
this.#promiseManager = new PromiseManager({
|
|
199
|
-
nullCheck: (state) => !!
|
|
173
|
+
nullCheck: (state) => !!state?.result
|
|
200
174
|
});
|
|
201
|
-
const plugins = config.plugins || [];
|
|
202
175
|
const core = pluginCore({
|
|
203
176
|
config,
|
|
204
177
|
logger: this.logger,
|
|
@@ -209,8 +182,9 @@ var PluginManager = (_class = class {
|
|
|
209
182
|
getPlugins: this.#getSortedPlugins.bind(this)
|
|
210
183
|
});
|
|
211
184
|
this.#core = this.#parse(core, this, core.context.call(null));
|
|
212
|
-
|
|
213
|
-
|
|
185
|
+
[this.#core, ...config.plugins || []].forEach((plugin) => {
|
|
186
|
+
const parsedPlugin = this.#parse(plugin, this, this.#core.context);
|
|
187
|
+
this.plugins.add(parsedPlugin);
|
|
214
188
|
});
|
|
215
189
|
return this;
|
|
216
190
|
}
|
|
@@ -229,7 +203,7 @@ var PluginManager = (_class = class {
|
|
|
229
203
|
sources: []
|
|
230
204
|
};
|
|
231
205
|
}
|
|
232
|
-
|
|
206
|
+
resolvePath = (params) => {
|
|
233
207
|
if (params.pluginKey) {
|
|
234
208
|
const paths = this.hookForPluginSync({
|
|
235
209
|
pluginKey: params.pluginKey,
|
|
@@ -237,7 +211,7 @@ var PluginManager = (_class = class {
|
|
|
237
211
|
parameters: [params.baseName, params.mode, params.options],
|
|
238
212
|
message: `Resolving path '${params.baseName}'`
|
|
239
213
|
});
|
|
240
|
-
if (paths &&
|
|
214
|
+
if (paths && paths?.length > 1) {
|
|
241
215
|
this.logger.emit("debug", {
|
|
242
216
|
date: /* @__PURE__ */ new Date(),
|
|
243
217
|
logs: [
|
|
@@ -250,16 +224,16 @@ Falling back on the first item.
|
|
|
250
224
|
]
|
|
251
225
|
});
|
|
252
226
|
}
|
|
253
|
-
return
|
|
227
|
+
return paths?.at(0);
|
|
254
228
|
}
|
|
255
229
|
return this.hookFirstSync({
|
|
256
230
|
hookName: "resolvePath",
|
|
257
231
|
parameters: [params.baseName, params.mode, params.options],
|
|
258
232
|
message: `Resolving path '${params.baseName}'`
|
|
259
233
|
}).result;
|
|
260
|
-
}
|
|
234
|
+
};
|
|
261
235
|
//TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path
|
|
262
|
-
|
|
236
|
+
resolveName = (params) => {
|
|
263
237
|
if (params.pluginKey) {
|
|
264
238
|
const names = this.hookForPluginSync({
|
|
265
239
|
pluginKey: params.pluginKey,
|
|
@@ -267,7 +241,7 @@ Falling back on the first item.
|
|
|
267
241
|
parameters: [params.name, params.type],
|
|
268
242
|
message: `Resolving name '${params.name}' and type '${params.type}'`
|
|
269
243
|
});
|
|
270
|
-
if (names &&
|
|
244
|
+
if (names && names?.length > 1) {
|
|
271
245
|
this.logger.emit("debug", {
|
|
272
246
|
date: /* @__PURE__ */ new Date(),
|
|
273
247
|
logs: [
|
|
@@ -280,15 +254,15 @@ Falling back on the first item.
|
|
|
280
254
|
]
|
|
281
255
|
});
|
|
282
256
|
}
|
|
283
|
-
return
|
|
257
|
+
return chunkTTDCUWK7_cjs.transformReservedWord(names?.at(0) || params.name);
|
|
284
258
|
}
|
|
285
259
|
const name = this.hookFirstSync({
|
|
286
260
|
hookName: "resolveName",
|
|
287
261
|
parameters: [params.name, params.type],
|
|
288
262
|
message: `Resolving name '${params.name}' and type '${params.type}'`
|
|
289
263
|
}).result;
|
|
290
|
-
return
|
|
291
|
-
}
|
|
264
|
+
return chunkTTDCUWK7_cjs.transformReservedWord(name);
|
|
265
|
+
};
|
|
292
266
|
/**
|
|
293
267
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
294
268
|
*/
|
|
@@ -396,7 +370,7 @@ Falling back on the first item.
|
|
|
396
370
|
}),
|
|
397
371
|
plugin
|
|
398
372
|
};
|
|
399
|
-
if (
|
|
373
|
+
if (parseResult?.result != null) {
|
|
400
374
|
break;
|
|
401
375
|
}
|
|
402
376
|
}
|
|
@@ -482,7 +456,7 @@ Falling back on the first item.
|
|
|
482
456
|
#getSortedPlugins(hookName) {
|
|
483
457
|
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
484
458
|
if (hookName) {
|
|
485
|
-
return plugins.filter((
|
|
459
|
+
return plugins.filter((plugin) => hookName in plugin);
|
|
486
460
|
}
|
|
487
461
|
return plugins.map((plugin) => {
|
|
488
462
|
if (plugin.pre) {
|
|
@@ -493,10 +467,10 @@ Falling back on the first item.
|
|
|
493
467
|
}
|
|
494
468
|
return plugin;
|
|
495
469
|
}).sort((a, b) => {
|
|
496
|
-
if (
|
|
470
|
+
if (b.pre?.includes(a.name)) {
|
|
497
471
|
return 1;
|
|
498
472
|
}
|
|
499
|
-
if (
|
|
473
|
+
if (b.post?.includes(a.name)) {
|
|
500
474
|
return -1;
|
|
501
475
|
}
|
|
502
476
|
return 0;
|
|
@@ -505,17 +479,17 @@ Falling back on the first item.
|
|
|
505
479
|
getPluginsByKey(hookName, pluginKey) {
|
|
506
480
|
const plugins = [...this.plugins];
|
|
507
481
|
const [searchPluginName, searchIdentifier] = pluginKey;
|
|
508
|
-
const pluginByPluginName = plugins.filter((plugin) => plugin
|
|
482
|
+
const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => {
|
|
509
483
|
const [name, identifier] = item.key;
|
|
510
|
-
const identifierCheck =
|
|
484
|
+
const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
|
|
511
485
|
const nameCheck = name === searchPluginName;
|
|
512
486
|
if (searchIdentifier) {
|
|
513
487
|
return identifierCheck && nameCheck;
|
|
514
488
|
}
|
|
515
489
|
return nameCheck;
|
|
516
490
|
});
|
|
517
|
-
if (!
|
|
518
|
-
const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin
|
|
491
|
+
if (!pluginByPluginName?.length) {
|
|
492
|
+
const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
|
|
519
493
|
if (corePlugin) {
|
|
520
494
|
this.logger.emit("debug", {
|
|
521
495
|
date: /* @__PURE__ */ new Date(),
|
|
@@ -637,13 +611,13 @@ Falling back on the first item.
|
|
|
637
611
|
}
|
|
638
612
|
}
|
|
639
613
|
#catcher(cause, plugin, hookName) {
|
|
640
|
-
const text = `${cause.message} (plugin: ${
|
|
614
|
+
const text = `${cause.message} (plugin: ${plugin?.name || "unknown"}, hook: ${hookName || "unknown"})`;
|
|
641
615
|
this.logger.emit("error", text, cause);
|
|
642
616
|
this.events.emit("error", cause);
|
|
643
617
|
}
|
|
644
618
|
#parse(plugin, pluginManager, context) {
|
|
645
619
|
const usedPluginNames = pluginManager.#usedPluginNames;
|
|
646
|
-
|
|
620
|
+
chunkOJRKV365_cjs.setUniqueName(plugin.name, usedPluginNames);
|
|
647
621
|
const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
|
|
648
622
|
if (plugin.context && typeof plugin.context === "function") {
|
|
649
623
|
return {
|
|
@@ -675,25 +649,21 @@ Falling back on the first item.
|
|
|
675
649
|
static get hooks() {
|
|
676
650
|
return ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
677
651
|
}
|
|
678
|
-
}
|
|
652
|
+
};
|
|
679
653
|
|
|
680
654
|
// src/config.ts
|
|
681
|
-
|
|
655
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
682
656
|
function defineConfig(options) {
|
|
683
657
|
return options;
|
|
684
658
|
}
|
|
685
659
|
function isInputPath(result) {
|
|
686
660
|
return !!result && "path" in result;
|
|
687
661
|
}
|
|
688
|
-
|
|
689
|
-
// src/build.ts
|
|
690
|
-
|
|
691
|
-
|
|
692
662
|
async function setup(options) {
|
|
693
|
-
const { config, logger =
|
|
663
|
+
const { config, logger = chunkYEVCYV36_cjs.createLogger() } = options;
|
|
694
664
|
try {
|
|
695
|
-
if (isInputPath(config) && !new
|
|
696
|
-
await
|
|
665
|
+
if (isInputPath(config) && !new chunkOJRKV365_cjs.URLPath(config.input.path).isURL) {
|
|
666
|
+
await fs.read(config.input.path);
|
|
697
667
|
}
|
|
698
668
|
} catch (e) {
|
|
699
669
|
if (isInputPath(config)) {
|
|
@@ -703,8 +673,8 @@ async function setup(options) {
|
|
|
703
673
|
}
|
|
704
674
|
}
|
|
705
675
|
if (config.output.clean) {
|
|
706
|
-
await
|
|
707
|
-
await
|
|
676
|
+
await fs.clean(config.output.path);
|
|
677
|
+
await fs.clean(path3.join(config.root, ".kubb"));
|
|
708
678
|
}
|
|
709
679
|
return new PluginManager(config, { logger });
|
|
710
680
|
}
|
|
@@ -722,12 +692,12 @@ async function safeBuild(options) {
|
|
|
722
692
|
const pluginManager = await setup(options);
|
|
723
693
|
try {
|
|
724
694
|
pluginManager.events.on("executing", ({ plugin, message }) => {
|
|
725
|
-
pluginManager.logger.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Executing pluginKey ${
|
|
695
|
+
pluginManager.logger.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Executing pluginKey ${plugin.key?.join(".")} | ${message}`] });
|
|
726
696
|
});
|
|
727
697
|
pluginManager.events.on("executed", ({ plugin, message, output }) => {
|
|
728
698
|
pluginManager.logger.emit("debug", {
|
|
729
699
|
date: /* @__PURE__ */ new Date(),
|
|
730
|
-
logs: [`Executed pluginKey ${
|
|
700
|
+
logs: [`Executed pluginKey ${plugin.key?.join(".")} | ${message} | ${JSON.stringify(output, void 0, 2)}`]
|
|
731
701
|
});
|
|
732
702
|
});
|
|
733
703
|
await pluginManager.hookParallel({
|
|
@@ -735,8 +705,8 @@ async function safeBuild(options) {
|
|
|
735
705
|
parameters: [options.config],
|
|
736
706
|
message: "buildStart"
|
|
737
707
|
});
|
|
738
|
-
const root =
|
|
739
|
-
const rootPath =
|
|
708
|
+
const root = path3.resolve(options.config.root);
|
|
709
|
+
const rootPath = path3.resolve(root, options.config.output.path, "index.ts");
|
|
740
710
|
const barrelFiles = pluginManager.fileManager.files.filter((file) => {
|
|
741
711
|
return file.sources.some((source) => source.isIndexable);
|
|
742
712
|
});
|
|
@@ -744,26 +714,26 @@ async function safeBuild(options) {
|
|
|
744
714
|
path: rootPath,
|
|
745
715
|
baseName: "index.ts",
|
|
746
716
|
exports: barrelFiles.flatMap((file) => {
|
|
747
|
-
return
|
|
717
|
+
return file.sources?.map((source) => {
|
|
748
718
|
if (!file.path || !source.isIndexable) {
|
|
749
719
|
return void 0;
|
|
750
720
|
}
|
|
751
|
-
const plugin = pluginManager.plugins.find((item) => {
|
|
721
|
+
const plugin = [...pluginManager.plugins].find((item) => {
|
|
752
722
|
const meta = file.meta;
|
|
753
|
-
return item.name ===
|
|
723
|
+
return item.name === meta?.pluginKey?.[0];
|
|
754
724
|
});
|
|
755
|
-
if (
|
|
725
|
+
if (plugin?.output?.exportType === false) {
|
|
756
726
|
return void 0;
|
|
757
727
|
}
|
|
758
|
-
if (
|
|
728
|
+
if (chunkOJRKV365_cjs.FileManager.getMode(plugin?.output?.path) === "single") {
|
|
759
729
|
return void 0;
|
|
760
730
|
}
|
|
761
731
|
return {
|
|
762
732
|
name: options.config.output.exportType === "barrel" ? void 0 : [source.name],
|
|
763
|
-
path:
|
|
733
|
+
path: fs.getRelativePath(rootPath, file.path),
|
|
764
734
|
isTypeOnly: source.isTypeOnly
|
|
765
735
|
};
|
|
766
|
-
})
|
|
736
|
+
}).filter(Boolean);
|
|
767
737
|
}).filter(Boolean),
|
|
768
738
|
sources: [],
|
|
769
739
|
meta: {}
|
|
@@ -771,7 +741,7 @@ async function safeBuild(options) {
|
|
|
771
741
|
if (options.config.output.exportType) {
|
|
772
742
|
await pluginManager.fileManager.add(rootFile);
|
|
773
743
|
}
|
|
774
|
-
files = await
|
|
744
|
+
files = await chunkOJRKV365_cjs.processFiles({
|
|
775
745
|
config: options.config,
|
|
776
746
|
dryRun: !options.config.output.write,
|
|
777
747
|
files: pluginManager.fileManager.files,
|
|
@@ -793,7 +763,7 @@ async function safeBuild(options) {
|
|
|
793
763
|
}
|
|
794
764
|
|
|
795
765
|
// src/BaseGenerator.ts
|
|
796
|
-
|
|
766
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
797
767
|
var BaseGenerator = class {
|
|
798
768
|
#options = {};
|
|
799
769
|
#context = {};
|
|
@@ -818,33 +788,25 @@ var BaseGenerator = class {
|
|
|
818
788
|
};
|
|
819
789
|
|
|
820
790
|
// src/PackageManager.ts
|
|
821
|
-
|
|
822
|
-
var _module = require('module'); var _module2 = _interopRequireDefault(_module);
|
|
823
|
-
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
824
|
-
var _url = require('url');
|
|
791
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
825
792
|
|
|
826
793
|
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
827
|
-
|
|
828
|
-
|
|
794
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
829
795
|
|
|
830
796
|
// ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
|
|
831
|
-
|
|
832
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
833
|
-
|
|
834
|
-
var _fs3 = require('fs'); var _fs4 = _interopRequireDefault(_fs3);
|
|
835
|
-
|
|
797
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
836
798
|
|
|
837
799
|
// ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
|
838
|
-
|
|
800
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
839
801
|
|
|
840
802
|
// ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
841
|
-
|
|
803
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
842
804
|
|
|
843
805
|
// ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
|
844
|
-
|
|
806
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
845
807
|
var Node = class {
|
|
846
|
-
|
|
847
|
-
|
|
808
|
+
value;
|
|
809
|
+
next;
|
|
848
810
|
constructor(value) {
|
|
849
811
|
this.value = value;
|
|
850
812
|
}
|
|
@@ -912,7 +874,7 @@ function pLimit(concurrency) {
|
|
|
912
874
|
resolve2(result);
|
|
913
875
|
try {
|
|
914
876
|
await result;
|
|
915
|
-
} catch
|
|
877
|
+
} catch {
|
|
916
878
|
}
|
|
917
879
|
next();
|
|
918
880
|
};
|
|
@@ -988,9 +950,9 @@ function checkType(type) {
|
|
|
988
950
|
throw new Error(`Invalid type specified: ${type}`);
|
|
989
951
|
}
|
|
990
952
|
var matchType = (type, stat) => stat[typeMappings[type]]();
|
|
991
|
-
var toPath = (urlOrPath) => urlOrPath instanceof URL ?
|
|
953
|
+
var toPath = (urlOrPath) => urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
|
|
992
954
|
async function locatePath(paths, {
|
|
993
|
-
cwd =
|
|
955
|
+
cwd = process__default.default.cwd(),
|
|
994
956
|
type = "file",
|
|
995
957
|
allowSymlinks = true,
|
|
996
958
|
concurrency,
|
|
@@ -998,27 +960,27 @@ async function locatePath(paths, {
|
|
|
998
960
|
} = {}) {
|
|
999
961
|
checkType(type);
|
|
1000
962
|
cwd = toPath(cwd);
|
|
1001
|
-
const statFunction = allowSymlinks ?
|
|
963
|
+
const statFunction = allowSymlinks ? fs$1.promises.stat : fs$1.promises.lstat;
|
|
1002
964
|
return pLocate(paths, async (path_) => {
|
|
1003
965
|
try {
|
|
1004
|
-
const stat = await statFunction(
|
|
966
|
+
const stat = await statFunction(path3__default.default.resolve(cwd, path_));
|
|
1005
967
|
return matchType(type, stat);
|
|
1006
|
-
} catch
|
|
968
|
+
} catch {
|
|
1007
969
|
return false;
|
|
1008
970
|
}
|
|
1009
971
|
}, { concurrency, preserveOrder });
|
|
1010
972
|
}
|
|
1011
973
|
function locatePathSync(paths, {
|
|
1012
|
-
cwd =
|
|
974
|
+
cwd = process__default.default.cwd(),
|
|
1013
975
|
type = "file",
|
|
1014
976
|
allowSymlinks = true
|
|
1015
977
|
} = {}) {
|
|
1016
978
|
checkType(type);
|
|
1017
979
|
cwd = toPath(cwd);
|
|
1018
|
-
const statFunction = allowSymlinks ?
|
|
980
|
+
const statFunction = allowSymlinks ? fs__default.default.statSync : fs__default.default.lstatSync;
|
|
1019
981
|
for (const path_ of paths) {
|
|
1020
982
|
try {
|
|
1021
|
-
const stat = statFunction(
|
|
983
|
+
const stat = statFunction(path3__default.default.resolve(cwd, path_), {
|
|
1022
984
|
throwIfNoEntry: false
|
|
1023
985
|
});
|
|
1024
986
|
if (!stat) {
|
|
@@ -1027,29 +989,27 @@ function locatePathSync(paths, {
|
|
|
1027
989
|
if (matchType(type, stat)) {
|
|
1028
990
|
return path_;
|
|
1029
991
|
}
|
|
1030
|
-
} catch
|
|
992
|
+
} catch {
|
|
1031
993
|
}
|
|
1032
994
|
}
|
|
1033
995
|
}
|
|
1034
996
|
|
|
1035
997
|
// ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
|
|
1036
|
-
|
|
1037
|
-
|
|
998
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
1038
999
|
function toPath2(urlOrPath) {
|
|
1039
|
-
return urlOrPath instanceof URL ?
|
|
1000
|
+
return urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
|
|
1040
1001
|
}
|
|
1041
1002
|
|
|
1042
1003
|
// ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
|
|
1043
|
-
|
|
1044
|
-
|
|
1004
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
1045
1005
|
|
|
1046
1006
|
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
1047
1007
|
var findUpStop = Symbol("findUpStop");
|
|
1048
1008
|
async function findUpMultiple(name, options = {}) {
|
|
1049
|
-
let directory =
|
|
1050
|
-
const { root } =
|
|
1051
|
-
const stopAt =
|
|
1052
|
-
const limit =
|
|
1009
|
+
let directory = path3__default.default.resolve(toPath2(options.cwd) ?? "");
|
|
1010
|
+
const { root } = path3__default.default.parse(directory);
|
|
1011
|
+
const stopAt = path3__default.default.resolve(directory, toPath2(options.stopAt ?? root));
|
|
1012
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
1053
1013
|
const paths = [name].flat();
|
|
1054
1014
|
const runMatcher = async (locateOptions) => {
|
|
1055
1015
|
if (typeof name !== "function") {
|
|
@@ -1068,20 +1028,20 @@ async function findUpMultiple(name, options = {}) {
|
|
|
1068
1028
|
break;
|
|
1069
1029
|
}
|
|
1070
1030
|
if (foundPath) {
|
|
1071
|
-
matches.push(
|
|
1031
|
+
matches.push(path3__default.default.resolve(directory, foundPath));
|
|
1072
1032
|
}
|
|
1073
1033
|
if (directory === stopAt || matches.length >= limit) {
|
|
1074
1034
|
break;
|
|
1075
1035
|
}
|
|
1076
|
-
directory =
|
|
1036
|
+
directory = path3__default.default.dirname(directory);
|
|
1077
1037
|
}
|
|
1078
1038
|
return matches;
|
|
1079
1039
|
}
|
|
1080
1040
|
function findUpMultipleSync(name, options = {}) {
|
|
1081
|
-
let directory =
|
|
1082
|
-
const { root } =
|
|
1083
|
-
const stopAt =
|
|
1084
|
-
const limit =
|
|
1041
|
+
let directory = path3__default.default.resolve(toPath2(options.cwd) ?? "");
|
|
1042
|
+
const { root } = path3__default.default.parse(directory);
|
|
1043
|
+
const stopAt = path3__default.default.resolve(directory, toPath2(options.stopAt) ?? root);
|
|
1044
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
1085
1045
|
const paths = [name].flat();
|
|
1086
1046
|
const runMatcher = (locateOptions) => {
|
|
1087
1047
|
if (typeof name !== "function") {
|
|
@@ -1100,12 +1060,12 @@ function findUpMultipleSync(name, options = {}) {
|
|
|
1100
1060
|
break;
|
|
1101
1061
|
}
|
|
1102
1062
|
if (foundPath) {
|
|
1103
|
-
matches.push(
|
|
1063
|
+
matches.push(path3__default.default.resolve(directory, foundPath));
|
|
1104
1064
|
}
|
|
1105
1065
|
if (directory === stopAt || matches.length >= limit) {
|
|
1106
1066
|
break;
|
|
1107
1067
|
}
|
|
1108
|
-
directory =
|
|
1068
|
+
directory = path3__default.default.dirname(directory);
|
|
1109
1069
|
}
|
|
1110
1070
|
return matches;
|
|
1111
1071
|
}
|
|
@@ -1117,10 +1077,6 @@ function findUpSync(name, options = {}) {
|
|
|
1117
1077
|
const matches = findUpMultipleSync(name, { ...options, limit: 1 });
|
|
1118
1078
|
return matches[0];
|
|
1119
1079
|
}
|
|
1120
|
-
|
|
1121
|
-
// src/PackageManager.ts
|
|
1122
|
-
var _semver = require('semver');
|
|
1123
|
-
|
|
1124
1080
|
var PackageManager = class _PackageManager {
|
|
1125
1081
|
static #cache = {};
|
|
1126
1082
|
#cwd;
|
|
@@ -1146,7 +1102,7 @@ var PackageManager = class _PackageManager {
|
|
|
1146
1102
|
getLocation(path4) {
|
|
1147
1103
|
let location = path4;
|
|
1148
1104
|
if (this.#cwd) {
|
|
1149
|
-
const require2 =
|
|
1105
|
+
const require2 = mod__default.default.createRequire(this.normalizeDirectory(this.#cwd));
|
|
1150
1106
|
location = require2.resolve(path4);
|
|
1151
1107
|
}
|
|
1152
1108
|
return location;
|
|
@@ -1154,11 +1110,11 @@ var PackageManager = class _PackageManager {
|
|
|
1154
1110
|
async import(path4) {
|
|
1155
1111
|
try {
|
|
1156
1112
|
let location = this.getLocation(path4);
|
|
1157
|
-
if (
|
|
1158
|
-
location =
|
|
1113
|
+
if (os__default.default.platform() === "win32") {
|
|
1114
|
+
location = url.pathToFileURL(location).href;
|
|
1159
1115
|
}
|
|
1160
|
-
const module = await
|
|
1161
|
-
return
|
|
1116
|
+
const module = await import(location);
|
|
1117
|
+
return module?.default ?? module;
|
|
1162
1118
|
} catch (e) {
|
|
1163
1119
|
console.error(e);
|
|
1164
1120
|
return void 0;
|
|
@@ -1171,7 +1127,7 @@ var PackageManager = class _PackageManager {
|
|
|
1171
1127
|
if (!pkgPath) {
|
|
1172
1128
|
return void 0;
|
|
1173
1129
|
}
|
|
1174
|
-
const json = await
|
|
1130
|
+
const json = await fs.read(pkgPath);
|
|
1175
1131
|
return JSON.parse(json);
|
|
1176
1132
|
}
|
|
1177
1133
|
getPackageJSONSync() {
|
|
@@ -1181,7 +1137,7 @@ var PackageManager = class _PackageManager {
|
|
|
1181
1137
|
if (!pkgPath) {
|
|
1182
1138
|
return void 0;
|
|
1183
1139
|
}
|
|
1184
|
-
const json =
|
|
1140
|
+
const json = fs.readSync(pkgPath);
|
|
1185
1141
|
return JSON.parse(json);
|
|
1186
1142
|
}
|
|
1187
1143
|
static setVersion(dependency, version) {
|
|
@@ -1226,35 +1182,50 @@ var PackageManager = class _PackageManager {
|
|
|
1226
1182
|
if (packageVersion === version) {
|
|
1227
1183
|
return true;
|
|
1228
1184
|
}
|
|
1229
|
-
const semVer =
|
|
1185
|
+
const semVer = semver.coerce(packageVersion);
|
|
1230
1186
|
if (!semVer) {
|
|
1231
1187
|
throw new Error(`${packageVersion} is not valid`);
|
|
1232
1188
|
}
|
|
1233
|
-
return
|
|
1189
|
+
return semver.satisfies(semVer, version);
|
|
1234
1190
|
}
|
|
1235
1191
|
isValidSync(dependency, version) {
|
|
1236
1192
|
const packageVersion = this.getVersionSync(dependency);
|
|
1237
1193
|
if (!packageVersion) {
|
|
1238
1194
|
return false;
|
|
1239
1195
|
}
|
|
1240
|
-
const semVer =
|
|
1196
|
+
const semVer = semver.coerce(packageVersion);
|
|
1241
1197
|
if (!semVer) {
|
|
1242
1198
|
throw new Error(`${packageVersion} is not valid`);
|
|
1243
1199
|
}
|
|
1244
|
-
return
|
|
1200
|
+
return semver.satisfies(semVer, version);
|
|
1245
1201
|
}
|
|
1246
1202
|
};
|
|
1247
1203
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1204
|
+
Object.defineProperty(exports, "FileManager", {
|
|
1205
|
+
enumerable: true,
|
|
1206
|
+
get: function () { return chunkOJRKV365_cjs.FileManager; }
|
|
1207
|
+
});
|
|
1208
|
+
Object.defineProperty(exports, "combineExports", {
|
|
1209
|
+
enumerable: true,
|
|
1210
|
+
get: function () { return chunkOJRKV365_cjs.combineExports; }
|
|
1211
|
+
});
|
|
1212
|
+
Object.defineProperty(exports, "combineImports", {
|
|
1213
|
+
enumerable: true,
|
|
1214
|
+
get: function () { return chunkOJRKV365_cjs.combineImports; }
|
|
1215
|
+
});
|
|
1216
|
+
Object.defineProperty(exports, "combineSources", {
|
|
1217
|
+
enumerable: true,
|
|
1218
|
+
get: function () { return chunkOJRKV365_cjs.combineSources; }
|
|
1219
|
+
});
|
|
1220
|
+
exports.BaseGenerator = BaseGenerator;
|
|
1221
|
+
exports.PackageManager = PackageManager;
|
|
1222
|
+
exports.PluginManager = PluginManager;
|
|
1223
|
+
exports.PromiseManager = PromiseManager;
|
|
1224
|
+
exports.build = build;
|
|
1225
|
+
exports.createPlugin = createPlugin;
|
|
1226
|
+
exports.default = build;
|
|
1227
|
+
exports.defineConfig = defineConfig;
|
|
1228
|
+
exports.isInputPath = isInputPath;
|
|
1229
|
+
exports.safeBuild = safeBuild;
|
|
1230
|
+
//# sourceMappingURL=index.cjs.map
|
|
1260
1231
|
//# sourceMappingURL=index.cjs.map
|