Skip to content

Commit

Permalink
bugy#282 updated build process according to new vue-cli structure
Browse files Browse the repository at this point in the history
  • Loading branch information
bugy authored and antonellocaroli committed Aug 1, 2020
1 parent f16ae39 commit b59c988
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/utils/tool_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ 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)

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)


Expand Down
12 changes: 5 additions & 7 deletions tools/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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'])
1 change: 0 additions & 1 deletion web-src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down

0 comments on commit b59c988

Please sign in to comment.