tworingtools 1.13.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4345e37e847c8727beba43d2538cd56a7c1b2614a3dc854fad8fee43655a6b30
4
- data.tar.gz: e1c6774ce2efa864d5092c769f1fe9a29e7664a30ad9976bf081de4d2da91bbb
3
+ metadata.gz: 98d86d61eb0b2583b752ea311b9944c8c604684af1d5075f38c9448923f2a6fc
4
+ data.tar.gz: 358f9078bdf5ee55d1a8f7283a6bafb4bfa49c96c92a435490226f8c18f63a95
5
5
  SHA512:
6
- metadata.gz: ab156cda589e379c370c688ff513730462af02c986e91ecce7572e486de872dd31fa41c52974e4737221d93321bd192c64c18a6379e878b3314762b6ff34615f
7
- data.tar.gz: 73cc10c48f523aa663571e2cfaeb737abc1d60c94264dcd9e37f97318992144fc0c356345cb17dd3907237907dcb3cbc6126bb5062bff70a06cef2649333fce8
6
+ metadata.gz: 25565c97a355ba89be66f40cf3d9e63b6f51f1b3860cb4cc9a4f7982540ef40504302342d78804b04071c43583685024018815c4ddbc81a4ee47208cd2c4b4bc
7
+ data.tar.gz: 17560e14b306881354f7bcffc1757eb345b2dd22a49adafe291c566e1fcc0984471971ca8e5315f1a1814c0b724aa2072f9bda391a36bc9df448928d067191b4
@@ -0,0 +1,43 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../lib/echoexec'
5
+
6
+ options = {}
7
+ parser = OptionParser.new do |opts|
8
+ opts.banner = <<~BANNER
9
+
10
+ Usage: migrate-changelog /path/to/../CHANGELOG.md <version>
11
+
12
+ Move any contents in Unreleased under a new heading for the specified version with current date.
13
+
14
+ BANNER
15
+ opts.on('-h', '--help', 'Print this help message.') do
16
+ puts opts
17
+ exit
18
+ end
19
+ end
20
+ parser.parse!
21
+
22
+ changelog_path = ARGV[0]
23
+ version = ARGV[1]
24
+
25
+ new_entry = "\n\#\# [#{version}] #{Time.now.strftime("%Y-%m-%d")}\n"
26
+
27
+ `git stash`
28
+
29
+ # read in the changelog file contents
30
+ changelog_contents = File.open(changelog_path).readlines
31
+
32
+ # insert the new version heading
33
+ unreleased_index = changelog_contents.find_index("## [Unreleased]\n")
34
+ changelog_contents.insert(unreleased_index + 1, new_entry)
35
+
36
+ # write the updated changlog
37
+ File.open(changelog_path, 'w+') do |writable_changelog|
38
+ writable_changelog << changelog_contents.join('')
39
+ end
40
+
41
+ `git add #{changelog_path}`
42
+ `git commit --message "chore(changelog): moved Unreleased entries to #{version}"`
43
+ `git stash pop`
@@ -34,7 +34,7 @@ changelog_path = 'CHANGELOG.md'
34
34
  if options[:changelog_path] != nil then
35
35
  changelog_path = options[:changelog_path]
36
36
  end
37
- echo_and_exec "rbenv exec bundle exec changetag #{changelog_path} `vrsn --read --file tworingtools.gemspec`"
37
+ echo_and_exec "rbenv exec bundle exec changetag #{changelog_path} `vrsn --read --file #{podspec}.podspec`"
38
38
  echo_and_exec 'git push --tags'
39
39
 
40
40
  spec_lint_flags = Array.new
@@ -0,0 +1,103 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'json'
4
+ require 'optparse'
5
+ require_relative '../lib/echoexec'
6
+
7
+ options = {}
8
+ parser = OptionParser.new do |opts|
9
+ opts.banner = <<~BANNER
10
+
11
+ Usage: xcsim [options] <podspec-name>
12
+
13
+ Perform batch operations on iOS Simulators.
14
+
15
+ Options:
16
+
17
+ BANNER
18
+ opts.on('-s', '--shutdown', 'Shut down all simulators.') do |force| options[:shutdown] = true end
19
+ opts.on('-r', '--rebuild', 'Delete and recreate all available ') do |force| options[:rebuild] = true end
20
+ opts.on('-h', '--help', 'Print this help message.') do
21
+ puts opts
22
+ exit
23
+ end
24
+ end
25
+ parser.parse!
26
+
27
+ def perform_batch_operation operation
28
+ echo_and_exec "xcrun simctl list -j devices | jq '[.devices[]] | flatten | .[] | .udid' | xargs -t -I @ xcrun simctl #{operation} @"
29
+ end
30
+
31
+ def rebuild_simulators
32
+ # get the lists of device types and runtimes
33
+ @device_types = JSON.parse(`xcrun simctl list -j devicetypes`)
34
+ @runtimes = JSON.parse(`xcrun simctl list -j runtimes`)
35
+
36
+ puts 'Deleting simulators...'
37
+ puts
38
+
39
+ echo_and_exec 'xcrun simctl delete unavailable'
40
+
41
+ # delete all simulators
42
+ perform_batch_operation "delete"
43
+
44
+ # sometimes simctl list misses some things
45
+ user = `whoami`.strip
46
+ simulator_dir = "/Users/#{user}/Library/Developer/CoreSimulator/Devices"
47
+ leftover_simulators = Dir.entries(simulator_dir).select do |child|
48
+ child != '.' && child != '..' && File.directory?(simulator_dir + '/' + child)
49
+ end
50
+ if leftover_simulators.count > 0 then
51
+ puts
52
+ puts "The following were not removed by simctl, consider manually deleting:"
53
+ puts
54
+ puts leftover_simulators.map {|dir| simulator_dir + '/' + dir}
55
+ end
56
+
57
+ puts
58
+ puts 'Creating simulators...'
59
+ puts
60
+
61
+ # given a runtime keyword (e.g. 'iphone') and a set of device type keywords (e.g. 'ios'), find all runtimes matching the runtime keyword, and all device types that match one of the device type keywords, take the cartesian product of runtimes and device types and create a simulator for each entry in that product
62
+ def create_simulators runtime_keyword, device_type_keywords
63
+ selected_runtimes = @runtimes['runtimes'].select do |runtime|
64
+ runtime['name'].downcase.include?(runtime_keyword)
65
+ end
66
+ selected_device_types = @device_types['devicetypes'].select do |device_type|
67
+ device_type_keywords.select do |keyword|
68
+ device_type['name'].downcase.include?(keyword)
69
+ end.size > 0
70
+ end
71
+ selected_runtimes.product(selected_device_types).each do |runtime_device_type_pair_array|
72
+ runtime = runtime_device_type_pair_array.first
73
+ device_type = runtime_device_type_pair_array.last
74
+ create_command = "xcrun simctl create '#{device_type['name']}' #{device_type['identifier']} #{runtime['identifier']}"
75
+ puts create_command
76
+ `#{create_command}`
77
+ end
78
+ end
79
+
80
+ # create simulators for each runtime/device relationship
81
+ create_simulators 'ios', ['iphone', 'ipad']
82
+ create_simulators 'tv', ['tv']
83
+ create_simulators 'watch', ['watch']
84
+
85
+ puts
86
+ puts 'Summary:'
87
+ puts
88
+
89
+ # print summary
90
+ list_command = 'xcrun simctl list devices'
91
+ puts list_command
92
+ puts `#{list_command}`
93
+ end
94
+
95
+ def shut_down_simulators
96
+ perform_batch_operation "shutdown"
97
+ end
98
+
99
+ if options[:shutdown] then
100
+ shut_down_simulators
101
+ elsif options[:rebuild] then
102
+ rebuild_simulators
103
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tworingtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew McKnight
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2020-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github_api
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.1'
41
41
  description: |2
42
- - rebuild-sims: Delete all simulators and recreate one for each compatible platform and device type pairing.
42
+ - xcsims: Delete all simulators and recreate one for each compatible platform and device type pairing.
43
43
  - sync-forks: Make sure all your GitHub forks are clones into a given directory, and have “upstream” remotes pointing to the repos that were forked.
44
44
  - changetag: Extract changelog entries to write into git tag annotation messages.
45
45
  - prerelease-podspec: Branch and create/push a release candidate tag, modify the podspec to use that version tag, and try linting it.
@@ -47,27 +47,30 @@ description: |2
47
47
  - revert-failed-release-tag: In case `release-podspec` fails, make sure the tag it may have created/pushed is destroyed before trying to run it again after fixing, so it doesn't break due to the tag already existing the second time around.
48
48
  - bumpr: Increment the desired part of a version number (major/minor/patch/build) and write the change to a git commit.
49
49
  - clean-rc-tags: deletes any release candidate tags leftover after prerelease testing.
50
+ - migrate-changelog: for a changelog adhering to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), move any contents under Unreleased to a new section for a new version with the current date.
50
51
  email: andrew@tworingsoft.com
51
52
  executables:
52
53
  - clean-rc-tags
53
- - rebuild-sims
54
+ - xcsims
54
55
  - sync-forks
55
56
  - changetag
56
57
  - prerelease-podspec
57
58
  - release-podspec
58
59
  - revert-failed-release-tag
59
60
  - bumpr
61
+ - migrate-changelog
60
62
  extensions: []
61
63
  extra_rdoc_files: []
62
64
  files:
63
65
  - bin/bumpr
64
66
  - bin/changetag
65
67
  - bin/clean-rc-tags
68
+ - bin/migrate-changelog
66
69
  - bin/prerelease-podspec
67
- - bin/rebuild-sims
68
70
  - bin/release-podspec
69
71
  - bin/revert-failed-release-tag
70
72
  - bin/sync-forks
73
+ - bin/xcsims
71
74
  - lib/echoexec.rb
72
75
  homepage: https://github.com/TwoRingSoft/tools
73
76
  licenses:
@@ -1,70 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- require 'json'
4
-
5
- # get the lists of device types and runtimes
6
- @device_types = JSON.parse(`xcrun simctl list -j devicetypes`)
7
- @runtimes = JSON.parse(`xcrun simctl list -j runtimes`)
8
-
9
- def put_and_exe command
10
- puts command
11
- `#{command}`
12
- end
13
-
14
- puts 'Deleting simulators...'
15
- puts
16
-
17
- put_and_exe 'xcrun simctl delete unavailable'
18
-
19
- # delete all simulators
20
- put_and_exe "xcrun simctl list -j devices | jq '[.devices[]] | flatten | .[] | .udid' | xargs -t -I @ xcrun simctl delete @"
21
-
22
- # sometimes simctl list misses some things
23
- user = `whoami`.strip
24
- simulator_dir = "/Users/#{user}/Library/Developer/CoreSimulator/Devices"
25
- leftover_simulators = Dir.entries(simulator_dir).select do |child|
26
- child != '.' && child != '..' && File.directory?(simulator_dir + '/' + child)
27
- end
28
- if leftover_simulators.count > 0 then
29
- puts
30
- puts "The following were not removed by simctl, consider manually deleting:"
31
- puts
32
- puts leftover_simulators.map {|dir| simulator_dir + '/' + dir}
33
- end
34
-
35
- puts
36
- puts 'Creating simulators...'
37
- puts
38
-
39
- # given a runtime keyword (e.g. 'iphone') and a set of device type keywords (e.g. 'ios'), find all runtimes matching the runtime keyword, and all device types that match one of the device type keywords, take the cartesian product of runtimes and device types and create a simulator for each entry in that product
40
- def create_simulators runtime_keyword, device_type_keywords
41
- selected_runtimes = @runtimes['runtimes'].select do |runtime|
42
- runtime['name'].downcase.include?(runtime_keyword)
43
- end
44
- selected_device_types = @device_types['devicetypes'].select do |device_type|
45
- device_type_keywords.select do |keyword|
46
- device_type['name'].downcase.include?(keyword)
47
- end.size > 0
48
- end
49
- selected_runtimes.product(selected_device_types).each do |runtime_device_type_pair_array|
50
- runtime = runtime_device_type_pair_array.first
51
- device_type = runtime_device_type_pair_array.last
52
- create_command = "xcrun simctl create '#{device_type['name']}' #{device_type['identifier']} #{runtime['identifier']}"
53
- puts create_command
54
- `#{create_command}`
55
- end
56
- end
57
-
58
- # create simulators for each runtime/device relationship
59
- create_simulators 'ios', ['iphone', 'ipad']
60
- create_simulators 'tv', ['tv']
61
- create_simulators 'watch', ['watch']
62
-
63
- puts
64
- puts 'Summary:'
65
- puts
66
-
67
- # print summary
68
- list_command = 'xcrun simctl list devices'
69
- puts list_command
70
- puts `#{list_command}`