const transform = (fileInfo, api, options) => {
  if (fileInfo.path.endsWith('package.json')) {
    const packageJson = JSON.parse(fileInfo.source);

    if (
      packageJson.dependencies &&
      packageJson.dependencies['@sentry/nextjs']
    ) {
      delete packageJson.dependencies['@sentry/nextjs'];
    }

    if (
      packageJson.devDependencies &&
      packageJson.devDependencies['@sentry/nextjs']
    ) {
      delete packageJson.devDependencies['@sentry/nextjs'];
    }

    return JSON.stringify(packageJson, null, 2);
  }

  return fileInfo.source;
};

module.exports = transform;
