Skip to content

Commit

Permalink
Merge pull request #81 from vidartf/refactorprojects
Browse files Browse the repository at this point in the history
Refactor NPM projects
  • Loading branch information
Martin Sandve Alnæs committed Sep 27, 2016
2 parents 88acecf + dc14211 commit 9824304
Show file tree
Hide file tree
Showing 60 changed files with 2,708 additions and 450 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ htmlcov

.spyderproject
**/.vscode/
nbdime/webapp/node_modules/
**/node_modules/
nbdime/webapp/test/build/
nbdime/webapp/build/
nbdime-web/lib/
nbdime-web/coverage/
nbdime-web/test/build/

nbdime/webapp/static/build/
33 changes: 30 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,42 @@ python:
- 3.3
- 2.7
sudo: false
env:
matrix:
- GROUP=python
matrix:
include:
- python: 3.5
env: GROUP=js
cache:
pip: true
directories:
- nbdime/webapp/node_modules # NPM packages
- nbdime-web/node_modules # NPM packages
before_install:
- nvm install 4
- pip install -r requirements.txt
- pip install pytest
- pip install pytest-cov
- pip install codecov
- 'if [[ $GROUP == python ]]; then pip install codecov; fi'
- 'if [[ $GROUP == js ]]; then npm install -g codecov; fi'
install:
- pip install -e .
- 'if [[ $GROUP == python ]]; then pip install -e ./; fi'
- 'if [[ $GROUP == js ]]; then cd ./nbdime-web; fi'
- 'if [[ $GROUP == js ]]; then npm install; fi'
before_script:
# Set up a virtual screen for Firefox browser testing:
- export CHROME_BIN=chromium-browser
- 'if [[ $GROUP == js ]]; then export DISPLAY=:99.0; fi'
- 'if [[ $GROUP == js ]]; then sh -e /etc/init.d/xvfb start; fi'
script:
- py.test -l --cov-report html --cov=nbdime
- 'if [[ $GROUP == python ]]; then py.test -l --cov-report html --cov=nbdime; fi'
- 'if [[ $GROUP == js ]]; then npm test; fi'
after_success:
- 'if [[ $GROUP == js ]]; then cd ..; fi'
- codecov
before_cache:
# Do not cache our folder
- rm -rf nbdime/webapp/node_modules/nbdime
- rm -rf nbdime/webapp/node_modules/nbdime-webapp
- rm -rf nbdime-web/node_modules/nbdime
52 changes: 52 additions & 0 deletions nbdime-web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "nbdime",
"version": "0.1.0",
"directories": {
"lib": "lib/"
},
"scripts": {
"build": "tsc --project src && node scripts/copy-files.js",
"build:test": "webpack --config webpack.test.config.js",
"clean": "rimraf build && rimraf node_modules && rimraf static/build",
"postinstall": "npm dedupe",
"test": "npm run test:firefox",
"posttest": "node scripts/fix-coverage.js",
"test:chrome": "npm run build:test && karma start --browsers=Chrome test/karma.conf.js",
"test:debug": "npm run build:test && karma start --browsers=Chrome --singleRun=false --debug=true test/karma.conf.js",
"test:firefox": "npm run build:test && karma start --browsers=Firefox test/karma.conf.js",
"test:ie": "npm run build:test && karma start --browsers=IE test/karma.conf.js"
},
"devDependencies": {
"awesome-typescript-loader": "2.1.1",
"concurrently": "^2.2.0",
"css-loader": "^0.23.1",
"expect.js": "^0.3.1",
"file-loader": "^0.9.0",
"fs-extra": "^0.30.0",
"istanbul": "^0.4.5",
"json-loader": "^0.5.4",
"jupyterlab-extension-builder": "^0.6.2",
"karma": "^1.2.0",
"karma-chrome-launcher": "^1.0.1",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.0",
"karma-ie-launcher": "^1.0.0",
"karma-mocha": "^1.1.1",
"karma-mocha-reporter": "^2.1.0",
"karma-remap-coverage": "^0.1.1",
"karma-sourcemap-loader": "^0.3.7",
"mocha": "^3.0.2",
"rimraf": "^2.5.2",
"style-loader": "^0.13.1",
"typescript": "^1.8.10",
"url-loader": "^0.5.7",
"webpack": "^1.13.1"
},
"dependencies": {
"codemirror": "^5.17.0",
"json-stable-stringify": "^1.0.1",
"jupyter-js-services": "^0.18.0",
"jupyterlab": "^0.3.0",
"phosphor": "^0.6.1"
}
}
7 changes: 7 additions & 0 deletions nbdime-web/scripts/copy-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

var fs = require('fs-extra');
fs.copySync('src/', 'lib/', { filter: /\.css$/ });
fs.copySync('src/', 'lib/', { filter: /\.svg$/ });
fs.copySync('src/', 'lib/', { filter: /\.png$/ });
33 changes: 33 additions & 0 deletions nbdime-web/scripts/fix-coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

var istanbul = require('istanbul');
var path = require('path');
var collector = new istanbul.Collector();
var reporter = new istanbul.Reporter();

var remappedJson = require('../coverage/remapped.json');
var keys = Object.keys(remappedJson);
var coverage = {};


// Filter out any path that is not local:
var shortPrefix = 'src/';
for (var i = 0; i < keys.length; i++) {
var key = keys[i].replace(/\\/g, '/');
if (key.startsWith(shortPrefix)) {
coverage[ key ] = remappedJson[ keys[i] ];
} else {
var longPrefix = path.resolve(__dirname + '/../' + shortPrefix).replace(/\\/g, '/');
if (key.startsWith(longPrefix)) {
coverage[ keys[i] ] = remappedJson[ keys[i] ];
}
}
}


collector.add(coverage);
reporter.add('html');
reporter.add('lcovonly');
reporter.reports['lcovonly'].file = 'coverage.lcov';
reporter.write(collector, true, function() {});
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

'use strict';

import 'codemirror/lib/codemirror.css';
import 'jupyterlab/lib/codemirror/index.css';

import * as CodeMirror from 'codemirror';

import {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ import {
IStringDiffModel, StringDiffModel, OutputDiffModel
} from './model';

import 'phosphor/styles/base.css';
import 'jupyterlab/lib/basestyle/materialcolors.css';
import 'jupyterlab/lib/default-theme/variables.css';
import 'jupyterlab/lib/markdownwidget/index.css';
import 'jupyterlab/lib/notebook/index.css';
import 'jupyterlab/lib/renderers/index.css';
import 'jupyterlab/lib/editorwidget/index.css';
import 'jupyterlab/lib/editorwidget/index.css';
import '../common/collapsible.css';


const NBDIFF_CLASS = 'jp-Notebook-diff';

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ import {
} from '../diff/widgets';


import 'phosphor/styles/base.css';
import '../common/dragpanel.css';
import '../common/collapsible.css';
import '../upstreaming/flexpanel.css';
import 'jupyterlab/lib/basestyle/materialcolors.css';
import 'jupyterlab/lib/default-theme/variables.css';
import 'jupyterlab/lib/markdownwidget/index.css';
import 'jupyterlab/lib/notebook/index.css';
import 'jupyterlab/lib/renderers/index.css';
import 'jupyterlab/lib/editorwidget/index.css';
import 'jupyterlab/lib/editorwidget/index.css';


const NBMERGE_CLASS = 'jp-Notebook-merge';

const ROOT_METADATA_CLASS = 'jp-Metadata-diff';
Expand Down
File renamed without changes.
55 changes: 55 additions & 0 deletions nbdime-web/src/request/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
'use strict';



/**
* Make a POST request passing a JSON argument and receiving a JSON result.
*/
export
function requestJson(url: string, argument: any, callback: (result: any) => void, onError: (result: any) => void) {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState === 4) {
if (xhttp.status === 200) {
let result = JSON.parse(xhttp.responseText);
callback(result);
} else {
onError(xhttp.responseText);
}
}
};
xhttp.open('POST', url, true);
xhttp.setRequestHeader('Content-type', 'application/json');
xhttp.send(JSON.stringify(argument));
}

/**
* Make a diff request for the given base/remote specifiers (filenames)
*/
export
function requestDiff(
base: string, remote: string,
onComplete: (result: any) => void,
onFail: (result: any) => void) {
requestJson('/api/diff',
{base: base, remote: remote},
onComplete,
onFail);
}


/**
* Make a diff request for the given base/remote specifiers (filenames)
*/
export
function requestMerge(
base: string, local: string, remote: string,
onComplete: (result: any) => void,
onFail: (result: any) => void) {
requestJson('/api/merge',
{base: base, local: local, remote: remote},
onComplete,
onFail);
}
File renamed without changes.
119 changes: 119 additions & 0 deletions nbdime-web/src/styles/diff.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@



.jp-Diff-unchanged .jp-Output *:first-child {
margin-left: auto;
}

.jp-Diff-unchanged .jp-Output *:last-child {
margin-right: auto;
}

.jp-Diff-unchanged .jp-Diff-unchanged {
margin-left: 0;
width: 100%;
}

.jp-Metadata-diff {
margin-bottom: 20px;
border: solid black thin;
}

.jp-Cell-diff {
margin-bottom: 20px;
border-top: solid #ccc 1px;
}

.jp-Diff-added > div:first-child {
float: left;
width: 25%;
}

.jp-Diff-deleted > div:first-child {
float: right;
width: 25%;
}

.jp-Diff-added .jp-Cellrow-metadata {
display: none;
}

.jp-Diff-deleted .jp-Cellrow-metadata {
display: none;
}

.jp-Diff-unchanged .jp-Cellrow-outputs {
display: none;
}

/*
.jp-Diff-added .jp-Cellrow-outputs {
display: none;
}
.jp-Diff-deleted .jp-Cellrow-outputs {
display: none;
}
*/

.jp-Diff-added .jp-Diff-unchanged {
margin-left: 25%;
width: 75%;
}

.jp-Diff-deleted .jp-Diff-unchanged {
margin-left: 0;
width: 75%;
}

.jp-Diff-unchanged .jp-Output-result > * {
display: block;
margin-left: auto;
margin-right: auto;
}

.jp-Cellrow-outputs .jp-Diff-twoway .jp-Diff-base {
float: left;
width: 47%;
}

.jp-Cellrow-outputs .jp-Diff-twoway .jp-Diff-remote {
float: right;
width: 47%;
}

.jp-Notebook-diff .jp-Output-result img {
max-width: 100%;
}

.jp-Notebook-diff .CodeMirror-merge-pane-remote {
position: relative;
left: 6%;
}

.CodeMirror-merge-pane-deleted, .CodeMirror-merge-pane-added { width: 75%; }

.jp-Notebook-diff .CodeMirror-merge-r-chunk { background-color: #ffecec; }
.jp-Notebook-diff .CodeMirror-merge-r-chunk-start { border-top: 1px solid #f8cbcb; }
.jp-Notebook-diff .CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #f8cbcb; }
.jp-Notebook-diff .CodeMirror-merge-r-connect { fill: #ffffe0; stroke: #f8cbcb; stroke-width: 1px; }
.jp-Notebook-diff .CodeMirror-merge-spacer { background-color: #ffecec; }

.jp-Notebook-diff .CodeMirror-merge-pane-remote .CodeMirror-merge-r-chunk { background-color: #dbffdb; }
.jp-Notebook-diff .CodeMirror-merge-pane-remote .CodeMirror-merge-r-chunk-start { border-top: 1px solid #a6f3a6; }
.jp-Notebook-diff .CodeMirror-merge-pane-remote .CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #a6f3a6; }
.jp-Notebook-diff .CodeMirror-merge-pane-remote .CodeMirror-merge-r-connect { fill: #ffffe0; stroke: #a6f3a6; stroke-width: 1px; }
.jp-Notebook-diff .CodeMirror-merge-pane-remote .CodeMirror-merge-spacer { background-color: #dbffdb; }


.jp-Diff-deleted .CodeMirror {
background-color: #ffecec;
}

.jp-Diff-added .CodeMirror {
background-color: #dbffdb;
}

.jp-Diff-added .CodeMirror-merge-pane-added {
width: 100%;
}

0 comments on commit 9824304

Please sign in to comment.