silgi 0.25.4 → 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.4";
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,10 +1585,62 @@ function useCLIRuntimeConfig(silgi) {
1584
1585
  data.runtimeConfig = safeRuntimeConfig;
1585
1586
  silgi.options.envOptions = silgi.options.envOptions;
1586
1587
  });
1588
+ addTemplate({
1589
+ filename: "env.example",
1590
+ write: true,
1591
+ where: ".silgi",
1592
+ getContents() {
1593
+ console.log("Generating env.example");
1594
+ const flattenedConfig = flattenObject(safeRuntimeConfig);
1595
+ const groupedVars = {};
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] = {};
1602
+ }
1603
+ groupedVars[categoryName][key] = value;
1604
+ } else {
1605
+ if (!groupedVars.OTHER) {
1606
+ groupedVars.OTHER = {};
1607
+ }
1608
+ groupedVars.OTHER[key] = value;
1609
+ }
1610
+ });
1611
+ return Object.entries(groupedVars).map(([category, vars]) => {
1612
+ const varsContent = Object.entries(vars).map(([key, value]) => `${key}=${value}`).join("\n");
1613
+ return `# ${category}
1614
+ ${varsContent}`;
1615
+ }).join("\n\n");
1616
+ }
1617
+ });
1587
1618
  const _sharedRuntimeConfig = initRuntimeConfig(silgi.options.envOptions, silgi.options.runtimeConfig);
1588
1619
  silgi.options.runtimeConfig = safeRuntimeConfig;
1589
1620
  return _sharedRuntimeConfig;
1590
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
+ }
1591
1644
 
1592
1645
  const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
1593
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.4",
4
+ "version": "0.25.6",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {
@@ -107,8 +107,8 @@
107
107
  "@antfu/eslint-config": "^4.11.0",
108
108
  "@nuxt/kit": "^3.16.1",
109
109
  "@nuxt/schema": "^3.16.1",
110
- "@silgi/ecosystem": "^0.3.4",
111
- "@types/node": "^22.13.11",
110
+ "@silgi/ecosystem": "^0.4.4",
111
+ "@types/node": "^22.13.13",
112
112
  "@types/semver": "^7.5.8",
113
113
  "@vitest/coverage-v8": "3.0.5",
114
114
  "eslint": "^9.23.0",