const chalk = {
  yellow: (text) => `\x1b[33m${text}\x1b[0m`,
  green: (text) => `\x1b[32m${text}\x1b[0m`,
  blue: (text) => `\x1b[34m${text}\x1b[0m`,
  // Add more colors as needed
};


const log = async (s, color) => {
  //const { default: chalk } = await import("chalk");
  if (color === undefined) { color = 'blue' }
  var prefix = '* ReExt: '
  console.log(chalk[color](prefix + s) + '   ')
}

function getRegistryUrl(scope) {
  try {
    const { execSync } = require('child_process');
    const registryUrl = execSync(`npm get ${scope}:registry`).toString().trim();
    return registryUrl || 'https://registry.npmjs.org/';
  } catch (error) {
    console.error('Error fetching registry URL:', error);
    return null;
  }
}
module.exports = {
  log: log,
  chalk: chalk,
  getRegistryUrl: getRegistryUrl
};