silgi 0.25.5 → 0.25.7
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/build.mjs +1 -0
- package/dist/cli/dev.mjs +1 -0
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/install.mjs +1 -0
- package/dist/cli/types.mjs +8 -0
- package/dist/cli/writeTypesAndFiles.mjs +37 -18
- package/dist/types/index.d.mts +5 -0
- package/package.json +1 -1
package/dist/build.mjs
CHANGED
package/dist/cli/dev.mjs
CHANGED
package/dist/cli/index.mjs
CHANGED
package/dist/cli/install.mjs
CHANGED
package/dist/cli/types.mjs
CHANGED
|
@@ -55,6 +55,14 @@ const SilgiCLIDefaults = {
|
|
|
55
55
|
vfsDir: "{{ silgi.serverDir }}/vfs",
|
|
56
56
|
typesDir: "{{ silgi.serverDir }}/types"
|
|
57
57
|
},
|
|
58
|
+
// Codegen
|
|
59
|
+
codegen: {
|
|
60
|
+
env: {
|
|
61
|
+
safeList: [
|
|
62
|
+
["silgi", "version"]
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
58
66
|
// Modules
|
|
59
67
|
_modules: [],
|
|
60
68
|
modules: [],
|
|
@@ -26,6 +26,7 @@ import { klona } from 'klona';
|
|
|
26
26
|
import { useSilgiRuntimeConfig, initRuntimeConfig } from 'silgi/runtime';
|
|
27
27
|
import { createStorage, builtinDrivers } from 'unstorage';
|
|
28
28
|
import { peerDependencies } from 'silgi/meta';
|
|
29
|
+
import { snakeCase } from 'scule';
|
|
29
30
|
import { l as loadOptions, s as silgiGenerateType } from './types.mjs';
|
|
30
31
|
import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
31
32
|
|
|
@@ -1584,17 +1585,6 @@ function useCLIRuntimeConfig(silgi) {
|
|
|
1584
1585
|
data.runtimeConfig = safeRuntimeConfig;
|
|
1585
1586
|
silgi.options.envOptions = silgi.options.envOptions;
|
|
1586
1587
|
});
|
|
1587
|
-
function flattenObject(obj, prefix = "SILGI") {
|
|
1588
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
1589
|
-
const newKey = `${prefix}_${key.toUpperCase()}`;
|
|
1590
|
-
if (typeof value === "object" && value !== null) {
|
|
1591
|
-
Object.assign(acc, flattenObject(value, newKey));
|
|
1592
|
-
} else {
|
|
1593
|
-
acc[newKey] = value;
|
|
1594
|
-
}
|
|
1595
|
-
return acc;
|
|
1596
|
-
}, {});
|
|
1597
|
-
}
|
|
1598
1588
|
addTemplate({
|
|
1599
1589
|
filename: "env.example",
|
|
1600
1590
|
write: true,
|
|
@@ -1603,14 +1593,21 @@ function useCLIRuntimeConfig(silgi) {
|
|
|
1603
1593
|
console.log("Generating env.example");
|
|
1604
1594
|
const flattenedConfig = flattenObject(safeRuntimeConfig);
|
|
1605
1595
|
const groupedVars = {};
|
|
1606
|
-
Object.entries(flattenedConfig).forEach(([key, value]) => {
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1596
|
+
Object.entries(flattenedConfig).forEach(([key, { value, originalPath }]) => {
|
|
1597
|
+
const shouldExclude = silgi.options.codegen.env.safeList.some((safePath) => {
|
|
1598
|
+
if (safePath.length !== originalPath.length)
|
|
1599
|
+
return false;
|
|
1600
|
+
return safePath.every((segment, index) => segment.toLowerCase() === originalPath[index].toLowerCase());
|
|
1601
|
+
});
|
|
1602
|
+
if (shouldExclude)
|
|
1603
|
+
return;
|
|
1604
|
+
if (originalPath.length > 0) {
|
|
1605
|
+
const firstKey = originalPath[0];
|
|
1606
|
+
const categoryName = extractCategoryFromCamel(firstKey);
|
|
1607
|
+
if (!groupedVars[categoryName]) {
|
|
1608
|
+
groupedVars[categoryName] = {};
|
|
1612
1609
|
}
|
|
1613
|
-
groupedVars[
|
|
1610
|
+
groupedVars[categoryName][key] = value;
|
|
1614
1611
|
} else {
|
|
1615
1612
|
if (!groupedVars.OTHER) {
|
|
1616
1613
|
groupedVars.OTHER = {};
|
|
@@ -1629,6 +1626,28 @@ ${varsContent}`;
|
|
|
1629
1626
|
silgi.options.runtimeConfig = safeRuntimeConfig;
|
|
1630
1627
|
return _sharedRuntimeConfig;
|
|
1631
1628
|
}
|
|
1629
|
+
function extractCategoryFromCamel(str) {
|
|
1630
|
+
if (/^[a-z]+[A-Z]/.test(str)) {
|
|
1631
|
+
const matches = str.match(/^([a-z]+)([A-Z][a-z0-9]*)?/);
|
|
1632
|
+
if (matches && matches[2]) {
|
|
1633
|
+
return `${matches[1].toUpperCase()}_${matches[2].toUpperCase()}`;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
return str.toUpperCase();
|
|
1637
|
+
}
|
|
1638
|
+
function flattenObject(obj, prefix = "SILGI", originalPath = []) {
|
|
1639
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
1640
|
+
const formattedKey = snakeCase(key).toUpperCase();
|
|
1641
|
+
const newKey = `${prefix}_${formattedKey}`;
|
|
1642
|
+
const newPath = [...originalPath, key];
|
|
1643
|
+
if (typeof value === "object" && value !== null) {
|
|
1644
|
+
Object.assign(acc, flattenObject(value, newKey, newPath));
|
|
1645
|
+
} else {
|
|
1646
|
+
acc[newKey] = { value, originalPath: newPath };
|
|
1647
|
+
}
|
|
1648
|
+
return acc;
|
|
1649
|
+
}, {});
|
|
1650
|
+
}
|
|
1632
1651
|
|
|
1633
1652
|
const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
1634
1653
|
async function scanAndSyncOptions(silgi) {
|
package/dist/types/index.d.mts
CHANGED
|
@@ -602,6 +602,11 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
602
602
|
logLevel: LogLevel;
|
|
603
603
|
appConfig: AppConfig;
|
|
604
604
|
appConfigFiles: string[];
|
|
605
|
+
codegen: {
|
|
606
|
+
env: {
|
|
607
|
+
safeList: string[][];
|
|
608
|
+
};
|
|
609
|
+
};
|
|
605
610
|
storage: StorageMounts$1;
|
|
606
611
|
devStorage: StorageMounts$1;
|
|
607
612
|
workspaceDir: string;
|