poetry-plugin-hook 0.0.0__tar.gz → 1.4.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {poetry_plugin_hook-0.0.0 → poetry_plugin_hook-1.4.0}/LICENSE +21 -21
- poetry_plugin_hook-1.4.0/PKG-INFO +287 -0
- poetry_plugin_hook-1.4.0/README.md +261 -0
- {poetry_plugin_hook-0.0.0 → poetry_plugin_hook-1.4.0}/poetry_plugin_hook/__init__.py +33 -17
- poetry_plugin_hook-1.4.0/poetry_plugin_hook/bump.py +157 -0
- poetry_plugin_hook-1.4.0/poetry_plugin_hook/latest.py +133 -0
- {poetry_plugin_hook-0.0.0 → poetry_plugin_hook-1.4.0}/poetry_plugin_hook/redirect.py +82 -82
- {poetry_plugin_hook-0.0.0 → poetry_plugin_hook-1.4.0}/poetry_plugin_hook/sync.py +106 -90
- poetry_plugin_hook-1.4.0/pyproject.toml +68 -0
- poetry_plugin_hook-0.0.0/PKG-INFO +0 -55
- poetry_plugin_hook-0.0.0/README.md +0 -38
- poetry_plugin_hook-0.0.0/poetry_plugin_hook/latest.py +0 -72
- poetry_plugin_hook-0.0.0/pyproject.toml +0 -18
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2024 Christoph Dörrer
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Christoph Dörrer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,287 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: poetry-plugin-hook
|
3
|
+
Version: 1.4.0
|
4
|
+
Summary: poetry plugin to register wrapped commands to use as pre-commit-hooks
|
5
|
+
License: MIT
|
6
|
+
Keywords: poetry,pre-commit,plugin,hook
|
7
|
+
Author: Christoph Dörrer
|
8
|
+
Author-email: d-chris@web.de
|
9
|
+
Requires-Python: >=3.9,<4.0
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Operating System :: OS Independent
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
18
|
+
Classifier: Topic :: Software Development :: Build Tools
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
20
|
+
Requires-Dist: cleo (>=2.1.0,<3.0.0)
|
21
|
+
Requires-Dist: poetry (>=1.7.0)
|
22
|
+
Project-URL: documentation, https://d-chris.github.io/poetry-plugin-hook
|
23
|
+
Project-URL: repository, https://github.com/d-chris/poetry-plugin-hook
|
24
|
+
Description-Content-Type: text/markdown
|
25
|
+
|
26
|
+
# poetry-plugin-hook
|
27
|
+
|
28
|
+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/poetry-plugin-hook)](https://pypi.org/project/poetry-plugin-hook/)
|
29
|
+
[![PyPI - Version](https://img.shields.io/pypi/v/poetry-plugin-hook)](https://pypi.org/project/poetry-plugin-hook/)
|
30
|
+
[![PyPI - Downloads](https://img.shields.io/pypi/dm/poetry-plugin-hook)](https://pypi.org/project/poetry-plugin-hook/)
|
31
|
+
[![PyPI - License](https://img.shields.io/pypi/l/poetry-plugin-hook)](https://raw.githubusercontent.com/d-chris/poetry-plugin-hook/main/LICENSE)
|
32
|
+
[![GitHub - Pytest](https://img.shields.io/github/actions/workflow/status/d-chris/poetry-plugin-hook/pytest.yml?logo=github&label=pytest)](https://github.com/d-chris/poetry-plugin-hook/actions/workflows/pytest.yml)
|
33
|
+
[![GitHub - Page](https://img.shields.io/website?url=https%3A%2F%2Fd-chris.github.io%2Fpoetry-plugin-hook&up_message=pdoc&logo=github&label=documentation)](https://d-chris.github.io/poetry-plugin-hook)
|
34
|
+
[![GitHub - Release](https://img.shields.io/github/v/tag/d-chris/poetry-plugin-hook?logo=github&label=github)](https://github.com/d-chris/poetry-plugin-hook)
|
35
|
+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://raw.githubusercontent.com/d-chris/poetry-plugin-hook/main/.pre-commit-config.yaml)
|
36
|
+
[![codecov](https://codecov.io/gh/d-chris/poetry-plugin-hook/graph/badge.svg?token=RNNV7TN8WZ)](https://codecov.io/gh/d-chris/poetry-plugin-hook)
|
37
|
+
|
38
|
+
---
|
39
|
+
|
40
|
+
[`poetry`](https://python-poetry.org/) plugin to register wrapped commands to use as [`pre-commit-hooks`](https://pre-commit.com/). all hook commands return zero on success and non-zero on failure.
|
41
|
+
|
42
|
+
## install
|
43
|
+
|
44
|
+
```cmd
|
45
|
+
$ pip install poetry-plugin-hook
|
46
|
+
```
|
47
|
+
|
48
|
+
or with `poetry`
|
49
|
+
|
50
|
+
> Especially on [Windows](https://python-poetry.org/docs/cli/#self), self commands that update or remove packages may be problematic.
|
51
|
+
|
52
|
+
```cmd
|
53
|
+
$ poetry self add poetry-plugin-hook
|
54
|
+
```
|
55
|
+
|
56
|
+
## hook bump
|
57
|
+
|
58
|
+
Extends `poetry version` command, to also bump `__version__` strings in python files.
|
59
|
+
|
60
|
+
```cmd
|
61
|
+
$ poetry hook bump --help
|
62
|
+
|
63
|
+
Description:
|
64
|
+
Update the version in pyproject.toml and synchronize it into files.
|
65
|
+
|
66
|
+
Usage:
|
67
|
+
hook bump [options] [--] [<version>]
|
68
|
+
|
69
|
+
Arguments:
|
70
|
+
version The version number or the rule to update the version.
|
71
|
+
|
72
|
+
Options:
|
73
|
+
-f, --file=FILE Specify the files to update the __version__ string. [default: ["__init__.py"]] (multiple values allowed)
|
74
|
+
--dry-run Do not update pyproject.toml file
|
75
|
+
--next-phase Increment the phase of the current version
|
76
|
+
-h, --help Display help for the given command. When no command is given display help for the list command.
|
77
|
+
-q, --quiet Do not output any message.
|
78
|
+
-V, --version Display this application version.
|
79
|
+
--ansi Force ANSI output.
|
80
|
+
--no-ansi Disable ANSI output.
|
81
|
+
-n, --no-interaction Do not ask any interactive question.
|
82
|
+
--no-plugins Disables plugins.
|
83
|
+
--no-cache Disables Poetry source caches.
|
84
|
+
-P, --project=PROJECT Specify another path as the project root. All command-line arguments will be resolved relative to the current working directory.
|
85
|
+
-C, --directory=DIRECTORY The working directory for the Poetry command (defaults to the current working directory). All command-line arguments will be resolved relative to the given directory.
|
86
|
+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
|
87
|
+
|
88
|
+
Help:
|
89
|
+
Update the version from package and also bumps __version__ strings in any given file.
|
90
|
+
|
91
|
+
poetry hook bump --next-phase patch --file __init__.py
|
92
|
+
|
93
|
+
The new version should ideally be a valid semver string or a valid bump rule:
|
94
|
+
patch, minor, major, prepatch, preminor, premajor, prerelease.
|
95
|
+
|
96
|
+
If no next-phase or version is provied the version from the pyproject.toml file will be
|
97
|
+
synced into the files.
|
98
|
+
```
|
99
|
+
|
100
|
+
## hook latest
|
101
|
+
|
102
|
+
Wrapper for `poetry show -o -T` command.
|
103
|
+
|
104
|
+
Exit code represents the number of outdated packages.
|
105
|
+
|
106
|
+
```cmd
|
107
|
+
$ poetry hook latest --help
|
108
|
+
|
109
|
+
Description:
|
110
|
+
Check if all top-level dependencies are up-to-date.
|
111
|
+
|
112
|
+
Usage:
|
113
|
+
hook latest [options] [--] [<package>]
|
114
|
+
|
115
|
+
Arguments:
|
116
|
+
package The package to inspect
|
117
|
+
|
118
|
+
Options:
|
119
|
+
--without=WITHOUT The dependency groups to ignore. (multiple values allowed)
|
120
|
+
--with=WITH The optional dependency groups to include. (multiple values allowed)
|
121
|
+
--only=ONLY The only dependency groups to include. (multiple values allowed)
|
122
|
+
-l, --latest Show the latest version. (option is always True)
|
123
|
+
-o, --outdated Show the latest version but only for packages that are outdated. (option is always True)
|
124
|
+
-T, --top-level Show only top-level dependencies. (option is always True)
|
125
|
+
-h, --help Display help for the given command. When no command is given display help for the list command.
|
126
|
+
-q, --quiet Do not output any message.
|
127
|
+
-V, --version Display this application version.
|
128
|
+
--ansi Force ANSI output.
|
129
|
+
--no-ansi Disable ANSI output.
|
130
|
+
-n, --no-interaction Do not ask any interactive question.
|
131
|
+
--no-plugins Disables plugins.
|
132
|
+
--no-cache Disables Poetry source caches.
|
133
|
+
-P, --project=PROJECT Specify another path as the project root. All command-line arguments will be resolved relative to the current working directory.
|
134
|
+
-C, --directory=DIRECTORY The working directory for the Poetry command (defaults to the current working directory). All command-line arguments will be resolved relative to the given directory.
|
135
|
+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
|
136
|
+
|
137
|
+
Help:
|
138
|
+
To check if all top-level dependencies of your package are up-to-date
|
139
|
+
poetry hook latest --only=main
|
140
|
+
|
141
|
+
If a specific package is outdated
|
142
|
+
poetry hook latest <package>
|
143
|
+
```
|
144
|
+
|
145
|
+
## hook sync
|
146
|
+
|
147
|
+
Wrapper for `poetry install --sync` command.
|
148
|
+
|
149
|
+
With `--exit` option, the command returns the corresponding value as exit code. With it's default `--exit=any` the sum of *installs*, *updates* and *removals* is returned.
|
150
|
+
|
151
|
+
```cmd
|
152
|
+
$ poetry hook sync --help
|
153
|
+
|
154
|
+
Description:
|
155
|
+
Synchronize the environment with the locked packages and the specified groups.
|
156
|
+
|
157
|
+
Usage:
|
158
|
+
hook sync [options]
|
159
|
+
|
160
|
+
Options:
|
161
|
+
--exit=EXIT Specify the value to return as exitcode. choices=['any', 'installs', 'updates', 'removals'] [default: "any"]
|
162
|
+
--without=WITHOUT The dependency groups to ignore. (multiple values allowed)
|
163
|
+
--with=WITH The optional dependency groups to include. (multiple values allowed)
|
164
|
+
--only=ONLY The only dependency groups to include. (multiple values allowed)
|
165
|
+
--sync Synchronize the environment with the locked packages and the specified groups. (Deprecated) (option is always True)
|
166
|
+
--no-root Do not install the root package (the current project).
|
167
|
+
--no-directory Do not install any directory path dependencies; useful to install dependencies without source code, e.g. for caching of Docker layers)
|
168
|
+
--dry-run Output the operations but do not execute anything (implicitly enables --verbose).
|
169
|
+
-E, --extras=EXTRAS Extra sets of dependencies to install. (multiple values allowed)
|
170
|
+
--all-extras Install all extra dependencies.
|
171
|
+
--all-groups Install dependencies from all groups.
|
172
|
+
--only-root Exclude all dependencies.
|
173
|
+
-h, --help Display help for the given command. When no command is given display help for the list command.
|
174
|
+
-q, --quiet Do not output any message.
|
175
|
+
-V, --version Display this application version.
|
176
|
+
--ansi Force ANSI output.
|
177
|
+
--no-ansi Disable ANSI output.
|
178
|
+
-n, --no-interaction Do not ask any interactive question.
|
179
|
+
--no-plugins Disables plugins.
|
180
|
+
--no-cache Disables Poetry source caches.
|
181
|
+
-P, --project=PROJECT Specify another path as the project root. All command-line arguments will be resolved relative to the current working directory.
|
182
|
+
-C, --directory=DIRECTORY The working directory for the Poetry command (defaults to the current working directory). All command-line arguments will be resolved relative to the given directory.
|
183
|
+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
|
184
|
+
|
185
|
+
Help:
|
186
|
+
To check if your environment is synchronized without making any changes
|
187
|
+
poetry hook sync --dry-run
|
188
|
+
```
|
189
|
+
|
190
|
+
## pre-commit-config
|
191
|
+
|
192
|
+
Add the following to your `.pre-commit-config.yaml` file.
|
193
|
+
|
194
|
+
```yaml
|
195
|
+
default_install_hook_types:
|
196
|
+
- pre-commit
|
197
|
+
- pre-push
|
198
|
+
default_stages:
|
199
|
+
- pre-commit
|
200
|
+
repos:
|
201
|
+
- repo: https://github.com/d-chris/poetry-plugin-hook
|
202
|
+
rev: v1.2.1
|
203
|
+
hooks:
|
204
|
+
- id: poetry-hook-bump
|
205
|
+
- id: poetry-hook-latest
|
206
|
+
args: ["--only=main"]
|
207
|
+
- id: poetry-hook-sync
|
208
|
+
args: ["--dry-run"]
|
209
|
+
```
|
210
|
+
|
211
|
+
### usage
|
212
|
+
|
213
|
+
1. Make sure pre-commit is installed, see [official documentation](https://pre-commit.com/#installation).
|
214
|
+
```cmd
|
215
|
+
$ pre-commit --version
|
216
|
+
|
217
|
+
pre-commit 3.7.1
|
218
|
+
```
|
219
|
+
2. `cd` into your project and register hooks and install them. this may take a while.
|
220
|
+
```cmd
|
221
|
+
$ pre-commit install --install-hooks
|
222
|
+
|
223
|
+
pre-commit installed at .git\hooks\pre-commit
|
224
|
+
pre-commit installed at .git\hooks\pre-push
|
225
|
+
```
|
226
|
+
3. Test the pre-push hook.
|
227
|
+
```cmd
|
228
|
+
$ pre-commit run poetry-hook-latest --all-files --hook-stage pre-push
|
229
|
+
|
230
|
+
poetry-hook-latest.......................................................Failed
|
231
|
+
- hook id: poetry-hook-latest
|
232
|
+
- exit code: 1
|
233
|
+
|
234
|
+
pytest-cov 5.0.0 6.0.0 Pytest plugin for measuring coverage.
|
235
|
+
```
|
236
|
+
4. Test the pre-commit hooks.
|
237
|
+
```cmd
|
238
|
+
$ pre-commit run poetry-hook-sync --all-files
|
239
|
+
|
240
|
+
poetry-hook-sync.........................................................Failed
|
241
|
+
- hook id: poetry-hook-sync
|
242
|
+
- exit code: 1
|
243
|
+
|
244
|
+
Installing dependencies from lock file
|
245
|
+
|
246
|
+
Package operations: 0 installs, 1 update, 0 removals
|
247
|
+
|
248
|
+
- Downgrading pytest-cov (6.0.0 -> 5.0.0)
|
249
|
+
|
250
|
+
Installing the current project: poetry-plugin-hook (0.0.0)
|
251
|
+
```
|
252
|
+
|
253
|
+
## pre-commit-hooks
|
254
|
+
|
255
|
+
```yaml
|
256
|
+
- id: poetry-hook-bump
|
257
|
+
name: poetry-hook-bump
|
258
|
+
description: Bump the version of the package and also in files.
|
259
|
+
entry: poetry hook bump
|
260
|
+
language: system
|
261
|
+
pass_filenames: false
|
262
|
+
always_run: true
|
263
|
+
stages: [pre-push]
|
264
|
+
- id: poetry-hook-latest
|
265
|
+
name: poetry-hook-latest
|
266
|
+
description: Check if all top-level dependencies are up-to-date.
|
267
|
+
entry: poetry hook latest
|
268
|
+
language: system
|
269
|
+
pass_filenames: false
|
270
|
+
always_run: true
|
271
|
+
stages: [pre-push]
|
272
|
+
- id: poetry-hook-sync
|
273
|
+
name: poetry-hook-sync
|
274
|
+
description: Synchronize the environment with the locked packages and the specified groups.
|
275
|
+
entry: poetry hook sync
|
276
|
+
language: system
|
277
|
+
pass_filenames: false
|
278
|
+
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
|
279
|
+
```
|
280
|
+
|
281
|
+
## Dependencies
|
282
|
+
|
283
|
+
[![PyPI - cleo](https://img.shields.io/pypi/v/cleo?logo=pypi&logoColor=white&label=cleo)](https://pypi.org/project/cleo/)
|
284
|
+
[![PyPI - poetry](https://img.shields.io/pypi/v/poetry?logo=poetry&logoColor=white&label=poetry)](https://pypi.org/project/poetry/)
|
285
|
+
|
286
|
+
---
|
287
|
+
|
@@ -0,0 +1,261 @@
|
|
1
|
+
# poetry-plugin-hook
|
2
|
+
|
3
|
+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/poetry-plugin-hook)](https://pypi.org/project/poetry-plugin-hook/)
|
4
|
+
[![PyPI - Version](https://img.shields.io/pypi/v/poetry-plugin-hook)](https://pypi.org/project/poetry-plugin-hook/)
|
5
|
+
[![PyPI - Downloads](https://img.shields.io/pypi/dm/poetry-plugin-hook)](https://pypi.org/project/poetry-plugin-hook/)
|
6
|
+
[![PyPI - License](https://img.shields.io/pypi/l/poetry-plugin-hook)](https://raw.githubusercontent.com/d-chris/poetry-plugin-hook/main/LICENSE)
|
7
|
+
[![GitHub - Pytest](https://img.shields.io/github/actions/workflow/status/d-chris/poetry-plugin-hook/pytest.yml?logo=github&label=pytest)](https://github.com/d-chris/poetry-plugin-hook/actions/workflows/pytest.yml)
|
8
|
+
[![GitHub - Page](https://img.shields.io/website?url=https%3A%2F%2Fd-chris.github.io%2Fpoetry-plugin-hook&up_message=pdoc&logo=github&label=documentation)](https://d-chris.github.io/poetry-plugin-hook)
|
9
|
+
[![GitHub - Release](https://img.shields.io/github/v/tag/d-chris/poetry-plugin-hook?logo=github&label=github)](https://github.com/d-chris/poetry-plugin-hook)
|
10
|
+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://raw.githubusercontent.com/d-chris/poetry-plugin-hook/main/.pre-commit-config.yaml)
|
11
|
+
[![codecov](https://codecov.io/gh/d-chris/poetry-plugin-hook/graph/badge.svg?token=RNNV7TN8WZ)](https://codecov.io/gh/d-chris/poetry-plugin-hook)
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
[`poetry`](https://python-poetry.org/) plugin to register wrapped commands to use as [`pre-commit-hooks`](https://pre-commit.com/). all hook commands return zero on success and non-zero on failure.
|
16
|
+
|
17
|
+
## install
|
18
|
+
|
19
|
+
```cmd
|
20
|
+
$ pip install poetry-plugin-hook
|
21
|
+
```
|
22
|
+
|
23
|
+
or with `poetry`
|
24
|
+
|
25
|
+
> Especially on [Windows](https://python-poetry.org/docs/cli/#self), self commands that update or remove packages may be problematic.
|
26
|
+
|
27
|
+
```cmd
|
28
|
+
$ poetry self add poetry-plugin-hook
|
29
|
+
```
|
30
|
+
|
31
|
+
## hook bump
|
32
|
+
|
33
|
+
Extends `poetry version` command, to also bump `__version__` strings in python files.
|
34
|
+
|
35
|
+
```cmd
|
36
|
+
$ poetry hook bump --help
|
37
|
+
|
38
|
+
Description:
|
39
|
+
Update the version in pyproject.toml and synchronize it into files.
|
40
|
+
|
41
|
+
Usage:
|
42
|
+
hook bump [options] [--] [<version>]
|
43
|
+
|
44
|
+
Arguments:
|
45
|
+
version The version number or the rule to update the version.
|
46
|
+
|
47
|
+
Options:
|
48
|
+
-f, --file=FILE Specify the files to update the __version__ string. [default: ["__init__.py"]] (multiple values allowed)
|
49
|
+
--dry-run Do not update pyproject.toml file
|
50
|
+
--next-phase Increment the phase of the current version
|
51
|
+
-h, --help Display help for the given command. When no command is given display help for the list command.
|
52
|
+
-q, --quiet Do not output any message.
|
53
|
+
-V, --version Display this application version.
|
54
|
+
--ansi Force ANSI output.
|
55
|
+
--no-ansi Disable ANSI output.
|
56
|
+
-n, --no-interaction Do not ask any interactive question.
|
57
|
+
--no-plugins Disables plugins.
|
58
|
+
--no-cache Disables Poetry source caches.
|
59
|
+
-P, --project=PROJECT Specify another path as the project root. All command-line arguments will be resolved relative to the current working directory.
|
60
|
+
-C, --directory=DIRECTORY The working directory for the Poetry command (defaults to the current working directory). All command-line arguments will be resolved relative to the given directory.
|
61
|
+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
|
62
|
+
|
63
|
+
Help:
|
64
|
+
Update the version from package and also bumps __version__ strings in any given file.
|
65
|
+
|
66
|
+
poetry hook bump --next-phase patch --file __init__.py
|
67
|
+
|
68
|
+
The new version should ideally be a valid semver string or a valid bump rule:
|
69
|
+
patch, minor, major, prepatch, preminor, premajor, prerelease.
|
70
|
+
|
71
|
+
If no next-phase or version is provied the version from the pyproject.toml file will be
|
72
|
+
synced into the files.
|
73
|
+
```
|
74
|
+
|
75
|
+
## hook latest
|
76
|
+
|
77
|
+
Wrapper for `poetry show -o -T` command.
|
78
|
+
|
79
|
+
Exit code represents the number of outdated packages.
|
80
|
+
|
81
|
+
```cmd
|
82
|
+
$ poetry hook latest --help
|
83
|
+
|
84
|
+
Description:
|
85
|
+
Check if all top-level dependencies are up-to-date.
|
86
|
+
|
87
|
+
Usage:
|
88
|
+
hook latest [options] [--] [<package>]
|
89
|
+
|
90
|
+
Arguments:
|
91
|
+
package The package to inspect
|
92
|
+
|
93
|
+
Options:
|
94
|
+
--without=WITHOUT The dependency groups to ignore. (multiple values allowed)
|
95
|
+
--with=WITH The optional dependency groups to include. (multiple values allowed)
|
96
|
+
--only=ONLY The only dependency groups to include. (multiple values allowed)
|
97
|
+
-l, --latest Show the latest version. (option is always True)
|
98
|
+
-o, --outdated Show the latest version but only for packages that are outdated. (option is always True)
|
99
|
+
-T, --top-level Show only top-level dependencies. (option is always True)
|
100
|
+
-h, --help Display help for the given command. When no command is given display help for the list command.
|
101
|
+
-q, --quiet Do not output any message.
|
102
|
+
-V, --version Display this application version.
|
103
|
+
--ansi Force ANSI output.
|
104
|
+
--no-ansi Disable ANSI output.
|
105
|
+
-n, --no-interaction Do not ask any interactive question.
|
106
|
+
--no-plugins Disables plugins.
|
107
|
+
--no-cache Disables Poetry source caches.
|
108
|
+
-P, --project=PROJECT Specify another path as the project root. All command-line arguments will be resolved relative to the current working directory.
|
109
|
+
-C, --directory=DIRECTORY The working directory for the Poetry command (defaults to the current working directory). All command-line arguments will be resolved relative to the given directory.
|
110
|
+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
|
111
|
+
|
112
|
+
Help:
|
113
|
+
To check if all top-level dependencies of your package are up-to-date
|
114
|
+
poetry hook latest --only=main
|
115
|
+
|
116
|
+
If a specific package is outdated
|
117
|
+
poetry hook latest <package>
|
118
|
+
```
|
119
|
+
|
120
|
+
## hook sync
|
121
|
+
|
122
|
+
Wrapper for `poetry install --sync` command.
|
123
|
+
|
124
|
+
With `--exit` option, the command returns the corresponding value as exit code. With it's default `--exit=any` the sum of *installs*, *updates* and *removals* is returned.
|
125
|
+
|
126
|
+
```cmd
|
127
|
+
$ poetry hook sync --help
|
128
|
+
|
129
|
+
Description:
|
130
|
+
Synchronize the environment with the locked packages and the specified groups.
|
131
|
+
|
132
|
+
Usage:
|
133
|
+
hook sync [options]
|
134
|
+
|
135
|
+
Options:
|
136
|
+
--exit=EXIT Specify the value to return as exitcode. choices=['any', 'installs', 'updates', 'removals'] [default: "any"]
|
137
|
+
--without=WITHOUT The dependency groups to ignore. (multiple values allowed)
|
138
|
+
--with=WITH The optional dependency groups to include. (multiple values allowed)
|
139
|
+
--only=ONLY The only dependency groups to include. (multiple values allowed)
|
140
|
+
--sync Synchronize the environment with the locked packages and the specified groups. (Deprecated) (option is always True)
|
141
|
+
--no-root Do not install the root package (the current project).
|
142
|
+
--no-directory Do not install any directory path dependencies; useful to install dependencies without source code, e.g. for caching of Docker layers)
|
143
|
+
--dry-run Output the operations but do not execute anything (implicitly enables --verbose).
|
144
|
+
-E, --extras=EXTRAS Extra sets of dependencies to install. (multiple values allowed)
|
145
|
+
--all-extras Install all extra dependencies.
|
146
|
+
--all-groups Install dependencies from all groups.
|
147
|
+
--only-root Exclude all dependencies.
|
148
|
+
-h, --help Display help for the given command. When no command is given display help for the list command.
|
149
|
+
-q, --quiet Do not output any message.
|
150
|
+
-V, --version Display this application version.
|
151
|
+
--ansi Force ANSI output.
|
152
|
+
--no-ansi Disable ANSI output.
|
153
|
+
-n, --no-interaction Do not ask any interactive question.
|
154
|
+
--no-plugins Disables plugins.
|
155
|
+
--no-cache Disables Poetry source caches.
|
156
|
+
-P, --project=PROJECT Specify another path as the project root. All command-line arguments will be resolved relative to the current working directory.
|
157
|
+
-C, --directory=DIRECTORY The working directory for the Poetry command (defaults to the current working directory). All command-line arguments will be resolved relative to the given directory.
|
158
|
+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
|
159
|
+
|
160
|
+
Help:
|
161
|
+
To check if your environment is synchronized without making any changes
|
162
|
+
poetry hook sync --dry-run
|
163
|
+
```
|
164
|
+
|
165
|
+
## pre-commit-config
|
166
|
+
|
167
|
+
Add the following to your `.pre-commit-config.yaml` file.
|
168
|
+
|
169
|
+
```yaml
|
170
|
+
default_install_hook_types:
|
171
|
+
- pre-commit
|
172
|
+
- pre-push
|
173
|
+
default_stages:
|
174
|
+
- pre-commit
|
175
|
+
repos:
|
176
|
+
- repo: https://github.com/d-chris/poetry-plugin-hook
|
177
|
+
rev: v1.2.1
|
178
|
+
hooks:
|
179
|
+
- id: poetry-hook-bump
|
180
|
+
- id: poetry-hook-latest
|
181
|
+
args: ["--only=main"]
|
182
|
+
- id: poetry-hook-sync
|
183
|
+
args: ["--dry-run"]
|
184
|
+
```
|
185
|
+
|
186
|
+
### usage
|
187
|
+
|
188
|
+
1. Make sure pre-commit is installed, see [official documentation](https://pre-commit.com/#installation).
|
189
|
+
```cmd
|
190
|
+
$ pre-commit --version
|
191
|
+
|
192
|
+
pre-commit 3.7.1
|
193
|
+
```
|
194
|
+
2. `cd` into your project and register hooks and install them. this may take a while.
|
195
|
+
```cmd
|
196
|
+
$ pre-commit install --install-hooks
|
197
|
+
|
198
|
+
pre-commit installed at .git\hooks\pre-commit
|
199
|
+
pre-commit installed at .git\hooks\pre-push
|
200
|
+
```
|
201
|
+
3. Test the pre-push hook.
|
202
|
+
```cmd
|
203
|
+
$ pre-commit run poetry-hook-latest --all-files --hook-stage pre-push
|
204
|
+
|
205
|
+
poetry-hook-latest.......................................................Failed
|
206
|
+
- hook id: poetry-hook-latest
|
207
|
+
- exit code: 1
|
208
|
+
|
209
|
+
pytest-cov 5.0.0 6.0.0 Pytest plugin for measuring coverage.
|
210
|
+
```
|
211
|
+
4. Test the pre-commit hooks.
|
212
|
+
```cmd
|
213
|
+
$ pre-commit run poetry-hook-sync --all-files
|
214
|
+
|
215
|
+
poetry-hook-sync.........................................................Failed
|
216
|
+
- hook id: poetry-hook-sync
|
217
|
+
- exit code: 1
|
218
|
+
|
219
|
+
Installing dependencies from lock file
|
220
|
+
|
221
|
+
Package operations: 0 installs, 1 update, 0 removals
|
222
|
+
|
223
|
+
- Downgrading pytest-cov (6.0.0 -> 5.0.0)
|
224
|
+
|
225
|
+
Installing the current project: poetry-plugin-hook (0.0.0)
|
226
|
+
```
|
227
|
+
|
228
|
+
## pre-commit-hooks
|
229
|
+
|
230
|
+
```yaml
|
231
|
+
- id: poetry-hook-bump
|
232
|
+
name: poetry-hook-bump
|
233
|
+
description: Bump the version of the package and also in files.
|
234
|
+
entry: poetry hook bump
|
235
|
+
language: system
|
236
|
+
pass_filenames: false
|
237
|
+
always_run: true
|
238
|
+
stages: [pre-push]
|
239
|
+
- id: poetry-hook-latest
|
240
|
+
name: poetry-hook-latest
|
241
|
+
description: Check if all top-level dependencies are up-to-date.
|
242
|
+
entry: poetry hook latest
|
243
|
+
language: system
|
244
|
+
pass_filenames: false
|
245
|
+
always_run: true
|
246
|
+
stages: [pre-push]
|
247
|
+
- id: poetry-hook-sync
|
248
|
+
name: poetry-hook-sync
|
249
|
+
description: Synchronize the environment with the locked packages and the specified groups.
|
250
|
+
entry: poetry hook sync
|
251
|
+
language: system
|
252
|
+
pass_filenames: false
|
253
|
+
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
|
254
|
+
```
|
255
|
+
|
256
|
+
## Dependencies
|
257
|
+
|
258
|
+
[![PyPI - cleo](https://img.shields.io/pypi/v/cleo?logo=pypi&logoColor=white&label=cleo)](https://pypi.org/project/cleo/)
|
259
|
+
[![PyPI - poetry](https://img.shields.io/pypi/v/poetry?logo=poetry&logoColor=white&label=poetry)](https://pypi.org/project/poetry/)
|
260
|
+
|
261
|
+
---
|
@@ -1,17 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
"""
|
2
|
+
.. include:: ../README.md
|
3
|
+
"""
|
4
|
+
|
5
|
+
from poetry.plugins.application_plugin import ApplicationPlugin
|
6
|
+
|
7
|
+
from poetry_plugin_hook.bump import BumpCommand
|
8
|
+
from poetry_plugin_hook.latest import LatestCommand
|
9
|
+
from poetry_plugin_hook.sync import SyncCommand
|
10
|
+
|
11
|
+
|
12
|
+
class HookPlugin(ApplicationPlugin):
|
13
|
+
def activate(self, application):
|
14
|
+
|
15
|
+
application.command_loader.register_factory(
|
16
|
+
BumpCommand.name,
|
17
|
+
lambda: BumpCommand(),
|
18
|
+
)
|
19
|
+
application.command_loader.register_factory(
|
20
|
+
LatestCommand.name,
|
21
|
+
lambda: LatestCommand(),
|
22
|
+
)
|
23
|
+
application.command_loader.register_factory(
|
24
|
+
SyncCommand.name,
|
25
|
+
lambda: SyncCommand(),
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
__all__ = [
|
30
|
+
"BumpCommand",
|
31
|
+
"LatestCommand",
|
32
|
+
"SyncCommand",
|
33
|
+
]
|