Explorar el Código

Clean up the development scripts

Steven Silvester hace 8 años
padre
commit
0912277a42

+ 1 - 1
jupyterlab/package.json

@@ -5,7 +5,7 @@
   "scripts": {
     "build": "npm install && tsc && webpack",
     "clean": "rimraf build",
-    "watch": "watch \"npm run build\" ../packages --wait 10 --ignoreDotFiles"
+    "watch": "watch \"npm run build\" ../packages --wait 10 --filter=../scripts/watch-filter.js"
   },
   "dependencies": {
     "@jupyterlab/application": "^0.1.1",

+ 6 - 4
package.json

@@ -11,9 +11,10 @@
     "build:main": "cd jupyterlab && npm run build",
     "build:src": "lerna run build --scope \"@jupyterlab/!(test-|example-)*\"",
     "build:tests": "lerna run build --scope \"@jupyterlab/test-*\"",
-    "clean": "lerna run clean",
-    "clean:examples": "lerna run clean --scope \"@jupyterlab/example-*\"",
-    "clean:src": "lerna run clean --scope \"@jupyterlab/!(test-|example-)*\"",
+    "clean": "node scripts/clean-packages.js examples packages",
+    "clean:examples": "node scripts/clean-packages.js examples",
+    "clean:main": "cd jupyterlab && npm run clean",
+    "clean:src": "node scripts/clean-packages.js packages",
     "clean:tests": "lerna run clean --scope \"@jupyterlab/test-*\"",
     "coverage": "lerna run coverage --stream --scope \"@jupyterlab/test-*\"",
     "test": "lerna run test --stream --scope \"@jupyterlab/test-*\"",
@@ -21,6 +22,7 @@
     "test:firefox": "lerna run test:firefox --stream --scope \"@jupyterlab/test-*\"",
     "test:ie": "lerna run test:ie --concurrency 1 --stream --scope \"@jupyterlab/test-*\"",
     "package:update": "lerna exec --scope \"@jupyterlab/!(test-|main)*\" -- node ../../scripts/package-update.js",
-    "publish": "npm run clean && npm run build && lerna publish -m \"Publish\""
+    "publish": "lerna publish -m \"Publish\"",
+    "watch": "cd jupyterlab && npm run watch"
   }
 }

+ 0 - 17
scripts/buildexamples.js

@@ -1,17 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-var childProcess = require('child_process');
-var fs = require('fs');
-
-// Build all of the example folders.
-dirs = fs.readdirSync('examples');
-
-for (var i = 0; i < dirs.length; i++) {
-  console.log('\n********');
-  console.log('Building: ' + dirs[i] + '...');
-  process.chdir('examples/' + dirs[i]);
-  childProcess.execSync('rimraf node_modules/jupyterlab && npm install --cache-min 9999999', { stdio: [0, 1, 2] });
-  process.chdir('../..');
-}
-console.log('\n********\nDone building examples!');

+ 53 - 0
scripts/clean-packages.js

@@ -0,0 +1,53 @@
+#!/usr/bin/env node
+var fs = require('fs');
+var path = require('path');
+var glob = require('glob');
+var childProcess = require('child_process');
+
+
+// Get all of the packages.
+var basePath = path.resolve('.');
+var lernaConfig = require(path.join(basePath, 'lerna.json'));
+var packageConfig = lernaConfig.packages;
+var skipSource = process.argv.indexOf('packages') === -1;
+var skipExamples = process.argv.indexOf('examples') === -1;
+
+
+// Handle the packages
+for (var i = 0; i < packageConfig.length; i++) {
+  if (skipSource && packageConfig[i] === 'packages/*') {
+    continue;
+  }
+  if (skipExamples && packageConfig[i] === 'examples/*') {
+    continue;
+  }
+  var files = glob.sync(path.join(basePath, packageConfig[i]));
+  for (var j = 0; j < files.length; j++) {
+    try {
+      handlePackage(files[j]);
+    } catch (e) {
+      console.error(e);
+    }
+  }
+}
+
+
+/**
+ * Handle an individual package on the path - update the dependency.
+ */
+function handlePackage(packagePath) {
+  // Read in the package.json.
+  var packagePath = path.join(packagePath, 'package.json');
+  var package = require(packagePath);
+  if (!package.scripts || !package.scripts.clean) {
+    return;
+  }
+  var targets = package.scripts.clean.split('&&');
+  for (var i = 0; i < targets.length; i++) {
+    var target = targets[i].replace('rimraf', '').trim();
+    target = path.join(packagePath, target);
+    if (fs.existsSync(target)) {
+      fs.removeSync(target);
+    }
+  }
+}

+ 0 - 16
scripts/cleanexamples.js

@@ -1,16 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-var childProcess = require('child_process');
-var fs = require('fs');
-
-// Clean all of the example folders.
-dirs = fs.readdirSync('examples');
-
-for (var i = 0; i < dirs.length; i++) {
-  console.log('Cleaning: ' + dirs[i] + '...');
-  process.chdir('examples/' + dirs[i]);
-  childProcess.execSync('npm run clean', { stdio: [0, 1, 2] });
-  process.chdir('../..');
-}
-console.log('\n********\nDone!');

+ 0 - 7
scripts/copyfiles.js

@@ -1,7 +0,0 @@
-// 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: /\.gif$/ });

+ 0 - 11
scripts/dedupe.js

@@ -1,11 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-var childProcess = require('child_process');
-var semver = require('semver');
-var required = '3.0.0';
-var version = childProcess.execSync('npm --version', { encoding: 'utf8' });
-
-if (semver.lt(version, required)) {
-  childProcess.execSync('npm dedupe', { stdio: [0, 1, 2] });
-}

+ 0 - 0
scripts/package-update.js → scripts/update-dependency.js


+ 14 - 0
scripts/watch-filter.js

@@ -0,0 +1,14 @@
+var path = require('path');
+
+module.exports = function(f, stat) {
+    if (f.indexOf('node_modules') !== -1) {
+        return false;
+    }
+    if (f.indexOf('.git') !== -1) {
+        return false;
+    }
+    if (f.indexOf('src') !== -1 && f.indexOf('style') !== -1) {
+        return false;
+    }
+    return true;
+}

+ 0 - 1
setupbase.py

@@ -131,7 +131,6 @@ class NPM(Command):
         log.info("Installing build dependencies with npm. This may take a while...")
         main = os.path.join(here, 'jupyterlab')
         run(['npm', 'install'], cwd=here)
-        run(['npm', 'run', 'clean'], cwd=main)
         run(['npm', 'run', 'build'], cwd=main)
 
         for t in self.targets: