瀏覽代碼

Streamline example install and building

Steven Silvester 9 年之前
父節點
當前提交
b207ba7f0f

+ 0 - 34
examples/filebrowser/package.json

@@ -1,34 +0,0 @@
-{
-  "private": true,
-  "name": "filebrowser-example",
-  "dependencies": {
-    "codemirror": "^5.12.0",
-    "jupyter-js-services": "^0.5.1",
-    "jupyter-js-ui": "file:../..",
-    "jupyter-js-utils": "^0.3.1",
-    "phosphor-arrays": "^1.0.6",
-    "phosphor-codemirror": "0.0.1",
-    "phosphor-dockpanel": "^0.9.6",
-    "phosphor-keymap": "^0.7.1",
-    "phosphor-menus": "^1.0.0-rc.1",
-    "phosphor-splitpanel": "^1.0.0-rc.1",
-    "phosphor-widget": "^1.0.0-rc.1"
-  },
-  "scripts": {
-    "build": "tsconfig -u src/tsconfig.json && tsc --project src && webpack --config webpack.conf.js",
-    "clean": "rimraf build && rimraf node_modules",
-    "postinstall": "npm dedupe",
-    "update": "rimraf node_modules/jupyter-js-ui && npm install",
-    "watch:src": "watch 'npm run build' src --wait 5",
-    "watch": "concurrently 'npm run watch:src' 'python main.py'"
-  },
-  "devDependencies": {
-    "concurrently": "^2.0.0",
-    "css-loader": "^0.23.1",
-    "rimraf": "^2.5.2",
-    "style-loader": "^0.13.0",
-    "tsconfig-cli": "^0.1.1",
-    "watch": "^0.17.1",
-    "webpack": "^1.12.14"
-  }
-}

+ 19 - 0
examples/package.json

@@ -0,0 +1,19 @@
+{
+  "private": true,
+  "name": "jupyter-js-ui-example",
+  "dependencies": {
+    "jupyter-js-ui": "file:..",
+    "phosphor-dockpanel": "^0.9.6",
+    "phosphor-keymap": "^0.7.1",
+    "phosphor-splitpanel": "^1.0.0-rc.1"
+  },
+  "scripts": {
+    "build": "cd .. && npm run build:examples",
+    "clean": "rimraf node_modules",
+    "postinstall": "npm dedupe",
+    "update": "rimraf node_modules/jupyter-js-ui && npm install"
+  },
+  "devDependencies": {
+    "rimraf": "^2.5.2"
+  }
+}

+ 0 - 25
examples/terminal/package.json

@@ -1,25 +0,0 @@
-{
-  "private": true,
-  "name": "terminal-example",
-  "dependencies": {
-    "phosphor-dockpanel": "^0.9.6",
-    "jupyter-js-ui": "file:../.."
-  },
-  "scripts": {
-    "build": "tsconfig -u src/tsconfig.json && tsc --project src && webpack --config webpack.conf.js",
-    "clean": "rimraf build && rimraf node_modules",
-    "postinstall": "npm dedupe",
-    "update": "rimraf node_modules/jupyter-js-ui && npm install",
-    "watch:src": "watch 'npm run build' src --wait 5",
-    "watch": "concurrently 'npm run watch:src' 'python main.py'"
-  },
-  "devDependencies": {
-    "concurrently": "^2.0.0",
-    "css-loader": "^0.23.1",
-    "rimraf": "^2.5.2",
-    "style-loader": "^0.13.0",
-    "tsconfig-cli": "^0.1.1",
-    "watch": "^0.17.1",
-    "webpack": "^1.12.14"
-  }
-}

+ 2 - 1
package.json

@@ -5,6 +5,7 @@
   "main": "lib/index.js",
   "typings": "lib/index.d.ts",
   "dependencies": {
+    "codemirror": "^5.12.0",
     "jupyter-js-services": "^0.5.4",
     "jupyter-js-utils": "^0.3.3",
     "moment": "^2.11.2",
@@ -20,6 +21,7 @@
     "term.js": "0.0.7"
   },
   "devDependencies": {
+    "concurrently": "^2.0.0",
     "css-loader": "^0.23.1",
     "expect.js": "^0.3.1",
     "file-loader": "^0.8.5",
@@ -46,7 +48,6 @@
   "scripts": {
     "clean": "rimraf docs && rimraf lib && rimraf test/build",
     "clean:examples": "node scripts/cleanexamples.js",
-    "build:example": "cd examples/$EXAMPLE && npm run update && npm run build",
     "build:examples": "node scripts/buildexamples.js",
     "build:src": "tsc --project src && node scripts/copycss.js",
     "build:test": "tsconfig -u test/src/tsconfig.json && tsc --project test/src && webpack --config test/webpack.conf.js",

+ 18 - 1
scripts/buildexamples.js

@@ -1,12 +1,29 @@
 var childProcess = require('child_process');
 var fs = require('fs');
 
+process.chdir('examples');
+childProcess.execSync('npm install', { stdio: [0, 1, 2] });
+childProcess.execSync('npm run update', { stdio: [0, 1, 2] });
+process.chdir('..');
+
 // Build all of the example folders.
 dirs = fs.readdirSync('examples');
 
+var cmd;
 for (var i = 0; i < dirs.length; i++) {
+  if (dirs[i].indexOf('.') !== -1) {
+    continue;
+  }
+  if (dirs[i].indexOf('node_modules') !== -1) {
+    continue;
+  }
   console.log('Building: ' + dirs[i] + '...');
+  cmd = 'tsconfig -u examples/' + dirs[i] + '/src/tsconfig.json';
+  childProcess.execSync(cmd, { stdio: [0, 1, 2] });
+  cmd = 'tsc --project examples/' + dirs[i] + '/src';
+  childProcess.execSync(cmd, { stdio: [0, 1, 2] });
   process.chdir('examples/' + dirs[i]);
-  childProcess.execSync('npm run update && npm run build', { stdio: [0, 1, 2] });
+  cmd = 'webpack --config webpack.conf.js';
+  childProcess.execSync(cmd, { stdio: [0, 1, 2] });
   process.chdir('../..');
 }

+ 8 - 3
scripts/cleanexamples.js

@@ -1,11 +1,16 @@
 var childProcess = require('child_process');
 var fs = require('fs');
 
+childProcess.execSync('rimraf examples/node_modules', { stdio: [0, 1, 2] });
+
 // Clean all of the example folders.
 dirs = fs.readdirSync('examples');
 
 for (var i = 0; i < dirs.length; i++) {
-  process.chdir('examples/' + dirs[i]);
-  childProcess.execSync('npm run clean', { stdio: [0, 1, 2] });
-  process.chdir('../..');
+  if (dirs[i].indexOf('.') !== -1) {
+    continue;
+  }
+  var cmd = 'rimraf examples/' + dirs[i] + '/build';
+  childProcess.execSync(cmd, { stdio: [0, 1, 2] });
+  
 }

+ 1 - 0
scripts/travis_script.sh

@@ -6,6 +6,7 @@ export PATH="$HOME/miniconda/bin:$PATH"
 
 npm run clean
 npm run build
+npm run clean:examples
 npm run build:examples
 
 npm run test