|
@@ -2,6 +2,7 @@
|
|
|
var fs = require('fs-extra');
|
|
|
var path = require('path');
|
|
|
var childProcess = require('child_process');
|
|
|
+var sortPackageJson = require('sort-package-json');
|
|
|
|
|
|
/**
|
|
|
* Add an extension to the source tree of JupyterLab.
|
|
@@ -38,7 +39,7 @@ if (target[0] === '.' || target[0] === '/') {
|
|
|
// Copy the package directory contents to the sibling package.
|
|
|
var newPackagePath = path.join(basePath, 'packages', packageDirName);
|
|
|
fs.copySync(packagePath, newPackagePath);
|
|
|
-} else {
|
|
|
+} else {
|
|
|
// Otherwise treat it as a git reposotory and try to add it.
|
|
|
packageDirName = target.split('/').pop().split('.')[0];
|
|
|
var packagePath = path.join(basePath, 'packages', packageDirName);
|
|
@@ -52,8 +53,9 @@ var package = require(path.join(packagePath, 'package.json'));
|
|
|
// Add the extension to packages/all-packages/package.json
|
|
|
var allPackagesPath = path.join(basePath, 'packages', 'all-packages', 'package.json');
|
|
|
var allPackages = require(allPackagesPath);
|
|
|
-allPackages.dependencies[package.name] = '~'+String(package.version);
|
|
|
-fs.writeFileSync(allPackagesPath, JSON.stringify(allPackages, null, 2) + '\n');
|
|
|
+allPackages.dependencies[package.name] = '^'+String(package.version);
|
|
|
+var text = JSON.stringify(sortPackageJson(allPackages), null, 2) + '\n';
|
|
|
+fs.writeFileSync(allPackagesPath, text);
|
|
|
|
|
|
// Add the extension path to packages/all-packages/tsconfig.json
|
|
|
var tsconfigPath = path.join(basePath, 'packages', 'all-packages', 'tsconfig.json');
|
|
@@ -66,10 +68,3 @@ var indexPath = path.join(basePath, 'packages', 'all-packages', 'src', 'index.ts
|
|
|
var index = fs.readFileSync(indexPath, 'utf8');
|
|
|
index = index + 'import "' + package.name + '";\n';
|
|
|
fs.writeFileSync(indexPath, index);
|
|
|
-
|
|
|
-// Add the extension to jupyterlab/package.json
|
|
|
-var jupyterlabPackagePath = path.join(basePath, 'jupyterlab', 'package.json');
|
|
|
-var jupyterlabPackage = require(jupyterlabPackagePath);
|
|
|
-jupyterlabPackage.dependencies[package.name] = '~'+String(package.version);
|
|
|
-jupyterlabPackage.jupyterlab.extensions.push(package.name);
|
|
|
-fs.writeFileSync(jupyterlabPackagePath, JSON.stringify(jupyterlabPackage, null, 2) + '\n');
|