silgi 0.25.4 → 0.25.5

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.
@@ -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.5";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -1584,6 +1584,47 @@ function useCLIRuntimeConfig(silgi) {
1584
1584
  data.runtimeConfig = safeRuntimeConfig;
1585
1585
  silgi.options.envOptions = silgi.options.envOptions;
1586
1586
  });
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
+ addTemplate({
1599
+ filename: "env.example",
1600
+ write: true,
1601
+ where: ".silgi",
1602
+ getContents() {
1603
+ console.log("Generating env.example");
1604
+ const flattenedConfig = flattenObject(safeRuntimeConfig);
1605
+ 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] = {};
1612
+ }
1613
+ groupedVars[mainCategory][key] = value;
1614
+ } else {
1615
+ if (!groupedVars.OTHER) {
1616
+ groupedVars.OTHER = {};
1617
+ }
1618
+ groupedVars.OTHER[key] = value;
1619
+ }
1620
+ });
1621
+ return Object.entries(groupedVars).map(([category, vars]) => {
1622
+ const varsContent = Object.entries(vars).map(([key, value]) => `${key}=${value}`).join("\n");
1623
+ return `# ${category}
1624
+ ${varsContent}`;
1625
+ }).join("\n\n");
1626
+ }
1627
+ });
1587
1628
  const _sharedRuntimeConfig = initRuntimeConfig(silgi.options.envOptions, silgi.options.runtimeConfig);
1588
1629
  silgi.options.runtimeConfig = safeRuntimeConfig;
1589
1630
  return _sharedRuntimeConfig;
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.5",
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",