public final class CmdUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
appendMessagesToConsole(String msg) |
static void |
copyAndReplaceFolder(String source,
String destination)
This function deletes the existing destination folder and recursively copy all the sub folder and files from
source to destination file paths.
|
static void |
copyFilesToSources(String sourcePath,
String destinationPath)
Copy files to resources directory.
|
static void |
copyFolder(String source,
String destination)
This function recursively copy all the sub folder and files from source to destination file paths.
|
static void |
createDeploymentConfig(String projectName,
String deploymentConfPath)
Create initial deployment configuration file.
|
static File |
createDirectory(String path,
boolean overwrite)
Creates a new folder if not exists.
|
static File |
createFile(String path,
String fileName,
boolean overwrite)
Create new file in a given location.
|
static void |
createProjectStructure(String projectName,
String apiDefinition,
String headers,
String values,
boolean insecure)
Create a project structure for a particular project name.
|
static CliLauncherException |
createUsageException(String errorMsg)
Create usage exception.
|
static String |
decrypt(String value,
String secret)
Decrypt given value with provided secret.
|
static void |
deleteProject(String projectPath)
Delete project folder.
|
static String |
encrypt(String value,
String secret)
Encrypt given value with provided secret.
|
static String |
format(String message)
Formats a message based on the type of OS.
|
static String |
getAPIDefinitionPath(String projectName)
Returns path to the /api-definition of a given project the current working directory.
|
static String |
getCacertsLocation()
Get cacerts location.
|
static String |
getCacertsPassword()
Get cacerts password.
|
static String |
getCLIHome()
Get cli home location.
|
static String |
getCLILibPath()
Get cli library location.
|
static CodeGenerationContext |
getCodeGenerationContext() |
static Config |
getConfig() |
static ContainerConfig |
getContainerConfig() |
static APICorsConfigurationDTO |
getDefaultCorsConfig() |
static String |
getDefinitionsLocation()
Get filters folder location.
|
static String |
getDeploymentConfigLocation(String projectName)
Returns location of the deployment configuration file of given project.
|
static List<String> |
getExternalJarDependencies(String projectName) |
static String |
getFiltersFolderLocation()
Get filters folder location.
|
static String |
getGrpcDefinitionsDirPath(String projectName)
Returns path to the /grpc_definitions of a given project in the current directory.
|
static String |
getLoggingPropertiesFileLocation()
Get resources file directory path.
|
static String |
getMainConfigLocation()
Returns location of the main configuration file of given project root.
|
static String |
getMicroGWConfResourceLocation() |
static String |
getProjectAPIFilesDirectoryPath(String projectName)
Returns path to the /API-Files of a given project in the current working directory.
|
static String |
getProjectDirectoryPath(String projectName)
Returns path to the given project in the current working directory.
|
static String |
getProjectExtensionsDirectoryPath(String projectName)
Returns path to the /extensions of a given project in the current working directory.
|
static String |
getProjectGenAPIDefinitionPath(String projectName)
Returns path to the /gen/api-definition of a given project in the current working directory.
|
static String |
getProjectGenDirectoryPath(String projectName)
Returns path to the /gen of a given project in the current working directory.
|
static String |
getProjectGenSrcDirectoryPath(String projectName)
Returns path to the /gen/src of a given project in the current working directory.
|
static String |
getProjectGenSwaggerPath(String projectName,
String apiId)
Returns path to the /gen/api-definition of a given project in the current working directory.
|
static String |
getProjectGenSwaggerPath(String projectName,
String apiId,
String extensionType)
Returns path to the /gen/api-definition of a given project in the current working directory.
|
static String |
getProjectGrpcDirectoryPath()
Returns path to the /grpc_service/client of a given project in the current working directory.
|
static String |
getProjectGrpcSoloDirectoryPath()
Returns path to the /grpc_service of a given project in the current working directory.
|
static String |
getProjectInterceptorsPath(String projectName)
Returns the path to mgw project's 'interceptors' directory.
|
static String |
getProjectSwaggerFilePath(String projectName,
String apiId)
Returns the path to the swagger for a defined version of an API.
|
static String |
getProjectTargetGenDirectoryPath(String projectName)
Returns path to the /target/gen of a given project in the current working directory.
|
static String |
getProjectTargetGenGrpcSrcDescDirectory(String projectName)
Returns path to the /target/gen/gRPCSrc/desc of a given project in the current working directory.
|
static String |
getProjectTargetGenGrpcSrcDirectory(String projectName)
Returns path to the /target/gen/gRPCSrc of a given project in the current working directory.
|
static String |
getProjectTargetGenGrpcSrcOpenAPIsDirectory(String projectName)
Returns path to the /target/gen/gRPCSrc/OpenAPIs of a given project in the current working directory.
|
static String |
getProjectTargetInterceptorsPath(String projectName)
Returns the path to target ballerina project's 'interceptors' directory, inside of a
given mgw project in the current working directory.
|
static String |
getProjectTargetModulePath(String projectName)
Returns the path to ballerina project module inside of a given mgw project
in the current working directory.
|
static String |
getProtocDirPath()
get the path of the protoc executable.
|
static String |
getProtoDescriptorPath(String projectName,
String protoFileName)
descriptor path of the grpc definition.
|
static String |
getResourceFolderLocation()
Get resources file directory path.
|
static String |
getResourcesGrpcDirLocation()
Get grpc directory location inside Resources Directory.
|
static String |
getUnixPath(String path)
Replace backslashes `\` in windows path string with forward slashes `/`.
|
static String |
getUserDir()
Returns current user dir.
|
static String |
loadStoredResourceHashes(String projectName)
Load the stored resource hash content from the CLI temp folder.
|
static void |
printCallHomeMessage() |
static void |
printMessagesToConsole() |
static void |
printVerbose(String msg)
To print the message if verbose flag is set.
|
static String |
promptForTextInput(PrintStream outStream,
String msg)
Prompts for a test input.
|
static String |
readFileAsString(String path,
boolean inResource)
Read file as string.
|
static void |
saveConfig(Config config,
String configPath) |
static void |
saveSwaggerDefinition(String projectName,
String apiDefinition,
String apiId,
String extension)
Save openAPI definition (developer first approach).
|
static void |
saveSwaggerDefinitionForMultipleAPIs(String projectName,
List<ExtendedAPI> apis,
boolean isExpand)
Save swagger definition for multiple APIs.
|
static void |
setCallHomeMessage(String message) |
static void |
setCodeGenerationContext(CodeGenerationContext codeGenerationContext) |
static void |
setConfig(Config configFromFile) |
static void |
setContainerConfig(ContainerConfig containerConfig) |
static void |
storeResourceHashesFileContent(String content,
String projectName)
Saves the resource hash content to the CLI temp folder.
|
static void |
useInsecureSSL()
method use to trust all certificates using insecure ssl.
|
static void |
writeContent(String content,
File file)
Write content to a specified file.
|
public static Config getConfig()
public static void setConfig(Config configFromFile)
public static CodeGenerationContext getCodeGenerationContext()
public static void setCodeGenerationContext(CodeGenerationContext codeGenerationContext)
public static String readFileAsString(String path, boolean inResource) throws IOException
path - to the fileinResource - whether file is in resources directory of jar or notIOException - if file read went wrongpublic static CliLauncherException createUsageException(String errorMsg)
errorMsg - error messagepublic static String encrypt(String value, String secret)
value - value to encryptsecret - encryption keypublic static String decrypt(String value, String secret)
value - value to decryptsecret - decryption keypublic static String getUserDir()
public static String getCLIHome()
public static String getCacertsLocation()
public static String getCacertsPassword()
public static String getCLILibPath()
public static String getResourceFolderLocation()
public static String getResourcesGrpcDirLocation()
public static String getLoggingPropertiesFileLocation()
public static String getDefinitionsLocation()
public static String getFiltersFolderLocation()
public static void createProjectStructure(String projectName, String apiDefinition, String headers, String values, boolean insecure) throws IOException
projectName - name of the projectIOExceptionpublic static void saveSwaggerDefinition(String projectName, String apiDefinition, String apiId, String extension)
projectName - project nameapiDefinition - api Definition as Stringpublic static void saveSwaggerDefinitionForMultipleAPIs(String projectName, List<ExtendedAPI> apis, boolean isExpand)
projectName - project nameapis - API object Listpublic static String loadStoredResourceHashes(String projectName) throws IOException
projectName - name of the projectIOException - error while loading stored resource hash contentpublic static void storeResourceHashesFileContent(String content, String projectName) throws IOException
content - resource hash contentprojectName - name of the projectIOException - error while saving resource hash contentpublic static String getMainConfigLocation()
public static String getDeploymentConfigLocation(String projectName)
projectName - name of the projectpublic static String getProjectDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectGenDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectTargetGenDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectTargetGenGrpcSrcDirectory(String projectName)
projectName - name of the projectpublic static String getProjectTargetGenGrpcSrcOpenAPIsDirectory(String projectName)
projectName - name of the projectpublic static String getProjectTargetGenGrpcSrcDescDirectory(String projectName)
projectName - name of the projectpublic static String getProjectTargetModulePath(String projectName)
projectName - name of the mgw projectpublic static String getProjectGenSrcDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectExtensionsDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectInterceptorsPath(String projectName)
projectName - name of the projectpublic static String getProjectTargetInterceptorsPath(String projectName)
projectName - name of the projectpublic static String getProjectGenSwaggerPath(String projectName, String apiId, String extensionType)
projectName - name of the projectapiId - md5 hash value of apiName:apiVersionextensionType - The file extension type. (ex : yaml or json)public static String getProjectGenSwaggerPath(String projectName, String apiId)
projectName - name of the projectapiId - md5 hash value of apiName:apiVersionpublic static String getProjectGenAPIDefinitionPath(String projectName)
projectName - name of the projectpublic static String getAPIDefinitionPath(String projectName)
projectName - name of the projectpublic static String getGrpcDefinitionsDirPath(String projectName)
projectName - project namepublic static String getProjectGrpcDirectoryPath()
public static String getProjectGrpcSoloDirectoryPath()
public static void copyFolder(String source, String destination) throws IOException
source - source locationdestination - destination locationIOException - error while copying folder to destinationpublic static void copyAndReplaceFolder(String source, String destination) throws IOException
source - source locationdestination - destination locationIOException - error while copying folder to destinationpublic static void copyFilesToSources(String sourcePath, String destinationPath) throws IOException
sourcePath - source directory pathdestinationPath - destionation directory pathIOException - if file copy went wrongpublic static File createDirectory(String path, boolean overwrite) throws IOException
path - folder pathoverwrite - if `true` existing directory will be removed
and new directory will be created in path.IOException - Failed delete or create the directory in pathpublic static File createFile(String path, String fileName, boolean overwrite) throws IOException
path - location of the new file.overwrite - if `true` existing file with the same name will be replaced.fileName - name of the new file.IOException - Failed delete or create the file in pathpublic static void writeContent(String content, File file) throws IOException
content - content to be writtenfile - file object initialized with pathIOException - error while writing content to filepublic static void createDeploymentConfig(String projectName, String deploymentConfPath) throws IOException
projectName - project namedeploymentConfPath - path to deployment configIOException - if file create went wrongpublic static ContainerConfig getContainerConfig()
public static void setContainerConfig(ContainerConfig containerConfig)
public static APICorsConfigurationDTO getDefaultCorsConfig()
public static String getUnixPath(String path)
path - Location of a resource (file or directory)public static void deleteProject(String projectPath)
projectPath - project pathpublic static String promptForTextInput(PrintStream outStream, String msg)
outStream - Print Streammsg - messagepublic static String getProjectAPIFilesDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectSwaggerFilePath(String projectName, String apiId)
projectName - name of the projectapiId - md5 hash value of apiName:apiVersionpublic static String getProtocDirPath()
public static String getProtoDescriptorPath(String projectName, String protoFileName)
projectName - project nameprotoFileName - protobuf file namepublic static void printVerbose(String msg)
msg - Messagepublic static void useInsecureSSL()
public static String getMicroGWConfResourceLocation()
public static List<String> getExternalJarDependencies(String projectName)
public static String format(String message)
message - message to be printed in the consolepublic static void appendMessagesToConsole(String msg)
public static void printMessagesToConsole()
public static void setCallHomeMessage(String message)
public static void printCallHomeMessage()
Copyright © 2021 WSO2. All rights reserved.