Skip to content

Commit

Permalink
Release v1.6.2 (#184)
Browse files Browse the repository at this point in the history
* feat(uninstall): remove unused config parameters when uninstalling

* chore: version bump
  • Loading branch information
marchbold authored Jul 12, 2023
1 parent 60dfd9b commit 8665e8f
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* __ __ __
* ____/ /_ ____/ /______ _ ___ / /_
* / __ / / ___/ __/ ___/ / __ `/ __/
* / /_/ / (__ ) / / / / / /_/ / /
* \__,_/_/____/_/ /_/ /_/\__, /_/
* / /
* \/
* http://distriqt.com
*
* @author Michael (https://github.com/marchbold)
* @created 15/6/2021
*/
package com.apm.client.commands.packages.processes
{
import com.apm.client.APM;
import com.apm.data.packages.PackageIdentifier;
import com.apm.data.packages.PackageParameter;
import com.apm.utils.DeployFileUtils;
import com.apm.utils.FileUtils;
import com.apm.utils.PackageFileUtils;
import com.apm.client.logging.Log;
import com.apm.client.processes.ProcessBase;
import com.apm.data.packages.PackageDefinitionFile;
import com.apm.utils.ProjectPackageCache;

import flash.filesystem.File;
import flash.html.script.Package;


/**
* This process removes any unused project config params associated with an AIR package
* - it does not remove any related dependencies
* - it only removes config params that isn't related to other packages
*/
public class UninstallConfigForPackageProcess extends ProcessBase
{
////////////////////////////////////////////////////////
// CONSTANTS
//

private static const TAG:String = "UninstallConfigForPackageProcess";


////////////////////////////////////////////////////////
// VARIABLES
//

private var _packageDefinition:PackageDefinitionFile;


////////////////////////////////////////////////////////
// FUNCTIONALITY
//

public function UninstallConfigForPackageProcess( packageDefinition:PackageDefinitionFile )
{
super();
_packageDefinition = packageDefinition;
}


override public function start( completeCallback:Function = null, failureCallback:Function = null ):void
{
super.start( completeCallback, failureCallback );
APM.io.showSpinner( "Removing config for package : " + _packageDefinition.packageDef.identifier );

var paramsToRemove:Vector.<PackageParameter> = new Vector.<PackageParameter>();

var packages:Vector.<PackageDefinitionFile> = ProjectPackageCache.getPackages();
for each (var param:PackageParameter in _packageDefinition.version.parameters)
{
var shouldRemove:Boolean = true;
for each (var packageDef:PackageDefinitionFile in packages)
{
if (packageDef.packageDef.equals( _packageDefinition.packageDef )) continue;
for each (var packageParam:PackageParameter in packageDef.version.parameters)
{
if (packageParam.name == param.name) shouldRemove = false;
}
}

if (shouldRemove) paramsToRemove.push( param );
}

for each (var removeParam:PackageParameter in paramsToRemove)
{
APM.config.projectDefinition.removePackageParameter( removeParam.name );
}

APM.io.stopSpinner( true, "Removed config for package : " + _packageDefinition.packageDef.identifier );
complete();
}



}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package com.apm.client.commands.packages.processes
import com.apm.client.processes.ProcessQueue;
import com.apm.data.packages.PackageDefinitionFile;
import com.apm.data.packages.PackageDependency;
import com.apm.utils.ProjectPackageCache;
import com.apm.utils.PackageFileUtils;
import com.apm.utils.ProjectPackageCache;

import flash.filesystem.File;

Expand Down Expand Up @@ -72,11 +72,11 @@ package com.apm.client.commands.packages.processes
{
super();
_uninstallingPackageIdentifier = uninstallingPackageIdentifier;
_packageIdentifier = packageIdentifier;
_appDescriptorPath = appDescriptorPath;
_version = version;
_failIfNotInstalled = failIfNotInstalled;
_checkIfRequiredDependency = checkIfRequiredDependency;
_packageIdentifier = packageIdentifier;
_appDescriptorPath = appDescriptorPath;
_version = version;
_failIfNotInstalled = failIfNotInstalled;
_checkIfRequiredDependency = checkIfRequiredDependency;
}


Expand Down Expand Up @@ -140,6 +140,7 @@ package com.apm.client.commands.packages.processes

var queue:ProcessQueue = new ProcessQueue();

queue.addProcess( new UninstallConfigForPackageProcess( uninstallingPackageDefinition ) );
queue.addProcess( new UninstallFilesForPackageProcess( uninstallingPackageDefinition ) );
if (_appDescriptorPath != null)
{
Expand Down
23 changes: 23 additions & 0 deletions client/src/com/apm/data/project/ProjectDefinition.as
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,29 @@ package com.apm.data.project
}


/**
* Removes the specified package parameter
* @param paramName The name of the package parameter
*/
public function removePackageParameter( paramName:String ):void
{
var param:ProjectParameter = getConfigurationParam( paramName, null );
if (param == null)
{
return;
}

for (var i:int = _configuration.length-1; i >= 0; i--)
{
if (_configuration[i].name == paramName)
{
_configuration.removeAt(i);
}
}

}


//
// BUILD TYPES
//
Expand Down
4 changes: 2 additions & 2 deletions version.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri, 02 Jun 2023 12:13:05 +1000
#Wed, 12 Jul 2023 16:28:17 +1000

version_major=1
version_minor=6
version_build=1
version_build=2
version_preview=

0 comments on commit 8665e8f

Please sign in to comment.