From b59c988b9aadea4731fb11258211cf23f81a36df Mon Sep 17 00:00:00 2001 From: yshepilov Date: Thu, 16 Apr 2020 21:46:00 +0200 Subject: [PATCH] #282 updated build process according to new vue-cli structure --- .travis.yml | 2 +- README.md | 4 ++-- src/utils/tool_utils.py | 9 ++++++++- tools/init.py | 12 +++++------- web-src/package.json | 1 - 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38356b41..8b69a74f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_script: - cd src - python3 -m unittest discover -s tests -p "*.py" -t . - cd ../web-src -- npm run test +- npm run test:unit-ci - cd .. script: - python3 tools/build.py diff --git a/README.md b/README.md index ec1c0a27..3c793edd 100644 --- a/README.md +++ b/README.md @@ -57,11 +57,11 @@ For the usage please check [this ticket](https://github.com/bugy/script-server/i ### For development 1. Clone/download the repository -2. Run 'tools/init.py --dev --no-npm' script +2. Run 'tools/init.py --no-npm' script `init.py` script should be run after pulling any new changes -If you are making changes to web files, use `npm run build:dev` or `npm run start:dev` +If you are making changes to web files, use `npm run build` or `npm run serve` ## Setup and run diff --git a/src/utils/tool_utils.py b/src/utils/tool_utils.py index d028fc10..01404b95 100644 --- a/src/utils/tool_utils.py +++ b/src/utils/tool_utils.py @@ -9,7 +9,7 @@ def validate_web_build_exists(project_path): how_to_fix_build_message = \ 'How to fix: ' \ '\n - PROD: please use stable releases from https://github.com/bugy/script-server/releases/latest' \ - '\n - DEV: please run tools/init.py --dev --no-npm' + '\n - DEV: please run tools/init.py --no-npm' if not os.path.exists(web_folder): raise InvalidWebBuildException(web_folder + ' does not exist. \n' + how_to_fix_build_message) @@ -17,7 +17,14 @@ def validate_web_build_exists(project_path): required_files = ['index.js', 'index.html', 'index-deps.css', 'admin.html', 'admin.js'] for file in required_files: file_path = os.path.join(web_folder, file) + + valid = True if not os.path.exists(file_path): + valid = False + elif os.path.isdir(file_path) and not os.listdir(file_path): + valid = False + + if not valid: raise InvalidWebBuildException('web folder is invalid. \n' + how_to_fix_build_message) diff --git a/tools/init.py b/tools/init.py index 1f02c0d2..4a4bae0a 100755 --- a/tools/init.py +++ b/tools/init.py @@ -24,20 +24,19 @@ def download_web_files(project_path): print('Done') -def build_web_files(prod, project_path): +def build_web_files(project_path): print('Building web...') - npm_mode = 'prod' if prod else 'dev' work_dir = os.path.join(project_path, 'web-src') process_utils.invoke('npm install', work_dir) - process_utils.invoke('npm run build:' + npm_mode, work_dir) + process_utils.invoke('npm run build', work_dir) print('Done') -def prepare_project(project_path, *, prod, download_web=False): +def prepare_project(project_path, *, download_web=False): if download_web: download_web_files(project_path) else: - build_web_files(prod, project_path) + build_web_files(project_path) runners_conf = os.path.join(project_path, 'conf', 'runners') if not os.path.exists(runners_conf): @@ -53,7 +52,6 @@ def prepare_project(project_path, *, prod, download_web=False): parser = argparse.ArgumentParser(description='Initializes source code repo to make it runnable') parser.add_argument('--no-npm', action='store_true', default=False) - parser.add_argument('--dev', action='store_true', default=False) args = vars(parser.parse_args()) - prepare_project(project_path, prod=not args['dev'], download_web=args['no_npm']) + prepare_project(project_path, download_web=args['no_npm']) diff --git a/web-src/package.json b/web-src/package.json index b4c9927a..f492dc74 100644 --- a/web-src/package.json +++ b/web-src/package.json @@ -52,7 +52,6 @@ "build": "vue-cli-service build", "test:unit": "vue-cli-service test:unit", "test:unit-ci": "vue-cli-service test:unit -b ChromeHeadless", - "test:e2e": "vue-cli-service test:e2e", "stryker": "stryker run tests/stryker.conf.js" }, "browserslist": [