import { loadToken, createInternalClientContext, third_party_applications_exports } from './chunk-3YWCQTFR.js';
import './chunk-SGKKZASK.js';
import './chunk-Y45LX2LV.js';
import { init_esm_shims } from './chunk-LC652GLE.js';
import { consola } from 'consola';
import { colorize } from 'consola/utils';

// src/commands/site/version/list/versionListCommand.mts
init_esm_shims();
async function versionListCommand({
  foundryUrl,
  application,
  token,
  tokenFile
}) {
  const loadedToken = await loadToken(token, tokenFile);
  const tokenProvider = () => loadedToken;
  const clientCtx = createInternalClientContext(foundryUrl, tokenProvider);
  consola.start("Fetching versions & deployed version");
  const [versions, website] = await Promise.all([third_party_applications_exports.listVersions(clientCtx, application), third_party_applications_exports.getWebsite(clientCtx, application)]);
  if (versions.data.length === 0) {
    consola.info("No site versions found");
    return;
  }
  consola.success("Found versions:");
  const semver = await import('semver');
  const sortedVersions = semver.rsort(versions.data.map((v) => v.version).filter((v) => semver.valid(v)));
  for (const version of sortedVersions) {
    consola.log(`    - ${version}${website?.deployedVersion && version === website?.deployedVersion ? colorize("green", ` (deployed)`) : ""}`);
  }
}

export { versionListCommand as default };
//# sourceMappingURL=versionListCommand-VM3BN7EK.js.map
//# sourceMappingURL=versionListCommand-VM3BN7EK.js.map