<commit_before>const replace = require('replace-in-file');

const fs = require('fs')

const CWD = process.cwd()
const siteConfig = require(`${CWD}/siteConfig.js`);
const docsDir = `${CWD}/build/${siteConfig.projectName}/docs`


function getVersions() {
  try {
    return JSON.parse(require('fs').readFileSync(`${CWD}/versions.json`, 'utf8'));
  } catch (error) {
    //console.error(error)
    console.error('no versions found defaulting to 2.1.0')
  }
  return ['2.1.0']
}

function downloadPageUrl() {
  return `${siteConfig.baseUrl}download`
}

function binaryReleaseUrl(version) {
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/apache-pulsar-${version}-bin.tar.gz`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/apache-pulsar-${version}-bin.tar.gz`
  }
}

function connectorReleaseUrl(version) {
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/apache-pulsar-io-connectors-${version}-bin.tar.gz`
  } else if (version >= '2.3.0') {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/connectors`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/apache-pulsar-io-connectors-${version}-bin.tar.gz`
  }
}

function offloaderReleaseUrl(version) {
  return `https://archive.apache.org/dist/pulsar/pulsar-${version}/apache-pulsar-offloaders-${version}-bin.tar.gz`
}

function prestoPulsarReleaseUrl(version) {
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/pulsar-presto-connector-${version}.tar.gz`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/pulsar-presto-connector-${version}.tar.gz`
  }
}

function rpmReleaseUrl(version, type) {
  rpmVersion = version.replace('incubating', '1_incubating');
  if (version.includes('incubating')) {
    return `https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=incubator/pulsar/pulsar-${version}/RPMS/apache-pulsar-client${type}-${rpmVersion}.x86_64.rpm`
  } else {
    return `https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-${version}/RPMS/apache-pulsar-client${type}-${rpmVersion}-1.x86_64.rpm`
  }
}

function debReleaseUrl(version, type) {
  if (version.includes('incubating')) {
    return `https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=incubator/pulsar/pulsar-${version}/DEB/apache-pulsar-client${type}.deb`
  } else {
    return `https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-${version}/DEB/apache-pulsar-client${type}.deb`
  }
}

function rpmDistUrl(version, type) {
  rpmVersion = version.replace('incubating', '1_incubating');
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/RPMS/apache-pulsar-client${type}-${rpmVersion}.x86_64.rpm`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/RPMS/apache-pulsar-client${type}-${rpmVersion}-1.x86_64.rpm`
  }
}

function debDistUrl(version, type) {
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/DEB/apache-pulsar-client${type}.deb`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/DEB/apache-pulsar-client${type}.deb`
  }
}

function clientVersionUrl(version, type) {
  var versions = version.split('.')
  var majorVersion = parseInt(versions[0])
  var minorVersion = parseInt(versions[1])
  if (majorVersion === 2 && minorVersion < 5) {
    return `/api/` + type + `/` + version;
  } else if (majorVersion === 2 && minorVersion >= 5) {
    return `/api/` + type + `/` + version + `-SNAPSHOT`
  }
}

function doReplace(options) {
  replace(options)
    .then(changes => {
      if (options.dry) {
        console.log('Modified files:');
        console.log(changes.join('\n'))
      }
    })
    .catch(error => {
      console.error('Error occurred:', error);
    });
}


const versions = getVersions();

const latestVersion = versions[0];
const latestVersionWithoutIncubating = latestVersion.replace('-incubating', '');<commit_msg>Fixed client api error link (#6904)<commit_after>const replace = require('replace-in-file');

const fs = require('fs')

const CWD = process.cwd()
const siteConfig = require(`${CWD}/siteConfig.js`);
const docsDir = `${CWD}/build/${siteConfig.projectName}/docs`


function getVersions() {
  try {
    return JSON.parse(require('fs').readFileSync(`${CWD}/versions.json`, 'utf8'));
  } catch (error) {
    //console.error(error)
    console.error('no versions found defaulting to 2.1.0')
  }
  return ['2.1.0']
}

function downloadPageUrl() {
  return `${siteConfig.baseUrl}download`
}

function binaryReleaseUrl(version) {
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/apache-pulsar-${version}-bin.tar.gz`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/apache-pulsar-${version}-bin.tar.gz`
  }
}

function connectorReleaseUrl(version) {
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/apache-pulsar-io-connectors-${version}-bin.tar.gz`
  } else if (version >= '2.3.0') {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/connectors`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/apache-pulsar-io-connectors-${version}-bin.tar.gz`
  }
}

function offloaderReleaseUrl(version) {
  return `https://archive.apache.org/dist/pulsar/pulsar-${version}/apache-pulsar-offloaders-${version}-bin.tar.gz`
}

function prestoPulsarReleaseUrl(version) {
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/pulsar-presto-connector-${version}.tar.gz`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/pulsar-presto-connector-${version}.tar.gz`
  }
}

function rpmReleaseUrl(version, type) {
  rpmVersion = version.replace('incubating', '1_incubating');
  if (version.includes('incubating')) {
    return `https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=incubator/pulsar/pulsar-${version}/RPMS/apache-pulsar-client${type}-${rpmVersion}.x86_64.rpm`
  } else {
    return `https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-${version}/RPMS/apache-pulsar-client${type}-${rpmVersion}-1.x86_64.rpm`
  }
}

function debReleaseUrl(version, type) {
  if (version.includes('incubating')) {
    return `https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=incubator/pulsar/pulsar-${version}/DEB/apache-pulsar-client${type}.deb`
  } else {
    return `https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-${version}/DEB/apache-pulsar-client${type}.deb`
  }
}

function rpmDistUrl(version, type) {
  rpmVersion = version.replace('incubating', '1_incubating');
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/RPMS/apache-pulsar-client${type}-${rpmVersion}.x86_64.rpm`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/RPMS/apache-pulsar-client${type}-${rpmVersion}-1.x86_64.rpm`
  }
}

function debDistUrl(version, type) {
  if (version.includes('incubating')) {
    return `https://archive.apache.org/dist/incubator/pulsar/pulsar-${version}/DEB/apache-pulsar-client${type}.deb`
  } else {
    return `https://archive.apache.org/dist/pulsar/pulsar-${version}/DEB/apache-pulsar-client${type}.deb`
  }
}

function clientVersionUrl(version, type) {
  var versions = version.split('.')
  var majorVersion = parseInt(versions[0])
  var minorVersion = parseInt(versions[1])
  if (majorVersion === 2 && minorVersion < 5) {
    return `/api/` + type + `/` + version;
  } else if (majorVersion >= 2 && minorVersion >= 5) {
    return `/api/` + type + `/` + majorVersion + `.` + minorVersion + `.0` + `-SNAPSHOT`
  }
}

function doReplace(options) {
  replace(options)
    .then(changes => {
      if (options.dry) {
        console.log('Modified files:');
        console.log(changes.join('\n'))
      }
    })
    .catch(error => {
      console.error('Error occurred:', error);
    });
}


const versions = getVersions();

const latestVersion = versions[0];
const latestVersionWithoutIncubating = latestVersion.replace('-incubating', '');
{'fraction_non_alphanumeric': 0.18535283194057567, 'fraction_numerical': 0.009168987929433612, 'mean_word_length': 4.42632241813602, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 32, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2209384', 'n_tokens_mistral': 3131, 'n_tokens_neox': 3070, 'n_words': 353}