Prechádzať zdrojové kódy

Merge pull request #5227 from blink1073/specify-engine

Specify and enforce a node version
Afshin Darian 6 rokov pred
rodič
commit
774ca4a5c7

+ 2 - 5
CONTRIBUTING.md

@@ -38,13 +38,12 @@ a keyboard shortcut or automatically on save.
 
 ### Installing Node.js and jlpm
 
-Building JupyterLab from its GitHub source code requires Node.js version
-5+.
+Building JupyterLab from its GitHub source code requires Node.js.
 
 If you use `conda`, you can get it with:
 
 ```bash
-conda install -c conda-forge 'nodejs<10'
+conda install -c conda-forge 'nodejs'
 ```
 
 If you use [Homebrew](http://brew.sh/) on Mac OS X:
@@ -96,8 +95,6 @@ Notes:
 
 * A few of the scripts will run "python". If your target python is called something else (such as "python3") then parts of the build will fail. You may wish to build in a conda environment, or make an alias.
 
-* There are versions of Node that are too modern. You should use a version of Node < 10.
-
 * The `jlpm` command is a JupyterLab-provided, locked version of the [yarn](https://yarnpkg.com/en/) package manager. If you have `yarn` installed
   already, you can use the `yarn` command when developing, and it will use the
   local version of `yarn` in `jupyterlab/yarn.js` when run in the repository or

+ 3 - 0
dev_mode/package.json

@@ -216,6 +216,9 @@
       "xterm"
     ],
     "version": "0.35.0a0",
+    "engines": {
+      "node": ">=6.11.5"
+    },
     "linkedPackages": {
       "@jupyterlab/application": "../packages/application",
       "@jupyterlab/application-extension": "../packages/application-extension",

+ 1 - 1
docs/source/user/extensions.rst

@@ -27,7 +27,7 @@ information about developing extensions, see the :ref:`developer documentation
 
 
 In order to install JupyterLab extensions, you need to have `Node.js
-<https://nodejs.org/>`__ version 4 or later installed.
+<https://nodejs.org/>`__ installed.
 
 If you use ``conda``, you can get it with:
 

+ 6 - 2
jupyterlab/commands.py

@@ -1473,9 +1473,13 @@ def _node_check():
     """
     try:
         proc = Process(['node', 'node-version-check.js'], cwd=HERE, quiet=True)
-        proc.wait()
+        ret = proc.wait()
     except Exception:
-        msg = 'Please install nodejs 5+ and npm before continuing. nodejs may be installed using conda or directly from the nodejs website.'
+        ret = 1
+    if ret != 0:
+        data = _get_core_data()
+        ver = data['engines']['node']
+        msg = 'Please install nodejs %s before continuing. nodejs may be installed using conda or directly from the nodejs website.' % ver
         raise ValueError(msg)
 
 

+ 29 - 2
jupyterlab/node-version-check.js

@@ -1,5 +1,32 @@
 #!/usr/bin/env node
-var version = parseInt(process.version.replace('v', ''));
-if (version < 5) {
+var pkg = require('./staging/package.json');
+
+function parser(part) {
+  return parseInt(part, 10);
+}
+
+var engine = pkg.engines.node.replace('>=', '');
+var eparts = engine.split('.').map(parser);
+
+var version = process.version.replace('v', '');
+var vparts = version.split('.').map(parser);
+
+if (vparts[0] > eparts[0]) {
+  process.exit(0);
+}
+
+if (vparts[0] < eparts[0]) {
+  process.exit(1);
+}
+
+if (vparts[1] > eparts[1]) {
+  process.exit(0);
+}
+
+if (vparts[1] < eparts[1]) {
+  process.exit(1);
+}
+
+if (vparts[2] < eparts[1]) {
   process.exit(1);
 }

+ 3 - 0
jupyterlab/staging/package.json

@@ -124,6 +124,9 @@
     "webpack-cli": "^3.0.3",
     "webpack-merge": "^4.1.1"
   },
+  "engines": {
+      "node": ">=6.11.5"
+    },
   "jupyterlab": {
     "extensions": {
       "@jupyterlab/application-extension": "",

+ 2 - 0
scripts/travis_script.sh

@@ -6,6 +6,8 @@
 set -ex
 set -o pipefail
 
+python -c "from jupyterlab.commands import build_check; build_check()"
+
 
 if [[ $GROUP == python ]]; then
     # Run the python tests