{"id":21065093,"url":"https://github.com/prolificinteractive/data-builder","last_synced_at":"2025-03-14T01:43:09.992Z","repository":{"id":147516534,"uuid":"59771906","full_name":"prolificinteractive/data-builder","owner":"prolificinteractive","description":"A build tool for JSON and YAML that uses special keys to specify functions, i.e. $import.","archived":false,"fork":false,"pushed_at":"2016-06-28T22:16:19.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-14T15:22:15.926Z","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/prolificinteractive.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":"2016-05-26T18:01:54.000Z","updated_at":"2017-09-29T20:03:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"106b5693-7f2c-4ac5-9e64-5b3c74a640dd","html_url":"https://github.com/prolificinteractive/data-builder","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/prolificinteractive%2Fdata-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2Fdata-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2Fdata-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2Fdata-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prolificinteractive","download_url":"https://codeload.github.com/prolificinteractive/data-builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243508986,"owners_count":20302106,"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-11-19T17:53:34.510Z","updated_at":"2025-03-14T01:43:09.964Z","avatar_url":"https://github.com/prolificinteractive.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Builder\n\nData Builder is a simple preprocessor for JSON and YAML files that uses directive keys to apply functions. It's useful for composing large JSON and YAML files from smaller parts, for instance for Swagger specs.\n\n## Installation\n\n`npm install -g data-builder`\n\n## Usage\n\n### CLI\n\n`databuild path/to/file.yaml --format=yaml \u003e result.yaml`\n\n`--format` - Specifies the output format. It can be either `yaml` or `json`.\n\n### Library\n\nThis module exports a function, which takes a path to a file as its lone argument:\n\n```javascript\n'use strict';\n\nconst dataBuilder = require('data-builder');\n\ndataBuilder\n  .parseFile(__dirname + '/path/to/file.yaml')\n  .then(doStuffWithData)\n  .tap(doMoreStuffWithData);\n```\n\n## Directives API\n\nDirectives are keys that specify a function to perform at that path in the data structure.\n\nRight now, the tool only recognizes one directive, `$import`.\n\n### $import\n\nThe `$import` directive loads the specified file, relative to that file, and deeply extends the object at that location with the imported object. You can override keys by defining them explicitly before or after the `$import` directive.\n\nIt can also take an array of files, which will be loaded asynchronously (no guaranteed order) and merged.\n\n#### Merge Behavior\n\nWhen objects are imported, they will be merged passively (existing keys are not overridden). When arrays are imported, they will be concatenated if the existing value is an array. Any incompatible merging will result in the new value replacing the previous.\n\n#### Globs\n\nAs of 0.1, the library supports globbing via the [`node-glob` library](https://github.com/isaacs/node-glob), which will pull in files matching a pattern. This also works when you have an array of imports--it will simply expand the globbed files into the array.\n\n#### Example\n\n`a.yaml`\n\n```yaml\nfoo:\n  bar:\n    $import: b.yaml\n    z: 300\n```\n\n`b.yaml`\n\n```yaml\nx: 100\ny: 200\n```\n\nResult:\n\n```yaml\nfoo:\n  bar:\n    x: 100\n    y: 200\n    z: 300\n```\n\n### Examples\n\nGo to the `examples` directory in the repo to see a fully working Swagger example.\n\n### Development\n\nJust run `npm test`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprolificinteractive%2Fdata-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprolificinteractive%2Fdata-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprolificinteractive%2Fdata-builder/lists"}