1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-19 08:26:23 -07:00

Rename devtools directory to tools, add get_js.py to download JS

This commit is contained in:
Eggbertx 2024-08-09 18:16:10 -07:00
parent 7307e2c6a4
commit 6a6a61f44e
20 changed files with 43 additions and 6 deletions

View file

@ -558,7 +558,7 @@ if __name__ == "__main__":
args = parser.parse_args()
sass(args.watch)
elif action == "selenium":
from devtools.selenium_testing.runtests import parseArgs, start_tests, close_tests
from tools.selenium_testing.runtests import parseArgs, start_tests, close_tests
args = parseArgs(parser)
try:
start_tests(args.browser, args.headless, args.keepopen, args.site, args.board, "html/static/notbanned.png", args.singletest)

37
tools/get_js.py Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env python3
# Use this to download the latest version of the pre-transpiled JavaScript files if you don't have Node/NPM installed
# it takes an optional command line argument, which specifies a custom output directory if set (js otherwise)
import gzip
from urllib.request import urlopen
import tarfile
import io
from os import path
import sys
VERSION = "v3.10.2"
DIR = "gochan-{}_linux".format(VERSION)
DOWNLOAD_URL = "https://github.com/gochan-org/gochan/releases/download/{}/{}.tar.gz".format(VERSION, DIR)
JS_DIR = path.join(DIR, "html/js/")
if __name__ == "__main__":
out_dir = "js"
if len(sys.argv) == 2:
match sys.argv[1]:
case "-h" | "--help":
print("usage: {} [path/to/out/js/]".format(sys.argv[0]))
sys.exit(0)
case _:
out_dir = sys.argv[1]
with urlopen(DOWNLOAD_URL) as response:
data = response.read()
tar_bytes = gzip.decompress(data)
buf = io.BytesIO(tar_bytes)
with tarfile.open(fileobj=buf) as tar_file:
files = tar_file.getmembers()
for file in files:
if file.path.startswith(JS_DIR):
file.path = file.path[len(JS_DIR):]
tar_file.extract(file, out_dir, filter=tarfile.tar_filter)

View file

@ -52,7 +52,7 @@ def start_tests(browser:str, headless=False, keep_open=False, site="", board="",
spec = importlib.util.spec_from_file_location(test_class, test_location)
module = importlib.util.module_from_spec(spec)
module.__package__ = "devtools.selenium_testing.tests"
module.__package__ = "tools.selenium_testing.tests"
spec.loader.exec_module(module)
suite = unittest.suite.TestSuite()

View file

@ -124,12 +124,12 @@ elif [ "$DBTYPE" = "sqlite3" ]; then
fi
# a convenient script for connecting to the db, whichever type we're using
ln -s {/vagrant/devtools,/home/vagrant}/dbconnect.sh
ln -s {/vagrant/tools,/home/vagrant}/dbconnect.sh
chmod +x /home/vagrant/dbconnect.sh
# used for testing migration from the pre-2021 db schema
ln -s {/vagrant/devtools,/home/vagrant}/get_pre2021.sh
ln -s {/vagrant/devtools,/home/vagrant}/get_previous_version.sh
ln -s {/vagrant/tools,/home/vagrant}/get_pre2021.sh
ln -s {/vagrant/tools,/home/vagrant}/get_previous_version.sh
chmod +x get_{pre2021,previous_version}.sh
cat <<EOF >>/home/vagrant/.bashrc
@ -141,7 +141,7 @@ su - vagrant <<EOF
echo 'alias bbig="cd /vagrant && ./build.py && sudo ./build.py install && sudo -E ./gochan"' >> /home/vagrant/.bash_aliases
mkdir -p /home/vagrant/go
source /home/vagrant/.bashrc
cd /vagrant/devtools
cd /vagrant/tools
./build_initdb.py
cd ..
mkdir -p $GOPATH/src/github.com/gochan-org/gochan