How to use the kyt-utils/logger.info function in kyt-utils

To help you get started, weā€™ve selected a few kyt-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nytimes / kyt / packages / kyt-core / utils / kytConfig.js View on Github external
try {
      logger.log('');
      logger.info(`Using kyt config at ${kytConfigPath}`);
      // eslint-disable-next-line global-require,import/no-dynamic-require
      config = require(kytConfigPath);
    } catch (error) {
      logger.error('Error loading your kyt.config.js:', error);
      process.exit();
    }
  }

  config = merge({}, baseConfig, config);

  if (typeof config.modifyWebpackConfig === 'function') {
    logger.info('What are you doing in your modifyWebpackConfig?');
    logger.info('Let us know: https://github.com/NYTimes/kyt/issues/432');
  }

  // Create default identity functions for modify functions
  ['modifyWebpackConfig', 'modifyJestConfig'].forEach(m => {
    if (typeof config[m] !== 'function') {
      config[m] = c => c;
    }
  });

  const validateURL = (name, userURL) => {
    // Check to see if the url has the
    // required protocol, hostname and port.
    if (!userURL.protocol || !userURL.hostname || !userURL.port) {
      logger.error(`āŒ  Error: ${name} is an invalid url - ${userURL.href}`);
    }
  };
github nytimes / kyt / packages / kyt-core / utils / kytConfig.js View on Github external
if (shell.test('-f', kytConfigPath)) {
    try {
      logger.log('');
      logger.info(`Using kyt config at ${kytConfigPath}`);
      // eslint-disable-next-line global-require,import/no-dynamic-require
      config = require(kytConfigPath);
    } catch (error) {
      logger.error('Error loading your kyt.config.js:', error);
      process.exit();
    }
  }

  config = merge({}, baseConfig, config);

  if (typeof config.modifyWebpackConfig === 'function') {
    logger.info('What are you doing in your modifyWebpackConfig?');
    logger.info('Let us know: https://github.com/NYTimes/kyt/issues/432');
  }

  // Create default identity functions for modify functions
  ['modifyWebpackConfig', 'modifyJestConfig'].forEach(m => {
    if (typeof config[m] !== 'function') {
      config[m] = c => c;
    }
  });

  const validateURL = (name, userURL) => {
    // Check to see if the url has the
    // required protocol, hostname and port.
    if (!userURL.protocol || !userURL.hostname || !userURL.port) {
      logger.error(`āŒ  Error: ${name} is an invalid url - ${userURL.href}`);
    }
github nytimes / kyt / packages / kyt-core / utils / buildConfigs.js View on Github external
// These are the only differences between dev & prod
  if (environment === 'production') {
    clientConfig = prodClientConfig;
    serverConfig = prodServerConfig;
    clientOptions = merge(clientOptions, {
      publicPath: config.productionPublicPath,
      publicDir: 'build/public',
    });
  }

  const serverOptions = merge(clientOptions, { type: 'server' });

  const hasBabelrc = shell.test('-f', userBabelrcPath);
  if (!hasBabelrc) {
    logger.info('No user .babelrc found. Using kyt default babel preset...');
  }

  // Merge options with static webpack configs
  clientConfig = merge.smart(baseConfig(clientOptions), clientConfig(clientOptions));
  serverConfig = merge.smart(baseConfig(serverOptions), serverConfig(serverOptions));

  // Modify via userland config
  try {
    clientConfig = config.modifyWebpackConfig(clone(clientConfig), clientOptions);
    serverConfig = config.modifyWebpackConfig(clone(serverConfig), serverOptions);
  } catch (error) {
    logger.error('Error in your kyt.config.js modifyWebpackConfig():', error);
    process.exit(1);
  }

  if (config.debug) {
github nytimes / kyt / packages / kyt-core / utils / webpackCompiler.js View on Github external
webpackCompiler.hooks.done.tap('kyt', stats => {
    if (stats.hasErrors()) {
      logger.error(`${type} build failed\n`, stats.toString());
      logger.info('See webpack error above');
    } else if (stats.hasWarnings()) {
      logger.warn(`${type} build warnings`, stats.toJson().warnings.join('\n'));
    } else {
      logger.task(`${type} build successful`);
    }

    // Remove the build type that we set in the "before-run" hook.
    delete process.env.KYT_ENV_TYPE;

    // Call the callback on successful build
    if (cb) {
      cb(stats);
    }
  });
github nytimes / kyt / packages / kyt-core / cli / actions / build.js View on Github external
const clientCompiler = webpackCompiler(clientConfig, stats => {
    if (stats.hasErrors()) process.exit(1);
    logger.info('Assets:');
    printAssets(stats, clientConfig);
    if (config.hasServer) {
      buildServer();
    } else {
      logger.end('Done building');
    }
  });
  clientCompiler.run(() => undefined);
github nytimes / kyt / packages / kyt-core / utils / ifPortIsFreeDo.js View on Github external
detect(port, (error, unusedPort) => {
    if (error) {
      logger.error('error attempting to detect port', error);
      process.exit();
    }

    if (port === unusedPort) {
      callback();
    } else {
      logger.error(`port: ${port} is in use.`);
      logger.info('Ports can be configured in kyt.config.js');
      process.exit();
    }
  });
};
github nytimes / kyt / packages / kyt-cli / cli / actions / setup.js View on Github external
const installUserDependencies = () => {
    logger.info('Cleaning node modules and reinstalling. This may take a couple of minutes...');
    shell.rm('-rf', paths.userNodeModulesPath);
    const result = shell.exec(`${ypm} install`);
    if (result.code !== 0) {
      fs.writeFileSync(paths.userPackageJSONPath, JSON.stringify(oldPackageJSON, null, 2));
      logger.error('An error occurred when trying to install node modules', result.stderr);
      logger.task('Restored the original package.json and bailing');
      logger.info('You may need to reinstall your modules');
      bailProcess();
    }
    logger.task('Installed new modules');
  };
github nytimes / kyt / packages / kyt-cli / cli / actions / setup.js View on Github external
const installUserDependencies = () => {
    logger.info('Cleaning node modules and reinstalling. This may take a couple of minutes...');
    shell.rm('-rf', paths.userNodeModulesPath);
    const result = shell.exec(`${ypm} install`);
    if (result.code !== 0) {
      fs.writeFileSync(paths.userPackageJSONPath, JSON.stringify(oldPackageJSON, null, 2));
      logger.error('An error occurred when trying to install node modules', result.stderr);
      logger.task('Restored the original package.json and bailing');
      logger.info('You may need to reinstall your modules');
      bailProcess();
    }
    logger.task('Installed new modules');
  };

kyt-utils

A shared kyt utility library.

Apache-2.0
Latest version published 12 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages