Skip to content

Commit

Permalink
Merge pull request #265 from fundacionjala/develop
Browse files Browse the repository at this point in the history
version 1.1.4
  • Loading branch information
marcocdlv committed Nov 4, 2015
2 parents f03075d + cfb3b9f commit 42bfa93
Show file tree
Hide file tree
Showing 41 changed files with 246 additions and 124 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Jalasoft
Copyright (c) 2015 Fundacion Jala

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.1.3'
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.1.4'
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should create a file called build.gradle as:
jcenter()
}
dependencies {
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.1.3'
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.1.4'
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.1.3'
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.1.4'
}
}

Expand Down
47 changes: 47 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
## 1.1.4 - 2015-11-04

### Features

* Add 'location' parameter to shows credentials from home directory and project directory

This can be used as:

>$ gradle showCredentials
:showCredentials
*********************************************
Credentials
*********************************************
Id : iterum
User name : [email protected]
Type : Production/Developer

Id : test
User name : [email protected]
Type : dev (Specified)

*********************************************
Those credentials are located at /home/user_directory/credentials.dat

>$ gradle showCredentials -Plocation=project
:showCredentials
*********************************************
Credentials
*********************************************
Id : myId
User name : [email protected]
Type : jeje (Specified)

Id : demo
User name : [email protected]
Type : Production/Developer

*********************************************
Those credentials are located at /home/user_directory/project_directory/credentials.dat

### Enhancements

* Support new components called lightning.


## 1.1.3 - 2015-10-19

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import org.fundacionjala.gradle.plugins.enforce.wsc.LoginType
import java.nio.file.Paths

class CredentialManagerInput {
private final String HOME_PATH = Paths.get(System.properties['user.home'].toString(), 'credentials.dat').toString()
private final String PROJECT_PATH = Paths.get(System.getProperty("user.dir"), 'credentials.dat').toString()
private final String PROJECT = 'project'
private CredentialManager credentialManager
private String pathSecretKey
private String option

public static final String HOME_PATH = Paths.get(System.properties['user.home'].toString(), 'credentials.dat').toString()
public static final String PROJECT_PATH = Paths.get(System.getProperty("user.dir"), 'credentials.dat').toString()
public String locationInput
public String idInput
public String userNameInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.fundacionjala.gradle.plugins.enforce.interceptor

import com.jalasoft.sfdc.devtool.interceptor.interceptors.*
import org.fundacionjala.gradle.plugins.enforce.interceptor.interceptors.*
import org.fundacionjala.gradle.plugins.enforce.utils.salesforce.MetadataComponents

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package org.fundacionjala.gradle.plugins.enforce.tasks.credentialmanager

import org.fundacionjala.gradle.plugins.enforce.credentialmanagement.CredentialFileManager
import org.fundacionjala.gradle.plugins.enforce.credentialmanagement.CredentialManager
import org.fundacionjala.gradle.plugins.enforce.credentialmanagement.CredentialManagerInput
import org.fundacionjala.gradle.plugins.enforce.credentialmanagement.CredentialMessage
import org.fundacionjala.gradle.plugins.enforce.utils.Constants
import org.fundacionjala.gradle.plugins.enforce.wsc.Credential

/**
* Gives all credentials registered on Enforce.
*/
class CredentialGiver extends CredentialManagerTask {

private CredentialFileManager credentialFileManager
private final String PROJECT_OPTION = 'project'
private final String CREDENTIAL_LOCATION_INFO = 'Those credentials are located at'
private final String WARNING_TAG = "[Warning]"
private final String WARNING_MESSAGE = "doesn't exist, \nYou should add credential here using parameter location: " +
"\n\t${'$'}gradle addCredential -Pid=my [email protected] -Ppassword=qweasd456fgh -Plocation="
/**
* Sets description and group task
* @param description is description tasks
Expand All @@ -21,18 +27,29 @@ class CredentialGiver extends CredentialManagerTask {

@Override
void runTask() {
CredentialManager credentialManager = new CredentialManager()
CredentialFileManager credentialFileManager = new CredentialFileManager(credentialManager.pathCredentials,'');
String credentialsFilePath = getCredentialsFilePath()
if (!new File(credentialsFilePath).exists()) {
throw new Exception("${WARNING_TAG} ${credentialsFilePath} ${WARNING_MESSAGE}${location}")
}
credentialFileManager = new CredentialFileManager(credentialsFilePath, Constants.EMPTY)
showCredentials()
}

/**
* Shows credentials from home or project directory
*/
private void showCredentials() {
logger.quiet("*********************************************")
logger.quiet(" Credentials ")
logger.quiet("*********************************************")
for (Credential credential in credentialFileManager.getCredentials()) {
logger.quiet("")
logger.quiet("Id : $credential.id")
logger.quiet("User name : $credential.username")
logger.quiet("Type : ${getOrganizationType(credential.loginFormat)}")
logger.quiet("")
}
logger.quiet("*********************************************")
logger.quiet("${CREDENTIAL_LOCATION_INFO} ${getCredentialsFilePath()}")
}

/**
Expand All @@ -41,17 +58,29 @@ class CredentialGiver extends CredentialManagerTask {
* @return a friendly message that represents credential type.
*/
private String getOrganizationType(String loginFormat) {
String enviorement
String environment
switch (loginFormat) {
case CredentialMessage.LOGIN.value():
enviorement = CredentialMessage.DEVELOPER_ENVIRONMENT.value()
environment = CredentialMessage.DEVELOPER_ENVIRONMENT.value()
break
case CredentialMessage.TEST.value():
enviorement = CredentialMessage.TEST_ENVIRONMENT.value()
environment = CredentialMessage.TEST_ENVIRONMENT.value()
break
default:
enviorement = "$loginFormat ${CredentialMessage.OTHER_ENVIRONMENT.value()}"
environment = "$loginFormat ${CredentialMessage.OTHER_ENVIRONMENT.value()}"
}
return environment
}

/**
* Gets the path of credentials.dat file, by default it gets home directory
* @return the path of credentials.dat file
*/
private String getCredentialsFilePath() {
String credentialsFilePath = CredentialManagerInput.HOME_PATH
if (location == PROJECT_OPTION) {
credentialsFilePath = CredentialManagerInput.PROJECT_PATH
}
return enviorement
return credentialsFilePath
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class CredentialUpdater extends CredentialManagerTask {
* Updates a credential by parameters
*/
public void updateCredentialByParameters() {
if (!credentialManagerInput.hasCredential(project.properties[CredentialMessage.ID_PARAM.value()].toString())) {
throw new CredentialException(CredentialMessage.MESSAGE_ID_CREDENTIAL_DOES_NOT_EXIST.value())
String credentialId = project.properties[CredentialMessage.ID_PARAM.value()].toString()
if (!credentialManagerInput.hasCredential(credentialId)) {
throw new CredentialException("${credentialId} ${CredentialMessage.MESSAGE_ID_CREDENTIAL_DOES_NOT_EXIST.value()}" )
}
if (CredentialParameterValidator.validateFieldsCredential(project)) {
String credentialId = project.properties[CredentialMessage.ID_PARAM.value()].toString()
String credentialType = credentialManagerInput.getCredentialToUpdate(credentialId).type
credentialManagerInput.updateCredential(CredentialParameterValidator.getCredentialInserted(project, credentialType))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,6 @@ abstract class SalesforceTask extends ForceTask {
fileWriter.close()
}

/**
* Prepares the packages requested
* @param packagePath is path when package xml will be to create
* @param files is an array of files
*/
void preparePackage(String packagePath, ArrayList<File> files) {
this.packageLoaded = packagePath
packageBuilder.createPackage(files, projectPath)
}

/**
* Saves package created
*/
void savePackage() {
if (!this.packageLoaded) {
throw new DeployException(SAVE_PACKAGE_ERROR, [])
}
FileWriter fileWriter = new FileWriter(this.packageLoaded)
packageBuilder.write(fileWriter)
fileWriter.close()
}

/**
* Updates the package prepared
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Undeploy extends Deployment {
private static final String DIR_UN_DEPLOY = "undeploy"
private static final String FILE_NOT_FOUND = "these files can't be deleted from your organization, because these weren't found!"
private static final String METADATA_WILDCARD = "*${File.separator}*-meta.xml"
private static final String DOCUMENTS_WILDCARD = "*documents${File.separator}**"

public PackageComponent packageComponent
public ArrayList<File> filesToTruncate
Expand Down Expand Up @@ -110,7 +109,7 @@ class Undeploy extends Deployment {
ArrayList<String> filesToExclude = Util.getComponentsWithWildcard(standardComponents)

includes.addAll(Util.getComponentsWithWildcard(standardComponents).grep(~/.*.object$/))
includes.addAll([METADATA_WILDCARD, DOCUMENTS_WILDCARD])
includes.addAll([METADATA_WILDCARD])
filesToExclude.addAll(packageComponent.components.grep(~/.*.workflow$/) as ArrayList<String>)
filesToExclude.add(excludes)
showValidatedFiles = Constants.FALSE_OPTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,26 @@ class PackageComponent {
* @return a map with all directory names with its components
*/
private Map getComponentsFromPackage(File packageFile) {

def Package = new XmlParser().parse(packageFile)
def files = []
def directories = [:]
Package.types.each { type ->
type.members.each { memberName ->
def fileExtension = MetadataComponents.getExtensionByName(type.name.text() as String)
if (!memberName.text().equals("*")) {
files.add("${memberName.text()}.${fileExtension}")
if (fileExtension == null) {
return
}
if (fileExtension.isEmpty()) {
files.add("**")
} else {
def wildCard = "*.${fileExtension}"
files.add(wildCard)
if (!memberName.text().equals("*")) {
files.add("${memberName.text()}.${fileExtension}")
} else {
def wildCard = "*.${fileExtension}"
files.add(wildCard)
}
}
}

directories.put(MetadataComponents.getDirectoryByName(type.name.text() as String), files.clone())
files.clear()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,25 @@ class Util {
}
//validates files
ClassifiedFile classifiedFile = FileValidator.validateFiles(projectPath, filesToRetrieve)
if (!classifiedFile.invalidFiles.isEmpty()) {
throw new Exception("${Constants.INVALID_FILE}: ${classifiedFile.invalidFiles}")
ArrayList<File> invalidFiles = getFilesWithoutAuraComponents(classifiedFile.invalidFiles)
if (!invalidFiles.isEmpty()) {
throw new Exception("${Constants.INVALID_FILE}: ${invalidFiles}")
}
}

/**
* Gets files excluding aura files
* @param files is an array list o files
* @return an array list of files
*/
public static ArrayList<File> getFilesWithoutAuraComponents(ArrayList<File> files) {
ArrayList<File> filesFiltered = files.clone() as ArrayList<File>
files.each {File file ->
if(file.getPath().contains('aura')) {
filesFiltered.remove(file)
}
}
return filesFiltered
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public enum MetadataComponents {
PROFILES("Profile", "profile", "profiles"),
TABS("CustomTab", "tab", "tabs"),
TRANSLATIONS("Translations", "translation", "translations"),
AURADEFINITIONBUNDLE("AuraDefinitionBundle", "", "aura", Constants.CONTAINS_XML_FILE),
FIELDS("CustomField", "sbc", "fields"),
COMPACTLAYOUTS("CompactLayout", "sbc", "compactLayouts"),
RECORDTYPES("RecordType", "sbc", "recordTypes"),
Expand All @@ -75,14 +76,13 @@ public enum MetadataComponents {
OBJECTWEBLINKS("Weblink", "sbc", "webLinks"),
CUSTOMPERMISSIONS("CustomPermission", "customPermission", "customPermissions")


public final static Map<String, MetadataComponents> COMPONENT;
public final static Map<String, MetadataComponents> COMPONENT

static {
COMPONENT = new HashMap<String, MetadataComponents>();
COMPONENT = new HashMap<String, MetadataComponents>()

for (MetadataComponents input : values()) {
COMPONENT.put(input.name(), input);
COMPONENT.put(input.name(), input)
}
}

Expand Down Expand Up @@ -255,7 +255,7 @@ public enum MetadataComponents {
*/
public static boolean validFolder(String folderName) {
for (MetadataComponents input : values()) {
if (input.name() == folderName.toUpperCase()) {
if (input.getDirectory() == folderName) {
return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ class PackageBuilder {
MetadataComponents component = MetadataComponents.getComponentByPath(folder as String)
if (component) {
packageTypeMembers = new PackageTypeMembers()
ArrayList<String> filesMembers = PackageUtil.selectFilesMembers(folder, files, basePath)
ArrayList<File> filesByFolder = PackageUtil.getFilesByFolder(folder, files)
ArrayList<String> filesMembers = PackageUtil.selectFilesMembers(filesByFolder, basePath)
packageTypeMembers.members = filesMembers ?: [WILDCARD]
packageTypeMembers.name = component.getTypeName()
packageData.push(packageTypeMembers)
Expand Down
Loading

0 comments on commit 42bfa93

Please sign in to comment.