<commit_before>'use strict';

var chalk = require('chalk');
var fs = require('fs');
var path = require('path');

module.exports = function(kbox) {

  var util = require('./util.js')(kbox);
  var helpers = kbox.util.helpers;
  var provisioned = kbox.core.deps.lookup('globalConfig').provisioned;

  // Add common steps
  require('./steps/common.js')(kbox, 'install');

  // Run administator commands.
  kbox.install.registerStep(function(step) {
    step.name = 'core-run-admin-commands';
    if (provisioned) {
      step.deps = ['core-auth'];
    }
    if (!provisioned && process.platform === 'win32') {
      // @todo: this should be a core dep
      step.deps.push('engine-docker-provider-profile');
    }
    step.description = 'Running admin install commands...';
    step.all = function(state, done) {
      var adminCommands = state.adminCommands;
      util.runAdminCmds(adminCommands, done);
    };
  });

  if (!provisioned) {
    kbox.install.registerStep(function(step) {
      step.name = 'core-prepare-usr-bin';
      step.description  = 'Preparing /usr/local/bin...';
      step.subscribes = ['core-run-admin-commands'];
      step.deps = ['core-auth'];
      step.all.linux = function(state, done) {
        var owner = [process.env.USER, process.env.USER].join(':');
        state.adminCommands.unshift('chown ' + owner + ' /usr/local/bin');
        if (!fs.existsSync('/usr/local/bin')) {
          state.adminCommands.unshift('mkdir -p /usr/local/bin');
        }
        done();
      };
    });

    kbox.install.registerStep(function(step) {
      step.name = 'core-finish';
      step.description = 'Finishing install...';
      // @todo: need core dep
      step.deps = ['services-kalabox-finalize'];
      step.all = function(state, done) {
        fs.writeFileSync(
          path.join(state.config.sysConfRoot, 'provisioned'),
          'true'
        );
        done();
      };
    });
  }

  if (provisioned) {
    kbox.install.registerStep(function(step) {
      step.name = 'core-update';
      step.deps = ['core-auth'];
      step.description = 'Updating your Kalabox dependencies...';
      step.all.darwin = function(state, done) {
        kbox.util.npm.updateKalabox(function(err) {
          if (err) {
            done(err);
          }
          else {
            state.log.debug('Updated kalabox deps!');
            done();
          }
        });
      };
      step.all.linux = step.all.darwin;
      step.all.win32 = function(state, done) {
        state.log.info(chalk.yellow('NPM update not yet available on Win'));
        done();
      };
    });

    kbox.install.registerStep(function(step) {
      step.name = 'core-backends';
      step.deps = ['core-auth'];
      step.description = 'Updating your Kalabox backends...';
      step.all = function(state, done) {
        kbox.util.npm.updateBackends(function(err) {
          if (err) {
            done(err);
          }
          else {
            state.log.debug('Updated kalabox backends!');
            done();
          }
        });
      };
    });

    kbox.install.registerStep(function(step) {
      step.name = 'core-image-prepare';
      step.deps = ['core-apps-prepare'];
      step.description = 'Preparing images for updates...';
      step.all = function(state, done) {
        util.prepareImages(state.containers, done);
      };
    });

    kbox.install.registerStep(function(step) {<commit_msg>#395: Remove npm install from provision update<commit_after>'use strict';

var chalk = require('chalk');
var fs = require('fs');
var path = require('path');

module.exports = function(kbox) {

  var util = require('./util.js')(kbox);
  var helpers = kbox.util.helpers;
  var provisioned = kbox.core.deps.lookup('globalConfig').provisioned;

  // Add common steps
  require('./steps/common.js')(kbox, 'install');

  // Run administator commands.
  kbox.install.registerStep(function(step) {
    step.name = 'core-run-admin-commands';
    if (provisioned) {
      step.deps = ['core-auth'];
    }
    if (!provisioned && process.platform === 'win32') {
      // @todo: this should be a core dep
      step.deps.push('engine-docker-provider-profile');
    }
    step.description = 'Running admin install commands...';
    step.all = function(state, done) {
      var adminCommands = state.adminCommands;
      util.runAdminCmds(adminCommands, done);
    };
  });

  if (!provisioned) {
    kbox.install.registerStep(function(step) {
      step.name = 'core-prepare-usr-bin';
      step.description  = 'Preparing /usr/local/bin...';
      step.subscribes = ['core-run-admin-commands'];
      step.deps = ['core-auth'];
      step.all.linux = function(state, done) {
        var owner = [process.env.USER, process.env.USER].join(':');
        state.adminCommands.unshift('chown ' + owner + ' /usr/local/bin');
        if (!fs.existsSync('/usr/local/bin')) {
          state.adminCommands.unshift('mkdir -p /usr/local/bin');
        }
        done();
      };
    });

    kbox.install.registerStep(function(step) {
      step.name = 'core-finish';
      step.description = 'Finishing install...';
      // @todo: need core dep
      step.deps = ['services-kalabox-finalize'];
      step.all = function(state, done) {
        fs.writeFileSync(
          path.join(state.config.sysConfRoot, 'provisioned'),
          'true'
        );
        done();
      };
    });
  }

  if (provisioned) {

    kbox.install.registerStep(function(step) {
      step.name = 'core-backends';
      step.deps = ['core-auth'];
      step.description = 'Updating your Kalabox backends...';
      step.all = function(state, done) {
        kbox.util.npm.updateBackends(function(err) {
          if (err) {
            done(err);
          }
          else {
            state.log.debug('Updated kalabox backends!');
            done();
          }
        });
      };
    });

    kbox.install.registerStep(function(step) {
      step.name = 'core-image-prepare';
      step.deps = ['core-apps-prepare'];
      step.description = 'Preparing images for updates...';
      step.all = function(state, done) {
        util.prepareImages(state.containers, done);
      };
    });

    kbox.install.registerStep(function(step) {
{'fraction_non_alphanumeric': 0.16277947563133344, 'fraction_numerical': 0.001447643557986167, 'mean_word_length': 2.2934322033898304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5606109', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1958, 'n_words': 341}