import { Connection } from "@salesforce/core" ; import ExecuteCommand from "../../command/commandExecutor/ExecuteCommand" ; import SFPLogger , { Logger , LoggerLevel } from "../../logger/SFPLogger" ; import AssignPermissionSets from "../../permsets/AssignPermissionSets" ; export default class PackageInstallationHelpers { static async executeScript ( script , sfdx_package , targetOrg , logger ) { let cmd ; if ( process . platform !== "win32" ) { cmd = `sh -e ${ script } ${ sfdx_package } ${ targetOrg }` ; } else { cmd = `cmd.exe /c ${ script } ${ sfdx_package } ${ targetOrg }` ; } SFPLogger . log ( `Executing command.. ${ cmd }` ) ; let scriptExecutor = new ExecuteCommand ( logger , LoggerLevel . INFO , true ) ; let result = await scriptExecutor . execCommand ( cmd , null ) ; SFPLogger . log ( result , LoggerLevel . INFO , logger ) ; } static async applyPermsets ( permsets , conn , sourceDirectory , logger ) { let assignPermissionSetsImpl = new AssignPermissionSets ( conn , permsets , sourceDirectory , logger ) ; let results = await assignPermissionSetsImpl . exec ( ) ; if ( results . failedAssignments . length > 0 ) throw new Error ( "Unable to assign permsets" ) ; } }