diff --git a/.env b/.env index 6bcda2c4a..cd7b51669 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ FLASK_ENV=development -FLASK_APP=project_name:create_app_wsgi +FLASK_APP=hiddifypanel:create_app_wsgi diff --git a/.github/rename_project.sh b/.github/rename_project.sh index 8f05495aa..219efa9b5 100755 --- a/.github/rename_project.sh +++ b/.github/rename_project.sh @@ -16,10 +16,10 @@ echo "Description: $description"; echo "Renaming project..." -original_author="author_name" -original_name="project_name" -original_urlname="project_urlname" -original_description="project_description" +original_author="hiddify" +original_name="hiddifypanel" +original_urlname="HiddifyPanel" +original_description="Awesome hiddifypanel created by hiddify" # for filename in $(find . -name "*.*") for filename in $(git ls-files) do @@ -30,7 +30,7 @@ do echo "Renamed $filename" done -mv project_name $name +mv hiddifypanel $name # This command runs only once on GHA! rm -rf .github/template.yml diff --git a/.github/template.yml b/.github/template.yml deleted file mode 100644 index 3386bee5c..000000000 --- a/.github/template.yml +++ /dev/null @@ -1 +0,0 @@ -author: rochacbruno diff --git a/ABOUT_THIS_TEMPLATE.md b/ABOUT_THIS_TEMPLATE.md index 11795f325..c493e7b7d 100644 --- a/ABOUT_THIS_TEMPLATE.md +++ b/ABOUT_THIS_TEMPLATE.md @@ -32,7 +32,7 @@ Lets take a look at the structure of this template: ├── Makefile # A collection of utilities to manage the project ├── MANIFEST.in # A list of files to include in a package ├── mkdocs.yml # Configuration for documentation site -├── project_name # The main python package for the project +├── hiddifypanel # The main python package for the project │   ├── base.py # The base module for the project │   ├── __init__.py # This tells Python that this is a package │   ├── __main__.py # The entry point for the project @@ -109,7 +109,7 @@ I had to do some tricks to read that version variable inside the setuptools I decided to keep the version in a static file because it is easier to read from wherever I want without the need to install the package. -e.g: `cat project_name/VERSION` will get the project version without harming +e.g: `cat hiddifypanel/VERSION` will get the project version without harming with module imports or anything else, it is useful for CI, logs and debugging. ### Why to include `tests`, `history` and `Containerfile` as part of the release? diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0d0dd72ad..b210a56b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # How to develop on this project -project_name welcomes contributions from the community. +hiddifypanel welcomes contributions from the community. **You need PYTHON3!** @@ -8,9 +8,9 @@ This instructions are for linux base systems. (Linux, MacOS, BSD, etc.) ## Setting up your own fork of this repo. - On github interface click on `Fork` button. -- Clone your fork of this repo. `git clone git@github.com:YOUR_GIT_USERNAME/project_urlname.git` -- Enter the directory `cd project_urlname` -- Add upstream repo `git remote add upstream https://github.com/author_name/project_urlname` +- Clone your fork of this repo. `git clone git@github.com:YOUR_GIT_USERNAME/HiddifyPanel.git` +- Enter the directory `cd HiddifyPanel` +- Add upstream repo `git remote add upstream https://github.com/hiddify/HiddifyPanel` ## Setting up your own virtual environment diff --git a/Containerfile b/Containerfile index 8950ef3e4..eb077a214 100644 --- a/Containerfile +++ b/Containerfile @@ -2,8 +2,8 @@ FROM python:3.7-alpine COPY . /app WORKDIR /app RUN pip install . -RUN project_name create-db -RUN project_name populate-db -RUN project_name add-user -u admin -p admin +RUN hiddifypanel create-db +RUN hiddifypanel populate-db +RUN hiddifypanel add-user -u admin -p admin EXPOSE 5000 -CMD ["project_name", "run"] +CMD ["hiddifypanel", "run"] diff --git a/MANIFEST.in b/MANIFEST.in index ef198d6fe..fbf8b84aa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,4 @@ include LICENSE include HISTORY.md include Containerfile graft tests -graft project_name +graft hiddifypanel diff --git a/Makefile b/Makefile index 6a042d5c5..7226fbcf4 100644 --- a/Makefile +++ b/Makefile @@ -26,20 +26,20 @@ install: ## Install the project in dev mode. .PHONY: fmt fmt: ## Format code using black & isort. - $(ENV_PREFIX)isort project_name/ - $(ENV_PREFIX)black -l 79 project_name/ + $(ENV_PREFIX)isort hiddifypanel/ + $(ENV_PREFIX)black -l 79 hiddifypanel/ $(ENV_PREFIX)black -l 79 tests/ .PHONY: lint lint: ## Run pep8, black, mypy linters. - $(ENV_PREFIX)flake8 project_name/ - $(ENV_PREFIX)black -l 79 --check project_name/ + $(ENV_PREFIX)flake8 hiddifypanel/ + $(ENV_PREFIX)black -l 79 --check hiddifypanel/ $(ENV_PREFIX)black -l 79 --check tests/ - $(ENV_PREFIX)mypy --ignore-missing-imports project_name/ + $(ENV_PREFIX)mypy --ignore-missing-imports hiddifypanel/ .PHONY: test test: lint ## Run tests and generate coverage report. - $(ENV_PREFIX)pytest -v --cov-config .coveragerc --cov=project_name -l --tb=short --maxfail=1 tests/ + $(ENV_PREFIX)pytest -v --cov-config .coveragerc --cov=hiddifypanel -l --tb=short --maxfail=1 tests/ $(ENV_PREFIX)coverage xml $(ENV_PREFIX)coverage html @@ -80,9 +80,9 @@ release: ## Create a new tag for release. @read -p "Version? (provide the next x.y.z semver) : " TAG @echo "creating git tag : $${TAG}" @git tag $${TAG} - @echo "$${TAG}" > project_name/VERSION + @echo "$${TAG}" > hiddifypanel/VERSION @$(ENV_PREFIX)gitchangelog > HISTORY.md - @git add project_name/VERSION HISTORY.md + @git add hiddifypanel/VERSION HISTORY.md @git commit -m "release: version $${TAG} 🚀" @git push -u origin HEAD --tags @echo "Github Actions will detect the new tag and release the new version." @@ -101,7 +101,7 @@ switch-to-poetry: ## Switch to poetry package manager. @poetry init --no-interaction --name=a_flask_test --author=rochacbruno @echo "" >> pyproject.toml @echo "[tool.poetry.scripts]" >> pyproject.toml - @echo "project_name = 'project_name.__main__:main'" >> pyproject.toml + @echo "hiddifypanel = 'hiddifypanel.__main__:main'" >> pyproject.toml @cat requirements.txt | while read in; do poetry add --no-interaction "$${in}"; done @cat requirements-base.txt | while read in; do poetry add --no-interaction "$${in}" --dev; done @cat requirements-test.txt | while read in; do poetry add --no-interaction "$${in}" --dev; done @@ -110,7 +110,7 @@ switch-to-poetry: ## Switch to poetry package manager. @mv requirements* .github/backup @mv setup.py .github/backup @echo "You have switched to https://python-poetry.org/ package manager." - @echo "Please run 'poetry shell' or 'poetry run project_name'" + @echo "Please run 'poetry shell' or 'poetry run hiddifypanel'" # This project has been generated from rochacbruno/flask-project-template diff --git a/README.md b/README.md index b2266f494..84b29eec7 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ See also - ✅ Code linting using [flake8](https://flake8.pycqa.org/en/latest/) - 📊 Code coverage reports using [codecov](https://about.codecov.io/sign-up/) - 🛳️ Automatic release to [PyPI](https://pypi.org) using [twine](https://twine.readthedocs.io/en/latest/) and github actions. -- 🎯 Entry points to execute your program using `python -m ` or `$ project_name` with basic CLI argument parsing. +- 🎯 Entry points to execute your program using `python -m ` or `$ hiddifypanel` with basic CLI argument parsing. - 🔄 Continuous integration using [Github Actions](.github/workflows/) with jobs to lint, test and release your project on Linux, Mac and Windows environments. > Curious about architectural decisions on this template? read [ABOUT_THIS_TEMPLATE.md](ABOUT_THIS_TEMPLATE.md) @@ -45,24 +45,24 @@ See also --- -# project_name Flask Application +# hiddifypanel Flask Application -project_description +Awesome hiddifypanel created by hiddify ## Installation From source: ```bash -git clone https://github.com/author_name/project_urlname project_name -cd project_name +git clone https://github.com/hiddify/HiddifyPanel hiddifypanel +cd hiddifypanel make install ``` From pypi: ```bash -pip install project_name +pip install hiddifypanel ``` ## Executing @@ -72,13 +72,13 @@ This application has a CLI interface that extends the Flask CLI. Just run: ```bash -$ project_name +$ hiddifypanel ``` or ```bash -$ python -m project_name +$ python -m hiddifypanel ``` To see the help message and usage instructions. @@ -86,10 +86,10 @@ To see the help message and usage instructions. ## First run ```bash -project_name create-db # run once -project_name populate-db # run once (optional) -project_name add-user -u admin -p 1234 # ads a user -project_name run +hiddifypanel create-db # run once +hiddifypanel populate-db # run once (optional) +hiddifypanel add-user -u admin -p 1234 # ads a user +hiddifypanel run ``` Go to: diff --git a/apply.sh b/apply.sh index 71f67d50c..d00f44365 100755 --- a/apply.sh +++ b/apply.sh @@ -15,10 +15,10 @@ echo "Project URL name: $urlname"; echo "Description: $description"; echo "Rendering the Flask template..." -original_author="author_name" -original_name="project_name" -original_urlname="project_urlname" -original_description="project_description" +original_author="hiddify" +original_name="hiddifypanel" +original_urlname="HiddifyPanel" +original_description="Awesome hiddifypanel created by hiddify" TEMPLATE_DIR="./.github/templates/flask" for filename in $(find ${TEMPLATE_DIR} -name "*.*" -not \( -name "*.git*" -prune \) -not \( -name "apply.sh" -prune \)) do @@ -48,7 +48,7 @@ fi # Move module files rm -rf "${name}" rm -rf tests -cp -R ${TEMPLATE_DIR}/project_name "${name}" +cp -R ${TEMPLATE_DIR}/hiddifypanel "${name}" cp -R ${TEMPLATE_DIR}/tests tests cp ${TEMPLATE_DIR}/README.md README.md @@ -66,12 +66,12 @@ then make install echo "Applied Flask template" echo "Ensure you activate your env with 'source .venv/bin/activate'" - echo "then run 'project_name' or 'python -m project_name'" + echo "then run 'hiddifypanel' or 'python -m hiddifypanel'" else poetry install echo "Applied Flask template" echo "Ensure you activate your env with 'poetry shell'" - echo "then run 'project_name' or 'python -m project_name' or 'poetry run project_name'" + echo "then run 'hiddifypanel' or 'python -m hiddifypanel' or 'poetry run hiddifypanel'" fi echo "README.md has instructions on how to use this Flask application." diff --git a/project_name/VERSION b/hiddifypanel/VERSION similarity index 100% rename from project_name/VERSION rename to hiddifypanel/VERSION diff --git a/project_name/__init__.py b/hiddifypanel/__init__.py similarity index 100% rename from project_name/__init__.py rename to hiddifypanel/__init__.py diff --git a/project_name/__main__.py b/hiddifypanel/__main__.py similarity index 77% rename from project_name/__main__.py rename to hiddifypanel/__main__.py index de55e8d7b..249c05d2e 100644 --- a/project_name/__main__.py +++ b/hiddifypanel/__main__.py @@ -6,7 +6,7 @@ @click.group(cls=FlaskGroup, create_app=create_app_wsgi) def main(): - """Management script for the project_name application.""" + """Management script for the hiddifypanel application.""" if __name__ == "__main__": # pragma: no cover diff --git a/project_name/base.py b/hiddifypanel/base.py similarity index 100% rename from project_name/base.py rename to hiddifypanel/base.py diff --git a/project_name/ext/__init__.py b/hiddifypanel/ext/__init__.py similarity index 100% rename from project_name/ext/__init__.py rename to hiddifypanel/ext/__init__.py diff --git a/project_name/ext/admin.py b/hiddifypanel/ext/admin.py similarity index 91% rename from project_name/ext/admin.py rename to hiddifypanel/ext/admin.py index ba1761960..f57d6832b 100644 --- a/project_name/ext/admin.py +++ b/hiddifypanel/ext/admin.py @@ -4,8 +4,8 @@ from flask_simplelogin import login_required from werkzeug.security import generate_password_hash -from project_name.ext.database import db -from project_name.models import Product, User +from hiddifypanel.ext.database import db +from hiddifypanel.models import Product, User # Proteck admin with login / Monkey Patch AdminIndexView._handle_view = login_required(AdminIndexView._handle_view) diff --git a/project_name/ext/auth.py b/hiddifypanel/ext/auth.py similarity index 92% rename from project_name/ext/auth.py rename to hiddifypanel/ext/auth.py index ce09c5d54..55074805e 100644 --- a/project_name/ext/auth.py +++ b/hiddifypanel/ext/auth.py @@ -1,8 +1,8 @@ from flask_simplelogin import SimpleLogin from werkzeug.security import check_password_hash, generate_password_hash -from project_name.ext.database import db -from project_name.models import User +from hiddifypanel.ext.database import db +from hiddifypanel.models import User def verify_login(user): diff --git a/project_name/ext/commands.py b/hiddifypanel/ext/commands.py similarity index 88% rename from project_name/ext/commands.py rename to hiddifypanel/ext/commands.py index 5ddb07746..cf2d1effd 100644 --- a/project_name/ext/commands.py +++ b/hiddifypanel/ext/commands.py @@ -1,8 +1,8 @@ import click -from project_name.ext.auth import create_user -from project_name.ext.database import db -from project_name.models import Product +from hiddifypanel.ext.auth import create_user +from hiddifypanel.ext.database import db +from hiddifypanel.models import Product def create_db(): diff --git a/project_name/ext/database.py b/hiddifypanel/ext/database.py similarity index 100% rename from project_name/ext/database.py rename to hiddifypanel/ext/database.py diff --git a/project_name/ext/restapi/__init__.py b/hiddifypanel/ext/restapi/__init__.py similarity index 100% rename from project_name/ext/restapi/__init__.py rename to hiddifypanel/ext/restapi/__init__.py diff --git a/project_name/ext/restapi/resources.py b/hiddifypanel/ext/restapi/resources.py similarity index 96% rename from project_name/ext/restapi/resources.py rename to hiddifypanel/ext/restapi/resources.py index bb7426e12..f9b225b57 100644 --- a/project_name/ext/restapi/resources.py +++ b/hiddifypanel/ext/restapi/resources.py @@ -2,7 +2,7 @@ from flask_restful import Resource from flask_simplelogin import login_required -from project_name.models import Product +from hiddifypanel.models import Product class ProductResource(Resource): diff --git a/project_name/ext/webui/__init__.py b/hiddifypanel/ext/webui/__init__.py similarity index 100% rename from project_name/ext/webui/__init__.py rename to hiddifypanel/ext/webui/__init__.py diff --git a/project_name/ext/webui/templates/index.html b/hiddifypanel/ext/webui/templates/index.html similarity index 100% rename from project_name/ext/webui/templates/index.html rename to hiddifypanel/ext/webui/templates/index.html diff --git a/project_name/ext/webui/templates/product.html b/hiddifypanel/ext/webui/templates/product.html similarity index 100% rename from project_name/ext/webui/templates/product.html rename to hiddifypanel/ext/webui/templates/product.html diff --git a/project_name/ext/webui/views.py b/hiddifypanel/ext/webui/views.py similarity index 93% rename from project_name/ext/webui/views.py rename to hiddifypanel/ext/webui/views.py index cead2e3b3..9c87428d6 100644 --- a/project_name/ext/webui/views.py +++ b/hiddifypanel/ext/webui/views.py @@ -1,7 +1,7 @@ from flask import abort, render_template from flask_simplelogin import login_required -from project_name.models import Product +from hiddifypanel.models import Product def index(): diff --git a/project_name/models.py b/hiddifypanel/models.py similarity index 91% rename from project_name/models.py rename to hiddifypanel/models.py index 698613592..14cb41efd 100644 --- a/project_name/models.py +++ b/hiddifypanel/models.py @@ -1,6 +1,6 @@ from sqlalchemy_serializer import SerializerMixin -from project_name.ext.database import db +from hiddifypanel.ext.database import db class Product(db.Model, SerializerMixin): diff --git a/mkdocs.yml b/mkdocs.yml index 33a69ca87..a96260071 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,2 +1,2 @@ -site_name: project_name +site_name: hiddifypanel theme: readthedocs diff --git a/settings.toml b/settings.toml index 39b5a5924..b24b28b25 100644 --- a/settings.toml +++ b/settings.toml @@ -3,17 +3,17 @@ DEBUG = false FLASK_ADMIN_TEMPLATE_MODE = "bootstrap3" FLASK_ADMIN_SWATCH = 'cerulean' SQLALCHEMY_DATABASE_URI = 'sqlite:///development.db' -TITLE = "project_name" +TITLE = "hiddifypanel" SECRET_KEY = "Pl3453Ch4ng3" PASSWORD_SCHEMES = ['pbkdf2_sha512', 'md5_crypt'] EXTENSIONS = [ "flask_bootstrap:Bootstrap", - "project_name.ext.database:init_app", - "project_name.ext.auth:init_app", - "project_name.ext.admin:init_app", - "project_name.ext.commands:init_app", - "project_name.ext.webui:init_app", - "project_name.ext.restapi:init_app", + "hiddifypanel.ext.database:init_app", + "hiddifypanel.ext.auth:init_app", + "hiddifypanel.ext.admin:init_app", + "hiddifypanel.ext.commands:init_app", + "hiddifypanel.ext.webui:init_app", + "hiddifypanel.ext.restapi:init_app", ] [development] diff --git a/setup.py b/setup.py index 06a458fbf..2fc2ec38c 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -"""Python setup.py for project_name package""" +"""Python setup.py for hiddifypanel package""" import io import os from setuptools import find_packages, setup @@ -6,7 +6,7 @@ def read(*paths, **kwargs): """Read the contents of a text file safely. - >>> read("project_name", "VERSION") + >>> read("hiddifypanel", "VERSION") '0.1.0' >>> read("README.md") ... @@ -30,17 +30,17 @@ def read_requirements(path): setup( - name="project_name", - version=read("project_name", "VERSION"), - description="project_description", - url="https://github.com/author_name/project_urlname/", + name="hiddifypanel", + version=read("hiddifypanel", "VERSION"), + description="Awesome hiddifypanel created by hiddify", + url="https://github.com/hiddify/HiddifyPanel/", long_description=read("README.md"), long_description_content_type="text/markdown", - author="author_name", + author="hiddify", packages=find_packages(exclude=["tests", ".github"]), install_requires=read_requirements("requirements.txt"), entry_points={ - "console_scripts": ["project_name = project_name.__main__:main"] + "console_scripts": ["hiddifypanel = hiddifypanel.__main__:main"] }, extras_require={ "test": read_requirements("requirements-test.txt") diff --git a/tests/conftest.py b/tests/conftest.py index 25798ba80..c936bbcaf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,9 @@ import sys import pytest -from project_name import create_app -from project_name.ext.commands import populate_db -from project_name.ext.database import db +from hiddifypanel import create_app +from hiddifypanel.ext.commands import populate_db +from hiddifypanel.ext.database import db @pytest.fixture(scope="session") diff --git a/wsgi.py b/wsgi.py index 3197cf900..ba5f19a42 100644 --- a/wsgi.py +++ b/wsgi.py @@ -1,3 +1,3 @@ -from project_name import create_app_wsgi +from hiddifypanel import create_app_wsgi app = application = create_app_wsgi() # noqa