<commit_before>/*******************************
         Install Task
*******************************/

/*
   Install tasks

   For more notes

   * Runs automatically after npm update (hooks)
   * (NPM) Install - Will ask for where to put semantic (outside pm folder)
   * (NPM) Upgrade - Will look for semantic install, copy over files and update if new version
   * Standard installer runs asking for paths to site files etc

*/

var
  gulp           = require('gulp'),

  // node dependencies
  console        = require('better-console'),
  extend         = require('extend'),
  fs             = require('fs'),
  mkdirp         = require('mkdirp'),
  path           = require('path'),

  // gulp dependencies
  chmod          = require('gulp-chmod'),
  del            = require('del'),
  jsonEditor     = require('gulp-json-editor'),
  plumber        = require('gulp-plumber'),
  prompt         = require('gulp-prompt'),
  rename         = require('gulp-rename'),
  replace        = require('gulp-replace'),
  requireDotFile = require('require-dot-file'),
  wrench         = require('wrench'),

  // user config
  config         = require('./config/user'),

  // install config
  install        = require('./config/project/install'),

  // release config (name/title/etc)
  release        = require('./config/project/release'),

  // shorthand
  questions      = install.questions,
  files          = install.files,
  folders        = install.folders,
  regExp         = install.regExp,
  settings       = install.settings,
  source         = install.source
;

// Export install task
module.exports = function () {

  var
    currentConfig = requireDotFile('semantic.json'),
    manager       = install.getPackageManager(),
    rootQuestions = questions.root
  ;

  console.clear();

  /* use to debug NPM install from standard git clone
  manager = {
    name : 'NPM',
    root : path.normalize(__dirname + '/../')
  };
  */

  /*--------------
      PM Config
  ---------------*/

  /* Don't do end user config if SUI is a sub-module */
  if( install.isSubModule() ) {
    console.info('SUI is a sub-module, skipping end-user install');
    return;
  }

  // run update scripts if semantic.json exists
  if(currentConfig && manager.name === 'NPM') {

    var
      updateFolder = manager.root,
      updatePaths  = {
        config      : path.join(updateFolder, files.config),
        definition  : path.join(updateFolder, currentConfig.base, currentConfig.paths.source.definitions),
        site        : path.join(updateFolder, currentConfig.base, currentConfig.paths.source.site),
        theme       : path.join(updateFolder, currentConfig.base, currentConfig.paths.source.themes)
      }
    ;

    // duck-type if there is a project installed
    if( fs.existsSync(updatePaths.definition) ) {

      // perform update if new version
      if(currentConfig.version !== release.version) {

        console.log('Updating Semantic UI from ' + currentConfig.version + ' to ' + release.version);

        console.info('Updating ui definitions...');
        wrench.copyDirSyncRecursive(source.definitions, updatePaths.definition, settings.wrench.update);

        console.info('Updating default theme...');<commit_msg>Fix update paths<commit_after>/*******************************
         Install Task
*******************************/

/*
   Install tasks

   For more notes

   * Runs automatically after npm update (hooks)
   * (NPM) Install - Will ask for where to put semantic (outside pm folder)
   * (NPM) Upgrade - Will look for semantic install, copy over files and update if new version
   * Standard installer runs asking for paths to site files etc

*/

var
  gulp           = require('gulp'),

  // node dependencies
  console        = require('better-console'),
  extend         = require('extend'),
  fs             = require('fs'),
  mkdirp         = require('mkdirp'),
  path           = require('path'),

  // gulp dependencies
  chmod          = require('gulp-chmod'),
  del            = require('del'),
  jsonEditor     = require('gulp-json-editor'),
  plumber        = require('gulp-plumber'),
  prompt         = require('gulp-prompt'),
  rename         = require('gulp-rename'),
  replace        = require('gulp-replace'),
  requireDotFile = require('require-dot-file'),
  wrench         = require('wrench'),

  // user config
  config         = require('./config/user'),

  // install config
  install        = require('./config/project/install'),

  // release config (name/title/etc)
  release        = require('./config/project/release'),

  // shorthand
  questions      = install.questions,
  files          = install.files,
  folders        = install.folders,
  regExp         = install.regExp,
  settings       = install.settings,
  source         = install.source
;

// Export install task
module.exports = function () {

  var
    currentConfig = requireDotFile('semantic.json'),
    manager       = install.getPackageManager(),
    rootQuestions = questions.root
  ;

  console.clear();

  /* use to debug NPM install from standard git clone
  manager = {
    name : 'NPM',
    root : path.normalize(__dirname + '/../')
  };
  */

  /*--------------
      PM Config
  ---------------*/

  /* Don't do end user config if SUI is a sub-module */
  if( install.isSubModule() ) {
    console.info('SUI is a sub-module, skipping end-user install');
    return;
  }

  // run update scripts if semantic.json exists
  if(currentConfig && manager.name === 'NPM') {

    var
      updateFolder = manager.root,
      updatePaths  = {
        config      : path.join(manager.root, files.config),
        definition  : path.join(updateFolder, currentConfig.paths.source.definitions),
        site        : path.join(updateFolder, currentConfig.paths.source.site),
        theme       : path.join(updateFolder, currentConfig.paths.source.themes)
      }
    ;

    // duck-type if there is a project installed
    if( fs.existsSync(updatePaths.definition) ) {

      // perform update if new version
      if(currentConfig.version !== release.version) {

        console.log('Updating Semantic UI from ' + currentConfig.version + ' to ' + release.version);

        console.info('Updating ui definitions...');
        wrench.copyDirSyncRecursive(source.definitions, updatePaths.definition, settings.wrench.update);

        console.info('Updating default theme...');
{'fraction_non_alphanumeric': 0.14786418400876233, 'fraction_numerical': 0.0, 'mean_word_length': 2.382010582010582, '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': '7414348', 'n_tokens_mistral': 1795, 'n_tokens_neox': 1724, 'n_words': 440}