class Fastlane::Actions::UpgradePackageJsonVersionAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/npm/actions/upgrade_package_json_version_action.rb, line 41 def self.available_options [ FastlaneCore::ConfigItem.new(key: :new_version, default_value: "Installing dependencies", description: "Name for this step", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :version_match, default_value: '(\d+\.\d+\.\d+)', description: "Regex to match the version", optional: true, type: String), ] end
description()
click to toggle source
# File lib/fastlane/plugin/npm/actions/upgrade_package_json_version_action.rb, line 24 def self.description "A very simple plugin to run npm scripts" end
details()
click to toggle source
# File lib/fastlane/plugin/npm/actions/upgrade_package_json_version_action.rb, line 36 def self.details # Optional: "A very simple plugin to run npm scripts" end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/npm/actions/upgrade_package_json_version_action.rb, line 57 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
return_value()
click to toggle source
# File lib/fastlane/plugin/npm/actions/upgrade_package_json_version_action.rb, line 32 def self.return_value # If your method provides a return value, you can describe here what it does end
run(params)
click to toggle source
# File lib/fastlane/plugin/npm/actions/upgrade_package_json_version_action.rb, line 7 def self.run(params) UI.message "Changing package.json version to #{params[:new_version]}" root_dir = Helper::NpmHelper.find_root_dir UI.user_error! "apparently it's not running inside a node project. package.json cannot be found" unless root_dir package_json_path = File.join(root_dir, 'package.json') regex = Regexp.new("\"version\": \"#{params[:version_match]}\"") Helper::NpmHelper.update_file_content( file_name: package_json_path, search: regex, replace: "\"version\": \"#{params[:new_version]}\"" ) end