Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _None_

### New Features

_None_
- `upload_build_to_apps_cdn`: Add support for `Microsoft Store` as an allowed value for the `platform` parameter. [#661]

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,35 @@ module SharedValues
end

class UploadBuildToAppsCdnAction < Action
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-resource-type.php
RESOURCE_TYPE = 'Build'
# These are from the WordPress.com API, not the Apps CDN plugin
VALID_POST_STATUS = %w[publish draft].freeze
VALID_BUILD_TYPES = %w[Alpha Beta Nightly Production Prototype].freeze
VALID_PLATFORMS = ['Android', 'iOS', 'Mac - Silicon', 'Mac - Intel', 'Mac - Any', 'Windows'].freeze
VALID_INSTALL_TYPES = ['Full Install', 'Update'].freeze
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-build-type.php
VALID_BUILD_TYPES = %w[
Alpha
Beta
Nightly
Production
Prototype
].freeze
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-platform.php
VALID_PLATFORMS = [
'Android',
'iOS',
'Mac - Silicon',
'Mac - Intel',
'Mac - Any',
'Windows',
'Microsoft Store',
].freeze
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-install-type.php
VALID_INSTALL_TYPES = [
'Full Install',
'Update',
].freeze
# See https://github.a8c.com/Automattic/wpcom/blob/trunk/wp-content/lib/a8c/cdn/src/enums/enum-visibility.php
VALID_VISIBILITIES = %i[internal external].freeze

def self.run(params)
UI.message('Uploading build to Apps CDN...')
Expand Down Expand Up @@ -179,6 +203,8 @@ def self.available_options
type: String,
verify_block: proc do |value|
UI.user_error!('Product cannot be empty') if value.to_s.empty?
# Unlike for other parameters, we don't validate the product value against a list of valid values because we expect this list of
# supported products to be updated on the backend from time to time and we don't want to have to update the toolkit every time for it.
end
),
FastlaneCore::ConfigItem.new(
Expand Down Expand Up @@ -228,7 +254,7 @@ def self.available_options
optional: false,
type: Symbol,
verify_block: proc do |value|
UI.user_error!('Visibility must be either :internal or :external') unless %i[internal external].include?(value)
UI.user_error!("Visibility must be one of: #{VALID_VISIBILITIES.map { "`:#{_1}`" }.join(', ')}") unless VALID_VISIBILITIES.include?(value.to_s.downcase.to_sym)
end
),
FastlaneCore::ConfigItem.new(
Expand Down
4 changes: 2 additions & 2 deletions spec/upload_build_to_apps_cdn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def expected_form_part(name:, value:, filename: nil)
version: test_version,
file_path: file_path
)
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'Visibility must be either :internal or :external')
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'Visibility must be one of: `:internal`, `:external`')
end
end

Expand Down Expand Up @@ -421,7 +421,7 @@ def expected_form_part(name:, value:, filename: nil)
version: test_version,
file_path: file_path
)
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'Platform must be one of: Android, iOS, Mac - Silicon, Mac - Intel, Mac - Any, Windows')
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'Platform must be one of: Android, iOS, Mac - Silicon, Mac - Intel, Mac - Any, Windows, Microsoft Store')
end
end

Expand Down