<commit_before>#!/usr/bin/env node

const chalk = require('chalk');
const fs = require('fs-extra');
const bent = require('bent');
const path = require('path');
const emptyDir = require('empty-dir');
const validatePackageName = require('validate-npm-package-name');
const kopy = require('kopy');
const dedent = require('dedent');
const detectYarn = require('../lib/detectYarn');
const prettierWrite = require('../lib/runPrettier').write;
const configure = require('../lib/configure');
const install = require('../lib/install');
const { getMissingHosts } = require('../lib/hosts');
const { getSuggestedScript } = require('../lib/suggestScript');

const getFileContent = bent('string');

const args = require('../config/args');

(async () => {
  const projectName = args.argv[0];

  const usage = () => {
    console.log('Usage:');

    console.log(
      `  ${chalk.cyan('sku init')} ${chalk.green(
        '<project-directory>',
      )} [--verbose]`,
    );
    console.log();
    console.log('For example:');
    console.log(`  ${chalk.cyan('sku init')} ${chalk.green('my-seek-ui')}`);
    process.exit(1);
  };

  if (args.argv.indexOf('--help') >= 0) {
    usage();
    process.exit(0);
  }

  if (!projectName) {
    usage();
    process.exit(1);
  }

  const verbose = args.argv.indexOf('--verbose') >= 0;

  const root = path.resolve(projectName);
  const appName = path.basename(root);

  const reservedNames = [
    'react',
    'react-dom',
    'sku',
    'braid-design-system',
  ].sort();

  const {
    validForNewPackages,
    errors = [],
    warnings = [],
  } = validatePackageName(appName);

  if (!validForNewPackages) {
    console.error(dedent`
    Could not create a project called ${chalk.red(`"${appName}"`)} \
    because of npm naming restrictions:
  `);

    const results = [...errors, ...warnings];
    results.forEach(result => console.error(chalk.red(`  *  ${result}`)));

    process.exit(1);
  }

  if (reservedNames.indexOf(appName) >= 0) {
    console.error(
      chalk.red(dedent`
      We cannot create a project called \<commit_msg>fix(init): Stop config files being generated in parent directory (#446)<commit_after>#!/usr/bin/env node

const chalk = require('chalk');
const fs = require('fs-extra');
const bent = require('bent');
const path = require('path');
const emptyDir = require('empty-dir');
const validatePackageName = require('validate-npm-package-name');
const kopy = require('kopy');
const dedent = require('dedent');
const { setCwd } = require('../lib/cwd');
const detectYarn = require('../lib/detectYarn');
const prettierWrite = require('../lib/runPrettier').write;
const configure = require('../lib/configure');
const install = require('../lib/install');
const { getMissingHosts } = require('../lib/hosts');
const { getSuggestedScript } = require('../lib/suggestScript');

const getFileContent = bent('string');

const args = require('../config/args');

(async () => {
  const projectName = args.argv[0];

  const usage = () => {
    console.log('Usage:');

    console.log(
      `  ${chalk.cyan('sku init')} ${chalk.green(
        '<project-directory>',
      )} [--verbose]`,
    );
    console.log();
    console.log('For example:');
    console.log(`  ${chalk.cyan('sku init')} ${chalk.green('my-seek-ui')}`);
    process.exit(1);
  };

  if (args.argv.indexOf('--help') >= 0) {
    usage();
    process.exit(0);
  }

  if (!projectName) {
    usage();
    process.exit(1);
  }

  const verbose = args.argv.indexOf('--verbose') >= 0;

  const root = path.resolve(projectName);
  setCwd(root);

  const appName = path.basename(root);

  const reservedNames = [
    'react',
    'react-dom',
    'sku',
    'braid-design-system',
  ].sort();

  const {
    validForNewPackages,
    errors = [],
    warnings = [],
  } = validatePackageName(appName);

  if (!validForNewPackages) {
    console.error(dedent`
    Could not create a project called ${chalk.red(`"${appName}"`)} \
    because of npm naming restrictions:
  `);

    const results = [...errors, ...warnings];
    results.forEach(result => console.error(chalk.red(`  *  ${result}`)));

    process.exit(1);
  }

  if (reservedNames.indexOf(appName) >= 0) {
    console.error(
      chalk.red(dedent`
      We cannot create a project called \
{'fraction_non_alphanumeric': 0.1942682640357059, 'fraction_numerical': 0.004463237021376556, 'mean_word_length': 3.4261954261954264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '4844168', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1376, 'n_words': 287}