wpsync 1.13.14__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.
Potentially problematic release.
This version of wpsync might be problematic. Click here for more details.
- wpsync-1.13.14/.gitignore +12 -0
- wpsync-1.13.14/LICENSE +61 -0
- wpsync-1.13.14/PKG-INFO +148 -0
- wpsync-1.13.14/README.md +125 -0
- wpsync-1.13.14/build_backend/versioning.py +57 -0
- wpsync-1.13.14/pyproject.toml +74 -0
- wpsync-1.13.14/src/wpsync/__init__.py +3 -0
- wpsync-1.13.14/src/wpsync/__main__.py +3 -0
- wpsync-1.13.14/src/wpsync/cli.py +1464 -0
- wpsync-1.13.14/src/wpsync/config.py +178 -0
- wpsync-1.13.14/src/wpsync/documents.py +294 -0
- wpsync-1.13.14/src/wpsync/editors.py +68 -0
- wpsync-1.13.14/src/wpsync/markup/__init__.py +0 -0
- wpsync-1.13.14/src/wpsync/markup/dom.py +371 -0
- wpsync-1.13.14/src/wpsync/markup/markdown.py +526 -0
- wpsync-1.13.14/src/wpsync/media.py +161 -0
- wpsync-1.13.14/src/wpsync/posts.py +78 -0
- wpsync-1.13.14/src/wpsync/pull.py +400 -0
- wpsync-1.13.14/src/wpsync/push.py +288 -0
- wpsync-1.13.14/src/wpsync/state.py +219 -0
- wpsync-1.13.14/src/wpsync/storage.py +28 -0
- wpsync-1.13.14/src/wpsync/sync.py +506 -0
- wpsync-1.13.14/src/wpsync/trash.py +132 -0
- wpsync-1.13.14/src/wpsync/wordpress/__init__.py +0 -0
- wpsync-1.13.14/src/wpsync/wordpress/autop.py +114 -0
- wpsync-1.13.14/src/wpsync/wordpress/client.py +233 -0
- wpsync-1.13.14/src/wpsync/wordpress/content.py +602 -0
- wpsync-1.13.14/src/wpsync/wordpress/remote.py +264 -0
- wpsync-1.13.14/version.json +3 -0
wpsync-1.13.14/LICENSE
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Copyright (c) 2026 WPSync contributors
|
|
2
|
+
|
|
3
|
+
# PolyForm Strict License 1.0.0
|
|
4
|
+
|
|
5
|
+
<https://polyformproject.org/licenses/strict/1.0.0>
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
|
|
14
|
+
|
|
15
|
+
## Patent License
|
|
16
|
+
|
|
17
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
18
|
+
|
|
19
|
+
## Noncommercial Purposes
|
|
20
|
+
|
|
21
|
+
Any noncommercial purpose is a permitted purpose.
|
|
22
|
+
|
|
23
|
+
## Personal Uses
|
|
24
|
+
|
|
25
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
26
|
+
|
|
27
|
+
## Noncommercial Organizations
|
|
28
|
+
|
|
29
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
30
|
+
|
|
31
|
+
## Fair Use
|
|
32
|
+
|
|
33
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
34
|
+
|
|
35
|
+
## No Other Rights
|
|
36
|
+
|
|
37
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
38
|
+
|
|
39
|
+
## Patent Defense
|
|
40
|
+
|
|
41
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
42
|
+
|
|
43
|
+
## Violations
|
|
44
|
+
|
|
45
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
46
|
+
|
|
47
|
+
## No Liability
|
|
48
|
+
|
|
49
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
50
|
+
|
|
51
|
+
## Definitions
|
|
52
|
+
|
|
53
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
54
|
+
|
|
55
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
56
|
+
|
|
57
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
58
|
+
|
|
59
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
60
|
+
|
|
61
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
wpsync-1.13.14/PKG-INFO
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wpsync
|
|
3
|
+
Version: 1.13.14
|
|
4
|
+
Summary: Manage blog posts as local Markdown files
|
|
5
|
+
Project-URL: Homepage, https://wpsync.dev
|
|
6
|
+
Project-URL: Changelog, https://github.com/ediril/wpsync/blob/main/CHANGELOG.md
|
|
7
|
+
Project-URL: Issues, https://github.com/ediril/wpsync/issues
|
|
8
|
+
Project-URL: Repository, https://github.com/ediril/wpsync.git
|
|
9
|
+
License-Expression: LicenseRef-PolyForm-Strict-1.0.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: html5lib<2,>=1.1
|
|
17
|
+
Requires-Dist: httpx<1,>=0.28
|
|
18
|
+
Requires-Dist: markdown-it-py<5,>=3
|
|
19
|
+
Requires-Dist: mdit-py-plugins<1,>=0.5
|
|
20
|
+
Requires-Dist: pyyaml<7,>=6
|
|
21
|
+
Requires-Dist: tzdata; sys_platform == 'win32'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# WPSync
|
|
25
|
+
|
|
26
|
+
WPSync (`wpsync`) is a command-line tool for managing blog posts as local
|
|
27
|
+
Markdown files: map a folder to a blog, pull its posts, edit them in any
|
|
28
|
+
editor, preview the differences, and push the changes back. WordPress is the
|
|
29
|
+
first supported platform. Website: [wpsync.dev](https://wpsync.dev).
|
|
30
|
+
|
|
31
|
+
WPSync is pre-alpha software. Profiles, pull, diff, and push work today;
|
|
32
|
+
commands and the post file format may change before a stable release.
|
|
33
|
+
|
|
34
|
+
## Who is it for?
|
|
35
|
+
|
|
36
|
+
WPSync is for people who would rather write blog posts in a Markdown editor,
|
|
37
|
+
such as VS Code or Obsidian, than in the WordPress editor.
|
|
38
|
+
|
|
39
|
+
Your files are the source of truth. Keep them in Git, edit them offline, and see
|
|
40
|
+
exactly what a push will change before anything reaches the blog.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
WPSync requires Python 3.11 or newer. Install it from PyPI with uv:
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
uv tool install wpsync
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Upgrade later with:
|
|
51
|
+
|
|
52
|
+
```console
|
|
53
|
+
uv tool upgrade wpsync
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick start
|
|
57
|
+
|
|
58
|
+
WPSync signs in with a WordPress Application Password, created in the WordPress
|
|
59
|
+
dashboard under **Users > Profile > Application Passwords**; the site must use
|
|
60
|
+
HTTPS. WPSync reads the password from an environment variable named after the
|
|
61
|
+
profile and never stores it.
|
|
62
|
+
|
|
63
|
+
From the folder you want to use for the blog:
|
|
64
|
+
|
|
65
|
+
```console
|
|
66
|
+
wpsync init myblog --site https://example.com --username emrah
|
|
67
|
+
export MYBLOG_WP_PASSWORD='abcd efgh ijkl mnop qrst uvwx'
|
|
68
|
+
wpsync pull # download posts and images into content/
|
|
69
|
+
wpsync open hello-world # edit a post in Obsidian or VS Code
|
|
70
|
+
wpsync diff # see what push would change
|
|
71
|
+
wpsync push # send the changes to the blog
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`init` proposes the current directory as the profile's folder; pressing Enter
|
|
75
|
+
accepts it. Each post becomes a Markdown file under `content/` with a YAML
|
|
76
|
+
header, and its images go in `content/images/`.
|
|
77
|
+
|
|
78
|
+
## Everyday commands
|
|
79
|
+
|
|
80
|
+
```console
|
|
81
|
+
wpsync profiles # list profiles; * marks the current one
|
|
82
|
+
wpsync ls # local posts, without contacting the blog
|
|
83
|
+
wpsync show hello # one post's details and issues
|
|
84
|
+
wpsync create -o # start a new private post and open it
|
|
85
|
+
wpsync open idea # open a post in your editor
|
|
86
|
+
wpsync pull # bring changes from the blog
|
|
87
|
+
wpsync diff # what push would change, read-only
|
|
88
|
+
wpsync push hello # send one post
|
|
89
|
+
wpsync delete hello # delete a post, keeping it in .trash/
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
A new post is private until you set `status: public` in its header. Pull asks
|
|
93
|
+
before replacing a file you edited, and push asks before replacing a post that
|
|
94
|
+
also changed on WordPress. Push deletes nothing on the blog unless you pass
|
|
95
|
+
`-p`, and a deleted post is kept in `.trash/`, where `restore` brings it back.
|
|
96
|
+
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
- [Profiles and credentials](https://github.com/ediril/wpsync/blob/main/docs/profiles.md):
|
|
100
|
+
Application Passwords, profiles, and running commands from anywhere.
|
|
101
|
+
- [Post files](https://github.com/ediril/wpsync/blob/main/docs/post-files.md):
|
|
102
|
+
the header and body format, images, starting a post, and opening it in an
|
|
103
|
+
editor.
|
|
104
|
+
- [Pull and push](https://github.com/ediril/wpsync/blob/main/docs/push-and-pull.md):
|
|
105
|
+
what each changes, how they protect local and remote work, when they ask,
|
|
106
|
+
and deleting posts.
|
|
107
|
+
- [Listing posts and diff](https://github.com/ediril/wpsync/blob/main/docs/listing-and-diff.md):
|
|
108
|
+
`ls`, `show`, issues, and `diff`'s status markers.
|
|
109
|
+
- [Development and maintenance](https://github.com/ediril/wpsync/blob/main/docs/development.md):
|
|
110
|
+
testing local changes, switching installs, and releasing.
|
|
111
|
+
|
|
112
|
+
## Command behavior
|
|
113
|
+
|
|
114
|
+
Commands accept any unique prefix, such as `wpsync di`. An ambiguous prefix
|
|
115
|
+
fails and lists the commands it could mean.
|
|
116
|
+
|
|
117
|
+
`show`, `open`, `diff`, and `push` take one post by ID, slug, file name, title,
|
|
118
|
+
or path. A file name needs no folder: `vibing` or `vibing.md` finds
|
|
119
|
+
`content/2019/vibing.md`, looking in the current folder first and then in every
|
|
120
|
+
folder under `content/`. A name that matches several files lists them. `pull`
|
|
121
|
+
takes an ID, a slug, a file name ending in `.md`, or a path.
|
|
122
|
+
|
|
123
|
+
Use `wpsync -h` and `wpsync COMMAND -h` for built-in help, and `wpsync --legend`
|
|
124
|
+
for the diff and ls symbols. `wpsync -v` and `wpsync --version` print the
|
|
125
|
+
installed version.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
WPSync is source-available under the [PolyForm Strict License 1.0.0](https://github.com/ediril/wpsync/blob/main/LICENSE).
|
|
130
|
+
Use is free of charge for the purposes permitted by that license, including:
|
|
131
|
+
|
|
132
|
+
- Any noncommercial purpose.
|
|
133
|
+
- The personal uses listed in the license, such as personal study and hobby
|
|
134
|
+
projects, without any anticipated commercial application.
|
|
135
|
+
- Use by charitable organizations, educational institutions, public research
|
|
136
|
+
organizations, public safety or health organizations, environmental protection
|
|
137
|
+
organizations, and government institutions, regardless of funding source or
|
|
138
|
+
obligations resulting from funding.
|
|
139
|
+
|
|
140
|
+
This license grants no rights to modify or redistribute WPSync or create works
|
|
141
|
+
based on it. The full license governs; this summary does not grant additional
|
|
142
|
+
permissions.
|
|
143
|
+
|
|
144
|
+
Commercial use outside those permissions requires a separate paid license.
|
|
145
|
+
Contact [Emrah Diril](mailto:emrah@diril.org) for pricing and a commercial
|
|
146
|
+
agreement before beginning such use.
|
|
147
|
+
|
|
148
|
+
WPSync is source-available, not open source.
|
wpsync-1.13.14/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# WPSync
|
|
2
|
+
|
|
3
|
+
WPSync (`wpsync`) is a command-line tool for managing blog posts as local
|
|
4
|
+
Markdown files: map a folder to a blog, pull its posts, edit them in any
|
|
5
|
+
editor, preview the differences, and push the changes back. WordPress is the
|
|
6
|
+
first supported platform. Website: [wpsync.dev](https://wpsync.dev).
|
|
7
|
+
|
|
8
|
+
WPSync is pre-alpha software. Profiles, pull, diff, and push work today;
|
|
9
|
+
commands and the post file format may change before a stable release.
|
|
10
|
+
|
|
11
|
+
## Who is it for?
|
|
12
|
+
|
|
13
|
+
WPSync is for people who would rather write blog posts in a Markdown editor,
|
|
14
|
+
such as VS Code or Obsidian, than in the WordPress editor.
|
|
15
|
+
|
|
16
|
+
Your files are the source of truth. Keep them in Git, edit them offline, and see
|
|
17
|
+
exactly what a push will change before anything reaches the blog.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
WPSync requires Python 3.11 or newer. Install it from PyPI with uv:
|
|
22
|
+
|
|
23
|
+
```console
|
|
24
|
+
uv tool install wpsync
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Upgrade later with:
|
|
28
|
+
|
|
29
|
+
```console
|
|
30
|
+
uv tool upgrade wpsync
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
WPSync signs in with a WordPress Application Password, created in the WordPress
|
|
36
|
+
dashboard under **Users > Profile > Application Passwords**; the site must use
|
|
37
|
+
HTTPS. WPSync reads the password from an environment variable named after the
|
|
38
|
+
profile and never stores it.
|
|
39
|
+
|
|
40
|
+
From the folder you want to use for the blog:
|
|
41
|
+
|
|
42
|
+
```console
|
|
43
|
+
wpsync init myblog --site https://example.com --username emrah
|
|
44
|
+
export MYBLOG_WP_PASSWORD='abcd efgh ijkl mnop qrst uvwx'
|
|
45
|
+
wpsync pull # download posts and images into content/
|
|
46
|
+
wpsync open hello-world # edit a post in Obsidian or VS Code
|
|
47
|
+
wpsync diff # see what push would change
|
|
48
|
+
wpsync push # send the changes to the blog
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`init` proposes the current directory as the profile's folder; pressing Enter
|
|
52
|
+
accepts it. Each post becomes a Markdown file under `content/` with a YAML
|
|
53
|
+
header, and its images go in `content/images/`.
|
|
54
|
+
|
|
55
|
+
## Everyday commands
|
|
56
|
+
|
|
57
|
+
```console
|
|
58
|
+
wpsync profiles # list profiles; * marks the current one
|
|
59
|
+
wpsync ls # local posts, without contacting the blog
|
|
60
|
+
wpsync show hello # one post's details and issues
|
|
61
|
+
wpsync create -o # start a new private post and open it
|
|
62
|
+
wpsync open idea # open a post in your editor
|
|
63
|
+
wpsync pull # bring changes from the blog
|
|
64
|
+
wpsync diff # what push would change, read-only
|
|
65
|
+
wpsync push hello # send one post
|
|
66
|
+
wpsync delete hello # delete a post, keeping it in .trash/
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
A new post is private until you set `status: public` in its header. Pull asks
|
|
70
|
+
before replacing a file you edited, and push asks before replacing a post that
|
|
71
|
+
also changed on WordPress. Push deletes nothing on the blog unless you pass
|
|
72
|
+
`-p`, and a deleted post is kept in `.trash/`, where `restore` brings it back.
|
|
73
|
+
|
|
74
|
+
## Documentation
|
|
75
|
+
|
|
76
|
+
- [Profiles and credentials](https://github.com/ediril/wpsync/blob/main/docs/profiles.md):
|
|
77
|
+
Application Passwords, profiles, and running commands from anywhere.
|
|
78
|
+
- [Post files](https://github.com/ediril/wpsync/blob/main/docs/post-files.md):
|
|
79
|
+
the header and body format, images, starting a post, and opening it in an
|
|
80
|
+
editor.
|
|
81
|
+
- [Pull and push](https://github.com/ediril/wpsync/blob/main/docs/push-and-pull.md):
|
|
82
|
+
what each changes, how they protect local and remote work, when they ask,
|
|
83
|
+
and deleting posts.
|
|
84
|
+
- [Listing posts and diff](https://github.com/ediril/wpsync/blob/main/docs/listing-and-diff.md):
|
|
85
|
+
`ls`, `show`, issues, and `diff`'s status markers.
|
|
86
|
+
- [Development and maintenance](https://github.com/ediril/wpsync/blob/main/docs/development.md):
|
|
87
|
+
testing local changes, switching installs, and releasing.
|
|
88
|
+
|
|
89
|
+
## Command behavior
|
|
90
|
+
|
|
91
|
+
Commands accept any unique prefix, such as `wpsync di`. An ambiguous prefix
|
|
92
|
+
fails and lists the commands it could mean.
|
|
93
|
+
|
|
94
|
+
`show`, `open`, `diff`, and `push` take one post by ID, slug, file name, title,
|
|
95
|
+
or path. A file name needs no folder: `vibing` or `vibing.md` finds
|
|
96
|
+
`content/2019/vibing.md`, looking in the current folder first and then in every
|
|
97
|
+
folder under `content/`. A name that matches several files lists them. `pull`
|
|
98
|
+
takes an ID, a slug, a file name ending in `.md`, or a path.
|
|
99
|
+
|
|
100
|
+
Use `wpsync -h` and `wpsync COMMAND -h` for built-in help, and `wpsync --legend`
|
|
101
|
+
for the diff and ls symbols. `wpsync -v` and `wpsync --version` print the
|
|
102
|
+
installed version.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
WPSync is source-available under the [PolyForm Strict License 1.0.0](https://github.com/ediril/wpsync/blob/main/LICENSE).
|
|
107
|
+
Use is free of charge for the purposes permitted by that license, including:
|
|
108
|
+
|
|
109
|
+
- Any noncommercial purpose.
|
|
110
|
+
- The personal uses listed in the license, such as personal study and hobby
|
|
111
|
+
projects, without any anticipated commercial application.
|
|
112
|
+
- Use by charitable organizations, educational institutions, public research
|
|
113
|
+
organizations, public safety or health organizations, environmental protection
|
|
114
|
+
organizations, and government institutions, regardless of funding source or
|
|
115
|
+
obligations resulting from funding.
|
|
116
|
+
|
|
117
|
+
This license grants no rights to modify or redistribute WPSync or create works
|
|
118
|
+
based on it. The full license governs; this summary does not grant additional
|
|
119
|
+
permissions.
|
|
120
|
+
|
|
121
|
+
Commercial use outside those permissions requires a separate paid license.
|
|
122
|
+
Contact [Emrah Diril](mailto:emrah@diril.org) for pricing and a commercial
|
|
123
|
+
agreement before beginning such use.
|
|
124
|
+
|
|
125
|
+
WPSync is source-available, not open source.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Advance the starting version along the first-parent history from its root.
|
|
2
|
+
|
|
3
|
+
Hatchling evaluates `release_version()` from this file to set the package
|
|
4
|
+
version, so every built artifact carries the version computed from Git.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import re
|
|
11
|
+
import subprocess
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
from email.parser import Parser
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
17
|
+
VERSION_PATTERN = re.compile(r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.[1-9][0-9]*")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def git_version(root: Path) -> str:
|
|
21
|
+
"""`<major>.<work-day>.<daily-commit>` from the history's root commit.
|
|
22
|
+
|
|
23
|
+
The root commit has the starting version. Each later date with commits
|
|
24
|
+
advances the work day by one; the last number counts that day's commits.
|
|
25
|
+
"""
|
|
26
|
+
start = json.loads((root / "version.json").read_text())["version"]
|
|
27
|
+
if not isinstance(start, str) or VERSION_PATTERN.fullmatch(start) is None:
|
|
28
|
+
raise ValueError("version.json requires a valid starting version")
|
|
29
|
+
major, work_day, increment = map(int, start.split("."))
|
|
30
|
+
result = subprocess.run(
|
|
31
|
+
["git", "log", "--first-parent", "--format=%cI", "HEAD"],
|
|
32
|
+
cwd=root,
|
|
33
|
+
capture_output=True,
|
|
34
|
+
text=True,
|
|
35
|
+
check=True,
|
|
36
|
+
)
|
|
37
|
+
dates = [datetime.fromisoformat(line).date() for line in result.stdout.split()]
|
|
38
|
+
if dates != sorted(dates, reverse=True):
|
|
39
|
+
raise ValueError("commit dates go backwards in the first-parent history")
|
|
40
|
+
work_day += len(set(dates)) - 1
|
|
41
|
+
daily_commits = dates.count(dates[0])
|
|
42
|
+
if dates[0] == dates[-1]:
|
|
43
|
+
daily_commits += increment - 1
|
|
44
|
+
return f"{major}.{work_day}.{daily_commits}"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def release_version(root: Path = ROOT) -> str:
|
|
48
|
+
if (root / ".git").exists():
|
|
49
|
+
return git_version(root)
|
|
50
|
+
# A source archive carries the version fixed when it was built.
|
|
51
|
+
metadata = root / "PKG-INFO"
|
|
52
|
+
if not metadata.is_file():
|
|
53
|
+
raise ValueError("version requires a Git checkout or a built source archive")
|
|
54
|
+
version = Parser().parsestr(metadata.read_text())["Version"]
|
|
55
|
+
if version is None or VERSION_PATTERN.fullmatch(version) is None:
|
|
56
|
+
raise ValueError("source archive has an invalid release version")
|
|
57
|
+
return version
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.26"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "wpsync"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Manage blog posts as local Markdown files"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "LicenseRef-PolyForm-Strict-1.0.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"html5lib>=1.1,<2",
|
|
15
|
+
"httpx>=0.28,<1",
|
|
16
|
+
"markdown-it-py>=3,<5",
|
|
17
|
+
"mdit-py-plugins>=0.5,<1",
|
|
18
|
+
"PyYAML>=6,<7",
|
|
19
|
+
"tzdata; sys_platform == 'win32'",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
23
|
+
"Environment :: Console",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://wpsync.dev"
|
|
30
|
+
Changelog = "https://github.com/ediril/wpsync/blob/main/CHANGELOG.md"
|
|
31
|
+
Issues = "https://github.com/ediril/wpsync/issues"
|
|
32
|
+
Repository = "https://github.com/ediril/wpsync.git"
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
wpsync = "wpsync.cli:main"
|
|
36
|
+
|
|
37
|
+
[dependency-groups]
|
|
38
|
+
dev = ["pytest>=8,<10", "ruff>=0.12,<1", "twine>=6,<7"]
|
|
39
|
+
|
|
40
|
+
[tool.hatch.version]
|
|
41
|
+
source = "code"
|
|
42
|
+
path = "build_backend/versioning.py"
|
|
43
|
+
expression = "release_version()"
|
|
44
|
+
|
|
45
|
+
# Twine and PyPI accept core metadata up to 2.4, which License-Expression needs.
|
|
46
|
+
[tool.hatch.build.targets.wheel]
|
|
47
|
+
packages = ["src/wpsync"]
|
|
48
|
+
core-metadata-version = "2.4"
|
|
49
|
+
|
|
50
|
+
[tool.hatch.build.targets.sdist]
|
|
51
|
+
include = ["src/wpsync", "build_backend", "version.json", "README.md", "LICENSE"]
|
|
52
|
+
core-metadata-version = "2.4"
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
addopts = "-ra"
|
|
56
|
+
testpaths = ["tests"]
|
|
57
|
+
pythonpath = ["tests"]
|
|
58
|
+
|
|
59
|
+
[tool.ruff]
|
|
60
|
+
target-version = "py311"
|
|
61
|
+
line-length = 88
|
|
62
|
+
|
|
63
|
+
[tool.ruff.lint]
|
|
64
|
+
select = ["E", "F", "I", "UP"]
|
|
65
|
+
|
|
66
|
+
[tool.uv]
|
|
67
|
+
# The version comes from version.json, Git history, and the script that combines
|
|
68
|
+
# them, so rebuild when any of them changes.
|
|
69
|
+
cache-keys = [
|
|
70
|
+
{ file = "pyproject.toml" },
|
|
71
|
+
{ file = "version.json" },
|
|
72
|
+
{ file = "build_backend/*.py" },
|
|
73
|
+
{ git = { commit = true } },
|
|
74
|
+
]
|