silgi 0.20.28 → 0.20.29
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/_chunks/index.mjs +1 -1
- package/dist/cli/common.mjs +52 -70
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/common.mjs
CHANGED
|
@@ -342,147 +342,125 @@ async function nuxtFramework(silgi, skip = false) {
|
|
|
342
342
|
const frameworkSetup = [emptyFramework, h3Framework, nitroFramework, nuxtFramework];
|
|
343
343
|
|
|
344
344
|
async function registerModuleExportScan(silgi) {
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
345
|
+
silgi.hook("prepare:schema.ts", async (options) => {
|
|
346
|
+
for (const module of silgi.scanModules) {
|
|
347
|
+
const moduleReExports = [];
|
|
348
|
+
const moduleTypes = await promises.readFile(module.entryPath.replace(/\.mjs$/, "Types.d.ts"), "utf8").catch(() => "");
|
|
349
|
+
const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
|
|
350
|
+
for (const e of findTypeExports(normalisedModuleTypes)) {
|
|
351
|
+
moduleReExports.push(e);
|
|
352
|
+
}
|
|
353
|
+
for (const e of findExports(normalisedModuleTypes)) {
|
|
354
|
+
moduleReExports.push(e);
|
|
355
|
+
}
|
|
356
|
+
const hasTypeExport = (name) => moduleReExports.find((exp) => exp.names?.includes(name));
|
|
357
|
+
const configKey = module.meta.configKey;
|
|
358
|
+
const moduleName = module.meta.name || module.meta._packageName;
|
|
359
359
|
options.importItems[configKey] = {
|
|
360
360
|
import: [],
|
|
361
361
|
from: module.meta._packageName ? moduleName : relativeWithDot(silgi.options.build.typesDir, module.entryPath)
|
|
362
362
|
};
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const importName = `_${hash(`${configKey}ModuleOptions`)}`;
|
|
366
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
363
|
+
if (hasTypeExport("ModuleOptions")) {
|
|
364
|
+
const importName = `_${hash(`${configKey}ModuleOptions`)}`;
|
|
367
365
|
options.importItems[configKey].import.push({
|
|
368
366
|
name: `ModuleOptions as ${importName}`,
|
|
369
367
|
type: true,
|
|
370
368
|
key: importName
|
|
371
369
|
});
|
|
372
370
|
options.options.push({ key: configKey, value: importName });
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
const importName = `_${hash(`${configKey}ModuleRuntimeOptions`)}`;
|
|
377
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
371
|
+
}
|
|
372
|
+
if (hasTypeExport("ModuleRuntimeOptions")) {
|
|
373
|
+
const importName = `_${hash(`${configKey}ModuleRuntimeOptions`)}`;
|
|
378
374
|
options.importItems[configKey].import.push({
|
|
379
375
|
name: `ModuleRuntimeOptions as ${importName}`,
|
|
380
376
|
type: true,
|
|
381
377
|
key: importName
|
|
382
378
|
});
|
|
383
379
|
options.runtimeOptions.push({ key: configKey, value: importName });
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const importName = `_${hash(`${configKey}ModuleRuntimeShareds`)}`;
|
|
388
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
380
|
+
}
|
|
381
|
+
if (hasTypeExport("ModuleRuntimeShareds")) {
|
|
382
|
+
const importName = `_${hash(`${configKey}ModuleRuntimeShareds`)}`;
|
|
389
383
|
options.importItems[configKey].import.push({
|
|
390
384
|
name: `ModuleRuntimeShareds as ${importName}`,
|
|
391
385
|
type: true,
|
|
392
386
|
key: importName
|
|
393
387
|
});
|
|
394
388
|
options.shareds.push({ key: configKey, value: importName });
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
const importName = `_${hash(`${configKey}ModuleEvents`)}`;
|
|
399
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
389
|
+
}
|
|
390
|
+
if (hasTypeExport("ModuleEvents")) {
|
|
391
|
+
const importName = `_${hash(`${configKey}ModuleEvents`)}`;
|
|
400
392
|
options.importItems[configKey].import.push({
|
|
401
393
|
name: `ModuleEvents as ${importName}`,
|
|
402
394
|
type: true,
|
|
403
395
|
key: importName
|
|
404
396
|
});
|
|
405
397
|
options.events.push({ key: configKey, value: importName });
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
const importName = `_${hash(`${configKey}ModuleRuntimeContexts`)}`;
|
|
410
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
398
|
+
}
|
|
399
|
+
if (hasTypeExport("ModuleRuntimeContexts")) {
|
|
400
|
+
const importName = `_${hash(`${configKey}ModuleRuntimeContexts`)}`;
|
|
411
401
|
options.importItems[configKey].import.push({
|
|
412
402
|
name: `ModuleRuntimeContexts as ${importName}`,
|
|
413
403
|
type: true,
|
|
414
404
|
key: importName
|
|
415
405
|
});
|
|
416
406
|
options.contexts.push({ key: configKey, value: importName });
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const importName = `_${hash(`${configKey}ModuleHooks`)}`;
|
|
421
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
407
|
+
}
|
|
408
|
+
if (hasTypeExport("ModuleHooks")) {
|
|
409
|
+
const importName = `_${hash(`${configKey}ModuleHooks`)}`;
|
|
422
410
|
options.importItems[configKey].import.push({
|
|
423
411
|
name: `ModuleHooks as ${importName}`,
|
|
424
412
|
type: true,
|
|
425
413
|
key: importName
|
|
426
414
|
});
|
|
427
415
|
options.hooks.push({ key: configKey, value: importName });
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const importName = `_${hash(`${configKey}RuntimeHooks`)}`;
|
|
432
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
416
|
+
}
|
|
417
|
+
if (hasTypeExport("ModuleRuntimeHooks")) {
|
|
418
|
+
const importName = `_${hash(`${configKey}RuntimeHooks`)}`;
|
|
433
419
|
options.importItems[configKey].import.push({
|
|
434
420
|
name: `ModuleRuntimeHooks as ${importName}`,
|
|
435
421
|
type: true,
|
|
436
422
|
key: importName
|
|
437
423
|
});
|
|
438
424
|
options.runtimeHooks.push({ key: configKey, value: importName });
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
const importName = `_${hash(`${configKey}ModuleRuntimeActions`)}`;
|
|
443
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
425
|
+
}
|
|
426
|
+
if (hasTypeExport("ModuleRuntimeActions")) {
|
|
427
|
+
const importName = `_${hash(`${configKey}ModuleRuntimeActions`)}`;
|
|
444
428
|
options.importItems[configKey].import.push({
|
|
445
429
|
name: `ModuleRuntimeActions as ${importName}`,
|
|
446
430
|
type: true,
|
|
447
431
|
key: importName
|
|
448
432
|
});
|
|
449
433
|
options.actions.push({ key: configKey, value: importName });
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
const importName = `_${hash(`${configKey}ModuleRuntimeMethods`)}`;
|
|
454
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
434
|
+
}
|
|
435
|
+
if (hasTypeExport("ModuleRuntimeMethods")) {
|
|
436
|
+
const importName = `_${hash(`${configKey}ModuleRuntimeMethods`)}`;
|
|
455
437
|
options.importItems[configKey].import.push({
|
|
456
438
|
name: `ModuleRuntimeMethods as ${importName}`,
|
|
457
439
|
type: true,
|
|
458
440
|
key: importName
|
|
459
441
|
});
|
|
460
442
|
options.methods.push({ key: configKey, value: importName });
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
const importName = `_${hash(`${configKey}ModuleRuntimeRouteRules`)}`;
|
|
465
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
443
|
+
}
|
|
444
|
+
if (hasTypeExport("ModuleRuntimeRouteRules")) {
|
|
445
|
+
const importName = `_${hash(`${configKey}ModuleRuntimeRouteRules`)}`;
|
|
466
446
|
options.importItems[configKey].import.push({
|
|
467
447
|
name: `ModuleRuntimeRouteRules as ${importName}`,
|
|
468
448
|
type: true,
|
|
469
449
|
key: importName
|
|
470
450
|
});
|
|
471
451
|
options.routeRules.push({ key: configKey, value: importName });
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const importName = `_${hash(`${configKey}ModuleRuntimeRouteRulesConfig`)}`;
|
|
476
|
-
silgi.hook("prepare:schema.ts", async (options) => {
|
|
452
|
+
}
|
|
453
|
+
if (hasTypeExport("ModuleRuntimeRouteRulesConfig")) {
|
|
454
|
+
const importName = `_${hash(`${configKey}ModuleRuntimeRouteRulesConfig`)}`;
|
|
477
455
|
options.importItems[configKey].import.push({
|
|
478
456
|
name: `ModuleRuntimeRouteRulesConfig as ${importName}`,
|
|
479
457
|
type: true,
|
|
480
458
|
key: importName
|
|
481
459
|
});
|
|
482
460
|
options.routeRulesConfig.push({ key: configKey, value: importName });
|
|
483
|
-
}
|
|
461
|
+
}
|
|
484
462
|
}
|
|
485
|
-
}
|
|
463
|
+
});
|
|
486
464
|
}
|
|
487
465
|
|
|
488
466
|
async function loadSilgiModuleInstance(silgiModule) {
|
|
@@ -1633,6 +1611,10 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1633
1611
|
},
|
|
1634
1612
|
routeRules: void 0
|
|
1635
1613
|
};
|
|
1614
|
+
silgi.hook("prepare:scan.ts", (options2) => {
|
|
1615
|
+
options2.services = [];
|
|
1616
|
+
options2.importItems = options2.importItems || {};
|
|
1617
|
+
});
|
|
1636
1618
|
const routeRules = createRouteRules();
|
|
1637
1619
|
routeRules.importRules(options.routeRules ?? {});
|
|
1638
1620
|
silgi.routeRules = routeRules;
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED