import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  WIX_LOCK_FILENAME,
  getWixLockFilePath
} from "./chunk-YT5BPQDJ.js";
import {
  outputFile,
  pathExists,
  readFile,
  readPackageJson,
  readPackageJsonContent
} from "./chunk-VASURI4S.js";
import {
  CliError,
  CliErrorCode
} from "./chunk-MTT3QXBC.js";
import {
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-site/src/files/wix.lock.ts
init_esm_shims();
function isWixLockExists(projectFolder) {
  return pathExists(getWixLockFilePath(projectFolder));
}
function readWixLock(projectFolder) {
  return readFile(getWixLockFilePath(projectFolder), "utf-8");
}
async function saveWixLock(projectFolder, content) {
  try {
    await outputFile(getWixLockFilePath(projectFolder), content);
  } catch (e) {
    throw new CliError({
      code: CliErrorCode.FailedToWriteWixLock(),
      cause: e
    });
  }
}

// ../cli-site/src/velo.ts
init_esm_shims();
async function loadProjectRootFiles(projectFolder) {
  if (await isWixLockExists(projectFolder)) {
    const [packageJson, wixLock] = await Promise.all([
      readPackageJsonContent(projectFolder),
      readWixLock(projectFolder)
    ]);
    return [
      { path: "package.json", content: packageJson },
      { path: WIX_LOCK_FILENAME, content: wixLock }
    ];
  }
  return [];
}
async function getProjectDependencies(projectFolder) {
  const packageJson = await readPackageJson(projectFolder);
  return Object.entries(packageJson.dependencies ?? {}).map(
    ([name, version]) => ({ name, version })
  );
}

export {
  saveWixLock,
  loadProjectRootFiles,
  getProjectDependencies
};
//# sourceMappingURL=chunk-I5KDLQBC.js.map