Skip to content

Commit

Permalink
removing bower, using bower-lite script to copy dependencies, install…
Browse files Browse the repository at this point in the history
…ed with npm, into components folder.

this is applying the changes made by @minrk in https://github.com/jupyter/notebook/pull/6213/files to nbclassic
  • Loading branch information
Rosio Reyes authored and Rosio Reyes committed May 11, 2022
1 parent 2a8235d commit 21af09c
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 66 deletions.
3 changes: 0 additions & 3 deletions .bowerrc

This file was deleted.

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include LICENSE

# added by check-manifest
include *.md
include bower-lite
recursive-include docs *.md
recursive-include nbclassic *.py
recursive-include tests *.py
37 changes: 37 additions & 0 deletions bower-lite
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
"""
bower-lite
Since Bower's on its way out,
stage frontend dependencies from node_modules into components
"""
import json
import os
import shutil
from os.path import join

HERE = os.path.abspath(os.path.dirname(__file__))


components = join(HERE, "nbclassic", "static", "components")
node_modules = join(HERE, "node_modules")

if os.path.exists(components):
shutil.rmtree(components)
os.mkdir(components)

with open(join(HERE, "package.json")) as f:
package_json = json.load(f)

renames = {
"jquery-ui-dist": "jquery-ui",
}

dependencies = package_json["dependencies"]
for dep in dependencies:
src = join(node_modules, dep)
dest_name = renames.get(dep, dep)
dest = join(components, dest_name)
print(f"{src} -> {dest}")
shutil.copytree(src, dest)
30 changes: 0 additions & 30 deletions bower.json

This file was deleted.

14 changes: 7 additions & 7 deletions nbclassic/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
<title>{% block title %}Jupyter Notebook{% endblock %}</title>
{% block favicon %}<link id="favicon" rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon.ico") }}">{% endblock %}
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="{{static_url("components/jquery-ui/themes/smoothness/jquery-ui.min.css") }}" type="text/css" />
<link rel="stylesheet" href="{{static_url("components/jquery-ui-themes/themes/smoothness/jquery-ui.min.css") }}" type="text/css" />
<link rel="stylesheet" href="{{static_url("components/jquery-typeahead/dist/jquery.typeahead.min.css") }}" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

{% block stylesheet %}
<link rel="stylesheet" href="{{ static_url("style/style.min.css") }}" type="text/css"/>
{% endblock %}
<link rel="stylesheet" href="{{ base_url }}custom/custom.css" type="text/css" />
<script src="{{static_url("components/es6-promise/promise.min.js")}}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url('components/react/react.production.min.js')}}" type="text/javascript"></script>
<script src="{{static_url('components/react/react-dom.production.min.js')}}" type="text/javascript"></script>
<script src="{{static_url('components/create-react-class/index.js')}}" type="text/javascript"></script>
<script src="{{static_url("components/es6-promise/dist/promise-1.0.0.min.js")}}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url('components/react/umd/react.production.min.js')}}" type="text/javascript"></script>
<script src="{{static_url('components/react-dom/umd/react-dom.production.min.js')}}" type="text/javascript"></script>
<script src="{{static_url('components/create-react-class/create-react-class.min.js')}}" type="text/javascript"></script>
<script src="{{static_url('components/requirejs/require.js') }}" type="text/javascript" charset="utf-8"></script>
<script>
require.config({
Expand All @@ -34,15 +34,15 @@
underscore : 'components/underscore/underscore-min',
backbone : 'components/backbone/backbone-min',
jed: 'components/jed/jed',
jquery: 'components/jquery/jquery.min',
jquery: 'components/jquery/dist/jquery.min',
json: 'components/requirejs-plugins/src/json',
text: 'components/requirejs-text/text',
bootstrap: 'components/bootstrap/dist/js/bootstrap.min',
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
'jquery-ui': 'components/jquery-ui/jquery-ui.min',
moment: 'components/moment/min/moment-with-locales',
codemirror: 'components/codemirror',
termjs: 'components/xterm.js/xterm',
termjs: 'components/xterm/dist/xterm',
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead.min',
},
map: { // for backward compatibility
Expand Down
2 changes: 1 addition & 1 deletion nbclassic/templates/terminal.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% block stylesheet %}
{{super()}}
<link rel="stylesheet" href="{{ static_url("terminal/css/override.css") }}" type="text/css" />
<link rel="stylesheet" href="{{static_url("components/xterm.js-css/index.css") }}" type="text/css" />
<link rel="stylesheet" href="{{static_url("components/xterm/dist/xterm.css") }}" type="text/css" />
{% endblock %}

{% block headercontainer %}
Expand Down
32 changes: 28 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,48 @@
"url": "https://github.com/jupyter/nbclassic.git"
},
"scripts": {
"bower": "bower install",
"bower": "python3 bower-lite",
"build": "python setup.py js css",
"build:webpack": "webpack --mode production",
"build:watch": "npm run watch",
"watch": "onchange 'nbclassic/static/**/!(*.min).js' 'nbclassic/static/**/*.less' 'bower.json' -- npm run build"
"watch": "onchange 'nbclassic/static/**/!(*.min).js' 'nbclassic/static/**/*.less' -- npm run build"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@jupyterlab/apputils": "^3.1.3",
"babel-loader": "^8.2.2",
"babel-polyfill": "^6.26.0",
"bower": "^1.8.8",
"less": "~2",
"onchange": "^6.0.0",
"po2json": "^0.4.5",
"requirejs": "^2.3.6",
"webpack": "^5.46.0",
"webpack-cli": "^4.7.2"
},
"dependencies": {
"backbone": "~1.2",
"bootstrap": "~3.4",
"bootstrap-tour": "^0.10.0",
"codemirror": "5.56.0",
"create-react-class": "^15.6.3",
"es6-promise": "~1.0",
"font-awesome": "~4.7.0",
"google-caja": "^0.0.2",
"jed": "~1.1.1",
"jquery": "~3.5.0",
"jquery-typeahead": "~2.10.6",
"jquery-ui-dist": "^1.12.0",
"jquery-ui-themes": "^1.12.0",
"marked": "^0.7.0",
"mathjax": "^2.7.4",
"moment": "~2.19.3",
"react": "~16.0.0",
"react-dom": "~16.0.0",
"requirejs": "^2.3.6",
"requirejs-plugins": "^1.0.2",
"requirejs-text": "~2.0.15",
"text-encoding": "~0.7.0",
"underscore": "~1.8.3",
"xterm": "~3.1.0"
}
}
36 changes: 18 additions & 18 deletions setupbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,31 @@ def find_package_data():
pjoin(components, "bootstrap", "dist", "js", "bootstrap.min.js"),
pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
pjoin(components, "create-react-class", "index.js"),
pjoin(components, "create-react-class", "create-react-class.min.js"),
pjoin(components, "font-awesome", "css", "*.css"),
pjoin(components, "google-caja", "html-css-sanitizer-minified.js"),
pjoin(components, "es6-promise", "*.js"),
pjoin(components, "google-caja", "sanitizer.js"),
pjoin(components, "es6-promise", "dist", "*.min.js"),
pjoin(components, "font-awesome", "fonts", "*.*"),
pjoin(components, "jed", "jed.js"),
pjoin(components, "jquery", "jquery.min.js"),
pjoin(components, "jquery", "dist", "jquery.min.js"),
pjoin(components, "jquery-typeahead", "dist", "jquery.typeahead.min.js"),
pjoin(components, "jquery-typeahead", "dist", "jquery.typeahead.min.css"),
pjoin(components, "jquery-ui", "jquery-ui.min.js"),
pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"),
pjoin(components, "jquery-ui-themes", "themes", "smoothness", "jquery-ui.min.css"),
pjoin(components, "jquery-ui-themes", "themes", "smoothness", "images", "*"),
pjoin(components, "marked", "lib", "marked.js"),
pjoin(components, "react", "react.production.min.js"),
pjoin(components, "react", "react-dom.production.min.js"),
pjoin(components, "react", "umd", "react.production.min.js"),
pjoin(components, "react-dom", "umd", "react-dom.production.min.js"),
pjoin(components, "requirejs", "require.js"),
pjoin(components, "requirejs-plugins", "src", "json.js"),
pjoin(components, "requirejs-text", "text.js"),
pjoin(components, "sanitizer", "index.js"),
pjoin(components, "underscore", "underscore-min.js"),
pjoin(components, "moment", "moment.js"),
pjoin(components, "moment", "min", "*.js"),
pjoin(components, "xterm.js", "index.js"),
pjoin(components, "xterm.js-css", "index.css"),
pjoin(components, "xterm.js-fit", "index.js"),
pjoin(components, "xterm", "dist", "xterm.js"),
pjoin(components, "xterm", "dist", "xterm.css"),
pjoin(components, "xterm", "dist", "addons", "fit", "fit.js"),
pjoin(components, "text-encoding", "lib", "encoding.js"),
])

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

# Trim mathjax
mj = lambda *path: pjoin(components, 'MathJax', *path)
mj = lambda *path: pjoin(components, 'mathjax', *path)
static_data.extend([
mj('MathJax.js'),
mj('config', 'TeX-AMS-MML_HTMLorMML-full.js'),
Expand Down Expand Up @@ -360,10 +360,10 @@ def run(self):
])

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

user_options = [
('force', 'f', "force fetching of bower dependencies"),
('force', 'f', "force fetching of JavaScript dependencies"),
]

def initialize_options(self):
Expand All @@ -384,7 +384,7 @@ def should_run(self):
if not os.path.exists(self.sanitizer_dir):
return True

bower_stale = mtime(self.bower_dir) < mtime(pjoin(repo_root, 'bower.json'))
bower_stale = mtime(self.bower_dir) < mtime(pjoin(repo_root, 'package.json'))
if bower_stale:
return True

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

def run(self):
if not self.should_run():
print("bower dependencies up to date")
print("JS dependencies up to date")
return

if self.should_run_npm():
Expand All @@ -413,12 +413,12 @@ def run(self):

try:
run(
['bower', 'install', '--allow-root', '--config.interactive=false'],
[sys.executable, pjoin(repo_root, "bower-lite")],
cwd=repo_root,
env=env
)
except OSError as e:
print("Failed to run bower: %s" % e, file=sys.stderr)
print("Failed to run bower-lite: %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
# self.npm_components()
Expand Down
6 changes: 3 additions & 3 deletions tools/build-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ var rjs_config = {
underscore : 'components/underscore/underscore-min',
backbone : 'components/backbone/backbone-min',
jed: 'components/jed/jed',
jquery: 'components/jquery/jquery.min',
jquery: 'components/jquery/dist/jquery.min',
json: 'components/requirejs-plugins/src/json',
text: 'components/requirejs-text/text',
bootstrap: 'components/bootstrap/dist/js/bootstrap.min',
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
"jquery-ui": 'components/jquery-ui/jquery-ui.min',
moment: 'components/moment/min/moment-with-locales',
codemirror: 'components/codemirror',
xterm: 'components/xterm.js/index',
"xtermjs-fit": 'components/xterm.js-fit/index',
xterm: 'components/xterm/dist/xterm',
"xtermjs-fit": 'components/xterm/dist/addons/fit/fit',
"jquery-typeahead": 'components/jquery-typeahead/dist/jquery.typeahead.min',
contents: 'empty:',
custom: 'empty:',
Expand Down

0 comments on commit 21af09c

Please sign in to comment.