From 5fdac941e07b393faff9bf5e82d3f5e869cbfa79 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Mon, 23 Oct 2023 14:58:18 -0700 Subject: [PATCH 1/2] CLI-1143: Don't use invalidated access keys (#1609) * CLI-1143: Don't use invalidated access keys * back to stable --- composer.json | 2 +- composer.lock | 76 +++++++++++++++++++++++++++------------------------ 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index 0ebbbc7c0..989de611f 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "symfony/yaml": "^6.0", "thecodingmachine/safe": "^2.4", "typhonius/acquia-logstream": "^0.0.13", - "typhonius/acquia-php-sdk-v2": "^3.1.0", + "typhonius/acquia-php-sdk-v2": "^3.1.1", "vlucas/phpdotenv": "^5.5", "zumba/amplitude-php": "^1.0.4" }, diff --git a/composer.lock b/composer.lock index eb8a1faac..6aa740632 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "30883d9882c37c949a848b08581cb472", + "content-hash": "16c2aa336ca4d6275a5bdc30feb500dc", "packages": [ { "name": "acquia/drupal-environment-detector", @@ -577,16 +577,16 @@ }, { "name": "composer/pcre", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", "shasum": "" }, "require": { @@ -628,7 +628,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/3.1.1" }, "funding": [ { @@ -644,7 +644,7 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2023-10-11T07:11:09+00:00" }, { "name": "composer/semver", @@ -7219,16 +7219,16 @@ }, { "name": "typhonius/acquia-php-sdk-v2", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/typhonius/acquia-php-sdk-v2.git", - "reference": "9f0bcb91ac2942af97a512b8b579f0fb895f1d80" + "reference": "552a644020695bf1826c66da15c233849495a4fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/typhonius/acquia-php-sdk-v2/zipball/9f0bcb91ac2942af97a512b8b579f0fb895f1d80", - "reference": "9f0bcb91ac2942af97a512b8b579f0fb895f1d80", + "url": "https://api.github.com/repos/typhonius/acquia-php-sdk-v2/zipball/552a644020695bf1826c66da15c233849495a4fa", + "reference": "552a644020695bf1826c66da15c233849495a4fa", "shasum": "" }, "require": { @@ -7272,7 +7272,7 @@ "description": "A PHP SDK for Acquia CloudAPI v2", "support": { "issues": "https://github.com/typhonius/acquia-php-sdk-v2/issues", - "source": "https://github.com/typhonius/acquia-php-sdk-v2/tree/3.1.0" + "source": "https://github.com/typhonius/acquia-php-sdk-v2/tree/3.1.1" }, "funding": [ { @@ -7280,7 +7280,7 @@ "type": "github" } ], - "time": "2023-08-28T21:15:44+00:00" + "time": "2023-10-23T20:28:39+00:00" }, { "name": "vlucas/phpdotenv", @@ -8552,16 +8552,16 @@ }, { "name": "drupal/coder", - "version": "8.3.21", + "version": "8.3.22", "source": { "type": "git", "url": "https://github.com/pfrenssen/coder.git", - "reference": "a0b76c6c8ea277b07d58fa75dcacf102a203ad51" + "reference": "ba6e62303d567863275fb086941f50a06dc7d08f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pfrenssen/coder/zipball/a0b76c6c8ea277b07d58fa75dcacf102a203ad51", - "reference": "a0b76c6c8ea277b07d58fa75dcacf102a203ad51", + "url": "https://api.github.com/repos/pfrenssen/coder/zipball/ba6e62303d567863275fb086941f50a06dc7d08f", + "reference": "ba6e62303d567863275fb086941f50a06dc7d08f", "shasum": "" }, "require": { @@ -8599,7 +8599,7 @@ "issues": "https://www.drupal.org/project/issues/coder", "source": "https://www.drupal.org/project/coder" }, - "time": "2023-07-17T15:36:49+00:00" + "time": "2023-10-15T09:55:50+00:00" }, { "name": "fidry/cpu-core-counter", @@ -10910,31 +10910,37 @@ }, { "name": "sanmai/later", - "version": "0.1.2", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/sanmai/later.git", - "reference": "9b659fecef2030193fd02402955bc39629d5606f" + "reference": "88a1d39965aa3659ceb96622e2801b9194d16e2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sanmai/later/zipball/9b659fecef2030193fd02402955bc39629d5606f", - "reference": "9b659fecef2030193fd02402955bc39629d5606f", + "url": "https://api.github.com/repos/sanmai/later/zipball/88a1d39965aa3659ceb96622e2801b9194d16e2c", + "reference": "88a1d39965aa3659ceb96622e2801b9194d16e2c", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.4" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.13", - "infection/infection": ">=0.10.5", + "ergebnis/composer-normalize": "^2.8", + "friendsofphp/php-cs-fixer": "^3.35.1", + "infection/infection": ">=0.27.6", "phan/phan": ">=2", "php-coveralls/php-coveralls": "^2.0", - "phpstan/phpstan": ">=0.10", - "phpunit/phpunit": ">=7.4", + "phpstan/phpstan": ">=1.4.5", + "phpunit/phpunit": ">=9.5 <10", "vimeo/psalm": ">=2" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.1.x-dev" + } + }, "autoload": { "files": [ "src/functions.php" @@ -10956,7 +10962,7 @@ "description": "Later: deferred wrapper object", "support": { "issues": "https://github.com/sanmai/later/issues", - "source": "https://github.com/sanmai/later/tree/0.1.2" + "source": "https://github.com/sanmai/later/tree/0.1.3" }, "funding": [ { @@ -10964,20 +10970,20 @@ "type": "github" } ], - "time": "2021-01-02T10:26:44+00:00" + "time": "2023-10-23T13:38:10+00:00" }, { "name": "sanmai/pipeline", - "version": "v6.8.1", + "version": "v6.9", "source": { "type": "git", "url": "https://github.com/sanmai/pipeline.git", - "reference": "2e88e466dd49f20c10a15330b3953d4d49c326e3" + "reference": "c48f45c22c3ce4140d071f7658fb151df1cc08ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sanmai/pipeline/zipball/2e88e466dd49f20c10a15330b3953d4d49c326e3", - "reference": "2e88e466dd49f20c10a15330b3953d4d49c326e3", + "url": "https://api.github.com/repos/sanmai/pipeline/zipball/c48f45c22c3ce4140d071f7658fb151df1cc08ea", + "reference": "c48f45c22c3ce4140d071f7658fb151df1cc08ea", "shasum": "" }, "require": { @@ -11021,7 +11027,7 @@ "description": "General-purpose collections pipeline", "support": { "issues": "https://github.com/sanmai/pipeline/issues", - "source": "https://github.com/sanmai/pipeline/tree/v6.8.1" + "source": "https://github.com/sanmai/pipeline/tree/v6.9" }, "funding": [ { @@ -11029,7 +11035,7 @@ "type": "github" } ], - "time": "2023-06-15T09:14:47+00:00" + "time": "2023-10-08T11:56:54+00:00" }, { "name": "sebastian/cli-parser", From 030e53b5d0b1711d02579cc17e43fd58bcfac620 Mon Sep 17 00:00:00 2001 From: Jura Khrapunov Date: Mon, 23 Oct 2023 18:01:30 -0400 Subject: [PATCH 2/2] CLI-1171: Home directory errors on Windows (#1611) * CLI-1171: updated env variable testing condition * CLI-1171: Updated tests coverage --- src/Helpers/LocalMachineHelper.php | 6 ++-- .../src/Misc/LocalMachineHelperTest.php | 35 +++++++++++++++++++ tests/phpunit/src/TestBase.php | 14 ++++++-- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/Helpers/LocalMachineHelper.php b/src/Helpers/LocalMachineHelper.php index e6fd68db5..61d3874c2 100644 --- a/src/Helpers/LocalMachineHelper.php +++ b/src/Helpers/LocalMachineHelper.php @@ -215,15 +215,13 @@ private function fixFilename(string $filename): string { /** * Returns the appropriate home directory. * - * Adapted from Ads Package Manager by Ed Reel. - * - * @url https://github.com/uberhacker/tpm + * @see https://github.com/pantheon-systems/terminus/blob/1d89e20dd388dc08979a1bc52dfd142b26c03dcf/src/Config/DefaultsConfig.php#L99 */ public static function getHomeDir(): string { $home = getenv('HOME'); if (!$home) { $system = ''; - if (getenv('MSYSTEM') !== NULL) { + if (getenv('MSYSTEM')) { $system = strtoupper(substr(getenv('MSYSTEM'), 0, 4)); } if ($system !== 'MING') { diff --git a/tests/phpunit/src/Misc/LocalMachineHelperTest.php b/tests/phpunit/src/Misc/LocalMachineHelperTest.php index 13d77b689..13407a942 100644 --- a/tests/phpunit/src/Misc/LocalMachineHelperTest.php +++ b/tests/phpunit/src/Misc/LocalMachineHelperTest.php @@ -4,6 +4,8 @@ namespace Acquia\Cli\Tests\Misc; +use Acquia\Cli\Exception\AcquiaCliException; +use Acquia\Cli\Helpers\LocalMachineHelper; use Acquia\Cli\Tests\TestBase; use Symfony\Component\Console\Output\BufferedOutput; @@ -61,4 +63,37 @@ public function testCommandExists(): void { $this->assertIsBool($exists); } + public function testHomeDirWindowsCmd(): void { + self::setEnvVars([ + 'HOMEPATH' => 'something', + ]); + self::unsetEnvVars([ + 'MSYSTEM', + 'HOME', + ]); + $home = LocalMachineHelper::getHomeDir(); + $this->assertEquals('something', $home); + } + + public function testHomeDirWindowsMsys2(): void { + self::setEnvVars([ + 'HOMEPATH' => 'something', + 'MSYSTEM' => 'MSYS2', + ]); + self::unsetEnvVars(['HOME']); + $home = LocalMachineHelper::getHomeDir(); + $this->assertEquals('something', $home); + } + + /** + * I don't know why, but apparently Ming is unsupported ¯\_(ツ)_/¯. + */ + public function testHomeDirWindowsMing(): void { + self::setEnvVars(['MSYSTEM' => 'MING']); + self::unsetEnvVars(['HOME']); + $this->expectException(AcquiaCliException::class); + $this->expectExceptionMessage('Could not determine $HOME directory. Ensure $HOME is set in your shell.'); + LocalMachineHelper::getHomeDir(); + } + } diff --git a/tests/phpunit/src/TestBase.php b/tests/phpunit/src/TestBase.php index e88bdb6a8..78d5de29f 100644 --- a/tests/phpunit/src/TestBase.php +++ b/tests/phpunit/src/TestBase.php @@ -164,7 +164,10 @@ public function setupFsFixture(): void { * This method is called before each test. */ protected function setUp(): void { - putenv('COLUMNS=85'); + self::setEnvVars([ + 'COLUMNS' => '85', + 'HOME' => '/home/test', + ]); $this->output = new BufferedOutput(); $this->input = new ArrayInput([]); @@ -241,9 +244,14 @@ public static function setEnvVars(array $envVars): void { } } - public static function unsetEnvVars(mixed $envVars): void { + public static function unsetEnvVars(array $envVars): void { foreach ($envVars as $key => $value) { - putenv($key); + if (is_int($key)) { + putenv($value); + } + else { + putenv($key); + } } }