<commit_before>/* eslint-disable import/no-dynamic-require, no-console */
const chalk = require('chalk');
const path = require('path');
const fetch = require('isomorphic-fetch');
const simpleGit = require('simple-git');

const cwd = process.cwd();
const git = simpleGit(cwd);

const { version } = require(path.resolve(cwd, 'package.json'));

function exitProcess(code = 1) {
  console.log(''); // Keep an empty line here to make looks good~
  process.exit(code);
}

async function checkVersion() {
  try {
    const { versions } = await fetch('http://registry.npmjs.org/antd').then((res) => res.json());
    if (version in versions) {
      console.log(chalk.yellow('😈 Current version already exists. Forget update package.json?'));
      console.log(chalk.cyan(' => Current:'), version);
      exitProcess();
    }
  } catch (error) {
    console.log(chalk.red('🚨 Check version failed. Skip...'));
  }
}

async function checkBranch({ current }) {
  if (
    version.includes('-alpha.') ||
    version.includes('-beta.') ||
    version.includes('-rc.') ||
    version.includes('-experimental.')
  ) {
    console.log(chalk.cyan('😃 Alpha version. Skip branch check.'));
  } else if (current !== 'master' && current !== '4.0-prepare') {
    console.log(chalk.yellow('🤔 You are not in the master branch!'));
    exitProcess();
  }
}

async function checkCommit({ files }) {
  if (files.length) {
    console.log(chalk.yellow('🙄 You forgot something to commit.'));
    files.forEach(({ path: filePath, working_dir: mark }) => {
      console.log(' -', chalk.red(mark), filePath);
    });
    exitProcess();
  }
}

async function checkRemote() {
  const { remote } = await git.fetch('origin', 'master');
  if (remote?.indexOf('ant-design/ant-design') === -1) {
    console.log(
      chalk.yellow('😓 Your remote origin is not ant-design/ant-design, did you fork it?'),
    );
    exitProcess();
  }
}

async function checkAll() {
  const status = await git.status();

  await checkVersion();<commit_msg>chore: adjust script with check remote<commit_after>/* eslint-disable import/no-dynamic-require, no-console */
const chalk = require('chalk');
const path = require('path');
const fetch = require('isomorphic-fetch');
const simpleGit = require('simple-git');

const cwd = process.cwd();
const git = simpleGit(cwd);

const { version } = require(path.resolve(cwd, 'package.json'));

function exitProcess(code = 1) {
  console.log(''); // Keep an empty line here to make looks good~
  process.exit(code);
}

async function checkVersion() {
  try {
    const { versions } = await fetch('http://registry.npmjs.org/antd').then((res) => res.json());
    if (version in versions) {
      console.log(chalk.yellow('😈 Current version already exists. Forget update package.json?'));
      console.log(chalk.cyan(' => Current:'), version);
      exitProcess();
    }
  } catch (error) {
    console.log(chalk.red('🚨 Check version failed. Skip...'));
  }
}

async function checkBranch({ current }) {
  if (
    version.includes('-alpha.') ||
    version.includes('-beta.') ||
    version.includes('-rc.') ||
    version.includes('-experimental.')
  ) {
    console.log(chalk.cyan('😃 Alpha version. Skip branch check.'));
  } else if (current !== 'master' && current !== '4.0-prepare') {
    console.log(chalk.yellow('🤔 You are not in the master branch!'));
    exitProcess();
  }
}

async function checkCommit({ files }) {
  if (files.length) {
    console.log(chalk.yellow('🙄 You forgot something to commit.'));
    files.forEach(({ path: filePath, working_dir: mark }) => {
      console.log(' -', chalk.red(mark), filePath);
    });
    exitProcess();
  }
}

async function checkRemote() {
  try {
    const { remote } = await git.fetch('origin', 'master');
    if (remote?.indexOf('ant-design/ant-design') === -1) {
      console.log(
        chalk.yellow('😓 Your remote origin is not ant-design/ant-design, did you fork it?'),
      );
      exitProcess();
    }
  } catch (error) {
    console.log(chalk.red('🚨 Check remote failed. Skip...'));
  }
}

async function checkAll() {
  const status = await git.status();

  await checkVersion();
{'fraction_non_alphanumeric': 0.18091547590215548, 'fraction_numerical': 0.0019375151368370065, 'mean_word_length': 3.489130434782609, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1272140', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1309, 'n_words': 324}