diff --git a/bench/package.json b/bench/package.json deleted file mode 100644 index 31121283..00000000 --- a/bench/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "frappe", - "description": "Default package.json for frappe apps", - "dependencies": { - "babel-core": "^6.24.1", - "babel-preset-babili": "0.0.12", - "babel-preset-es2015": "^6.24.1", - "babel-preset-es2016": "^6.24.1", - "babel-preset-es2017": "^6.24.1", - "chokidar": "^1.7.0", - "cookie": "^0.3.1", - "express": "^4.15.3", - "less": "^2.7.2", - "redis": "^2.7.1", - "socket.io": "^2.0.1", - "superagent": "^3.5.2" - } -} diff --git a/bench/patches/patches.txt b/bench/patches/patches.txt index e979b0d6..f9adc549 100644 --- a/bench/patches/patches.txt +++ b/bench/patches/patches.txt @@ -3,4 +3,4 @@ bench.patches.v3.celery_to_rq bench.patches.v3.redis_bind_ip bench.patches.v4.update_node bench.patches.v4.update_socketio - +bench.patches.v4.install_yarn diff --git a/bench/patches/v4/install_yarn.py b/bench/patches/v4/install_yarn.py new file mode 100644 index 00000000..4ea0c23a --- /dev/null +++ b/bench/patches/v4/install_yarn.py @@ -0,0 +1,4 @@ +import subprocess + +def execute(bench_path): + subprocess.check_output(['npm', 'install', '-g', 'yarn']) \ No newline at end of file diff --git a/bench/utils.py b/bench/utils.py index aafa29cd..3ce3f264 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -144,7 +144,7 @@ def exec_cmd(cmd, cwd='.'): def which(executable, raise_err = False): from distutils.spawn import find_executable exec_ = find_executable(executable) - + if not exec_ and raise_err: raise ValueError('{executable} not found.'.format( executable = executable @@ -430,34 +430,11 @@ def update_requirements(bench_path='.'): def update_npm_packages(bench_path='.'): print('Updating node libraries...') apps_dir = os.path.join(bench_path, 'apps') - package_json = {} for app in os.listdir(apps_dir): - package_json_path = os.path.join(apps_dir, app, 'package.json') + app_path = os.path.join(apps_dir, app) + exec_cmd('yarn install', cwd=app_path) - if os.path.exists(package_json_path): - with open(package_json_path, "r") as f: - app_package_json = json.loads(f.read()) - # package.json is usually a dict in a dict - for key, value in iteritems(app_package_json): - if not key in package_json: - package_json[key] = value - else: - if isinstance(value, dict): - package_json[key].update(value) - elif isinstance(value, list): - package_json[key].extend(value) - else: - package_json[key] = value - - if package_json is {}: - with open(os.path.join(os.path.dirname(__file__), 'package.json'), 'r') as f: - package_json = json.loads(f.read()) - - with open(os.path.join(bench_path, 'package.json'), 'w') as f: - f.write(json.dumps(package_json, indent=1, sort_keys=True)) - - exec_cmd('npm install', cwd=bench_path) def install_requirements(pip, req_file): if os.path.exists(req_file): @@ -784,12 +761,11 @@ def run_playbook(playbook_name, extra_vars=None, tag=None): print("Ansible is needed to run this command, please install it using 'pip install ansible'") sys.exit(1) args = ['ansible-playbook', '-c', 'local', playbook_name] - + if extra_vars: args.extend(['-e', json.dumps(extra_vars)]) - + if tag: args.extend(['-t', tag]) - + subprocess.check_call(args, cwd=os.path.join(os.path.dirname(bench.__path__[0]), 'playbooks')) - \ No newline at end of file