'use strict';
import _0x1c3e3a from 'node:path';
import { existsSync } from 'node:fs';
import { readFile, rename } from 'node:fs/promises';
import { execCommand } from '../tools/exec.js';
import { cliLogSubtitle } from '../../../fd-toolbox/logging/cli-logger.js';
import { ciBuildPackage, nxProjects } from '../constants/paths.js';
import { npmCommands, pnpmFlags } from '../constants/npm-commands.js';
import { getNewUuid } from '../../../fd-toolbox/uuids.js';
import { buildTgzFileName } from './get-build-package-info.js';
import { stringEncodingNames, fileExtensions } from '../../../base-repo/app-constants/internal-system-constants.js';
import { packageJsonPath } from '../constants/job-constants.js';

var __defProp=Object['defineProperty'],__name=(_0x5e53d8,_0x22fcc3)=>__defProp(_0x5e53d8,'name',{'value':_0x22fcc3,'configurable':!![]});async function installLocalSaasKit(){const _0x5a93dd=await readFile(packageJsonPath,stringEncodingNames['utfDash8']),_0xa7cb74=JSON['parse'](_0x5a93dd),_0x5bc401=buildTgzFileName(_0xa7cb74['name'],_0xa7cb74['version']),_0x1fc56b=_0x1c3e3a['join'](ciBuildPackage,_0x5bc401),_0x2606e3=getNewUuid(),_0x33aad4=_0x5bc401['replace'](fileExtensions['tgz'],'-reinstalled-'+_0x2606e3+fileExtensions['tgz']),_0x121500=_0x1c3e3a['join'](ciBuildPackage,_0x33aad4);existsSync(_0x1fc56b)?(cliLogSubtitle('Renaming\x20'+_0x5bc401+'\x20to\x20'+_0x33aad4+'\x20to\x20force\x20pnpm\x20cache\x20invalidation...'),await rename(_0x1fc56b,_0x121500)):cliLogSubtitle('Original\x20TGZ\x20not\x20found\x20at\x20'+_0x1fc56b+'.\x20Trying\x20to\x20use\x20it\x20anyway\x20(or\x20it\x20was\x20already\x20renamed).');const _0x30aa34=existsSync(_0x121500)?_0x121500:_0x1fc56b,_0x3eeac0=_0x1c3e3a['resolve'](_0x30aa34);return cliLogSubtitle('Installing\x20local\x20saas-kit\x20from:\x20'+_0x3eeac0),await execCommand(npmCommands['pnpmAdd']+'\x20'+_0x3eeac0+'\x20'+pnpmFlags['filter']+'\x20'+nxProjects['test']+'\x20'+pnpmFlags['filter']+'\x20'+nxProjects['ranksters']),_0x33aad4;}__name(installLocalSaasKit,'installLocalSaasKit');

export { installLocalSaasKit };
