dotstash 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dotstash-0.1.0/.github/workflows/publish.yml +73 -0
- dotstash-0.1.0/.gitignore +177 -0
- dotstash-0.1.0/.python-version +1 -0
- dotstash-0.1.0/AGENTS.md +128 -0
- dotstash-0.1.0/LICENSE.txt +8 -0
- dotstash-0.1.0/PKG-INFO +15 -0
- dotstash-0.1.0/README.md +0 -0
- dotstash-0.1.0/migrations/__init__.py +0 -0
- dotstash-0.1.0/migrations/env.py +64 -0
- dotstash-0.1.0/migrations/script.py.mako +23 -0
- dotstash-0.1.0/migrations/versions/001_initial_schema.py +87 -0
- dotstash-0.1.0/migrations/versions/__init__.py +0 -0
- dotstash-0.1.0/pyproject.toml +45 -0
- dotstash-0.1.0/stash/__init__.py +0 -0
- dotstash-0.1.0/stash/adopt.py +122 -0
- dotstash-0.1.0/stash/cleanup.py +65 -0
- dotstash-0.1.0/stash/config.py +26 -0
- dotstash-0.1.0/stash/database.py +23 -0
- dotstash-0.1.0/stash/db.py +45 -0
- dotstash-0.1.0/stash/formats.py +22 -0
- dotstash-0.1.0/stash/history.py +64 -0
- dotstash-0.1.0/stash/interactive_rollback.py +62 -0
- dotstash-0.1.0/stash/main.py +248 -0
- dotstash-0.1.0/stash/models.py +116 -0
- dotstash-0.1.0/stash/render.py +138 -0
- dotstash-0.1.0/stash/repositories.py +177 -0
- dotstash-0.1.0/stash/rollback.py +60 -0
- dotstash-0.1.0/stash/status.py +112 -0
- dotstash-0.1.0/test/assets/dotfiles/test_config/test_file.ini +2 -0
- dotstash-0.1.0/test/assets/dotfiles/test_config/test_file.json +3 -0
- dotstash-0.1.0/test/assets/formats/invalid.json +3 -0
- dotstash-0.1.0/test/assets/formats/invalid.yaml +2 -0
- dotstash-0.1.0/test/assets/formats/valid.json +3 -0
- dotstash-0.1.0/test/assets/formats/valid.yaml +2 -0
- dotstash-0.1.0/test/test_adopt.py +146 -0
- dotstash-0.1.0/test/test_clean.py +77 -0
- dotstash-0.1.0/test/test_formats.py +12 -0
- dotstash-0.1.0/test/test_history.py +115 -0
- dotstash-0.1.0/test/test_migrations.py +6 -0
- dotstash-0.1.0/test/test_models.py +30 -0
- dotstash-0.1.0/test/test_render.py +47 -0
- dotstash-0.1.0/test/test_render_hashing.py +48 -0
- dotstash-0.1.0/test/test_rollback.py +51 -0
- dotstash-0.1.0/test/test_status.py +93 -0
- dotstash-0.1.0/uv.lock +549 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
name: CI and Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- "v*"
|
|
9
|
+
pull_request:
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
checks:
|
|
14
|
+
name: Lint, Type, Test, Build
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Python
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version-file: ".python-version"
|
|
24
|
+
|
|
25
|
+
- name: Set up uv
|
|
26
|
+
uses: astral-sh/setup-uv@v5
|
|
27
|
+
with:
|
|
28
|
+
enable-cache: true
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: uv sync --locked --group dev
|
|
32
|
+
|
|
33
|
+
- name: Ruff lint
|
|
34
|
+
run: uv run ruff check .
|
|
35
|
+
|
|
36
|
+
- name: Ruff format check
|
|
37
|
+
run: uv run ruff format --check .
|
|
38
|
+
|
|
39
|
+
- name: Pyright
|
|
40
|
+
run: uv run pyright
|
|
41
|
+
|
|
42
|
+
- name: Pytest
|
|
43
|
+
run: uv run pytest
|
|
44
|
+
|
|
45
|
+
- name: Build
|
|
46
|
+
run: uv build
|
|
47
|
+
|
|
48
|
+
- name: Upload distributions
|
|
49
|
+
uses: actions/upload-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: python-package-distributions
|
|
52
|
+
path: dist/
|
|
53
|
+
|
|
54
|
+
publish:
|
|
55
|
+
name: Publish to PyPI
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
needs: checks
|
|
58
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
59
|
+
permissions:
|
|
60
|
+
id-token: write
|
|
61
|
+
contents: read
|
|
62
|
+
environment:
|
|
63
|
+
name: pypi
|
|
64
|
+
url: https://pypi.org/p/dotstash
|
|
65
|
+
steps:
|
|
66
|
+
- name: Download distributions
|
|
67
|
+
uses: actions/download-artifact@v4
|
|
68
|
+
with:
|
|
69
|
+
name: python-package-distributions
|
|
70
|
+
path: dist/
|
|
71
|
+
|
|
72
|
+
- name: Publish package distributions to PyPI
|
|
73
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Created by https://www.toptal.com/developers/gitignore/api/python
|
|
2
|
+
# Edit at https://www.toptal.com/developers/gitignore?templates=python
|
|
3
|
+
|
|
4
|
+
### Python ###
|
|
5
|
+
# Byte-compiled / optimized / DLL files
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*$py.class
|
|
9
|
+
|
|
10
|
+
# C extensions
|
|
11
|
+
*.so
|
|
12
|
+
|
|
13
|
+
# Distribution / packaging
|
|
14
|
+
.Python
|
|
15
|
+
build/
|
|
16
|
+
develop-eggs/
|
|
17
|
+
dist/
|
|
18
|
+
downloads/
|
|
19
|
+
eggs/
|
|
20
|
+
.eggs/
|
|
21
|
+
lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
wheels/
|
|
27
|
+
share/python-wheels/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
MANIFEST
|
|
32
|
+
|
|
33
|
+
# PyInstaller
|
|
34
|
+
# Usually these files are written by a python script from a template
|
|
35
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
36
|
+
*.manifest
|
|
37
|
+
*.spec
|
|
38
|
+
|
|
39
|
+
# Installer logs
|
|
40
|
+
pip-log.txt
|
|
41
|
+
pip-delete-this-directory.txt
|
|
42
|
+
|
|
43
|
+
# Unit test / coverage reports
|
|
44
|
+
htmlcov/
|
|
45
|
+
.tox/
|
|
46
|
+
.nox/
|
|
47
|
+
.coverage
|
|
48
|
+
.coverage.*
|
|
49
|
+
.cache
|
|
50
|
+
nosetests.xml
|
|
51
|
+
coverage.xml
|
|
52
|
+
*.cover
|
|
53
|
+
*.py,cover
|
|
54
|
+
.hypothesis/
|
|
55
|
+
.pytest_cache/
|
|
56
|
+
cover/
|
|
57
|
+
|
|
58
|
+
# Translations
|
|
59
|
+
*.mo
|
|
60
|
+
*.pot
|
|
61
|
+
|
|
62
|
+
# Django stuff:
|
|
63
|
+
*.log
|
|
64
|
+
local_settings.py
|
|
65
|
+
db.sqlite3
|
|
66
|
+
db.sqlite3-journal
|
|
67
|
+
|
|
68
|
+
# Flask stuff:
|
|
69
|
+
instance/
|
|
70
|
+
.webassets-cache
|
|
71
|
+
|
|
72
|
+
# Scrapy stuff:
|
|
73
|
+
.scrapy
|
|
74
|
+
|
|
75
|
+
# Sphinx documentation
|
|
76
|
+
docs/_build/
|
|
77
|
+
|
|
78
|
+
# PyBuilder
|
|
79
|
+
.pybuilder/
|
|
80
|
+
target/
|
|
81
|
+
|
|
82
|
+
# Jupyter Notebook
|
|
83
|
+
.ipynb_checkpoints
|
|
84
|
+
|
|
85
|
+
# IPython
|
|
86
|
+
profile_default/
|
|
87
|
+
ipython_config.py
|
|
88
|
+
|
|
89
|
+
# pyenv
|
|
90
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
91
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
92
|
+
# .python-version
|
|
93
|
+
|
|
94
|
+
# pipenv
|
|
95
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
96
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
97
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
98
|
+
# install all needed dependencies.
|
|
99
|
+
#Pipfile.lock
|
|
100
|
+
|
|
101
|
+
# poetry
|
|
102
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
103
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
104
|
+
# commonly ignored for libraries.
|
|
105
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
106
|
+
#poetry.lock
|
|
107
|
+
|
|
108
|
+
# pdm
|
|
109
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
110
|
+
#pdm.lock
|
|
111
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
112
|
+
# in version control.
|
|
113
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
114
|
+
.pdm.toml
|
|
115
|
+
|
|
116
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
117
|
+
__pypackages__/
|
|
118
|
+
|
|
119
|
+
# Celery stuff
|
|
120
|
+
celerybeat-schedule
|
|
121
|
+
celerybeat.pid
|
|
122
|
+
|
|
123
|
+
# SageMath parsed files
|
|
124
|
+
*.sage.py
|
|
125
|
+
|
|
126
|
+
# Environments
|
|
127
|
+
.env
|
|
128
|
+
.venv
|
|
129
|
+
env/
|
|
130
|
+
venv/
|
|
131
|
+
ENV/
|
|
132
|
+
env.bak/
|
|
133
|
+
venv.bak/
|
|
134
|
+
|
|
135
|
+
# Spyder project settings
|
|
136
|
+
.spyderproject
|
|
137
|
+
.spyproject
|
|
138
|
+
|
|
139
|
+
# Rope project settings
|
|
140
|
+
.ropeproject
|
|
141
|
+
|
|
142
|
+
# mkdocs documentation
|
|
143
|
+
/site
|
|
144
|
+
|
|
145
|
+
# mypy
|
|
146
|
+
.mypy_cache/
|
|
147
|
+
.dmypy.json
|
|
148
|
+
dmypy.json
|
|
149
|
+
|
|
150
|
+
# Pyre type checker
|
|
151
|
+
.pyre/
|
|
152
|
+
|
|
153
|
+
# pytype static type analyzer
|
|
154
|
+
.pytype/
|
|
155
|
+
|
|
156
|
+
# Cython debug symbols
|
|
157
|
+
cython_debug/
|
|
158
|
+
|
|
159
|
+
# PyCharm
|
|
160
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
161
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
162
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
163
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
164
|
+
#.idea/
|
|
165
|
+
|
|
166
|
+
### Python Patch ###
|
|
167
|
+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
|
168
|
+
poetry.toml
|
|
169
|
+
|
|
170
|
+
# ruff
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# LSP config files
|
|
174
|
+
pyrightconfig.json
|
|
175
|
+
|
|
176
|
+
# End of https://www.toptal.com/developers/gitignore/api/python
|
|
177
|
+
.envrc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
dotstash-0.1.0/AGENTS.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Repository Guidelines (stash)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
- This file guides agentic coding assistants working in this repo.
|
|
5
|
+
- Follow local patterns, keep changes minimal, and prefer explicit errors.
|
|
6
|
+
|
|
7
|
+
## Project Structure & Module Organization
|
|
8
|
+
- `stash/` holds application logic.
|
|
9
|
+
- `stash/main.py`: CLI entry, config loading, orchestration.
|
|
10
|
+
- `stash/render.py`: Jinja rendering + symlink wiring.
|
|
11
|
+
- `stash/formats.py`: format validation helpers.
|
|
12
|
+
- `stash/database.py`: Pydantic model stubs.
|
|
13
|
+
- `test/` contains pytest suites.
|
|
14
|
+
- `test/assets/` holds fixture templates and config inputs.
|
|
15
|
+
- `config.yaml` in repo root is sample config, not production.
|
|
16
|
+
|
|
17
|
+
## Environment & Dependencies
|
|
18
|
+
- Python version: `>=3.14` (see `.python-version`).
|
|
19
|
+
- Install dev deps (choose one):
|
|
20
|
+
- `pip install -e .[dev]`
|
|
21
|
+
- `uv sync`
|
|
22
|
+
- Script entrypoint: `stash` → `stash.main:main` (see `pyproject.toml`).
|
|
23
|
+
|
|
24
|
+
## Build, Lint, Type Check, Test
|
|
25
|
+
### Build
|
|
26
|
+
- Build distributions:
|
|
27
|
+
- `python -m build`
|
|
28
|
+
|
|
29
|
+
### Lint + Format (Ruff)
|
|
30
|
+
- Lint:
|
|
31
|
+
- `ruff check .`
|
|
32
|
+
- `ruff check --fix .` (apply auto-fixes)
|
|
33
|
+
- Format:
|
|
34
|
+
- `ruff format .`
|
|
35
|
+
- `ruff format --check .`
|
|
36
|
+
- `ruff format --diff .`
|
|
37
|
+
|
|
38
|
+
### Type Checking
|
|
39
|
+
- `pyright`
|
|
40
|
+
|
|
41
|
+
### Tests (Pytest)
|
|
42
|
+
- Run all tests:
|
|
43
|
+
- `pytest`
|
|
44
|
+
- Run a single file:
|
|
45
|
+
- `pytest test/test_render.py`
|
|
46
|
+
- `pytest test/test_formats.py`
|
|
47
|
+
- Run a single test:
|
|
48
|
+
- `pytest test/test_render.py::test_render`
|
|
49
|
+
- `pytest test/test_formats.py::test_json_validator`
|
|
50
|
+
- Run by name pattern:
|
|
51
|
+
- `pytest -k "render"`
|
|
52
|
+
- `pytest -k "json"`
|
|
53
|
+
- Re-run failed tests:
|
|
54
|
+
- `pytest --lf`
|
|
55
|
+
- `pytest --ff`
|
|
56
|
+
- Stop on first failure:
|
|
57
|
+
- `pytest -x`
|
|
58
|
+
- Verbose output:
|
|
59
|
+
- `pytest -v`
|
|
60
|
+
- `pytest -vv`
|
|
61
|
+
|
|
62
|
+
## Coding Style & Conventions
|
|
63
|
+
### Imports
|
|
64
|
+
- Standard library first, third-party second, local imports last.
|
|
65
|
+
- Prefer explicit imports over `import *`.
|
|
66
|
+
|
|
67
|
+
### Formatting
|
|
68
|
+
- 4-space indentation, no tabs.
|
|
69
|
+
- Keep lines readable; let `ruff format` enforce formatting.
|
|
70
|
+
- Avoid trailing whitespace and extra blank lines.
|
|
71
|
+
|
|
72
|
+
### Types
|
|
73
|
+
- Use type hints where practical (see `render.py`).
|
|
74
|
+
- Prefer concrete types (`dict[str, Any]`) over `dict`.
|
|
75
|
+
- Avoid type suppression (`as any`, `# type: ignore`).
|
|
76
|
+
|
|
77
|
+
### Naming
|
|
78
|
+
- Files: snake_case.
|
|
79
|
+
- Functions and variables: snake_case.
|
|
80
|
+
- Classes: PascalCase.
|
|
81
|
+
- Avoid one-letter variables unless in tiny local scopes.
|
|
82
|
+
|
|
83
|
+
### Path Handling
|
|
84
|
+
- Prefer `pathlib.Path` for filesystem operations.
|
|
85
|
+
- Use `Path.open()` and `Path.write_text()`.
|
|
86
|
+
|
|
87
|
+
### Error Handling
|
|
88
|
+
- Raise explicit errors for invalid config or invalid states.
|
|
89
|
+
- Do not swallow exceptions silently.
|
|
90
|
+
- Prefer explicit messaging for user-facing CLI errors.
|
|
91
|
+
|
|
92
|
+
### Logging/Output
|
|
93
|
+
- Current code uses `print()` for CLI output. Follow that pattern.
|
|
94
|
+
- If adding logging, keep it minimal and consistent.
|
|
95
|
+
|
|
96
|
+
## Template & Rendering Behavior
|
|
97
|
+
- Jinja environment uses `StrictUndefined` to surface missing variables.
|
|
98
|
+
- Rendered templates are written under render root and symlinked to targets.
|
|
99
|
+
- Avoid clobbering real directories; raise if target is a directory.
|
|
100
|
+
|
|
101
|
+
## Tests & Fixtures
|
|
102
|
+
- Tests live in `test/` and are named `test_*.py`.
|
|
103
|
+
- Fixture assets live in `test/assets/`.
|
|
104
|
+
- For new template features:
|
|
105
|
+
- Add sample templates under `test/assets/dotfiles/<module>/`.
|
|
106
|
+
- Assert renders exist under render root.
|
|
107
|
+
- Confirm targets are symlinks pointing to rendered files.
|
|
108
|
+
|
|
109
|
+
## Configuration & Safety
|
|
110
|
+
- Do not commit real secrets into fixtures or `config.yaml`.
|
|
111
|
+
- Avoid writing to real home directories in tests.
|
|
112
|
+
- Use `tmp_path` for filesystem fixtures in pytest.
|
|
113
|
+
|
|
114
|
+
## Repo-Specific Notes
|
|
115
|
+
- `pyproject.toml` is the single source of tool configuration.
|
|
116
|
+
- No `tox.ini`, `noxfile`, or `pytest.ini` present.
|
|
117
|
+
- No Cursor rules (`.cursor/rules/`, `.cursorrules`) found.
|
|
118
|
+
- No Copilot rules (`.github/copilot-instructions.md`) found.
|
|
119
|
+
|
|
120
|
+
## Change Management
|
|
121
|
+
- Keep changes minimal and scoped to the request.
|
|
122
|
+
- Avoid refactors when fixing a specific bug.
|
|
123
|
+
- Update tests when behavior changes.
|
|
124
|
+
|
|
125
|
+
## Validation Checklist
|
|
126
|
+
- Run relevant unit tests for touched modules.
|
|
127
|
+
- Run `ruff check .` and `ruff format .` after code changes.
|
|
128
|
+
- Run `pyright` if type-sensitive changes were made.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright 2026 Frede Hoey
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
+
|
dotstash-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dotstash
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A dotfile manager with template support
|
|
5
|
+
License-File: LICENSE.txt
|
|
6
|
+
Requires-Python: >=3.14
|
|
7
|
+
Requires-Dist: alembic>=1.18.1
|
|
8
|
+
Requires-Dist: inotify>=0.2.12
|
|
9
|
+
Requires-Dist: jinja2>=3.1.6
|
|
10
|
+
Requires-Dist: pydantic>=2.12.5
|
|
11
|
+
Requires-Dist: pytoml>=0.1.21
|
|
12
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
13
|
+
Requires-Dist: questionary>=2.1.0
|
|
14
|
+
Requires-Dist: rich>=13.9.4
|
|
15
|
+
Requires-Dist: sqlalchemy>=2.0.45
|
dotstash-0.1.0/README.md
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from logging.config import fileConfig
|
|
4
|
+
|
|
5
|
+
from alembic import context
|
|
6
|
+
from sqlalchemy import engine_from_config, pool
|
|
7
|
+
|
|
8
|
+
from stash.models import Base
|
|
9
|
+
|
|
10
|
+
config = context.config
|
|
11
|
+
|
|
12
|
+
if config.config_file_name is not None:
|
|
13
|
+
fileConfig(config.config_file_name)
|
|
14
|
+
|
|
15
|
+
target_metadata = Base.metadata
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _get_sqlalchemy_url() -> str:
|
|
19
|
+
url = config.get_main_option("sqlalchemy.url")
|
|
20
|
+
if not url:
|
|
21
|
+
raise RuntimeError("sqlalchemy.url is not configured for migrations")
|
|
22
|
+
return url
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def run_migrations_offline() -> None:
|
|
26
|
+
url = _get_sqlalchemy_url()
|
|
27
|
+
context.configure(
|
|
28
|
+
url=url,
|
|
29
|
+
target_metadata=target_metadata,
|
|
30
|
+
literal_binds=True,
|
|
31
|
+
render_as_batch=True,
|
|
32
|
+
compare_type=True,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
with context.begin_transaction():
|
|
36
|
+
context.run_migrations()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def run_migrations_online() -> None:
|
|
40
|
+
configuration = config.get_section(config.config_ini_section) or {}
|
|
41
|
+
configuration["sqlalchemy.url"] = _get_sqlalchemy_url()
|
|
42
|
+
|
|
43
|
+
connectable = engine_from_config(
|
|
44
|
+
configuration,
|
|
45
|
+
prefix="sqlalchemy.",
|
|
46
|
+
poolclass=pool.NullPool,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
with connectable.connect() as connection:
|
|
50
|
+
context.configure(
|
|
51
|
+
connection=connection,
|
|
52
|
+
target_metadata=target_metadata,
|
|
53
|
+
render_as_batch=True,
|
|
54
|
+
compare_type=True,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
with context.begin_transaction():
|
|
58
|
+
context.run_migrations()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if context.is_offline_mode():
|
|
62
|
+
run_migrations_offline()
|
|
63
|
+
else:
|
|
64
|
+
run_migrations_online()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""${message}
|
|
2
|
+
|
|
3
|
+
Revision ID: ${up_revision}
|
|
4
|
+
Revises: ${down_revision | comma,n}
|
|
5
|
+
Create Date: ${create_date}
|
|
6
|
+
"""
|
|
7
|
+
from alembic import op
|
|
8
|
+
import sqlalchemy as sa
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# revision identifiers, used by Alembic.
|
|
12
|
+
revision = ${repr(up_revision)}
|
|
13
|
+
down_revision = ${repr(down_revision)}
|
|
14
|
+
branch_labels = ${repr(branch_labels)}
|
|
15
|
+
depends_on = ${repr(depends_on)}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def upgrade() -> None:
|
|
19
|
+
${upgrades if upgrades else "pass"}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def downgrade() -> None:
|
|
23
|
+
${downgrades if downgrades else "pass"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from alembic import op
|
|
2
|
+
import sqlalchemy as sa
|
|
3
|
+
|
|
4
|
+
revision = "001_initial_schema"
|
|
5
|
+
|
|
6
|
+
down_revision = None
|
|
7
|
+
branch_labels = None
|
|
8
|
+
depends_on = None
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def upgrade() -> None:
|
|
12
|
+
op.create_table(
|
|
13
|
+
"generations",
|
|
14
|
+
sa.Column("id", sa.Uuid(), nullable=False),
|
|
15
|
+
sa.Column(
|
|
16
|
+
"created_at",
|
|
17
|
+
sa.DateTime(timezone=True),
|
|
18
|
+
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
19
|
+
nullable=False,
|
|
20
|
+
),
|
|
21
|
+
sa.Column("description", sa.Text(), nullable=True),
|
|
22
|
+
sa.PrimaryKeyConstraint("id"),
|
|
23
|
+
)
|
|
24
|
+
op.create_index(op.f("ix_generations_created_at"), "generations", ["created_at"])
|
|
25
|
+
op.create_table(
|
|
26
|
+
"dotfile_modules",
|
|
27
|
+
sa.Column("id", sa.Integer(), nullable=False),
|
|
28
|
+
sa.Column("generation_id", sa.Uuid(), nullable=False),
|
|
29
|
+
sa.Column("module_name", sa.String(length=255), nullable=False),
|
|
30
|
+
sa.Column("output_path", sa.Text(), nullable=False),
|
|
31
|
+
sa.Column("target_path", sa.Text(), nullable=False),
|
|
32
|
+
sa.ForeignKeyConstraint(
|
|
33
|
+
["generation_id"],
|
|
34
|
+
["generations.id"],
|
|
35
|
+
ondelete="CASCADE",
|
|
36
|
+
),
|
|
37
|
+
sa.PrimaryKeyConstraint("id"),
|
|
38
|
+
sa.UniqueConstraint(
|
|
39
|
+
"generation_id", "module_name", name="uq_generation_module"
|
|
40
|
+
),
|
|
41
|
+
)
|
|
42
|
+
op.create_index(
|
|
43
|
+
op.f("ix_dotfile_modules_generation_id"),
|
|
44
|
+
"dotfile_modules",
|
|
45
|
+
["generation_id"],
|
|
46
|
+
)
|
|
47
|
+
op.create_index(
|
|
48
|
+
op.f("ix_dotfile_modules_module_name"),
|
|
49
|
+
"dotfile_modules",
|
|
50
|
+
["module_name"],
|
|
51
|
+
)
|
|
52
|
+
op.create_table(
|
|
53
|
+
"rendered_files",
|
|
54
|
+
sa.Column("id", sa.Integer(), nullable=False),
|
|
55
|
+
sa.Column("module_id", sa.Integer(), nullable=False),
|
|
56
|
+
sa.Column("file_path", sa.Text(), nullable=False),
|
|
57
|
+
sa.Column("template_path", sa.Text(), nullable=False),
|
|
58
|
+
sa.Column("content_hash", sa.String(length=64), nullable=False),
|
|
59
|
+
sa.ForeignKeyConstraint(
|
|
60
|
+
["module_id"], ["dotfile_modules.id"], ondelete="CASCADE"
|
|
61
|
+
),
|
|
62
|
+
sa.PrimaryKeyConstraint("id"),
|
|
63
|
+
sa.UniqueConstraint("module_id", "file_path", name="uq_module_file"),
|
|
64
|
+
)
|
|
65
|
+
op.create_index(
|
|
66
|
+
op.f("ix_rendered_files_content_hash"),
|
|
67
|
+
"rendered_files",
|
|
68
|
+
["content_hash"],
|
|
69
|
+
)
|
|
70
|
+
op.create_index(
|
|
71
|
+
op.f("ix_rendered_files_module_id"),
|
|
72
|
+
"rendered_files",
|
|
73
|
+
["module_id"],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def downgrade() -> None:
|
|
78
|
+
op.drop_index(op.f("ix_rendered_files_module_id"), table_name="rendered_files")
|
|
79
|
+
op.drop_index(op.f("ix_rendered_files_content_hash"), table_name="rendered_files")
|
|
80
|
+
op.drop_table("rendered_files")
|
|
81
|
+
op.drop_index(op.f("ix_dotfile_modules_module_name"), table_name="dotfile_modules")
|
|
82
|
+
op.drop_index(
|
|
83
|
+
op.f("ix_dotfile_modules_generation_id"), table_name="dotfile_modules"
|
|
84
|
+
)
|
|
85
|
+
op.drop_table("dotfile_modules")
|
|
86
|
+
op.drop_index(op.f("ix_generations_created_at"), table_name="generations")
|
|
87
|
+
op.drop_table("generations")
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dotstash"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A dotfile manager with template support"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"alembic>=1.18.1",
|
|
9
|
+
"inotify>=0.2.12",
|
|
10
|
+
"jinja2>=3.1.6",
|
|
11
|
+
"pydantic>=2.12.5",
|
|
12
|
+
"pytoml>=0.1.21",
|
|
13
|
+
"pyyaml>=6.0.3",
|
|
14
|
+
"questionary>=2.1.0",
|
|
15
|
+
"rich>=13.9.4",
|
|
16
|
+
"sqlalchemy>=2.0.45",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
stash = "stash.main:main"
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["hatchling"]
|
|
24
|
+
build-backend = "hatchling.build"
|
|
25
|
+
|
|
26
|
+
[tool.hatch.build.targets.wheel]
|
|
27
|
+
packages = [
|
|
28
|
+
"stash",
|
|
29
|
+
"migrations",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
dev = [
|
|
34
|
+
"debugpy>=1.8.19",
|
|
35
|
+
"pyright>=1.1.408",
|
|
36
|
+
"pytest>=9.0.2",
|
|
37
|
+
"ruff>=0.14.10",
|
|
38
|
+
"ty>=0.0.8",
|
|
39
|
+
"zuban>=0.4.1",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
pythonpath = [
|
|
44
|
+
"stash"
|
|
45
|
+
]
|
|
File without changes
|