add admin script, update config, update dependencies

This commit is contained in:
aj 2020-07-31 11:21:29 +01:00
parent cd45dedf62
commit 9ba1b957d6
9 changed files with 1302 additions and 1499 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
service.json
node_modules/ node_modules/
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files

72
admin.py Normal file
View File

@ -0,0 +1,72 @@
#!/usr/bin/env python3
import shutil
import os
from pathlib import Path
import sys
from cmd import Cmd
stage_dir = '_sarsoo.xyz'
scss_rel_path = Path('src', 'scss', 'style.scss')
css_rel_path = Path('build', 'style.css')
folders_to_ignore = ['venv', 'docs', '.git', '.idea', 'node_modules']
class Admin(Cmd):
intro = 'Sarsoo.xyz Admin... ? for help'
prompt = '> '
def prepare_stage(self):
print('>> backing up a directory')
os.chdir(Path(__file__).absolute().parent.parent)
print('>> deleting old deployment stage')
shutil.rmtree(stage_dir, ignore_errors=True)
print('>> copying main source')
shutil.copytree('sarsoo.xyz',
stage_dir,
ignore=lambda path, contents:
contents if any(i in Path(path).parts for i in folders_to_ignore) else []
)
for dependency in ['fmframework']:
print(f'>> injecting {dependency}')
shutil.copytree(
Path(dependency, dependency),
Path(stage_dir, dependency)
)
os.chdir(stage_dir)
os.system('gcloud config set project sarsooxyz')
def prepare_frontend(self):
print('>> building css')
os.system(f'sass --style=compressed {scss_rel_path} {css_rel_path}')
print('>> building javascript')
os.system('npm run build')
def do_api(self, args):
self.prepare_frontend()
self.prepare_stage()
print('>> deploying')
os.system('gcloud app deploy')
def do_exit(self, args):
exit(0)
def do_sass(self, args):
os.system(f'sass --style=compressed {scss_rel_path} {css_rel_path}')
def do_watchsass(self, args):
os.system(f'sass --style=compressed --watch {scss_rel_path} {css_rel_path}')
if __name__ == '__main__':
console = Admin()
if len(sys.argv) > 1:
console.onecmd(' '.join(sys.argv[1:]))
else:
console.cmdloop()

27
deploy
View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
stage_dir=_sarsoo.xyz
echo '>> backing up a directory'
cd ..
echo '>> deleting old deployment stage'
rm -rf $stage_dir
echo '>> copying main source'
cp -r sarsoo.xyz $stage_dir
echo '>> injecting fmframework'
cp -r fmframework/fmframework $stage_dir/
cd $stage_dir
echo '>> building css'
sass --style=compressed src/scss/style.scss build/style.css
echo '>> building javascript'
npm run build
echo '>> deploying'
gcloud config set project sarsooxyz
gcloud app deploy

2646
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -19,16 +19,16 @@
}, },
"homepage": "https://github.com/Sarsoo/sarsoo.xyz#readme", "homepage": "https://github.com/Sarsoo/sarsoo.xyz#readme",
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.8.4", "@babel/cli": "^7.10.5",
"@babel/core": "^7.8.6", "@babel/core": "^7.11.0",
"@babel/preset-env": "^7.8.6", "@babel/preset-env": "^7.11.0",
"@babel/preset-react": "^7.8.3", "@babel/preset-react": "^7.10.4",
"babel-loader": "^8.1.0", "babel-loader": "^8.1.0",
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^3.0.0",
"css-loader": "^2.1.1", "css-loader": "^2.1.1",
"style-loader": "^0.23.1", "style-loader": "^0.23.1",
"webpack": "^4.41.6", "webpack": "^4.44.1",
"webpack-cli": "^3.3.11", "webpack-cli": "^3.3.12",
"webpack-merge": "^4.2.2" "webpack-merge": "^4.2.2"
}, },
"dependencies": { "dependencies": {

View File

@ -1,27 +1,25 @@
cachetools==4.0.0 cachetools==4.1.1
certifi==2019.11.28 certifi==2020.6.20
chardet==3.0.4 chardet==3.0.4
click==7.1.1 click==7.1.2
Flask==1.1.1 Flask==1.1.2
google-api-core==1.16.0 google-api-core==1.22.0
google-auth==1.12.0 google-auth==1.20.0
google-cloud-core==1.3.0 google-cloud-core==1.3.0
google-cloud-firestore==1.6.2 google-cloud-firestore==1.8.1
google-cloud-logging==1.15.0 google-cloud-logging==1.15.0
googleapis-common-protos==1.51.0 googleapis-common-protos==1.52.0
grpcio==1.27.2 grpcio==1.30.0
idna==2.9 idna==2.10
itsdangerous==1.1.0 itsdangerous==1.1.0
Jinja2==2.11.1 Jinja2==2.11.2
MarkupSafe==1.1.1 MarkupSafe==1.1.1
numpy==1.18.2 protobuf==3.12.4
opencv-python==4.2.0.32
protobuf==3.11.3
pyasn1==0.4.8 pyasn1==0.4.8
pyasn1-modules==0.2.8 pyasn1-modules==0.2.8
pytz==2019.3 pytz==2020.1
requests==2.23.0 requests==2.24.0
rsa==4.0 rsa==4.6
six==1.14.0 six==1.15.0
urllib3==1.25.8 urllib3==1.25.10
Werkzeug==1.0.0 Werkzeug==1.0.1

View File

@ -12,7 +12,7 @@ music_print = Blueprint('music', __name__, template_folder='templates')
@music_print.route('/') @music_print.route('/')
def root(): def root():
fmkey = fs.document('key/fm').get().to_dict()['clientid'] fmkey = fs.document('config/music-tools').get().to_dict()['last_fm_client_id']
fmnet = Network(username='sarsoo', api_key=fmkey) fmnet = Network(username='sarsoo', api_key=fmkey)
albums = fmnet.get_top_albums(Network.Range.MONTH, limit=6) albums = fmnet.get_top_albums(Network.Range.MONTH, limit=6)

1
sass
View File

@ -1 +0,0 @@
sass --style=compressed src/scss/style.scss build/style.css

View File

@ -1 +0,0 @@
sass --style=compressed --watch src/scss/style.scss build/style.css