Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no need for shellwords when the commands are between single quotes #1

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b9fb239
There is no need for shellwords when the commands are between single …
jedi4ever Aug 29, 2015
b0fe146
Enabled rubocop and updated code style
KrauseFx Aug 30, 2015
589c8ca
Updated code style of all classes
KrauseFx Aug 30, 2015
b04cf4b
Allow to lookup apps by country, see codes #17
lacostej Aug 31, 2015
e27821a
Merge pull request #29 from lacostej/lookup_by_country
KrauseFx Sep 1, 2015
103bafa
Skipped checking of :trace key in config manager
KrauseFx Sep 1, 2015
4a512d9
Version bump
KrauseFx Sep 1, 2015
d985575
Added hound file
KrauseFx Sep 1, 2015
87a9a73
Updated available languages for iTunes Connect
KrauseFx Sep 2, 2015
d22a109
Version bump
KrauseFx Sep 2, 2015
dd38206
Added `rake test` command
KrauseFx Sep 4, 2015
0f283e7
Updated rubocop style rules
KrauseFx Sep 4, 2015
c82bdb1
Enabled stack trace by default
KrauseFx Sep 7, 2015
fea1ee3
Merge branch 'master' of https://github.com/KrauseFx/fastlane_core
KrauseFx Sep 7, 2015
4703102
Updated iTunes Transporter to use the new password manager
KrauseFx Sep 7, 2015
fcf19a6
Updated credentials_manager dependency
KrauseFx Sep 7, 2015
26b4e70
Version bump
KrauseFx Sep 7, 2015
eb2097d
Updated credentials_manager dependency
KrauseFx Sep 8, 2015
9a72794
Version bump
KrauseFx Sep 8, 2015
20a1cc5
Added link to `countdown`
KrauseFx Sep 10, 2015
2189d2e
Updated credentials_manager dependency
KrauseFx Sep 10, 2015
5736890
Added spacings inbetween {}
KrauseFx Sep 10, 2015
1a8e5d2
Updated code style
KrauseFx Sep 10, 2015
6ccdefc
Updated code style
KrauseFx Sep 10, 2015
1e758f9
Improved code style
KrauseFx Sep 10, 2015
6947dd4
Improved code style rules
KrauseFx Sep 15, 2015
f968e21
Added better detection of common syntax errors in configuration files
KrauseFx Sep 15, 2015
9f6f410
Version Bump
KrauseFx Sep 15, 2015
1035f42
Added new xcode_version method to helper
KrauseFx Sep 17, 2015
7b92359
Improved regex style
KrauseFx Sep 17, 2015
587ad90
Version bump
KrauseFx Sep 17, 2015
cc21906
Added auto-convert of boolean values
KrauseFx Sep 21, 2015
1d26a16
Version bump
KrauseFx Sep 21, 2015
e63bb2d
Added ipa package builder to fastlane_core
KrauseFx Sep 24, 2015
748ea5e
No more automatic short code for config items
KrauseFx Sep 24, 2015
35a20d2
Fixed bug with config items
KrauseFx Sep 24, 2015
3355c01
Only show environment variable name if available
KrauseFx Sep 27, 2015
36be544
Version bump
KrauseFx Sep 27, 2015
2036362
Version bump
KrauseFx Sep 27, 2015
2cdd354
rebase again
jedi4ever Sep 28, 2015
85ec895
merge correctly
jedi4ever Sep 28, 2015
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: 2 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruby:
config_file: .rubocop.yml
26 changes: 26 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

##################
# All rules specific to this repo
##################

inherit_from: .rubocop_general.yml

Style/ClassVars:
Enabled: false

AllCops:
Exclude:
# Legacy code that gets removed soon
- 'lib/fastlane_core/itunes_connect/*'



##################
# TODO
##################

Style/Documentation:
Enabled: false

Style/PerlBackrefs:
Enabled: false
112 changes: 112 additions & 0 deletions .rubocop_general.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

Style/ClassCheck:
EnforcedStyle: kind_of?

# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/BracesAroundHashParameters:
Enabled: false

Lint/UselessAssignment:
Exclude:
- 'spec/**/*'

# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/IndentHash:
Enabled: false

Style/RaiseArgs:
EnforcedStyle: exploded

Style/DoubleNegation:
Enabled: false

Lint/HandleExceptions:
Enabled: false

# Cop supports --auto-correct.
Lint/UnusedBlockArgument:
Enabled: false

# Needed for $verbose
Style/GlobalVars:
Enabled: false

Style/FileName:
Enabled: false

# $? Exit
Style/SpecialGlobalVars:
Enabled: false

# the let(:key) { ... } should be allowed in tests
Lint/ParenthesesAsGroupedExpression:
Exclude:
- 'spec/**/*'

# options.rb might be large, we know that
Metrics/MethodLength:
Max: 60
Exclude:
- 'lib/*/options.rb'

# Both string notations are okay
Style/StringLiterals:
Enabled: false

# The %w might be confusing for new users
Style/WordArray:
MinSize: 19

# Not a good thing
Style/RedundantSelf:
Enabled: false

# raise and fail are both okay
Style/SignalException:
Enabled: false

# Better too much 'return' than one missing
Style/RedundantReturn:
Enabled: false

# Having if in the same line might not always be good
Style/IfUnlessModifier:
Enabled: false

# That looks wrong
Style/AlignHash:
Enabled: false

# and and or is okay
Style/AndOr:
Enabled: false

# Offense count: 20
Metrics/AbcSize:
Max: 60

# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 320

Metrics/CyclomaticComplexity:
Max: 17

# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 370

# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 17

Metrics/PerceivedComplexity:
Max: 18

Style/DotPosition:
Enabled: false

Style/GuardClause:
Enabled: false
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Contributing to `fastlane` and its tools

To clone the [fastlane](https://fastlane.tools) repos, use the [countdown](https://github.com/fastlane/countdown) repo. It will help you set up the development environment within minutes.

## New Issues

Before submitting a new issue, do the following:
Expand Down
6 changes: 5 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ require "bundler/gem_tasks"

Dir.glob('tasks/**/*.rake').each(&method(:import))

task :default => :spec
task default: :spec

task :test do
sh "../fastlane/bin/fastlane test"
end
8 changes: 4 additions & 4 deletions fastlane_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Gem::Specification.new do |spec|
spec.version = FastlaneCore::VERSION
spec.authors = ["Felix Krause"]
spec.email = ["[email protected]"]
spec.summary = %q{Contains all shared code/dependencies of the fastlane.tools}
spec.description = %q{Contains all shared code/dependencies of the fastlane.tools}
spec.summary = 'Contains all shared code/dependencies of the fastlane.tools'
spec.description = 'Contains all shared code/dependencies of the fastlane.tools'
spec.homepage = "https://fastlane.tools"
spec.license = "MIT"

spec.required_ruby_version = '>= 2.0.0'

spec.files = Dir["lib/**/*"] + %w{ README.md LICENSE }
spec.files = Dir["lib/**/*"] + %w( README.md LICENSE )

spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
Expand All @@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'rubyzip', '~> 1.1.6' # needed for extracting the ipa file
spec.add_dependency 'plist', '~> 3.1' # needed for parsing provisioning profiles

spec.add_dependency 'credentials_manager', '>= 0.7.2' # fastlane password manager
spec.add_dependency 'credentials_manager', '>= 0.8.2', '< 1.0.0' # fastlane password manager

# Frontend Scripting
spec.add_dependency 'phantomjs', '~> 1.9.8' # dependency for poltergeist
Expand Down
12 changes: 12 additions & 0 deletions lib/assets/XMLTemplate.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://apple.com/itunes/importer" version="software4.7">
<software_assets apple_id="<%= @data[:apple_id] %>">
<asset type="bundle">
<data_file>
<size><%= @data[:file_size] %></size>
<file_name><%= @data[:ipa_path] %></file_name>
<checksum type="md5"><%= @data[:md5] %></checksum>
</data_file>
</asset>
</software_assets>
</package>
2 changes: 1 addition & 1 deletion lib/fastlane_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
require 'fastlane_core/itunes_transporter'
require 'fastlane_core/provisioning_profile'
require 'fastlane_core/command_executor'
require 'fastlane_core/ipa_upload_package_builder'

# Third Party code
require 'colored'
require 'commander'

module FastlaneCore

end
26 changes: 18 additions & 8 deletions lib/fastlane_core/cert_checker.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
module FastlaneCore
# This class checks if a specific certificate is installed on the current mac
class CertChecker
def self.is_installed?(path)
raise "Could not find file '#{path}'".red unless File.exists?(path)
def self.installed?(path)
raise "Could not find file '#{path}'".red unless File.exist?(path)

ids = installed_identies
finger_print = sha1_fingerprint(path)

return ids.include?finger_print
return ids.include? finger_print
end

# Legacy Method, use `installed?` instead
# rubocop:disable Style/PredicateName
def self.is_installed?(path)
installed?(path)
end
# rubocop:enable Style/PredicateName

def self.installed_identies
available = `security find-identity -v -p codesigning`
ids = []
available.split("\n").each do |current|
unless current.include?"REVOKED"
(ids << current.match(/.*\) (.*) \".*/)[1]) rescue nil # the last line does not match
next if current.include? "REVOKED"
begin
(ids << current.match(/.*\) (.*) \".*/)[1])
rescue
# the last line does not match
end
end

Expand All @@ -26,12 +36,12 @@ def self.sha1_fingerprint(path)
result = `openssl x509 -in "#{path}" -inform der -noout -sha1 -fingerprint`
begin
result = result.match(/SHA1 Fingerprint=(.*)/)[1]
result.gsub!(":", "")
result.delete!(':')
return result
rescue => ex
rescue
Helper.log.info result
raise "Error parsing certificate '#{path}'"
end
end
end
end
end
16 changes: 10 additions & 6 deletions lib/fastlane_core/configuration/commander_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ class CommanderGenerator

# Calls the appropriate methods for commander to show the available parameters
def generate(options)
# First, enable `always_trace`, to show the stack trace
always_trace!

short_codes = []
options.each do |option|
appendix = (option.is_string ? "STRING" : "")
type = (option.is_string ? String : nil)
short_option = option.short_option || "-#{option.key.to_s[0]}"
short_option = option.short_option

raise "Short option #{short_option} already taken for key #{option.key}".red if short_codes.include?short_option
raise "Short option #{short_option} already taken for key #{option.key}".red if short_codes.include? short_option
raise "-v is already used for the version (key #{option.key})".red if short_option == "-v"
raise "-h is already used for the help screen (key #{option.key})".red if short_option == "-h"
raise "-t is already used for the trace screen (key #{option.key})".red if short_option == "-t"
short_codes << short_option

short_codes << short_option if short_option

# Example Call
# c.option '-p', '--pattern STRING', String, 'Description'

flag = "--#{option.key} #{appendix}"
description = (option.description + " (#{option.env_name})")
description = option.description
description += " (#{option.env_name})" if option.env_name.to_s.length > 0

global_option short_option, flag, type, description
end
end
end
end
end
35 changes: 23 additions & 12 deletions lib/fastlane_core/configuration/config_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ class ConfigItem
# @param description (String) A description shown to the user
# @param short_option (String) A string of length 1 which is used for the command parameters (e.g. -f)
# @param default_value the value which is used if there was no given values and no environment values
# @param verify_block an optional block which is called when a new value is set.
# @param verify_block an optional block which is called when a new value is set.
# Check value is valid. This could be type checks or if a folder/file exists
# You have to raise a specific exception if something goes wrong. Append .red after the string
# @param is_string (String) is that parameter a string? Defaults to true. If it's true, the type string will be verified.
# @param optional (Boolean) is false by default. If set to true, also string values will not be asked to the user
def initialize(key: nil, env_name: nil, description: nil, short_option: nil, default_value: nil, verify_block: nil, is_string: true, optional: false)
raise "key must be a symbol" unless key.kind_of?Symbol
raise "env_name must be a String" unless (env_name || '').kind_of?String
raise "key must be a symbol" unless key.kind_of? Symbol
raise "env_name must be a String" unless (env_name || '').kind_of? String
if short_option
raise "short_option must be a String of length 1" unless (short_option.kind_of?String and short_option.gsub('-', '').length == 1)
raise "short_option must be a String of length 1" unless short_option.kind_of? String and short_option.delete('-').length == 1
end
if description
raise "Do not let descriptions end with a '.', since it's used for user inputs as well".red if (description[-1] == '.')
Expand All @@ -33,26 +33,25 @@ def initialize(key: nil, env_name: nil, description: nil, short_option: nil, def
@optional = optional
end


# This will raise an exception if the value is not valid
def verify!(value)
raise "Invalid value '#{value}' for option '#{self}'".red unless is_valid?value
raise "Invalid value '#{value}' for option '#{self}'".red unless valid? value
true
end

# Make sure, the value is valid (based on the verify block)
# Returns false if that's not the case
def is_valid?(value)
# we also allow nil values, which do not have to be verified.
def valid?(value)
# we also allow nil values, which do not have to be verified.
if value
if @is_string
raise "'#{self.key}' value must be a String! Found #{value.class} instead.".red unless value.kind_of?String
raise "'#{self.key}' value must be a String! Found #{value.class} instead.".red unless value.kind_of? String
end

if @verify_block
begin
@verify_block.call(value)
rescue Exception => ex
rescue => ex
Helper.log.fatal "Error setting value '#{value}' for option '#{@key}'".red
raise ex
end
Expand All @@ -62,8 +61,20 @@ def is_valid?(value)
true
end

# Returns an updated value type (if necessary)
def auto_convert_value(value)
# Special treatment if the user specififed true, false or YES, NO
if %w(YES yes true).include?(value)
value = true
elsif %w(NO no false).include?(value)
value = false
end

return value
end

def to_s
[@key, @description].join(": ")
end
end
end
end
Loading