import*as t from"path";import{cliCommandNames as r}from"../../constants/common.js";import{PUBLIC_STATIC_FOLDER as i}from"../constants/common.js";import{logger as n}from"../tools/notifiers/logger.js";import{blue as f,gray as l}from"../tools/notifiers/helpers/colors.js";import{loadEnvVariables as p}from"./envs/load-env-variables.js";import{copyFolderRecursiveSync as c}from"./fs.js";import{validateInstalledVersion as s}from"./validate-installed-version.js";import{PACKAGE_NAME as E}from"../../config/product-gates.js";import{PORTAL_VERSION as P}from"../version.js";import{setEnv as u}from"../config/env-config.js";function L(o){return o?"true":"false"}function d(o){const e={};o["log-level"]&&(e.REDOCLY_LOG_LEVEL=String(o["log-level"])),e.INSPECT_MODE="inspect"in o?L(o.inspect):"false",o.pathPrefix&&(e.REDOCLY_PREFIX_PATHS=o.pathPrefix),u(e)}function v({contentDir:o,outdir:e}){c(t.join(o,i),t.join(e,i))}async function S(o,e,m){await p(e["project-dir"]);const a=o===r.DEVELOP?"  Previewing with":"Building with";switch(n.logInFooter("product",`${a} ${f(`${E}@${P}`)}`),n.logInFooter("server",`  \u{1F310} Preview URL: ${l("server starting...")}`),o){case r.DEVELOP:case r.BUILD:case r.PREPARE:d(e);break;default:break}await s(),v(m)}export{S as beforeCommand};
