update.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # coding: utf-8
  2. # Copyright (c) Jupyter Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. from os.path import join as pjoin
  5. import json
  6. import os
  7. import shutil
  8. HERE = os.path.dirname(__file__)
  9. # Get the dev mode package.json file.
  10. dev_path = os.path.realpath(pjoin(HERE, '..', 'dev_mode'))
  11. with open(pjoin(dev_path, 'package.json')) as fid:
  12. data = json.load(fid)
  13. # Update the values that need to change and write to staging.
  14. data['scripts']['build'] = 'webpack'
  15. data['scripts']['watch'] = 'webpack --watch'
  16. data['scripts']['build:prod'] = (
  17. "webpack --define process.env.NODE_ENV=\"'production'\"")
  18. data['jupyterlab']['outputDir'] = '..'
  19. data['jupyterlab']['staticDir'] = '../static'
  20. data['jupyterlab']['linkedPackages'] = dict()
  21. staging = pjoin(HERE, 'staging')
  22. with open(pjoin(staging, 'package.json'), 'w') as fid:
  23. json.dump(data, fid)
  24. # Update our index file and webpack file.
  25. for fname in ['index.js', 'webpack.config.js']:
  26. shutil.copy(pjoin(dev_path, fname), pjoin(staging, fname))
  27. # Get a new yarn lock file.
  28. target = os.path.join(app_dir, 'staging', 'yarn.lock')
  29. shutil.copy(target, os.path.join(staging, 'yarn.lock'))