silgi 0.25.5 → 0.25.6

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 CHANGED
@@ -28,6 +28,7 @@ import '@oxc-parser/wasm';
28
28
  import 'klona';
29
29
  import 'silgi/runtime';
30
30
  import 'unstorage';
31
+ import 'scule';
31
32
  import './cli/types.mjs';
32
33
  import 'c12';
33
34
  import 'compatx';
package/dist/cli/dev.mjs CHANGED
@@ -34,6 +34,7 @@ import '@oxc-parser/wasm';
34
34
  import 'klona';
35
35
  import 'silgi/runtime';
36
36
  import 'unstorage';
37
+ import 'scule';
37
38
  import './types.mjs';
38
39
  import 'c12';
39
40
  import 'compatx';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.25.5";
4
+ const version = "0.25.6";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -32,6 +32,7 @@ import '@oxc-parser/wasm';
32
32
  import 'klona';
33
33
  import 'silgi/runtime';
34
34
  import 'unstorage';
35
+ import 'scule';
35
36
  import 'pathe/utils';
36
37
  import 'picocolors';
37
38
  import '../_chunks/silgiApp.mjs';
@@ -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,14 @@ 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 parts = key.split("_");
1608
- if (parts.length >= 2) {
1609
- const mainCategory = parts[1];
1610
- if (!groupedVars[mainCategory]) {
1611
- groupedVars[mainCategory] = {};
1596
+ Object.entries(flattenedConfig).forEach(([key, { value, originalPath }]) => {
1597
+ if (originalPath.length > 0) {
1598
+ const firstKey = originalPath[0];
1599
+ const categoryName = extractCategoryFromCamel(firstKey);
1600
+ if (!groupedVars[categoryName]) {
1601
+ groupedVars[categoryName] = {};
1612
1602
  }
1613
- groupedVars[mainCategory][key] = value;
1603
+ groupedVars[categoryName][key] = value;
1614
1604
  } else {
1615
1605
  if (!groupedVars.OTHER) {
1616
1606
  groupedVars.OTHER = {};
@@ -1629,6 +1619,28 @@ ${varsContent}`;
1629
1619
  silgi.options.runtimeConfig = safeRuntimeConfig;
1630
1620
  return _sharedRuntimeConfig;
1631
1621
  }
1622
+ function extractCategoryFromCamel(str) {
1623
+ if (/^[a-z]+[A-Z]/.test(str)) {
1624
+ const matches = str.match(/^([a-z]+)([A-Z][a-z0-9]*)?/);
1625
+ if (matches && matches[2]) {
1626
+ return `${matches[1].toUpperCase()}_${matches[2].toUpperCase()}`;
1627
+ }
1628
+ }
1629
+ return str.toUpperCase();
1630
+ }
1631
+ function flattenObject(obj, prefix = "SILGI", originalPath = []) {
1632
+ return Object.entries(obj).reduce((acc, [key, value]) => {
1633
+ const formattedKey = snakeCase(key).toUpperCase();
1634
+ const newKey = `${prefix}_${formattedKey}`;
1635
+ const newPath = [...originalPath, key];
1636
+ if (typeof value === "object" && value !== null) {
1637
+ Object.assign(acc, flattenObject(value, newKey, newPath));
1638
+ } else {
1639
+ acc[newKey] = { value, originalPath: newPath };
1640
+ }
1641
+ return acc;
1642
+ }, {});
1643
+ }
1632
1644
 
1633
1645
  const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
1634
1646
  async function scanAndSyncOptions(silgi) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.25.5",
4
+ "version": "0.25.6",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {