fastlane-plugin-twine 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b681ccb119a37f145ca75684c638a361b7e0f9cc
4
+ data.tar.gz: e10edc315e947b499c9eea326a1747062623ac73
5
+ SHA512:
6
+ metadata.gz: 62b931db18e891ddd9994ae4190fe0efa2d6a3f2dcd6501ef7f93c6589eb4ba1f70c1b217d3ab874e1251c53f002c898c12aa5eeca6aecde7c89c764fa759d38
7
+ data.tar.gz: 1b4d4ae39c664f9ddc953f2efa4c9ae3981bc36fe82b1eb84068fe46afc00302e340f751e0f03ab91d113d0d9366b82a3d37ed234f5e20bb410ad90c527ad63b
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-present the fastlane authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # twine plugin
2
+
3
+ [![Travis CI](https://img.shields.io/travis/jonasrottmann/fastlane-plugin-twine.svg?style=flat)](https://travis-ci.org/jonasrottmann/fastlane-plugin-twine)
4
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-twine)
5
+ [![Gem](https://img.shields.io/gem/v/fastlane-plugin-twine.svg?style=flat)](http://rubygems.org/gems/fastlane-plugin-twine)
6
+ [![License](https://img.shields.io/github/license/SiarheiFedartsou/fastlane-plugin-twine.svg)](https://github.com/jonasrottmann/fastlane-plugin-twine/blob/master/LICENSE)
7
+
8
+
9
+ ## Getting Started
10
+
11
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-twine`, add it to your project by running:
12
+
13
+ ```bash
14
+ fastlane add_plugin twine
15
+ ```
16
+
17
+ ## About the plugin
18
+
19
+ This plugin provides easy access to common actions (e.g. generating the localization files) you would normally perform with [_twine_](https://github.com/scelis/twine) and adds some extra functionality.
20
+
21
+ ### Configuration file
22
+
23
+ Check out the [example configuration](fastlane/example_config.json).
24
+
25
+ JSON file scheme:
26
+
27
+ ```json
28
+ [
29
+ {
30
+ "description": "",
31
+ "source_path": "",
32
+ "twine_args": "",
33
+ "destination_path": ""
34
+ }
35
+ ]
36
+ ```
37
+
38
+ * `description`: This is optional but recommended to make the output more readable.
39
+ * `source_path`: The path to your twine file. This is required.
40
+ * `twine_args`: Additional args to pass to twine. For example: `--lang en --format android`
41
+ * `destination_path`: The path where the generated translation file will be found. This is required.
42
+
43
+
44
+ ## Example
45
+
46
+ 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 all`.
47
+
48
+ ## Troubleshooting
49
+
50
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/twine/version'
2
+
3
+ module Fastlane
4
+ module Twine
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Twine.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,69 @@
1
+ module Fastlane
2
+ module Actions
3
+ class TwineCheckAction < Action
4
+ def self.run(params)
5
+ require 'diffy'
6
+ Actions.verify_gem!('twine')
7
+ Helper::TwineConfigParser.parse(params).each do |config|
8
+ if !File.exist?(config.source_path)
9
+ UI.user_error!("Source file #{config.source_path} not found")
10
+ else
11
+ UI.message(config.description)
12
+ cmd = Helper::TwineCommandHelper.generate_command(config.source_path, config.destination_path + '.tmp', config.twine_args)
13
+ cmd.prepend('bundle exec ') if params[:use_bundle_exec] && shell_out_should_use_bundle_exec?
14
+ Actions.sh(cmd, error_callback: lambda { |e|
15
+ UI.user_error!('Error while generating localization file ' + config.destination_path)
16
+ })
17
+ files_are_the_same = FileUtils.compare_file(config.destination_path, config.destination_path + '.tmp')
18
+ if params[:visualize_diff] && !files_are_the_same
19
+ UI.message("#{config.destination_path}:")
20
+ puts Diffy::Diff.new(config.destination_path, config.destination_path + '.tmp', source: 'files').to_s(:color)
21
+ end
22
+ File.delete(config.destination_path + '.tmp')
23
+ UI.build_failure!("Localization file #{config.destination_path} differs from the source file #{config.source_path}") unless files_are_the_same
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.description
29
+ 'Checks the source twine file against the localization file to make sure they are in sync'
30
+ end
31
+
32
+ def self.available_options
33
+ [
34
+ FastlaneCore::ConfigItem.new(key: :configuration_path,
35
+ env_name: 'TWINE_CONFIGURATION_PATH',
36
+ description: 'Location to json file with configuration information',
37
+ is_string: true,
38
+ optional: false),
39
+ FastlaneCore::ConfigItem.new(key: :visualize_diff,
40
+ env_name: "TWINE_VISUALIZE_DIFF",
41
+ description: "Display the diff of the files in case of a failure",
42
+ is_string: false,
43
+ default_value: true),
44
+ FastlaneCore::ConfigItem.new(key: :use_bundle_exec,
45
+ env_name: "TWINE_USE_BUNDLE_EXEC",
46
+ description: "Use bundle exec when there is a Gemfile presented",
47
+ is_string: false,
48
+ default_value: true)
49
+ ]
50
+ end
51
+
52
+ def self.authors
53
+ ['Jonas Rottmann']
54
+ end
55
+
56
+ def self.is_supported?(_platform)
57
+ true
58
+ end
59
+
60
+ def self.category
61
+ :building
62
+ end
63
+
64
+ def self.action_name
65
+ name.split('::').last.gsub('Action', '').fastlane_underscore
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,56 @@
1
+ module Fastlane
2
+ module Actions
3
+ class TwineGenerateAction < Action
4
+ def self.run(params)
5
+ Actions.verify_gem!('twine')
6
+ Helper::TwineConfigParser.parse(params).each do |config|
7
+ if !File.exist?(config.source_path)
8
+ UI.user_error!("Source file #{config.source_path} not found")
9
+ else
10
+ UI.message(config.description)
11
+ cmd = Helper::TwineCommandHelper.generate_command(config.source_path, config.destination_path, config.twine_args)
12
+ cmd.prepend('bundle exec ') if params[:use_bundle_exec] && shell_out_should_use_bundle_exec?
13
+ Actions.sh(cmd, error_callback: lambda { |e|
14
+ UI.user_error!('Error while generating localization file ' + config.destination_path)
15
+ })
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.description
21
+ 'Generates all localization files specified by the configuration file'
22
+ end
23
+
24
+ def self.available_options
25
+ [
26
+ FastlaneCore::ConfigItem.new(key: :configuration_path,
27
+ env_name: 'TWINE_CONFIGURATION_PATH',
28
+ description: 'Location to json file with configuration information',
29
+ is_string: true,
30
+ optional: false),
31
+ FastlaneCore::ConfigItem.new(key: :use_bundle_exec,
32
+ env_name: "TWINE_USE_BUNDLE_EXEC",
33
+ description: "Use bundle exec when there is a Gemfile presented",
34
+ is_string: false,
35
+ default_value: true)
36
+ ]
37
+ end
38
+
39
+ def self.authors
40
+ ['Jonas Rottmann']
41
+ end
42
+
43
+ def self.is_supported?(_platform)
44
+ true
45
+ end
46
+
47
+ def self.category
48
+ :building
49
+ end
50
+
51
+ def self.action_name
52
+ name.split('::').last.gsub('Action', '').fastlane_underscore
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,61 @@
1
+ module Fastlane
2
+ module Actions
3
+ class TwineValidateAction < Action
4
+ def self.run(params)
5
+ Actions.verify_gem!('twine')
6
+ Helper::TwineConfigParser.parse(params).map(&:source_path).uniq.each do |source_path|
7
+ if !File.exist?(source_path)
8
+ UI.user_error!("Source file #{source_path} not found")
9
+ else
10
+ cmd = Helper::TwineCommandHelper.validate_command(source_path, params[:pedantic])
11
+ cmd.prepend('bundle exec ') if params[:use_bundle_exec] && shell_out_should_use_bundle_exec?
12
+ Actions.sh(cmd, error_callback: lambda { |result|
13
+ UI.build_failure!(result)
14
+ })
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.description
20
+ 'Validates all twine files mentioned in the config file'
21
+ end
22
+
23
+ def self.available_options
24
+ [
25
+ FastlaneCore::ConfigItem.new(key: :configuration_path,
26
+ env_name: 'TWINE_CONFIGURATION_PATH',
27
+ description: 'Location to json file with configuration information',
28
+ is_string: true,
29
+ optional: false),
30
+ FastlaneCore::ConfigItem.new(key: :pedantic,
31
+ env_name: 'TWINE_VALIDATE_PEDANTIC',
32
+ description: 'Run the validation using twines `pedantic` flag',
33
+ is_string: false,
34
+ optional: true,
35
+ default_value: false),
36
+ FastlaneCore::ConfigItem.new(key: :use_bundle_exec,
37
+ env_name: "TWINE_USE_BUNDLE_EXEC",
38
+ description: "Use bundle exec when there is a Gemfile presented",
39
+ is_string: false,
40
+ default_value: true)
41
+ ]
42
+ end
43
+
44
+ def self.authors
45
+ ['Jonas Rottmann']
46
+ end
47
+
48
+ def self.is_supported?(_platform)
49
+ true
50
+ end
51
+
52
+ def self.category
53
+ :building
54
+ end
55
+
56
+ def self.action_name
57
+ name.split('::').last.gsub('Action', '').fastlane_underscore
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,58 @@
1
+ module Fastlane
2
+ module Helper
3
+ class TwineConfig
4
+ attr_accessor :description, :source_path, :twine_args, :destination_path
5
+ def initialize(description, source_path, twine_args, destination_path)
6
+ @description = description
7
+ @source_path = source_path
8
+ @twine_args = twine_args
9
+ @destination_path = destination_path
10
+ end
11
+ end
12
+
13
+ class TwineConfigParser
14
+ def self.parse(params)
15
+ require 'json'
16
+ config_json = read_config_file(params)
17
+ UI.user_error!("Config file " + params[:configuration_path] + " not found") if config_json.nil?
18
+ UI.user_error!("Config file is of wrong format") unless validate_config_schema(config_json)
19
+ return JSON.parse(config_json).map { |c| TwineConfig.new(c['description'], c['source_path'], c['twine_args'], c['destination_path']) }
20
+ end
21
+
22
+ def self.read_config_file(params)
23
+ require 'fileutils'
24
+ if File.exist?(params[:configuration_path])
25
+ return File.read(params[:configuration_path])
26
+ else
27
+ return nil
28
+ end
29
+ end
30
+
31
+ def self.validate_config_schema(json)
32
+ require "json-schema"
33
+ schema = {
34
+ "type" => "object",
35
+ "properties" => {
36
+ "source_path" => {
37
+ "type" => "string"
38
+ },
39
+ "twine_args" => {
40
+ "type" => "string"
41
+ },
42
+ "destination_path" => {
43
+ "type" => "string"
44
+ },
45
+ "description" => {
46
+ "type" => "string"
47
+ }
48
+ },
49
+ "required" => [
50
+ "source_path",
51
+ "destination_path"
52
+ ]
53
+ }
54
+ return JSON::Validator.validate(schema, json, list: true)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,22 @@
1
+ module Fastlane
2
+ module Helper
3
+ class TwineCommandHelper
4
+ def self.generate_command(path_to_twine_file, destination_path, twine_args)
5
+ cmd = []
6
+ cmd << ['twine generate-localization-file']
7
+ cmd << [path_to_twine_file]
8
+ cmd << [destination_path]
9
+ cmd << [twine_args]
10
+ return cmd.join(' ')
11
+ end
12
+
13
+ def self.validate_command(path_to_twine_file, pedantic)
14
+ cmd = []
15
+ cmd << ['twine validate-twine-file']
16
+ cmd << [path_to_twine_file]
17
+ cmd << [' --pedantic'] if pedantic
18
+ return cmd.join(' ')
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Twine
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-twine
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonas Rottmann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: diffy
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json-schema
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: twine
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fastlane
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.26.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.26.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.49.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.49.1
139
+ description:
140
+ email: jonasrottmann@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/twine.rb
148
+ - lib/fastlane/plugin/twine/actions/twine_check_action.rb
149
+ - lib/fastlane/plugin/twine/actions/twine_generate_action.rb
150
+ - lib/fastlane/plugin/twine/actions/twine_validate_action.rb
151
+ - lib/fastlane/plugin/twine/helper/confighelper.rb
152
+ - lib/fastlane/plugin/twine/helper/twinehelper.rb
153
+ - lib/fastlane/plugin/twine/version.rb
154
+ homepage: https://github.com/jonasrottmann/fastlane-plugin-twine
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.6.14
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: A fastlane plugin providing actions related to twine
178
+ test_files: []