{"id":18263852,"url":"https://github.com/atomist/yaml-updater","last_synced_at":"2025-07-05T15:14:45.373Z","repository":{"id":45229653,"uuid":"100739637","full_name":"atomist/yaml-updater","owner":"atomist","description":"Clean updates to YAML files","archived":false,"fork":false,"pushed_at":"2021-12-30T00:00:55.000Z","size":590,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-20T19:07:39.252Z","etag":null,"topics":["node"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomist.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2017-08-18T18:26:08.000Z","updated_at":"2024-08-09T23:03:35.000Z","dependencies_parsed_at":"2022-09-05T18:12:17.981Z","dependency_job_id":null,"html_url":"https://github.com/atomist/yaml-updater","commit_stats":null,"previous_names":[],"tags_count":100,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomist%2Fyaml-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomist%2Fyaml-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomist%2Fyaml-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomist%2Fyaml-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomist","download_url":"https://codeload.github.com/atomist/yaml-updater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247246402,"owners_count":20907789,"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":["node"],"created_at":"2024-11-05T11:12:54.627Z","updated_at":"2025-04-04T20:31:24.677Z","avatar_url":"https://github.com/atomist.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @atomist/yaml-updater\n\n[![atomist sdm goals](http://badge.atomist.com/T29E48P34/atomist/yaml-updater/00cff505-6345-430a-b615-382c43c7eb1a)](https://app.atomist.com/workspace/T29E48P34)\n[![npm version](https://img.shields.io/npm/v/@atomist/yaml-updater.svg)](https://www.npmjs.com/package/@atomist/yaml-updater)\n\n[Node][node] [TypeScript][ts] module\n[`@atomist/yaml-updater`][yaml-updater] for creating clean changes to\nYAML files producing reasonable diffs from the original.  This module\nwas originally developed for use with [Atomist][atomist] [code\ntransforms][docs].\n\n[node]: https://nodejs.org/\n[ts]: https://www.typescriptlang.org/\n[yaml-updater]: https://www.npmjs.com/package/@atomist/yaml-updater\n[docs]: https://docs.atomist.com/\n\n## Using\n\nAdd this package to your package's dependencies.\n\n```\n$ npm install @atomist/yaml-updater\n```\n\nThis module defines and exports several functions for formatting and\nupdating YAML.  The published module contains the TypeScript type\ndefinitions.  To use from TypeScript, import the functions you want to\nuse.  For example:\n\n```typescript\nimport { updateYamlDocument } from \"@atomist/yaml-updater\";\n```\n\nEach function is documented using [TypeDoc][typedoc], which are\npublished at [https://atomist.github.io/yaml-updater/][gh-pages].\nThe [tests][] are pretty complete and a great source of examples for\nwhat functions are available and how to use them.\n\nIn general, updating a property value adds property and value if it\ndoes not exist.  If the property does exist in the original YAML, its\nvalue will be updated.  If its current value is an object, the value\nwill be recursively updated, resulting in nested properties being\nadd/updated without affecting elements of the original YAML that do\nnot appear in the updates.  If the updated value is `null` or\n`undefined`, the key and value will be removed from the YAML if it\nexists.  If it does not exist, there will be no change.\n\nMost functions take an optional last `options` parameter that is an\nobject.  Currently the only `options` object parameter used all the\nupdate functions is \"keepArrayIndent\".  If the value of that property\nis true, the resulting YAML will have arrays indented compared to\ntheir parent object.  If the value is false, the indentation of the\narray will be at the same level as its parent object.  For example, if\n`keepArrayIndent: true`, you will get\n\n```yaml\nparent:\n  - first array item\n  - second array item\n```\n\nwhile if `keepArrayIndent: false`, you will get\n\n```yaml\nparent:\n- first array item\n- second array item\n```\n\nBoth are valid YAML and equivalent representation of the same data\nstructure.  Note that only arrays that are updated in some way will be\nmodified, so we recommend you base the value for this option on the\nformat of the original YAML document you are updating.\n\nThe `updateYamlDocuments` function also uses the \"updateAll\" `options`\nproperty.  If `true`, the `updates` provided to `updateYamlDocuments`\nwill be applied to all YAML documents.  If `false`, the `updates` will\nonly be applied to YAML documents with keys that match those in the\n`updates` object.  For example, given the following YAML:\n\n```yaml\n---\nfirst: element\nsecond: element\n---\nfirst: thing\nsecond: thing\nthird: thing\n```\n\ncalling\n\n```typescript\nconst updated = updateYamlDocuments({ third: \"item\" }, docs, { updateAll: false });\n```\n\nwith `docs` being the above YAML documents, would result in:\n\n```yaml\n---\nfirst: element\nsecond: element\n---\nfirst: thing\nsecond: thing\nthird: item\n```\n\nwhile calling\n\n```typescript\nconst updated = updateYamlDocuments({ third: \"item\" }, docs, { updateAll: true });\n```\n\nwould result in:\n\n```yaml\n---\nfirst: element\nsecond: element\nthird: item\n---\nfirst: thing\nsecond: thing\nthird: item\n```\n\n[typedoc]: http://typedoc.org/ (TypeDoc)\n[gh-pages]: https://atomist.github.io/yaml-updater/ (@atomist/yaml-updater TypeDocs)\n[tests]: src/yaml.test.ts (yaml-updater Tests)\n\n## Support\n\nGeneral support questions should be discussed in the `#help`\nchannel in the [Atomist community Slack workspace][slack].\n\nIf you find a problem, please create an [issue][].\n\n[issue]: https://github.com/atomist/yaml-updater/issues\n\n## Development\n\nYou will need to install [Node.js][node] to build and test this\nproject.\n\n[node]: https://nodejs.org/ (Node.js)\n\n### Build and test\n\nInstall dependencies.\n\n```\n$ npm install\n```\n\nUse the `build` package script to compile, test, lint, and build the\ndocumentation.\n\n```\n$ npm run build\n```\n\n### Release\n\nReleases are handled via the [Atomist SDM][atomist-sdm].  Just press\nthe 'Approve' button in the Atomist dashboard or Slack.\n\n[atomist-sdm]: https://github.com/atomist/atomist-sdm (Atomist Software Delivery Machine)\n\n---\n\nCreated by [Atomist][atomist].\nNeed Help?  [Join our Slack workspace][slack].\n\n[atomist]: https://atomist.com/ (Atomist - How Teams Deliver Software)\n[slack]: https://join.atomist.com/ (Atomist Community Slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomist%2Fyaml-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomist%2Fyaml-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomist%2Fyaml-updater/lists"}