Skip to content

Commit 21af09c

Browse files
Rosio ReyesRosio Reyes
authored andcommitted
removing bower, using bower-lite script to copy dependencies, installed with npm, into components folder.
this is applying the changes made by @minrk in https://github.com/jupyter/notebook/pull/6213/files to nbclassic
1 parent 2a8235d commit 21af09c

File tree

9 files changed

+95
-66
lines changed

9 files changed

+95
-66
lines changed

.bowerrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include LICENSE
22

33
# added by check-manifest
44
include *.md
5+
include bower-lite
56
recursive-include docs *.md
67
recursive-include nbclassic *.py
78
recursive-include tests *.py

bower-lite

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
Since Bower's on its way out,
7+
stage frontend dependencies from node_modules into components
8+
"""
9+
import json
10+
import os
11+
import shutil
12+
from os.path import join
13+
14+
HERE = os.path.abspath(os.path.dirname(__file__))
15+
16+
17+
components = join(HERE, "nbclassic", "static", "components")
18+
node_modules = join(HERE, "node_modules")
19+
20+
if os.path.exists(components):
21+
shutil.rmtree(components)
22+
os.mkdir(components)
23+
24+
with open(join(HERE, "package.json")) as f:
25+
package_json = json.load(f)
26+
27+
renames = {
28+
"jquery-ui-dist": "jquery-ui",
29+
}
30+
31+
dependencies = package_json["dependencies"]
32+
for dep in dependencies:
33+
src = join(node_modules, dep)
34+
dest_name = renames.get(dep, dep)
35+
dest = join(components, dest_name)
36+
print(f"{src} -> {dest}")
37+
shutil.copytree(src, dest)

bower.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

nbclassic/templates/page.html

Lines changed: 7 additions & 7 deletions
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

nbclassic/templates/terminal.html

Lines changed: 1 addition & 1 deletion
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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,48 @@
1010
"url": "https://github.com/jupyter/nbclassic.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 'nbclassic/static/**/!(*.min).js' 'nbclassic/static/**/*.less' 'bower.json' -- npm run build"
17+
"watch": "onchange 'nbclassic/static/**/!(*.min).js' 'nbclassic/static/**/*.less' -- npm run build"
1818
},
1919
"devDependencies": {
2020
"@babel/core": "^7.15.0",
2121
"@babel/preset-env": "^7.15.0",
2222
"@jupyterlab/apputils": "^3.1.3",
2323
"babel-loader": "^8.2.2",
2424
"babel-polyfill": "^6.26.0",
25-
"bower": "^1.8.8",
2625
"less": "~2",
2726
"onchange": "^6.0.0",
2827
"po2json": "^0.4.5",
29-
"requirejs": "^2.3.6",
3028
"webpack": "^5.46.0",
3129
"webpack-cli": "^4.7.2"
30+
},
31+
"dependencies": {
32+
"backbone": "~1.2",
33+
"bootstrap": "~3.4",
34+
"bootstrap-tour": "^0.10.0",
35+
"codemirror": "5.56.0",
36+
"create-react-class": "^15.6.3",
37+
"es6-promise": "~1.0",
38+
"font-awesome": "~4.7.0",
39+
"google-caja": "^0.0.2",
40+
"jed": "~1.1.1",
41+
"jquery": "~3.5.0",
42+
"jquery-typeahead": "~2.10.6",
43+
"jquery-ui-dist": "^1.12.0",
44+
"jquery-ui-themes": "^1.12.0",
45+
"marked": "^0.7.0",
46+
"mathjax": "^2.7.4",
47+
"moment": "~2.19.3",
48+
"react": "~16.0.0",
49+
"react-dom": "~16.0.0",
50+
"requirejs": "^2.3.6",
51+
"requirejs-plugins": "^1.0.2",
52+
"requirejs-text": "~2.0.15",
53+
"text-encoding": "~0.7.0",
54+
"underscore": "~1.8.3",
55+
"xterm": "~3.1.0"
3256
}
3357
}

setupbase.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,31 +133,31 @@ def find_package_data():
133133
pjoin(components, "bootstrap", "dist", "js", "bootstrap.min.js"),
134134
pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
135135
pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
136-
pjoin(components, "create-react-class", "index.js"),
136+
pjoin(components, "create-react-class", "create-react-class.min.js"),
137137
pjoin(components, "font-awesome", "css", "*.css"),
138-
pjoin(components, "google-caja", "html-css-sanitizer-minified.js"),
139-
pjoin(components, "es6-promise", "*.js"),
138+
pjoin(components, "google-caja", "sanitizer.js"),
139+
pjoin(components, "es6-promise", "dist", "*.min.js"),
140140
pjoin(components, "font-awesome", "fonts", "*.*"),
141141
pjoin(components, "jed", "jed.js"),
142-
pjoin(components, "jquery", "jquery.min.js"),
142+
pjoin(components, "jquery", "dist", "jquery.min.js"),
143143
pjoin(components, "jquery-typeahead", "dist", "jquery.typeahead.min.js"),
144144
pjoin(components, "jquery-typeahead", "dist", "jquery.typeahead.min.css"),
145145
pjoin(components, "jquery-ui", "jquery-ui.min.js"),
146-
pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
147-
pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"),
146+
pjoin(components, "jquery-ui-themes", "themes", "smoothness", "jquery-ui.min.css"),
147+
pjoin(components, "jquery-ui-themes", "themes", "smoothness", "images", "*"),
148148
pjoin(components, "marked", "lib", "marked.js"),
149-
pjoin(components, "react", "react.production.min.js"),
150-
pjoin(components, "react", "react-dom.production.min.js"),
149+
pjoin(components, "react", "umd", "react.production.min.js"),
150+
pjoin(components, "react-dom", "umd", "react-dom.production.min.js"),
151151
pjoin(components, "requirejs", "require.js"),
152152
pjoin(components, "requirejs-plugins", "src", "json.js"),
153153
pjoin(components, "requirejs-text", "text.js"),
154154
pjoin(components, "sanitizer", "index.js"),
155155
pjoin(components, "underscore", "underscore-min.js"),
156156
pjoin(components, "moment", "moment.js"),
157157
pjoin(components, "moment", "min", "*.js"),
158-
pjoin(components, "xterm.js", "index.js"),
159-
pjoin(components, "xterm.js-css", "index.css"),
160-
pjoin(components, "xterm.js-fit", "index.js"),
158+
pjoin(components, "xterm", "dist", "xterm.js"),
159+
pjoin(components, "xterm", "dist", "xterm.css"),
160+
pjoin(components, "xterm", "dist", "addons", "fit", "fit.js"),
161161
pjoin(components, "text-encoding", "lib", "encoding.js"),
162162
])
163163

@@ -168,7 +168,7 @@ def find_package_data():
168168
static_data.append(pjoin(parent, f))
169169

170170
# Trim mathjax
171-
mj = lambda *path: pjoin(components, 'MathJax', *path)
171+
mj = lambda *path: pjoin(components, 'mathjax', *path)
172172
static_data.extend([
173173
mj('MathJax.js'),
174174
mj('config', 'TeX-AMS-MML_HTMLorMML-full.js'),
@@ -360,10 +360,10 @@ def run(self):
360360
])
361361

362362
class Bower(Command):
363-
description = "fetch static client-side components with bower"
363+
description = "fetch static client-side components with npm"
364364

365365
user_options = [
366-
('force', 'f', "force fetching of bower dependencies"),
366+
('force', 'f', "force fetching of JavaScript dependencies"),
367367
]
368368

369369
def initialize_options(self):
@@ -384,7 +384,7 @@ def should_run(self):
384384
if not os.path.exists(self.sanitizer_dir):
385385
return True
386386

387-
bower_stale = mtime(self.bower_dir) < mtime(pjoin(repo_root, 'bower.json'))
387+
bower_stale = mtime(self.bower_dir) < mtime(pjoin(repo_root, 'package.json'))
388388
if bower_stale:
389389
return True
390390

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

401401
def run(self):
402402
if not self.should_run():
403-
print("bower dependencies up to date")
403+
print("JS dependencies up to date")
404404
return
405405

406406
if self.should_run_npm():
@@ -413,12 +413,12 @@ def run(self):
413413

414414
try:
415415
run(
416-
['bower', 'install', '--allow-root', '--config.interactive=false'],
416+
[sys.executable, pjoin(repo_root, "bower-lite")],
417417
cwd=repo_root,
418418
env=env
419419
)
420420
except OSError as e:
421-
print("Failed to run bower: %s" % e, file=sys.stderr)
421+
print("Failed to run bower-lite: %s" % e, file=sys.stderr)
422422
print("You can install js dependencies with `npm install`", file=sys.stderr)
423423
raise
424424
# self.npm_components()

tools/build-main.js

Lines changed: 3 additions & 3 deletions
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',
2323
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
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)