import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  migrateToAnyNpmIfNeeded,
  resolveNpmDependencies,
  resolvePackageManager
} from "./chunk-NWTPCDEK.js";
import {
  createLogger
} from "./chunk-YKAYM32Q.js";
import "./chunk-KB3GWH37.js";
import "./chunk-HTRGINHM.js";
import {
  createI18nT
} from "./chunk-PPRKUU25.js";
import "./chunk-HEANTKSX.js";
import "./chunk-MYWHJYA3.js";
import "./chunk-4BLGYECY.js";
import {
  authenticate
} from "./chunk-II4C4GML.js";
import "./chunk-O6HC4AYN.js";
import "./chunk-3QMRQKKR.js";
import "./chunk-RF4NA2OH.js";
import "./chunk-NMCF7XG5.js";
import "./chunk-MHV22UIU.js";
import "./chunk-VC5Q2AI5.js";
import "./chunk-HWT3LUJJ.js";
import "./chunk-TOBTRYZF.js";
import "./chunk-7WVNO7VU.js";
import "./chunk-RPTAJN5Y.js";
import "./chunk-YL4347CI.js";
import "./chunk-TODKQSCF.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-SVUXJRFD.js";
import "./chunk-YT5BPQDJ.js";
import "./chunk-LU3R3EBR.js";
import "./chunk-XZUGLEBK.js";
import "./chunk-VASURI4S.js";
import "./chunk-SDLCFZRL.js";
import "./chunk-MTT3QXBC.js";
import {
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-site-old/src/install/index.ts
init_esm_shims();

// ../cli-site-old/src/install/install.ts
init_esm_shims();
async function install(model, { biLogger, errorReporter }, options, initialPackageName) {
  const authState = await authenticate({
    metaSiteId: model.metaSiteId,
    biLogger,
    errorReporter
  });
  const t = createI18nT();
  const logger = createLogger({ t });
  const packageName = initialPackageName?.trim() ?? null;
  await migrateToAnyNpmIfNeeded(model.projectFolder, logger);
  const logInstalled = packageName ? logger.logDependencyInstalling(packageName) : logger.logAllDependenciesInstalling();
  try {
    const packageManager = await resolvePackageManager(
      model.projectFolder,
      options
    );
    if (packageName) {
      await packageManager.runInstallPackage(model.projectFolder, packageName);
    } else {
      await packageManager.runInstall(model.projectFolder);
    }
    await resolveNpmDependencies(model.projectFolder, { authState });
    logInstalled.success();
  } catch (error) {
    logInstalled.fail();
    throw error;
  }
}
export {
  install
};
//# sourceMappingURL=install-6EZS3HL2.js.map