1
0
forked from erp-dev/erp
Files
erpnew/api_v1/management/commands/set_app_version.py

41 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from datetime import date
from django.core.management.base import BaseCommand, CommandError
from flower.app_version import set_cached_app_version_payload
class Command(BaseCommand):
help = "创建 App 版本并设为当前版本"
def add_arguments(self, parser):
parser.add_argument("--major", type=int, required=True)
parser.add_argument("--minor", type=int, required=True)
parser.add_argument("--build", type=int, required=True)
parser.add_argument("--download-url", required=True)
parser.add_argument("--force", action="store_true", default=False)
parser.add_argument("--message", default="", help="更新说明")
parser.add_argument(
"--publish-date",
help="发布日期,格式 YYYY-MM-DD不传则使用当前日期",
)
def handle(self, *args, **options):
publish_date = options.get("publish_date")
if publish_date:
try:
date.fromisoformat(publish_date)
except ValueError as exc:
raise CommandError("publish-date 必须是 YYYY-MM-DD 格式") from exc
payload = set_cached_app_version_payload(
major=options["major"],
minor=options["minor"],
build=options["build"],
download_url=options["download_url"],
force=options["force"],
publish_date=publish_date,
message=options["message"],
)
self.stdout.write(self.style.SUCCESS(str(payload)))