diff --git a/repo_scaffold/templates/template-python/cookiecutter.json b/repo_scaffold/templates/template-python/cookiecutter.json index 8c63a58..b89cce0 100644 --- a/repo_scaffold/templates/template-python/cookiecutter.json +++ b/repo_scaffold/templates/template-python/cookiecutter.json @@ -5,7 +5,7 @@ "github_username": "ShawnDen-coder", "project_slug": "{{ cookiecutter.repo_name.strip().lower().replace('-', '_') }}", "description": "A short description of the project.", - "min_python_version": ["3.8", "3.9", "3.10", "3.11"], + "min_python_version": ["3.9", "3.10", "3.11"], "max_python_version": ["3.12"], "use_docker": ["yes", "no"], "include_cli": ["yes", "no"], diff --git a/repo_scaffold/templates/template-python/hooks/post_gen_project.py b/repo_scaffold/templates/template-python/hooks/post_gen_project.py index a46fae5..7666e5c 100644 --- a/repo_scaffold/templates/template-python/hooks/post_gen_project.py +++ b/repo_scaffold/templates/template-python/hooks/post_gen_project.py @@ -18,6 +18,18 @@ def remove_github_actions(): shutil.rmtree(github_dir) +def remove_docs(): + """Remove documentation related files if GitHub Actions is not used.""" + if "{{cookiecutter.use_github_actions}}" == "no": + # 删除 mkdocs.yml + if os.path.exists("mkdocs.yml"): + os.remove("mkdocs.yml") + # 删除 docs 目录 + docs_dir = "docs" + if os.path.exists(docs_dir): + shutil.rmtree(docs_dir) + + def init_project_depends(): """Initialize project dependencies using uv.""" project_dir = os.path.abspath("{{cookiecutter.project_slug}}") @@ -33,5 +45,6 @@ def init_project_depends(): if "{{cookiecutter.use_github_actions}}" == "no": remove_github_actions() + remove_docs() init_project_depends() \ No newline at end of file diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/release_build.yaml b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/release_build.yaml index b894a4b..c755d75 100644 --- a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/release_build.yaml +++ b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/release_build.yaml @@ -29,7 +29,7 @@ jobs: with: export-env: true env: - OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_SERVICE_ACCOUNT_TOKEN: {% raw %}${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}{% endraw %} PERSONAL_ACCESS_TOKEN: op://shawndengdev/github_access_token/credential PYPI_TOKEN: op://shawndengdev/pypi_token/credential diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/noxfile.py b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/noxfile.py index 9c62e40..f11222f 100644 --- a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/noxfile.py +++ b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/noxfile.py @@ -203,7 +203,7 @@ def baseline(session: nox.Session) -> None: session.run("uv", "run", "ruff", "format", ".") -{% if cookiecutter.use_mkdocs == "yes" %} +{% if cookiecutter.use_github_actions == "yes" %} @nox.session(reuse_venv=True) def docs(session: nox.Session) -> None: """Build the documentation. diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/pyproject.toml b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/pyproject.toml index 9141580..1ee1a10 100644 --- a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/pyproject.toml +++ b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/pyproject.toml @@ -9,7 +9,7 @@ license = "MIT" readme = "README.md" requires-python = ">={{cookiecutter.min_python_version}},<{{cookiecutter.max_python_version}}.99" dependencies = [ -{% if cookiecutter.include_cli == 'y' %} +{% if cookiecutter.include_cli == 'yes' %} "click>=8.1.8", {% endif %} ] @@ -21,8 +21,9 @@ dev = [ "pytest>=8.3.4", "pytest-mock>=3.14.0", "pytest-cov>=6.0.0", - "commitizen>=4.1.0", + "commitizen>=3.12.0", # 使用支持 Python 3.8 的版本 ] +{% if cookiecutter.use_github_actions == 'yes' %} docs = [ "mkdocs>=1.5.3", "mkdocs-material>=9.5.3", @@ -31,8 +32,9 @@ docs = [ "mkdocs-gen-files>=0.5.0", "mkdocs-literate-nav>=0.6.1", ] +{% endif %} -{% if cookiecutter.include_cli == 'y' %} +{% if cookiecutter.include_cli == 'yes' %} [project.scripts] {{cookiecutter.project_slug}} = "{{cookiecutter.project_slug}}.cli:cli" {% endif %} diff --git a/uv.lock b/uv.lock index 8ea67f8..2b1ec3b 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,4 @@ version = 1 -revision = 1 requires-python = ">=3.12" [[package]] @@ -778,7 +777,7 @@ wheels = [ [[package]] name = "repo-scaffold" -version = "0.6.0" +version = "0.8.3" source = { editable = "." } dependencies = [ { name = "click" }, @@ -824,7 +823,6 @@ requires-dist = [ { name = "ruff", specifier = ">=0.9.6" }, { name = "ruff", marker = "extra == 'dev'", specifier = ">=0.9.6" }, ] -provides-extras = ["dev", "docs"] [[package]] name = "requests"