master c5b56f9b4728 cached
17 files
14.8 KB
3.9k tokens
20 symbols
1 requests
Download .txt
Repository: Jems22/fastlane-plugin-increment_version_code
Branch: master
Commit: c5b56f9b4728
Files: 17
Total size: 14.8 KB

Directory structure:
gitextract_vmqjrexn/

├── .rspec
├── .rubocop.yml
├── .travis.yml
├── Gemfile
├── LICENSE
├── README.md
├── Rakefile
├── circle.yml
├── fastlane/
│   ├── Fastfile
│   └── Pluginfile
├── fastlane-plugin-increment_version_code.gemspec
├── lib/
│   └── fastlane/
│       └── plugin/
│           ├── increment_version_code/
│           │   ├── actions/
│           │   │   └── increment_version_code_action.rb
│           │   ├── helper/
│           │   │   └── increment_version_code_helper.rb
│           │   └── version.rb
│           └── increment_version_code.rb
└── spec/
    ├── increment_version_code_action_spec.rb
    └── spec_helper.rb

================================================
FILE CONTENTS
================================================

================================================
FILE: .rspec
================================================
--require spec_helper
--color
--format d


================================================
FILE: .rubocop.yml
================================================
# kind_of? is a good way to check a type
Style/ClassCheck:
  EnforcedStyle: kind_of?

# It's better to be more explicit about the type
Style/BracesAroundHashParameters:
  Enabled: false

# specs sometimes have useless assignments, which is fine
Lint/UselessAssignment:
  Exclude:
    - '**/spec/**/*'

# We could potentially enable the 2 below:
Style/IndentHash:
  Enabled: false

Style/AlignHash:
  Enabled: false

# HoundCI doesn't like this rule
Style/DotPosition:
  Enabled: false

# We allow !! as it's an easy way to convert ot boolean
Style/DoubleNegation:
  Enabled: false

# Sometimes we allow a rescue block that doesn't contain code
Lint/HandleExceptions:
  Enabled: false

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

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

# We want to allow class Fastlane::Class
Style/ClassAndModuleChildren:
  Enabled: false

# $? Exit
Style/SpecialGlobalVars:
  Enabled: false

Metrics/AbcSize:
  Max: 60
  Exclude:
    - '**/lib/*/options.rb'

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

# 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

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

# 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

# Sometimes it's easier to read without guards
Style/GuardClause:
  Enabled: false

# We allow both " and '
Style/StringLiterals:
  Enabled: false

# something = if something_else
# that's confusing
Style/ConditionalAssignment:
  Enabled: false

# Better to have too much self than missing a self
Style/RedundantSelf:
  Enabled: false

# e.g.
# def self.is_supported?(platform)
# we may never use `platform`
Lint/UnusedMethodArgument:
  Enabled: false

# the let(:key) { ... }
Lint/ParenthesesAsGroupedExpression:
  Exclude:
    - '**/spec/**/*'

# This would reject is_ in front of methods
# We use `is_supported?` everywhere already
Style/PredicateName:
  Enabled: false

# We allow the $
Style/PerlBackrefs:
  Enabled: false

# Disable '+ should be surrounded with a single space' for xcodebuild_spec.rb
Style/SpaceAroundOperators:
  Exclude:
    - '**/spec/actions_specs/xcodebuild_spec.rb'

Metrics/MethodLength:
  Exclude:
    - '**/lib/fastlane/actions/*.rb'
    - '**/bin/fastlane'
    - '**/lib/*/options.rb'
  Max: 60

AllCops:
  Include:
    - '**/fastlane/Fastfile'
  Exclude:
    - '**/lib/assets/custom_action_template.rb'
    - './vendor/**/*'

# We're not there yet
Style/Documentation:
  Enabled: false

# Added after upgrade to 0.38.0
Style/MutableConstant:
  Enabled: false

# length > 0 is good
Style/ZeroLengthPredicate:
  Enabled: false

# Adds complexity
Style/IfInsideElse:
  Enabled: false

================================================
FILE: .travis.yml
================================================
# os: osx # enable this if you need macOS support
language: ruby
rvm:
  - 2.2.4


================================================
FILE: Gemfile
================================================
source 'https://rubygems.org'

gemspec

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval(File.read(plugins_path), binding) if File.exist?(plugins_path)


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2017 Jems <jeremy.toudic@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# increment_version_code plugin

[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-increment_version_code)

## Getting Started

This 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:

```bash
fastlane add_plugin increment_version_code
```

## About increment_version_code

Increment the version code of your android project.

**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.

## 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`. 

**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)

## Run tests for this plugin

To run both the tests, and code style validation, run

```
rake
```

To automatically fix many of the styling issues, use 
```
rubocop -a
```

## Issues and Feedback

For any other issues and feedback about this plugin, please submit it to this repository.

## Troubleshooting

If 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.

## Using `fastlane` Plugins

For 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).

## About `fastlane`

`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).
# fastlane-plugin-increment_version_code


================================================
FILE: Rakefile
================================================
require 'bundler/gem_tasks'

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)

task default: [:spec, :rubocop]


================================================
FILE: circle.yml
================================================
test:
  override:
    - bundle exec rake
machine:
  ruby:
    version: 2.2.4
# Enable xcode below if you need macOS
#   xcode:
#     version: "7.3"


================================================
FILE: fastlane/Fastfile
================================================
lane :test do
  increment_version_code(
        gradle_file_path: "project/build.gradle",
        #ext_constant_name: "test"
        #app_folder_name:"app"
  )
end


================================================
FILE: fastlane/Pluginfile
================================================
# Autogenerated by fastlane


================================================
FILE: fastlane-plugin-increment_version_code.gemspec
================================================
# coding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fastlane/plugin/increment_version_code/version'

Gem::Specification.new do |spec|
  spec.name          = 'fastlane-plugin-increment_version_code'
  spec.version       = Fastlane::IncrementVersionCode::VERSION
  spec.author        = %q{Jems}
  spec.email         = %q{jeremy.toudic@gmail.com}

  spec.summary       = %q{Increment the version code of your android project.}
  spec.homepage      = "https://github.com/Jems22/fastlane-plugin-increment_version_code"
  spec.license       = "MIT"

  spec.files         = Dir["lib/**/*"] + %w(README.md LICENSE)
  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
  spec.require_paths = ['lib']

  # spec.add_dependency 'your-dependency', '~> 1.0.0'

  spec.add_development_dependency 'pry'
  spec.add_development_dependency 'bundler'
  spec.add_development_dependency 'rspec'
  spec.add_development_dependency 'rake'
  spec.add_development_dependency 'rubocop'
  spec.add_development_dependency 'fastlane', '>= 1.99.0'
end


================================================
FILE: lib/fastlane/plugin/increment_version_code/actions/increment_version_code_action.rb
================================================
require 'tempfile'
require 'fileutils'

module Fastlane
  module Actions
    class IncrementVersionCodeAction < Action
      def self.run(params)

        version_code = "0"
        new_version_code ||= params[:version_code]

        constant_name ||= params[:ext_constant_name]

        gradle_file_path ||= params[:gradle_file_path]
        if gradle_file_path != nil
            UI.message("The increment_version_code plugin will use gradle file at (#{gradle_file_path})!")
            new_version_code = incrementVersion(gradle_file_path, new_version_code, constant_name)
        else
            app_folder_name ||= params[:app_folder_name]
            UI.message("The get_version_code plugin is looking inside your project folder (#{app_folder_name})!")

            #temp_file = Tempfile.new('fastlaneIncrementVersionCode')
            #foundVersionCode = "false"
            Dir.glob("**/#{app_folder_name}/build.gradle") do |path|
                UI.message(" -> Found a build.gradle file at path: (#{path})!")
                new_version_code = incrementVersion(path, new_version_code, constant_name)
            end

        end

        if new_version_code == -1
            UI.user_error!("Impossible to find the version code with the specified properties 😭")
        else
            # Store the version name in the shared hash
            Actions.lane_context["VERSION_CODE"]=new_version_code
            UI.success("☝️ Version code has been changed to #{new_version_code}")
        end

        return new_version_code
      end

      def self.incrementVersion(path, new_version_code, constant_name)
          if !File.file?(path)
              UI.message(" -> No file exist at path: (#{path})!")
              return -1
          end
          begin
              foundVersionCode = "false"
              temp_file = Tempfile.new('fastlaneIncrementVersionCode')
              File.open(path, 'r') do |file|
                  file.each_line do |line|
                      if line.include? constant_name and foundVersionCode=="false"
                          UI.message(" -> line: (#{line})!")
                        versionComponents = line.strip.split(' ')
                        version_code = versionComponents[versionComponents.length-1].tr("\"","")
                        if new_version_code <= 0
                            new_version_code = version_code.to_i + 1
                        end
                        if !!(version_code =~ /\A[-+]?[0-9]+\z/)
                            line.replace line.sub(version_code, new_version_code.to_s)
                            foundVersionCode = "true"
                        end
                        temp_file.puts line
                      else
                      temp_file.puts line
                   end
              end
              file.close
            end
            temp_file.rewind
            temp_file.close
            FileUtils.mv(temp_file.path, path)
            temp_file.unlink
          end
          if foundVersionCode == "true"
              return new_version_code
          end
          return -1
      end

      def self.description
        "Increment the version code of your android project."
      end

      def self.authors
        ["Jems"]
      end

      def self.available_options
          [
              FastlaneCore::ConfigItem.new(key: :app_folder_name,
                                      env_name: "INCREMENTVERSIONCODE_APP_FOLDER_NAME",
                                   description: "The name of the application source folder in the Android project (default: app)",
                                      optional: true,
                                          type: String,
                                 default_value:"app"),
             FastlaneCore::ConfigItem.new(key: :gradle_file_path,
                                     env_name: "INCREMENTVERSIONCODE_GRADLE_FILE_PATH",
                                  description: "The relative path to the gradle file containing the version code parameter (default:app/build.gradle)",
                                     optional: true,
                                         type: String,
                                default_value: nil),
              FastlaneCore::ConfigItem.new(key: :version_code,
                                      env_name: "INCREMENTVERSIONCODE_VERSION_CODE",
                                   description: "Change to a specific version (optional)",
                                      optional: true,
                                          type: Integer,
                                 default_value: 0),
              FastlaneCore::ConfigItem.new(key: :ext_constant_name,
                                      env_name: "INCREMENTVERSIONCODE_EXT_CONSTANT_NAME",
                                   description: "If the version code is set in an ext constant, specify the constant name (optional)",
                                      optional: true,
                                          type: String,
                                 default_value: "versionCode")
          ]
      end

      def self.output
        [
          ['VERSION_CODE', 'The new version code of the project']
        ]
      end

      def self.is_supported?(platform)
        [:android].include?(platform)
      end
    end
  end
end


================================================
FILE: lib/fastlane/plugin/increment_version_code/helper/increment_version_code_helper.rb
================================================
module Fastlane
  module Helper
    class IncrementVersionCodeHelper
      # class methods that you define here become available in your action
      # as `Helper::IncrementVersionCodeHelper.your_method`
      #
      def self.show_message
        UI.message("Hello from the increment_version_code plugin helper!")
      end
    end
  end
end


================================================
FILE: lib/fastlane/plugin/increment_version_code/version.rb
================================================
module Fastlane
  module IncrementVersionCode
    VERSION = "0.4.3"
  end
end


================================================
FILE: lib/fastlane/plugin/increment_version_code.rb
================================================
require 'fastlane/plugin/increment_version_code/version'

module Fastlane
  module IncrementVersionCode
    # Return all .rb files inside the "actions" and "helper" directory
    def self.all_classes
      Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
    end
  end
end

# By default we want to import all available actions and helpers
# A plugin can contain any number of actions and plugins
Fastlane::IncrementVersionCode.all_classes.each do |current|
  require current
end


================================================
FILE: spec/increment_version_code_action_spec.rb
================================================
describe Fastlane::Actions::IncrementVersionCodeAction do
  describe '#run' do
    it 'prints a message' do
      expect(Fastlane::UI).to receive(:message).with("The increment_version_code plugin is working!")

      Fastlane::Actions::IncrementVersionCodeAction.run(nil)
    end
  end
end


================================================
FILE: spec/spec_helper.rb
================================================
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

# This module is only used to check the environment is currently a testing env
module SpecHelper
end

require 'fastlane' # to import the Action super class
require 'fastlane/plugin/increment_version_code' # import the actual plugin

Fastlane.load_actions # load other actions (in case your plugin calls other actions or shared values)
Download .txt
gitextract_vmqjrexn/

├── .rspec
├── .rubocop.yml
├── .travis.yml
├── Gemfile
├── LICENSE
├── README.md
├── Rakefile
├── circle.yml
├── fastlane/
│   ├── Fastfile
│   └── Pluginfile
├── fastlane-plugin-increment_version_code.gemspec
├── lib/
│   └── fastlane/
│       └── plugin/
│           ├── increment_version_code/
│           │   ├── actions/
│           │   │   └── increment_version_code_action.rb
│           │   ├── helper/
│           │   │   └── increment_version_code_helper.rb
│           │   └── version.rb
│           └── increment_version_code.rb
└── spec/
    ├── increment_version_code_action_spec.rb
    └── spec_helper.rb
Download .txt
SYMBOL INDEX (20 symbols across 5 files)

FILE: lib/fastlane/plugin/increment_version_code.rb
  type Fastlane (line 3) | module Fastlane
    type IncrementVersionCode (line 4) | module IncrementVersionCode
      function all_classes (line 6) | def self.all_classes

FILE: lib/fastlane/plugin/increment_version_code/actions/increment_version_code_action.rb
  type Fastlane (line 4) | module Fastlane
    type Actions (line 5) | module Actions
      class IncrementVersionCodeAction (line 6) | class IncrementVersionCodeAction < Action
        method run (line 7) | def self.run(params)
        method incrementVersion (line 42) | def self.incrementVersion(path, new_version_code, constant_name)
        method description (line 81) | def self.description
        method authors (line 85) | def self.authors
        method available_options (line 89) | def self.available_options
        method output (line 118) | def self.output
        method is_supported? (line 124) | def self.is_supported?(platform)

FILE: lib/fastlane/plugin/increment_version_code/helper/increment_version_code_helper.rb
  type Fastlane (line 1) | module Fastlane
    type Helper (line 2) | module Helper
      class IncrementVersionCodeHelper (line 3) | class IncrementVersionCodeHelper
        method show_message (line 7) | def self.show_message

FILE: lib/fastlane/plugin/increment_version_code/version.rb
  type Fastlane (line 1) | module Fastlane
    type IncrementVersionCode (line 2) | module IncrementVersionCode

FILE: spec/spec_helper.rb
  type SpecHelper (line 4) | module SpecHelper
Condensed preview — 17 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (17K chars).
[
  {
    "path": ".rspec",
    "chars": 41,
    "preview": "--require spec_helper\n--color\n--format d\n"
  },
  {
    "path": ".rubocop.yml",
    "chars": 3140,
    "preview": "# 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 "
  },
  {
    "path": ".travis.yml",
    "chars": 80,
    "preview": "# os: osx # enable this if you need macOS support\nlanguage: ruby\nrvm:\n  - 2.2.4\n"
  },
  {
    "path": "Gemfile",
    "chars": 183,
    "preview": "source 'https://rubygems.org'\n\ngemspec\n\nplugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')\neval("
  },
  {
    "path": "LICENSE",
    "chars": 1097,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2017 Jems <jeremy.toudic@gmail.com>\n\nPermission is hereby granted, free of charge, "
  },
  {
    "path": "README.md",
    "chars": 2076,
    "preview": "# increment_version_code plugin\n\n[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/"
  },
  {
    "path": "Rakefile",
    "chars": 180,
    "preview": "require 'bundler/gem_tasks'\n\nrequire 'rspec/core/rake_task'\nRSpec::Core::RakeTask.new\n\nrequire 'rubocop/rake_task'\nRuboC"
  },
  {
    "path": "circle.yml",
    "chars": 148,
    "preview": "test:\n  override:\n    - bundle exec rake\nmachine:\n  ruby:\n    version: 2.2.4\n# Enable xcode below if you need macOS\n#   "
  },
  {
    "path": "fastlane/Fastfile",
    "chars": 164,
    "preview": "lane :test do\n  increment_version_code(\n        gradle_file_path: \"project/build.gradle\",\n        #ext_constant_name: \"t"
  },
  {
    "path": "fastlane/Pluginfile",
    "chars": 28,
    "preview": "# Autogenerated by fastlane\n"
  },
  {
    "path": "fastlane-plugin-increment_version_code.gemspec",
    "chars": 1106,
    "preview": "# coding: utf-8\nlib = File.expand_path(\"../lib\", __FILE__)\n$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)\nrequi"
  },
  {
    "path": "lib/fastlane/plugin/increment_version_code/actions/increment_version_code_action.rb",
    "chars": 5348,
    "preview": "require 'tempfile'\nrequire 'fileutils'\n\nmodule Fastlane\n  module Actions\n    class IncrementVersionCodeAction < Action\n "
  },
  {
    "path": "lib/fastlane/plugin/increment_version_code/helper/increment_version_code_helper.rb",
    "chars": 343,
    "preview": "module Fastlane\n  module Helper\n    class IncrementVersionCodeHelper\n      # class methods that you define here become a"
  },
  {
    "path": "lib/fastlane/plugin/increment_version_code/version.rb",
    "chars": 78,
    "preview": "module Fastlane\n  module IncrementVersionCode\n    VERSION = \"0.4.3\"\n  end\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/increment_version_code.rb",
    "chars": 504,
    "preview": "require 'fastlane/plugin/increment_version_code/version'\n\nmodule Fastlane\n  module IncrementVersionCode\n    # Return all"
  },
  {
    "path": "spec/increment_version_code_action_spec.rb",
    "chars": 290,
    "preview": "describe Fastlane::Actions::IncrementVersionCodeAction do\n  describe '#run' do\n    it 'prints a message' do\n      expect"
  },
  {
    "path": "spec/spec_helper.rb",
    "chars": 395,
    "preview": "$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)\n\n# This module is only used to check the environment is curre"
  }
]

About this extraction

This page contains the full source code of the Jems22/fastlane-plugin-increment_version_code GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 17 files (14.8 KB), approximately 3.9k tokens, and a symbol index with 20 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!