@kubb/core 3.0.0-alpha.9 → 3.0.0-beta.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.
- package/README.md +14 -5
- package/dist/{FileManager-B0GJlthB.d.cts → FileManager-C9aZTwst.d.ts} +94 -77
- package/dist/{FileManager-BFycBDqG.d.ts → FileManager-ibNoWwHN.d.cts} +94 -77
- package/dist/chunk-2EU7DMPM.js +2 -3
- package/dist/chunk-2EU7DMPM.js.map +1 -1
- package/dist/{chunk-5E2I6KH4.cjs → chunk-7FIOLZNC.cjs} +54 -37
- package/dist/chunk-7FIOLZNC.cjs.map +1 -0
- package/dist/{chunk-4X5FFJPJ.js → chunk-BQXM32UO.js} +11 -16
- package/dist/chunk-BQXM32UO.js.map +1 -0
- package/dist/{chunk-27CPVXAT.js → chunk-DXGMSPTW.js} +174 -231
- package/dist/chunk-DXGMSPTW.js.map +1 -0
- package/dist/{chunk-SCR3LUXT.js → chunk-E6CN2CZC.js} +38 -27
- package/dist/chunk-E6CN2CZC.js.map +1 -0
- package/dist/{chunk-A6PCLWEY.cjs → chunk-GT5BP3R3.cjs} +30 -31
- package/dist/chunk-GT5BP3R3.cjs.map +1 -0
- package/dist/{chunk-5IGANEGE.cjs → chunk-GYVPCXVO.cjs} +268 -301
- package/dist/chunk-GYVPCXVO.cjs.map +1 -0
- package/dist/chunk-HBQM723K.js +12 -26
- package/dist/chunk-HBQM723K.js.map +1 -1
- package/dist/{chunk-DID47EQD.cjs → chunk-NXUSJIVM.cjs} +6 -7
- package/dist/chunk-NXUSJIVM.cjs.map +1 -0
- package/dist/{chunk-SEH6NUCX.cjs → chunk-VD74XCQ4.cjs} +10 -10
- package/dist/chunk-VD74XCQ4.cjs.map +1 -0
- package/dist/{chunk-IPZQXBA2.cjs → chunk-ZFYMG5ID.cjs} +57 -34
- package/dist/chunk-ZFYMG5ID.cjs.map +1 -0
- package/dist/index.cjs +223 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +106 -148
- package/dist/index.js.map +1 -1
- package/dist/{logger-BWFeedRk.d.cts → logger-DvbHXjIO.d.cts} +10 -8
- package/dist/{logger-BWFeedRk.d.ts → logger-DvbHXjIO.d.ts} +10 -8
- package/dist/logger.cjs +25 -14
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +3 -13
- package/dist/logger.js.map +1 -1
- package/dist/mocks.cjs +29 -24
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +4 -3
- package/dist/mocks.d.ts +4 -3
- package/dist/mocks.js +22 -25
- package/dist/mocks.js.map +1 -1
- package/dist/{prompt-DVQN7JTN.cjs → prompt-GVDKBQQY.cjs} +89 -89
- package/dist/prompt-GVDKBQQY.cjs.map +1 -0
- package/dist/prompt-WQQUN22Z.js +8 -13
- package/dist/prompt-WQQUN22Z.js.map +1 -1
- package/dist/transformers.cjs +63 -52
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.d.cts +1 -1
- package/dist/transformers.d.ts +1 -1
- package/dist/transformers.js +10 -37
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +65 -34
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +6 -8
- package/dist/utils.d.ts +6 -8
- package/dist/utils.js +3 -33
- package/dist/utils.js.map +1 -1
- package/package.json +10 -13
- package/src/BarrelManager.ts +76 -74
- package/src/FileManager.ts +55 -60
- package/src/PluginManager.ts +61 -61
- package/src/PromiseManager.ts +1 -1
- package/src/__snapshots__/barrel.json +11 -29
- package/src/__snapshots__/grouped.json +18 -12
- package/src/__snapshots__/ordered.json +18 -12
- package/src/build.ts +24 -11
- package/src/config.ts +2 -4
- package/src/index.ts +1 -1
- package/src/logger.ts +41 -7
- package/src/plugin.ts +0 -3
- package/src/transformers/escape.ts +0 -10
- package/src/transformers/stringify.ts +1 -1
- package/src/types.ts +70 -38
- package/src/utils/TreeNode.ts +31 -56
- package/src/utils/executeStrategies.ts +2 -2
- package/src/utils/parser.ts +38 -39
- package/dist/chunk-27CPVXAT.js.map +0 -1
- package/dist/chunk-4X5FFJPJ.js.map +0 -1
- package/dist/chunk-5E2I6KH4.cjs.map +0 -1
- package/dist/chunk-5IGANEGE.cjs.map +0 -1
- package/dist/chunk-A6PCLWEY.cjs.map +0 -1
- package/dist/chunk-DID47EQD.cjs.map +0 -1
- package/dist/chunk-IPZQXBA2.cjs.map +0 -1
- package/dist/chunk-SCR3LUXT.js.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 chunkNXUSJIVM_cjs = require('./chunk-NXUSJIVM.cjs');
|
|
6
|
+
var chunkZFYMG5ID_cjs = require('./chunk-ZFYMG5ID.cjs');
|
|
7
|
+
var chunkGYVPCXVO_cjs = require('./chunk-GYVPCXVO.cjs');
|
|
8
|
+
require('./chunk-GT5BP3R3.cjs');
|
|
9
|
+
require('./chunk-7FIOLZNC.cjs');
|
|
10
|
+
var chunkVD74XCQ4_cjs = require('./chunk-VD74XCQ4.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 _chunk5IGANEGEcjs = require('./chunk-5IGANEGE.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
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
22
30
|
|
|
23
31
|
// src/build.ts
|
|
24
|
-
|
|
25
|
-
var _fs = require('@kubb/fs');
|
|
32
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
26
33
|
|
|
27
34
|
// src/PluginManager.ts
|
|
28
|
-
|
|
35
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
29
36
|
|
|
30
37
|
// src/PromiseManager.ts
|
|
31
|
-
|
|
38
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
32
39
|
|
|
33
40
|
// src/utils/executeStrategies.ts
|
|
34
|
-
|
|
41
|
+
chunkVD74XCQ4_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
|
+
chunkVD74XCQ4_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
|
+
chunkVD74XCQ4_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 chunkZFYMG5ID_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 chunkGYVPCXVO_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,13 +182,14 @@ 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
|
}
|
|
217
|
-
getFile({ name, mode,
|
|
218
|
-
const baseName = `${name}${
|
|
191
|
+
getFile({ name, mode, extname, pluginKey, options }) {
|
|
192
|
+
const baseName = `${name}${extname}`;
|
|
219
193
|
const path4 = this.resolvePath({ baseName, mode, pluginKey, options });
|
|
220
194
|
if (!path4) {
|
|
221
195
|
throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
|
|
@@ -229,15 +203,17 @@ 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,
|
|
236
210
|
hookName: "resolvePath",
|
|
237
|
-
parameters: [params.baseName, params.mode, params.options]
|
|
211
|
+
parameters: [params.baseName, params.mode, params.options],
|
|
212
|
+
message: `Resolving path '${params.baseName}'`
|
|
238
213
|
});
|
|
239
|
-
if (paths &&
|
|
214
|
+
if (paths && paths?.length > 1) {
|
|
240
215
|
this.logger.emit("debug", {
|
|
216
|
+
date: /* @__PURE__ */ new Date(),
|
|
241
217
|
logs: [
|
|
242
218
|
`Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
243
219
|
|
|
@@ -248,23 +224,26 @@ Falling back on the first item.
|
|
|
248
224
|
]
|
|
249
225
|
});
|
|
250
226
|
}
|
|
251
|
-
return
|
|
227
|
+
return paths?.at(0);
|
|
252
228
|
}
|
|
253
229
|
return this.hookFirstSync({
|
|
254
230
|
hookName: "resolvePath",
|
|
255
|
-
parameters: [params.baseName, params.mode, params.options]
|
|
231
|
+
parameters: [params.baseName, params.mode, params.options],
|
|
232
|
+
message: `Resolving path '${params.baseName}'`
|
|
256
233
|
}).result;
|
|
257
|
-
}
|
|
234
|
+
};
|
|
258
235
|
//TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path
|
|
259
|
-
|
|
236
|
+
resolveName = (params) => {
|
|
260
237
|
if (params.pluginKey) {
|
|
261
238
|
const names = this.hookForPluginSync({
|
|
262
239
|
pluginKey: params.pluginKey,
|
|
263
240
|
hookName: "resolveName",
|
|
264
|
-
parameters: [params.name, params.type]
|
|
241
|
+
parameters: [params.name, params.type],
|
|
242
|
+
message: `Resolving name '${params.name}' and type '${params.type}'`
|
|
265
243
|
});
|
|
266
|
-
if (names &&
|
|
244
|
+
if (names && names?.length > 1) {
|
|
267
245
|
this.logger.emit("debug", {
|
|
246
|
+
date: /* @__PURE__ */ new Date(),
|
|
268
247
|
logs: [
|
|
269
248
|
`Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
270
249
|
|
|
@@ -275,14 +254,15 @@ Falling back on the first item.
|
|
|
275
254
|
]
|
|
276
255
|
});
|
|
277
256
|
}
|
|
278
|
-
return
|
|
257
|
+
return chunkNXUSJIVM_cjs.transformReservedWord(names?.at(0) || params.name);
|
|
279
258
|
}
|
|
280
259
|
const name = this.hookFirstSync({
|
|
281
260
|
hookName: "resolveName",
|
|
282
|
-
parameters: [params.name, params.type]
|
|
261
|
+
parameters: [params.name, params.type],
|
|
262
|
+
message: `Resolving name '${params.name}' and type '${params.type}'`
|
|
283
263
|
}).result;
|
|
284
|
-
return
|
|
285
|
-
}
|
|
264
|
+
return chunkNXUSJIVM_cjs.transformReservedWord(name);
|
|
265
|
+
};
|
|
286
266
|
/**
|
|
287
267
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
288
268
|
*/
|
|
@@ -295,16 +275,18 @@ Falling back on the first item.
|
|
|
295
275
|
async hookForPlugin({
|
|
296
276
|
pluginKey,
|
|
297
277
|
hookName,
|
|
298
|
-
parameters
|
|
278
|
+
parameters,
|
|
279
|
+
message
|
|
299
280
|
}) {
|
|
300
281
|
const plugins = this.getPluginsByKey(hookName, pluginKey);
|
|
301
|
-
this.logger.emit("progress_start", { id: hookName, size: plugins.length });
|
|
282
|
+
this.logger.emit("progress_start", { id: hookName, size: plugins.length, message: "Running plugins..." });
|
|
302
283
|
const promises = plugins.map((plugin) => {
|
|
303
284
|
return this.#execute({
|
|
304
285
|
strategy: "hookFirst",
|
|
305
286
|
hookName,
|
|
306
287
|
parameters,
|
|
307
|
-
plugin
|
|
288
|
+
plugin,
|
|
289
|
+
message
|
|
308
290
|
});
|
|
309
291
|
}).filter(Boolean);
|
|
310
292
|
const items = await Promise.all(promises);
|
|
@@ -317,7 +299,8 @@ Falling back on the first item.
|
|
|
317
299
|
hookForPluginSync({
|
|
318
300
|
pluginKey,
|
|
319
301
|
hookName,
|
|
320
|
-
parameters
|
|
302
|
+
parameters,
|
|
303
|
+
message
|
|
321
304
|
}) {
|
|
322
305
|
const plugins = this.getPluginsByKey(hookName, pluginKey);
|
|
323
306
|
const result = plugins.map((plugin) => {
|
|
@@ -325,7 +308,8 @@ Falling back on the first item.
|
|
|
325
308
|
strategy: "hookFirst",
|
|
326
309
|
hookName,
|
|
327
310
|
parameters,
|
|
328
|
-
plugin
|
|
311
|
+
plugin,
|
|
312
|
+
message
|
|
329
313
|
});
|
|
330
314
|
}).filter(Boolean);
|
|
331
315
|
return result;
|
|
@@ -336,7 +320,8 @@ Falling back on the first item.
|
|
|
336
320
|
async hookFirst({
|
|
337
321
|
hookName,
|
|
338
322
|
parameters,
|
|
339
|
-
skipped
|
|
323
|
+
skipped,
|
|
324
|
+
message
|
|
340
325
|
}) {
|
|
341
326
|
const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {
|
|
342
327
|
return skipped ? skipped.has(plugin) : true;
|
|
@@ -348,7 +333,8 @@ Falling back on the first item.
|
|
|
348
333
|
strategy: "hookFirst",
|
|
349
334
|
hookName,
|
|
350
335
|
parameters,
|
|
351
|
-
plugin
|
|
336
|
+
plugin,
|
|
337
|
+
message
|
|
352
338
|
});
|
|
353
339
|
return Promise.resolve({
|
|
354
340
|
plugin,
|
|
@@ -366,7 +352,8 @@ Falling back on the first item.
|
|
|
366
352
|
hookFirstSync({
|
|
367
353
|
hookName,
|
|
368
354
|
parameters,
|
|
369
|
-
skipped
|
|
355
|
+
skipped,
|
|
356
|
+
message
|
|
370
357
|
}) {
|
|
371
358
|
let parseResult = null;
|
|
372
359
|
const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {
|
|
@@ -378,11 +365,12 @@ Falling back on the first item.
|
|
|
378
365
|
strategy: "hookFirst",
|
|
379
366
|
hookName,
|
|
380
367
|
parameters,
|
|
381
|
-
plugin
|
|
368
|
+
plugin,
|
|
369
|
+
message
|
|
382
370
|
}),
|
|
383
371
|
plugin
|
|
384
372
|
};
|
|
385
|
-
if (
|
|
373
|
+
if (parseResult?.result != null) {
|
|
386
374
|
break;
|
|
387
375
|
}
|
|
388
376
|
}
|
|
@@ -393,7 +381,8 @@ Falling back on the first item.
|
|
|
393
381
|
*/
|
|
394
382
|
async hookParallel({
|
|
395
383
|
hookName,
|
|
396
|
-
parameters
|
|
384
|
+
parameters,
|
|
385
|
+
message
|
|
397
386
|
}) {
|
|
398
387
|
const plugins = this.#getSortedPlugins(hookName);
|
|
399
388
|
this.logger.emit("progress_start", { id: hookName, size: plugins.length });
|
|
@@ -402,7 +391,8 @@ Falling back on the first item.
|
|
|
402
391
|
strategy: "hookParallel",
|
|
403
392
|
hookName,
|
|
404
393
|
parameters,
|
|
405
|
-
plugin
|
|
394
|
+
plugin,
|
|
395
|
+
message
|
|
406
396
|
});
|
|
407
397
|
});
|
|
408
398
|
const results = await this.#promiseManager.run("parallel", promises);
|
|
@@ -416,33 +406,13 @@ Falling back on the first item.
|
|
|
416
406
|
return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
417
407
|
}
|
|
418
408
|
/**
|
|
419
|
-
*
|
|
409
|
+
* Chains plugins
|
|
420
410
|
*/
|
|
421
|
-
|
|
411
|
+
async hookSeq({
|
|
422
412
|
hookName,
|
|
423
413
|
parameters,
|
|
424
|
-
|
|
414
|
+
message
|
|
425
415
|
}) {
|
|
426
|
-
const [argument0, ...rest] = parameters;
|
|
427
|
-
const plugins = this.#getSortedPlugins(hookName);
|
|
428
|
-
let promise = Promise.resolve(argument0);
|
|
429
|
-
for (const plugin of plugins) {
|
|
430
|
-
promise = promise.then((arg0) => {
|
|
431
|
-
const value = this.#execute({
|
|
432
|
-
strategy: "hookReduceArg0",
|
|
433
|
-
hookName,
|
|
434
|
-
parameters: [arg0, ...rest],
|
|
435
|
-
plugin
|
|
436
|
-
});
|
|
437
|
-
return value;
|
|
438
|
-
}).then((result) => reduce.call(this.#core.context, argument0, result, plugin));
|
|
439
|
-
}
|
|
440
|
-
return promise;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Chains plugins
|
|
444
|
-
*/
|
|
445
|
-
async hookSeq({ hookName, parameters }) {
|
|
446
416
|
const plugins = this.#getSortedPlugins(hookName);
|
|
447
417
|
this.logger.emit("progress_start", { id: hookName, size: plugins.length });
|
|
448
418
|
const promises = plugins.map((plugin) => {
|
|
@@ -450,7 +420,8 @@ Falling back on the first item.
|
|
|
450
420
|
strategy: "hookSeq",
|
|
451
421
|
hookName,
|
|
452
422
|
parameters,
|
|
453
|
-
plugin
|
|
423
|
+
plugin,
|
|
424
|
+
message
|
|
454
425
|
});
|
|
455
426
|
});
|
|
456
427
|
await this.#promiseManager.run("seq", promises);
|
|
@@ -459,11 +430,7 @@ Falling back on the first item.
|
|
|
459
430
|
#getSortedPlugins(hookName) {
|
|
460
431
|
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
461
432
|
if (hookName) {
|
|
462
|
-
|
|
463
|
-
if (!containsHookName) {
|
|
464
|
-
this.logger.emit("debug", { logs: [`No hook ${hookName} found`] });
|
|
465
|
-
}
|
|
466
|
-
return plugins.filter((item) => item[hookName]);
|
|
433
|
+
return plugins.filter((plugin) => hookName in plugin);
|
|
467
434
|
}
|
|
468
435
|
return plugins.map((plugin) => {
|
|
469
436
|
if (plugin.pre) {
|
|
@@ -474,10 +441,10 @@ Falling back on the first item.
|
|
|
474
441
|
}
|
|
475
442
|
return plugin;
|
|
476
443
|
}).sort((a, b) => {
|
|
477
|
-
if (
|
|
444
|
+
if (b.pre?.includes(a.name)) {
|
|
478
445
|
return 1;
|
|
479
446
|
}
|
|
480
|
-
if (
|
|
447
|
+
if (b.post?.includes(a.name)) {
|
|
481
448
|
return -1;
|
|
482
449
|
}
|
|
483
450
|
return 0;
|
|
@@ -486,23 +453,25 @@ Falling back on the first item.
|
|
|
486
453
|
getPluginsByKey(hookName, pluginKey) {
|
|
487
454
|
const plugins = [...this.plugins];
|
|
488
455
|
const [searchPluginName, searchIdentifier] = pluginKey;
|
|
489
|
-
const pluginByPluginName = plugins.filter((plugin) => plugin
|
|
456
|
+
const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => {
|
|
490
457
|
const [name, identifier] = item.key;
|
|
491
|
-
const identifierCheck =
|
|
458
|
+
const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
|
|
492
459
|
const nameCheck = name === searchPluginName;
|
|
493
460
|
if (searchIdentifier) {
|
|
494
461
|
return identifierCheck && nameCheck;
|
|
495
462
|
}
|
|
496
463
|
return nameCheck;
|
|
497
464
|
});
|
|
498
|
-
if (!
|
|
499
|
-
const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin
|
|
465
|
+
if (!pluginByPluginName?.length) {
|
|
466
|
+
const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
|
|
500
467
|
if (corePlugin) {
|
|
501
468
|
this.logger.emit("debug", {
|
|
469
|
+
date: /* @__PURE__ */ new Date(),
|
|
502
470
|
logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`]
|
|
503
471
|
});
|
|
504
472
|
} else {
|
|
505
473
|
this.logger.emit("debug", {
|
|
474
|
+
date: /* @__PURE__ */ new Date(),
|
|
506
475
|
logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`]
|
|
507
476
|
});
|
|
508
477
|
}
|
|
@@ -514,7 +483,7 @@ Falling back on the first item.
|
|
|
514
483
|
if (executer) {
|
|
515
484
|
this.events.emit("executed", executer);
|
|
516
485
|
this.executed.push(executer);
|
|
517
|
-
this.logger.emit("
|
|
486
|
+
this.logger.emit("progressed", { id: executer.hookName, message: `${executer.plugin.name}: ${executer.message}` });
|
|
518
487
|
}
|
|
519
488
|
}
|
|
520
489
|
/**
|
|
@@ -528,14 +497,15 @@ Falling back on the first item.
|
|
|
528
497
|
strategy,
|
|
529
498
|
hookName,
|
|
530
499
|
parameters,
|
|
531
|
-
plugin
|
|
500
|
+
plugin,
|
|
501
|
+
message
|
|
532
502
|
}) {
|
|
533
503
|
const hook = plugin[hookName];
|
|
534
504
|
let output;
|
|
535
505
|
if (!hook) {
|
|
536
506
|
return null;
|
|
537
507
|
}
|
|
538
|
-
this.events.emit("
|
|
508
|
+
this.events.emit("executing", { strategy, hookName, parameters, plugin, message });
|
|
539
509
|
const promise = new Promise((resolve2) => {
|
|
540
510
|
resolve2(void 0);
|
|
541
511
|
});
|
|
@@ -555,7 +525,8 @@ Falling back on the first item.
|
|
|
555
525
|
output,
|
|
556
526
|
strategy,
|
|
557
527
|
hookName,
|
|
558
|
-
plugin
|
|
528
|
+
plugin,
|
|
529
|
+
message
|
|
559
530
|
});
|
|
560
531
|
return result;
|
|
561
532
|
}).catch((e) => {
|
|
@@ -575,18 +546,27 @@ Falling back on the first item.
|
|
|
575
546
|
strategy,
|
|
576
547
|
hookName,
|
|
577
548
|
parameters,
|
|
578
|
-
plugin
|
|
549
|
+
plugin,
|
|
550
|
+
message
|
|
579
551
|
}) {
|
|
580
552
|
const hook = plugin[hookName];
|
|
581
553
|
let output;
|
|
582
554
|
if (!hook) {
|
|
583
555
|
return null;
|
|
584
556
|
}
|
|
585
|
-
this.events.emit("
|
|
557
|
+
this.events.emit("executing", { strategy, hookName, parameters, plugin, message });
|
|
586
558
|
try {
|
|
587
559
|
if (typeof hook === "function") {
|
|
588
560
|
const fn = hook.apply({ ...this.#core.context, plugin }, parameters);
|
|
589
561
|
output = fn;
|
|
562
|
+
this.#addExecutedToCallStack({
|
|
563
|
+
parameters,
|
|
564
|
+
output,
|
|
565
|
+
strategy,
|
|
566
|
+
hookName,
|
|
567
|
+
plugin,
|
|
568
|
+
message
|
|
569
|
+
});
|
|
590
570
|
return fn;
|
|
591
571
|
}
|
|
592
572
|
output = hook;
|
|
@@ -595,7 +575,8 @@ Falling back on the first item.
|
|
|
595
575
|
output,
|
|
596
576
|
strategy,
|
|
597
577
|
hookName,
|
|
598
|
-
plugin
|
|
578
|
+
plugin,
|
|
579
|
+
message
|
|
599
580
|
});
|
|
600
581
|
return hook;
|
|
601
582
|
} catch (e) {
|
|
@@ -604,13 +585,13 @@ Falling back on the first item.
|
|
|
604
585
|
}
|
|
605
586
|
}
|
|
606
587
|
#catcher(cause, plugin, hookName) {
|
|
607
|
-
const text = `${cause.message} (plugin: ${
|
|
588
|
+
const text = `${cause.message} (plugin: ${plugin?.name || "unknown"}, hook: ${hookName || "unknown"})`;
|
|
608
589
|
this.logger.emit("error", text, cause);
|
|
609
590
|
this.events.emit("error", cause);
|
|
610
591
|
}
|
|
611
592
|
#parse(plugin, pluginManager, context) {
|
|
612
593
|
const usedPluginNames = pluginManager.#usedPluginNames;
|
|
613
|
-
|
|
594
|
+
chunkGYVPCXVO_cjs.setUniqueName(plugin.name, usedPluginNames);
|
|
614
595
|
const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
|
|
615
596
|
if (plugin.context && typeof plugin.context === "function") {
|
|
616
597
|
return {
|
|
@@ -642,25 +623,21 @@ Falling back on the first item.
|
|
|
642
623
|
static get hooks() {
|
|
643
624
|
return ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
644
625
|
}
|
|
645
|
-
}
|
|
626
|
+
};
|
|
646
627
|
|
|
647
628
|
// src/config.ts
|
|
648
|
-
|
|
629
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
649
630
|
function defineConfig(options) {
|
|
650
631
|
return options;
|
|
651
632
|
}
|
|
652
633
|
function isInputPath(result) {
|
|
653
|
-
return !!result && "path" in result;
|
|
634
|
+
return !!result && "path" in result?.input;
|
|
654
635
|
}
|
|
655
|
-
|
|
656
|
-
// src/build.ts
|
|
657
|
-
|
|
658
|
-
|
|
659
636
|
async function setup(options) {
|
|
660
|
-
const { config, logger =
|
|
637
|
+
const { config, logger = chunkZFYMG5ID_cjs.createLogger() } = options;
|
|
661
638
|
try {
|
|
662
|
-
if (isInputPath(config) && !new
|
|
663
|
-
await
|
|
639
|
+
if (isInputPath(config) && !new chunkGYVPCXVO_cjs.URLPath(config.input.path).isURL) {
|
|
640
|
+
await fs.read(config.input.path);
|
|
664
641
|
}
|
|
665
642
|
} catch (e) {
|
|
666
643
|
if (isInputPath(config)) {
|
|
@@ -670,7 +647,8 @@ async function setup(options) {
|
|
|
670
647
|
}
|
|
671
648
|
}
|
|
672
649
|
if (config.output.clean) {
|
|
673
|
-
await
|
|
650
|
+
await fs.clean(config.output.path);
|
|
651
|
+
await fs.clean(path3.join(config.root, ".kubb"));
|
|
674
652
|
}
|
|
675
653
|
return new PluginManager(config, { logger });
|
|
676
654
|
}
|
|
@@ -684,15 +662,25 @@ async function build(options) {
|
|
|
684
662
|
};
|
|
685
663
|
}
|
|
686
664
|
async function safeBuild(options) {
|
|
687
|
-
const pluginManager = await setup(options);
|
|
688
665
|
let files = [];
|
|
666
|
+
const pluginManager = await setup(options);
|
|
689
667
|
try {
|
|
668
|
+
pluginManager.events.on("executing", ({ plugin, message }) => {
|
|
669
|
+
pluginManager.logger.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Executing pluginKey ${plugin.key?.join(".")} | ${message}`] });
|
|
670
|
+
});
|
|
671
|
+
pluginManager.events.on("executed", ({ plugin, message, output }) => {
|
|
672
|
+
pluginManager.logger.emit("debug", {
|
|
673
|
+
date: /* @__PURE__ */ new Date(),
|
|
674
|
+
logs: [`Executed pluginKey ${plugin.key?.join(".")} | ${message} | ${JSON.stringify(output, void 0, 2)}`]
|
|
675
|
+
});
|
|
676
|
+
});
|
|
690
677
|
await pluginManager.hookParallel({
|
|
691
678
|
hookName: "buildStart",
|
|
692
|
-
parameters: [options.config]
|
|
679
|
+
parameters: [options.config],
|
|
680
|
+
message: "buildStart"
|
|
693
681
|
});
|
|
694
|
-
const root =
|
|
695
|
-
const rootPath =
|
|
682
|
+
const root = path3.resolve(options.config.root);
|
|
683
|
+
const rootPath = path3.resolve(root, options.config.output.path, "index.ts");
|
|
696
684
|
const barrelFiles = pluginManager.fileManager.files.filter((file) => {
|
|
697
685
|
return file.sources.some((source) => source.isIndexable);
|
|
698
686
|
});
|
|
@@ -700,40 +688,41 @@ async function safeBuild(options) {
|
|
|
700
688
|
path: rootPath,
|
|
701
689
|
baseName: "index.ts",
|
|
702
690
|
exports: barrelFiles.flatMap((file) => {
|
|
703
|
-
return
|
|
691
|
+
return file.sources?.map((source) => {
|
|
704
692
|
if (!file.path || !source.isIndexable) {
|
|
705
693
|
return void 0;
|
|
706
694
|
}
|
|
707
|
-
const plugin = pluginManager.plugins.find((item) => {
|
|
695
|
+
const plugin = [...pluginManager.plugins].find((item) => {
|
|
708
696
|
const meta = file.meta;
|
|
709
|
-
return item.
|
|
697
|
+
return item.key === meta?.pluginKey;
|
|
710
698
|
});
|
|
711
|
-
|
|
699
|
+
const pluginOptions = plugin?.options ?? {};
|
|
700
|
+
if (pluginOptions.output?.barrelType === false) {
|
|
712
701
|
return void 0;
|
|
713
702
|
}
|
|
714
|
-
if (
|
|
703
|
+
if (chunkGYVPCXVO_cjs.FileManager.getMode(pluginOptions.output?.path) === "single") {
|
|
715
704
|
return void 0;
|
|
716
705
|
}
|
|
717
706
|
return {
|
|
718
|
-
name:
|
|
719
|
-
path:
|
|
707
|
+
name: pluginOptions.output?.barrelType === "all" ? void 0 : [source.name],
|
|
708
|
+
path: fs.getRelativePath(rootPath, file.path),
|
|
720
709
|
isTypeOnly: source.isTypeOnly
|
|
721
710
|
};
|
|
722
|
-
})
|
|
711
|
+
}).filter(Boolean);
|
|
723
712
|
}).filter(Boolean),
|
|
724
713
|
sources: [],
|
|
725
714
|
meta: {}
|
|
726
715
|
};
|
|
727
|
-
if (options.config.output.
|
|
716
|
+
if (options.config.output.barrelType) {
|
|
728
717
|
await pluginManager.fileManager.add(rootFile);
|
|
729
718
|
}
|
|
730
|
-
files = await
|
|
719
|
+
files = await chunkGYVPCXVO_cjs.processFiles({
|
|
731
720
|
config: options.config,
|
|
732
721
|
dryRun: !options.config.output.write,
|
|
733
722
|
files: pluginManager.fileManager.files,
|
|
734
723
|
logger: pluginManager.logger
|
|
735
724
|
});
|
|
736
|
-
await pluginManager.hookParallel({ hookName: "buildEnd" });
|
|
725
|
+
await pluginManager.hookParallel({ hookName: "buildEnd", message: `Build stopped for ${options.config.name}` });
|
|
737
726
|
pluginManager.fileManager.clear();
|
|
738
727
|
} catch (e) {
|
|
739
728
|
return {
|
|
@@ -749,7 +738,7 @@ async function safeBuild(options) {
|
|
|
749
738
|
}
|
|
750
739
|
|
|
751
740
|
// src/BaseGenerator.ts
|
|
752
|
-
|
|
741
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
753
742
|
var BaseGenerator = class {
|
|
754
743
|
#options = {};
|
|
755
744
|
#context = {};
|
|
@@ -774,33 +763,25 @@ var BaseGenerator = class {
|
|
|
774
763
|
};
|
|
775
764
|
|
|
776
765
|
// src/PackageManager.ts
|
|
777
|
-
|
|
778
|
-
var _module = require('module'); var _module2 = _interopRequireDefault(_module);
|
|
779
|
-
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
780
|
-
var _url = require('url');
|
|
766
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
781
767
|
|
|
782
768
|
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
783
|
-
|
|
784
|
-
|
|
769
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
785
770
|
|
|
786
771
|
// ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
|
|
787
|
-
|
|
788
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
789
|
-
|
|
790
|
-
var _fs3 = require('fs'); var _fs4 = _interopRequireDefault(_fs3);
|
|
791
|
-
|
|
772
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
792
773
|
|
|
793
774
|
// ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
|
794
|
-
|
|
775
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
795
776
|
|
|
796
777
|
// ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
797
|
-
|
|
778
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
798
779
|
|
|
799
780
|
// ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
|
800
|
-
|
|
781
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
801
782
|
var Node = class {
|
|
802
|
-
|
|
803
|
-
|
|
783
|
+
value;
|
|
784
|
+
next;
|
|
804
785
|
constructor(value) {
|
|
805
786
|
this.value = value;
|
|
806
787
|
}
|
|
@@ -868,7 +849,7 @@ function pLimit(concurrency) {
|
|
|
868
849
|
resolve2(result);
|
|
869
850
|
try {
|
|
870
851
|
await result;
|
|
871
|
-
} catch
|
|
852
|
+
} catch {
|
|
872
853
|
}
|
|
873
854
|
next();
|
|
874
855
|
};
|
|
@@ -944,9 +925,9 @@ function checkType(type) {
|
|
|
944
925
|
throw new Error(`Invalid type specified: ${type}`);
|
|
945
926
|
}
|
|
946
927
|
var matchType = (type, stat) => stat[typeMappings[type]]();
|
|
947
|
-
var toPath = (urlOrPath) => urlOrPath instanceof URL ?
|
|
928
|
+
var toPath = (urlOrPath) => urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
|
|
948
929
|
async function locatePath(paths, {
|
|
949
|
-
cwd =
|
|
930
|
+
cwd = process__default.default.cwd(),
|
|
950
931
|
type = "file",
|
|
951
932
|
allowSymlinks = true,
|
|
952
933
|
concurrency,
|
|
@@ -954,27 +935,27 @@ async function locatePath(paths, {
|
|
|
954
935
|
} = {}) {
|
|
955
936
|
checkType(type);
|
|
956
937
|
cwd = toPath(cwd);
|
|
957
|
-
const statFunction = allowSymlinks ?
|
|
938
|
+
const statFunction = allowSymlinks ? fs$1.promises.stat : fs$1.promises.lstat;
|
|
958
939
|
return pLocate(paths, async (path_) => {
|
|
959
940
|
try {
|
|
960
|
-
const stat = await statFunction(
|
|
941
|
+
const stat = await statFunction(path3__default.default.resolve(cwd, path_));
|
|
961
942
|
return matchType(type, stat);
|
|
962
|
-
} catch
|
|
943
|
+
} catch {
|
|
963
944
|
return false;
|
|
964
945
|
}
|
|
965
946
|
}, { concurrency, preserveOrder });
|
|
966
947
|
}
|
|
967
948
|
function locatePathSync(paths, {
|
|
968
|
-
cwd =
|
|
949
|
+
cwd = process__default.default.cwd(),
|
|
969
950
|
type = "file",
|
|
970
951
|
allowSymlinks = true
|
|
971
952
|
} = {}) {
|
|
972
953
|
checkType(type);
|
|
973
954
|
cwd = toPath(cwd);
|
|
974
|
-
const statFunction = allowSymlinks ?
|
|
955
|
+
const statFunction = allowSymlinks ? fs__default.default.statSync : fs__default.default.lstatSync;
|
|
975
956
|
for (const path_ of paths) {
|
|
976
957
|
try {
|
|
977
|
-
const stat = statFunction(
|
|
958
|
+
const stat = statFunction(path3__default.default.resolve(cwd, path_), {
|
|
978
959
|
throwIfNoEntry: false
|
|
979
960
|
});
|
|
980
961
|
if (!stat) {
|
|
@@ -983,29 +964,27 @@ function locatePathSync(paths, {
|
|
|
983
964
|
if (matchType(type, stat)) {
|
|
984
965
|
return path_;
|
|
985
966
|
}
|
|
986
|
-
} catch
|
|
967
|
+
} catch {
|
|
987
968
|
}
|
|
988
969
|
}
|
|
989
970
|
}
|
|
990
971
|
|
|
991
972
|
// ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
|
|
992
|
-
|
|
993
|
-
|
|
973
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
994
974
|
function toPath2(urlOrPath) {
|
|
995
|
-
return urlOrPath instanceof URL ?
|
|
975
|
+
return urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
|
|
996
976
|
}
|
|
997
977
|
|
|
998
978
|
// ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
|
|
999
|
-
|
|
1000
|
-
|
|
979
|
+
chunkVD74XCQ4_cjs.init_cjs_shims();
|
|
1001
980
|
|
|
1002
981
|
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
1003
982
|
var findUpStop = Symbol("findUpStop");
|
|
1004
983
|
async function findUpMultiple(name, options = {}) {
|
|
1005
|
-
let directory =
|
|
1006
|
-
const { root } =
|
|
1007
|
-
const stopAt =
|
|
1008
|
-
const limit =
|
|
984
|
+
let directory = path3__default.default.resolve(toPath2(options.cwd) ?? "");
|
|
985
|
+
const { root } = path3__default.default.parse(directory);
|
|
986
|
+
const stopAt = path3__default.default.resolve(directory, toPath2(options.stopAt ?? root));
|
|
987
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
1009
988
|
const paths = [name].flat();
|
|
1010
989
|
const runMatcher = async (locateOptions) => {
|
|
1011
990
|
if (typeof name !== "function") {
|
|
@@ -1024,20 +1003,20 @@ async function findUpMultiple(name, options = {}) {
|
|
|
1024
1003
|
break;
|
|
1025
1004
|
}
|
|
1026
1005
|
if (foundPath) {
|
|
1027
|
-
matches.push(
|
|
1006
|
+
matches.push(path3__default.default.resolve(directory, foundPath));
|
|
1028
1007
|
}
|
|
1029
1008
|
if (directory === stopAt || matches.length >= limit) {
|
|
1030
1009
|
break;
|
|
1031
1010
|
}
|
|
1032
|
-
directory =
|
|
1011
|
+
directory = path3__default.default.dirname(directory);
|
|
1033
1012
|
}
|
|
1034
1013
|
return matches;
|
|
1035
1014
|
}
|
|
1036
1015
|
function findUpMultipleSync(name, options = {}) {
|
|
1037
|
-
let directory =
|
|
1038
|
-
const { root } =
|
|
1039
|
-
const stopAt =
|
|
1040
|
-
const limit =
|
|
1016
|
+
let directory = path3__default.default.resolve(toPath2(options.cwd) ?? "");
|
|
1017
|
+
const { root } = path3__default.default.parse(directory);
|
|
1018
|
+
const stopAt = path3__default.default.resolve(directory, toPath2(options.stopAt) ?? root);
|
|
1019
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
1041
1020
|
const paths = [name].flat();
|
|
1042
1021
|
const runMatcher = (locateOptions) => {
|
|
1043
1022
|
if (typeof name !== "function") {
|
|
@@ -1056,12 +1035,12 @@ function findUpMultipleSync(name, options = {}) {
|
|
|
1056
1035
|
break;
|
|
1057
1036
|
}
|
|
1058
1037
|
if (foundPath) {
|
|
1059
|
-
matches.push(
|
|
1038
|
+
matches.push(path3__default.default.resolve(directory, foundPath));
|
|
1060
1039
|
}
|
|
1061
1040
|
if (directory === stopAt || matches.length >= limit) {
|
|
1062
1041
|
break;
|
|
1063
1042
|
}
|
|
1064
|
-
directory =
|
|
1043
|
+
directory = path3__default.default.dirname(directory);
|
|
1065
1044
|
}
|
|
1066
1045
|
return matches;
|
|
1067
1046
|
}
|
|
@@ -1073,10 +1052,6 @@ function findUpSync(name, options = {}) {
|
|
|
1073
1052
|
const matches = findUpMultipleSync(name, { ...options, limit: 1 });
|
|
1074
1053
|
return matches[0];
|
|
1075
1054
|
}
|
|
1076
|
-
|
|
1077
|
-
// src/PackageManager.ts
|
|
1078
|
-
var _semver = require('semver');
|
|
1079
|
-
|
|
1080
1055
|
var PackageManager = class _PackageManager {
|
|
1081
1056
|
static #cache = {};
|
|
1082
1057
|
#cwd;
|
|
@@ -1102,7 +1077,7 @@ var PackageManager = class _PackageManager {
|
|
|
1102
1077
|
getLocation(path4) {
|
|
1103
1078
|
let location = path4;
|
|
1104
1079
|
if (this.#cwd) {
|
|
1105
|
-
const require2 =
|
|
1080
|
+
const require2 = mod__default.default.createRequire(this.normalizeDirectory(this.#cwd));
|
|
1106
1081
|
location = require2.resolve(path4);
|
|
1107
1082
|
}
|
|
1108
1083
|
return location;
|
|
@@ -1110,11 +1085,11 @@ var PackageManager = class _PackageManager {
|
|
|
1110
1085
|
async import(path4) {
|
|
1111
1086
|
try {
|
|
1112
1087
|
let location = this.getLocation(path4);
|
|
1113
|
-
if (
|
|
1114
|
-
location =
|
|
1088
|
+
if (os__default.default.platform() === "win32") {
|
|
1089
|
+
location = url.pathToFileURL(location).href;
|
|
1115
1090
|
}
|
|
1116
|
-
const module = await
|
|
1117
|
-
return
|
|
1091
|
+
const module = await import(location);
|
|
1092
|
+
return module?.default ?? module;
|
|
1118
1093
|
} catch (e) {
|
|
1119
1094
|
console.error(e);
|
|
1120
1095
|
return void 0;
|
|
@@ -1127,7 +1102,7 @@ var PackageManager = class _PackageManager {
|
|
|
1127
1102
|
if (!pkgPath) {
|
|
1128
1103
|
return void 0;
|
|
1129
1104
|
}
|
|
1130
|
-
const json = await
|
|
1105
|
+
const json = await fs.read(pkgPath);
|
|
1131
1106
|
return JSON.parse(json);
|
|
1132
1107
|
}
|
|
1133
1108
|
getPackageJSONSync() {
|
|
@@ -1137,7 +1112,7 @@ var PackageManager = class _PackageManager {
|
|
|
1137
1112
|
if (!pkgPath) {
|
|
1138
1113
|
return void 0;
|
|
1139
1114
|
}
|
|
1140
|
-
const json =
|
|
1115
|
+
const json = fs.readSync(pkgPath);
|
|
1141
1116
|
return JSON.parse(json);
|
|
1142
1117
|
}
|
|
1143
1118
|
static setVersion(dependency, version) {
|
|
@@ -1182,35 +1157,42 @@ var PackageManager = class _PackageManager {
|
|
|
1182
1157
|
if (packageVersion === version) {
|
|
1183
1158
|
return true;
|
|
1184
1159
|
}
|
|
1185
|
-
const semVer =
|
|
1160
|
+
const semVer = semver.coerce(packageVersion);
|
|
1186
1161
|
if (!semVer) {
|
|
1187
1162
|
throw new Error(`${packageVersion} is not valid`);
|
|
1188
1163
|
}
|
|
1189
|
-
return
|
|
1164
|
+
return semver.satisfies(semVer, version);
|
|
1190
1165
|
}
|
|
1191
1166
|
isValidSync(dependency, version) {
|
|
1192
1167
|
const packageVersion = this.getVersionSync(dependency);
|
|
1193
1168
|
if (!packageVersion) {
|
|
1194
1169
|
return false;
|
|
1195
1170
|
}
|
|
1196
|
-
const semVer =
|
|
1171
|
+
const semVer = semver.coerce(packageVersion);
|
|
1197
1172
|
if (!semVer) {
|
|
1198
1173
|
throw new Error(`${packageVersion} is not valid`);
|
|
1199
1174
|
}
|
|
1200
|
-
return
|
|
1175
|
+
return semver.satisfies(semVer, version);
|
|
1201
1176
|
}
|
|
1202
1177
|
};
|
|
1203
1178
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
exports.
|
|
1179
|
+
Object.defineProperty(exports, "FileManager", {
|
|
1180
|
+
enumerable: true,
|
|
1181
|
+
get: function () { return chunkGYVPCXVO_cjs.FileManager; }
|
|
1182
|
+
});
|
|
1183
|
+
Object.defineProperty(exports, "getSource", {
|
|
1184
|
+
enumerable: true,
|
|
1185
|
+
get: function () { return chunkGYVPCXVO_cjs.getSource; }
|
|
1186
|
+
});
|
|
1187
|
+
exports.BaseGenerator = BaseGenerator;
|
|
1188
|
+
exports.PackageManager = PackageManager;
|
|
1189
|
+
exports.PluginManager = PluginManager;
|
|
1190
|
+
exports.PromiseManager = PromiseManager;
|
|
1191
|
+
exports.build = build;
|
|
1192
|
+
exports.createPlugin = createPlugin;
|
|
1193
|
+
exports.default = build;
|
|
1194
|
+
exports.defineConfig = defineConfig;
|
|
1195
|
+
exports.isInputPath = isInputPath;
|
|
1196
|
+
exports.safeBuild = safeBuild;
|
|
1197
|
+
//# sourceMappingURL=index.cjs.map
|
|
1216
1198
|
//# sourceMappingURL=index.cjs.map
|