afterpython 0.1.0__py3-none-any.whl → 0.1.0.dev4__py3-none-any.whl
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.
- afterpython/{templates/pre-commit-config-template.yaml → .pre-commit-config.yaml} +1 -1
- afterpython/_io/toml.py +3 -5
- afterpython/_paths.py +1 -1
- afterpython/_typing.py +2 -1
- afterpython/builders/__init__.py +3 -12
- afterpython/builders/metadata.py +3 -7
- afterpython/builders/molab.py +99 -0
- afterpython/cli/__init__.py +1 -0
- afterpython/cli/commands/build.py +63 -136
- afterpython/cli/commands/bump.py +0 -30
- afterpython/cli/commands/check.py +1 -1
- afterpython/cli/commands/clean.py +3 -4
- afterpython/cli/commands/commit.py +3 -21
- afterpython/cli/commands/commitizen.py +1 -1
- afterpython/cli/commands/dev.py +13 -80
- afterpython/cli/commands/format.py +1 -1
- afterpython/cli/commands/init.py +39 -48
- afterpython/cli/commands/install.py +2 -8
- afterpython/cli/commands/pre_commit.py +1 -1
- afterpython/cli/commands/preview.py +1 -1
- afterpython/cli/commands/start.py +4 -8
- afterpython/cli/commands/sync.py +21 -65
- afterpython/cli/commands/update.py +8 -31
- afterpython/cli/main.py +14 -75
- afterpython/const.py +2 -1
- afterpython/cz.toml +27 -0
- afterpython/pcu.py +1 -3
- afterpython/templates/deploy-workflow-template.yml +5 -22
- afterpython/templates/release-workflow-template.yml +3 -3
- afterpython/templates/ruff-template.toml +1 -1
- afterpython/tools/_afterpython.py +10 -73
- afterpython/tools/_git.py +2 -28
- afterpython/tools/commitizen.py +45 -5
- afterpython/tools/github_actions.py +53 -23
- afterpython/tools/myst.py +38 -82
- afterpython/tools/pre_commit.py +31 -6
- afterpython/tools/pyproject.py +2 -40
- afterpython/utils.py +3 -87
- {afterpython-0.1.0.dist-info → afterpython-0.1.0.dev4.dist-info}/METADATA +13 -39
- afterpython-0.1.0.dev4.dist-info/RECORD +47 -0
- {afterpython-0.1.0.dist-info → afterpython-0.1.0.dev4.dist-info}/WHEEL +1 -1
- afterpython/builders/content_json.py +0 -131
- afterpython/builders/index_md.py +0 -94
- afterpython/builders/jupyter_notebook.py +0 -293
- afterpython/builders/markdown.py +0 -271
- afterpython/cli/commands/add.py +0 -67
- afterpython/cli/commands/init_branch_rules.py +0 -9
- afterpython/cli/commands/lock.py +0 -23
- afterpython/cli/commands/remove.py +0 -67
- afterpython/templates/ci-workflow-template.yml +0 -197
- afterpython/templates/cz-template.toml +0 -7
- afterpython/templates/dependabot-template.yml +0 -30
- afterpython/tools/branch_rules.py +0 -106
- afterpython-0.1.0.dist-info/RECORD +0 -57
- {afterpython-0.1.0.dist-info → afterpython-0.1.0.dev4.dist-info}/entry_points.txt +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Branch protection rules for AfterPython projects.
|
|
3
|
-
Uses gh CLI to create GitHub rulesets.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import json
|
|
7
|
-
import subprocess
|
|
8
|
-
from copy import deepcopy
|
|
9
|
-
|
|
10
|
-
from afterpython.tools._git import is_gh_authenticated
|
|
11
|
-
|
|
12
|
-
DEFAULT_RULESET = {
|
|
13
|
-
"name": "afterpython-default", # The ruleset identifier in GitHub
|
|
14
|
-
"target": "branch", # This ruleset applies to branches (not tags)
|
|
15
|
-
"enforcement": "active", # Rules are enforced (vs "disabled" or "evaluate")
|
|
16
|
-
"conditions": { # Which branches this ruleset applies to
|
|
17
|
-
"ref_name": {
|
|
18
|
-
"include": ["refs/heads/main"], # Only protect the 'main' branch
|
|
19
|
-
"exclude": [], # No exclusions
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"bypass_actors": [
|
|
23
|
-
{
|
|
24
|
-
"actor_id": 5, # Repository admin role
|
|
25
|
-
"actor_type": "RepositoryRole",
|
|
26
|
-
"bypass_mode": "always",
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"rules": [ # Array of protection rules
|
|
30
|
-
# Rule 1: No Force Pushes
|
|
31
|
-
{"type": "non_fast_forward"}, # Prevents git push --force
|
|
32
|
-
# Rule 2: No Branch Deletion
|
|
33
|
-
{"type": "deletion"}, # Prevents branch from being deleted
|
|
34
|
-
# Rule 3: CI Status Checks
|
|
35
|
-
{
|
|
36
|
-
"type": "required_status_checks",
|
|
37
|
-
"parameters": {
|
|
38
|
-
"required_status_checks": [
|
|
39
|
-
{"context": "lint"},
|
|
40
|
-
{"context": "test"},
|
|
41
|
-
{"context": "build"},
|
|
42
|
-
],
|
|
43
|
-
# The PR branch must be up to date with the base branch (main) before merging
|
|
44
|
-
"strict_required_status_checks_policy": True,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def list_rulesets() -> list[dict] | None:
|
|
52
|
-
"""
|
|
53
|
-
List existing rulesets for the current repository.
|
|
54
|
-
|
|
55
|
-
Returns:
|
|
56
|
-
List of rulesets or None if error
|
|
57
|
-
"""
|
|
58
|
-
if not is_gh_authenticated():
|
|
59
|
-
return None
|
|
60
|
-
|
|
61
|
-
result = subprocess.run(
|
|
62
|
-
["gh", "api", "repos/{owner}/{repo}/rulesets"],
|
|
63
|
-
capture_output=True,
|
|
64
|
-
text=True,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
if result.returncode != 0:
|
|
68
|
-
print(f"Error listing rulesets: {result.stderr}")
|
|
69
|
-
return None
|
|
70
|
-
|
|
71
|
-
try:
|
|
72
|
-
return json.loads(result.stdout)
|
|
73
|
-
except json.JSONDecodeError:
|
|
74
|
-
print("Error: Failed to parse rulesets JSON")
|
|
75
|
-
return None
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def create_default_branch_rules(branch: str = "main") -> bool:
|
|
79
|
-
if not is_gh_authenticated():
|
|
80
|
-
return False
|
|
81
|
-
|
|
82
|
-
# Check if ruleset already exists
|
|
83
|
-
existing_rulesets = list_rulesets()
|
|
84
|
-
if existing_rulesets:
|
|
85
|
-
print(f"Ruleset '{DEFAULT_RULESET['name']}' already exists.")
|
|
86
|
-
return False
|
|
87
|
-
|
|
88
|
-
# Build payload
|
|
89
|
-
payload = deepcopy(DEFAULT_RULESET)
|
|
90
|
-
if branch != "main":
|
|
91
|
-
payload["conditions"]["ref_name"]["include"] = [f"refs/heads/{branch}"]
|
|
92
|
-
|
|
93
|
-
# Create ruleset
|
|
94
|
-
result = subprocess.run(
|
|
95
|
-
["gh", "api", "-X", "POST", "repos/{owner}/{repo}/rulesets", "--input", "-"],
|
|
96
|
-
input=json.dumps(payload),
|
|
97
|
-
capture_output=True,
|
|
98
|
-
text=True,
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
if result.returncode != 0:
|
|
102
|
-
print(f"Error creating ruleset: {result.stderr}")
|
|
103
|
-
return False
|
|
104
|
-
|
|
105
|
-
print(f"✓ Created branch ruleset '{DEFAULT_RULESET['name']}' for {branch=}")
|
|
106
|
-
return True
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
afterpython/__init__.py,sha256=aNochs72gU2NR1cBzIkk3NxSsdJ7ceHluI5gdYwaFpI,289
|
|
2
|
-
afterpython/_io/toml.py,sha256=dvmq6n4MhlJ02u_YjfC3mOnCWatfCn_J1lugavigoJw,3410
|
|
3
|
-
afterpython/_io/yaml.py,sha256=raksve_gaIFJim8lQrq-kQHkRjTloed7CT2FY0oUJSg,654
|
|
4
|
-
afterpython/_paths.py,sha256=FTwQ7necKYuRosCyMZPfv1eqaEmGIsyqd3yXpm-WQTA,1584
|
|
5
|
-
afterpython/_typing.py,sha256=FbphSGoujPuTfCZqt0HaKQrBgzhRpCOEAEQU6Cbl7oA,145
|
|
6
|
-
afterpython/builders/__init__.py,sha256=YMfYfsbSJNMjqfq9GRsQj8ayWUhtZKpvrc0oFUASICo,575
|
|
7
|
-
afterpython/builders/content_json.py,sha256=-LTkeA8oA6XEudc2b1H7U0-UwcJlHn7xgICeweMYrG0,4805
|
|
8
|
-
afterpython/builders/index_md.py,sha256=SDVHnVftL4D1AA8jw2YvRdTem_Ho8v8DcrORVjVtW8A,3762
|
|
9
|
-
afterpython/builders/jupyter_notebook.py,sha256=2H5Qv_IIkmOud-GYZPYjB0E30fVZubpUUQ5gFrtGSqU,10140
|
|
10
|
-
afterpython/builders/markdown.py,sha256=0ExfRqvOTWsgUkAVaGGNkiNDtNedRr7JR1yTGxpbsmA,8736
|
|
11
|
-
afterpython/builders/metadata.py,sha256=--0zWaI0ZI1wKeezcyqSUy-h1IuLqnI33ateoAHIaBU,1337
|
|
12
|
-
afterpython/cli/__init__.py,sha256=G4AB-rllhmr7tURFc5cXJfkjZZ2bXtMBg3oy4zUGEFw,84
|
|
13
|
-
afterpython/cli/commands/add.py,sha256=Ppp4msdvOwN9_-fdG5-b0-IV9p0Eef9CiIEU3srUjYk,1792
|
|
14
|
-
afterpython/cli/commands/build.py,sha256=Vvyd7AkL2Tw3vEDhi4bEOWD9hdtxon7SgAzXUeh5D8w,9050
|
|
15
|
-
afterpython/cli/commands/bump.py,sha256=2MZBQ1kxjr0bWhA--_xHwdwjsUlCyrXPn3pJ5NDZO4k,4088
|
|
16
|
-
afterpython/cli/commands/check.py,sha256=lrPaVThAwxxnczu-VOZT7dd7aKjstnMQfX9UpZY3Lxs,1058
|
|
17
|
-
afterpython/cli/commands/clean.py,sha256=havP43ZC1AKFzvscsRMF_to6TvOwruxGA5qzr6dMHvg,2529
|
|
18
|
-
afterpython/cli/commands/commit.py,sha256=9QOKyt4tfTJzZEdHEPAdpUc4stYMSvG3-31uADuBxn4,1420
|
|
19
|
-
afterpython/cli/commands/commitizen.py,sha256=H3jewz4VkZi5FYTWw3USVM3XosRx12kPShOQGxD3LNM,842
|
|
20
|
-
afterpython/cli/commands/dev.py,sha256=YIJECfroGRQnuMWWRC4W_DMA0eJoQssufj8WBDjQVOM,6796
|
|
21
|
-
afterpython/cli/commands/format.py,sha256=VFwCG9KDTF6j4Y_Ewp4_RpS8uNBQNOAj9HU_G97my5A,710
|
|
22
|
-
afterpython/cli/commands/init.py,sha256=UiE8QIhDV9NqoqU2EU_FMAlJ2Y18lFF0x2JmcyiAQxc,3044
|
|
23
|
-
afterpython/cli/commands/init_branch_rules.py,sha256=fzAm8D5qbW3u4bEMpqPuRgO-0akuCGG7pu09JlKhYn4,243
|
|
24
|
-
afterpython/cli/commands/install.py,sha256=B8JuQmtU_4EZpHct2J5j30BGLkGmvwKvU26upbmabvQ,750
|
|
25
|
-
afterpython/cli/commands/lock.py,sha256=Kppu_0tnqdbP6Gbulxf123f-cFzTGIw39si2O7rDo3Q,603
|
|
26
|
-
afterpython/cli/commands/pre_commit.py,sha256=QIuzTZEfw4uPMqmQT8YmyD0yewBcwjLvcnbVjRbonQE,1978
|
|
27
|
-
afterpython/cli/commands/preview.py,sha256=sBwe46H0V-U7I4d0-u-nXmPBWGmkjKhkUTbqV927zRM,593
|
|
28
|
-
afterpython/cli/commands/release.py,sha256=6SDEnPtuCL0_XUqWUlvRSKxAv011QqOD0kc5pKu7378,2479
|
|
29
|
-
afterpython/cli/commands/remove.py,sha256=Fl79JSI9IdHyzYflocXxcxgBkBPkNFAW98Yuijly26g,1812
|
|
30
|
-
afterpython/cli/commands/start.py,sha256=q4rUkIllOO8wJQ9ABtsx-dqkW1yC0vltAtSkiHN_GH4,4002
|
|
31
|
-
afterpython/cli/commands/sync.py,sha256=u9L3aq04M5VHh0FByDSpmBD7F1RYCNsIgvZFifnRZ6A,6042
|
|
32
|
-
afterpython/cli/commands/update.py,sha256=4h_zKp72e4RmXUKHyeP6kfHqr4V3IugSOnxa-E1F55I,6312
|
|
33
|
-
afterpython/cli/main.py,sha256=m3BJ5rOlllUyOngD2HF2fosDLrduREzAQKpsTqcYPZc,4956
|
|
34
|
-
afterpython/const.py,sha256=B_yUBmHPyu98aOibwt7idWbhKNBBed0TeYXNBd8tPTk,157
|
|
35
|
-
afterpython/main.py,sha256=w0z6mTib3u4p2HxMrk-tIJlZtur7uRaqsbE0ewlYlSs,490
|
|
36
|
-
afterpython/pcu.py,sha256=EoEhSzFZ49b5qc9KH2RLxIHSzY8YFM5uhtw07chcrr8,6093
|
|
37
|
-
afterpython/templates/ci-workflow-template.yml,sha256=w0BiV9F_y9YNTd6mTD7xRlJgwRQw61AinhiACXlEQqk,5933
|
|
38
|
-
afterpython/templates/cz-template.toml,sha256=2qwbQLb0nbZaA63oWXFFzvzPNBsFZHATL1C2rdNdjjs,185
|
|
39
|
-
afterpython/templates/dependabot-template.yml,sha256=CBQEgh8EsXw2X7IqzGtFI7lVT9liF6PW4DvGLB0X2LY,1136
|
|
40
|
-
afterpython/templates/deploy-workflow-template.yml,sha256=2W4K3lKMYjSTPrlXIsMweBzqP9IoLtZXAAcUu5FA5NA,2365
|
|
41
|
-
afterpython/templates/pre-commit-config-template.yaml,sha256=u_JF4YHGHIWxLdcX5BS__VsVgOwwVQQsSZGPNR2Yyf0,915
|
|
42
|
-
afterpython/templates/release-workflow-template.yml,sha256=3YBkgrqmi--uznslpMxPz7Vj7L4_NPlhDxgwYBt-Ui8,1606
|
|
43
|
-
afterpython/templates/ruff-template.toml,sha256=lNCd4EthoLScr4cyVEgGUH4xK5CfIX3f9I3zkJHAYgg,1008
|
|
44
|
-
afterpython/tools/_afterpython.py,sha256=G1075u8VT6s-TjEcGajqEYS3pZoW0sGyJM7DJohMOPE,4244
|
|
45
|
-
afterpython/tools/_git.py,sha256=aO-qDEQ4OevD_B74DYKK4nQKYeiaS1BXmYc8paJRfbQ,3772
|
|
46
|
-
afterpython/tools/branch_rules.py,sha256=ciQ2H2YBnoCZu_plyVeIHzf2FcAILRFhpjzOR2_IfJg,3159
|
|
47
|
-
afterpython/tools/commitizen.py,sha256=ZO1qHmzUU0myd85tncv76WtIR7DB_AoQGSUvaf78Ohg,438
|
|
48
|
-
afterpython/tools/github_actions.py,sha256=zVmg9aqUg-EO0CnbRHl9i8TmFtXpt7nd0VjzckqqE30,1527
|
|
49
|
-
afterpython/tools/myst.py,sha256=2VO-gD25PbGSD8-v1sLI1v3Q9loahRd3ednKrW4_Utc,8113
|
|
50
|
-
afterpython/tools/pre_commit.py,sha256=oNsrUkPI13rSSBSyhyTTKPnQGhDxLIPYhxu6kL0fDmo,1206
|
|
51
|
-
afterpython/tools/pyproject.py,sha256=kb7BDn24yH_xS2F5_L0dK-GL4KgOJS-MIIUQhHnLorI,3507
|
|
52
|
-
afterpython/utils.py,sha256=s1FIJP6FvpAcK8SujB8glFbiKx-ZCltywh5ihaOhL0U,9516
|
|
53
|
-
afterpython/version.py,sha256=hihRV1S-gc1m46OaXD32ikkEkqzs-Gtq7AcAqOQV-wY,1603
|
|
54
|
-
afterpython-0.1.0.dist-info/WHEEL,sha256=93kfTGt3a0Dykt_T-gsjtyS5_p8F_d6CE1NwmBOirzo,79
|
|
55
|
-
afterpython-0.1.0.dist-info/entry_points.txt,sha256=roa0PDgBueM1JPbRG0G2OSxzaN394OUL_oS9iEwVLBc,80
|
|
56
|
-
afterpython-0.1.0.dist-info/METADATA,sha256=pld74AzH2JQEKTgHbrVpJ0BJUNk2k7HAzumazs-83bo,5779
|
|
57
|
-
afterpython-0.1.0.dist-info/RECORD,,
|
|
File without changes
|