How to use the kyt-utils/logger.task 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 / cli / actions / build.js View on Github external
module.exports = config => {
  logger.start('Starting production build...');

  let serverCompiler;

  const { clientConfig, serverConfig } = buildConfigs(config, 'production');

  // Clean the build directory.
  if (shell.rm('-rf', buildPath).code === 0) {
    shell.mkdir(buildPath);
    logger.task('Cleaned ./build');
  }

  // Copy public folder into build
  if (shell.test('-d', publicSrcPath)) {
    // Create build folder if it doesnt exist
    if (!shell.test('-d', buildPath)) {
      shell.mkdir(buildPath);
    }
    shell.cp('-r', publicSrcPath, publicBuildPath);
    logger.task('Copied /src/public to /build/public');
  } else {
    shell.mkdir('-p', `${buildPath}/public`);
  }

  // Compiles server code using the prod.server config
  const buildServer = () => {
github nytimes / kyt / packages / kyt-cli / cli / actions / setup.js View on Github external
const createEditorconfigLink = () => {
    const editorPath = path.join(__dirname, '../../config/user/.kyt-editorconfig');
    const configPath = path.join(paths.userRootPath, '.editorconfig');

    // Backup existing editor config
    if (shell.test('-f', configPath)) {
      const mvTo = path.join(paths.userRootPath, `editorconfig-${date}.bak`);
      shell.mv(configPath, mvTo);
      logger.info(`Backed up current editor config to ${mvTo}`);
    }

    shell.cp(editorPath, configPath);
    logger.task('Created .editorconfig file');
  };
github nytimes / kyt / packages / kyt-cli / cli / actions / setup.js View on Github external
const createBabelrc = () => {
    // back up existing .babelrc, if it exists
    if (shell.test('-f', paths.userBabelrcPath)) {
      const mvTo = path.join(paths.userRootPath, `.babelrc-${date}.bak`);
      shell.mv(paths.userBabelrcPath, mvTo);
      logger.info(`Backed up current .babelrc to ${mvTo}`);
    }
    shell.cp(`${tmpDir}/.babelrc`, paths.userBabelrcPath);
    logger.task('Created .babelrc');
  };
github nytimes / kyt / packages / kyt-cli / cli / actions / setup.js View on Github external
const createPrototypeFile = () => {
    const starterProto = `${tmpDir}/prototype.js`;
    // No need to copy file if it doesn't exist
    if (!shell.test('-f', starterProto)) return;
    // Backup user's prototype file if they already have one
    if (shell.test('-f', paths.userPrototypePath)) {
      const prototypeBackup = path.join(paths.userRootPath, `prototype-${date}.js.bak`);
      shell.mv(paths.userPrototypePath, prototypeBackup);
      logger.info(`Backed up current prototype file to: ${prototypeBackup}`);
    }
    // Copy the prototype file from the starter-kyt into the users repo
    shell.cp(starterProto, paths.userPrototypePath);
    logger.task('copied prototype.js file into root');
  };
github nytimes / kyt / packages / kyt-core / cli / actions / build.js View on Github external
const { clientConfig, serverConfig } = buildConfigs(config, 'production');

  // Clean the build directory.
  if (shell.rm('-rf', buildPath).code === 0) {
    shell.mkdir(buildPath);
    logger.task('Cleaned ./build');
  }

  // Copy public folder into build
  if (shell.test('-d', publicSrcPath)) {
    // Create build folder if it doesnt exist
    if (!shell.test('-d', buildPath)) {
      shell.mkdir(buildPath);
    }
    shell.cp('-r', publicSrcPath, publicBuildPath);
    logger.task('Copied /src/public to /build/public');
  } else {
    shell.mkdir('-p', `${buildPath}/public`);
  }

  // Compiles server code using the prod.server config
  const buildServer = () => {
    serverCompiler = webpackCompiler(serverConfig, stats => {
      if (stats.hasErrors()) process.exit(1);
      logger.end('Done building');
    });
    serverCompiler.run(() => undefined);
  };

  const clientCompiler = webpackCompiler(clientConfig, stats => {
    if (stats.hasErrors()) process.exit(1);
    logger.info('Assets:');
github nytimes / kyt / packages / kyt-cli / cli / actions / setup.js View on Github external
const updateUserPackageJSON = existingProject => {
    let userPackageJSON;
    // Create a package.json definition if
    // the user doesn't already have one.
    if (shell.test('-f', paths.userPackageJSONPath)) {
      // eslint-disable-next-line global-require,import/no-dynamic-require
      userPackageJSON = require(paths.userPackageJSONPath);
    } else {
      userPackageJSON = fakePackageJson;
      logger.task('Creating a new package.json. You should fill it in.');
    }
    // Clone the package.json so that we have a backup.
    oldPackageJSON = Object.assign({}, userPackageJSON);

    // Add dependencies from starter-kyts
    if (!existingProject) {
      const kytPrefVersion = args.kytVersion || checkStarterKytVersion(userPackageJSON);
      userPackageJSON = updatePackageJSONDependencies(userPackageJSON);
      addKytDependency(userPackageJSON, kytPrefVersion);
    } else {
      // exisitng projects should also have kyt as a devDependency
      addKytDependency(userPackageJSON);
    }
    // Add scripts
    userPackageJSON = addPackageJsonScripts(userPackageJSON);
    fs.writeFileSync(paths.userPackageJSONPath, JSON.stringify(userPackageJSON, null, 2));
github nytimes / kyt / packages / kyt-cli / cli / actions / setup.js View on Github external
packageJson.scripts[commandName] !== npmInitDefaultTestScript
        ) {
          commandName = `kyt:${commandName}`;
        }
      }

      // If the command is from a starter-kyt then
      // we need to copy in the starter-kyt value.
      if (tempScripts.indexOf(command) > -1) {
        packageJson.scripts[commandName] = tempPackageJSON.scripts[command];
      } else {
        packageJson.scripts[commandName] = commandMap[command] || `kyt ${command}`;
      }
    });
    packageJson.scripts['kyt:help'] = 'kyt --help';
    logger.task('Added kyt scripts into your package.json scripts');
    return packageJson;
  };
github nytimes / kyt / packages / kyt-cli / cli / actions / setup.js View on Github external
const cpSrc = () => {
      const tmpSrcPath = path.join(tmpDir, '/src');
      shell.cp('-r', `${tmpSrcPath}`, paths.userRootPath);
      logger.task('Created src directory');
    };
    if (shell.test('-d', paths.srcPath)) {
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 / list.js View on Github external
module.exports = () => {
  logger.start('Listing starter-kyts');
  logger.task('kyt supported starter-kyts: \n');
  Object.keys(starterKyts.supported).forEach((starterName, index) => {
    const li = index + 1;
    printStarter(li, starterKyts.supported[starterName]);
  });
  logger.task('Recommended starter-kyts:\n');
  Object.keys(starterKyts.recommended).forEach((starterName, index) => {
    const li = index + 1;
    printStarter(li, starterKyts.recommended[starterName]);
  });
  logger.end('List complete');
};

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