demo | Cell 13 | update notebook repo on colab | Search

This code sets up a development environment for a Jupyter project by installing necessary packages, configuring Git, and initializing a repository. It then pulls the latest code from a remote repository and builds the project.

Run example

npm run import -- "Install build stack on colab"

Install build stack on colab

!npm config set user 0
!npm config set unsafe-perm true
!npm install -g --unsafe-perm ijavascript zeromq node-gyp node-pre-gyp webpack
!ijsinstall --install=global
!jupyter-kernelspec list
!apt-get install -yy git built-tools
!rm -R /content/jupytangular/ || true
!mkdir /content/jupytangular
!ln -s /content/jupytangular /Core || true
!git init /content/jupytangular
!cd jupytangular && git remote add origin https://:@bitbucket.org/megamindbrian/jupyter_ops.git
!cd jupytangular && git fetch
!cd jupytangular && git reset --hard origin/master
!cd jupytangular && git pull origin master
!cd jupytangular && npm install && npm run test && npm run build

What the code could have been:

// Set npm configuration
npmConfig = {
  user: 0,
  unsafePerms: true
};

// Set unsafe-perm true (using npm config object)
npm.config.set('unsafe-perm', true);

// Set user 0 (using npm config object)
npm.config.set('user', 0);

// Install global packages
const packages = [
  'ijavascript',
  'zeromq',
  'node-gyp',
  'node-pre-gyp',
  'webpack'
];

packages.forEach(packageName => {
  npm.config.set('unsafe-perm', true);
  npm.install(packageName, { global: true });
});

// Perform ijsinstall with global install flag
const ijsinstall = require('ijsinstall');
ijsinstall({ install: 'global' });

// List jupyter kernels
console.log(npm.cmd('jupyter-kernelspec', 'list'));

// Install git and build tools
const childProcess = require('child_process');
childProcess.execSync('apt-get install -yy git build-essential');

// Create jupytangular directory if it does not exist
const path = require('path');
const jupytangularDir = path.join('/content', 'jupytangular');
if (!fs.existsSync(jupytangularDir)) {
  fs.mkdirSync(jupytangularDir);
}

// Create symbolic link
const fs = require('fs');
fs.symlinkSync(jupytangularDir, '/Core');

// Initialize git in jupytangular directory
const git = require('git');
const jupytangularRepo = path.join(jupytangularDir, '.git');
fs.mkdirSync(jupytangularRepo);
git.init(jupytangularRepo);

// Add remote origin and fetch data
const gitRemote = require('git-remote');
gitRemote.add(jupytangularRepo, 'origin', 'https://:@bitbucket.org/megamindbrian/jupyter_ops.git');
gitRemote.fetch(jupytangularRepo, 'origin');

// Reset local branch to origin/master
const gitReset = require('git-reset');
gitReset(jupytangularRepo, '--hard', 'origin/master');

// Pull master branch
const gitPull = require('git-pull');
gitPull(jupytangularRepo,'master');

// Install dependencies, run tests and build
process.chdir(jupytangularDir);
npm.install();
npm.run('test');
npm.run('build');

This code snippet appears to be a series of shell commands designed to set up a development environment for a Jupyter-based project.

Here's a breakdown:

1. npm Configuration and Installation:

2. ijavascript Installation:

3. Jupyter Environment Setup:

4. Project Directory Creation and Initialization:

5. Git Remote and Branch Setup:

6. Project Build and Testing:

Let me know if you have any more questions!