[
  {
    "path": ".rspec",
    "content": "--require spec_helper\n--color\n--format d\n"
  },
  {
    "path": ".rubocop.yml",
    "content": "# kind_of? is a good way to check a type\nStyle/ClassCheck:\n  EnforcedStyle: kind_of?\n\n# It's better to be more explicit about the type\nStyle/BracesAroundHashParameters:\n  Enabled: false\n\n# specs sometimes have useless assignments, which is fine\nLint/UselessAssignment:\n  Exclude:\n    - '**/spec/**/*'\n\n# We could potentially enable the 2 below:\nStyle/IndentHash:\n  Enabled: false\n\nStyle/AlignHash:\n  Enabled: false\n\n# HoundCI doesn't like this rule\nStyle/DotPosition:\n  Enabled: false\n\n# We allow !! as it's an easy way to convert ot boolean\nStyle/DoubleNegation:\n  Enabled: false\n\n# Sometimes we allow a rescue block that doesn't contain code\nLint/HandleExceptions:\n  Enabled: false\n\n# Cop supports --auto-correct.\nLint/UnusedBlockArgument:\n  Enabled: false\n\n# Needed for $verbose\nStyle/GlobalVars:\n  Enabled: false\n\n# We want to allow class Fastlane::Class\nStyle/ClassAndModuleChildren:\n  Enabled: false\n\n# $? Exit\nStyle/SpecialGlobalVars:\n  Enabled: false\n\nMetrics/AbcSize:\n  Max: 60\n  Exclude:\n    - '**/lib/*/options.rb'\n\n# The %w might be confusing for new users\nStyle/WordArray:\n  MinSize: 19\n\n# raise and fail are both okay\nStyle/SignalException:\n  Enabled: false\n\n# Better too much 'return' than one missing\nStyle/RedundantReturn:\n  Enabled: false\n\n# Having if in the same line might not always be good\nStyle/IfUnlessModifier:\n  Enabled: false\n\n# and and or is okay\nStyle/AndOr:\n  Enabled: false\n\n# Configuration parameters: CountComments.\nMetrics/ClassLength:\n  Max: 320\n\nMetrics/CyclomaticComplexity:\n  Max: 17\n\n# Configuration parameters: AllowURI, URISchemes.\nMetrics/LineLength:\n  Max: 370\n\n# Configuration parameters: CountKeywordArgs.\nMetrics/ParameterLists:\n  Max: 17\n\nMetrics/PerceivedComplexity:\n  Max: 18\n\n# Sometimes it's easier to read without guards\nStyle/GuardClause:\n  Enabled: false\n\n# We allow both \" and '\nStyle/StringLiterals:\n  Enabled: false\n\n# something = if something_else\n# that's confusing\nStyle/ConditionalAssignment:\n  Enabled: false\n\n# Better to have too much self than missing a self\nStyle/RedundantSelf:\n  Enabled: false\n\n# e.g.\n# def self.is_supported?(platform)\n# we may never use `platform`\nLint/UnusedMethodArgument:\n  Enabled: false\n\n# the let(:key) { ... }\nLint/ParenthesesAsGroupedExpression:\n  Exclude:\n    - '**/spec/**/*'\n\n# This would reject is_ in front of methods\n# We use `is_supported?` everywhere already\nStyle/PredicateName:\n  Enabled: false\n\n# We allow the $\nStyle/PerlBackrefs:\n  Enabled: false\n\n# Disable '+ should be surrounded with a single space' for xcodebuild_spec.rb\nStyle/SpaceAroundOperators:\n  Exclude:\n    - '**/spec/actions_specs/xcodebuild_spec.rb'\n\nMetrics/MethodLength:\n  Exclude:\n    - '**/lib/fastlane/actions/*.rb'\n    - '**/bin/fastlane'\n    - '**/lib/*/options.rb'\n  Max: 60\n\nAllCops:\n  Include:\n    - '**/fastlane/Fastfile'\n  Exclude:\n    - '**/lib/assets/custom_action_template.rb'\n    - './vendor/**/*'\n\n# We're not there yet\nStyle/Documentation:\n  Enabled: false\n\n# Added after upgrade to 0.38.0\nStyle/MutableConstant:\n  Enabled: false\n\n# length > 0 is good\nStyle/ZeroLengthPredicate:\n  Enabled: false\n\n# Adds complexity\nStyle/IfInsideElse:\n  Enabled: false"
  },
  {
    "path": ".travis.yml",
    "content": "# os: osx # enable this if you need macOS support\nlanguage: ruby\nrvm:\n  - 2.2.4\n"
  },
  {
    "path": "Gemfile",
    "content": "source 'https://rubygems.org'\n\ngemspec\n\nplugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')\neval(File.read(plugins_path), binding) if File.exist?(plugins_path)\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2017 Jems <jeremy.toudic@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# increment_version_code plugin\n\n[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-increment_version_code)\n\n## Getting Started\n\nThis project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-increment_version_code`, add it to your project by running:\n\n```bash\nfastlane add_plugin increment_version_code\n```\n\n## About increment_version_code\n\nIncrement the version code of your android project.\n\n**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.\n\n## Example\n\nCheck 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`. \n\n**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)\n\n## Run tests for this plugin\n\nTo run both the tests, and code style validation, run\n\n```\nrake\n```\n\nTo automatically fix many of the styling issues, use \n```\nrubocop -a\n```\n\n## Issues and Feedback\n\nFor any other issues and feedback about this plugin, please submit it to this repository.\n\n## Troubleshooting\n\nIf you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.\n\n## Using `fastlane` Plugins\n\nFor more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).\n\n## About `fastlane`\n\n`fastlane` is the easiest way to automate building and releasing your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).\n# fastlane-plugin-increment_version_code\n"
  },
  {
    "path": "Rakefile",
    "content": "require 'bundler/gem_tasks'\n\nrequire 'rspec/core/rake_task'\nRSpec::Core::RakeTask.new\n\nrequire 'rubocop/rake_task'\nRuboCop::RakeTask.new(:rubocop)\n\ntask default: [:spec, :rubocop]\n"
  },
  {
    "path": "circle.yml",
    "content": "test:\n  override:\n    - bundle exec rake\nmachine:\n  ruby:\n    version: 2.2.4\n# Enable xcode below if you need macOS\n#   xcode:\n#     version: \"7.3\"\n"
  },
  {
    "path": "fastlane/Fastfile",
    "content": "lane :test do\n  increment_version_code(\n        gradle_file_path: \"project/build.gradle\",\n        #ext_constant_name: \"test\"\n        #app_folder_name:\"app\"\n  )\nend\n"
  },
  {
    "path": "fastlane/Pluginfile",
    "content": "# Autogenerated by fastlane\n"
  },
  {
    "path": "fastlane-plugin-increment_version_code.gemspec",
    "content": "# coding: utf-8\nlib = File.expand_path(\"../lib\", __FILE__)\n$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)\nrequire 'fastlane/plugin/increment_version_code/version'\n\nGem::Specification.new do |spec|\n  spec.name          = 'fastlane-plugin-increment_version_code'\n  spec.version       = Fastlane::IncrementVersionCode::VERSION\n  spec.author        = %q{Jems}\n  spec.email         = %q{jeremy.toudic@gmail.com}\n\n  spec.summary       = %q{Increment the version code of your android project.}\n  spec.homepage      = \"https://github.com/Jems22/fastlane-plugin-increment_version_code\"\n  spec.license       = \"MIT\"\n\n  spec.files         = Dir[\"lib/**/*\"] + %w(README.md LICENSE)\n  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})\n  spec.require_paths = ['lib']\n\n  # spec.add_dependency 'your-dependency', '~> 1.0.0'\n\n  spec.add_development_dependency 'pry'\n  spec.add_development_dependency 'bundler'\n  spec.add_development_dependency 'rspec'\n  spec.add_development_dependency 'rake'\n  spec.add_development_dependency 'rubocop'\n  spec.add_development_dependency 'fastlane', '>= 1.99.0'\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/increment_version_code/actions/increment_version_code_action.rb",
    "content": "require 'tempfile'\nrequire 'fileutils'\n\nmodule Fastlane\n  module Actions\n    class IncrementVersionCodeAction < Action\n      def self.run(params)\n\n        version_code = \"0\"\n        new_version_code ||= params[:version_code]\n\n        constant_name ||= params[:ext_constant_name]\n\n        gradle_file_path ||= params[:gradle_file_path]\n        if gradle_file_path != nil\n            UI.message(\"The increment_version_code plugin will use gradle file at (#{gradle_file_path})!\")\n            new_version_code = incrementVersion(gradle_file_path, new_version_code, constant_name)\n        else\n            app_folder_name ||= params[:app_folder_name]\n            UI.message(\"The get_version_code plugin is looking inside your project folder (#{app_folder_name})!\")\n\n            #temp_file = Tempfile.new('fastlaneIncrementVersionCode')\n            #foundVersionCode = \"false\"\n            Dir.glob(\"**/#{app_folder_name}/build.gradle\") do |path|\n                UI.message(\" -> Found a build.gradle file at path: (#{path})!\")\n                new_version_code = incrementVersion(path, new_version_code, constant_name)\n            end\n\n        end\n\n        if new_version_code == -1\n            UI.user_error!(\"Impossible to find the version code with the specified properties 😭\")\n        else\n            # Store the version name in the shared hash\n            Actions.lane_context[\"VERSION_CODE\"]=new_version_code\n            UI.success(\"☝️ Version code has been changed to #{new_version_code}\")\n        end\n\n        return new_version_code\n      end\n\n      def self.incrementVersion(path, new_version_code, constant_name)\n          if !File.file?(path)\n              UI.message(\" -> No file exist at path: (#{path})!\")\n              return -1\n          end\n          begin\n              foundVersionCode = \"false\"\n              temp_file = Tempfile.new('fastlaneIncrementVersionCode')\n              File.open(path, 'r') do |file|\n                  file.each_line do |line|\n                      if line.include? constant_name and foundVersionCode==\"false\"\n                          UI.message(\" -> line: (#{line})!\")\n                        versionComponents = line.strip.split(' ')\n                        version_code = versionComponents[versionComponents.length-1].tr(\"\\\"\",\"\")\n                        if new_version_code <= 0\n                            new_version_code = version_code.to_i + 1\n                        end\n                        if !!(version_code =~ /\\A[-+]?[0-9]+\\z/)\n                            line.replace line.sub(version_code, new_version_code.to_s)\n                            foundVersionCode = \"true\"\n                        end\n                        temp_file.puts line\n                      else\n                      temp_file.puts line\n                   end\n              end\n              file.close\n            end\n            temp_file.rewind\n            temp_file.close\n            FileUtils.mv(temp_file.path, path)\n            temp_file.unlink\n          end\n          if foundVersionCode == \"true\"\n              return new_version_code\n          end\n          return -1\n      end\n\n      def self.description\n        \"Increment the version code of your android project.\"\n      end\n\n      def self.authors\n        [\"Jems\"]\n      end\n\n      def self.available_options\n          [\n              FastlaneCore::ConfigItem.new(key: :app_folder_name,\n                                      env_name: \"INCREMENTVERSIONCODE_APP_FOLDER_NAME\",\n                                   description: \"The name of the application source folder in the Android project (default: app)\",\n                                      optional: true,\n                                          type: String,\n                                 default_value:\"app\"),\n             FastlaneCore::ConfigItem.new(key: :gradle_file_path,\n                                     env_name: \"INCREMENTVERSIONCODE_GRADLE_FILE_PATH\",\n                                  description: \"The relative path to the gradle file containing the version code parameter (default:app/build.gradle)\",\n                                     optional: true,\n                                         type: String,\n                                default_value: nil),\n              FastlaneCore::ConfigItem.new(key: :version_code,\n                                      env_name: \"INCREMENTVERSIONCODE_VERSION_CODE\",\n                                   description: \"Change to a specific version (optional)\",\n                                      optional: true,\n                                          type: Integer,\n                                 default_value: 0),\n              FastlaneCore::ConfigItem.new(key: :ext_constant_name,\n                                      env_name: \"INCREMENTVERSIONCODE_EXT_CONSTANT_NAME\",\n                                   description: \"If the version code is set in an ext constant, specify the constant name (optional)\",\n                                      optional: true,\n                                          type: String,\n                                 default_value: \"versionCode\")\n          ]\n      end\n\n      def self.output\n        [\n          ['VERSION_CODE', 'The new version code of the project']\n        ]\n      end\n\n      def self.is_supported?(platform)\n        [:android].include?(platform)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/increment_version_code/helper/increment_version_code_helper.rb",
    "content": "module Fastlane\n  module Helper\n    class IncrementVersionCodeHelper\n      # class methods that you define here become available in your action\n      # as `Helper::IncrementVersionCodeHelper.your_method`\n      #\n      def self.show_message\n        UI.message(\"Hello from the increment_version_code plugin helper!\")\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/increment_version_code/version.rb",
    "content": "module Fastlane\n  module IncrementVersionCode\n    VERSION = \"0.4.3\"\n  end\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/increment_version_code.rb",
    "content": "require 'fastlane/plugin/increment_version_code/version'\n\nmodule Fastlane\n  module IncrementVersionCode\n    # Return all .rb files inside the \"actions\" and \"helper\" directory\n    def self.all_classes\n      Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]\n    end\n  end\nend\n\n# By default we want to import all available actions and helpers\n# A plugin can contain any number of actions and plugins\nFastlane::IncrementVersionCode.all_classes.each do |current|\n  require current\nend\n"
  },
  {
    "path": "spec/increment_version_code_action_spec.rb",
    "content": "describe Fastlane::Actions::IncrementVersionCodeAction do\n  describe '#run' do\n    it 'prints a message' do\n      expect(Fastlane::UI).to receive(:message).with(\"The increment_version_code plugin is working!\")\n\n      Fastlane::Actions::IncrementVersionCodeAction.run(nil)\n    end\n  end\nend\n"
  },
  {
    "path": "spec/spec_helper.rb",
    "content": "$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)\n\n# This module is only used to check the environment is currently a testing env\nmodule SpecHelper\nend\n\nrequire 'fastlane' # to import the Action super class\nrequire 'fastlane/plugin/increment_version_code' # import the actual plugin\n\nFastlane.load_actions # load other actions (in case your plugin calls other actions or shared values)\n"
  }
]