{"id":18381,"library":"gemini-configparser","title":"gemini-configparser","description":"A configuration parser module for the Gemini (testplane) testing framework, version 1.4.2. It provides a declarative way to define configuration schemas using composable functions like `option`, `section`, `map`, and `root`. Supports parsing from CLI arguments, environment variables, and objects with validation and transformation. Differentiates from alternatives like `convict` by being tightly integrated with Gemini/testplane and offering a nested structure with functions.","status":"active","version":"1.4.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install gemini-configparser","lang":"bash","label":"npm"},{"cmd":"yarn add gemini-configparser","lang":"bash","label":"yarn"},{"cmd":"pnpm add gemini-configparser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import is not supported; use named import.","wrong":"import option from 'gemini-configparser'","symbol":"option","correct":"import { option } from 'gemini-configparser'"},{"note":"CommonJS require works but TypeScript prefers import.","wrong":"const section = require('gemini-configparser').section","symbol":"section","correct":"import { section } from 'gemini-configparser'"},{"note":"map is a named export, not a submodule.","wrong":"const map = require('gemini-configparser/map')","symbol":"map","correct":"import { map } from 'gemini-configparser'"},{"note":"root is exported as named export.","wrong":"const root = require('gemini-configparser').root","symbol":"root","correct":"import { root } from 'gemini-configparser'"}],"quickstart":{"code":"import { root, section, option } from 'gemini-configparser';\n\nconst configParser = root(section({\n  server: section({\n    port: option({\n      defaultValue: 8080,\n      parseEnv: Number,\n      parseCli: Number,\n      validate: (v) => { if (v < 0) throw new Error('port must be positive'); }\n    }),\n    host: option({\n      defaultValue: 'localhost',\n      parseEnv: String,\n      parseCli: String\n    })\n  })\n}), {\n  envPrefix: 'MY_APP_',\n  cliPrefix: '--'\n});\n\nconst config = configParser({\n  options: { server: { port: 3000 } },\n  env: { MY_APP_SERVER_HOST: '0.0.0.0' },\n  argv: ['--server:port', '4000']\n});\n\nconsole.log(config); // { server: { port: 4000, host: '0.0.0.0' } }","lang":"typescript","description":"Defines a config parser with nested sections, options with defaults and validation, then parses from options, env, and CLI arguments."},"warnings":[{"fix":"Include all possible keys in the section definition.","message":"All keys in the schema must be defined; unknown keys in input will be treated as errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Wrap with Number() or String() as shown in quickstart.","message":"parseCli and parseEnv functions are applied to the raw string value; ensure they handle strings correctly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you need a dynamic default, provide a function: defaultValue: (config, node) => ...","message":"defaultValue can be a function receiving config and currentNode for dynamic defaults.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Remove the unknown key from input or add it to the section definition.","cause":"Input data contains a key not defined in the schema.","error":"Error: Unknown field 'extraField'"},{"fix":"Ensure parseEnv/parseCli functions return the correct type; e.g., Number(rawValue) for numbers.","cause":"parseEnv or parseCli returns a non-number when Number is expected.","error":"Error: Expected number, got string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}