2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-14 09:14:04 +00:00

Merge branch 'master' into clean_code

This commit is contained in:
Ameya Shenoy 2018-02-28 12:29:42 +05:30
commit e0af4e24f1
No known key found for this signature in database
GPG Key ID: 735490161CD5C91E
2 changed files with 18 additions and 15 deletions

View File

@ -127,18 +127,21 @@ def setup_socketio():
from bench.utils import setup_socketio from bench.utils import setup_socketio
setup_socketio() setup_socketio()
@click.command('requirements') @click.command('requirements', help="Update Python and Node packages")
def setup_requirements(): @click.option('--node', help="Update only Node packages", default=False, is_flag=True)
@click.option('--python', help="Update only Python packages", default=False, is_flag=True)
def setup_requirements(node=False, python=False):
"Setup python and node requirements" "Setup python and node requirements"
setup_python_requirements()
setup_node_requirements()
@click.command('python-requirements') if not node:
setup_python_requirements()
if not python:
setup_node_requirements()
def setup_python_requirements(): def setup_python_requirements():
from bench.utils import update_requirements from bench.utils import update_requirements
update_requirements() update_requirements()
@click.command('node-requirements')
def setup_node_requirements(): def setup_node_requirements():
from bench.utils import update_node_packages from bench.utils import update_node_packages
update_node_packages() update_node_packages()
@ -236,8 +239,6 @@ setup.add_command(setup_env)
setup.add_command(setup_procfile) setup.add_command(setup_procfile)
setup.add_command(setup_socketio) setup.add_command(setup_socketio)
setup.add_command(setup_requirements) setup.add_command(setup_requirements)
setup.add_command(setup_python_requirements)
setup.add_command(setup_node_requirements)
setup.add_command(setup_config) setup.add_command(setup_config)
setup.add_command(setup_fonts) setup.add_command(setup_fonts)
setup.add_command(add_domain) setup.add_command(add_domain)

View File

@ -72,7 +72,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
bench.set_frappe_version(bench_path=path) bench.set_frappe_version(bench_path=path)
if bench.FRAPPE_VERSION > 5: if bench.FRAPPE_VERSION > 5:
update_npm_packages(bench_path=path) update_node_packages(bench_path=path)
set_all_patches_executed(bench_path=path) set_all_patches_executed(bench_path=path)
build_assets(bench_path=path) build_assets(bench_path=path)
@ -92,8 +92,10 @@ def clone_apps_from(bench_path, clone_from):
print('Copying apps from {0}...'.format(clone_from)) print('Copying apps from {0}...'.format(clone_from))
subprocess.check_output(['cp', '-R', os.path.join(clone_from, 'apps'), bench_path]) subprocess.check_output(['cp', '-R', os.path.join(clone_from, 'apps'), bench_path])
print('Copying node_modules from {0}...'.format(clone_from)) node_modules_path = os.path.join(clone_from, 'node_modules')
subprocess.check_output(['cp', '-R', os.path.join(clone_from, 'node_modules'), bench_path]) if os.path.exists(node_modules_path):
print('Copying node_modules from {0}...'.format(clone_from))
subprocess.check_output(['cp', '-R', node_modules_path, bench_path])
def setup_app(app): def setup_app(app):
# run git reset --hard in each branch, pull latest updates and install_app # run git reset --hard in each branch, pull latest updates and install_app
@ -428,17 +430,17 @@ def update_requirements(bench_path='.'):
req_file = os.path.join(apps_dir, app, 'requirements.txt') req_file = os.path.join(apps_dir, app, 'requirements.txt')
install_requirements(pip, req_file) install_requirements(pip, req_file)
def update_node_packages(): def update_node_packages(bench_path='.'):
print('Updating node packages...') print('Updating node packages...')
from bench.app import get_current_version from bench.app import get_current_version
v = semantic_version.Version(get_current_version('frappe')) v = semantic_version.Version(get_current_version('frappe', bench_path = bench_path))
# After rollup was merged, frappe_version = 10.1 # After rollup was merged, frappe_version = 10.1
# anything before that was npm based # anything before that was npm based
if v.major <= 10 and v.minor < 1: if v.major <= 10 and v.minor < 1:
update_npm_packages() update_npm_packages(bench_path)
else: else:
update_yarn_packages() update_yarn_packages(bench_path)
def update_yarn_packages(bench_path='.'): def update_yarn_packages(bench_path='.'):
apps_dir = os.path.join(bench_path, 'apps') apps_dir = os.path.join(bench_path, 'apps')