Skip to content

Commit

Permalink
✅ Ready to clone and code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify authored and github-actions[bot] committed Jan 17, 2023
1 parent 89e97b8 commit f3ea231
Show file tree
Hide file tree
Showing 31 changed files with 77 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FLASK_ENV=development
FLASK_APP=project_name:create_app_wsgi
FLASK_APP=hiddifypanel:create_app_wsgi
10 changes: 5 additions & 5 deletions .github/rename_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 0 additions & 1 deletion .github/template.yml

This file was deleted.

4 changes: 2 additions & 2 deletions ABOUT_THIS_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# How to develop on this project

project_name welcomes contributions from the community.
hiddifypanel welcomes contributions from the community.

**You need PYTHON3!**

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 [email protected]: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 [email protected]: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

Expand Down
8 changes: 4 additions & 4 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ include LICENSE
include HISTORY.md
include Containerfile
graft tests
graft project_name
graft hiddifypanel
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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."
Expand All @@ -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
Expand All @@ -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
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <project_name>` or `$ project_name` with basic CLI argument parsing.
- 🎯 Entry points to execute your program using `python -m <hiddifypanel>` 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)
Expand All @@ -45,24 +45,24 @@ See also
<!-- DELETE THE LINES ABOVE THIS AND WRITE YOUR PROJECT README BELOW -->

---
# 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
Expand All @@ -72,24 +72,24 @@ 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.

## 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:
Expand Down
14 changes: 7 additions & 7 deletions apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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."
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion project_name/__main__.py → hiddifypanel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions project_name/ext/admin.py → hiddifypanel/ext/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions project_name/ext/auth.py → hiddifypanel/ext/auth.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
6 changes: 3 additions & 3 deletions project_name/ext/commands.py → hiddifypanel/ext/commands.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
2 changes: 1 addition & 1 deletion project_name/models.py → hiddifypanel/models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
site_name: project_name
site_name: hiddifypanel
theme: readthedocs
14 changes: 7 additions & 7 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
16 changes: 8 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Python setup.py for project_name package"""
"""Python setup.py for hiddifypanel package"""
import io
import os
from setuptools import find_packages, setup


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")
...
Expand All @@ -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")
Expand Down
Loading

0 comments on commit f3ea231

Please sign in to comment.