{"id":20105079,"url":"https://github.com/jdee/fastlane-plugin-patch","last_synced_at":"2025-05-06T09:31:05.578Z","repository":{"id":56845882,"uuid":"97991117","full_name":"jdee/fastlane-plugin-patch","owner":"jdee","description":"Fastlane plugin to patch text files","archived":false,"fork":false,"pushed_at":"2017-11-09T01:10:09.000Z","size":170,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-30T18:18:53.113Z","etag":null,"topics":["fastlane-plugin"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdee.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}},"created_at":"2017-07-21T22:29:46.000Z","updated_at":"2021-04-22T07:53:47.000Z","dependencies_parsed_at":"2022-09-17T21:53:09.969Z","dependency_job_id":null,"html_url":"https://github.com/jdee/fastlane-plugin-patch","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdee%2Ffastlane-plugin-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdee%2Ffastlane-plugin-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdee%2Ffastlane-plugin-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdee%2Ffastlane-plugin-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdee","download_url":"https://codeload.github.com/jdee/fastlane-plugin-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224498991,"owners_count":17321591,"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":["fastlane-plugin"],"created_at":"2024-11-13T17:45:45.381Z","updated_at":"2024-11-13T17:45:46.047Z","avatar_url":"https://github.com/jdee.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# patch plugin\n\n[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-patch)\n[![Gem](https://img.shields.io/gem/v/fastlane-plugin-patch.svg?style=flat)](https://rubygems.org/gems/fastlane-plugin-patch)\n[![Downloads](https://img.shields.io/gem/dt/fastlane-plugin-patch.svg?style=flat)](https://rubygems.org/gems/fastlane-plugin-patch)\n[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/jdee/fastlane-plugin-patch/blob/master/LICENSE)\n[![CircleCI](https://img.shields.io/circleci/project/github/jdee/fastlane-plugin-patch.svg)](https://circleci.com/gh/jdee/fastlane-plugin-patch)\n\n## Getting Started\n\nThis project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-patch`, add it to your project by running:\n\n```bash\nfastlane add_plugin patch\n```\n\n## About patch\n\nApply and revert pattern-based patches to any text file.\n\nThis is a very preliminary plugin to apply and revert patches to text files. One\nof the main intended use cases for this plugin is source-code modification, e.g.\nwhen automatically integrating an SDK.\n\nPlease provide any feedback via issues in this repo.\n\n### patch action\n\n```Ruby\npatch(\n  files: \"examples/PatchTestAndroid/app/src/main/AndroidManifest.xml\",\n  regexp: %r{^\\s*\u003c/application\u003e},\n  mode: :prepend,\n  text: \"        \u003cmeta-data android:name=\\\"foo\\\" android:value=\\\"bar\\\" /\u003e\\n\"\n)\n```\n\nThis action matches one or all occurrences of a specified regular expression and\nmodifies the file contents based on the optional `:mode` parameter. By default,\nthe action appends the specified text to the pattern match. It can also prepend\nthe text or replace the pattern match with the text. Use an optional `:global`\nparameter to apply the patch to all instances of the regular expression.\n\nThe `regexp`, `text`, `mode` and `global` options may be specified in a YAML file to\ndefine a patch, e.g.:\n\n**patch.yaml**:\n```yaml\nregexp: '^\\s*\u003c/application\u003e'\nmode: prepend\ntext: \"        \u003cmeta-data android:name='foo' android:value='bar' /\u003e\\n\"\nglobal: false\n```\n\n**Fastfile**:\n```Ruby\npatch(\n  files: \"examples/PatchTestAndroid/app/src/main/AndroidManifest.xml\",\n  patch: \"patch.yaml\"\n)\n```\n\n#### Capture groups\n\nCapture groups may be used within the text argument in any mode. Note that\nthis works best without interpolation (single quotes or %q). If you use double\nquotes, the backslash must be escaped, e.g. `text: \"\\\\1\\\"MyOtherpod\\\"\"`.\n\n```Ruby\npatch(\n  files: \"MyPod.podspec\",\n  regexp: /(s\\.name\\s*=\\s*)\"MyPod\"/,\n  text: '\\1\"MyOtherPod\"',\n  mode: :replace\n)\n```\n\nPatches in `:append` mode using capture groups in the text argument may be\nreverted. This is not currently supported in `:prepend` mode.\n\n#### Revert patches\n\nRevert patches by passing the optional `:revert` parameter:\n\n```Ruby\npatch(\n  files: \"examples/PatchTestAndroid/app/src/main/AndroidManifest.xml\",\n  regexp: %r{^\\s*\u003c/application\u003e},\n  mode: :prepend,\n  text: \"        \u003cmeta-data android:name=\\\"foo\\\" android:value=\\\"bar\\\" /\u003e\\n\",\n  revert: true\n)\n```\n\n```Ruby\npatch(\n  files: \"examples/PatchTestAndroid/app/src/main/AndroidManifest.xml\",\n  patch: \"patch.yaml\"\n  revert: true\n)\n```\n\nPatches using the `:replace` mode cannot be reverted.\n\n### Options\n\n|key|description|type|optional|default value|\n|---|-----------|----|--------|-------------|\n|:files|Absolute or relative path(s) to one or more files to patch|Array or String|no| |\n|:regexp|A regular expression to match|Regexp|yes| |\n|:text|Text to append to the match|String|yes| |\n|:global|If true, patch all occurrences of the pattern|Boolean|yes|false|\n|:mode|:append, :prepend or :replace|Symbol|yes|:append|\n|:offset|Offset from which to start matching|Integer|yes|0|\n|:patch|A YAML file specifying patch data|String|yes| |\n|:revert|Set to true to revert the specified patch rather than apply it|Boolean|yes|false|\n\nThe :regexp and :text options must be set either in a patch file specified using the\n:patch argument or via arguments in the Fastfile.\n\n**Note**: The `apply_patch` and `revert_patch` actions have been deprecated in favor of a single\n`patch` action with an optional `:revert` parameter.\n\n## Example\n\nCheck out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, and running `fastlane install_plugins`.\n\nThe examples folder contains an empty Android project called PatchTestAndroid. There is an example\npatch at the repo root in `patch.yaml` that will add a `meta-data` key to the end of the `application`\nelement in the Android project's manifest. The Fastfile includes two lanes: `apply` and `revert`.\n\nApply the patch to `examples/PatchTestAndroid/app/src/main/AndroidManifest.xml`:\n```bash\nfastlane apply\n```\n\nRevert the patch:\n```bash\nfastlane revert\n```\n\n## Run tests for this plugin\n\nTo run both the tests, and code style validation, run\n\n```\nrake\n```\n\nTo automatically fix many of the styling issues, use\n```\nrubocop -a\n```\n\n## Issues and Feedback\n\nFor any other issues and feedback about this plugin, please submit it to this repository.\n\n## Troubleshooting\n\nIf you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.\n\n## Using _fastlane_ Plugins\n\nFor more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).\n\n## About _fastlane_\n\n_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdee%2Ffastlane-plugin-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdee%2Ffastlane-plugin-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdee%2Ffastlane-plugin-patch/lists"}