{"id":16698137,"url":"https://github.com/arlac77/config-expander","last_synced_at":"2025-04-10T02:55:23.355Z","repository":{"id":13251703,"uuid":"73998037","full_name":"arlac77/config-expander","owner":"arlac77","description":"expands configuration templates","archived":false,"fork":false,"pushed_at":"2025-03-31T14:23:24.000Z","size":2937,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T15:54:15.677Z","etag":null,"topics":["configuration"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arlac77.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-11-17T06:38:01.000Z","updated_at":"2025-03-31T14:23:27.000Z","dependencies_parsed_at":"2024-02-09T23:22:47.613Z","dependency_job_id":"eabd14b6-7da6-4260-b4cf-abfb87806d02","html_url":"https://github.com/arlac77/config-expander","commit_stats":{"total_commits":1626,"total_committers":9,"mean_commits":"180.66666666666666","dds":"0.10639606396063961","last_synced_commit":"8a2141b3d97c6c0e51112b3406c4a902d7e2ec6e"},"previous_names":[],"tags_count":140,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fconfig-expander","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fconfig-expander/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fconfig-expander/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fconfig-expander/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arlac77","download_url":"https://codeload.github.com/arlac77/config-expander/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248147484,"owners_count":21055540,"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":["configuration"],"created_at":"2024-10-12T17:50:56.889Z","updated_at":"2025-04-10T02:55:23.329Z","avatar_url":"https://github.com/arlac77.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/config-expander.svg)](https://www.npmjs.com/package/config-expander)\n[![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)\n[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\\\u0026label\\\u0026labelColor=blue\\\u0026color=555555)](https://typescriptlang.org)\n[![bundlejs](https://deno.bundlejs.com/?q=config-expander\\\u0026badge=detailed)](https://bundlejs.com/?q=config-expander)\n[![downloads](http://img.shields.io/npm/dm/config-expander.svg?style=flat-square)](https://npmjs.org/package/config-expander)\n[![GitHub Issues](https://img.shields.io/github/issues/arlac77/config-expander.svg?style=flat-square)](https://github.com/arlac77/config-expander/issues)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Fconfig-expander%2Fbadge\\\u0026style=flat)](https://actions-badge.atrox.dev/arlac77/config-expander/goto)\n[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/config-expander/badge.svg)](https://snyk.io/test/github/arlac77/config-expander)\n[![Coverage Status](https://coveralls.io/repos/arlac77/config-expander/badge.svg)](https://coveralls.io/github/arlac77/config-expander)\n\n## config-expander\n\nExpands expressions in config files\n\n# example\n\n## file.js\n\n\u003c!-- skip-example --\u003e\n\n```js\nimport { expand } from \"config-expander\";\n\n// expanding hole expressions at the value position (result key is a number)\nexpand({ key: \"${value + 1}\" }, { constants: { value: 77 } }).then(r =\u003e\n  console.log(JSON.stringify(r))\n);\n\n// calculate port numbers\nexpand({ constants: { base: 10000 }, http: { port: \"${base + 1}\" } }).then(r =\u003e\n  console.log(JSON.stringify(r))\n);\n\n// load config from file\nexpand(\"${include('tests/fixtures/other.json')}\").then(r =\u003e\n  console.log(JSON.stringify(r))\n);\n```\n\n## Output\n\n```json\n{ \"key\" : 78 }\n{ \"constants\": { \"base\": 10000 }, \"http\": { \"port\": 10001 }}\n{ \"key\": \"value from other\" }\n```\n\n# Examples\n\n## read config file (json)\n\n\u003c!-- skip-example --\u003e\n\n```js\nconst configuration await expand(\"${include('\" + '/path/to/the/config.json' + \"')}\")\n```\n\n## load key file\n\n```json\n{\n  \"ca\": \"${document(os.home + '/ca.pem')}\"\n}\n```\n\n## calculate port numbers\n\n```json\n{\n  \"http-port\": \"${base + 0}\",\n  \"https-port\": \"${base + 1}\"\n}\n```\n\n## conditions\n\n```json\n{\n  \"copy-cmd\": \"${os.platform == 'win32' ? 'copy' : 'cp'}\"\n}\n```\n\n# API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### Table of Contents\n\n*   [defaultConstants](#defaultconstants)\n    *   [Properties](#properties)\n*   [expand](#expand)\n    *   [Parameters](#parameters)\n*   [Context](#context)\n    *   [Properties](#properties-1)\n*   [Value](#value)\n    *   [Properties](#properties-2)\n*   [Apply](#apply)\n    *   [Parameters](#parameters-1)\n*   [ConfigFunction](#configfunction)\n    *   [Properties](#properties-3)\n*   [functions](#functions)\n    *   [include](#include)\n        *   [Parameters](#parameters-2)\n    *   [replace](#replace)\n        *   [Parameters](#parameters-3)\n    *   [toUpperCase](#touppercase)\n        *   [Parameters](#parameters-4)\n    *   [toLowerCase](#tolowercase)\n        *   [Parameters](#parameters-5)\n    *   [split](#split)\n        *   [Parameters](#parameters-6)\n    *   [encrypt](#encrypt)\n        *   [Parameters](#parameters-7)\n    *   [decrypt](#decrypt)\n        *   [Parameters](#parameters-8)\n    *   [spawn](#spawn)\n        *   [Parameters](#parameters-9)\n*   [merge](#merge)\n    *   [Parameters](#parameters-10)\n\n## defaultConstants\n\nPredefined constants\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### Properties\n\n*   `env` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** environment variables from process.env\n*   `os` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** os module\n*   `basedir` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** filesystem configuration start point\n\n## expand\n\nExpands expressions in a configuration object\n\n### Parameters\n\n*   `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** config source\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the options\n\n    *   `options.constants` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** additional constants\n    *   `options.default` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** default configuration\n    *   `options.functions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** additional functions\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u003c[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\u003e** resolves to the expanded configuration\n\n## Context\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### Properties\n\n*   `constants` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\n    *   `constants.basedir` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n    *   `constants.env` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n    *   `constants.os` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n*   `functions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\n## Value\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### Properties\n\n*   `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n*   `value` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\n## Apply\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n### Parameters\n\n*   `context` **[Context](#context)**\u0026#x20;\n*   `args` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[Value](#value)\u003e**\u0026#x20;\n\n## ConfigFunction\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### Properties\n\n*   `arguments` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e**\u0026#x20;\n*   `returns` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n*   `apply` **[Apply](#apply)**\u0026#x20;\n\n## functions\n\nknwon functions\n\n### include\n\nInclude definition form a file.\n\n#### Parameters\n\n*   `file` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file name to be included\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** content of the file\n\n### replace\n\nReplace string.\n\n#### Parameters\n\n*   `source` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** input value\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** replaced content\n\n### toUpperCase\n\nConvert string into upper case.\n\n#### Parameters\n\n*   `source` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** input value\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** uppercase result\n\n### toLowerCase\n\nConvert string into lower case.\n\n#### Parameters\n\n*   `source` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** input value\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** lowercase result\n\n### split\n\nSplit source string on pattern boundaries.\n\n#### Parameters\n\n*   `source` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n*   `pattern` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n\nReturns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e** separated source\n\n### encrypt\n\nEncrypt a plaintext value.\n\n#### Parameters\n\n*   `key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n*   `plaintext` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** input value\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** encrypted value\n\n### decrypt\n\nDecrypt a former encrypted string.\n\n#### Parameters\n\n*   `key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n*   `encrypted` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** plaintext\n\n### spawn\n\nCall executable.\n\n#### Parameters\n\n*   `executable` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** path\n*   `arguments` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e**\u0026#x20;\n*   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**\u0026#x20;\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** stdout\n\n## merge\n\nmerge from b into a\nWhen a and b are arrays of values only the none duplaces are appendend to a\n\n### Parameters\n\n*   `a` **any**\u0026#x20;\n*   `b` **any**\u0026#x20;\n\nReturns **any** merged b into a\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```shell\nnpm install config-expander\n```\n\n# license\n\nBSD-2-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Fconfig-expander","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farlac77%2Fconfig-expander","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Fconfig-expander/lists"}