scripts/publish.js
function changeVersion() {
  log.info('Updating version number...');

  const packageJson = path.join(__dirname, '../components/package.json');
  const currentVersion = fs.readFileSync(packageJson, 'utf-8').match(/"version": "([0-9.]+)"/)[ 1 ];

  let versionNumberValid = false;
  let version;

  function checkVersionNumber(cur, next) {
    // Must be numbers and dots.
    if (!/^[0-9][0-9.]{1,10}[0-9](\-\w+)*$/.test(next)) { return false; }

    const curArr = cur.split('.');
    const nextArr = next.split('.');
    const length = curArr.length;

    if (nextArr.length !== nextArr.length) {
      return false;
    }
    
    for (let i = 0; i < length; i++) {
      if (curArr[ i ] < nextArr[ i ]) { return true; }
      if (curArr[ i ] > nextArr[ i ]) { return false; }
      if (i === length - 1 && curArr[ i ] === nextArr[ i ]) { return false; }
    }
  }

  while (!versionNumberValid) {
    version = read.question(chalk.bgYellow.black('Please input the new version:') + '  ');
    if (checkVersionNumber(currentVersion, version)) {
      versionNumberValid = true;
      nextVersion = version;
    } else {
      log.error(`Your input ${version} is not after the current version ${currentVersion} or is unvalid. Please check it.`);
    }
  }

  fs.writeFileSync(packageJson,
    fs.readFileSync(packageJson, 'utf-8').replace(/"version": "[0-9.]+"/g, `"version": "${version}"`)
  );

  log.success('Version updated!');
}
function changeVersion() {
  log.info('Updating version number...');

  const packageJson = path.join(__dirname, '../components/package.json');
  const currentVersion = fs.readFileSync(packageJson, 'utf-8').match(/"version": "([0-9.]+)"/)[ 1 ];

  let versionNumberValid = false;
  let version;

  function checkVersionNumber(cur, next) {
    // Must be numbers and dots.
    if (!/^[0-9][0-9.]{1,10}[0-9](\-\w+)*$/.test(next)) { return false; }

    const curArr = cur.split('.');
    const nextArr = next.split('.');
    const length = curArr.length;

    if (nextArr.length !== nextArr.length) {
      return false;
    }
    
    for (let i = 0; i < length; i++) {
      if (curArr[ i ] < nextArr[ i ]) { return true; }
      if (curArr[ i ] > nextArr[ i ]) { return false; }
      if (i === length - 1 && curArr[ i ] === nextArr[ i ]) { return false; }
    }
  }

  while (!versionNumberValid) {
    version = read.question(chalk.bgYellow.black('Please input the new version:') + '  ');
    if (checkVersionNumber(currentVersion, version)) {
      versionNumberValid = true;
      nextVersion = version;
    } else {
      log.error(`Your input ${version} is not after the current version ${currentVersion} or is unvalid. Please check it.`);
    }
  }

  fs.writeFileSync(packageJson,
    fs.readFileSync(packageJson, 'utf-8').replace(/"version": "[0-9.]+"/g, `"version": "${version}"`)
  );

  log.success('Version updated!');
}
publish(); 
Publisher should input the new version number. This script would check if the input is valid.