From 28b08cec0c790b7dfa78dcb19931ed00fe14dd52 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 12:55:52 +0100 Subject: [PATCH 01/44] Reorganize tests to be PSR4 compliant --- tests/Integration/Blocks/RecommendationsBlockTest.php | 2 +- .../ContentHelperDashboardWidgetTest.php | 2 +- .../ContentHelperEditorSidebarTest.php | 2 +- .../{ => ContentHelper}/ContentHelperFeatureTest.php | 4 ++-- .../ContentHelperPostListStatsTest.php | 3 +-- .../{ => Proxy}/AnalyticsPostsProxyEndpointTest.php | 6 +++--- .../Proxy/BaseProxyEndpointTest.php} | 5 +++-- .../{ => Proxy}/ReferrersPostDetailProxyEndpointTest.php | 5 +++-- .../Endpoints/{ => Proxy}/RelatedProxyEndpointTest.php | 5 +++-- .../{ => Proxy}/StatsPostDetailProxyEndpointTest.php | 7 ++++--- .../UserMeta}/BaseUserMetaEndpointTest.php | 5 +++-- .../DashboardWidgetSettingsEndpointTest.php | 4 +--- .../{ => UserMeta}/EditorSidebarSettingsEndpointTest.php | 4 +--- tests/Integration/Metadata/AuthorArchiveTest.php | 2 +- tests/Integration/Metadata/BlogArchiveTest.php | 2 +- tests/Integration/Metadata/CustomPostTypeArchiveTest.php | 2 +- .../Metadata/CustomTaxonomyTermArchiveTest.php | 2 +- tests/Integration/Metadata/DateArchiveTest.php | 2 +- tests/Integration/Metadata/GetCurrentUrlTest.php | 3 ++- tests/Integration/Metadata/HomePageTest.php | 2 +- tests/Integration/Metadata/NonPostTestCase.php | 2 +- tests/Integration/Metadata/SinglePageTest.php | 2 +- tests/Integration/Metadata/SinglePostTest.php | 2 +- tests/Integration/Metadata/TermArchiveTest.php | 2 +- .../RemoteAPI/AnalyticsPostsRemoteAPITest.php | 4 ++-- .../BaseRemoteAPITest.php} | 7 ++++--- .../BaseContentSuggestionsAPITest.php | 4 ++-- .../SuggestBriefAPITest.php | 0 .../SuggestHeadlineAPITest.php | 0 .../SuggestLinkedReferenceAPITest.php | 0 tests/Integration/RemoteAPI/RelatedRemoteAPITest.php | 4 ++-- tests/Integration/TestCase.php | 9 ++++----- tests/Integration/bootstrap.php | 2 +- .../TestsReflection.php} | 4 ++-- tests/Unit/Utils/UtilsTest.php | 2 +- tests/Unit/bootstrap.php | 2 +- 36 files changed, 58 insertions(+), 57 deletions(-) rename tests/Integration/{content-helper => ContentHelper}/ContentHelperDashboardWidgetTest.php (98%) rename tests/Integration/{content-helper => ContentHelper}/ContentHelperEditorSidebarTest.php (96%) rename tests/Integration/{ => ContentHelper}/ContentHelperFeatureTest.php (99%) rename tests/Integration/{content-helper => ContentHelper}/ContentHelperPostListStatsTest.php (99%) rename tests/Integration/Endpoints/{ => Proxy}/AnalyticsPostsProxyEndpointTest.php (98%) rename tests/Integration/{ProxyEndpointTest.php => Endpoints/Proxy/BaseProxyEndpointTest.php} (97%) rename tests/Integration/Endpoints/{ => Proxy}/ReferrersPostDetailProxyEndpointTest.php (98%) rename tests/Integration/Endpoints/{ => Proxy}/RelatedProxyEndpointTest.php (96%) rename tests/Integration/Endpoints/{ => Proxy}/StatsPostDetailProxyEndpointTest.php (97%) rename tests/Integration/{ => Endpoints/UserMeta}/BaseUserMetaEndpointTest.php (95%) rename tests/Integration/Endpoints/{ => UserMeta}/DashboardWidgetSettingsEndpointTest.php (98%) rename tests/Integration/Endpoints/{ => UserMeta}/EditorSidebarSettingsEndpointTest.php (99%) rename tests/Integration/{RemoteAPITest.php => RemoteAPI/BaseRemoteAPITest.php} (97%) rename tests/Integration/RemoteAPI/{content-suggestions => ContentSuggestions}/BaseContentSuggestionsAPITest.php (96%) rename tests/Integration/RemoteAPI/{content-suggestions => ContentSuggestions}/SuggestBriefAPITest.php (100%) rename tests/Integration/RemoteAPI/{content-suggestions => ContentSuggestions}/SuggestHeadlineAPITest.php (100%) rename tests/Integration/RemoteAPI/{content-suggestions => ContentSuggestions}/SuggestLinkedReferenceAPITest.php (100%) rename tests/{trait-tests-reflection.php => Traits/TestsReflection.php} (96%) diff --git a/tests/Integration/Blocks/RecommendationsBlockTest.php b/tests/Integration/Blocks/RecommendationsBlockTest.php index 32039da0b3..3fc86a4d19 100644 --- a/tests/Integration/Blocks/RecommendationsBlockTest.php +++ b/tests/Integration/Blocks/RecommendationsBlockTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Blocks; +namespace Parsely\Tests\Integration\Blocks; use Parsely\Recommendations_Block; use Parsely\Tests\Integration\TestCase; diff --git a/tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php b/tests/Integration/ContentHelper/ContentHelperDashboardWidgetTest.php similarity index 98% rename from tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php rename to tests/Integration/ContentHelper/ContentHelperDashboardWidgetTest.php index 13032d1311..9d34215bb7 100644 --- a/tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php +++ b/tests/Integration/ContentHelper/ContentHelperDashboardWidgetTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\ContentHelper; +namespace Parsely\Tests\Integration\ContentHelper; use Parsely\Content_Helper\Dashboard_Widget; use Parsely\Parsely; diff --git a/tests/Integration/content-helper/ContentHelperEditorSidebarTest.php b/tests/Integration/ContentHelper/ContentHelperEditorSidebarTest.php similarity index 96% rename from tests/Integration/content-helper/ContentHelperEditorSidebarTest.php rename to tests/Integration/ContentHelper/ContentHelperEditorSidebarTest.php index 282d2eae0e..1fda7a1fb4 100644 --- a/tests/Integration/content-helper/ContentHelperEditorSidebarTest.php +++ b/tests/Integration/ContentHelper/ContentHelperEditorSidebarTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\ContentHelper; +namespace Parsely\Tests\Integration\ContentHelper; use Parsely\Content_Helper\Editor_Sidebar; use Parsely\Parsely; diff --git a/tests/Integration/ContentHelperFeatureTest.php b/tests/Integration/ContentHelper/ContentHelperFeatureTest.php similarity index 99% rename from tests/Integration/ContentHelperFeatureTest.php rename to tests/Integration/ContentHelper/ContentHelperFeatureTest.php index b250e2f863..2781a66b52 100644 --- a/tests/Integration/ContentHelperFeatureTest.php +++ b/tests/Integration/ContentHelper/ContentHelperFeatureTest.php @@ -8,10 +8,10 @@ declare(strict_types=1); -namespace Parsely\Tests\ContentHelper; +namespace Parsely\Tests\Integration\ContentHelper; -use Parsely\Tests\Integration\TestCase; use Parsely\Content_Helper\Content_Helper_Feature; +use Parsely\Tests\Integration\TestCase; /** * Base class for all Content Helper feature integration tests. diff --git a/tests/Integration/content-helper/ContentHelperPostListStatsTest.php b/tests/Integration/ContentHelper/ContentHelperPostListStatsTest.php similarity index 99% rename from tests/Integration/content-helper/ContentHelperPostListStatsTest.php rename to tests/Integration/ContentHelper/ContentHelperPostListStatsTest.php index 7070e67eb1..89ddacd256 100644 --- a/tests/Integration/content-helper/ContentHelperPostListStatsTest.php +++ b/tests/Integration/ContentHelper/ContentHelperPostListStatsTest.php @@ -7,13 +7,12 @@ declare(strict_types=1); -namespace Parsely\Tests\ContentHelper; +namespace Parsely\Tests\Integration\ContentHelper; use Mockery; use Parsely\Content_Helper\Post_List_Stats; use Parsely\Parsely; use Parsely\RemoteAPI\Analytics_Posts_API; -use Parsely\Tests\ContentHelper\ContentHelperFeatureTest; use Parsely\Tests\Integration\TestCase; use WP_Error; use WP_Post; diff --git a/tests/Integration/Endpoints/AnalyticsPostsProxyEndpointTest.php b/tests/Integration/Endpoints/Proxy/AnalyticsPostsProxyEndpointTest.php similarity index 98% rename from tests/Integration/Endpoints/AnalyticsPostsProxyEndpointTest.php rename to tests/Integration/Endpoints/Proxy/AnalyticsPostsProxyEndpointTest.php index 19d6170ff8..42a7dcf6a0 100644 --- a/tests/Integration/Endpoints/AnalyticsPostsProxyEndpointTest.php +++ b/tests/Integration/Endpoints/Proxy/AnalyticsPostsProxyEndpointTest.php @@ -8,21 +8,21 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\Endpoints\Proxy; use Parsely\Endpoints\Analytics_Posts_API_Proxy; use Parsely\Endpoints\Base_API_Proxy; use Parsely\Parsely; use Parsely\RemoteAPI\Analytics_Posts_API; +use Parsely\Tests\Integration\TestCase; use WP_Error; use WP_REST_Request; - use function Parsely\Utils\get_date_format; /** * Integration Tests for the Analytics Posts API Proxy Endpoint. */ -final class AnalyticsPostsProxyEndpointTest extends ProxyEndpointTest { +final class AnalyticsPostsProxyEndpointTest extends BaseProxyEndpointTest { /** * Initializes all required values for the test. diff --git a/tests/Integration/ProxyEndpointTest.php b/tests/Integration/Endpoints/Proxy/BaseProxyEndpointTest.php similarity index 97% rename from tests/Integration/ProxyEndpointTest.php rename to tests/Integration/Endpoints/Proxy/BaseProxyEndpointTest.php index 030871970f..d4a9ad9fe8 100644 --- a/tests/Integration/ProxyEndpointTest.php +++ b/tests/Integration/Endpoints/Proxy/BaseProxyEndpointTest.php @@ -8,11 +8,12 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\Endpoints\Proxy; use Parsely\Endpoints\Base_API_Proxy; use Parsely\Endpoints\User_Meta\Base_Endpoint_User_Meta; use Parsely\Parsely; +use Parsely\Tests\Integration\TestCase; use WP_Error; use WP_REST_Request; use WP_REST_Server; @@ -22,7 +23,7 @@ * * @phpstan-import-type Parsely_Options from Parsely */ -abstract class ProxyEndpointTest extends TestCase { +abstract class BaseProxyEndpointTest extends TestCase { /** * Holds a reference to the global $wp_rest_server object to restore in diff --git a/tests/Integration/Endpoints/ReferrersPostDetailProxyEndpointTest.php b/tests/Integration/Endpoints/Proxy/ReferrersPostDetailProxyEndpointTest.php similarity index 98% rename from tests/Integration/Endpoints/ReferrersPostDetailProxyEndpointTest.php rename to tests/Integration/Endpoints/Proxy/ReferrersPostDetailProxyEndpointTest.php index eac7f0429a..d126316bf9 100644 --- a/tests/Integration/Endpoints/ReferrersPostDetailProxyEndpointTest.php +++ b/tests/Integration/Endpoints/Proxy/ReferrersPostDetailProxyEndpointTest.php @@ -8,18 +8,19 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\Endpoints\Proxy; use Parsely\Endpoints\Base_API_Proxy; use Parsely\Endpoints\Referrers_Post_Detail_API_Proxy; use Parsely\Parsely; use Parsely\RemoteAPI\Referrers_Post_Detail_API; +use Parsely\Tests\Integration\TestCase; use WP_REST_Request; /** * Integration Tests for the Referrers Post Detail API Proxy Endpoint. */ -final class ReferrersPostDetailProxyEndpointTest extends ProxyEndpointTest { +final class ReferrersPostDetailProxyEndpointTest extends BaseProxyEndpointTest { /** * Initializes all required values for the test. diff --git a/tests/Integration/Endpoints/RelatedProxyEndpointTest.php b/tests/Integration/Endpoints/Proxy/RelatedProxyEndpointTest.php similarity index 96% rename from tests/Integration/Endpoints/RelatedProxyEndpointTest.php rename to tests/Integration/Endpoints/Proxy/RelatedProxyEndpointTest.php index d576f3bc76..7584fa597d 100644 --- a/tests/Integration/Endpoints/RelatedProxyEndpointTest.php +++ b/tests/Integration/Endpoints/Proxy/RelatedProxyEndpointTest.php @@ -7,18 +7,19 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\Endpoints\Proxy; use Parsely\Endpoints\Base_API_Proxy; use Parsely\Endpoints\Related_API_Proxy; use Parsely\Parsely; use Parsely\RemoteAPI\Related_API; +use Parsely\Tests\Integration\TestCase; use WP_REST_Request; /** * Integration Tests for the Related API Proxy Endpoint. */ -final class RelatedProxyEndpointTest extends ProxyEndpointTest { +final class RelatedProxyEndpointTest extends BaseProxyEndpointTest { /** * Initializes all required values for the test. diff --git a/tests/Integration/Endpoints/StatsPostDetailProxyEndpointTest.php b/tests/Integration/Endpoints/Proxy/StatsPostDetailProxyEndpointTest.php similarity index 97% rename from tests/Integration/Endpoints/StatsPostDetailProxyEndpointTest.php rename to tests/Integration/Endpoints/Proxy/StatsPostDetailProxyEndpointTest.php index 67280bac24..12d5bddd6b 100644 --- a/tests/Integration/Endpoints/StatsPostDetailProxyEndpointTest.php +++ b/tests/Integration/Endpoints/Proxy/StatsPostDetailProxyEndpointTest.php @@ -8,18 +8,19 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\Endpoints\Proxy; -use Parsely\Endpoints\Base_API_Proxy; use Parsely\Endpoints\Analytics_Post_Detail_API_Proxy; +use Parsely\Endpoints\Base_API_Proxy; use Parsely\Parsely; use Parsely\RemoteAPI\Analytics_Post_Detail_API; +use Parsely\Tests\Integration\TestCase; use WP_REST_Request; /** * Integration Tests for the Stats Post Detail API Proxy Endpoint. */ -final class StatsPostDetailProxyEndpointTest extends ProxyEndpointTest { +final class StatsPostDetailProxyEndpointTest extends BaseProxyEndpointTest { /** * Initializes all required values for the test. diff --git a/tests/Integration/BaseUserMetaEndpointTest.php b/tests/Integration/Endpoints/UserMeta/BaseUserMetaEndpointTest.php similarity index 95% rename from tests/Integration/BaseUserMetaEndpointTest.php rename to tests/Integration/Endpoints/UserMeta/BaseUserMetaEndpointTest.php index a32e32cc38..748c405e92 100644 --- a/tests/Integration/BaseUserMetaEndpointTest.php +++ b/tests/Integration/Endpoints/UserMeta/BaseUserMetaEndpointTest.php @@ -8,8 +8,9 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\Endpoints\UserMeta; +use Parsely\Tests\Integration\Endpoints\Proxy\BaseProxyEndpointTest; use WP_REST_Request; /** @@ -17,7 +18,7 @@ * * @since 3.13.0 */ -abstract class BaseUserMetaEndpointTest extends ProxyEndpointTest { +abstract class BaseUserMetaEndpointTest extends BaseProxyEndpointTest { /** * The endpoint's default value. * diff --git a/tests/Integration/Endpoints/DashboardWidgetSettingsEndpointTest.php b/tests/Integration/Endpoints/UserMeta/DashboardWidgetSettingsEndpointTest.php similarity index 98% rename from tests/Integration/Endpoints/DashboardWidgetSettingsEndpointTest.php rename to tests/Integration/Endpoints/UserMeta/DashboardWidgetSettingsEndpointTest.php index 401781bf11..91fdccca48 100644 --- a/tests/Integration/Endpoints/DashboardWidgetSettingsEndpointTest.php +++ b/tests/Integration/Endpoints/UserMeta/DashboardWidgetSettingsEndpointTest.php @@ -8,13 +8,11 @@ declare(strict_types=1); -namespace Parsely\Tests\ContentHelper; +namespace Parsely\Tests\Integration\Endpoints\UserMeta; use Parsely\Endpoints\User_Meta\Base_Endpoint_User_Meta; use Parsely\Endpoints\User_Meta\Dashboard_Widget_Settings_Endpoint; use Parsely\Parsely; -use Parsely\Tests\Integration\BaseUserMetaEndpointTest; - use function Parsely\Utils\convert_endpoint_to_filter_key; /** diff --git a/tests/Integration/Endpoints/EditorSidebarSettingsEndpointTest.php b/tests/Integration/Endpoints/UserMeta/EditorSidebarSettingsEndpointTest.php similarity index 99% rename from tests/Integration/Endpoints/EditorSidebarSettingsEndpointTest.php rename to tests/Integration/Endpoints/UserMeta/EditorSidebarSettingsEndpointTest.php index 4eef9d0d7a..3be4b56895 100644 --- a/tests/Integration/Endpoints/EditorSidebarSettingsEndpointTest.php +++ b/tests/Integration/Endpoints/UserMeta/EditorSidebarSettingsEndpointTest.php @@ -8,13 +8,11 @@ declare(strict_types=1); -namespace Parsely\Tests\ContentHelper; +namespace Parsely\Tests\Integration\Endpoints\UserMeta; use Parsely\Endpoints\User_Meta\Base_Endpoint_User_Meta; use Parsely\Endpoints\User_Meta\Editor_Sidebar_Settings_Endpoint; use Parsely\Parsely; -use Parsely\Tests\Integration\BaseUserMetaEndpointTest; - use function Parsely\Utils\convert_endpoint_to_filter_key; /** diff --git a/tests/Integration/Metadata/AuthorArchiveTest.php b/tests/Integration/Metadata/AuthorArchiveTest.php index 082ab15a2c..089abc3cdc 100644 --- a/tests/Integration/Metadata/AuthorArchiveTest.php +++ b/tests/Integration/Metadata/AuthorArchiveTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata; use Parsely\Parsely; diff --git a/tests/Integration/Metadata/BlogArchiveTest.php b/tests/Integration/Metadata/BlogArchiveTest.php index 73fc4c6d78..c42346812d 100644 --- a/tests/Integration/Metadata/BlogArchiveTest.php +++ b/tests/Integration/Metadata/BlogArchiveTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata; use Parsely\Parsely; diff --git a/tests/Integration/Metadata/CustomPostTypeArchiveTest.php b/tests/Integration/Metadata/CustomPostTypeArchiveTest.php index 6c30b2ef11..a9d3327d04 100644 --- a/tests/Integration/Metadata/CustomPostTypeArchiveTest.php +++ b/tests/Integration/Metadata/CustomPostTypeArchiveTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata; use Parsely\Parsely; diff --git a/tests/Integration/Metadata/CustomTaxonomyTermArchiveTest.php b/tests/Integration/Metadata/CustomTaxonomyTermArchiveTest.php index d8b9696496..869ac5a31d 100644 --- a/tests/Integration/Metadata/CustomTaxonomyTermArchiveTest.php +++ b/tests/Integration/Metadata/CustomTaxonomyTermArchiveTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata; use Parsely\Parsely; diff --git a/tests/Integration/Metadata/DateArchiveTest.php b/tests/Integration/Metadata/DateArchiveTest.php index 1c00da5022..49fd73a80a 100644 --- a/tests/Integration/Metadata/DateArchiveTest.php +++ b/tests/Integration/Metadata/DateArchiveTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Tests\Integration\TestCase; use Parsely\Metadata\Date_Builder; diff --git a/tests/Integration/Metadata/GetCurrentUrlTest.php b/tests/Integration/Metadata/GetCurrentUrlTest.php index fef56e32a6..d9f2390344 100644 --- a/tests/Integration/Metadata/GetCurrentUrlTest.php +++ b/tests/Integration/Metadata/GetCurrentUrlTest.php @@ -7,10 +7,11 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata\Front_Page_Builder; use Parsely\Parsely; +use Parsely\Tests\Integration\TestCase; /** * Integration Tests for \Parsely\MetadataMetadata_Builder->get_current_url(). diff --git a/tests/Integration/Metadata/HomePageTest.php b/tests/Integration/Metadata/HomePageTest.php index 0c2a4a3676..8373503b22 100644 --- a/tests/Integration/Metadata/HomePageTest.php +++ b/tests/Integration/Metadata/HomePageTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata; use Parsely\Parsely; diff --git a/tests/Integration/Metadata/NonPostTestCase.php b/tests/Integration/Metadata/NonPostTestCase.php index 44d0870161..71e873e2b4 100644 --- a/tests/Integration/Metadata/NonPostTestCase.php +++ b/tests/Integration/Metadata/NonPostTestCase.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Tests\Integration\TestCase; diff --git a/tests/Integration/Metadata/SinglePageTest.php b/tests/Integration/Metadata/SinglePageTest.php index 7afc846001..02b816ec90 100644 --- a/tests/Integration/Metadata/SinglePageTest.php +++ b/tests/Integration/Metadata/SinglePageTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata; use Parsely\Parsely; diff --git a/tests/Integration/Metadata/SinglePostTest.php b/tests/Integration/Metadata/SinglePostTest.php index 005538d2af..d249fb7796 100644 --- a/tests/Integration/Metadata/SinglePostTest.php +++ b/tests/Integration/Metadata/SinglePostTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata; use Parsely\Parsely; diff --git a/tests/Integration/Metadata/TermArchiveTest.php b/tests/Integration/Metadata/TermArchiveTest.php index 497723faab..8541f7cfb4 100644 --- a/tests/Integration/Metadata/TermArchiveTest.php +++ b/tests/Integration/Metadata/TermArchiveTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration\StructuredData; +namespace Parsely\Tests\Integration\Metadata; use Parsely\Metadata; use Parsely\Parsely; diff --git a/tests/Integration/RemoteAPI/AnalyticsPostsRemoteAPITest.php b/tests/Integration/RemoteAPI/AnalyticsPostsRemoteAPITest.php index c3f75b3e3b..f1f14bbf3c 100644 --- a/tests/Integration/RemoteAPI/AnalyticsPostsRemoteAPITest.php +++ b/tests/Integration/RemoteAPI/AnalyticsPostsRemoteAPITest.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\RemoteAPI; use Parsely\Parsely; use Parsely\RemoteAPI\Analytics_Posts_API; @@ -16,7 +16,7 @@ /** * Integration Tests for the Parsely `/analytics/posts` Remote API. */ -final class AnalyticsPostsRemoteAPITest extends RemoteAPITest { +final class AnalyticsPostsRemoteAPITest extends BaseRemoteAPITest { /** * Initializes all required values for the test. diff --git a/tests/Integration/RemoteAPITest.php b/tests/Integration/RemoteAPI/BaseRemoteAPITest.php similarity index 97% rename from tests/Integration/RemoteAPITest.php rename to tests/Integration/RemoteAPI/BaseRemoteAPITest.php index 9b8f5b84af..6f978d11c8 100644 --- a/tests/Integration/RemoteAPITest.php +++ b/tests/Integration/RemoteAPI/BaseRemoteAPITest.php @@ -8,16 +8,17 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\RemoteAPI; -use Parsely\RemoteAPI\Cache; use Parsely\RemoteAPI\Base_Endpoint_Remote; +use Parsely\RemoteAPI\Cache; use Parsely\RemoteAPI\Remote_API_Cache; +use Parsely\Tests\Integration\TestCase; /** * Integration Tests for the Parse.ly Remote API. */ -abstract class RemoteAPITest extends TestCase { +abstract class BaseRemoteAPITest extends TestCase { /** * Internal variable. * diff --git a/tests/Integration/RemoteAPI/content-suggestions/BaseContentSuggestionsAPITest.php b/tests/Integration/RemoteAPI/ContentSuggestions/BaseContentSuggestionsAPITest.php similarity index 96% rename from tests/Integration/RemoteAPI/content-suggestions/BaseContentSuggestionsAPITest.php rename to tests/Integration/RemoteAPI/ContentSuggestions/BaseContentSuggestionsAPITest.php index b472a0dc7e..708b08a6c7 100644 --- a/tests/Integration/RemoteAPI/content-suggestions/BaseContentSuggestionsAPITest.php +++ b/tests/Integration/RemoteAPI/ContentSuggestions/BaseContentSuggestionsAPITest.php @@ -9,14 +9,14 @@ namespace Parsely\Tests\Integration\RemoteAPI\ContentSuggestions; use Parsely\RemoteAPI\ContentSuggestions\Content_Suggestions_Base_API; -use Parsely\Tests\Integration\RemoteAPITest; +use Parsely\Tests\Integration\RemoteAPI\BaseRemoteAPITest; /** * Integration Tests for the Parse.ly Content Suggestions API endpoints. * * @since 3.14.0 */ -abstract class BaseContentSuggestionsAPITest extends RemoteAPITest { +abstract class BaseContentSuggestionsAPITest extends BaseRemoteAPITest { /** * Verifies the basic generation of the API headers. * diff --git a/tests/Integration/RemoteAPI/content-suggestions/SuggestBriefAPITest.php b/tests/Integration/RemoteAPI/ContentSuggestions/SuggestBriefAPITest.php similarity index 100% rename from tests/Integration/RemoteAPI/content-suggestions/SuggestBriefAPITest.php rename to tests/Integration/RemoteAPI/ContentSuggestions/SuggestBriefAPITest.php diff --git a/tests/Integration/RemoteAPI/content-suggestions/SuggestHeadlineAPITest.php b/tests/Integration/RemoteAPI/ContentSuggestions/SuggestHeadlineAPITest.php similarity index 100% rename from tests/Integration/RemoteAPI/content-suggestions/SuggestHeadlineAPITest.php rename to tests/Integration/RemoteAPI/ContentSuggestions/SuggestHeadlineAPITest.php diff --git a/tests/Integration/RemoteAPI/content-suggestions/SuggestLinkedReferenceAPITest.php b/tests/Integration/RemoteAPI/ContentSuggestions/SuggestLinkedReferenceAPITest.php similarity index 100% rename from tests/Integration/RemoteAPI/content-suggestions/SuggestLinkedReferenceAPITest.php rename to tests/Integration/RemoteAPI/ContentSuggestions/SuggestLinkedReferenceAPITest.php diff --git a/tests/Integration/RemoteAPI/RelatedRemoteAPITest.php b/tests/Integration/RemoteAPI/RelatedRemoteAPITest.php index 885e71f0f6..52c4ab80d4 100644 --- a/tests/Integration/RemoteAPI/RelatedRemoteAPITest.php +++ b/tests/Integration/RemoteAPI/RelatedRemoteAPITest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Integration; +namespace Parsely\Tests\Integration\RemoteAPI; use Parsely\Parsely; use Parsely\RemoteAPI\Related_API; @@ -15,7 +15,7 @@ /** * Integration Tests for the Parsely `/related` Remote API. */ -final class RelatedRemoteAPITest extends RemoteAPITest { +final class RelatedRemoteAPITest extends BaseRemoteAPITest { /** * Initializes all required values for the test. diff --git a/tests/Integration/TestCase.php b/tests/Integration/TestCase.php index 50672a8800..9d2d0de925 100644 --- a/tests/Integration/TestCase.php +++ b/tests/Integration/TestCase.php @@ -12,18 +12,17 @@ use DateInterval; use DateTime; use DateTimeZone; -use ReflectionClass; -use ReflectionProperty; -use ReflectionMethod; use Parsely\Parsely; use PHPUnit\Framework\RiskyTestError; +use ReflectionClass; +use ReflectionMethod; +use ReflectionProperty; use UnexpectedValueException; use WP_Error; use WP_Post; use WP_REST_Request; use WP_Term; use Yoast\WPTestUtils\WPIntegration\TestCase as WPIntegrationTestCase; - use const Parsely\Utils\WP_DATE_TIME_FORMAT; /** @@ -33,7 +32,7 @@ */ abstract class TestCase extends WPIntegrationTestCase { - use \Parsely\Tests\Tests_Reflection; + use \Parsely\Tests\Traits\TestsReflection; public const VALID_SITE_ID = 'demoaccount.parsely.com'; diff --git a/tests/Integration/bootstrap.php b/tests/Integration/bootstrap.php index 72a2cabad3..e52cfbcec5 100644 --- a/tests/Integration/bootstrap.php +++ b/tests/Integration/bootstrap.php @@ -47,7 +47,7 @@ } // Additional necessary requires. - require_once dirname( __DIR__ ) . '/trait-tests-reflection.php'; + require_once dirname( __DIR__ ) . '/Traits/TestsReflection.php'; require_once __DIR__ . '/TestCase.php'; require_once __DIR__ . '/Metadata/NonPostTestCase.php'; } diff --git a/tests/trait-tests-reflection.php b/tests/Traits/TestsReflection.php similarity index 96% rename from tests/trait-tests-reflection.php rename to tests/Traits/TestsReflection.php index bca4a6e620..5223b4b0e0 100644 --- a/tests/trait-tests-reflection.php +++ b/tests/Traits/TestsReflection.php @@ -7,13 +7,13 @@ declare(strict_types=1); -namespace Parsely\Tests; +namespace Parsely\Tests\Traits; use Parsely\Parsely; use ReflectionException; use ReflectionMethod; -trait Tests_Reflection { +trait TestsReflection { /** * Gets a method from a class. This should be used when trying to access a * private method for testing. diff --git a/tests/Unit/Utils/UtilsTest.php b/tests/Unit/Utils/UtilsTest.php index 209d4780e4..0ae2d7ba1b 100644 --- a/tests/Unit/Utils/UtilsTest.php +++ b/tests/Unit/Utils/UtilsTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Parsely\Tests\Unit; +namespace Parsely\Tests\Unit\Utils; use Yoast\WPTestUtils\BrainMonkey\TestCase; diff --git a/tests/Unit/bootstrap.php b/tests/Unit/bootstrap.php index 9c9db8b931..ad94bd1dd7 100644 --- a/tests/Unit/bootstrap.php +++ b/tests/Unit/bootstrap.php @@ -10,7 +10,7 @@ // phpcs:ignore Universal.Namespaces.DisallowCurlyBraceSyntax.Forbidden namespace Parsely\Tests\Unit { // Require any necessary files and autoload the plugin code. - require_once dirname( __DIR__ ) . '/trait-tests-reflection.php'; + require_once dirname( __DIR__ ) . '/Traits/TestsReflection.php'; require_once dirname( __DIR__ ) . '/../vendor/yoast/wp-test-utils/src/BrainMonkey/bootstrap.php'; require_once dirname( __DIR__ ) . '/../vendor/autoload.php'; } From ce7e72ed31ead2da87458d419b2e59d3b943ec17 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 12:57:30 +0100 Subject: [PATCH 02/44] Remove unnecessary imports --- tests/Integration/bootstrap.php | 5 ----- tests/Unit/bootstrap.php | 1 - 2 files changed, 6 deletions(-) diff --git a/tests/Integration/bootstrap.php b/tests/Integration/bootstrap.php index e52cfbcec5..5c373d015e 100644 --- a/tests/Integration/bootstrap.php +++ b/tests/Integration/bootstrap.php @@ -45,11 +45,6 @@ echo PHP_EOL, 'ERROR: Please check whether the WP_PLUGIN_DIR environment variable is set and set to the correct value. The unit test suite won\'t be able to run without it.', PHP_EOL; exit( 1 ); } - - // Additional necessary requires. - require_once dirname( __DIR__ ) . '/Traits/TestsReflection.php'; - require_once __DIR__ . '/TestCase.php'; - require_once __DIR__ . '/Metadata/NonPostTestCase.php'; } // Plugin root file is not included during tests, so define the namespaced diff --git a/tests/Unit/bootstrap.php b/tests/Unit/bootstrap.php index ad94bd1dd7..df68dc67f1 100644 --- a/tests/Unit/bootstrap.php +++ b/tests/Unit/bootstrap.php @@ -10,7 +10,6 @@ // phpcs:ignore Universal.Namespaces.DisallowCurlyBraceSyntax.Forbidden namespace Parsely\Tests\Unit { // Require any necessary files and autoload the plugin code. - require_once dirname( __DIR__ ) . '/Traits/TestsReflection.php'; require_once dirname( __DIR__ ) . '/../vendor/yoast/wp-test-utils/src/BrainMonkey/bootstrap.php'; require_once dirname( __DIR__ ) . '/../vendor/autoload.php'; } From 73a62e66dbb307c529213ce67dc418cc57537de6 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 13:11:24 +0100 Subject: [PATCH 03/44] Enable composer autoload for the source files --- .github/workflows/deploy.yml | 1 + .github/workflows/e2e-tests.yml | 3 + composer.json | 3 - wp-parsely.php | 114 +++++--------------------------- 4 files changed, 22 insertions(+), 99 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ca3d7f89a3..d9b42ffb01 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,6 +10,7 @@ jobs: run: | npm ci npm run build + composer dump-autoload --classmap-authoritative - name: WordPress Plugin Deploy uses: 10up/action-wordpress-plugin-deploy@stable env: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 1202e6e67e..7a74bc7cb0 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -23,6 +23,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Refresh Composer autoload files + run: composer dump-autoload --classmap-authoritative + - name: Use desired version of NodeJS uses: actions/setup-node@v4.0.2 with: diff --git a/composer.json b/composer.json index 19166b64db..6ef1f3791c 100644 --- a/composer.json +++ b/composer.json @@ -42,9 +42,6 @@ "autoload": { "classmap": [ "src/" - ], - "files": [ - "wp-parsely.php" ] }, "autoload-dev": { diff --git a/wp-parsely.php b/wp-parsely.php index e2fd4962ce..62befc0ac0 100644 --- a/wp-parsely.php +++ b/wp-parsely.php @@ -64,7 +64,7 @@ use Parsely\UI\Settings_Page; use Parsely\UI\Site_Health; -require_once __DIR__ . '/src/Utils/utils.php'; +require_once __DIR__ . '/src/Utils/utils.php'; // TODO: refactor to use autoloader. if ( class_exists( Parsely::class ) ) { return; @@ -73,34 +73,10 @@ const PARSELY_VERSION = '3.16.0'; const PARSELY_FILE = __FILE__; -require_once __DIR__ . '/src/Models/class-base-model.php'; -require_once __DIR__ . '/src/Models/class-smart-link.php'; -require_once __DIR__ . '/src/Models/class-inbound-smart-link.php'; - -require_once __DIR__ . '/src/class-parsely.php'; -require_once __DIR__ . '/src/class-permissions.php'; -require_once __DIR__ . '/src/class-scripts.php'; -require_once __DIR__ . '/src/class-dashboard-link.php'; -require_once __DIR__ . '/src/class-validator.php'; -require_once __DIR__ . '/src/UI/class-admin-bar.php'; -require_once __DIR__ . '/src/UI/class-metadata-renderer.php'; -require_once __DIR__ . '/src/Endpoints/class-metadata-endpoint.php'; -require_once __DIR__ . '/src/Endpoints/class-graphql-metadata.php'; -require_once __DIR__ . '/src/Telemetry/telemetry-init.php'; - -require_once __DIR__ . '/src/class-metadata.php'; -require_once __DIR__ . '/src/Metadata/class-metadata-builder.php'; -require_once __DIR__ . '/src/Metadata/class-author-archive-builder.php'; -require_once __DIR__ . '/src/Metadata/class-category-builder.php'; -require_once __DIR__ . '/src/Metadata/class-date-builder.php'; -require_once __DIR__ . '/src/Metadata/class-front-page-builder.php'; -require_once __DIR__ . '/src/Metadata/class-page-builder.php'; -require_once __DIR__ . '/src/Metadata/class-page-for-posts-builder.php'; -require_once __DIR__ . '/src/Metadata/class-paginated-front-page-builder.php'; -require_once __DIR__ . '/src/Metadata/class-post-builder.php'; -require_once __DIR__ . '/src/Metadata/class-tag-builder.php'; +if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { + require __DIR__ . '/vendor/autoload.php'; +} -add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' ); /** * Registers the basic classes to initialize the plugin. */ @@ -122,16 +98,9 @@ function parsely_initialize_plugin(): void { $metadata_renderer = new Metadata_Renderer( $GLOBALS['parsely'] ); $metadata_renderer->run(); } +add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' ); -require_once __DIR__ . '/src/content-helper/common/class-content-helper-feature.php'; -require_once __DIR__ . '/src/content-helper/post-list-stats/class-post-list-stats.php'; -require_once __DIR__ . '/src/UI/class-admin-warning.php'; -require_once __DIR__ . '/src/UI/class-plugins-actions.php'; -require_once __DIR__ . '/src/UI/class-row-actions.php'; -require_once __DIR__ . '/src/UI/class-site-health.php'; -require_once __DIR__ . '/src/content-helper/dashboard-widget/class-dashboard-widget.php'; -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' ); /** * Registers the Parse.ly wp-admin warnings, plugin actions and row actions. */ @@ -145,11 +114,9 @@ function parsely_admin_init_register(): void { ( new Site_Health( $parsely ) )->run(); ( new Dashboard_Widget( $parsely ) )->run(); } +add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' ); -require_once __DIR__ . '/src/UI/class-settings-page.php'; -require_once __DIR__ . '/src/UI/class-network-admin-sites-list.php'; -add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' ); /** * Registers the additions the Parse.ly wp-admin settings page and Multisite * Network Admin Sites List table. @@ -161,44 +128,8 @@ function parsely_wp_admin_early_register(): void { $network_admin_sites_list = new Network_Admin_Sites_List( $GLOBALS['parsely'] ); $network_admin_sites_list->run(); } +add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' ); -// Endpoint base classes. -require_once __DIR__ . '/src/Endpoints/class-base-endpoint.php'; -require_once __DIR__ . '/src/Endpoints/class-base-api-proxy.php'; -require_once __DIR__ . '/src/Endpoints/user-meta/class-base-endpoint-user-meta.php'; - -// Endpoint classes. -require_once __DIR__ . '/src/Endpoints/class-analytics-post-detail-api-proxy.php'; -require_once __DIR__ . '/src/Endpoints/class-analytics-posts-api-proxy.php'; -require_once __DIR__ . '/src/Endpoints/class-referrers-post-detail-api-proxy.php'; -require_once __DIR__ . '/src/Endpoints/class-related-api-proxy.php'; -require_once __DIR__ . '/src/Endpoints/class-rest-metadata.php'; -require_once __DIR__ . '/src/Endpoints/content-suggestions/class-suggest-brief-api-proxy.php'; -require_once __DIR__ . '/src/Endpoints/content-suggestions/class-suggest-headline-api-proxy.php'; -require_once __DIR__ . '/src/Endpoints/content-suggestions/class-suggest-linked-reference-api-proxy.php'; -require_once __DIR__ . '/src/Endpoints/user-meta/class-dashboard-widget-settings-endpoint.php'; -require_once __DIR__ . '/src/Endpoints/user-meta/class-editor-sidebar-settings-endpoint.php'; -require_once __DIR__ . '/src/Endpoints/content-helper/class-smart-linking-endpoint.php'; - -// RemoteAPI base classes. -require_once __DIR__ . '/src/RemoteAPI/interface-cache.php'; -require_once __DIR__ . '/src/RemoteAPI/interface-remote-api.php'; -require_once __DIR__ . '/src/RemoteAPI/class-remote-api-cache.php'; -require_once __DIR__ . '/src/RemoteAPI/class-wordpress-cache.php'; -require_once __DIR__ . '/src/RemoteAPI/class-base-endpoint-remote.php'; -require_once __DIR__ . '/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php'; - -// RemoteAPI classes. -require_once __DIR__ . '/src/RemoteAPI/class-analytics-post-detail-api.php'; -require_once __DIR__ . '/src/RemoteAPI/class-analytics-posts-api.php'; -require_once __DIR__ . '/src/RemoteAPI/class-referrers-post-detail-api.php'; -require_once __DIR__ . '/src/RemoteAPI/class-related-api.php'; -require_once __DIR__ . '/src/RemoteAPI/class-validate-api.php'; -require_once __DIR__ . '/src/RemoteAPI/content-suggestions/class-suggest-brief-api.php'; -require_once __DIR__ . '/src/RemoteAPI/content-suggestions/class-suggest-headline-api.php'; -require_once __DIR__ . '/src/RemoteAPI/content-suggestions/class-suggest-linked-reference-api.php'; - -add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' ); /** * Registers REST Endpoints that act as a proxy to the Parse.ly API. * This is needed to get around CORS issues with Firefox. @@ -259,10 +190,8 @@ function parsely_rest_api_init(): void { $wp_cache ); } +add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' ); -require_once __DIR__ . '/src/blocks/recommendations/class-recommendations-block.php'; - -add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' ); /** * Registers the Recommendations Block. */ @@ -270,10 +199,9 @@ function init_recommendations_block(): void { $recommendations_block = new Recommendations_Block(); $recommendations_block->run(); } +add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' ); -require_once __DIR__ . '/src/content-helper/editor-sidebar/class-editor-sidebar.php'; -add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_editor_sidebar' ); /** * Inserts the PCH Editor Sidebar. * @@ -283,11 +211,7 @@ function init_recommendations_block(): void { function init_content_helper_editor_sidebar(): void { $GLOBALS['parsely_editor_sidebar']->run(); } - -require_once __DIR__ . '/src/content-helper/excerpt-generator/class-excerpt-generator.php'; - -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' ); -add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' ); +add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_editor_sidebar' ); /** * Initializes the PCH Editor Sidebar features. @@ -305,8 +229,10 @@ function parsely_content_helper_editor_sidebar_features(): void { $GLOBALS['parsely_editor_sidebar']->init_features(); } -// The priority of 9 is used to ensure that the Excerpt Generator is loaded before the PCH Editor Sidebar (10). -add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_excerpt_generator', 9 ); +add_action( 'admin_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' ); +add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' ); + + /** * Initializes and inserts the PCH Excerpt Generator. * @@ -315,23 +241,18 @@ function parsely_content_helper_editor_sidebar_features(): void { function init_content_helper_excerpt_generator(): void { ( new Excerpt_Generator( $GLOBALS['parsely'] ) )->run(); } +// The priority of 9 is used to ensure that the Excerpt Generator is loaded before the PCH Editor Sidebar (10). +add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_excerpt_generator', 9 ); -require_once __DIR__ . '/src/UI/class-recommended-widget.php'; -add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' ); /** * Registers the Parse.ly Recommended widget. */ function parsely_recommended_widget_register(): void { register_widget( new Recommended_Widget( $GLOBALS['parsely'] ) ); } +add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' ); -require_once __DIR__ . '/src/Integrations/class-integration.php'; -require_once __DIR__ . '/src/Integrations/class-integrations.php'; -require_once __DIR__ . '/src/Integrations/class-amp.php'; -require_once __DIR__ . '/src/Integrations/class-google-web-stories.php'; - -add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); // @phpstan-ignore-line /** * Instantiates Integrations collection and registers built-in integrations. * @@ -356,6 +277,7 @@ function parsely_integrations( $parsely = null ): Integrations { return $parsely_integrations; } +add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); // @phpstan-ignore-line /** * Instantiates and runs the specified API endpoint. From c1c0821961a0d804269d98b90f01ee04fc0c72d8 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 13:27:21 +0100 Subject: [PATCH 04/44] Require utils file in the tests bootstrap file --- tests/Integration/bootstrap.php | 1 + tests/Unit/bootstrap.php | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/Integration/bootstrap.php b/tests/Integration/bootstrap.php index 5c373d015e..336f5164c7 100644 --- a/tests/Integration/bootstrap.php +++ b/tests/Integration/bootstrap.php @@ -40,6 +40,7 @@ * MockObject autoloader after that. */ WPIntegration\bootstrap_it(); + require_once dirname( __DIR__ ) . '/../src/Utils/utils.php'; // TODO: refactor to use autoloader. if ( ! defined( 'WP_PLUGIN_DIR' ) || file_exists( WP_PLUGIN_DIR . '/wp-parsely/wp-parsely.php' ) === false ) { echo PHP_EOL, 'ERROR: Please check whether the WP_PLUGIN_DIR environment variable is set and set to the correct value. The unit test suite won\'t be able to run without it.', PHP_EOL; diff --git a/tests/Unit/bootstrap.php b/tests/Unit/bootstrap.php index df68dc67f1..cb5f61de39 100644 --- a/tests/Unit/bootstrap.php +++ b/tests/Unit/bootstrap.php @@ -10,6 +10,7 @@ // phpcs:ignore Universal.Namespaces.DisallowCurlyBraceSyntax.Forbidden namespace Parsely\Tests\Unit { // Require any necessary files and autoload the plugin code. + require_once dirname( __DIR__ ) . '/../src/Utils/utils.php'; // TODO: refactor to use autoloader. require_once dirname( __DIR__ ) . '/../vendor/yoast/wp-test-utils/src/BrainMonkey/bootstrap.php'; require_once dirname( __DIR__ ) . '/../vendor/autoload.php'; } From 0a023a5d996b58c629791a77ef2c437f0d117bbd Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 15:17:00 +0100 Subject: [PATCH 05/44] Testing build step --- .github/workflows/build-and-deploy.yml | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/build-and-deploy.yml diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000000..fddf30cc6f --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,32 @@ +name: TEST Build and Deploy +on: workflow_dispatch +jobs: + build: + name: Build and Commit + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + + - name: Read .nvmrc + run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV + + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4.0.2 + with: + node-version: ${{ env.NODE_VERSION }} + cache: npm + + - name: Build + run: | + npm ci + npm run build + composer install --no-dev --optimize-autoloader --classmap-authoritative + + - name: Commit built files + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git checkout -b built-test + git add -A + git commit -m "Build plugin" + git push origin built-test From fcc0e915c643ab0468a0c80e0ab856b457d8b2b3 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 15:20:40 +0100 Subject: [PATCH 06/44] Making it run on PR --- .github/workflows/build-and-deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index fddf30cc6f..ae0f00a540 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -1,5 +1,7 @@ name: TEST Build and Deploy -on: workflow_dispatch +on: + workflow_dispatch: + pull_request: jobs: build: name: Build and Commit From d81d94b25743fd1304f86c7d77d0ff3f24f3ec46 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 15:24:13 +0100 Subject: [PATCH 07/44] Bypass commit hooks when committing to built branch --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index ae0f00a540..04bfd78051 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -30,5 +30,5 @@ jobs: git config --global user.email 'github-actions[bot]@users.noreply.github.com' git checkout -b built-test git add -A - git commit -m "Build plugin" + git commit -m "Build plugin" --no-verify git push origin built-test From 0cb7da7c3849f85c58dc40ab67547a3d67c8fd04 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 15:29:54 +0100 Subject: [PATCH 08/44] Include `vendor/` explicity on `git add` since it's on the gitignore file --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 04bfd78051..9378f66c93 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -29,6 +29,6 @@ jobs: git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git checkout -b built-test - git add -A + git add -Af vendor/ git commit -m "Build plugin" --no-verify git push origin built-test From 450d1594aa86315d96317c1cac33df665556ffdd Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 9 Jul 2024 16:09:47 +0100 Subject: [PATCH 09/44] Add Tag and Release step --- .github/workflows/build-and-deploy.yml | 44 +++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 9378f66c93..60b9ba0e19 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -29,6 +29,48 @@ jobs: git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git checkout -b built-test - git add -Af vendor/ + git add -Af vendor/autoload.php vendor/composer/ git commit -m "Build plugin" --no-verify git push origin built-test + tag_and_release: + name: Tag and Release + needs: build + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + + - name: Get version from package.json + id: get_version + run: | + VERSION=$(jq -r .version < package.json) + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "The version is $VERSION" + + - name: Extract Changelog + id: extract_changelog + run: | + VERSION=${{ env.VERSION }} + START_LINE=$(grep -n "## \[${VERSION}\]" CHANGELOG.md | cut -d: -f1) + TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1) + END_LINE=$((START_LINE + TAIL_LINE - 1)) + if [ -z "$TAIL_LINE" ]; then END_LINE=$(wc -l < CHANGELOG.md); fi + sed -n "${START_LINE},${END_LINE}p" CHANGELOG.md | sed '$d' > release_notes.md + shell: bash + + - name: Format Changelog + id: format_changelog + run: | + sed -i '1d' release_notes.md # Remove the first line + sed -i 's/###/##/g' release_notes.md # Change headers from ### to ## + shell: bash + + - name: Create a GitHub release + uses: actions/create-release@v1 + with: + tag_name: test-${{ env.VERSION }} + release_name: [TEST] Release v${{ env.VERSION }} + body_path: ./release_notes.md + draft: true + prerelease: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 722e6eaeb4fcd0ae6835753c7895733c63e190c3 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 09:55:50 +0100 Subject: [PATCH 10/44] Fix yaml issue --- .github/workflows/build-and-deploy.yml | 33 +++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 60b9ba0e19..95fb8cc662 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -1,36 +1,40 @@ +--- name: TEST Build and Deploy on: - workflow_dispatch: - pull_request: + workflow_dispatch: null + pull_request: null jobs: build: name: Build and Commit runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - name: Read .nvmrc run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV - - name: Use Node.js ${{ env.NODE_VERSION }} uses: actions/setup-node@v4.0.2 with: node-version: ${{ env.NODE_VERSION }} cache: npm - - name: Build - run: | + run: > npm ci + npm run build - composer install --no-dev --optimize-autoloader --classmap-authoritative + composer install --no-dev --optimize-autoloader --classmap-authoritative - name: Commit built files - run: | + run: > git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git checkout -b built-test + git add -Af vendor/autoload.php vendor/composer/ + git commit -m "Build plugin" --no-verify + git push origin built-test tag_and_release: name: Tag and Release @@ -38,37 +42,38 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - name: Get version from package.json id: get_version run: | VERSION=$(jq -r .version < package.json) echo "VERSION=$VERSION" >> $GITHUB_ENV echo "The version is $VERSION" - - name: Extract Changelog id: extract_changelog - run: | + run: > VERSION=${{ env.VERSION }} + START_LINE=$(grep -n "## \[${VERSION}\]" CHANGELOG.md | cut -d: -f1) + TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1) + END_LINE=$((START_LINE + TAIL_LINE - 1)) + if [ -z "$TAIL_LINE" ]; then END_LINE=$(wc -l < CHANGELOG.md); fi + sed -n "${START_LINE},${END_LINE}p" CHANGELOG.md | sed '$d' > release_notes.md shell: bash - - name: Format Changelog id: format_changelog run: | sed -i '1d' release_notes.md # Remove the first line sed -i 's/###/##/g' release_notes.md # Change headers from ### to ## shell: bash - - name: Create a GitHub release uses: actions/create-release@v1 with: tag_name: test-${{ env.VERSION }} - release_name: [TEST] Release v${{ env.VERSION }} + release_name: "[TEST] Release v${{ env.VERSION }}" body_path: ./release_notes.md draft: true prerelease: true From 8bea53a2dcc9fba67491f450f99bf16912ca92ee Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 09:58:55 +0100 Subject: [PATCH 11/44] Another fix --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 95fb8cc662..66aa52d079 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -73,7 +73,7 @@ jobs: uses: actions/create-release@v1 with: tag_name: test-${{ env.VERSION }} - release_name: "[TEST] Release v${{ env.VERSION }}" + release_name: TEST Release v${{ env.VERSION }} body_path: ./release_notes.md draft: true prerelease: true From 4357bef149b0d6e2df91ec2fa080115212e08905 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 10:33:42 +0100 Subject: [PATCH 12/44] Pull and merge built branch. --- .github/workflows/build-and-deploy.yml | 34 ++++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 66aa52d079..9c6afc9d0d 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -9,66 +9,68 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + - name: Read .nvmrc run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV + - name: Use Node.js ${{ env.NODE_VERSION }} uses: actions/setup-node@v4.0.2 with: node-version: ${{ env.NODE_VERSION }} cache: npm + - name: Build run: > npm ci - npm run build - composer install --no-dev --optimize-autoloader --classmap-authoritative + + - name: Fetch built branch + run: | + git fetch origin built:built || true + git checkout built || git checkout -b built + git pull origin built || true + - name: Commit built files - run: > + run: | git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add -A + git commit -m "Build plugin" + git push origin built - git checkout -b built-test - - git add -Af vendor/autoload.php vendor/composer/ - - git commit -m "Build plugin" --no-verify - - git push origin built-test tag_and_release: name: Tag and Release needs: build runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + - name: Get version from package.json id: get_version run: | VERSION=$(jq -r .version < package.json) echo "VERSION=$VERSION" >> $GITHUB_ENV echo "The version is $VERSION" + - name: Extract Changelog id: extract_changelog run: > VERSION=${{ env.VERSION }} - START_LINE=$(grep -n "## \[${VERSION}\]" CHANGELOG.md | cut -d: -f1) - TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1) - END_LINE=$((START_LINE + TAIL_LINE - 1)) - if [ -z "$TAIL_LINE" ]; then END_LINE=$(wc -l < CHANGELOG.md); fi - sed -n "${START_LINE},${END_LINE}p" CHANGELOG.md | sed '$d' > release_notes.md shell: bash + - name: Format Changelog id: format_changelog run: | sed -i '1d' release_notes.md # Remove the first line sed -i 's/###/##/g' release_notes.md # Change headers from ### to ## shell: bash + - name: Create a GitHub release uses: actions/create-release@v1 with: From 7c2d260228bb790202ebd503933c3dc37a025065 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 10:39:35 +0100 Subject: [PATCH 13/44] --no-verify the commit --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 9c6afc9d0d..e01c2465b6 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -36,7 +36,7 @@ jobs: git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add -A - git commit -m "Build plugin" + git commit -m "Build plugin v${{ env.VERSION }}" --no-verify git push origin built tag_and_release: From 6de004f65aee670a2dfd9bb7a2f1ff2adefacef0 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 10:43:34 +0100 Subject: [PATCH 14/44] Better handling of the fetch logic --- .github/workflows/build-and-deploy.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index e01c2465b6..6d20558be2 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -27,9 +27,13 @@ jobs: - name: Fetch built branch run: | - git fetch origin built:built || true - git checkout built || git checkout -b built - git pull origin built || true + if git ls-remote --exit-code origin built-test; then + git fetch origin built-test:built-test + git checkout built-test + git pull origin built-test + else + git checkout -b built-test + fi - name: Commit built files run: | From 5878f619696da81953f4860b6c9d34953509d1b3 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 10:47:58 +0100 Subject: [PATCH 15/44] Add the vendor/ directory before commit --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 6d20558be2..85d5358e97 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -39,7 +39,7 @@ jobs: run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git add -A + git add -Af vendor/ git commit -m "Build plugin v${{ env.VERSION }}" --no-verify git push origin built From 3b9a15c24403fed1036e7887373284cdce99ced9 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 10:53:41 +0100 Subject: [PATCH 16/44] Fix typo --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 85d5358e97..ef61002f14 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -20,7 +20,7 @@ jobs: cache: npm - name: Build - run: > + run: | npm ci npm run build composer install --no-dev --optimize-autoloader --classmap-authoritative From 106b59898532337f4fb0c47621f47ddc8b5fcca6 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 10:55:57 +0100 Subject: [PATCH 17/44] Fix branch name --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index ef61002f14..0bfa76fc40 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -41,7 +41,7 @@ jobs: git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add -Af vendor/ git commit -m "Build plugin v${{ env.VERSION }}" --no-verify - git push origin built + git push origin built-test tag_and_release: name: Tag and Release From 48af0c0fa0d95eb42fc49e321de06680e87039ba Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 10:59:34 +0100 Subject: [PATCH 18/44] Fix typo in the tag and release step --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 0bfa76fc40..33f8b40ba7 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -59,7 +59,7 @@ jobs: - name: Extract Changelog id: extract_changelog - run: > + run: | VERSION=${{ env.VERSION }} START_LINE=$(grep -n "## \[${VERSION}\]" CHANGELOG.md | cut -d: -f1) TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1) From 07a86d5989d9fc09715fc4415d220a3f2e8bef04 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:06:04 +0100 Subject: [PATCH 19/44] Change the order of the steps --- .github/workflows/build-and-deploy.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 33f8b40ba7..399936ad45 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -19,13 +19,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: npm - - name: Build - run: | - npm ci - npm run build - composer install --no-dev --optimize-autoloader --classmap-authoritative - - - name: Fetch built branch + - name: Fetch built-test branch run: | if git ls-remote --exit-code origin built-test; then git fetch origin built-test:built-test @@ -35,6 +29,16 @@ jobs: git checkout -b built-test fi + - name: Merge current branch into built-test + run: | + git merge $GITHUB_HEAD_REF + + - name: Build + run: | + npm ci + npm run build + composer install --no-dev --optimize-autoloader --classmap-authoritative + - name: Commit built files run: | git config --global user.name 'github-actions[bot]' From c6c8eaec3af0c9e971019d86060b2986d08dc04c Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:08:21 +0100 Subject: [PATCH 20/44] Add some debug info --- .github/workflows/build-and-deploy.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 399936ad45..1662e6c514 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -29,9 +29,14 @@ jobs: git checkout -b built-test fi + - name: Debug Branch Info + run: | + echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF" + git branch -a + - name: Merge current branch into built-test run: | - git merge $GITHUB_HEAD_REF + git merge origin/$GITHUB_HEAD_REF - name: Build run: | From d8f48ff1a3617b454e406f277a057f244b72ff13 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:10:41 +0100 Subject: [PATCH 21/44] Add some debug info --- .github/workflows/build-and-deploy.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 1662e6c514..8d4e655827 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -19,6 +19,12 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: npm + - name: Debug Branch Info + run: | + echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF" + git branch -a + + - name: Fetch built-test branch run: | if git ls-remote --exit-code origin built-test; then @@ -29,11 +35,6 @@ jobs: git checkout -b built-test fi - - name: Debug Branch Info - run: | - echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF" - git branch -a - - name: Merge current branch into built-test run: | git merge origin/$GITHUB_HEAD_REF From 257f5d96043f0245b403d998a05ce9f24b85ba9e Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:12:24 +0100 Subject: [PATCH 22/44] Change source branch name --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 8d4e655827..9d57ca4bbd 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -37,7 +37,7 @@ jobs: - name: Merge current branch into built-test run: | - git merge origin/$GITHUB_HEAD_REF + git merge remote/origin/$GITHUB_HEAD_REF - name: Build run: | From e422046802542c1d5ae1481e1d389cb581fbebc8 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:14:50 +0100 Subject: [PATCH 23/44] Another merge test --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 9d57ca4bbd..bc11b020d4 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -37,7 +37,7 @@ jobs: - name: Merge current branch into built-test run: | - git merge remote/origin/$GITHUB_HEAD_REF + git merge remote/$GITHUB_HEAD_REF - name: Build run: | From aa66580ddadbe8fcd52783f7f64f6487e47f3a39 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:21:23 +0100 Subject: [PATCH 24/44] Another test with GITHUB_REF --- .github/workflows/build-and-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index bc11b020d4..e3762bbcf2 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -22,9 +22,9 @@ jobs: - name: Debug Branch Info run: | echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF" + echo "GITHUB_REF: $GITHUB_REF" git branch -a - - name: Fetch built-test branch run: | if git ls-remote --exit-code origin built-test; then @@ -37,7 +37,7 @@ jobs: - name: Merge current branch into built-test run: | - git merge remote/$GITHUB_HEAD_REF + git merge $GITHUB_REF - name: Build run: | From 674b7c061d6292e0d7b0d57a24185aa253d26eff Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:22:18 +0100 Subject: [PATCH 25/44] Fetch GITHUB_REF before merging --- .github/workflows/build-and-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index e3762bbcf2..eff9379fd3 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -27,6 +27,7 @@ jobs: - name: Fetch built-test branch run: | + git fetch origin $GITHUB_REF:$GITHUB_REF if git ls-remote --exit-code origin built-test; then git fetch origin built-test:built-test git checkout built-test From 077f9feef9a6cdd1a657e335795d740ec5076e5b Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:27:48 +0100 Subject: [PATCH 26/44] Try a different approach --- .github/workflows/build-and-deploy.yml | 28 +++++++++----------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index eff9379fd3..d6c254c926 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -8,7 +8,10 @@ jobs: name: Build and Commit runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v4 + - name: Checkout the specific branch/ref + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} - name: Read .nvmrc run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV @@ -19,26 +22,15 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: npm - - name: Debug Branch Info - run: | - echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF" - echo "GITHUB_REF: $GITHUB_REF" - git branch -a - - - name: Fetch built-test branch + - name: Fetch and checkout built-test branch run: | - git fetch origin $GITHUB_REF:$GITHUB_REF - if git ls-remote --exit-code origin built-test; then - git fetch origin built-test:built-test - git checkout built-test - git pull origin built-test - else - git checkout -b built-test - fi + git fetch origin built-test:built-test || git fetch origin built-test + git checkout built-test || git checkout -b built-test + git pull origin built-test - name: Merge current branch into built-test run: | - git merge $GITHUB_REF + git merge ${{ github.ref }} - name: Build run: | @@ -51,7 +43,7 @@ jobs: git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add -Af vendor/ - git commit -m "Build plugin v${{ env.VERSION }}" --no-verify + git commit -m "Build plugin from ${{ github.ref }} v${{ env.VERSION }}" --no-verify git push origin built-test tag_and_release: From 9ca66bd3a6591dc9d32c068fdbba8e0e39b85580 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:31:36 +0100 Subject: [PATCH 27/44] Another approach --- .github/workflows/build-and-deploy.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index d6c254c926..9216c9e4db 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -12,6 +12,7 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.ref }} + fetch-depth: 0 - name: Read .nvmrc run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV @@ -22,6 +23,16 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: npm + - name: Build + run: | + npm ci + npm run build + composer install --no-dev --optimize-autoloader --classmap-authoritative + + - name: Get list of changed files + run: | + git status -s + - name: Fetch and checkout built-test branch run: | git fetch origin built-test:built-test || git fetch origin built-test @@ -30,20 +41,18 @@ jobs: - name: Merge current branch into built-test run: | - git merge ${{ github.ref }} + git merge --no-ff $GITHUB_SHA - - name: Build + - name: Get list of changed files run: | - npm ci - npm run build - composer install --no-dev --optimize-autoloader --classmap-authoritative + git status -s - name: Commit built files run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add -Af vendor/ - git commit -m "Build plugin from ${{ github.ref }} v${{ env.VERSION }}" --no-verify + git commit -m "Build plugin from ${{ github.ref_name }} v${{ env.VERSION }}" --no-verify git push origin built-test tag_and_release: From 2571d2b633c12d16836d1d4b50347b6486b915ae Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:36:11 +0100 Subject: [PATCH 28/44] Configure git before merge --- .github/workflows/build-and-deploy.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 9216c9e4db..20f02ea72c 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -39,6 +39,11 @@ jobs: git checkout built-test || git checkout -b built-test git pull origin built-test + - name: Configure Git + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + - name: Merge current branch into built-test run: | git merge --no-ff $GITHUB_SHA @@ -49,9 +54,8 @@ jobs: - name: Commit built files run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add -Af vendor/ + git status -s git commit -m "Build plugin from ${{ github.ref_name }} v${{ env.VERSION }}" --no-verify git push origin built-test From f23ef76a42138118746c2b7167a08532562b5f9e Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:42:05 +0100 Subject: [PATCH 29/44] Check if built branch exists --- .github/workflows/build-and-deploy.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 20f02ea72c..a689f44f8d 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -35,9 +35,13 @@ jobs: - name: Fetch and checkout built-test branch run: | - git fetch origin built-test:built-test || git fetch origin built-test - git checkout built-test || git checkout -b built-test - git pull origin built-test + if git ls-remote --exit-code origin built-test; then + git fetch origin built-test + git checkout built-test + git pull origin built-test + else + git checkout -b built-test + fi - name: Configure Git run: | From 34fff66a9bb75101566e51af94ae123ed741945d Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 11:56:08 +0100 Subject: [PATCH 30/44] Tag the built commit with the version --- .github/workflows/build-and-deploy.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index a689f44f8d..1a22325a04 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -60,6 +60,7 @@ jobs: run: | git add -Af vendor/ git status -s + VERSION=$(jq -r .version < package.json) git commit -m "Build plugin from ${{ github.ref_name }} v${{ env.VERSION }}" --no-verify git push origin built-test @@ -69,6 +70,9 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + with: + ref: built-test + fetch-depth: 0 - name: Get version from package.json id: get_version @@ -77,13 +81,18 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_ENV echo "The version is $VERSION" + - name: Tag the commit + run: | + VERSION=$(jq -r .version < package.json) + git tag test-${VERSION} + git push origin test-${VERSION} + - name: Extract Changelog id: extract_changelog run: | VERSION=${{ env.VERSION }} START_LINE=$(grep -n "## \[${VERSION}\]" CHANGELOG.md | cut -d: -f1) TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1) - END_LINE=$((START_LINE + TAIL_LINE - 1)) if [ -z "$TAIL_LINE" ]; then END_LINE=$(wc -l < CHANGELOG.md); fi sed -n "${START_LINE},${END_LINE}p" CHANGELOG.md | sed '$d' > release_notes.md shell: bash From 3f7f32a775588157c1dfc5f8ba72f6153569780e Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 12:06:02 +0100 Subject: [PATCH 31/44] Fix extract changelog script --- .github/workflows/build-and-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 1a22325a04..fc7a1d3804 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -93,6 +93,7 @@ jobs: VERSION=${{ env.VERSION }} START_LINE=$(grep -n "## \[${VERSION}\]" CHANGELOG.md | cut -d: -f1) TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1) + END_LINE=$((START_LINE + TAIL_LINE - 1)) if [ -z "$TAIL_LINE" ]; then END_LINE=$(wc -l < CHANGELOG.md); fi sed -n "${START_LINE},${END_LINE}p" CHANGELOG.md | sed '$d' > release_notes.md shell: bash From f93fbd7c3b0d62b44a0eb862838d14218c890fbf Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 12:35:58 +0100 Subject: [PATCH 32/44] Use different create-release action --- .github/workflows/build-and-deploy.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index fc7a1d3804..bffa888005 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -61,7 +61,7 @@ jobs: git add -Af vendor/ git status -s VERSION=$(jq -r .version < package.json) - git commit -m "Build plugin from ${{ github.ref_name }} v${{ env.VERSION }}" --no-verify + git commit -m "Build plugin from ${{ github.ref_name }} v${{ VERSION }}" --no-verify git push origin built-test tag_and_release: @@ -106,12 +106,10 @@ jobs: shell: bash - name: Create a GitHub release - uses: actions/create-release@v1 + uses: ncipollo/release-action@v1 with: - tag_name: test-${{ env.VERSION }} - release_name: TEST Release v${{ env.VERSION }} - body_path: ./release_notes.md + tag: test-${{ env.VERSION }} + name: ${{ env.VERSION }} + bodyFile: ./release_notes.md draft: true prerelease: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From c5b52dd3a49213f4537cf03a39a3a8fa57ccc3ce Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 12:38:16 +0100 Subject: [PATCH 33/44] Change commit message --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index bffa888005..c0c2087183 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -61,7 +61,7 @@ jobs: git add -Af vendor/ git status -s VERSION=$(jq -r .version < package.json) - git commit -m "Build plugin from ${{ github.ref_name }} v${{ VERSION }}" --no-verify + git commit -m "Build plugin v${{ VERSION }} (${{ github.ref_name }})" --no-verify git push origin built-test tag_and_release: From d0bc973ab81a3920d7a92440a804109977f41825 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 12:39:20 +0100 Subject: [PATCH 34/44] Fix issue with var interpolation --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index c0c2087183..f3ed7a87b6 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -61,7 +61,7 @@ jobs: git add -Af vendor/ git status -s VERSION=$(jq -r .version < package.json) - git commit -m "Build plugin v${{ VERSION }} (${{ github.ref_name }})" --no-verify + git commit -m "Build plugin v$VERSION (${{ github.ref_name }})" --no-verify git push origin built-test tag_and_release: From af845a62dec413400e8f8ad35e7e5567e9d1d818 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 13:02:45 +0100 Subject: [PATCH 35/44] Add deploy to wporg job --- .github/workflows/build-and-deploy.yml | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index f3ed7a87b6..14f3a5a043 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -113,3 +113,41 @@ jobs: bodyFile: ./release_notes.md draft: true prerelease: true + + deploy: + name: Deploy to WordPress.org + needs: tag_and_release + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + with: + tag: test-${{ env.VERSION }} + + - name: WordPress Plugin Deploy + id: wporg_deploy + uses: 10up/action-wordpress-plugin-deploy@stable + with: + dry-run: true + generate-zip: true + env: + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + + - name: Print ZIP file path + run: | + echo "ZIP file path: ${{ steps.wporg_deploy.outputs.zip-path }}" + + - name: Update release with ZIP file + uses: ncipollo/release-action@v1 + with: + tag: test-${{ env.VERSION }} + allowUpdates: true + omitBodyDuringUpdate: true + omitNameDuringUpdate: true + omitDraftDuringUpdate: true + omitPrereleaseDuringUpdate: true + removeArtifacts: true + updateOnlyUnreleased: true + artifacts: ${{ steps.wporg_deploy.outputs.zip-path }} + + From 735726e499e997fe9d62d89ddeb607ac58448246 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 13:09:52 +0100 Subject: [PATCH 36/44] Fix checkout param --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 14f3a5a043..67c7983a12 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -121,7 +121,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - tag: test-${{ env.VERSION }} + ref: test-${{ env.VERSION }} - name: WordPress Plugin Deploy id: wporg_deploy From 071aaebfb74f4dc4782a06812517d0403d07b869 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 13:16:42 +0100 Subject: [PATCH 37/44] Improve relibility of the extract changelog step --- .github/workflows/build-and-deploy.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 67c7983a12..2eac9a6e4d 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -90,12 +90,21 @@ jobs: - name: Extract Changelog id: extract_changelog run: | + set -e VERSION=${{ env.VERSION }} START_LINE=$(grep -n "## \[${VERSION}\]" CHANGELOG.md | cut -d: -f1) - TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1) - END_LINE=$((START_LINE + TAIL_LINE - 1)) - if [ -z "$TAIL_LINE" ]; then END_LINE=$(wc -l < CHANGELOG.md); fi + if [ -z "$START_LINE" ]; then + echo "Version not found in CHANGELOG.md" >&2 + exit 1 + fi + TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1 || true) + if [ -z "$TAIL_LINE" ]; then + END_LINE=$(wc -l < CHANGELOG.md) + else + END_LINE=$((START_LINE + TAIL_LINE - 1)) + fi sed -n "${START_LINE},${END_LINE}p" CHANGELOG.md | sed '$d' > release_notes.md + cat release_notes.md shell: bash - name: Format Changelog From a7e9ea0045b0a21505c4cdaaabc4aed7ad498a5c Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 13:23:40 +0100 Subject: [PATCH 38/44] Fix how version number is shared across jobs --- .github/workflows/build-and-deploy.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 2eac9a6e4d..79fd123a32 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -68,6 +68,8 @@ jobs: name: Tag and Release needs: build runs-on: ubuntu-20.04 + outputs: + VERSION: ${{ steps.get_version.outputs.VERSION }} steps: - uses: actions/checkout@v4 with: @@ -79,13 +81,13 @@ jobs: run: | VERSION=$(jq -r .version < package.json) echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "::set-output name=VERSION::$VERSION" echo "The version is $VERSION" - name: Tag the commit run: | - VERSION=$(jq -r .version < package.json) - git tag test-${VERSION} - git push origin test-${VERSION} + git tag test-${{ env.VERSION }} + git push origin test-${{ env.VERSION }} - name: Extract Changelog id: extract_changelog @@ -130,7 +132,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: test-${{ env.VERSION }} + ref: test-${{ needs.tag_and_release.outputs.VERSION }} - name: WordPress Plugin Deploy id: wporg_deploy @@ -141,6 +143,7 @@ jobs: env: SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + VERSION: ${{ needs.tag_and_release.outputs.VERSION }} - name: Print ZIP file path run: | From 8fd7f12bb28dea1234226aca8c48724415fef046 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 14:24:37 +0100 Subject: [PATCH 39/44] Fix .zip upload to the release --- .github/workflows/build-and-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 79fd123a32..569a3b5bed 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -70,6 +70,7 @@ jobs: runs-on: ubuntu-20.04 outputs: VERSION: ${{ steps.get_version.outputs.VERSION }} + UPLOAD_URL: ${{ steps.github_release.outputs.upload_url }} steps: - uses: actions/checkout@v4 with: @@ -117,6 +118,7 @@ jobs: shell: bash - name: Create a GitHub release + id: github_release uses: ncipollo/release-action@v1 with: tag: test-${{ env.VERSION }} @@ -152,7 +154,7 @@ jobs: - name: Update release with ZIP file uses: ncipollo/release-action@v1 with: - tag: test-${{ env.VERSION }} + tag: test-${{ needs.tag_and_release.outputs.VERSION }} allowUpdates: true omitBodyDuringUpdate: true omitNameDuringUpdate: true @@ -161,5 +163,6 @@ jobs: removeArtifacts: true updateOnlyUnreleased: true artifacts: ${{ steps.wporg_deploy.outputs.zip-path }} + artifactContentType: application/zip From 98ff4940b38beb58db2c2c15df439a80fc551039 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 10 Jul 2024 14:51:37 +0100 Subject: [PATCH 40/44] Change the WP.org version tag to a test one --- .github/workflows/build-and-deploy.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 569a3b5bed..951856b808 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -70,7 +70,6 @@ jobs: runs-on: ubuntu-20.04 outputs: VERSION: ${{ steps.get_version.outputs.VERSION }} - UPLOAD_URL: ${{ steps.github_release.outputs.upload_url }} steps: - uses: actions/checkout@v4 with: @@ -145,7 +144,7 @@ jobs: env: SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} SVN_USERNAME: ${{ secrets.SVN_USERNAME }} - VERSION: ${{ needs.tag_and_release.outputs.VERSION }} + VERSION: test-${{ needs.tag_and_release.outputs.VERSION }} - name: Print ZIP file path run: | @@ -164,5 +163,3 @@ jobs: updateOnlyUnreleased: true artifacts: ${{ steps.wporg_deploy.outputs.zip-path }} artifactContentType: application/zip - - From 6f9d43536b7da78b797ba882af27a88ff4520a57 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 11 Jul 2024 09:42:17 +0100 Subject: [PATCH 41/44] Mock change to see if the built branch is properly updated. --- build/content-helper/dashboard-widget.asset.php | 2 +- build/content-helper/dashboard-widget.js | 2 +- src/content-helper/dashboard-widget/components/top-posts.tsx | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/content-helper/dashboard-widget.asset.php b/build/content-helper/dashboard-widget.asset.php index e9331a046f..4d95b34fd9 100644 --- a/build/content-helper/dashboard-widget.asset.php +++ b/build/content-helper/dashboard-widget.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'a741adf6df6b723b2f3d'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'd02329b542f66b231abb'); diff --git a/build/content-helper/dashboard-widget.js b/build/content-helper/dashboard-widget.js index 50392fc4be..b4c7b61d96 100644 --- a/build/content-helper/dashboard-widget.js +++ b/build/content-helper/dashboard-widget.js @@ -1 +1 @@ -!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(848),s=window.wp.element,o=window.wp.i18n,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},l=function(e){var t;return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})},c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),f=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;rhere.',"wp-parsely"):s.code===j.ParselySuggestionsApiOpenAiError||s.code===j.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,o.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===j.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,o.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===j.ParselySuggestionsApiSchemaError?s.message=(0,o.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===j.ParselySuggestionsApiNoData?s.message=(0,o.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===j.ParselySuggestionsApiOpenAiSchema?s.message=(0,o.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===j.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,o.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return C(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[j.PluginCredentialsNotSetMessageDetected,j.PluginSettingsSiteIdNotSet,j.PluginSettingsApiSecretNotSet].includes(this.code)?l(e):(this.code===j.FetchError&&(this.hint=this.Hint((0,o.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==j.ParselyApiForbidden&&this.code!==j.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===j.HttpRequestFailed&&(this.hint=this.Hint((0,o.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,o.__)("Hint:","wp-parsely")," ").concat(e,"

")},t.prototype.createErrorSnackbar=function(){//.test(this.message)||(0,f.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},t}(Error),O=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,r=Array.from(this.abortControllers.keys()).pop();r&&(t=this.abortControllers.get(r))&&(t.abort(),this.abortControllers.delete(r))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),r=new AbortController;return this.abortControllers.set(t,r),{abortController:r,abortId:t}},e.prototype.fetch=function(e,t){return r=this,n=void 0,s=function(){var r,n,a,s,i,l;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=c){var u=t;(a=n/c)%1>1/i&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),o=l}i=c})),s+r+o}function z(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Number of Views","wp-parsely")}),s,$(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function X(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)(B,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(z,{metric:r,post:n}),(0,a.jsx)(Z,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(q,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(G,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Date","wp-parsely")}),M(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function B(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,o.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Post thumbnail not available","wp-parsely")})})}function Z(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var W=function(){return W=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:f(!1),v(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return f(!0),t(1),function(){f(!1),m([]),v(void 0)}}),[i,S]);var j=function(e,t){d.trackEvent("dash_widget_filter_changed",W({filter:e},t))},N=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(h,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,A(e)]})),onChange:function(t){x(t.target.value,e)&&(l({Period:t.target.value}),j("period",{period:t.target.value}),T(1))}}),(0,a.jsx)(h,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){x(e.target.value,t)&&(l({Metric:e.target.value}),j("metric",{metric:e.target.value}),T(1))}})]}),C=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:S<=1,"aria-label":(0,o.__)("Previous page","wp-parsely"),onClick:function(){T(S-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:S-1})},children:(0,o.__)("<< Previous","wp-parsely")}),(0,o.sprintf)(/* translators: 1: Current page */ /* translators: 1: Current page */(0,o.__)("Page %1$d","wp-parsely"),S),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!u&&_.length<5,"aria-label":(0,o.__)("Next page","wp-parsely"),onClick:function(){T(S+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:S+1})},children:(0,o.__)("Next >>","wp-parsely")})]});if(g)return(0,a.jsxs)(a.Fragment,{children:[N,g.Message(),S>1&&C]});var k=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(p.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[N,u?k:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(S-1)},children:_.map((function(e){return(0,a.jsx)(X,{metric:i.Metric,post:e},e.id)}))}),(_.length>=5||S>1)&&C]})}var J=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return x(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),x(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(S,{endpoint:"dashboard-widget-settings",defaultSettings:J(window.wpParselyContentHelperSettings),children:(0,a.jsx)(u,{children:(0,a.jsx)(Q,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file +!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(848),s=window.wp.element,o=window.wp.i18n,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},l=function(e){var t;return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})},c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),f=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;rhere.',"wp-parsely"):s.code===j.ParselySuggestionsApiOpenAiError||s.code===j.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,o.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===j.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,o.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===j.ParselySuggestionsApiSchemaError?s.message=(0,o.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===j.ParselySuggestionsApiNoData?s.message=(0,o.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===j.ParselySuggestionsApiOpenAiSchema?s.message=(0,o.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===j.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,o.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return C(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[j.PluginCredentialsNotSetMessageDetected,j.PluginSettingsSiteIdNotSet,j.PluginSettingsApiSecretNotSet].includes(this.code)?l(e):(this.code===j.FetchError&&(this.hint=this.Hint((0,o.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==j.ParselyApiForbidden&&this.code!==j.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===j.HttpRequestFailed&&(this.hint=this.Hint((0,o.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,o.__)("Hint:","wp-parsely")," ").concat(e,"

")},t.prototype.createErrorSnackbar=function(){//.test(this.message)||(0,f.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},t}(Error),O=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,r=Array.from(this.abortControllers.keys()).pop();r&&(t=this.abortControllers.get(r))&&(t.abort(),this.abortControllers.delete(r))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),r=new AbortController;return this.abortControllers.set(t,r),{abortController:r,abortId:t}},e.prototype.fetch=function(e,t){return r=this,n=void 0,s=function(){var r,n,a,s,i,l;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=c){var u=t;(a=n/c)%1>1/i&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),o=l}i=c})),s+r+o}function z(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Number of Views","wp-parsely")}),s,$(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function X(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)(B,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(z,{metric:r,post:n}),(0,a.jsx)(Z,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(q,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(G,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Date","wp-parsely")}),M(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function B(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,o.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Post thumbnail not available","wp-parsely")})})}function Z(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var W=function(){return W=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:f(!1),v(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return f(!0),t(1),function(){f(!1),m([]),v(void 0)}}),[i,S]);var j=function(e,t){console.log("test"),d.trackEvent("dash_widget_filter_changed",W({filter:e},t))},N=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(h,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,A(e)]})),onChange:function(t){x(t.target.value,e)&&(l({Period:t.target.value}),j("period",{period:t.target.value}),T(1))}}),(0,a.jsx)(h,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){x(e.target.value,t)&&(l({Metric:e.target.value}),j("metric",{metric:e.target.value}),T(1))}})]}),C=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:S<=1,"aria-label":(0,o.__)("Previous page","wp-parsely"),onClick:function(){T(S-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:S-1})},children:(0,o.__)("<< Previous","wp-parsely")}),(0,o.sprintf)(/* translators: 1: Current page */ /* translators: 1: Current page */(0,o.__)("Page %1$d","wp-parsely"),S),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!u&&_.length<5,"aria-label":(0,o.__)("Next page","wp-parsely"),onClick:function(){T(S+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:S+1})},children:(0,o.__)("Next >>","wp-parsely")})]});if(g)return(0,a.jsxs)(a.Fragment,{children:[N,g.Message(),S>1&&C]});var k=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(p.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[N,u?k:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(S-1)},children:_.map((function(e){return(0,a.jsx)(X,{metric:i.Metric,post:e},e.id)}))}),(_.length>=5||S>1)&&C]})}var J=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return x(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),x(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(S,{endpoint:"dashboard-widget-settings",defaultSettings:J(window.wpParselyContentHelperSettings),children:(0,a.jsx)(u,{children:(0,a.jsx)(Q,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file diff --git a/src/content-helper/dashboard-widget/components/top-posts.tsx b/src/content-helper/dashboard-widget/components/top-posts.tsx index c490b86d0c..ccfdc9b4e8 100644 --- a/src/content-helper/dashboard-widget/components/top-posts.tsx +++ b/src/content-helper/dashboard-widget/components/top-posts.tsx @@ -81,6 +81,7 @@ export function TopPosts(): React.JSX.Element { * @param {Object} props The filter properties. */ const trackFilterChanges = ( filter: string, props: object ): void => { + console.log( 'test' ); // eslint-disable-line no-console Telemetry.trackEvent( 'dash_widget_filter_changed', { filter, ...props } ); }; From 6d079ef0776321e9eacfcf2a6f2ecbc87395bfec Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 11 Jul 2024 09:46:46 +0100 Subject: [PATCH 42/44] Change order of the checkout built branch step --- .github/workflows/build-and-deploy.yml | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 951856b808..2a9b044576 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -14,25 +14,6 @@ jobs: ref: ${{ github.ref }} fetch-depth: 0 - - name: Read .nvmrc - run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV - - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v4.0.2 - with: - node-version: ${{ env.NODE_VERSION }} - cache: npm - - - name: Build - run: | - npm ci - npm run build - composer install --no-dev --optimize-autoloader --classmap-authoritative - - - name: Get list of changed files - run: | - git status -s - - name: Fetch and checkout built-test branch run: | if git ls-remote --exit-code origin built-test; then @@ -56,6 +37,25 @@ jobs: run: | git status -s + - name: Read .nvmrc + run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV + + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4.0.2 + with: + node-version: ${{ env.NODE_VERSION }} + cache: npm + + - name: Build + run: | + npm ci + npm run build + composer install --no-dev --optimize-autoloader --classmap-authoritative + + - name: Get list of changed files + run: | + git status -s + - name: Commit built files run: | git add -Af vendor/ From 5096e732a0ce4adfcdfa164eb748bc0a03688edc Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 11 Jul 2024 09:55:19 +0100 Subject: [PATCH 43/44] Trying git merge with squash --- .github/workflows/build-and-deploy.yml | 3 ++- build/content-helper/dashboard-widget.asset.php | 2 +- build/content-helper/dashboard-widget.js | 2 +- src/content-helper/dashboard-widget/components/top-posts.tsx | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 2a9b044576..8fed240158 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -31,7 +31,8 @@ jobs: - name: Merge current branch into built-test run: | - git merge --no-ff $GITHUB_SHA + git merge --squash $GITHUB_SHA + git commit -m "Merge $GITHUB_SHA into built-test" --no-verify - name: Get list of changed files run: | diff --git a/build/content-helper/dashboard-widget.asset.php b/build/content-helper/dashboard-widget.asset.php index 4d95b34fd9..61255c7d26 100644 --- a/build/content-helper/dashboard-widget.asset.php +++ b/build/content-helper/dashboard-widget.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'd02329b542f66b231abb'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'cdeb35cda9a85c94d603'); diff --git a/build/content-helper/dashboard-widget.js b/build/content-helper/dashboard-widget.js index b4c7b61d96..88e6e5f209 100644 --- a/build/content-helper/dashboard-widget.js +++ b/build/content-helper/dashboard-widget.js @@ -1 +1 @@ -!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(848),s=window.wp.element,o=window.wp.i18n,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},l=function(e){var t;return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})},c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),f=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;rhere.',"wp-parsely"):s.code===j.ParselySuggestionsApiOpenAiError||s.code===j.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,o.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===j.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,o.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===j.ParselySuggestionsApiSchemaError?s.message=(0,o.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===j.ParselySuggestionsApiNoData?s.message=(0,o.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===j.ParselySuggestionsApiOpenAiSchema?s.message=(0,o.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===j.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,o.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return C(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[j.PluginCredentialsNotSetMessageDetected,j.PluginSettingsSiteIdNotSet,j.PluginSettingsApiSecretNotSet].includes(this.code)?l(e):(this.code===j.FetchError&&(this.hint=this.Hint((0,o.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==j.ParselyApiForbidden&&this.code!==j.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===j.HttpRequestFailed&&(this.hint=this.Hint((0,o.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,o.__)("Hint:","wp-parsely")," ").concat(e,"

")},t.prototype.createErrorSnackbar=function(){//.test(this.message)||(0,f.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},t}(Error),O=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,r=Array.from(this.abortControllers.keys()).pop();r&&(t=this.abortControllers.get(r))&&(t.abort(),this.abortControllers.delete(r))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),r=new AbortController;return this.abortControllers.set(t,r),{abortController:r,abortId:t}},e.prototype.fetch=function(e,t){return r=this,n=void 0,s=function(){var r,n,a,s,i,l;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=c){var u=t;(a=n/c)%1>1/i&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),o=l}i=c})),s+r+o}function z(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Number of Views","wp-parsely")}),s,$(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function X(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)(B,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(z,{metric:r,post:n}),(0,a.jsx)(Z,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(q,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(G,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Date","wp-parsely")}),M(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function B(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,o.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Post thumbnail not available","wp-parsely")})})}function Z(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var W=function(){return W=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:f(!1),v(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return f(!0),t(1),function(){f(!1),m([]),v(void 0)}}),[i,S]);var j=function(e,t){console.log("test"),d.trackEvent("dash_widget_filter_changed",W({filter:e},t))},N=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(h,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,A(e)]})),onChange:function(t){x(t.target.value,e)&&(l({Period:t.target.value}),j("period",{period:t.target.value}),T(1))}}),(0,a.jsx)(h,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){x(e.target.value,t)&&(l({Metric:e.target.value}),j("metric",{metric:e.target.value}),T(1))}})]}),C=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:S<=1,"aria-label":(0,o.__)("Previous page","wp-parsely"),onClick:function(){T(S-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:S-1})},children:(0,o.__)("<< Previous","wp-parsely")}),(0,o.sprintf)(/* translators: 1: Current page */ /* translators: 1: Current page */(0,o.__)("Page %1$d","wp-parsely"),S),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!u&&_.length<5,"aria-label":(0,o.__)("Next page","wp-parsely"),onClick:function(){T(S+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:S+1})},children:(0,o.__)("Next >>","wp-parsely")})]});if(g)return(0,a.jsxs)(a.Fragment,{children:[N,g.Message(),S>1&&C]});var k=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(p.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[N,u?k:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(S-1)},children:_.map((function(e){return(0,a.jsx)(X,{metric:i.Metric,post:e},e.id)}))}),(_.length>=5||S>1)&&C]})}var J=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return x(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),x(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(S,{endpoint:"dashboard-widget-settings",defaultSettings:J(window.wpParselyContentHelperSettings),children:(0,a.jsx)(u,{children:(0,a.jsx)(Q,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file +!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(848),s=window.wp.element,o=window.wp.i18n,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},l=function(e){var t;return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})},c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),f=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;rhere.',"wp-parsely"):s.code===j.ParselySuggestionsApiOpenAiError||s.code===j.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,o.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===j.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,o.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===j.ParselySuggestionsApiSchemaError?s.message=(0,o.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===j.ParselySuggestionsApiNoData?s.message=(0,o.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===j.ParselySuggestionsApiOpenAiSchema?s.message=(0,o.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===j.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,o.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return C(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[j.PluginCredentialsNotSetMessageDetected,j.PluginSettingsSiteIdNotSet,j.PluginSettingsApiSecretNotSet].includes(this.code)?l(e):(this.code===j.FetchError&&(this.hint=this.Hint((0,o.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==j.ParselyApiForbidden&&this.code!==j.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===j.HttpRequestFailed&&(this.hint=this.Hint((0,o.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,o.__)("Hint:","wp-parsely")," ").concat(e,"

")},t.prototype.createErrorSnackbar=function(){//.test(this.message)||(0,f.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},t}(Error),O=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,r=Array.from(this.abortControllers.keys()).pop();r&&(t=this.abortControllers.get(r))&&(t.abort(),this.abortControllers.delete(r))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),r=new AbortController;return this.abortControllers.set(t,r),{abortController:r,abortId:t}},e.prototype.fetch=function(e,t){return r=this,n=void 0,s=function(){var r,n,a,s,i,l;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=c){var u=t;(a=n/c)%1>1/i&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),o=l}i=c})),s+r+o}function z(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Number of Views","wp-parsely")}),s,$(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function X(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)(B,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(z,{metric:r,post:n}),(0,a.jsx)(Z,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(q,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(G,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Date","wp-parsely")}),M(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function B(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,o.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Post thumbnail not available","wp-parsely")})})}function Z(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var W=function(){return W=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:f(!1),v(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return f(!0),t(1),function(){f(!1),m([]),v(void 0)}}),[i,S]);var j=function(e,t){console.log("test"),console.log("another change"),d.trackEvent("dash_widget_filter_changed",W({filter:e},t))},N=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(h,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,A(e)]})),onChange:function(t){x(t.target.value,e)&&(l({Period:t.target.value}),j("period",{period:t.target.value}),T(1))}}),(0,a.jsx)(h,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){x(e.target.value,t)&&(l({Metric:e.target.value}),j("metric",{metric:e.target.value}),T(1))}})]}),C=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:S<=1,"aria-label":(0,o.__)("Previous page","wp-parsely"),onClick:function(){T(S-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:S-1})},children:(0,o.__)("<< Previous","wp-parsely")}),(0,o.sprintf)(/* translators: 1: Current page */ /* translators: 1: Current page */(0,o.__)("Page %1$d","wp-parsely"),S),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!u&&_.length<5,"aria-label":(0,o.__)("Next page","wp-parsely"),onClick:function(){T(S+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:S+1})},children:(0,o.__)("Next >>","wp-parsely")})]});if(g)return(0,a.jsxs)(a.Fragment,{children:[N,g.Message(),S>1&&C]});var k=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(p.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[N,u?k:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(S-1)},children:_.map((function(e){return(0,a.jsx)(X,{metric:i.Metric,post:e},e.id)}))}),(_.length>=5||S>1)&&C]})}var J=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return x(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),x(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(S,{endpoint:"dashboard-widget-settings",defaultSettings:J(window.wpParselyContentHelperSettings),children:(0,a.jsx)(u,{children:(0,a.jsx)(Q,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file diff --git a/src/content-helper/dashboard-widget/components/top-posts.tsx b/src/content-helper/dashboard-widget/components/top-posts.tsx index ccfdc9b4e8..78f72d9298 100644 --- a/src/content-helper/dashboard-widget/components/top-posts.tsx +++ b/src/content-helper/dashboard-widget/components/top-posts.tsx @@ -82,6 +82,7 @@ export function TopPosts(): React.JSX.Element { */ const trackFilterChanges = ( filter: string, props: object ): void => { console.log( 'test' ); // eslint-disable-line no-console + console.log( 'another change' ); // eslint-disable-line no-console Telemetry.trackEvent( 'dash_widget_filter_changed', { filter, ...props } ); }; From 2c4602a23fe73207ecf2823bf388cab3ba56d74c Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 11 Jul 2024 10:03:29 +0100 Subject: [PATCH 44/44] Fix deprecated set-output --- .github/workflows/build-and-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 8fed240158..d82ad753e6 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -21,7 +21,7 @@ jobs: git checkout built-test git pull origin built-test else - git checkout -b built-test + git checkout -b built-test develop fi - name: Configure Git @@ -82,7 +82,7 @@ jobs: run: | VERSION=$(jq -r .version < package.json) echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "::set-output name=VERSION::$VERSION" + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "The version is $VERSION" - name: Tag the commit