{"size": 1783, "ext": "js", "max_stars_repo_path": "jupyterlab/make-release.js", "max_stars_repo_name": "wispyoureyes/jupyterlab", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "jupyterlab/make-release.js", "max_issues_repo_name": "wispyoureyes/jupyterlab", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "jupyterlab/make-release.js", "max_forks_repo_name": "wispyoureyes/jupyterlab", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.0151515152, "max_line_length": 79, "alphanum_fraction": 0.6752664049}
var childProcess = require('child_process');
var fs = require('fs-extra');
var glob = require('glob');
var path = require('path');
var sortPackageJson = require('sort-package-json');


/**
 * Update the dependencies of the package.
 */
function updateDependencies(data) {
  // Handle all of the packages.
  var basePath = path.resolve('..');
  var files = glob.sync(path.join(basePath, 'packages/*'));
  for (var j = 0; j < files.length; j++) {
    handlePackage(files[j], data);
  }
}


/**
 * Handle an individual package on the path - get its dependencies.
 */
function handlePackage(packagePath, data) {
  // Read in the package.json.
  var packagePath = path.join(packagePath, 'package.json');
  try {
    var package = require(packagePath);
  } catch (e) {
    console.log('Skipping package ' + packagePath);
    return;
  }

  var deps = package.dependencies || [];
  for (var dep in deps) {
    data.dependencies[dep] = deps[dep];
  }
}


// Get the current version of JupyterLab
var cwd = path.resolve('..');
var version = childProcess.execSync('python setup.py --version', { cwd: cwd });
version = version.toString().trim();

// Update our package.json files.
var data = require('./package.json');
data['jupyterlab']['version'] = version;

// Update our package.json files.
updateDependencies(data);
var text = JSON.stringify(sortPackageJson(data), null, 2) + '\n';
fs.writeFileSync('./package.json', text);
fs.writeFileSync('./package.app.json', text);

// Update our app index file.
fs.copySync('./index.js', './index.app.js')

// Run a standard build.
childProcess.execSync('npm run build');

// Add  the release metadata.
var release_data = { version: version };
text = JSON.stringify(release_data, null, 2) + '\n';
fs.writeFileSync('./build/release_data.json', text);
