diff --git a/composer.json b/composer.json
index fd732a9f..a0b111bc 100644
--- a/composer.json
+++ b/composer.json
@@ -6,8 +6,8 @@
"require": {
"php": ">=7.4",
"ext-dom": "*",
- "ext-simplexml": "*",
"ext-json": "*",
+ "ext-simplexml": "*",
"composer-plugin-api": "^1.0.0 || ^2.0.0",
"aws/aws-sdk-php": "^3.257",
"composer/composer": "^2.1.0",
diff --git a/src/Console/IntegratorLockUpdaterConsole.php b/src/Console/IntegratorLockUpdaterConsole.php
index 422997a7..1030008e 100644
--- a/src/Console/IntegratorLockUpdaterConsole.php
+++ b/src/Console/IntegratorLockUpdaterConsole.php
@@ -45,6 +45,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$commandArgumentsTransfer,
);
+ $this->getFacade()
+ ->runCleanLock($io);
+
return 0;
}
}
diff --git a/src/Executor/Module/ModuleManifestExecutor.php b/src/Executor/Module/ModuleManifestExecutor.php
index 9fe9edd1..65b5ca21 100644
--- a/src/Executor/Module/ModuleManifestExecutor.php
+++ b/src/Executor/Module/ModuleManifestExecutor.php
@@ -13,6 +13,7 @@
use SprykerSdk\Integrator\Dependency\Console\InputOutputInterface;
use SprykerSdk\Integrator\Executor\ManifestExecutorInterface;
use SprykerSdk\Integrator\Filter\ManifestsFiltersExecutorInterface;
+use SprykerSdk\Integrator\IntegratorLock\IntegratorLockCleanerInterface;
use SprykerSdk\Integrator\IntegratorLock\IntegratorLockReaderInterface;
use SprykerSdk\Integrator\IntegratorLock\IntegratorLockWriterInterface;
use SprykerSdk\Integrator\Manifest\RepositoryManifestReaderInterface;
@@ -50,9 +51,15 @@ class ModuleManifestExecutor implements ModuleManifestExecutorInterface
*/
private IntegratorLockReaderInterface $integratorLockReader;
+ /**
+ * @var \SprykerSdk\Integrator\IntegratorLock\IntegratorLockCleanerInterface
+ */
+ private IntegratorLockCleanerInterface $integratorLockCleaner;
+
/**
* @param \SprykerSdk\Integrator\IntegratorLock\IntegratorLockReaderInterface $integratorLockReader
* @param \SprykerSdk\Integrator\IntegratorLock\IntegratorLockWriterInterface $integratorLockWriter
+ * @param \SprykerSdk\Integrator\IntegratorLock\IntegratorLockCleanerInterface $integratorLockCleaner
* @param \SprykerSdk\Integrator\Manifest\RepositoryManifestReaderInterface $manifestReader
* @param \SprykerSdk\Integrator\Executor\ManifestExecutorInterface $manifestExecutor
* @param \SprykerSdk\Integrator\Composer\ComposerLockReaderInterface $composerLockReader
@@ -61,15 +68,17 @@ class ModuleManifestExecutor implements ModuleManifestExecutorInterface
public function __construct(
IntegratorLockReaderInterface $integratorLockReader,
IntegratorLockWriterInterface $integratorLockWriter,
+ IntegratorLockCleanerInterface $integratorLockCleaner,
RepositoryManifestReaderInterface $manifestReader,
ManifestExecutorInterface $manifestExecutor,
ComposerLockReaderInterface $composerLockReader,
ManifestsFiltersExecutorInterface $manifestsFiltersExecutor
) {
$this->integratorLockReader = $integratorLockReader;
- $this->manifestExecutor = $manifestExecutor;
$this->integratorLockWriter = $integratorLockWriter;
+ $this->integratorLockCleaner = $integratorLockCleaner;
$this->manifestReader = $manifestReader;
+ $this->manifestExecutor = $manifestExecutor;
$this->composerLockReader = $composerLockReader;
$this->manifestsFiltersExecutor = $manifestsFiltersExecutor;
}
@@ -111,4 +120,15 @@ public function runUpdateLock(
$this->integratorLockWriter->storeLock($moduleVersions);
$input->write('The integration lock file has been updated according to the project state.', true);
}
+
+ /**
+ * @param \SprykerSdk\Integrator\Dependency\Console\InputOutputInterface $input
+ *
+ * @return void
+ */
+ public function runCleanLock(InputOutputInterface $input): void
+ {
+ $this->integratorLockCleaner->deleteLock();
+ $input->write('The integration lock file has been removed.', true);
+ }
}
diff --git a/src/Executor/Module/ModuleManifestExecutorInterface.php b/src/Executor/Module/ModuleManifestExecutorInterface.php
index 1fe93e0d..5671f152 100644
--- a/src/Executor/Module/ModuleManifestExecutorInterface.php
+++ b/src/Executor/Module/ModuleManifestExecutorInterface.php
@@ -35,4 +35,11 @@ public function runUpdateLock(
InputOutputInterface $input,
IntegratorCommandArgumentsTransfer $commandArgumentsTransfer
): void;
+
+ /**
+ * @param \SprykerSdk\Integrator\Dependency\Console\InputOutputInterface $input
+ *
+ * @return void
+ */
+ public function runCleanLock(InputOutputInterface $input): void;
}
diff --git a/src/IntegratorFacade.php b/src/IntegratorFacade.php
index 9017d8dc..0760b7b5 100644
--- a/src/IntegratorFacade.php
+++ b/src/IntegratorFacade.php
@@ -46,6 +46,18 @@ public function runUpdateLock(
->runUpdateLock($input, $commandArgumentsTransfer);
}
+ /**
+ * @param \SprykerSdk\Integrator\Dependency\Console\InputOutputInterface $input
+ *
+ * @return void
+ */
+ public function runCleanLock(InputOutputInterface $input): void
+ {
+ $this->getFactory()
+ ->createModuleManifestExecutor()
+ ->runCleanLock($input);
+ }
+
/**
* @param \SprykerSdk\Integrator\Transfer\IntegratorCommandArgumentsTransfer $commandArgumentsTransfer
* @param \SprykerSdk\Integrator\Dependency\Console\InputOutputInterface $input
diff --git a/src/IntegratorFacadeInterface.php b/src/IntegratorFacadeInterface.php
index 32e9ded1..2104ade4 100644
--- a/src/IntegratorFacadeInterface.php
+++ b/src/IntegratorFacadeInterface.php
@@ -36,6 +36,13 @@ public function runUpdateLock(
IntegratorCommandArgumentsTransfer $commandArgumentsTransfer
): void;
+ /**
+ * @param \SprykerSdk\Integrator\Dependency\Console\InputOutputInterface $input
+ *
+ * @return void
+ */
+ public function runCleanLock(InputOutputInterface $input): void;
+
/**
* @param \SprykerSdk\Integrator\Transfer\IntegratorCommandArgumentsTransfer $commandArgumentsTransfer
* @param \SprykerSdk\Integrator\Dependency\Console\InputOutputInterface $input
diff --git a/src/IntegratorFactory.php b/src/IntegratorFactory.php
index 7bc12dbb..18fa25a6 100644
--- a/src/IntegratorFactory.php
+++ b/src/IntegratorFactory.php
@@ -136,6 +136,8 @@
use SprykerSdk\Integrator\Filter\RatingBasedManifestFilter\RatingBasedManifestsFilter;
use SprykerSdk\Integrator\Helper\ClassHelper;
use SprykerSdk\Integrator\Helper\ClassHelperInterface;
+use SprykerSdk\Integrator\IntegratorLock\IntegratorLockCleaner;
+use SprykerSdk\Integrator\IntegratorLock\IntegratorLockCleanerInterface;
use SprykerSdk\Integrator\IntegratorLock\IntegratorLockReader;
use SprykerSdk\Integrator\IntegratorLock\IntegratorLockReaderInterface;
use SprykerSdk\Integrator\IntegratorLock\IntegratorLockWriter;
@@ -184,6 +186,7 @@ public function createModuleManifestExecutor(): ModuleManifestExecutorInterface
return new ModuleManifestExecutor(
$this->createIntegratorLockReader(),
$this->createIntegratorLockWriter(),
+ $this->createIntegratorLockCleaner(),
$this->createRepositoryManifestReader(),
$this->createManifestExecutor(),
$this->createComposerLockReader(),
@@ -241,6 +244,14 @@ public function createIntegratorLockWriter(): IntegratorLockWriterInterface
return new IntegratorLockWriter($this->getConfig());
}
+ /**
+ * @return \SprykerSdk\Integrator\IntegratorLock\IntegratorLockCleanerInterface
+ */
+ public function createIntegratorLockCleaner(): IntegratorLockCleanerInterface
+ {
+ return new IntegratorLockCleaner($this->getConfig());
+ }
+
/**
* @return \SprykerSdk\Integrator\Composer\ComposerLockReaderInterface
*/
diff --git a/src/IntegratorLock/IntegratorLockCleaner.php b/src/IntegratorLock/IntegratorLockCleaner.php
new file mode 100644
index 00000000..9f94e362
--- /dev/null
+++ b/src/IntegratorLock/IntegratorLockCleaner.php
@@ -0,0 +1,38 @@
+config = $config;
+ }
+
+ /**
+ * @return void
+ */
+ public function deleteLock(): void
+ {
+ $lockFilePath = $this->config->getIntegratorLockFilePath();
+
+ unlink($lockFilePath);
+ }
+}
diff --git a/src/IntegratorLock/IntegratorLockCleanerInterface.php b/src/IntegratorLock/IntegratorLockCleanerInterface.php
new file mode 100644
index 00000000..044d61e9
--- /dev/null
+++ b/src/IntegratorLock/IntegratorLockCleanerInterface.php
@@ -0,0 +1,18 @@
+createComposerLockReadr();
+ $composerLockReader = $this->createComposerLockReader();
$this->assertCount(4, $composerLockReader->getModuleVersions());
$this->assertArrayHasKey(static::DEFAULT_PACKAGE_NAME, $composerLockReader->getModuleVersions());
@@ -34,7 +34,7 @@ public function testGetModuleVersions(): void
/**
* @return \SprykerSdk\Integrator\Composer\ComposerLockReader
*/
- private function createComposerLockReadr(): ComposerLockReader
+ private function createComposerLockReader(): ComposerLockReader
{
$integratorConfigMock = $this->createMock(IntegratorConfig::class);
$integratorConfigMock->method('getComposerLockFilePath')->willReturn('./tests/_data/composer/composer.lock');
diff --git a/tests/SprykerSdkTest/Integrator/ConfigReader/ConfigReaderTest.php b/tests/SprykerSdkTest/Integrator/ConfigReader/ConfigReaderTest.php
index 38b79823..b034e780 100644
--- a/tests/SprykerSdkTest/Integrator/ConfigReader/ConfigReaderTest.php
+++ b/tests/SprykerSdkTest/Integrator/ConfigReader/ConfigReaderTest.php
@@ -21,7 +21,7 @@ class ConfigReaderTest extends BaseTestCase
public function testReadShouldReturnParsedValues(): void
{
// Arrange
- $configFilePath = './tests/_data/project_config/config_default.php';
+ $configFilePath = ROOT_TESTS . '/_data/project_config/config_default.php';
$configReader = new ConfigReader(new ParserFactory());
$configKeys = ['KernelConstants::PROJECT_NAMESPACES', 'KernelConstants::CORE_NAMESPACES'];
diff --git a/tests/SprykerSdkTest/Integrator/IntegratorFacadeTest.php b/tests/SprykerSdkTest/Integrator/IntegratorFacadeTest.php
index 494918dd..01506368 100644
--- a/tests/SprykerSdkTest/Integrator/IntegratorFacadeTest.php
+++ b/tests/SprykerSdkTest/Integrator/IntegratorFacadeTest.php
@@ -561,4 +561,22 @@ public function testRunUpdateLock(): void
$this->assertNotEmpty(trim(file_get_contents($integratorLock)));
}
+
+ /**
+ * @return void
+ */
+ public function testRunCleanLock(): void
+ {
+ // Arrange
+ $ioAdapter = $this->buildSymfonyConsoleInputOutputAdapter();
+
+ file_put_contents($this->getTestTmpDirPath() . '/integrator.lock', 'test');
+
+ // Act
+ $this->createIntegratorFacade()->runCleanLock($ioAdapter);
+
+ // Assert
+ $integratorLock = $this->getTestTmpDirPath() . '/integrator.lock';
+ $this->assertFileDoesNotExist($integratorLock);
+ }
}
diff --git a/tests/SprykerSdkTest/Integrator/IntegratorLock/IntegratorLockTest.php b/tests/SprykerSdkTest/Integrator/IntegratorLock/IntegratorLockTest.php
index 6f53544c..54c56b12 100644
--- a/tests/SprykerSdkTest/Integrator/IntegratorLock/IntegratorLockTest.php
+++ b/tests/SprykerSdkTest/Integrator/IntegratorLock/IntegratorLockTest.php
@@ -10,6 +10,7 @@
namespace SprykerSdkTest\Integrator\IntegratorLock;
use SprykerSdk\Integrator\IntegratorConfig;
+use SprykerSdk\Integrator\IntegratorLock\IntegratorLockCleaner;
use SprykerSdk\Integrator\IntegratorLock\IntegratorLockReader;
use SprykerSdk\Integrator\IntegratorLock\IntegratorLockWriter;
use SprykerSdkTest\Integrator\BaseTestCase;
@@ -21,7 +22,7 @@ class IntegratorLockTest extends BaseTestCase
*/
public function testWriteFileLock(): void
{
- $compareFilePath = './tests/_data/composer/spryker_lock_test_write_lock.json';
+ $compareFilePath = ROOT_TESTS . '/_data/composer/spryker_lock_test_write_lock.json';
$lockData = [
'Spryker.Test' => [
'wire-plugin' => [
@@ -51,7 +52,7 @@ public function testWriteFileLock(): void
public function testReadFileLock(): void
{
$tmpIntegratorLockFilePath = tempnam(sys_get_temp_dir(), 'integrator.lock.');
- $compareFilePath = './tests/_data/composer/spryker_lock_test_write_lock.json';
+ $compareFilePath = ROOT_TESTS . '/_data/composer/spryker_lock_test_write_lock.json';
file_put_contents($tmpIntegratorLockFilePath, file_get_contents($compareFilePath));
@@ -64,6 +65,22 @@ public function testReadFileLock(): void
$this->removeFile($tmpIntegratorLockFilePath);
}
+ /**
+ * @return void
+ */
+ public function testDeleteFileLock(): void
+ {
+ $tmpIntegratorLockFilePath = tempnam(sys_get_temp_dir(), 'integrator.lock.');
+ $compareFilePath = ROOT_TESTS . '/_data/composer/spryker_lock_test_write_lock.json';
+
+ file_put_contents($tmpIntegratorLockFilePath, file_get_contents($compareFilePath));
+
+ $integratorLockCleaner = $this->createIntegratorLockCleaner($tmpIntegratorLockFilePath);
+ $integratorLockCleaner->deleteLock();
+
+ $this->assertFileDoesNotExist($tmpIntegratorLockFilePath);
+ }
+
/**
* @param string $tmpIntegratorLockFilePath
*
@@ -71,12 +88,7 @@ public function testReadFileLock(): void
*/
private function createIntegratorLockWriter(string $tmpIntegratorLockFilePath): IntegratorLockWriter
{
- $integrotorConfigMock = $this->createMock(IntegratorConfig::class);
-
- $integrotorConfigMock->method('getIntegratorLockFilePath')
- ->willReturn($tmpIntegratorLockFilePath);
-
- return new IntegratorLockWriter($integrotorConfigMock);
+ return new IntegratorLockWriter($this->mockIntegratorConfig($tmpIntegratorLockFilePath));
}
/**
@@ -86,12 +98,32 @@ private function createIntegratorLockWriter(string $tmpIntegratorLockFilePath):
*/
private function createIntegratorLockReader(string $tmpIntegratorLockFilePath): IntegratorLockReader
{
- $integrotorConfigMock = $this->createMock(IntegratorConfig::class);
+ return new IntegratorLockReader($this->mockIntegratorConfig($tmpIntegratorLockFilePath));
+ }
+
+ /**
+ * @param string $tmpIntegratorLockFilePath
+ *
+ * @return \SprykerSdk\Integrator\IntegratorLock\IntegratorLockCleaner
+ */
+ private function createIntegratorLockCleaner(string $tmpIntegratorLockFilePath): IntegratorLockCleaner
+ {
+ return new IntegratorLockCleaner($this->mockIntegratorConfig($tmpIntegratorLockFilePath));
+ }
+
+ /**
+ * @param string $tmpIntegratorLockFilePath
+ *
+ * @return \SprykerSdk\Integrator\IntegratorConfig
+ */
+ private function mockIntegratorConfig(string $tmpIntegratorLockFilePath): IntegratorConfig
+ {
+ $integratorConfigMock = $this->createMock(IntegratorConfig::class);
- $integrotorConfigMock->method('getIntegratorLockFilePath')
+ $integratorConfigMock->method('getIntegratorLockFilePath')
->willReturn($tmpIntegratorLockFilePath);
- return new IntegratorLockReader($integrotorConfigMock);
+ return $integratorConfigMock;
}
/**