'use strict';
import { execSyncCommand } from '../tools/exec.js';
import { cliLogSeparator, cliLogSubtitle, cliLogError } from '../../../fd-toolbox/logging/cli-logger.js';
import { environmentVariables } from '../constants/ci-constants.js';
import { folders, buildPaths } from '../../../base-repo/app-constants/project-paths.js';
import { systemCommands } from '../constants/npm-commands.js';
import { getStringEnvSetting } from '../../../fd-toolbox/infra/env-functions.js';
import { getSubmoduleDir } from '../tools/get-submodule-dir.js';

var __defProp=Object['defineProperty'],__name=(_0x501633,_0x3845ea)=>__defProp(_0x501633,'name',{'value':_0x3845ea,'configurable':!![]});async function exportBuildToSubmodule(){if(getSubmoduleDir()!==getStringEnvSetting(environmentVariables['mainRepoName'])){cliLogSeparator(),cliLogSubtitle('[2.7]\x20Copying\x20build\x20directory\x20to\x20submodule...');try{execSyncCommand('mkdir\x20-p\x20../'+getSubmoduleDir()+'/'+folders['generated']+'/'+folders['build']),await Promise['all']([execSyncCommand(buildCopyToSubmoduleCommand(buildPaths['buildPackage'])),execSyncCommand(buildCopyToSubmoduleCommand(buildPaths['buildCliPackage']))]),cliLogSubtitle('[2.7]\x20Build\x20directory\x20copied\x20to\x20submodule.');}catch(_0x23107a){cliLogError('[2.7]\x20Failed\x20to\x20copy\x20build\x20directory:\x20'+_0x23107a),process['exit'](-0x641*-0x3+0x199b+-0x2c5d);}}}__name(exportBuildToSubmodule,'exportBuildToSubmodule');async function importBuildFromSubmodule(){if(getSubmoduleDir()!==getStringEnvSetting(environmentVariables['mainRepoName'])){cliLogSeparator(),cliLogSubtitle('[2.8]\x20Returning\x20build\x20directory\x20to\x20main\x20repo...');try{execSyncCommand('mkdir\x20-p\x20./'+folders['generated']+'/'+folders['build']),await Promise['all']([execSyncCommand(buildCopyToTargetCommand(buildPaths['buildPackage'])),execSyncCommand(buildCopyToTargetCommand(buildPaths['buildCliPackage']))]),cliLogSubtitle('[2.8]\x20Build\x20directory\x20returned\x20to\x20main\x20repo.');}catch(_0x33a1aa){cliLogError('[2.8]\x20Failed\x20to\x20return\x20build\x20directory:\x20'+_0x33a1aa),process['exit'](-0x2650+-0xff+0x2750);}}}__name(importBuildFromSubmodule,'importBuildFromSubmodule');function buildCopyToTargetCommand(_0x417311){return systemCommands['copyRecursive']+'\x20../'+getSubmoduleDir()+'/'+_0x417311+'\x20./'+_0x417311;}__name(buildCopyToTargetCommand,'buildCopyToTargetCommand');function buildCopyToSubmoduleCommand(_0x10ab7f){return systemCommands['copyRecursive']+'\x20./'+_0x10ab7f+'\x20../'+getSubmoduleDir()+'/'+_0x10ab7f;}__name(buildCopyToSubmoduleCommand,'buildCopyToSubmoduleCommand');

export { exportBuildToSubmodule, importBuildFromSubmodule };
