Skip to content

Commit

Permalink
Merge pull request #1739 from jasongrout/dep
Browse files Browse the repository at this point in the history
Fix dependency issues.
  • Loading branch information
jasongrout authored Oct 18, 2017
2 parents 742350d + 5463c6a commit 378d160
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 24 deletions.
3 changes: 2 additions & 1 deletion examples/web-tmpnb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@jupyter-widgets/base": "^1.0.3",
"@jupyter-widgets/controls": "^1.0.3",
"@jupyterlab/services": "^0.50.2",
"@types/codemirror": "0.0.33",
"@phosphor/disposable": "^1.1.0",
"@phosphor/widgets": "^1.2.0",
"codemirror": "^5.9.0",
"font-awesome": "^4.7.0",
"http-server": "^0.10.0"
Expand Down
3 changes: 2 additions & 1 deletion examples/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"@jupyter-widgets/controls": "^1.0.3",
"@jupyter-widgets/html-manager": "^0.10.3",
"@jupyterlab/services": "^0.50.2",
"@types/codemirror": "0.0.33",
"@phosphor/disposable": "^1.1.0",
"@phosphor/widgets": "^1.2.0",
"codemirror": "^5.9.0",
"font-awesome": "^4.7.0",
"http-server": "^0.10.0"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"build:examples": "lerna run build --scope \"@jupyter-widgets/example-*\" --include-filtered-dependencies",
"build": "lerna run build --ignore \"@jupyter-widgets/example-*\"",
"update:dependency": "node scripts/update-dependency.js",
"integrity": "node scripts/package-integrity.js",
"updated": "lerna updated",
"publish": "npm run clean && npm run build && lerna publish -m \"Publish npm packages\""
},
Expand Down
7 changes: 1 addition & 6 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,14 @@
"webpack": "^3.5.5"
},
"dependencies": {
"@jupyter-widgets/schema": "^0.3.0",
"@jupyterlab/services": "^0.50.2",
"@phosphor/algorithm": "^1.1.0",
"@phosphor/domutils": "^1.1.0",
"@phosphor/messaging": "^1.2.0",
"@phosphor/widgets": "^1.2.0",
"@types/backbone": "^1.3.33",
"@types/lodash": "^4.14.66",
"@types/semver": "^5.3.30",
"backbone": "1.2.3",
"base64-js": "^1.2.1",
"jquery": "^3.1.1",
"lodash": "^4.17.4",
"semver": "^5.1.0"
"lodash": "^4.17.4"
}
}
4 changes: 1 addition & 3 deletions packages/base/src/manager-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Distributed under the terms of the Modified BSD License.

import * as utils from './utils';
import * as semver from 'semver';
import * as Backbone from 'backbone';
import * as services from '@jupyterlab/services';

import {
Expand Down Expand Up @@ -211,7 +209,7 @@ abstract class ManagerBase<T> {
/**
* Handle when a comm is opened.
*/
handle_comm_open(comm: shims.services.Comm, msg: services.KernelMessage.ICommOpenMsg): Promise<Backbone.Model> {
handle_comm_open(comm: shims.services.Comm, msg: services.KernelMessage.ICommOpenMsg): Promise<WidgetModel> {
let protocolVersion = ((msg.metadata || {}).version as string) || '';
if (protocolVersion.split('.', 1)[0] !== PROTOCOL_MAJOR_VERSION) {
let error = `Wrong widget protocol version: received protocol version '${protocolVersion}', but was expecting major version '${PROTOCOL_MAJOR_VERSION}'`;
Expand Down
8 changes: 1 addition & 7 deletions packages/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"prepublish": "npm run clean && npm run build"
},
"devDependencies": {
"@jupyterlab/services": "^0.50.2",
"@types/expect.js": "^0.3.29",
"@types/mathjax": "0.0.31",
"@types/mocha": "^2.2.41",
Expand Down Expand Up @@ -67,21 +68,14 @@
},
"dependencies": {
"@jupyter-widgets/base": "^1.0.3",
"@jupyter-widgets/schema": "^0.3.0",
"@jupyterlab/services": "^0.50.2",
"@phosphor/algorithm": "^1.1.0",
"@phosphor/domutils": "^1.1.0",
"@phosphor/messaging": "^1.2.0",
"@phosphor/signaling": "^1.2.0",
"@phosphor/widgets": "^1.2.0",
"@types/backbone": "^1.3.33",
"@types/semver": "^5.3.30",
"backbone": "1.2.3",
"d3-format": "^0.5.1",
"font-awesome": "^4.7.0",
"jquery": "^3.1.1",
"jquery-ui": "^1.12.1",
"semver": "^5.1.0",
"underscore": "^1.8.3"
}
}
4 changes: 3 additions & 1 deletion packages/html-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
"@jupyter-widgets/output": "^1.0.3",
"@jupyter-widgets/schema": "^0.3.0",
"@jupyterlab/outputarea": "^0.11.1",
"@jupyterlab/rendermime": "^0.11.0",
"@jupyterlab/rendermime-interfaces": "^0.4.1",
"@phosphor/widgets": "^1.2.0",
"ajv": "^5.2.2",
"font-awesome": "^4.7.0"
"font-awesome": "^4.7.0",
"jquery": "^3.1.1"
},
"devDependencies": {
"@types/mocha": "^2.2.41",
Expand Down
9 changes: 8 additions & 1 deletion packages/jupyterlab-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@
"@jupyter-widgets/controls": "^1.0.3",
"@jupyter-widgets/output": "^1.0.3",
"@jupyterlab/application": "^0.11.0",
"@jupyterlab/coreutils": "^0.11.1",
"@jupyterlab/docregistry": "^0.11.0",
"@jupyterlab/notebook": "^0.11.0",
"@jupyterlab/outputarea": "^0.11.1",
"@jupyterlab/rendermime": "^0.11.0",
"@jupyterlab/rendermime-interfaces": "^0.4.1",
"@jupyterlab/services": "^0.50.2",
"@phosphor/coreutils": "^1.1.0",
"@phosphor/disposable": "^1.1.0",
"@phosphor/widgets": "^1.2.0"
"@phosphor/messaging": "^1.2.0",
"@phosphor/widgets": "^1.2.0",
"@types/backbone": "^1.3.33",
"jquery": "^3.1.1",
"semver": "^5.1.0"
},
"devDependencies": {
"@types/semver": "^5.4.0",
"rimraf": "^2.6.1",
"typedoc": "^0.6.0",
"typescript": "~2.4.1"
Expand Down
1 change: 1 addition & 0 deletions packages/jupyterlab-manager/src/manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

// Just need typings
import * as Backbone from 'backbone';

import {
Expand Down
5 changes: 2 additions & 3 deletions packages/jupyterlab-manager/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
KernelMessage
} from '@jupyterlab/services';

import * as _ from 'underscore';
import * as $ from 'jquery';

export
Expand All @@ -44,9 +43,9 @@ const OUTPUT_WIDGET_VERSION = outputBase.OUTPUT_WIDGET_VERSION;
export
class OutputModel extends outputBase.OutputModel {
defaults() {
return _.extend(super.defaults(), {
return {...super.defaults(),
msg_id: ''
});
};
}

initialize(attributes: any, options: any) {
Expand Down
2 changes: 1 addition & 1 deletion packages/jupyterlab-manager/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"noEmitOnError": true,
"lib": ["dom", "es5", "es2015.promise"],
"types": ["mathjax", "node"],
"types": ["node"],
"module": "commonjs",
"moduleResolution": "node",
"target": "ES5",
Expand Down
146 changes: 146 additions & 0 deletions scripts/package-integrity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/**
* Verify the integrity of each package - ensure package json matches
* imports
*
* Originally based on https://github.com/jupyterlab/jupyterlab/blob/a36639e65aa0c5bc50b2b0bfa562bde1bb393c28/scripts/package-integrity.js
*
*/

var readFileSync = require("fs").readFileSync;
var writeFileSync = require("fs").writeFileSync;
var ts = require("typescript");
var glob = require("glob");
var childProcess = require('child_process');
var path = require('path');


// Packages to ignore
var IGNORE = {
'@jupyter-widgets/base': ['@types/backbone', '@types/lodash'],
'@jupyter-widgets/jupyterlab-manager': ['backbone', '@types/backbone'],
'@jupyter-widgets/html-manager': ['ajv', '@jupyter-widgets/schema'],
'@jupyter-widgets/example-web-tmpnb': ['http-server', 'font-awesome'],
'@jupyter-widgets/example-web3': ['http-server']
}

/**
* Extract the module imports from a TypeScript source file.
*/
function getImports(sourceFile) {
var imports = [];
handleNode(sourceFile);

function handleNode(node) {
switch (node.kind) {
case ts.SyntaxKind.ImportDeclaration:
imports.push(node.moduleSpecifier.text);
break;
case ts.SyntaxKind.ImportEqualsDeclaration:
imports.push(node.moduleReference.expression.text);
break;
}
ts.forEachChild(node, handleNode);
}
return imports;
}

/**
* Validate the integrity of a package in a directory.
*/
function validate(dname) {
filenames = glob.sync(dname + '/src/*.ts*');
filenames = filenames.concat(glob.sync(dname + '/src/**/*.ts*'));

if (filenames.length == 0) {
return [];
}

var imports = [];

try {
var pkg = require(path.resolve(dname) + '/package.json');
} catch (e) {
return [];
}
var ignore = IGNORE[pkg['name']] || [];
var deps = pkg['dependencies'];

// Extract all of the imports from the TypeScript files.
filenames.forEach(fileName => {
var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
imports = imports.concat(getImports(sourceFile));
//console.log(fileName, getImports(sourceFile));
});
var names = Array.from(new Set(imports)).sort();
names = names.map(function(name) {
var parts = name.split('/');
if (name.indexOf('@') === 0) {
return parts[0] + '/' + parts[1];
}
return parts[0];
})

var problems = [];
names.forEach(function(name) {
if (name === '..' || name === '.' || ignore.indexOf(name) !== -1) {
return;
}
if (!deps[name]) {
problems.push('Missing package: ' + name);
}
});
Object.keys(deps).forEach(function(name) {
if (versions[name]) {
var desired = '^' + versions[name];
if (deps[name] !== desired) {
problems.push('Bad core version: ' + name + ' should be ' + desired);
}
}
if (ignore.indexOf(name) !== -1) {
return;
}
if (names.indexOf(name) === -1) {
problems.push('Unused package: ' + name);
}
});
return problems;
}

// Find all of the packages.
var basePath = path.resolve('.');
var lernaConfig = require(path.join(basePath, 'lerna.json'));

// Gather the versions of each package.
var versions = {};
lernaConfig.packages.forEach(function(spec) {
var dirs = glob.sync(path.join(basePath, spec));
dirs.forEach(function(dname) {
try {
var pkg = require(path.resolve(dname) + '/package.json');
versions[pkg['name']] = pkg['version'];
} catch (e) {
return;
}
});
});

var errors = {};

// Validate each package.
lernaConfig.packages.forEach(function(spec) {
var dirs = glob.sync(path.join(basePath, spec));
dirs.forEach(function(dname) {
var name = path.relative('.', dname);
var problems = validate(dname);
if (problems.length > 0) {
errors[name] = problems;
}
});
});

// Handle any errors.
if (Object.keys(errors).length > 0) {
console.log('Package integrity failures:')
console.log(JSON.stringify(errors, null, 2));
process.exit(1);
}
2 changes: 2 additions & 0 deletions scripts/travis_script_js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ nvm use "v$TRAVIS_NODE_VERSION"
nvm alias default "v$TRAVIS_NODE_VERSION"
sh -e /etc/init.d/xvfb start

npm run integrity

cd packages

cd base
Expand Down

0 comments on commit 378d160

Please sign in to comment.