<commit_before>'use strict';

const _ = require('lodash');
const UPDATE_THROTTLE = 5000;

function boot (env, language) {

  function startBoot(ctx, next) {

    console.log('Executing startBoot');

    ctx.runtimeState = 'booting';
    ctx.settings = env.settings;
    ctx.bus = require('../bus')(env.settings, ctx);
    ctx.adminnotifies = require('../adminnotifies')(ctx);
    if (env.notifies) {
      for (var i = 0; i < env.notifies.length; i++) {
        ctx.adminnotifies.addNotify(env.notifies[i]);
      }
    }
    next();
  }

  //////////////////////////////////////////////////
  // Check Node version.
  // Latest Node LTS releases are recommended and supported.
  // Current Node releases MAY work, but are not recommended. Will be tested in CI
  // Older Node versions or Node versions with known security issues will not work.
  ///////////////////////////////////////////////////
  function checkNodeVersion (ctx, next) {

    console.log('Executing checkNodeVersion');

    var semver = require('semver');
    var nodeVersion = process.version;

    const isLTS = process.release.lts ? true : false;

    if (isLTS && (semver.satisfies(nodeVersion, '^16.0.0') || semver.satisfies(nodeVersion, '^14.0.0'))) {
      //Latest Node 14 LTS and Node 16 LTS are recommended and supported.
      //Require at least Node 14 without known security issues
      console.debug('Node LTS version ' + nodeVersion + ' is supported');
      next();
      return;
    }

    console.log( 'ERROR: Node version ' + nodeVersion + ' is not supported. Please use a secure LTS version or upgrade your Node');
    process.exit(1);

  }

  function checkEnv (ctx, next) {

    console.log('Executing checkEnv');

    ctx.language = language;
    if (env.err.length > 0) {
      ctx.bootErrors = ctx.bootErrors || [ ];
      ctx.bootErrors.push({'desc': 'ENV Error', err: env.err});
    }
    next();
  }

  function hasBootErrors(ctx) {
    return ctx.bootErrors && ctx.bootErrors.length > 0;
  }

  function augmentSettings (ctx, next) {

    console.log('Executing augmentSettings');

    var configURL = env.IMPORT_CONFIG || null;
    var url = require('url');
    var href = null;
    try {
      href = url.parse(configURL).href;
    } catch (e) {
      console.error('Parsing config URL from IMPORT_CONFIG failed');
    }<commit_msg>fix don't print error about IMPORT_CONFIG if not defined<commit_after>'use strict';

const _ = require('lodash');
const UPDATE_THROTTLE = 5000;

function boot (env, language) {

  function startBoot(ctx, next) {

    console.log('Executing startBoot');

    ctx.runtimeState = 'booting';
    ctx.settings = env.settings;
    ctx.bus = require('../bus')(env.settings, ctx);
    ctx.adminnotifies = require('../adminnotifies')(ctx);
    if (env.notifies) {
      for (var i = 0; i < env.notifies.length; i++) {
        ctx.adminnotifies.addNotify(env.notifies[i]);
      }
    }
    next();
  }

  //////////////////////////////////////////////////
  // Check Node version.
  // Latest Node LTS releases are recommended and supported.
  // Current Node releases MAY work, but are not recommended. Will be tested in CI
  // Older Node versions or Node versions with known security issues will not work.
  ///////////////////////////////////////////////////
  function checkNodeVersion (ctx, next) {

    console.log('Executing checkNodeVersion');

    var semver = require('semver');
    var nodeVersion = process.version;

    const isLTS = process.release.lts ? true : false;

    if (isLTS && (semver.satisfies(nodeVersion, '^16.0.0') || semver.satisfies(nodeVersion, '^14.0.0'))) {
      //Latest Node 14 LTS and Node 16 LTS are recommended and supported.
      //Require at least Node 14 without known security issues
      console.debug('Node LTS version ' + nodeVersion + ' is supported');
      next();
      return;
    }

    console.log( 'ERROR: Node version ' + nodeVersion + ' is not supported. Please use a secure LTS version or upgrade your Node');
    process.exit(1);

  }

  function checkEnv (ctx, next) {

    console.log('Executing checkEnv');

    ctx.language = language;
    if (env.err.length > 0) {
      ctx.bootErrors = ctx.bootErrors || [ ];
      ctx.bootErrors.push({'desc': 'ENV Error', err: env.err});
    }
    next();
  }

  function hasBootErrors(ctx) {
    return ctx.bootErrors && ctx.bootErrors.length > 0;
  }

  function augmentSettings (ctx, next) {

    console.log('Executing augmentSettings');

    var configURL = env.IMPORT_CONFIG || null;
    var url = require('url');
    var href = null;

    if (configURL) {
      try {
        href = url.parse(configURL).href;
      } catch (e) {
        console.error('Parsing config URL from IMPORT_CONFIG failed');
      }
    }

{'fraction_non_alphanumeric': 0.16694736842105262, 'fraction_numerical': 0.009263157894736843, 'mean_word_length': 2.4704163623082542, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4191453', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1383, 'n_words': 404}