silgi 0.10.3 → 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)
|
|
@@ -1525,19 +1535,58 @@ async function generateSilgiStorageBaseType(silgi) {
|
|
|
1525
1535
|
});
|
|
1526
1536
|
}
|
|
1527
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
|
+
|
|
1528
1562
|
async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
1529
1563
|
let importItems = {
|
|
1530
1564
|
"silgi/core": {
|
|
1531
1565
|
import: [
|
|
1532
|
-
{
|
|
1566
|
+
{
|
|
1567
|
+
name: "createSilgi",
|
|
1568
|
+
key: "createSilgi"
|
|
1569
|
+
}
|
|
1533
1570
|
],
|
|
1534
1571
|
from: "silgi/core"
|
|
1535
1572
|
},
|
|
1536
1573
|
"silgi/types": {
|
|
1537
1574
|
import: [
|
|
1538
|
-
{
|
|
1539
|
-
|
|
1540
|
-
|
|
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
|
+
}
|
|
1541
1590
|
],
|
|
1542
1591
|
from: "silgi/types"
|
|
1543
1592
|
},
|
|
@@ -1548,29 +1597,51 @@ async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
|
1548
1597
|
"silgi/runtime/internal/defu": {
|
|
1549
1598
|
import: [
|
|
1550
1599
|
{
|
|
1551
|
-
name: "mergeDeep"
|
|
1600
|
+
name: "mergeDeep",
|
|
1601
|
+
key: "mergeDeep"
|
|
1552
1602
|
}
|
|
1553
1603
|
],
|
|
1554
1604
|
from: "silgi/runtime/internal/defu"
|
|
1555
1605
|
},
|
|
1556
1606
|
"scan.ts": {
|
|
1557
|
-
import: [
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
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
|
+
],
|
|
1573
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"
|
|
1574
1645
|
}
|
|
1575
1646
|
};
|
|
1576
1647
|
importItems = { ...data._importItems, ...importItems };
|
|
@@ -1578,24 +1649,11 @@ async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
|
1578
1649
|
customImports: data._customImports || [],
|
|
1579
1650
|
buildSilgiExtraContent: [],
|
|
1580
1651
|
beforeBuildSilgiExtraContent: [],
|
|
1581
|
-
cliOptions: {},
|
|
1582
1652
|
afterCliOptions: [],
|
|
1583
1653
|
_silgiConfigs: [],
|
|
1584
1654
|
customContent: [],
|
|
1585
1655
|
importItems
|
|
1586
1656
|
};
|
|
1587
|
-
for (const module of silgi.scanModules) {
|
|
1588
|
-
if (module.meta.cliToRuntimeOptionsKeys && module.meta.cliToRuntimeOptionsKeys?.length > 0) {
|
|
1589
|
-
for (const key of module.meta.cliToRuntimeOptionsKeys) {
|
|
1590
|
-
_data.cliOptions[module.meta.configKey] = {
|
|
1591
|
-
..._data.cliOptions[module.meta.configKey],
|
|
1592
|
-
[key]: module.options[key]
|
|
1593
|
-
};
|
|
1594
|
-
}
|
|
1595
|
-
} else {
|
|
1596
|
-
_data.cliOptions[module.meta.configKey] = {};
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
1657
|
await silgi.callHook("prepare:core.ts", _data);
|
|
1600
1658
|
if (importItems["#silgi/vfs"].import.length === 0) {
|
|
1601
1659
|
delete importItems["#silgi/vfs"];
|
|
@@ -1615,9 +1673,6 @@ async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
|
1615
1673
|
""
|
|
1616
1674
|
];
|
|
1617
1675
|
const importData = [
|
|
1618
|
-
`export const cliOptions: Partial<SilgiRuntimeOptions> = ${JSON.stringify(_data.cliOptions, null, 2)}`,
|
|
1619
|
-
"",
|
|
1620
|
-
..._data.afterCliOptions,
|
|
1621
1676
|
"",
|
|
1622
1677
|
"export async function buildSilgi(framework: FrameworkContext, moduleOptions?: Partial<SilgiRuntimeOptions>,buildOptions?: Partial<BuildConfig>) {",
|
|
1623
1678
|
"",
|
|
@@ -1640,7 +1695,7 @@ async function prepareCoreFile(data, frameworkContext, silgi) {
|
|
|
1640
1695
|
" moduleOptions || {},",
|
|
1641
1696
|
" {",
|
|
1642
1697
|
` present: '${silgi.options.preset}',`,
|
|
1643
|
-
" ...
|
|
1698
|
+
" ...cliConfigs,",
|
|
1644
1699
|
" },",
|
|
1645
1700
|
" ) as any,",
|
|
1646
1701
|
" })",
|
|
@@ -1723,12 +1778,17 @@ async function writeCoreFile(silgi) {
|
|
|
1723
1778
|
_importItems: data?.importItems ?? {},
|
|
1724
1779
|
_customImports: data?.customImports ?? []
|
|
1725
1780
|
}, data?.content ?? [], silgi);
|
|
1781
|
+
const configs = await prepareConfigs(silgi);
|
|
1726
1782
|
const silgiDir = resolve(silgi.options.silgi.serverDir);
|
|
1727
1783
|
const buildFiles = [];
|
|
1728
1784
|
buildFiles.push({
|
|
1729
1785
|
path: join(silgiDir, "core.ts"),
|
|
1730
1786
|
contents: coreContent.join("\n")
|
|
1731
1787
|
});
|
|
1788
|
+
buildFiles.push({
|
|
1789
|
+
path: join(silgiDir, "configs.ts"),
|
|
1790
|
+
contents: configs.join("\n")
|
|
1791
|
+
});
|
|
1732
1792
|
for await (const file of buildFiles) {
|
|
1733
1793
|
await writeFile(
|
|
1734
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
|