Skip to content

Commit

Permalink
fix: Adapt for AAS
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFunny committed Nov 1, 2023
1 parent 6860f2e commit 3c4c9a6
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 55 deletions.
2 changes: 1 addition & 1 deletion config/deploy.template-cn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Deploy:
Git:
# URL of AzurLaneAutoScript repository
# [CN user] Use 'cn' to get update from git-over-cdn service
# [Other] Use 'global' to get update from https://github.com/LmeSzinc/StarRailCopilot
# [Other] Use 'global' to get update from https://github.com/TheFunny/ArisuAutoSrcipt
Repository: cn
# Branch of Alas
# [Developer] Use 'dev', 'app', etc, to try new features
Expand Down
2 changes: 1 addition & 1 deletion config/deploy.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Deploy:
Git:
# URL of AzurLaneAutoScript repository
# [CN user] Use 'cn' to get update from git-over-cdn service
# [Other] Use 'global' to get update from https://github.com/LmeSzinc/StarRailCopilot
# [Other] Use 'global' to get update from https://github.com/TheFunny/ArisuAutoSrcipt
Repository: global
# Branch of Alas
# [Developer] Use 'dev', 'app', etc, to try new features
Expand Down
64 changes: 32 additions & 32 deletions deploy/Windows/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from deploy.Windows.config import DeployConfig
from deploy.Windows.logger import Progress, logger
from deploy.Windows.utils import cached_property
from deploy.git_over_cdn.client import GitOverCdnClient
# from deploy.git_over_cdn.client import GitOverCdnClient


class GitConfigParser(configparser.ConfigParser):
Expand All @@ -17,23 +17,23 @@ def check(self, section, option, value):
return False


class GitOverCdnClientWindows(GitOverCdnClient):
def update(self, *args, **kwargs):
Progress.GitInit()
_ = super().update(*args, **kwargs)
Progress.GitShowVersion()
return _

@cached_property
def latest_commit(self) -> str:
_ = super().latest_commit
Progress.GitLatestCommit()
return _

def download_pack(self):
_ = super().download_pack()
Progress.GitDownloadPack()
return _
# class GitOverCdnClientWindows(GitOverCdnClient):
# def update(self, *args, **kwargs):
# Progress.GitInit()
# _ = super().update(*args, **kwargs)
# Progress.GitShowVersion()
# return _
#
# @cached_property
# def latest_commit(self) -> str:
# _ = super().latest_commit
# Progress.GitLatestCommit()
# return _
#
# def download_pack(self):
# _ = super().download_pack()
# Progress.GitDownloadPack()
# return _


class GitManager(DeployConfig):
Expand Down Expand Up @@ -128,17 +128,17 @@ def git_repository_init(
self.execute(f'"{self.git}" --no-pager log --no-merges -1')
Progress.GitShowVersion()

@property
def goc_client(self):
client = GitOverCdnClient(
url='https://vip.123pan.cn/1815343254/pack/LmeSzinc_StarRailCopilot_master',
folder=self.root_filepath,
source='origin',
branch='master',
git=self.git,
)
client.logger = logger
return client
# @property
# def goc_client(self):
# client = GitOverCdnClient(
# url='https://vip.123pan.cn/1815343254/pack/LmeSzinc_StarRailCopilot_master',
# folder=self.root_filepath,
# source='origin',
# branch='master',
# git=self.git,
# )
# client.logger = logger
# return client

def git_install(self):
logger.hr('Update Alas', 0)
Expand All @@ -148,9 +148,9 @@ def git_install(self):
Progress.GitShowVersion()
return

if self.GitOverCdn:
if self.goc_client.update(keep_changes=self.KeepLocalChanges):
return
# if self.GitOverCdn:
# if self.goc_client.update(keep_changes=self.KeepLocalChanges):
# return

self.git_repository_init(
repo=self.Repository,
Expand Down
2 changes: 1 addition & 1 deletion deploy/Windows/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Deploy:
Git:
# URL of AzurLaneAutoScript repository
# [CN user] Use 'cn' to get update from git-over-cdn service
# [Other] Use 'global' to get update from https://github.com/LmeSzinc/StarRailCopilot
# [Other] Use 'global' to get update from https://github.com/TheFunny/ArisuAutoSrcipt
Repository: 'global'
# Branch of Alas
# [Developer] Use 'dev', 'app', etc, to try new features
Expand Down
55 changes: 55 additions & 0 deletions installer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import argparse
import sys
import typing as t

sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')

"""
Alas installer
"""


def run_install():
from deploy.installer import run
run()


def run_print_test():
from deploy.Windows.installer_test import run
run()


def run_set(modify=t.List[str]) -> t.Dict[str, str]:
data = {}
for kv in modify:
if "=" in kv:
key, value = kv.split('=', maxsplit=1)
data[key] = value

from deploy.set import config_set
return config_set(data)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Alas installer")
parser.add_argument(
"--print-test",
help="To print example installer outputs instead of making an actual installation",
action="store_true",
)
parser.add_argument(
"--set",
help="Use key=value format to modify config/deploy.yaml\n"
"Example: python installer.py --set Branch=dev",
type=str,
nargs="*",
)
args, _ = parser.parse_known_args()

if args.set:
run_set(args.set)
elif args.print_test:
run_print_test()
else:
run_install()
6 changes: 3 additions & 3 deletions module/webui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,9 +1108,9 @@ def set_theme(t):
# show something
put_markdown(
"""
SRC is a free open source software, if you paid for SRC from any channel, please refund.
SRC 是一款免费开源软件,如果你在任何渠道付费购买了SRC,请退款。
Project repository 项目地址:`https://github.com/LmeSzinc/StarRailCopilot`
AAS is a free open source software, if you paid for AAS from any channel, please refund.
AAS 是一款免费开源软件,如果你在任何渠道付费购买了AAS,请退款。
Project repository 项目地址:`https://github.com/TheFunny/ArisuAutoSrcipt`
"""
).style("text-align: center")

Expand Down
22 changes: 11 additions & 11 deletions module/webui/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ def get_commit(self, revision="", n=1, short_sha1=False) -> Tuple:
def _check_update(self) -> bool:
self.state = "checking"

if State.deploy_config.GitOverCdn:
status = self.goc_client.get_status()
if status == "uptodate":
logger.info(f"No update")
return False
elif status == "behind":
logger.info(f"New update available")
return True
else:
# failed, should fallback to `git pull`
pass
# if State.deploy_config.GitOverCdn:
# status = self.goc_client.get_status()
# if status == "uptodate":
# logger.info(f"No update")
# return False
# elif status == "behind":
# logger.info(f"New update available")
# return True
# else:
# # failed, should fallback to `git pull`
# pass

source = "origin"
for _ in range(3):
Expand Down
3 changes: 0 additions & 3 deletions requirements-in.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ starlette==0.14.2
uvicorn[standard]==0.17.6
aiofiles

# Game resources
srcmap==1.1.0

# For dev
# pip-tools
pynput
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ scipy==1.10.1 # via -r requirements-in.txt
shapely==2.0.1 # via pponnxcr
six==1.16.0 # via pynput, uiautomator2
sniffio==1.3.0 # via anyio
srcmap==1.1.0 # via -r requirements-in.txt
starlette==0.14.2 # via -r requirements-in.txt
sympy==1.12 # via onnxruntime
tornado==6.3.1 # via pywebio
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/common/utils/getAlasABSPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import fs from 'fs';
*/
const getAlasABSPath = (
files: string[] = ['**/config/deploy.yaml', '**/config/deploy.template.yaml'],
rootName: string | string[] = ['AzurLaneAutoScript', 'Alas', 'StarRailCopilot'],
rootName: string | string[] = ['AzurLaneAutoScript', 'Alas', 'ArisuAutoSweeper'],
) => {
const path = require('path');
const sep = path.sep;
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/main/public/deploy.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Deploy:
Git:
# URL of AzurLaneAutoScript repository
# [CN user] Use 'cn' to get update from git-over-cdn service
# [Other] Use 'global' to get update from https://github.com/LmeSzinc/StarRailCopilot
# [Other] Use 'global' to get update from https://github.com/TheFunny/ArisuAutoSrcipt
Repository: {{repository}}
# Branch of Alas
# [Developer] Use 'dev', 'app', etc, to try new features
Expand Down

0 comments on commit 3c4c9a6

Please sign in to comment.