mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 00:21:23 +00:00
fix bench init with v4
This commit is contained in:
parent
0f74b9b47e
commit
b13adc28f2
@ -148,7 +148,6 @@ def install_apps_from_path(path, bench='.'):
|
||||
apps = get_apps_json(path)
|
||||
for app in apps:
|
||||
get_app(app['name'], app['url'], branch=app.get('branch'), bench=bench, build_asset_files=False)
|
||||
build_assets(bench=bench)
|
||||
|
||||
def get_apps_json(path):
|
||||
if path.startswith('http'):
|
||||
|
@ -76,7 +76,7 @@ def change_uid():
|
||||
sys.exit(1)
|
||||
|
||||
def change_dir():
|
||||
if os.path.exists('config.json'):
|
||||
if os.path.exists('config.json') or "init" in sys.argv:
|
||||
return
|
||||
dir_path_file = '/etc/frappe_bench_dir'
|
||||
if os.path.exists(dir_path_file):
|
||||
@ -218,6 +218,8 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
|
||||
version_upgrade = is_version_upgrade()
|
||||
|
||||
if version_upgrade and not upgrade:
|
||||
print
|
||||
print
|
||||
print "This update will cause a major version change in Frappe/ERPNext from {0} to {1}.".format(*version_upgrade)
|
||||
print "This would take significant time to migrate and might break custom apps. Please run `bench update --upgrade` to confirm."
|
||||
sys.exit(1)
|
||||
|
@ -35,6 +35,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
||||
no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None):
|
||||
from .app import get_app, install_apps_from_path
|
||||
from .config import generate_redis_config
|
||||
global FRAPPE_VERSION
|
||||
if os.path.exists(path):
|
||||
print 'Directory {} already exists!'.format(path)
|
||||
sys.exit(1)
|
||||
@ -50,9 +51,10 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
||||
if wheel_cache_dir:
|
||||
update_config({"wheel_cache_dir":wheel_cache_dir}, bench=path)
|
||||
prime_wheel_cache(bench=path)
|
||||
|
||||
if not frappe_path:
|
||||
frappe_path = 'https://github.com/frappe/frappe.git'
|
||||
get_app('frappe', frappe_path, branch=frappe_branch, bench=path)
|
||||
get_app('frappe', frappe_path, branch=frappe_branch, bench=path, build_asset_files=False)
|
||||
if not no_procfile:
|
||||
setup_procfile(bench=path)
|
||||
if not no_backups:
|
||||
@ -61,6 +63,8 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
||||
setup_auto_update(bench=path)
|
||||
if apps_path:
|
||||
install_apps_from_path(apps_path, bench=path)
|
||||
FRAPPE_VERSION = get_current_frappe_version(bench=path)
|
||||
build_assets(bench=bench)
|
||||
generate_redis_config(bench=path)
|
||||
|
||||
def exec_cmd(cmd, cwd='.'):
|
||||
@ -407,9 +411,9 @@ def get_redis_version():
|
||||
if re.search("Redis server v=2.8", version_string):
|
||||
return "2.8"
|
||||
|
||||
def get_current_frappe_version():
|
||||
def get_current_frappe_version(bench='.'):
|
||||
from .app import get_current_frappe_version as fv
|
||||
return fv()
|
||||
return fv(bench=bench)
|
||||
|
||||
def run_frappe_cmd(*args, **kwargs):
|
||||
bench = kwargs.get('bench', '.')
|
||||
@ -421,13 +425,20 @@ def run_frappe_cmd(*args, **kwargs):
|
||||
def pre_upgrade(from_ver, to_ver, bench='.'):
|
||||
from .migrate_to_v5 import validate_v4, remove_shopping_cart
|
||||
if from_ver == 4 and to_ver == 5:
|
||||
apps = ('frappe', 'erpnext')
|
||||
remove_shopping_cart(bench=bench)
|
||||
|
||||
for app in apps:
|
||||
cwd = os.path.join(bench, 'apps', repo)
|
||||
if os.path.exists(cwd):
|
||||
exec_cmd("git clean -df", cwd=cwd)
|
||||
|
||||
def post_upgrade(from_ver, to_ver, bench='.'):
|
||||
from .app import get_current_frappe_version
|
||||
from .config import generate_nginx_config, generate_supervisor_config, generate_redis_config
|
||||
conf = get_config(bench=bench)
|
||||
if from_ver == 4 and to_ver == 5:
|
||||
print "-"*80
|
||||
print "Your bench was upgraded to version 5"
|
||||
if conf.get('restart_supervisor_on_update'):
|
||||
generate_redis_config(bench=bench)
|
||||
|
@ -16,7 +16,7 @@ get_passwd() {
|
||||
}
|
||||
|
||||
set_opts () {
|
||||
OPTS=`getopt -o v --long verbose,mysql-root-password:,frappe-user:,setup-production,bench-branch:,skip-setup-bench,help -n 'parse-options' -- "$@"`
|
||||
OPTS=`getopt -o v --long verbose,mysql-root-password:,frappe-user:,bench-branch:,setup-production,skip-setup-bench,help -n 'parse-options' -- "$@"`
|
||||
|
||||
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user