diff --git a/db/project_name/settings/base.py b/db/project_name/settings/base.py index 6fef59a..20c0f51 100644 --- a/db/project_name/settings/base.py +++ b/db/project_name/settings/base.py @@ -39,6 +39,7 @@ 'wq.db.rest', 'wq.db.rest.auth',{% if not with_npm %} 'wq.app',{% endif %} + 'wq.build', # Project apps '{{ project_name }}_survey', @@ -137,10 +138,10 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ -STATIC_URL = '/static/'{% if not with_npm %} +STATIC_URL = '/static/' STATICFILES_DIRS = [ - ('app', BASE_DIR / 'app'), -]{% endif %} + {% if with_npm %}BASE_DIR / 'app' / 'build' / 'static'{% else %}('app', BASE_DIR / 'app'){% endif %}, +] # wq: Configure paths for default project layout PROJECT_NAME = '{{ title }}' diff --git a/deploy.bat b/deploy.bat new file mode 100644 index 0000000..ced1512 --- /dev/null +++ b/deploy.bat @@ -0,0 +1 @@ +python db/manage.py deploy %1 diff --git a/deploy.sh b/deploy.sh index 23b7a40..7b3950e 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,35 +1,4 @@ #!/bin/sh - -# Exit on error set -e - -VERSION=$1; - -if [ -z "$VERSION" ]; then - echo "Usage: ./deploy.sh [VERSION]" - exit 1 -fi; - -# Regenerate JSON fixtures -./update_json.sh $VERSION; - -wq icons; -{% if with_npm %} -# Build using react-scripts (Webpack/Babel) -cd app; -npm run build; - -# Update existing htdocs with new version -cd ..; -mkdir -p htdocs/ -cp -a app/build/* htdocs/ -{% else %} -# Collect static app files -wq build $VERSION -db/manage.py collectstatic --no-input -mv htdocs/static/app/public/*.* htdocs/ -wq serviceworker $VERSION -{% endif %} - -# Restart Django +db/manage.py deploy $1 touch db/{{project_name}}/wsgi.py diff --git a/update_json.sh b/update_json.sh deleted file mode 100755 index f24dbaa..0000000 --- a/update_json.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -VERSION=$1; - -# Dump wq configuration object to file -db/manage.py dump_config --format esm > app/{% if with_npm %}src{% else %}js{% endif %}/data/config.js - -# Update version.txt{% if with_npm %} and package.json{% endif %} -if [ "$VERSION" ]; then - wq setversion $VERSION -fi; diff --git a/wq.yml b/wq.yml index 5fc0704..142e5a5 100644 --- a/wq.yml +++ b/wq.yml @@ -4,12 +4,23 @@ setversion: package: app/package.json{% else %} esm: app/js/data/version.js{% endif %} +# Generate config.js +dump_config: + format: esm + filename: app/{% if with_npm %}src{% else %}js{% endif %}/data/config.js + # Generate web icons icons: source: app/public/icon-1024.png filename: app/public/icon-{size}.png size: web -{% if not with_npm %}# Generate Service Worker + +# Move public files to root +movefiles: + source: {% if with_npm %}app/build{% else %}htdocs/static/app/public{% endif %}/*.* + dest: htdocs/ +{% if not with_npm %} +# Generate Service Worker serviceworker: output: ./htdocs/service-worker.js timeout: 400