Skip to content

Commit 3b0d332

Browse files
fix: fix template cli and use raw jinja2
1 parent b41ace0 commit 3b0d332

File tree

7 files changed

+10
-69
lines changed

7 files changed

+10
-69
lines changed

repo_scaffold/templates/template-python/cookiecutter.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"description": "A short description of the project.",
88
"min_python_version": ["3.8", "3.9", "3.10", "3.11"],
99
"max_python_version": ["3.12"],
10-
"use_mkdocs": ["yes", "no"],
1110
"use_docker": ["yes", "no"],
1211
"include_cli": ["yes", "no"],
1312
"use_github_actions": ["yes", "no"],
@@ -20,7 +19,6 @@
2019
"description": "项目简短描述",
2120
"min_python_version": "最低支持的 Python 版本 (这将影响测试范围和依赖兼容性)",
2221
"max_python_version": "最高支持的 Python 版本",
23-
"use_mkdocs": "是否使用 MkDocs 生成文档?",
2422
"use_docker": "是否添加 Docker 支持?",
2523
"include_cli": "是否添加命令行界面?",
2624
"use_github_actions": "是否添加 GitHub Actions 支持?"

repo_scaffold/templates/template-python/hooks/post_gen_project.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,10 @@ def remove_cli():
1212

1313
def remove_github_actions():
1414
"""Remove GitHub Actions configuration if not needed."""
15-
github_dir = os.path.join("{{cookiecutter.project_slug}}", ".github")
16-
if os.path.exists(github_dir):
17-
shutil.rmtree(github_dir)
18-
19-
20-
def remove_mkdocs():
21-
"""Remove MkDocs related files if not needed."""
22-
files_to_remove = [
23-
"mkdocs.yml",
24-
os.path.join("docs"),
25-
]
26-
for file in files_to_remove:
27-
path = os.path.join("{{cookiecutter.project_slug}}", file)
28-
if os.path.exists(path):
29-
if os.path.isdir(path):
30-
shutil.rmtree(path)
31-
else:
32-
os.remove(path)
15+
if "{{cookiecutter.use_github_actions}}" == "no":
16+
github_dir = os.path.join(".github")
17+
if os.path.exists(github_dir):
18+
shutil.rmtree(github_dir)
3319

3420

3521
def init_project_depends():
@@ -39,10 +25,6 @@ def init_project_depends():
3925

4026
# 安装基础开发依赖
4127
subprocess.run(["uv", "sync", "--extra", "dev"], check=True)
42-
43-
# 如果启用了文档功能,安装文档依赖
44-
if "{{cookiecutter.use_mkdocs}}" == "yes":
45-
subprocess.run(["uv", "sync", "--extra", "docs"], check=True)
4628

4729

4830
if __name__ == "__main__":
@@ -52,7 +34,4 @@ def init_project_depends():
5234
if "{{cookiecutter.use_github_actions}}" == "no":
5335
remove_github_actions()
5436

55-
if "{{cookiecutter.use_mkdocs}}" == "no":
56-
remove_mkdocs()
57-
5837
init_project_depends()

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/bump_version.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ jobs:
3232
with:
3333
export-env: true
3434
env:
35-
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
35+
OP_SERVICE_ACCOUNT_TOKEN: {% raw %}${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}{% endraw %}
3636
PERSONAL_ACCESS_TOKEN: op://shawndengdev/github_access_token/credential
3737

3838
- name: Check out
3939
uses: actions/checkout@v4
4040
with:
4141
fetch-depth: 0
42-
token: '${{ env.PERSONAL_ACCESS_TOKEN }}'
42+
token: {% raw %}'${{ env.PERSONAL_ACCESS_TOKEN }}'{% endraw %}
4343

4444
- name: Create bump and changelog
4545
uses: commitizen-tools/commitizen-action@master
4646
with:
47-
github_token: ${{ env.PERSONAL_ACCESS_TOKEN }}
47+
github_token: {% raw %}${{ env.PERSONAL_ACCESS_TOKEN }}{% endraw %}
4848
branch: master

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/deploy_docs.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{% if cookiecutter.use_mkdocs == "yes" %}
21
name: Deploy Docs
32

43
on:
@@ -31,6 +30,4 @@ jobs:
3130
- name: Build and deploy documentation
3231
run: uv run mkdocs gh-deploy --force
3332
env:
34-
GITHUB_TOKEN: ${{ github.token }}
35-
36-
{% endif %}
33+
GITHUB_TOKEN: {% raw %}${{ github.token }}{% endraw %}

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/lint.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
install-deps: dev
2020
python-version: "{{cookiecutter.max_python_version}}" # 使用最新版本
2121
secrets:
22-
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
23-
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
22+
OP_SERVICE_ACCOUNT_TOKEN: {% raw %}${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}{% endraw %}
23+
PERSONAL_ACCESS_TOKEN: {% raw %}${{ secrets.PERSONAL_ACCESS_TOKEN }}{% endraw %}
2424

2525
lint:
2626
needs: setup
@@ -82,14 +82,6 @@ jobs:
8282
run: uv tool run nox -s test_all
8383
continue-on-error: true
8484

85-
- name: Upload coverage reports
86-
if: success()
87-
uses: codecov/codecov-action@v4
88-
with:
89-
token: ${{ secrets.CODECOV_TOKEN }}
90-
file: ./coverage.xml
91-
flags: unittests
92-
9385
- name: Comment on PR
9486
if: github.event_name == 'pull_request' && steps.test.outcome == 'failure'
9587
uses: actions/github-script@v7

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/api.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/contributing.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)