{"id":15945657,"url":"https://github.com/ig3/config","last_synced_at":"2025-05-14T11:15:41.953Z","repository":{"id":77186299,"uuid":"422320576","full_name":"ig3/config","owner":"ig3","description":"Config loader","archived":false,"fork":false,"pushed_at":"2024-07-06T13:54:02.000Z","size":233,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-25T20:24:35.207Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ig3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-28T18:50:29.000Z","updated_at":"2024-07-06T13:54:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"e6392cf9-1026-4e6a-805d-0de84ac7f156","html_url":"https://github.com/ig3/config","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ig3%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ig3","download_url":"https://codeload.github.com/ig3/config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239225765,"owners_count":19603162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-07T09:05:11.557Z","updated_at":"2025-02-17T02:41:41.777Z","avatar_url":"https://github.com/ig3.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @ig3/config\n\nThis packages loads configuration from command line, environment and a set\nof configuration files.\n\n## Install\n\n```\n$ npm install @ig3/config\n```\n\n## Usage\n\n```\nconst config = require('@ig3/config')();\nconsole.log(\"config: \", JSON.stringify(config, null, 2));\n```\n\nThe package exports a single function that takes an options argument and\nreturns a configuration object.\n\nConfiguration is read from defaults, one or more configuration files,\nenvironment variables beginning with the name of the program and command\nline arguments. The same parameter may appear more than once in which\ncase the later appearance overrides previous appearances.\n\n### Configuration\nOptions may be passed to the factory:\n\n```\nconst options = {};\nconst config = require('@ig3/config')(options);\n```\n\n#### debug (false)\nIf truthy, print debug messages to console.debug.\n\n```\noptions.debug = true;\n```\n\n#### defaults ({})\nDefault configuration parameters.\n\n```\noptions.defaults = {\n  option1: 'value1',\n  option2: 'value2',\n  option3: true,\n  option4: 1234\n};\n```\n\n#### argv (minimist)\nParsed arguments from process.argv, or wherever you like.\n\nIf not set, [minimist](https://github.com/substack/minimist) is used to\nparse the arguments.\n\n```\n  require('minimist')(process.argv.slice(2), {\n    string: ['config'],\n    boolean: ['debug'],\n    alias: {\n      config: ['C'],\n      debug: ['d']\n    }\n  });\n```\n\nFor example, to use nopt to process command line arguments:\n```\noptions.argv = nopt(knownOpts, shortHands, process.argv, 2);\n```\n\n#### name (path.basename(process.argv[1], '.js'))\nThe name of the program.\n\n```\noptions.name = 'myapp';\n```\n\n#### config (undefined)\nThe path of a config file to load. This file, if it exists, overrides all\nother config files from opts.paths.\n\n```\noptions.config = '/tmp/test/config.json';\n```\n\n#### paths\nThe paths to search for config files.\n\nDefault paths are:\n * /etc/\u0026lt;name\u003e\n * /etc/\u0026lt;name\u003e/config\n * /usr/local/etc/\u0026lt;name\u003e\n * /usr/local/etc/\u0026lt;name\u003e/config\n * ~/.config/\u0026lt;name\u003e\n * ~/.config/\u0026lt;name\u003e/config\n * ~/.\u0026lt;name\u003e\n * ~/.\u0026lt;name\u003e/config\n * .\u0026lt;name\u003e\n * \u0026lt;name\u003e\n\nThe path starting with '~' are dependent on the environment variable HOME\nbeing set. If it is not set, these paths will not be checked.\n\n```\noptions.paths = [\n  '/etc/myapp.json',\n  path.join(process.env.HOME, '.myapp.json'),\n  '.myapp.json'\n];\n```\n\nThe order of paths is significant. If multiple files are found their\ncontents are merged. If the same parameter appears in more than one file,\nthe value from files later in the list will override values from files\nearlier in the list.  in the list of paths will override those earlier in\nthe list.\n\n#### parsers The config file parsers.\n\nParsers for config files are selected by filename extension. If there is no\nextension, the parser for the last extension in option extensions is used.\n\n```\noptions.parsers = {\n  '.json5': JSON5.parse,\n  '.json': JSON.parse,\n  '.ini': ini.parse\n};\n```\n\n#### extensions\nAn array of extensions to try if a path does not end with an extension.\n\n```\noptions.extensions = [\n  '.ini',\n  '.xml',\n  '.json'\n];\n\n### Methods\n\nNone.\n\n## License\n\nMIT, see [LICENSE.md](http://github.com/ig3/agiloft-script/blob/master/LICENSE.md) for details.\n\n## Change Log\n\n### 0.2.2 - 20220331\n\nUpdate all dependencies.\n\n### 0.2.1 - 20220331\n\nFix the precedence of config option: command line; environment; options\n\n### 0.2.0\nRemove strop-json-comments and add JSON5.\n\n### 0.1.0\nAdd missing dependencies\n\n### 0.0.1\n\nInitial release\n\n### 0.2.3 - WIP\n * Update dependencies\n * Fix tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fig3%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fig3%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fig3%2Fconfig/lists"}