@kubb/core 3.0.0-alpha.1 → 3.0.0-alpha.2
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-EVJig-LT.d.ts → FileManager-BW--rO8q.d.ts} +13 -31
- package/dist/{FileManager-DSLZ6ps7.d.cts → FileManager-Bw-FNS3q.d.cts} +13 -31
- package/dist/index.cjs +27 -71
- 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 +11 -55
- package/dist/index.js.map +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/package.json +7 -7
- package/src/PluginManager.ts +10 -19
- package/src/build.ts +3 -52
- package/src/plugin.ts +1 -1
- package/src/types.ts +12 -32
|
@@ -128,7 +128,7 @@ declare class PluginManager {
|
|
|
128
128
|
}): Promise<void>;
|
|
129
129
|
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[];
|
|
130
130
|
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>]>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
131
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "
|
|
131
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
interface Cache<TStore extends object = object> {
|
|
@@ -154,11 +154,9 @@ type UserConfig = Omit<Config, 'root' | 'plugins'> & {
|
|
|
154
154
|
*/
|
|
155
155
|
root?: string;
|
|
156
156
|
/**
|
|
157
|
-
* Plugin type
|
|
158
|
-
* Example: ['@kubb/plugin-oas', { output: false }]
|
|
159
|
-
* Or: pluginOas({ output: false })
|
|
157
|
+
* Plugin type should be a Kubb plugin
|
|
160
158
|
*/
|
|
161
|
-
plugins?: Array<Omit<UnknownUserPlugin, '
|
|
159
|
+
plugins?: Array<Omit<UnknownUserPlugin, 'context'>>;
|
|
162
160
|
};
|
|
163
161
|
type InputPath = {
|
|
164
162
|
/**
|
|
@@ -236,9 +234,9 @@ TOptions extends object = object,
|
|
|
236
234
|
*/
|
|
237
235
|
TResolvedOptions extends object = TOptions,
|
|
238
236
|
/**
|
|
239
|
-
*
|
|
237
|
+
* Context that you want to expose to other plugins.
|
|
240
238
|
*/
|
|
241
|
-
|
|
239
|
+
TContext = any,
|
|
242
240
|
/**
|
|
243
241
|
* When calling `resolvePath` you can specify better types.
|
|
244
242
|
*/
|
|
@@ -250,7 +248,7 @@ TResolvePathOptions extends object = object> = {
|
|
|
250
248
|
key: PluginKey<TName | string>;
|
|
251
249
|
options: TOptions;
|
|
252
250
|
resolvedOptions: TResolvedOptions;
|
|
253
|
-
|
|
251
|
+
context: TContext;
|
|
254
252
|
resolvePathOptions: TResolvePathOptions;
|
|
255
253
|
};
|
|
256
254
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
@@ -275,10 +273,10 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
275
273
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
276
274
|
*/
|
|
277
275
|
post?: Array<string>;
|
|
278
|
-
} & (TOptions['
|
|
279
|
-
|
|
276
|
+
} & (TOptions['context'] extends never ? {
|
|
277
|
+
context?: never;
|
|
280
278
|
} : {
|
|
281
|
-
|
|
279
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
282
280
|
});
|
|
283
281
|
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
284
282
|
type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
|
|
@@ -306,10 +304,10 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
306
304
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
307
305
|
*/
|
|
308
306
|
options: TOptions['resolvedOptions'];
|
|
309
|
-
} & (TOptions['
|
|
310
|
-
|
|
307
|
+
} & (TOptions['context'] extends never ? {
|
|
308
|
+
context?: never;
|
|
311
309
|
} : {
|
|
312
|
-
|
|
310
|
+
context: TOptions['context'];
|
|
313
311
|
});
|
|
314
312
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
315
313
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
@@ -332,21 +330,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
332
330
|
* @example ('pet') => 'Pet'
|
|
333
331
|
*/
|
|
334
332
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
335
|
-
/**
|
|
336
|
-
* Makes it possible to run async logic to override the path defined previously by `resolvePath`.
|
|
337
|
-
* @type hookFirst
|
|
338
|
-
*/
|
|
339
|
-
load?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>;
|
|
340
|
-
/**
|
|
341
|
-
* Transform the source-code.
|
|
342
|
-
* @type hookReduceArg0
|
|
343
|
-
*/
|
|
344
|
-
transform?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>;
|
|
345
|
-
/**
|
|
346
|
-
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
|
347
|
-
* @type hookParallel
|
|
348
|
-
*/
|
|
349
|
-
writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path, source: string | undefined) => PossiblePromise<string | void>;
|
|
350
333
|
/**
|
|
351
334
|
* End of the plugin lifecycle.
|
|
352
335
|
* @type hookParallel
|
|
@@ -393,7 +376,6 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
393
376
|
*/
|
|
394
377
|
plugin: Plugin<TOptions>;
|
|
395
378
|
};
|
|
396
|
-
type TransformResult = string | null;
|
|
397
379
|
|
|
398
380
|
type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = File<TMeta, TBaseName> & {
|
|
399
381
|
/**
|
|
@@ -452,4 +434,4 @@ declare class FileManager {
|
|
|
452
434
|
static isJavascript(baseName: string): boolean;
|
|
453
435
|
}
|
|
454
436
|
|
|
455
|
-
export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type PluginContext as P, type ResolvePathParams as R, type
|
|
437
|
+
export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type PluginContext as P, type ResolvePathParams as R, type UserConfig as U, PluginManager as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, type UserPlugin as g, type Plugin as h, type PluginWithLifeCycle as i, type PluginLifecycle as j, type PluginLifecycleHooks as k, type PluginParameter as l, type PluginCache as m, type ResolveNameParams as n };
|
|
@@ -128,7 +128,7 @@ declare class PluginManager {
|
|
|
128
128
|
}): Promise<void>;
|
|
129
129
|
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[];
|
|
130
130
|
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>]>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
131
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "
|
|
131
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
interface Cache<TStore extends object = object> {
|
|
@@ -154,11 +154,9 @@ type UserConfig = Omit<Config, 'root' | 'plugins'> & {
|
|
|
154
154
|
*/
|
|
155
155
|
root?: string;
|
|
156
156
|
/**
|
|
157
|
-
* Plugin type
|
|
158
|
-
* Example: ['@kubb/plugin-oas', { output: false }]
|
|
159
|
-
* Or: pluginOas({ output: false })
|
|
157
|
+
* Plugin type should be a Kubb plugin
|
|
160
158
|
*/
|
|
161
|
-
plugins?: Array<Omit<UnknownUserPlugin, '
|
|
159
|
+
plugins?: Array<Omit<UnknownUserPlugin, 'context'>>;
|
|
162
160
|
};
|
|
163
161
|
type InputPath = {
|
|
164
162
|
/**
|
|
@@ -236,9 +234,9 @@ TOptions extends object = object,
|
|
|
236
234
|
*/
|
|
237
235
|
TResolvedOptions extends object = TOptions,
|
|
238
236
|
/**
|
|
239
|
-
*
|
|
237
|
+
* Context that you want to expose to other plugins.
|
|
240
238
|
*/
|
|
241
|
-
|
|
239
|
+
TContext = any,
|
|
242
240
|
/**
|
|
243
241
|
* When calling `resolvePath` you can specify better types.
|
|
244
242
|
*/
|
|
@@ -250,7 +248,7 @@ TResolvePathOptions extends object = object> = {
|
|
|
250
248
|
key: PluginKey<TName | string>;
|
|
251
249
|
options: TOptions;
|
|
252
250
|
resolvedOptions: TResolvedOptions;
|
|
253
|
-
|
|
251
|
+
context: TContext;
|
|
254
252
|
resolvePathOptions: TResolvePathOptions;
|
|
255
253
|
};
|
|
256
254
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
@@ -275,10 +273,10 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
275
273
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
276
274
|
*/
|
|
277
275
|
post?: Array<string>;
|
|
278
|
-
} & (TOptions['
|
|
279
|
-
|
|
276
|
+
} & (TOptions['context'] extends never ? {
|
|
277
|
+
context?: never;
|
|
280
278
|
} : {
|
|
281
|
-
|
|
279
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
282
280
|
});
|
|
283
281
|
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
284
282
|
type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
|
|
@@ -306,10 +304,10 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
306
304
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
307
305
|
*/
|
|
308
306
|
options: TOptions['resolvedOptions'];
|
|
309
|
-
} & (TOptions['
|
|
310
|
-
|
|
307
|
+
} & (TOptions['context'] extends never ? {
|
|
308
|
+
context?: never;
|
|
311
309
|
} : {
|
|
312
|
-
|
|
310
|
+
context: TOptions['context'];
|
|
313
311
|
});
|
|
314
312
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
315
313
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
@@ -332,21 +330,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
332
330
|
* @example ('pet') => 'Pet'
|
|
333
331
|
*/
|
|
334
332
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
335
|
-
/**
|
|
336
|
-
* Makes it possible to run async logic to override the path defined previously by `resolvePath`.
|
|
337
|
-
* @type hookFirst
|
|
338
|
-
*/
|
|
339
|
-
load?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>;
|
|
340
|
-
/**
|
|
341
|
-
* Transform the source-code.
|
|
342
|
-
* @type hookReduceArg0
|
|
343
|
-
*/
|
|
344
|
-
transform?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>;
|
|
345
|
-
/**
|
|
346
|
-
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
|
347
|
-
* @type hookParallel
|
|
348
|
-
*/
|
|
349
|
-
writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path, source: string | undefined) => PossiblePromise<string | void>;
|
|
350
333
|
/**
|
|
351
334
|
* End of the plugin lifecycle.
|
|
352
335
|
* @type hookParallel
|
|
@@ -393,7 +376,6 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
393
376
|
*/
|
|
394
377
|
plugin: Plugin<TOptions>;
|
|
395
378
|
};
|
|
396
|
-
type TransformResult = string | null;
|
|
397
379
|
|
|
398
380
|
type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = File<TMeta, TBaseName> & {
|
|
399
381
|
/**
|
|
@@ -452,4 +434,4 @@ declare class FileManager {
|
|
|
452
434
|
static isJavascript(baseName: string): boolean;
|
|
453
435
|
}
|
|
454
436
|
|
|
455
|
-
export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type PluginContext as P, type ResolvePathParams as R, type
|
|
437
|
+
export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type PluginContext as P, type ResolvePathParams as R, type UserConfig as U, PluginManager as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, type UserPlugin as g, type Plugin as h, type PluginWithLifeCycle as i, type PluginLifecycle as j, type PluginLifecycleHooks as k, type PluginParameter as l, type PluginCache as m, type ResolveNameParams as n };
|
package/dist/index.cjs
CHANGED
|
@@ -118,7 +118,7 @@ var ValidationPluginError = class extends Error {
|
|
|
118
118
|
|
|
119
119
|
// src/plugin.ts
|
|
120
120
|
_chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
|
|
121
|
-
var
|
|
121
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
122
122
|
|
|
123
123
|
// src/utils/cache.ts
|
|
124
124
|
_chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
|
|
@@ -161,7 +161,7 @@ var pluginCore = createPlugin((options) => {
|
|
|
161
161
|
name: "core",
|
|
162
162
|
options,
|
|
163
163
|
key: ["core"],
|
|
164
|
-
|
|
164
|
+
context() {
|
|
165
165
|
return {
|
|
166
166
|
get config() {
|
|
167
167
|
return options.config;
|
|
@@ -188,8 +188,8 @@ var pluginCore = createPlugin((options) => {
|
|
|
188
188
|
};
|
|
189
189
|
},
|
|
190
190
|
resolvePath(baseName) {
|
|
191
|
-
const root =
|
|
192
|
-
return
|
|
191
|
+
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
192
|
+
return _path2.default.resolve(root, baseName);
|
|
193
193
|
},
|
|
194
194
|
resolveName(name) {
|
|
195
195
|
return name;
|
|
@@ -276,9 +276,9 @@ Falling back on the first item.
|
|
|
276
276
|
resolveName: this.resolveName.bind(this),
|
|
277
277
|
getPlugins: _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).bind(this)
|
|
278
278
|
});
|
|
279
|
-
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _core, _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, parse_fn).call(this, core, this, core.
|
|
279
|
+
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _core, _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, parse_fn).call(this, core, this, core.context.call(null)));
|
|
280
280
|
this.plugins = [_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core), ...plugins].map((plugin) => {
|
|
281
|
-
return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, parse_fn).call(this, plugin, this, _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).
|
|
281
|
+
return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, parse_fn).call(this, plugin, this, _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).context);
|
|
282
282
|
});
|
|
283
283
|
return this;
|
|
284
284
|
}
|
|
@@ -442,7 +442,7 @@ Falling back on the first item.
|
|
|
442
442
|
plugin
|
|
443
443
|
});
|
|
444
444
|
return value;
|
|
445
|
-
}).then((result) => reduce.call(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).
|
|
445
|
+
}).then((result) => reduce.call(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).context, argument0, result, plugin));
|
|
446
446
|
}
|
|
447
447
|
return promise;
|
|
448
448
|
}
|
|
@@ -499,7 +499,7 @@ Falling back on the first item.
|
|
|
499
499
|
});
|
|
500
500
|
}
|
|
501
501
|
static get hooks() {
|
|
502
|
-
return ["buildStart", "resolvePath", "resolveName", "
|
|
502
|
+
return ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
503
503
|
}
|
|
504
504
|
};
|
|
505
505
|
_core = new WeakMap();
|
|
@@ -562,7 +562,7 @@ execute_fn = function({
|
|
|
562
562
|
this.events.emit("execute", { strategy, hookName, parameters, plugin });
|
|
563
563
|
const task = Promise.resolve().then(() => {
|
|
564
564
|
if (typeof hook === "function") {
|
|
565
|
-
const possiblePromiseResult = hook.apply({ ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).
|
|
565
|
+
const possiblePromiseResult = hook.apply({ ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).context, plugin }, parameters);
|
|
566
566
|
if (isPromise(possiblePromiseResult)) {
|
|
567
567
|
return Promise.resolve(possiblePromiseResult);
|
|
568
568
|
}
|
|
@@ -606,7 +606,7 @@ executeSync_fn = function({
|
|
|
606
606
|
this.events.emit("execute", { strategy, hookName, parameters, plugin });
|
|
607
607
|
try {
|
|
608
608
|
if (typeof hook === "function") {
|
|
609
|
-
const fn = hook.apply({ ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).
|
|
609
|
+
const fn = hook.apply({ ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).context, plugin }, parameters);
|
|
610
610
|
output = fn;
|
|
611
611
|
return fn;
|
|
612
612
|
}
|
|
@@ -633,17 +633,11 @@ parse_fn = function(plugin, pluginManager, context) {
|
|
|
633
633
|
const usedPluginNames = _chunkXCPFG6DOcjs.__privateGet.call(void 0, pluginManager, _usedPluginNames);
|
|
634
634
|
_chunkYTSNYMHWcjs.setUniqueName.call(void 0, plugin.name, usedPluginNames);
|
|
635
635
|
const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
|
|
636
|
-
if (
|
|
637
|
-
plugin.transform = function transform(_path, code) {
|
|
638
|
-
return code;
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
if (plugin.api && typeof plugin.api === "function") {
|
|
642
|
-
const api = plugin.api.call(context);
|
|
636
|
+
if (plugin.context && typeof plugin.context === "function") {
|
|
643
637
|
return {
|
|
644
638
|
...plugin,
|
|
645
639
|
key,
|
|
646
|
-
|
|
640
|
+
context: plugin.context.call(context)
|
|
647
641
|
};
|
|
648
642
|
}
|
|
649
643
|
return {
|
|
@@ -662,9 +656,6 @@ function isInputPath(result) {
|
|
|
662
656
|
}
|
|
663
657
|
|
|
664
658
|
// src/build.ts
|
|
665
|
-
async function transformReducer(_previousCode, result, _plugin) {
|
|
666
|
-
return result;
|
|
667
|
-
}
|
|
668
659
|
async function setup(options) {
|
|
669
660
|
const { config, logger = _chunkLM2YQC3Tcjs.createLogger.call(void 0, { logLevel: _chunkLM2YQC3Tcjs.LogLevel.silent }) } = options;
|
|
670
661
|
let count = 0;
|
|
@@ -687,35 +678,10 @@ async function setup(options) {
|
|
|
687
678
|
}
|
|
688
679
|
const task = async (file) => {
|
|
689
680
|
const { path: path4 } = file;
|
|
690
|
-
|
|
691
|
-
const { result: loadedResult } = await pluginManager.hookFirst({
|
|
692
|
-
hookName: "load",
|
|
693
|
-
parameters: [path4]
|
|
694
|
-
});
|
|
695
|
-
if (loadedResult && isPromise(loadedResult)) {
|
|
696
|
-
source = await loadedResult;
|
|
697
|
-
}
|
|
698
|
-
if (loadedResult && !isPromise(loadedResult)) {
|
|
699
|
-
source = loadedResult;
|
|
700
|
-
}
|
|
681
|
+
const source = await _chunkADC5UNZ5cjs.FileManager.getSource(file);
|
|
701
682
|
if (source) {
|
|
702
|
-
source = await pluginManager.hookReduceArg0({
|
|
703
|
-
hookName: "transform",
|
|
704
|
-
parameters: [path4, source],
|
|
705
|
-
reduce: transformReducer
|
|
706
|
-
});
|
|
707
683
|
if (config.output.write || config.output.write === void 0) {
|
|
708
|
-
|
|
709
|
-
await pluginManager.hookForPlugin({
|
|
710
|
-
pluginKey: _optionalChain([file, 'access', _28 => _28.meta, 'optionalAccess', _29 => _29.pluginKey]),
|
|
711
|
-
hookName: "writeFile",
|
|
712
|
-
parameters: [path4, source]
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
await pluginManager.hookFirst({
|
|
716
|
-
hookName: "writeFile",
|
|
717
|
-
parameters: [path4, source]
|
|
718
|
-
});
|
|
684
|
+
await pluginManager.fileManager.write(path4, source, { sanity: false });
|
|
719
685
|
}
|
|
720
686
|
}
|
|
721
687
|
return {
|
|
@@ -724,16 +690,6 @@ async function setup(options) {
|
|
|
724
690
|
};
|
|
725
691
|
};
|
|
726
692
|
const pluginManager = new PluginManager(config, { logger, task });
|
|
727
|
-
pluginManager.on("execute", (executer) => {
|
|
728
|
-
const { hookName, parameters, plugin } = executer;
|
|
729
|
-
if (hookName === "writeFile") {
|
|
730
|
-
const [code] = parameters;
|
|
731
|
-
logger.emit("debug", [`PluginKey ${_chunkLM2YQC3Tcjs.p.dim(JSON.stringify(plugin.key))}
|
|
732
|
-
with source
|
|
733
|
-
|
|
734
|
-
${code}`]);
|
|
735
|
-
}
|
|
736
|
-
});
|
|
737
693
|
pluginManager.queue.on("add", () => {
|
|
738
694
|
if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
|
|
739
695
|
return;
|
|
@@ -1049,7 +1005,7 @@ async function locatePath(paths, {
|
|
|
1049
1005
|
const statFunction = allowSymlinks ? _fs3.promises.stat : _fs3.promises.lstat;
|
|
1050
1006
|
return pLocate(paths, async (path_) => {
|
|
1051
1007
|
try {
|
|
1052
|
-
const stat = await statFunction(
|
|
1008
|
+
const stat = await statFunction(_path2.default.resolve(cwd, path_));
|
|
1053
1009
|
return matchType(type, stat);
|
|
1054
1010
|
} catch (e3) {
|
|
1055
1011
|
return false;
|
|
@@ -1066,7 +1022,7 @@ function locatePathSync(paths, {
|
|
|
1066
1022
|
const statFunction = allowSymlinks ? _fs4.default.statSync : _fs4.default.lstatSync;
|
|
1067
1023
|
for (const path_ of paths) {
|
|
1068
1024
|
try {
|
|
1069
|
-
const stat = statFunction(
|
|
1025
|
+
const stat = statFunction(_path2.default.resolve(cwd, path_), {
|
|
1070
1026
|
throwIfNoEntry: false
|
|
1071
1027
|
});
|
|
1072
1028
|
if (!stat) {
|
|
@@ -1094,9 +1050,9 @@ _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
|
|
|
1094
1050
|
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
1095
1051
|
var findUpStop = Symbol("findUpStop");
|
|
1096
1052
|
async function findUpMultiple(name, options = {}) {
|
|
1097
|
-
let directory =
|
|
1098
|
-
const { root } =
|
|
1099
|
-
const stopAt =
|
|
1053
|
+
let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
|
|
1054
|
+
const { root } = _path2.default.parse(directory);
|
|
1055
|
+
const stopAt = _path2.default.resolve(directory, toPath2(_nullishCoalesce(options.stopAt, () => ( root))));
|
|
1100
1056
|
const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
|
|
1101
1057
|
const paths = [name].flat();
|
|
1102
1058
|
const runMatcher = async (locateOptions) => {
|
|
@@ -1116,19 +1072,19 @@ async function findUpMultiple(name, options = {}) {
|
|
|
1116
1072
|
break;
|
|
1117
1073
|
}
|
|
1118
1074
|
if (foundPath) {
|
|
1119
|
-
matches.push(
|
|
1075
|
+
matches.push(_path2.default.resolve(directory, foundPath));
|
|
1120
1076
|
}
|
|
1121
1077
|
if (directory === stopAt || matches.length >= limit) {
|
|
1122
1078
|
break;
|
|
1123
1079
|
}
|
|
1124
|
-
directory =
|
|
1080
|
+
directory = _path2.default.dirname(directory);
|
|
1125
1081
|
}
|
|
1126
1082
|
return matches;
|
|
1127
1083
|
}
|
|
1128
1084
|
function findUpMultipleSync(name, options = {}) {
|
|
1129
|
-
let directory =
|
|
1130
|
-
const { root } =
|
|
1131
|
-
const stopAt =
|
|
1085
|
+
let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
|
|
1086
|
+
const { root } = _path2.default.parse(directory);
|
|
1087
|
+
const stopAt = _path2.default.resolve(directory, _nullishCoalesce(toPath2(options.stopAt), () => ( root)));
|
|
1132
1088
|
const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
|
|
1133
1089
|
const paths = [name].flat();
|
|
1134
1090
|
const runMatcher = (locateOptions) => {
|
|
@@ -1148,12 +1104,12 @@ function findUpMultipleSync(name, options = {}) {
|
|
|
1148
1104
|
break;
|
|
1149
1105
|
}
|
|
1150
1106
|
if (foundPath) {
|
|
1151
|
-
matches.push(
|
|
1107
|
+
matches.push(_path2.default.resolve(directory, foundPath));
|
|
1152
1108
|
}
|
|
1153
1109
|
if (directory === stopAt || matches.length >= limit) {
|
|
1154
1110
|
break;
|
|
1155
1111
|
}
|
|
1156
|
-
directory =
|
|
1112
|
+
directory = _path2.default.dirname(directory);
|
|
1157
1113
|
}
|
|
1158
1114
|
return matches;
|
|
1159
1115
|
}
|
|
@@ -1207,7 +1163,7 @@ var _PackageManager = class _PackageManager {
|
|
|
1207
1163
|
location = _url.pathToFileURL.call(void 0, location).href;
|
|
1208
1164
|
}
|
|
1209
1165
|
const module = await Promise.resolve().then(() => _interopRequireWildcard(require(location)));
|
|
1210
|
-
return _nullishCoalesce(_optionalChain([module, 'optionalAccess',
|
|
1166
|
+
return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _26 => _26.default]), () => ( module));
|
|
1211
1167
|
} catch (e) {
|
|
1212
1168
|
console.log(e);
|
|
1213
1169
|
return void 0;
|