Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update elliptic to >= 6.6.1 #4272

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Update elliptic to >= 6.6.1 #4272

wants to merge 2 commits into from

Conversation

kev1n-peters
Copy link
Contributor

johnsaigle
johnsaigle previously approved these changes Feb 20, 2025
@kev1n-peters
Copy link
Contributor Author

I ran this script to update all of the elliptic dependencies:

const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

const targetVersion = '^6.6.1';
const targetDependency = 'elliptic';

function updatePackageJson(filePath) {
  const packageJson = JSON.parse(fs.readFileSync(filePath, 'utf8'));

  let updated = false;

  // Update the version of elliptic in dependencies
  if (packageJson.dependencies && packageJson.dependencies[targetDependency]) {
    packageJson.dependencies[targetDependency] = targetVersion;
    updated = true;
  }

  // Update the version of elliptic in devDependencies
  if (packageJson.devDependencies && packageJson.devDependencies[targetDependency]) {
    packageJson.devDependencies[targetDependency] = targetVersion;
    updated = true;
  }

  // Add or update elliptic in overrides
  if (!packageJson.overrides) {
    packageJson.overrides = {};
  }
  if (packageJson.overrides[targetDependency] !== targetVersion) {
    packageJson.overrides[targetDependency] = targetVersion;
    updated = true;
  }

  if (updated) {
    fs.writeFileSync(filePath, JSON.stringify(packageJson, null, 2));
    console.log(`Updated ${filePath}`);

    // Run npm install in the directory of the updated package.json
    const dir = path.dirname(filePath);
    console.log(`Running npm install in ${dir}`);
    execSync('npm install', { cwd: dir, stdio: 'inherit' });
  }
}

function findPackageJsonFiles(dir) {
  const files = fs.readdirSync(dir);

  files.forEach((file) => {
    const filePath = path.join(dir, file);
    const stat = fs.statSync(filePath);

    if (stat.isDirectory() && file !== 'node_modules') {
      findPackageJsonFiles(filePath);
    } else if (file === 'package.json') {
      updatePackageJson(filePath);
    }
  });
}

// Start the search from the current directory
findPackageJsonFiles(process.cwd());

Copy link
Contributor

@evan-gray evan-gray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at a glance, the change / approach seem reasonable to me. also noting that many, if not all, of these packages / use cases are non-production and/or controlled inputs

Copy link
Collaborator

@djb15 djb15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat script! Thanks for updating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants