Skip to content

Commit

Permalink
Merge pull request #1 from elegion/feature/certs
Browse files Browse the repository at this point in the history
Feature/certs
  • Loading branch information
vvlkv authored Dec 2, 2021
2 parents fca8797 + 95ecdee commit 611240c
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 74 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require:
- rubocop/require_tools
- rubocop-performance
AllCops:
SuggestExtensions: false
TargetRubyVersion: 2.5
NewCops: enable
Include:
Expand Down Expand Up @@ -55,6 +56,7 @@ Lint/UselessAssignment:
- "**/spec/**/*"
Require/MissingRequireStatement:
Exclude:
- "lib/fastlane/plugin/eln/actions/*.rb" # Не понятно, почему ругается. Разобраться
- "**/spec/**/*.rb"
- "**/spec_helper.rb"
- spaceship/lib/spaceship/babosa_fix.rb
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To
```bash
fastlane add_plugin eln
```
Choose Git URL and enter the URL of this repository.

## About eln
## About ELN

E-Legion
ELN is a set of lanes which can automate some routines in CI actions.

**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
### Available actions
|Action|Description|
|------|-----------|
|eln_certs_get|Gets all private certificates and provision described in ELN_CERTS_PROVISION_PROFILE_NAME_LIST environment variable|
|eln_certs_update|Adds new developer devices to developer.apple from file described in FL_REGISTER_DEVICES_FILE and force update provisions from ELN_CERTS_PROVISION_PROFILE_NAME_LIST|

**Important note:** Make sure you already added MATCH environment variables.
## Example

Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
Expand Down
12 changes: 11 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
lane :test do
eln
eln_certs_get
eln_certs_update
end

lane :test_params do
eln_certs_get(
eln_certs_provision_profile_name_list: "Some App Name:com.team.some-app,Some Extension Name:com.team.some-extension"
)
eln_certs_update(
eln_certs_provision_profile_name_list: "Some App Name:com.team.some-app,Some Extension Name:com.team.some-extension"
)
end
24 changes: 0 additions & 24 deletions lib/fastlane/plugin/eln/actions/eln_certs.rb

This file was deleted.

39 changes: 23 additions & 16 deletions lib/fastlane/plugin/eln/actions/eln_certs_get.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
require 'fastlane/action'
require_relative '../helper/eln_helper'
require_relative 'eln_certs'

module Fastlane
module Actions

class ElnCertsGetAction < ElnCertsAction
class ElnCertsGetAction < Action
def self.run(params)

provisions_pairs = Helper::CertsHelper.validate_provisions(params)
provisions_pairs.each {
|key, value|

list = params[:eln_certs_provision_profile_name_list]
provisions_pairs = Helper::CertsHelper.validate_provisions(list)
provisions_pairs.each do |key, value|
other_action.match(
profile_name: key,
app_identifier: value,
readonly: true,
force_for_new_devices: false,
force: false
)
}
end
end

def self.authors
["[email protected]"]
end

def self.description
"E-Legion"
"Gets private certificate and provision profile"
end

def self.return_value
# If your method provides a return value, you can describe here what it does
end

def self.details
# Optional:
"Plugin for good start"
end

def self.available_options
[
FastlaneCore::ConfigItem.new(key: :eln_certs_provision_profile_name_list,
env_name: "ELN_CERTS_PROVISION_PROFILE_NAME_LIST",
description: "Provisions and identifiers to create. Provision and identifiers should be separated by colon, pairs should be separated by comma, e.g \"profile name_1:identifier_1,profile name_2:identifier_2\"",
optional: false,
type: String,
verify_block: proc do |value|
UI.user_error("Certificates and provisions are empty!") unless value && !value.empty?
end)
]
end

def self.is_supported?(platform)
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
#
# [:ios, :mac, :android].include?(platform)
true
end
end
Expand Down
38 changes: 23 additions & 15 deletions lib/fastlane/plugin/eln/actions/eln_certs_update.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
require 'fastlane/action'
require_relative '../helper/eln_helper'
require_relative 'eln_certs'

module Fastlane
module Actions

class ElnCertsUpdateAction < ElnCertsAction
class ElnCertsUpdateAction < Action
def self.run(params)
provisions_pairs = Helper::CertsHelper.validate_provisions(params)
list = params[:eln_certs_provision_profile_name_list]
provisions_pairs = Helper::CertsHelper.validate_provisions(list)
other_action.register_devices
provisions_pairs.each {
|key, value|

provisions_pairs.each do |key, value|
other_action.match(
profile_name: key,
app_identifier: value,
readonly: true,
force_for_new_devices: false,
force: false
)
}
end
end

def self.authors
["[email protected]"]
end

def self.description
"E-Legion"
"Adds new devices and force updates provision profiles"
end

def self.return_value
# If your method provides a return value, you can describe here what it does
end

def self.details
# Optional:
"Plugin for good start"
end

def self.available_options
[
FastlaneCore::ConfigItem.new(key: :eln_certs_provision_profile_name_list,
env_name: "ELN_CERTS_PROVISION_PROFILE_NAME_LIST",
description: "Provisions and identifiers to create. Provision and identifiers should be separated by colon, pairs should be separated by comma, e.g \"profile name_1:identifier_1,profile name_2:identifier_2\"",
optional: false,
type: String,
verify_block: proc do |value|
UI.user_error("Certificates and provisions are empty!") unless value && !value.empty?
end)
]
end

def self.is_supported?(platform)
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
#
# [:ios, :mac, :android].include?(platform)
true
end
end
Expand Down
10 changes: 4 additions & 6 deletions lib/fastlane/plugin/eln/helper/eln_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ module Fastlane

module Helper
class CertsHelper

def self.validate_provisions(params)
provisions_pairs = params[:eln_certs_provision_profile_name_list].split(",")
possible_wrong_pair = provisions_pairs.select { |pair| !!pair[/.+[:].+/] == false }
def self.validate_provisions(list)
provisions_pairs = list.split(",")
possible_wrong_pair = provisions_pairs.select { |pair| !!pair[/.+:.+/] == false }
unless possible_wrong_pair.length == 0
error = [
"Invalid format for next pairs:"
Expand All @@ -17,9 +16,8 @@ def self.validate_provisions(params)
"Example: Some Project Development:com.e-legion.some-project"
]
UI.error(error.join("\n"))
exit
end
return provisions_pairs.map { |pair| pair.split(":") }
return provisions_pairs.map { |pair| pair.split(":").map(&:strip) }
end
end
end
Expand Down
9 changes: 0 additions & 9 deletions spec/eln_action_spec.rb

This file was deleted.

14 changes: 14 additions & 0 deletions spec/eln_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe Fastlane::Helper::CertsHelper do
describe '#run' do
it "valid" do
expect(Fastlane::Helper::CertsHelper.validate_provisions("some:value")).to eql([["some", "value"]])
expect(Fastlane::Helper::CertsHelper.validate_provisions("some:value, some:value2")).to eql([["some", "value"], ["some", "value2"]])
expect(Fastlane::Helper::CertsHelper.validate_provisions("some:value, some: value2")).to eql([["some", "value"], ["some", "value2"]])
expect(Fastlane::Helper::CertsHelper.validate_provisions("some spaced value :value, some: value2")).to eql([["some spaced value", "value"], ["some", "value2"]])
end
it "fails" do
expect(Fastlane::UI).to receive(:error)
Fastlane::Helper::CertsHelper.validate_provisions("some:value,some")
end
end
end

0 comments on commit 611240c

Please sign in to comment.