silgi 0.10.2 → 0.10.4
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
CHANGED
|
@@ -566,6 +566,16 @@ async function prepareServerFiles(silgi) {
|
|
|
566
566
|
"#silgi/vfs": {
|
|
567
567
|
import: [],
|
|
568
568
|
from: "./vfs"
|
|
569
|
+
},
|
|
570
|
+
"configs.ts": {
|
|
571
|
+
import: [
|
|
572
|
+
{
|
|
573
|
+
name: "cliConfigs",
|
|
574
|
+
type: false,
|
|
575
|
+
key: "cliConfigs"
|
|
576
|
+
}
|
|
577
|
+
],
|
|
578
|
+
from: "./configs.ts"
|
|
569
579
|
}
|
|
570
580
|
};
|
|
571
581
|
const scanned = {
|
|
@@ -1376,8 +1386,8 @@ function useCLIRuntimeConfig(silgi) {
|
|
|
1376
1386
|
envExpansion: process.env.NITRO_ENV_EXPANSION ?? process.env.SILGI_ENV_EXPANSION ?? false,
|
|
1377
1387
|
...silgi.options.envOptions
|
|
1378
1388
|
};
|
|
1379
|
-
silgi.hook("prepare:
|
|
1380
|
-
data.
|
|
1389
|
+
silgi.hook("prepare:configs.ts", (data) => {
|
|
1390
|
+
data.envOptions = envOptions;
|
|
1381
1391
|
});
|
|
1382
1392
|
const _sharedRuntimeConfig = _deepFreeze(
|
|
1383
1393
|
applyEnv(klona(_inlineRuntimeConfig), envOptions)
|
|
@@ -1511,6 +1521,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1511
1521
|
await silgi.unimport.init();
|
|
1512
1522
|
}
|
|
1513
1523
|
await registerModuleExportScan(silgi);
|
|
1524
|
+
await writeScanFiles(silgi);
|
|
1514
1525
|
return silgi;
|
|
1515
1526
|
}
|
|
1516
1527
|
|
|
@@ -1524,19 +1535,58 @@ async function generateSilgiStorageBaseType(silgi) {
|
|
|
1524
1535
|
});
|
|
1525
1536
|
}
|
|
1526
1537
|
|
|
1538
|
+
async function prepareConfigs(silgi) {
|
|
1539
|
+
const _data = {};
|
|
1540
|
+
for (const module of silgi.scanModules) {
|
|
1541
|
+
if (module.meta.cliToRuntimeOptionsKeys && module.meta.cliToRuntimeOptionsKeys?.length > 0) {
|
|
1542
|
+
for (const key of module.meta.cliToRuntimeOptionsKeys) {
|
|
1543
|
+
_data[module.meta.configKey] = {
|
|
1544
|
+
..._data[module.meta.configKey],
|
|
1545
|
+
[key]: module.options[key]
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
} else {
|
|
1549
|
+
_data[module.meta.configKey] = {};
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
await silgi.callHook("prepare:configs.ts", _data);
|
|
1553
|
+
const importData = [
|
|
1554
|
+
"import type { SilgiRuntimeOptions } from 'silgi/types'",
|
|
1555
|
+
"",
|
|
1556
|
+
`export const cliConfigs: Partial<SilgiRuntimeOptions> = ${JSON.stringify(_data, null, 2)}`,
|
|
1557
|
+
""
|
|
1558
|
+
];
|
|
1559
|
+
return importData;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1527
1562
|
async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
1528
1563
|
let importItems = {
|
|
1529
1564
|
"silgi/core": {
|
|
1530
1565
|
import: [
|
|
1531
|
-
{
|
|
1566
|
+
{
|
|
1567
|
+
name: "createSilgi",
|
|
1568
|
+
key: "createSilgi"
|
|
1569
|
+
}
|
|
1532
1570
|
],
|
|
1533
1571
|
from: "silgi/core"
|
|
1534
1572
|
},
|
|
1535
1573
|
"silgi/types": {
|
|
1536
1574
|
import: [
|
|
1537
|
-
{
|
|
1538
|
-
|
|
1539
|
-
|
|
1575
|
+
{
|
|
1576
|
+
name: "SilgiRuntimeOptions",
|
|
1577
|
+
type: true,
|
|
1578
|
+
key: "SilgiRuntimeOptions"
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
name: "FrameworkContext",
|
|
1582
|
+
type: true,
|
|
1583
|
+
key: "FrameworkContext"
|
|
1584
|
+
},
|
|
1585
|
+
{
|
|
1586
|
+
name: "BuildConfig",
|
|
1587
|
+
type: true,
|
|
1588
|
+
key: "Build"
|
|
1589
|
+
}
|
|
1540
1590
|
],
|
|
1541
1591
|
from: "silgi/types"
|
|
1542
1592
|
},
|
|
@@ -1547,29 +1597,51 @@ async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
|
1547
1597
|
"silgi/runtime/internal/defu": {
|
|
1548
1598
|
import: [
|
|
1549
1599
|
{
|
|
1550
|
-
name: "mergeDeep"
|
|
1600
|
+
name: "mergeDeep",
|
|
1601
|
+
key: "mergeDeep"
|
|
1551
1602
|
}
|
|
1552
1603
|
],
|
|
1553
1604
|
from: "silgi/runtime/internal/defu"
|
|
1554
1605
|
},
|
|
1555
1606
|
"scan.ts": {
|
|
1556
|
-
import: [
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1607
|
+
import: [
|
|
1608
|
+
{
|
|
1609
|
+
name: "uris",
|
|
1610
|
+
type: false,
|
|
1611
|
+
key: "uris"
|
|
1612
|
+
},
|
|
1613
|
+
{
|
|
1614
|
+
name: "services",
|
|
1615
|
+
type: false,
|
|
1616
|
+
key: "services"
|
|
1617
|
+
},
|
|
1618
|
+
{
|
|
1619
|
+
name: "shareds",
|
|
1620
|
+
type: false,
|
|
1621
|
+
key: "shareds"
|
|
1622
|
+
},
|
|
1623
|
+
{
|
|
1624
|
+
name: "schemas",
|
|
1625
|
+
type: false,
|
|
1626
|
+
key: "schemas"
|
|
1627
|
+
},
|
|
1628
|
+
{
|
|
1629
|
+
name: "modulesURIs",
|
|
1630
|
+
type: false,
|
|
1631
|
+
key: "modulesURIs"
|
|
1632
|
+
}
|
|
1633
|
+
],
|
|
1572
1634
|
from: "./scan.ts"
|
|
1635
|
+
},
|
|
1636
|
+
"configs.ts": {
|
|
1637
|
+
import: [
|
|
1638
|
+
{
|
|
1639
|
+
name: "cliConfigs",
|
|
1640
|
+
type: false,
|
|
1641
|
+
key: "cliConfigs"
|
|
1642
|
+
}
|
|
1643
|
+
],
|
|
1644
|
+
from: "./configs.ts"
|
|
1573
1645
|
}
|
|
1574
1646
|
};
|
|
1575
1647
|
importItems = { ...data._importItems, ...importItems };
|
|
@@ -1577,24 +1649,11 @@ async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
|
1577
1649
|
customImports: data._customImports || [],
|
|
1578
1650
|
buildSilgiExtraContent: [],
|
|
1579
1651
|
beforeBuildSilgiExtraContent: [],
|
|
1580
|
-
cliOptions: {},
|
|
1581
1652
|
afterCliOptions: [],
|
|
1582
1653
|
_silgiConfigs: [],
|
|
1583
1654
|
customContent: [],
|
|
1584
1655
|
importItems
|
|
1585
1656
|
};
|
|
1586
|
-
for (const module of silgi.scanModules) {
|
|
1587
|
-
if (module.meta.cliToRuntimeOptionsKeys && module.meta.cliToRuntimeOptionsKeys?.length > 0) {
|
|
1588
|
-
for (const key of module.meta.cliToRuntimeOptionsKeys) {
|
|
1589
|
-
_data.cliOptions[module.meta.configKey] = {
|
|
1590
|
-
..._data.cliOptions[module.meta.configKey],
|
|
1591
|
-
[key]: module.options[key]
|
|
1592
|
-
};
|
|
1593
|
-
}
|
|
1594
|
-
} else {
|
|
1595
|
-
_data.cliOptions[module.meta.configKey] = {};
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
1657
|
await silgi.callHook("prepare:core.ts", _data);
|
|
1599
1658
|
if (importItems["#silgi/vfs"].import.length === 0) {
|
|
1600
1659
|
delete importItems["#silgi/vfs"];
|
|
@@ -1614,9 +1673,6 @@ async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
|
1614
1673
|
""
|
|
1615
1674
|
];
|
|
1616
1675
|
const importData = [
|
|
1617
|
-
`export const cliOptions: Partial<SilgiRuntimeOptions> = ${JSON.stringify(_data.cliOptions, null, 2)}`,
|
|
1618
|
-
"",
|
|
1619
|
-
..._data.afterCliOptions,
|
|
1620
1676
|
"",
|
|
1621
1677
|
"export async function buildSilgi(framework: FrameworkContext, moduleOptions?: Partial<SilgiRuntimeOptions>,buildOptions?: Partial<BuildConfig>) {",
|
|
1622
1678
|
"",
|
|
@@ -1639,7 +1695,7 @@ async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
|
1639
1695
|
" moduleOptions || {},",
|
|
1640
1696
|
" {",
|
|
1641
1697
|
` present: '${silgi.options.preset}',`,
|
|
1642
|
-
" ...
|
|
1698
|
+
" ...cliConfigs,",
|
|
1643
1699
|
" },",
|
|
1644
1700
|
" ) as any,",
|
|
1645
1701
|
" })",
|
|
@@ -1722,12 +1778,17 @@ async function writeCoreFile(silgi) {
|
|
|
1722
1778
|
_importItems: data?.importItems ?? {},
|
|
1723
1779
|
_customImports: data?.customImports ?? []
|
|
1724
1780
|
}, data?.content ?? [], silgi);
|
|
1781
|
+
const configs = await prepareConfigs(silgi);
|
|
1725
1782
|
const silgiDir = resolve(silgi.options.silgi.serverDir);
|
|
1726
1783
|
const buildFiles = [];
|
|
1727
1784
|
buildFiles.push({
|
|
1728
1785
|
path: join(silgiDir, "core.ts"),
|
|
1729
1786
|
contents: coreContent.join("\n")
|
|
1730
1787
|
});
|
|
1788
|
+
buildFiles.push({
|
|
1789
|
+
path: join(silgiDir, "configs.ts"),
|
|
1790
|
+
contents: configs.join("\n")
|
|
1791
|
+
});
|
|
1731
1792
|
for await (const file of buildFiles) {
|
|
1732
1793
|
await writeFile(
|
|
1733
1794
|
resolve(silgi.options.build.dir, file.path),
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -154,9 +154,6 @@ interface PrepareCore extends ImportItem {
|
|
|
154
154
|
value: string;
|
|
155
155
|
type: 'function' | 'variable';
|
|
156
156
|
}[];
|
|
157
|
-
cliOptions: {
|
|
158
|
-
[key: string]: any;
|
|
159
|
-
};
|
|
160
157
|
afterCliOptions: string[];
|
|
161
158
|
_silgiConfigs: any[];
|
|
162
159
|
}
|
|
@@ -255,6 +252,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
255
252
|
'prepare:schema.ts': (options: SchemaPreparationOptions) => HookResult;
|
|
256
253
|
'after:prepare:schema.ts': (content: string[]) => HookResult;
|
|
257
254
|
'prepare:framework.d.ts': (options: {} & ImportItem) => HookResult;
|
|
255
|
+
'prepare:configs.ts': (cliOptions: Record<string, any>) => HookResult;
|
|
258
256
|
/**
|
|
259
257
|
* Called during `SilgiCLI` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.nuxt`).
|
|
260
258
|
* @param app The configured `SilgiCLI` object
|
package/dist/types/index.d.ts
CHANGED
|
@@ -154,9 +154,6 @@ interface PrepareCore extends ImportItem {
|
|
|
154
154
|
value: string;
|
|
155
155
|
type: 'function' | 'variable';
|
|
156
156
|
}[];
|
|
157
|
-
cliOptions: {
|
|
158
|
-
[key: string]: any;
|
|
159
|
-
};
|
|
160
157
|
afterCliOptions: string[];
|
|
161
158
|
_silgiConfigs: any[];
|
|
162
159
|
}
|
|
@@ -255,6 +252,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
255
252
|
'prepare:schema.ts': (options: SchemaPreparationOptions) => HookResult;
|
|
256
253
|
'after:prepare:schema.ts': (content: string[]) => HookResult;
|
|
257
254
|
'prepare:framework.d.ts': (options: {} & ImportItem) => HookResult;
|
|
255
|
+
'prepare:configs.ts': (cliOptions: Record<string, any>) => HookResult;
|
|
258
256
|
/**
|
|
259
257
|
* Called during `SilgiCLI` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.nuxt`).
|
|
260
258
|
* @param app The configured `SilgiCLI` object
|