appium_console 4.2.0 → 4.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd05f297d96d2542f2101103c3bcf7e2a8626f0f46dfba004d7dcaab88663d04
4
- data.tar.gz: 487d016059200b2c94a43bbd98245778c5eaec965350f9194b1c2b4b527196bf
3
+ metadata.gz: d35c8ccbcf449176ebd22cb03bf4debd2c1b3538db04d09ed5a8af308bdb53d8
4
+ data.tar.gz: 6315d3dca7927d2137760d71f75bd04b9c47d63ceaf2576000620736bad18ffc
5
5
  SHA512:
6
- metadata.gz: 7a7742fded7155b9ab7c03d6dc530202e3bd2c0cfe27d3ab40a067f56a0fd4b076f3ef41017ec325dda26926f98e6363996fe17f068edc651006f58a76207a60
7
- data.tar.gz: d4be64288f72600ae0cd9c37b37b1181948b9172c381063b5fff0df781050bb2106494a4d22d378d833cf0687189540278c9c698327615c4501f0daa320527b1
6
+ metadata.gz: 1de4c84924901e5303ed218540d22926f98ed9ccd9ad337030f2a89bd462508c89bdeec7d80aa12edf0cf1461de2cfc035cc34cd00058ae900f72e146659be06
7
+ data.tar.gz: 1df9030b98171cf15667ccf98044c7290c914061a046f6023ef849b74f822947fb535bef611f6d381c737f0b6bc305a768ff8c59854c23ab1a027bf7b31fa6bc
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 3.1
3
- Metrics/LineLength:
3
+ Layout/LineLength:
4
4
  Max: 128
5
5
  Metrics/MethodLength:
6
6
  Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ Historical commit-level notes through 4.2.0 are in [release_notes.md](release_notes.md).
4
+ New entries are maintained by Release Please.
5
+
6
+ ## [4.3.0](https://github.com/appium/ruby_console/compare/v4.2.0...v4.3.0) (2026-09-20)
7
+
8
+
9
+ ### Features
10
+
11
+ * correct console setup defaults and safely load files ([#265](https://github.com/appium/ruby_console/issues/265)) ([d127d91](https://github.com/appium/ruby_console/commit/d127d9150d72fec8529d9c68c121a5dc6b50fb4c))
12
+
13
+ ## [4.2.0] - 2025-01-25
14
+
15
+ - See the historical release notes for this release.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem 'appium_thor', '~> 2.0'
4
+ gem 'minitest', '~> 5.0'
5
5
  gem 'rake', '~> 13.0'
6
- gem 'rubocop', '1.71.0'
6
+ gem 'rubocop', '1.91.0'
data/Rakefile CHANGED
@@ -2,6 +2,11 @@ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
  require 'rubocop/rake_task'
4
4
 
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'lib'
7
+ t.pattern = 'test/**/*_test.rb'
8
+ end
9
+
5
10
  desc('Execute RuboCop static code analysis')
6
11
  RuboCop::RakeTask.new(:rubocop) do |t|
7
12
  t.patterns = %w(lib test)
@@ -23,10 +23,16 @@ Gem::Specification.new do |s|
23
23
 
24
24
  # appium_lib version must match ruby console version.
25
25
  s.add_dependency 'appium_lib', '>= 14.0.0'
26
- s.add_dependency 'pry', '~> 0.14.0'
26
+ s.add_dependency 'pry', '>= 0.14', '< 0.17'
27
27
  s.add_dependency 'thor', '>= 0.19', '< 2.0'
28
28
 
29
29
  s.executables = ['arc']
30
30
  s.files = `git ls-files`.split "\n"
31
31
  s.metadata['rubygems_mfa_required'] = 'true'
32
+ # Keep release automation out of the published package.
33
+ s.files.reject! do |file|
34
+ file.start_with?('.github/', 'script/', 'test/release/') ||
35
+ %w[RELEASING.md release-please-config.json .release-please-manifest.json].include?(file)
36
+ end
37
+
32
38
  end
@@ -4,7 +4,7 @@
4
4
  module Appium; end unless defined? Appium
5
5
  module Appium
6
6
  module Console
7
- VERSION = '4.2.0' unless defined? ::Appium::Console::VERSION
8
- DATE = '2025-01-25' unless defined? ::Appium::Console::DATE
7
+ VERSION = '4.3.0' unless defined? ::Appium::Console::VERSION
8
+ DATE = '2026-09-20' unless defined? ::Appium::Console::DATE # x-release-please-date
9
9
  end
10
10
  end
@@ -43,7 +43,7 @@ module Appium
43
43
  requires = parsed[:appium_lib][:require]
44
44
 
45
45
  unless requires.empty?
46
- load_files = requires.map { |f| %(require "#{f}";) }.join "\n"
46
+ load_files = requires.map { |f| "require #{f.dump};" }.join "\n"
47
47
  cmd += ['-e', load_files]
48
48
  end
49
49
 
data/lib/cli.rb CHANGED
@@ -18,6 +18,7 @@ module Appium::CLI # rubocop:disable Style/ClassAndModuleChildren
18
18
  <<-TEMPLATE.gsub(/skip\s/, '')
19
19
  [caps]
20
20
  platformName = "#{caps[:platform_name]}"
21
+ automationName = "#{caps[:automation_name]}"
21
22
  #{caps[:platform_version] ? "platformVersion = \"#{caps[:platform_version]}\"" : 'skip'}
22
23
  #{caps[:device_name] ? "deviceName = \"#{caps[:device_name]}\"" : 'skip'}
23
24
  app = "#{caps[:path_to_app]}"
@@ -25,7 +26,7 @@ app = "#{caps[:path_to_app]}"
25
26
  #{caps[:app_activity] ? "appActivity = \"#{caps[:app_activity]}\"" : 'skip'}
26
27
 
27
28
  [appium_lib]
28
- server_url = "http://127.0.0.1:4723/wd/hub"
29
+ server_url = "http://127.0.0.1:4723/"
29
30
  TEMPLATE
30
31
  end
31
32
  end
@@ -33,6 +34,7 @@ server_url = "http://127.0.0.1:4723/wd/hub"
33
34
 
34
35
  class Setup < Thor
35
36
  desc 'ios', 'Generates toml for ios'
37
+ method_option :force, type: :boolean, default: false, desc: 'Overwrite an existing appium.txt'
36
38
  def ios
37
39
  toml = File.join(Dir.pwd, Config.default_appium_txt_path)
38
40
  template = Config.template(
@@ -42,10 +44,11 @@ server_url = "http://127.0.0.1:4723/wd/hub"
42
44
  platform_version: '15.0',
43
45
  path_to_app: '/path/to/app_bundle'
44
46
  )
45
- File.write(toml, template)
47
+ write_config(toml, template)
46
48
  end
47
49
 
48
50
  desc 'android', 'Generates toml for android'
51
+ method_option :force, type: :boolean, default: false, desc: 'Overwrite an existing appium.txt'
49
52
  def android
50
53
  toml = File.join(Dir.pwd, Config.default_appium_txt_path)
51
54
  template = Config.template(
@@ -56,11 +59,23 @@ server_url = "http://127.0.0.1:4723/wd/hub"
56
59
  app_package: 'com.package.example',
57
60
  app_activity: 'com.package.example.ExampleActivity'
58
61
  )
59
- File.write(toml, template)
62
+ write_config(toml, template)
63
+ end
64
+
65
+ private
66
+
67
+ def write_config(path, template)
68
+ File.write(path, template, mode: options[:force] ? 'w' : 'wx')
69
+ rescue Errno::EEXIST
70
+ raise Thor::Error, "#{path} already exists. Use --force to overwrite it."
60
71
  end
61
72
  end
62
73
 
63
74
  class Main < Thor
75
+ def self.exit_on_failure?
76
+ true
77
+ end
78
+
64
79
  desc 'version', 'Prints version of appium_lib and appium_console'
65
80
  def version
66
81
  puts <<-VERSION
data/readme.md CHANGED
@@ -19,15 +19,26 @@
19
19
  - `arc version` prints the current version of appium console and appium lib.
20
20
  - `arc setup android` creates `appium.txt` for android in the current working dir.
21
21
  - `arc setup ios` creates `appium.txt` for ios in the current working dir.
22
+ - Setup preserves an existing `appium.txt`. Add `--force` to overwrite it.
22
23
  - `arc toml FILE` starts arc with toml FILE path
23
24
 
24
25
  ## Documentation
25
26
 
26
27
  - [ruby_lib](https://github.com/appium/ruby_lib)
27
28
 
29
+ ## Development
30
+
31
+ Run `bundle install`, then `bundle exec rake test` and `bundle exec rake rubocop`.
32
+ Tests run without an Appium server or device.
33
+
28
34
  ## Changelog
29
35
  - 4.0.0
30
36
  - Drop Ruby 2.7 support
31
37
  - 3.0.0
32
38
  - Update ruby_lib version to v12
33
39
 
40
+
41
+ ## Releasing
42
+
43
+ Review and merge the Release Please PR to publish. See [RELEASING.md](RELEASING.md)
44
+ for one-time Trusted Publishing setup and recovery instructions.
data/test/cli_test.rb ADDED
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require 'open3'
5
+ require 'tmpdir'
6
+ require 'tomlrb'
7
+
8
+ class CliTest < Minitest::Test
9
+ ROOT = File.expand_path('..', __dir__)
10
+
11
+ def run_arc(*args)
12
+ Open3.capture3(Gem.ruby, '-I', File.join(ROOT, 'lib'), File.join(ROOT, 'bin/arc'), *args)
13
+ end
14
+
15
+ def test_setup_generates_driver_and_server_settings
16
+ { 'ios' => 'XCUITest', 'android' => 'uiautomator2' }.each do |platform, driver|
17
+ Dir.mktmpdir do |dir|
18
+ Dir.chdir(dir) do
19
+ _, stderr, status = run_arc('setup', platform)
20
+ assert status.success?, stderr
21
+ config = Tomlrb.load_file('appium.txt')
22
+ assert_equal driver, config.fetch('caps').fetch('automationName')
23
+ assert_equal platform == 'ios' ? 'iOS' : 'Android', config.fetch('caps').fetch('platformName')
24
+ assert_equal 'http://127.0.0.1:4723/', config.fetch('appium_lib').fetch('server_url')
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ def test_setup_preserves_existing_config_unless_forced
31
+ %w[ios android].each do |platform|
32
+ Dir.mktmpdir do |dir|
33
+ Dir.chdir(dir) do
34
+ File.write('appium.txt', 'custom configuration')
35
+ _, stderr, status = run_arc('setup', platform)
36
+ refute status.success?
37
+ assert_includes stderr, '--force'
38
+ assert_equal 'custom configuration', File.read('appium.txt')
39
+
40
+ _, stderr, status = run_arc('setup', platform, '--force')
41
+ assert status.success?, stderr
42
+ assert Tomlrb.load_file('appium.txt').fetch('caps').key?('automationName')
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def test_version_command
49
+ stdout, stderr, status = run_arc('version')
50
+ assert status.success?, stderr
51
+ assert_includes stdout, 'appium_console:'
52
+ assert_includes stdout, 'appium_lib:'
53
+ end
54
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require 'minitest/mock'
5
+ require 'open3'
6
+ require 'tmpdir'
7
+ require 'appium_console'
8
+
9
+ class ConsoleTest < Minitest::Test
10
+ def test_start_requires_files_with_special_characters_literally
11
+ Dir.mktmpdir do |dir|
12
+ file = File.join(dir, 'page"\\#{raise "interpolated"}.rb')
13
+ File.write(file, 'puts "page loaded"')
14
+ parsed = { appium_lib: { require: [file] } }
15
+ Appium::Console.setup('appium.txt')
16
+ launch = lambda do |args|
17
+ assert_equal '-r', args.first
18
+ assert_equal File.expand_path('../lib/start.rb', __dir__), args[1]
19
+ assert_equal '-e', args[2]
20
+ stdout, stderr, status = Open3.capture3(Gem.ruby, '-e', args[3])
21
+ assert status.success?, stderr
22
+ assert_equal "page loaded\n", stdout
23
+ end
24
+ Appium.stub(:load_appium_txt, parsed) do
25
+ Pry::CLI.stub(:parse_options, ->(args) { args }) do
26
+ Pry::CLI.stub(:start, launch) { capture_io { Appium::Console.start } }
27
+ end
28
+ end
29
+ ensure
30
+ Pry.hooks.delete_hook(:after_session, 'Release session hook')
31
+ end
32
+ end
33
+
34
+ def test_reload_loads_changed_file_contents
35
+ Dir.mktmpdir do |dir|
36
+ file = File.join(dir, 'page.rb')
37
+ Appium::Console.setup('appium.txt')
38
+ Appium.stub(:load_appium_txt, { appium_lib: { require: [file] } }) do
39
+ File.write(file, 'puts "first version"')
40
+ assert_output("first version\n") { Pry.reload }
41
+ File.write(file, 'puts "second version"')
42
+ assert_output("second version\n") { Pry.reload }
43
+ end
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_console
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
8
8
  - Kazuaki Matsuo
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-01-26 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: appium_lib
@@ -29,16 +28,22 @@ dependencies:
29
28
  name: pry
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.14'
34
+ - - "<"
33
35
  - !ruby/object:Gem::Version
34
- version: 0.14.0
36
+ version: '0.17'
35
37
  type: :runtime
36
38
  prerelease: false
37
39
  version_requirements: !ruby/object:Gem::Requirement
38
40
  requirements:
39
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0.14'
44
+ - - "<"
40
45
  - !ruby/object:Gem::Version
41
- version: 0.14.0
46
+ version: '0.17'
42
47
  - !ruby/object:Gem::Dependency
43
48
  name: thor
44
49
  requirement: !ruby/object:Gem::Requirement
@@ -68,13 +73,12 @@ executables:
68
73
  extensions: []
69
74
  extra_rdoc_files: []
70
75
  files:
71
- - ".github/dependabot.yml"
72
76
  - ".gitignore"
73
77
  - ".rubocop.yml"
78
+ - CHANGELOG.md
74
79
  - Gemfile
75
80
  - LICENSE-2.0.txt
76
81
  - Rakefile
77
- - Thorfile
78
82
  - appium_console.gemspec
79
83
  - bin/arc
80
84
  - img/avd_settings.png
@@ -85,13 +89,14 @@ files:
85
89
  - lib/start.rb
86
90
  - readme.md
87
91
  - release_notes.md
92
+ - test/cli_test.rb
93
+ - test/console_test.rb
88
94
  - test/simple.rb
89
95
  homepage: https://github.com/appium/ruby_console
90
96
  licenses:
91
97
  - http://www.apache.org/licenses/LICENSE-2.0.txt
92
98
  metadata:
93
99
  rubygems_mfa_required: 'true'
94
- post_install_message:
95
100
  rdoc_options: []
96
101
  require_paths:
97
102
  - lib
@@ -106,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
111
  - !ruby/object:Gem::Version
107
112
  version: '0'
108
113
  requirements: []
109
- rubygems_version: 3.5.9
110
- signing_key:
114
+ rubygems_version: 4.0.20
111
115
  specification_version: 4
112
116
  summary: Appium Ruby Console
113
117
  test_files: []
@@ -1,8 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: bundler
4
- directory: "/"
5
- schedule:
6
- interval: daily
7
- time: "11:00"
8
- open-pull-requests-limit: 10
data/Thorfile DELETED
@@ -1,20 +0,0 @@
1
- require 'appium_thor'
2
-
3
- Appium::Thor::Config.set do
4
- gem_name 'appium_console'
5
- github_owner 'appium'
6
- github_name 'ruby_console'
7
- version_file 'lib/appium_console/version.rb'
8
- end
9
-
10
- # Must use '::' otherwise Default will point to Thor::Sandbox::Default
11
- # Debug by calling Thor::Base.subclass_files via Pry
12
- #
13
- # https://github.com/erikhuda/thor/issues/484
14
- #
15
- class ::Default < Thor
16
- desc 'spec', 'Run RSpec tests'
17
- def spec
18
- exec 'rspec spec'
19
- end
20
- end