Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ jobs:
with:
poetry-version: "latest"

- name: install-poetry-plugins
- name: setup-pypi
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry self add poetry-pyinstaller-plugin
poetry self add poetry-plugin-taskipy

- name: build
run: poetry build
run: poetry publish --build

- name: Release
uses: softprops/action-gh-release@v2
Expand All @@ -34,4 +35,4 @@ jobs:
dist/*.whl
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "repo-template"
name = "repo-scaffold"
version = "0.1.0"
description = "shawn deng repo temple project"
authors = ["colyerdeng <[email protected]>"]
Expand All @@ -18,11 +18,11 @@ pre-commit = "^4.0.1"
commitizen = "^4.1.0"

[tool.poetry.scripts]
repo-template = "repo_template.cli:cli"
repo-scaffold = "repo_scaffold.cli:cli"

[tool.ruff]
line-length = 120
include = ["pyproject.toml", "{{template-python}}/{{cookiecutter.project_slug}}/*.py"]
include = ["pyproject.toml", "repo_scaffold/*.py"]

[tool.ruff.lint]
select = [
Expand Down
18 changes: 18 additions & 0 deletions repo_scaffold/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Repository scaffolding package for project initialization and setup.
This package provides tools and utilities for scaffolding new Python projects
with standardized structure and best practices. It serves as the main entry point
for the repo_scaffold package functionality.
Typical usage example:
import repo_scaffold
scaffold = repo_scaffold.create_project()
scaffold.setup_structure()
Attributes:
__author__: Package author information.
"""

__author__ = "Shawn Deng"
65 changes: 65 additions & 0 deletions repo_scaffold/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""Command Line Interface module for project scaffolding.

This module provides the CLI commands for creating new projects using cookiecutter
templates. It serves as the main entry point for the repo_scaffold tool and handles
all command-line interactions.

Typical usage example:

from repo_scaffold.cli import cli

if __name__ == '__main__':
cli()

Attributes:
cli: The main Click command group that serves as the entry point.
"""

import os

import click
from cookiecutter.main import cookiecutter


@click.group()
def cli():
"""CLI tool for project creation.

This function serves as the main command group for the CLI application.
It groups all subcommands and provides the base entry point for the tool.
"""
...


@cli.command()
@click.option(
"--template",
"-t",
default="https://github.com/ShawnDen-coder/repo-template.git",
help="Cookiecutter template URL or path",
)
@click.option("--output-dir", "-o", default=".", help="Where to output the generated project dir")
@click.option("--local", "-l", is_flag=True, help="Use local template in ./template-python")
def create(template, output_dir, local):
"""Create a new project from a Cookiecutter template.

Args:
template (str): URL or path to the cookiecutter template.
output_dir (str): Directory where the generated project will be created.
local (bool): Flag to use local template instead of remote.

Returns:
None

Example:
$ repo_scaffold create --template https://github.com/user/template.git
$ repo_scaffold create --local --output-dir ./projects
"""
if local:
template = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))

cookiecutter(template=template, output_dir=output_dir, no_input=False)


if __name__ == "__main__":
cli()
17 changes: 17 additions & 0 deletions repo_scaffold/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Utility functions module for common operations.
This module contains reusable utility functions that can be used across the application.
It provides helper methods, convenience functions, and shared functionality to promote
code reuse and maintainability.
Typical usage example:
from repo_scaffold.utils import validate_input, format_output
cleaned_data = validate_input(raw_data)
result = format_output(cleaned_data)
Note:
All utility functions should be stateless and follow single responsibility principle.
New utility functions should be well documented with type hints and docstrings.
"""
Empty file removed repo_template/__init__.py
Empty file.
31 changes: 0 additions & 31 deletions repo_template/cli.py

This file was deleted.

Empty file removed repo_template/utils.py
Empty file.
18 changes: 4 additions & 14 deletions template-python/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@
"email": "[email protected]",
"project_slug": "{{ cookiecutter.repo_name.strip().lower().replace('-', '_') }}",
"description": "A short description of the project.",
"include_cli": {
"__prompt__": "Include CLI interface? (y/n)",
"__choices__": [
"y",
"n"
]
},
"create_github_repo": {
"__prompt__": "Create GitHub repo? Requires ~/.github/config.json with GitHub token (y/n)",
"__choices__": [
"y",
"n"
]
}
"include_cli": [
"y",
"n"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Bump version

on:
pull_request:
branches:
- master
workflow_dispatch:

jobs:
bump-version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
name: "Bump version and create changelog with commitizen"
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0
token: '${{ secrets.GITHUB_TOKEN }}'
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: release-build
on:
push:
tags:
- '*.*.*'
workflow_dispatch:

jobs:
release-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "latest"

- name: setup-pypi
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry self add poetry-pyinstaller-plugin
poetry self add poetry-plugin-taskipy

- name: build
run: poetry publish --build

- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/**/*.exe
dist/*.tar.gz
dist/*.whl
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading