import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  migrateToAnyNpmIfNeeded,
  resolveNpmDependencies,
  resolvePackageManager
} from "./chunk-KEFW74AD.js";
import "./chunk-CJWIGDAC.js";
import {
  createLogger
} from "./chunk-KQQQHQ4W.js";
import "./chunk-UF3RDBXA.js";
import {
  createI18nT
} from "./chunk-FTXPALCB.js";
import {
  authenticate
} from "./chunk-C6NTLNAT.js";
import "./chunk-HEANTKSX.js";
import "./chunk-SCQFHY4A.js";
import "./chunk-MYWHJYA3.js";
import "./chunk-6ONWG3JF.js";
import "./chunk-HEKVXBWZ.js";
import "./chunk-K72QYUHN.js";
import "./chunk-WSX7GEXO.js";
import "./chunk-MHV22UIU.js";
import "./chunk-IBOXARGJ.js";
import "./chunk-V2542KTT.js";
import "./chunk-VZ3FZHJK.js";
import "./chunk-OWRWPLVG.js";
import "./chunk-CIOBCAOI.js";
import "./chunk-RPTAJN5Y.js";
import "./chunk-2DKXIL7C.js";
import "./chunk-7ZOEVDW3.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-LFX6WS3B.js";
import "./chunk-XTVDTH5G.js";
import "./chunk-TMZBOD2B.js";
import "./chunk-DR2IE2NL.js";
import "./chunk-JWVFFICN.js";
import "./chunk-YRSNPU5L.js";
import "./chunk-PIOT47FJ.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-SJTW6HNB.js.map