function addImport(contents, migrationData) {
  const importRegExp = createImportRegExp(migrationData.import);
  const importMatch = contents.match(importRegExp);
  if (importMatch) {
    return contents.replace(
      importRegExp,
      importMatch[1] + migrationData.newImport,
    );
  }

  const requireRegExp = createRequireRegExp(migrationData.import);
  const requireMatch = contents.match(requireRegExp);
  if (requireMatch) {
    return contents.replace(
      requireRegExp,
      requireMatch[1] + migrationData.newRequire,
    );
  }

  const blocklyImportMatch = contents.match(createImportRegExp('blockly'));
  if (blocklyImportMatch) {
    const match = blocklyImportMatch;
    return (
      contents.slice(0, match.index + match[0].length) +
      '\n' +
      migrationData.newImport +
      contents.slice(match.index + match[0].length)
    );
  }

  const blocklyRequireMatch = contents.match(createRequireRegExp('blockly'));
  if (blocklyRequireMatch) {
    const match = blocklyRequireMatch;
    return (
      contents.slice(0, match.index + match[0].length) +
      '\n' +
      migrationData.newRequire +
      contents.slice(match.index + match[0].length)
    );
  }

  // Should never happen, but return something so we can keep going if it does.
  return contents;
}
Replaces the any existing import with the new import, or if no import is
found, inserts a new one after the 'blockly' import.
@param {string} contents The string contents of the file to migrate.
@param {MigrationData} migrationData Data defining what to migrate and how.
@returns {string} The migrated contents of the file.