This repository has been archived on 2021-07-15. You can view files and clone it, but cannot push or open issues or pull requests.
tyop/README.md

50 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2021-07-06 11:21:31 +00:00
# tyop
2021-07-06 11:24:02 +00:00
> **WARNING**: still in prototype stage...
2021-07-06 11:53:57 +00:00
Automate your mass typo updates.
2021-07-10 13:46:59 +00:00
2021-07-10 13:48:04 +00:00
## Run/Hack
```
$ python3 -m venv .venv && source .venv/bin/activate
$ pip install -r requirements.txt
$ python mymigration.py --yaml
```
2021-07-10 13:46:59 +00:00
## CLI
- **--reset**: run `git-checkout` on all of your glob matches and exit
- **--validate**: ensure your `Migration` sub-class is valid
- **--yaml**: tell `tyop` that it should try to load the YAML with [ruamel.yaml](https://yaml.readthedocs.io/en/latest/)
- **--debug**: enable debug logging
## Logic
- Match all files specified by the `GLOB` pattern and apply the following
- Check out main/master, `git-pull` and `git-checkout` for clean branch
- Feed matched file contents into `Migration` sub-class and show the diff
- Show a few diffs to make sure things are running smoothly and then apply to all matches
- Iterate through all matches and `git-commit`/`git-push` changes (Use `s` to skip changes)
## Example migration
```python
from tyop import Migration
class InternalTrueMigration(Migration):
GLOB = "~/.abra/apps/**/compose*.yml"
def migrate(self, compose):
try:
if "internal" in compose["networks"]:
compose["networks"]["internal"] = {"internal": True}
return compose
except Exception:
return compose
InternalTrueMigration()
```