mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
scripts: Rename NPM_CACHE_PATH to NODE_MODULES_CACHE_PATH.
This commit is contained in:
@@ -10,11 +10,11 @@ if False:
|
|||||||
from scripts.lib.zulip_tools import subprocess_text_output, run
|
from scripts.lib.zulip_tools import subprocess_text_output, run
|
||||||
|
|
||||||
ZULIP_PATH = dirname(dirname(dirname(abspath(__file__))))
|
ZULIP_PATH = dirname(dirname(dirname(abspath(__file__))))
|
||||||
NPM_CACHE_PATH = "/srv/zulip-npm-cache"
|
NODE_MODULES_CACHE_PATH = "/srv/zulip-npm-cache"
|
||||||
|
|
||||||
if 'TRAVIS' in os.environ:
|
if 'TRAVIS' in os.environ:
|
||||||
# In Travis CI, we don't have root access
|
# In Travis CI, we don't have root access
|
||||||
NPM_CACHE_PATH = "/home/travis/zulip-npm-cache"
|
NODE_MODULES_CACHE_PATH = "/home/travis/zulip-npm-cache"
|
||||||
|
|
||||||
def generate_sha1sum_node_modules(npm_args=None):
|
def generate_sha1sum_node_modules(npm_args=None):
|
||||||
# type: (Optional[List[str]]) -> str
|
# type: (Optional[List[str]]) -> str
|
||||||
@@ -30,7 +30,7 @@ def generate_sha1sum_node_modules(npm_args=None):
|
|||||||
def setup_node_modules(npm_args=None, stdout=None, stderr=None, copy_modules=False):
|
def setup_node_modules(npm_args=None, stdout=None, stderr=None, copy_modules=False):
|
||||||
# type: (Optional[List[str]], Optional[IO], Optional[IO], Optional[bool]) -> None
|
# type: (Optional[List[str]], Optional[IO], Optional[IO], Optional[bool]) -> None
|
||||||
sha1sum = generate_sha1sum_node_modules(npm_args)
|
sha1sum = generate_sha1sum_node_modules(npm_args)
|
||||||
npm_cache = os.path.join(NPM_CACHE_PATH, sha1sum)
|
npm_cache = os.path.join(NODE_MODULES_CACHE_PATH, sha1sum)
|
||||||
cached_node_modules = os.path.join(npm_cache, 'node_modules')
|
cached_node_modules = os.path.join(npm_cache, 'node_modules')
|
||||||
success_stamp = os.path.join(cached_node_modules, '.success-stamp')
|
success_stamp = os.path.join(cached_node_modules, '.success-stamp')
|
||||||
# Check if a cached version already exists
|
# Check if a cached version already exists
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import sys
|
|||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
from scripts.lib.node_cache import generate_sha1sum_node_modules
|
from scripts.lib.node_cache import generate_sha1sum_node_modules
|
||||||
|
|
||||||
NPM_CACHE_PATH = "/srv/zulip-npm-cache"
|
NODE_MODULES_CACHE_PATH = "/srv/zulip-npm-cache"
|
||||||
if "--travis" in sys.argv:
|
if "--travis" in sys.argv:
|
||||||
try:
|
try:
|
||||||
subprocess.check_output(['npm', '--version'])
|
subprocess.check_output(['npm', '--version'])
|
||||||
@@ -16,15 +16,15 @@ if "--travis" in sys.argv:
|
|||||||
print('NPM not found. Most probably we are running static-analysis and '
|
print('NPM not found. Most probably we are running static-analysis and '
|
||||||
'hence npm is not installed. Exiting without cleaning npm cache.')
|
'hence npm is not installed. Exiting without cleaning npm cache.')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
NPM_CACHE_PATH = os.path.join(os.environ["HOME"], "zulip-npm-cache")
|
NODE_MODULES_CACHE_PATH = os.path.join(os.environ["HOME"], "zulip-npm-cache")
|
||||||
|
|
||||||
sha1sum = generate_sha1sum_node_modules()
|
sha1sum = generate_sha1sum_node_modules()
|
||||||
npm_cache = os.path.join(NPM_CACHE_PATH, sha1sum)
|
npm_cache = os.path.join(NODE_MODULES_CACHE_PATH, sha1sum)
|
||||||
cached_node_modules = os.path.join(npm_cache, 'node_modules')
|
cached_node_modules = os.path.join(npm_cache, 'node_modules')
|
||||||
success_stamp = os.path.join(cached_node_modules, '.success-stamp')
|
success_stamp = os.path.join(cached_node_modules, '.success-stamp')
|
||||||
|
|
||||||
for cache_dir_base in os.listdir(NPM_CACHE_PATH):
|
for cache_dir_base in os.listdir(NODE_MODULES_CACHE_PATH):
|
||||||
npm_cache_dir = os.path.join(NPM_CACHE_PATH, cache_dir_base)
|
npm_cache_dir = os.path.join(NODE_MODULES_CACHE_PATH, cache_dir_base)
|
||||||
if npm_cache_dir != npm_cache or not os.path.exists(success_stamp):
|
if npm_cache_dir != npm_cache or not os.path.exists(success_stamp):
|
||||||
print("Cleaning unused NPM cache dir %s" % (npm_cache_dir,))
|
print("Cleaning unused NPM cache dir %s" % (npm_cache_dir,))
|
||||||
subprocess.check_call(["sudo", "rm", "-rf", npm_cache_dir])
|
subprocess.check_call(["sudo", "rm", "-rf", npm_cache_dir])
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__f
|
|||||||
sys.path.append(ZULIP_PATH)
|
sys.path.append(ZULIP_PATH)
|
||||||
from scripts.lib.zulip_tools import run, subprocess_text_output, OKBLUE, ENDC, WARNING
|
from scripts.lib.zulip_tools import run, subprocess_text_output, OKBLUE, ENDC, WARNING
|
||||||
from scripts.lib.setup_venv import setup_virtualenv, VENV_DEPENDENCIES
|
from scripts.lib.setup_venv import setup_virtualenv, VENV_DEPENDENCIES
|
||||||
from scripts.lib.node_cache import setup_node_modules, NPM_CACHE_PATH
|
from scripts.lib.node_cache import setup_node_modules, NODE_MODULES_CACHE_PATH
|
||||||
|
|
||||||
from version import PROVISION_VERSION
|
from version import PROVISION_VERSION
|
||||||
if False:
|
if False:
|
||||||
@@ -236,9 +236,9 @@ def main(options):
|
|||||||
# issue with the symlinks being improperly owned by root.
|
# issue with the symlinks being improperly owned by root.
|
||||||
if os.path.islink("node_modules"):
|
if os.path.islink("node_modules"):
|
||||||
run(["sudo", "rm", "-f", "node_modules"])
|
run(["sudo", "rm", "-f", "node_modules"])
|
||||||
if not os.path.isdir(NPM_CACHE_PATH):
|
if not os.path.isdir(NODE_MODULES_CACHE_PATH):
|
||||||
run(["sudo", "mkdir", NPM_CACHE_PATH])
|
run(["sudo", "mkdir", NODE_MODULES_CACHE_PATH])
|
||||||
run(["sudo", "chown", "%s:%s" % (user_id, user_id), NPM_CACHE_PATH])
|
run(["sudo", "chown", "%s:%s" % (user_id, user_id), NODE_MODULES_CACHE_PATH])
|
||||||
setup_node_modules()
|
setup_node_modules()
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
print(WARNING + "`npm install` failed; retrying..." + ENDC)
|
print(WARNING + "`npm install` failed; retrying..." + ENDC)
|
||||||
|
|||||||
Reference in New Issue
Block a user