Skip to content

Commit d03d798

Browse files
committed
get bower dependencies from npm
a couple of packages have different layouts (jquery-ui, react, xterm), but little is changed a 'bower-lite' script copies dependencies from node_modules to `static/components` to match previous installation location
1 parent 41f1483 commit d03d798

11 files changed

+98
-72
lines changed

.bowerrc

-3
This file was deleted.

MANIFEST.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ include CONTRIBUTING.rst
33
include README.md
44
include CHANGELOG.md
55
include package.json
6-
include bower.json
7-
include .bowerrc
6+
include bower-lite
87
include pyproject.toml
98
include setup.py
109
include setupbase.py

bower-lite

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) Jupyter Development Team.
3+
# Distributed under the terms of the Modified BSD License.
4+
"""
5+
bower-lite
6+
7+
Since Bower's on its way out,
8+
stage frontend dependencies from node_modules into components
9+
"""
10+
import json
11+
import os
12+
import shutil
13+
from os.path import join
14+
15+
HERE = os.path.abspath(os.path.dirname(__file__))
16+
17+
18+
components = join(HERE, "notebook", "static", "components")
19+
node_modules = join(HERE, "node_modules")
20+
21+
if os.path.exists(components):
22+
shutil.rmtree(components)
23+
os.mkdir(components)
24+
25+
with open(join(HERE, "package.json")) as f:
26+
package_json = json.load(f)
27+
28+
renames = {
29+
"jquery-ui-dist": "jquery-ui",
30+
}
31+
32+
dependencies = package_json["dependencies"]
33+
for dep in dependencies:
34+
src = join(node_modules, dep)
35+
dest_name = renames.get(dep, dep)
36+
dest = join(components, dest_name)
37+
print(f"{src} -> {dest}")
38+
shutil.copytree(src, dest)

bower.json

-29
This file was deleted.

notebook/notebookapp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ def _default_mathjax_url(self):
13531353
if not self.enable_mathjax:
13541354
return u''
13551355
static_url_prefix = self.tornado_settings.get("static_url_prefix", "static")
1356-
return url_path_join(static_url_prefix, 'components', 'MathJax', 'MathJax.js')
1356+
return url_path_join(static_url_prefix, 'components', 'mathjax', 'MathJax.js')
13571357

13581358
@observe('mathjax_url')
13591359
def _update_mathjax_url(self, change):

notebook/templates/notebook.html

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
window.mathjax_url = "{{mathjax_url}}";
1414
</script>
1515

16-
<link rel="stylesheet" href="{{ static_url("components/bootstrap-tour/build/css/bootstrap-tour.min.css") }}" type="text/css" />
1716
<link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
1817

1918
{{super()}}

notebook/templates/page.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
<title>{% block title %}Jupyter Notebook{% endblock %}</title>
88
{% block favicon %}<link id="favicon" rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon.ico") }}">{% endblock %}
99
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
10-
<link rel="stylesheet" href="{{static_url("components/jquery-ui/themes/smoothness/jquery-ui.min.css") }}" type="text/css" />
10+
<link rel="stylesheet" href="{{static_url("components/jquery-ui-themes/themes/smoothness/jquery-ui.min.css") }}" type="text/css" />
1111
<link rel="stylesheet" href="{{static_url("components/jquery-typeahead/dist/jquery.typeahead.min.css") }}" type="text/css" />
1212
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1313

1414
{% block stylesheet %}
1515
<link rel="stylesheet" href="{{ static_url("style/style.min.css") }}" type="text/css"/>
1616
{% endblock %}
1717
<link rel="stylesheet" href="{{ base_url }}custom/custom.css" type="text/css" />
18-
<script src="{{static_url("components/es6-promise/promise.min.js")}}" type="text/javascript" charset="utf-8"></script>
19-
<script src="{{static_url('components/react/react.production.min.js')}}" type="text/javascript"></script>
20-
<script src="{{static_url('components/react/react-dom.production.min.js')}}" type="text/javascript"></script>
21-
<script src="{{static_url('components/create-react-class/index.js')}}" type="text/javascript"></script>
18+
<script src="{{static_url("components/es6-promise/dist/promise-1.0.0.min.js")}}" type="text/javascript" charset="utf-8"></script>
19+
<script src="{{static_url('components/react/umd/react.production.min.js')}}" type="text/javascript"></script>
20+
<script src="{{static_url('components/react-dom/umd/react-dom.production.min.js')}}" type="text/javascript"></script>
21+
<script src="{{static_url('components/create-react-class/create-react-class.min.js')}}" type="text/javascript"></script>
2222
<script src="{{static_url('components/requirejs/require.js') }}" type="text/javascript" charset="utf-8"></script>
2323
<script>
2424
require.config({
@@ -34,15 +34,15 @@
3434
underscore : 'components/underscore/underscore-min',
3535
backbone : 'components/backbone/backbone-min',
3636
jed: 'components/jed/jed',
37-
jquery: 'components/jquery/jquery.min',
37+
jquery: 'components/jquery/dist/jquery.min',
3838
json: 'components/requirejs-plugins/src/json',
3939
text: 'components/requirejs-text/text',
4040
bootstrap: 'components/bootstrap/dist/js/bootstrap.min',
4141
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
4242
'jquery-ui': 'components/jquery-ui/jquery-ui.min',
4343
moment: 'components/moment/min/moment-with-locales',
4444
codemirror: 'components/codemirror',
45-
termjs: 'components/xterm.js/xterm',
45+
termjs: 'components/xterm/dist/xterm',
4646
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead.min',
4747
},
4848
map: { // for backward compatibility

notebook/templates/terminal.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{% block stylesheet %}
1616
{{super()}}
1717
<link rel="stylesheet" href="{{ static_url("terminal/css/override.css") }}" type="text/css" />
18-
<link rel="stylesheet" href="{{static_url("components/xterm.js-css/index.css") }}" type="text/css" />
18+
<link rel="stylesheet" href="{{static_url("components/xterm/dist/xterm.css") }}" type="text/css" />
1919
{% endblock %}
2020

2121
{% block headercontainer %}

package.json

+27-4
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,46 @@
1010
"url": "https://github.com/jupyter/notebook.git"
1111
},
1212
"scripts": {
13-
"bower": "bower install",
13+
"bower": "python3 bower-lite",
1414
"build": "python setup.py js css",
1515
"build:webpack": "webpack --mode production",
1616
"build:watch": "npm run watch",
17-
"watch": "onchange 'notebook/static/**/!(*.min).js' 'notebook/static/**/*.less' 'bower.json' -- npm run build"
17+
"watch": "onchange 'notebook/static/**/!(*.min).js' 'notebook/static/**/*.less' -- npm run build"
18+
},
19+
"dependencies": {
20+
"backbone": "~1.2",
21+
"bootstrap": "~3.4",
22+
"bootstrap-tour": "^0.9.0",
23+
"codemirror": "5.56.0",
24+
"create-react-class": "^15.6.3",
25+
"es6-promise": "~1.0",
26+
"font-awesome": "~4.7.0",
27+
"jed": "~1.1.1",
28+
"jquery": "~3.5.0",
29+
"jquery-typeahead": "~2.10.6",
30+
"jquery-ui-dist": "^1.12.0",
31+
"jquery-ui-themes": "^1.12.0",
32+
"marked": "~0.7",
33+
"mathjax": "^2.7.4",
34+
"moment": "~2.19.3",
35+
"react": "~16.0.0",
36+
"react-dom": "~16.0.0",
37+
"requirejs": "^2.3.6",
38+
"requirejs-plugins": "~1.0.2",
39+
"requirejs-text": "~2.0.15",
40+
"text-encoding": "^0.7.0",
41+
"underscore": "~1.8.3",
42+
"xterm": "~3.1.0"
1843
},
1944
"devDependencies": {
2045
"@babel/core": "^7.15.0",
2146
"@babel/preset-env": "^7.15.0",
2247
"@jupyterlab/apputils": "^3.1.3",
2348
"babel-loader": "^8.2.2",
2449
"babel-polyfill": "^6.26.0",
25-
"bower": "^1.8.8",
2650
"less": "~2",
2751
"onchange": "^6.0.0",
2852
"po2json": "^0.4.5",
29-
"requirejs": "^2.3.6",
3053
"webpack": "^5.46.0",
3154
"webpack-cli": "^4.7.2"
3255
}

setupbase.py

+19-20
Original file line numberDiff line numberDiff line change
@@ -131,32 +131,31 @@ def find_package_data():
131131
static_data.extend([
132132
pjoin(components, "backbone", "backbone-min.js"),
133133
pjoin(components, "bootstrap", "dist", "js", "bootstrap.min.js"),
134-
pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
135-
pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
136-
pjoin(components, "create-react-class", "index.js"),
134+
pjoin(components, "bootstrap-tour", "lib", "bootstrap-tour.js"),
135+
pjoin(components, "create-react-class", "create-react-class.js"),
137136
pjoin(components, "font-awesome", "css", "*.css"),
138-
pjoin(components, "es6-promise", "*.js"),
137+
pjoin(components, "es6-promise", "dist", "*.min.js"),
139138
pjoin(components, "font-awesome", "fonts", "*.*"),
140139
pjoin(components, "jed", "jed.js"),
141-
pjoin(components, "jquery", "jquery.min.js"),
140+
pjoin(components, "jquery", "dist", "jquery.min.js"),
142141
pjoin(components, "jquery-typeahead", "dist", "jquery.typeahead.min.js"),
143142
pjoin(components, "jquery-typeahead", "dist", "jquery.typeahead.min.css"),
144143
pjoin(components, "jquery-ui", "jquery-ui.min.js"),
145-
pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
146-
pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"),
144+
pjoin(components, "jquery-ui-themes", "themes", "smoothness", "jquery-ui.min.css"),
145+
pjoin(components, "jquery-ui-themes", "themes", "smoothness", "images", "*"),
147146
pjoin(components, "marked", "lib", "marked.js"),
148-
pjoin(components, "react", "react.production.min.js"),
149-
pjoin(components, "react", "react-dom.production.min.js"),
147+
pjoin(components, "react", "umd", "react.production.min.js"),
148+
pjoin(components, "react-dom", "umd", "react-dom.production.min.js"),
150149
pjoin(components, "requirejs", "require.js"),
151150
pjoin(components, "requirejs-plugins", "src", "json.js"),
152151
pjoin(components, "requirejs-text", "text.js"),
153152
pjoin(components, "sanitizer", "index.js"),
154153
pjoin(components, "underscore", "underscore-min.js"),
155154
pjoin(components, "moment", "moment.js"),
156155
pjoin(components, "moment", "min", "*.js"),
157-
pjoin(components, "xterm.js", "index.js"),
158-
pjoin(components, "xterm.js-css", "index.css"),
159-
pjoin(components, "xterm.js-fit", "index.js"),
156+
pjoin(components, "xterm", "dist", "xterm.js"),
157+
pjoin(components, "xterm", "dist", "xterm.css"),
158+
pjoin(components, "xterm", "dist", "addons", "fit", "fit.js"),
160159
pjoin(components, "text-encoding", "lib", "encoding.js"),
161160
])
162161

@@ -167,7 +166,7 @@ def find_package_data():
167166
static_data.append(pjoin(parent, f))
168167

169168
# Trim mathjax
170-
mj = lambda *path: pjoin(components, 'MathJax', *path)
169+
mj = lambda *path: pjoin(components, 'mathjax', *path)
171170
static_data.extend([
172171
mj('MathJax.js'),
173172
mj('config', 'TeX-AMS-MML_HTMLorMML-full.js'),
@@ -360,10 +359,10 @@ def run(self):
360359
])
361360

362361
class Bower(Command):
363-
description = "fetch static client-side components with bower"
362+
description = "fetch static client-side components"
364363

365364
user_options = [
366-
('force', 'f', "force fetching of bower dependencies"),
365+
('force', 'f', "force fetching of javascript components"),
367366
]
368367

369368
def initialize_options(self):
@@ -384,7 +383,7 @@ def should_run(self):
384383
if not os.path.exists(self.sanitizer_dir):
385384
return True
386385

387-
bower_stale = mtime(self.bower_dir) < mtime(pjoin(repo_root, 'bower.json'))
386+
bower_stale = mtime(self.bower_dir) < mtime(pjoin(repo_root, "package.json"))
388387
if bower_stale:
389388
return True
390389

@@ -400,7 +399,7 @@ def should_run_npm(self):
400399

401400
def run(self):
402401
if not self.should_run():
403-
print("bower dependencies up to date")
402+
print("static/components up to date")
404403
return
405404

406405
if self.should_run_npm():
@@ -413,12 +412,12 @@ def run(self):
413412

414413
try:
415414
run(
416-
['bower', 'install', '--allow-root', '--config.interactive=false'],
415+
[sys.executable, pjoin(repo_root, "bower-lite")],
417416
cwd=repo_root,
418-
env=env
417+
env=env,
419418
)
420419
except OSError as e:
421-
print("Failed to run bower: %s" % e, file=sys.stderr)
420+
print("Failed to run bower-lite: %s" % e, file=sys.stderr)
422421
print("You can install js dependencies with `npm install`", file=sys.stderr)
423422
raise
424423
# self.npm_components()

tools/build-main.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ var rjs_config = {
1616
underscore : 'components/underscore/underscore-min',
1717
backbone : 'components/backbone/backbone-min',
1818
jed: 'components/jed/jed',
19-
jquery: 'components/jquery/jquery.min',
19+
jquery: 'components/jquery/dist/jquery.min',
2020
json: 'components/requirejs-plugins/src/json',
2121
text: 'components/requirejs-text/text',
2222
bootstrap: 'components/bootstrap/dist/js/bootstrap.min',
23-
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
23+
bootstraptour: 'components/bootstrap-tour/lib/bootstrap-tour',
2424
"jquery-ui": 'components/jquery-ui/jquery-ui.min',
2525
moment: 'components/moment/min/moment-with-locales',
2626
codemirror: 'components/codemirror',
27-
xterm: 'components/xterm.js/index',
28-
"xtermjs-fit": 'components/xterm.js-fit/index',
27+
xterm: 'components/xterm/dist/xterm',
28+
"xtermjs-fit": 'components/xterm/dist/addons/fit/fit',
2929
"jquery-typeahead": 'components/jquery-typeahead/dist/jquery.typeahead.min',
3030
contents: 'empty:',
3131
custom: 'empty:',

0 commit comments

Comments
 (0)