pkg-maintainer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 97442c9b8f9083337c6544ea663323fec98615e5e606222bae6d08d69ac94637
4
+ data.tar.gz: 98c91f244b58e23aeb8bd2697c53b152845c5423cd8b83321b5766ddd6de4a30
5
+ SHA512:
6
+ metadata.gz: 80dc725b0a2e19f32c882c6fe23acf72f8d0ff7efc4aea4a7a2036fdbe67eb63a66796eea728a6b73b09d1e7e5fc731d4189e919d9708c06083dc2e25836c7eb
7
+ data.tar.gz: 8c8e4135a0cb2c17dc4b6aac844f900850662864c72a612640c956920c5558664a9a0b400c341a0ded20eeef21aeb20f2564de38d57d8f421c1df1a4cd526b83
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at easports96@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in maintainer.gemspec
6
+ gemspec
7
+
8
+ gem 'rake'
9
+ gem 'rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ maintainer (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (12.3.1)
11
+ rspec (3.8.0)
12
+ rspec-core (~> 3.8.0)
13
+ rspec-expectations (~> 3.8.0)
14
+ rspec-mocks (~> 3.8.0)
15
+ rspec-core (3.8.0)
16
+ rspec-support (~> 3.8.0)
17
+ rspec-expectations (3.8.2)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.8.0)
20
+ rspec-mocks (3.8.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-support (3.8.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ maintainer!
30
+ rake
31
+ rspec
32
+
33
+ BUNDLED WITH
34
+ 1.16.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ehud Adler
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Maintainer
2
+
3
+ Welcome to the Maintainer! The idea is simple. There are so many ways to download packages, Bundler, Cocoapods, NPM, SPM, Homebrew ... and more. These packages are amazing but having to use multiple package managers is a pain. The Maintainer takes care of all that. It is the universal package manager.
4
+
5
+ | |Features |
6
+ |---|---|
7
+ |🛠| Universal Package Manager|
8
+ |👨‍👩‍👧‍👦| Open Source|
9
+ |⏳| Save Time|
10
+ |😰| Reduce Stress|
11
+
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'maintainer'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install maintainer
28
+
29
+ ## Usage
30
+
31
+ | Command |Description |
32
+ |---|---|
33
+ | setup| Setup the maintainer file|
34
+ | pod `podname`| Install a pod |
35
+ | install cocoapods| Installs cocoapods |
36
+ | uninstall cocoapods| Uninstalls cocoapods|
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/maintainer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
51
+
52
+ ## Code of Conduct
53
+
54
+ Everyone interacting in the Maintainer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/maintainer/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "maintainer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/maintain ADDED
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander'
5
+ require 'maintainer'
6
+
7
+ module Maintainer
8
+ class Kernal
9
+ include Commander::Methods
10
+ # include whatever modules you need
11
+ def run
12
+ program :name, 'maintainer'
13
+ program :version, '0.0.1'
14
+ program :description, 'Helps maintain dependencies'
15
+
16
+ command :setup do |c|
17
+ c.syntax = 'maintainer setup [options]'
18
+ c.summary = ''
19
+ c.description = ''
20
+ c.example 'description', 'command example'
21
+ c.option '--some-switch', 'Some switch that does something'
22
+ c.action do |args, options|
23
+ Maintainer::Runner.setup
24
+ end
25
+ end
26
+
27
+ command :install do |c|
28
+ c.syntax = 'maintainer setup [options]'
29
+ c.summary = ''
30
+ c.description = ''
31
+ c.example 'description', 'command example'
32
+ c.option '--some-switch', 'Some switch that does something'
33
+ c.action do |args, options|
34
+ if args[0] == "cocoapods"
35
+ Maintainer::Runner.install_cocoapods
36
+ elsif args[0] == "git"
37
+ Maintainer::Runner.install_git
38
+ end
39
+ end
40
+ end
41
+
42
+ command :uninstall do |c|
43
+ c.syntax = 'maintainer setup [options]'
44
+ c.summary = ''
45
+ c.description = ''
46
+ c.example 'description', 'command example'
47
+ c.option '--some-switch', 'Some switch that does something'
48
+ c.action do |args, options|
49
+ if args[0] == "cocoapods"
50
+ Maintainer::Runner.uninstall_cocoapods
51
+ end
52
+ end
53
+ end
54
+
55
+ command :pod do |c|
56
+ c.syntax = 'maintainer pod [options]'
57
+ c.summary = ''
58
+ c.description = ''
59
+ c.example 'description', 'command example'
60
+ c.option '--some-switch', 'Some switch that does something'
61
+ c.action do |args, options|
62
+ Maintainer::Runner.pod(podname: "#{args[0]}")
63
+ end
64
+ end
65
+
66
+ command :update do |c|
67
+ c.syntax = 'maintainer pod [options]'
68
+ c.summary = ''
69
+ c.description = ''
70
+ c.example 'description', 'command example'
71
+ c.option '--some-switch', 'Some switch that does something'
72
+ c.action do |args, options|
73
+ if args[0] == "all"
74
+ Maintainer::Runner.update_all!
75
+ end
76
+ end
77
+ end
78
+
79
+ command :help do |c|
80
+ c.syntax = 'maintainer help [options]'
81
+ c.summary = ''
82
+ c.description = ''
83
+ c.example 'description', 'command example'
84
+ c.option '--some-switch', 'Some switch that does something'
85
+ c.action do |args, options|
86
+ # Do something or c.when_called Maintainer::Commands::Help
87
+ end
88
+ end
89
+ run!
90
+ end
91
+ end
92
+ end
93
+
94
+ Maintainer::Kernal.new.run
95
+
96
+ #if $0 == __FILE__
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/maintainer.rb ADDED
@@ -0,0 +1,41 @@
1
+ require "maintainer/version"
2
+ require "maintainer/commandRunner"
3
+ require "maintainer/setup"
4
+ require "maintainer/writer"
5
+ require "maintainer/cocoapodRunner"
6
+ require "maintainer/gitRunner"
7
+ require "maintainer/updater"
8
+
9
+ module Maintainer
10
+ class Runner
11
+ class << self
12
+ def setup
13
+ Writer.welcome!
14
+ Setup.setup!
15
+ end
16
+ def pod(podname: nil)
17
+ Writer.write(message: "Adding the pod: #{podname}")
18
+ CocoapodRunner.add_pod(pod: podname)
19
+ end
20
+ def update_all!()
21
+ Writer.write(message: "Updating All.....")
22
+ Updater.update_all!
23
+ end
24
+ def podinit
25
+ CocoapodRunner.create_podfile!
26
+ end
27
+ def uninstall_cocoapods
28
+ CocoapodRunner.uninstall_cocoapods!
29
+ end
30
+ def install_cocoapods
31
+ CocoapodRunner.install_cocoapods!
32
+ end
33
+ def install_git
34
+ GitRunner.install_git!
35
+ end
36
+ def uninstall_git
37
+ GitRunner.uninstall_git!
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,139 @@
1
+ require_relative 'writer'
2
+
3
+ class StandardError
4
+ def exit_status
5
+ return -1
6
+ end
7
+ end
8
+
9
+ module Maintainer
10
+ class MaintainerPtyError < StandardError
11
+ attr_reader :exit_status
12
+ def initialize(e, exit_status)
13
+ super(e)
14
+ set_backtrace(e.backtrace) if e
15
+ @exit_status = exit_status
16
+ end
17
+ end
18
+
19
+ class MaintainerPty
20
+ def self.spawn(command)
21
+ require 'pty'
22
+ PTY.spawn(command) do |command_stdout, command_stdin, pid|
23
+ begin
24
+ yield(command_stdout, command_stdin, pid)
25
+ rescue Errno::EIO
26
+
27
+ ensure
28
+ begin
29
+ Process.wait(pid)
30
+ rescue Errno::ECHILD, PTY::ChildExited
31
+ # The process might have exited.
32
+ end
33
+ end
34
+ end
35
+ $?.exitstatus
36
+ rescue LoadError
37
+ require 'open3'
38
+ Open3.popen2e(command) do |command_stdin, command_stdout, p| # note the inversion
39
+ yield(command_stdout, command_stdin, p.value.pid)
40
+
41
+ command_stdin.close
42
+ command_stdout.close
43
+ p.value.exitstatus
44
+ end
45
+ rescue StandardError => e
46
+ puts "ERROR: #{e}"
47
+ raise MaintainerPtyError.new(e, $?.exitstatus)
48
+ end
49
+ end
50
+
51
+ class CommandRunner
52
+
53
+ class << self
54
+
55
+ def execute_sudo(command: nil)
56
+ system("sudo #{command}")
57
+ end
58
+
59
+ def execute(command: nil, error:nil)
60
+ if command.kind_of?(String)
61
+ _execute(command: command, error: error)
62
+ else
63
+ command.command!.each do |item|
64
+ _execute(command: item, error: error)
65
+ end
66
+ end
67
+ end
68
+
69
+ def _execute(command: nil, error:nil)
70
+
71
+ print_all = true
72
+ prefix ||= {}
73
+
74
+ output = []
75
+
76
+ if command.kind_of?(String)
77
+ cmd = command
78
+ else
79
+ cmd = command.command!
80
+ if command.requires_sudo!
81
+ self.execute_sudo(command: cmd)
82
+ return
83
+ end
84
+ end
85
+
86
+ cmd = command.command!.join(" ") if command.command!.kind_of?(Array)
87
+
88
+ Writer.write(message: "#{cmd}")
89
+
90
+ begin
91
+ status = Maintainer::MaintainerPty.spawn(cmd) do |command_stdout, command_stdin, pid|
92
+ command_stdout.each do |l|
93
+ line = l.strip # strip so that \n gets removed
94
+ output << line
95
+
96
+ next unless print_all
97
+
98
+ # Prefix the current line with a string
99
+ prefix.each do |element|
100
+ line = element[:prefix] + line if element[:block] && element[:block].call(line)
101
+ end
102
+ Writer.write(message: "#{line}")
103
+ end
104
+ end
105
+ rescue => ex
106
+ # FastlanePty adds exit_status on to StandardError so every error will have a status code
107
+ status = ex.exit_status
108
+
109
+ # This could happen when the environment is wrong:
110
+ # > invalid byte sequence in US-ASCII (ArgumentError)
111
+ output << ex.to_s
112
+ o = output.join("\n")
113
+ puts(o)
114
+ if error
115
+ error.call(o, nil)
116
+ else
117
+ raise ex
118
+ end
119
+ end
120
+
121
+ # Exit status for build command, should be 0 if build succeeded
122
+ if status != 0
123
+ o = output.join("\n")
124
+ puts(o)
125
+ Writer.write(message: ("Exit status: #{status}"))
126
+ if error
127
+ error.call(o, status)
128
+ else
129
+ Writer.write(message: ("Exit status: #{status}"))
130
+ end
131
+ end
132
+ return output.join("\n")
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+
139
+
@@ -0,0 +1,33 @@
1
+ require_relative 'writer'
2
+ require_relative 'maintainFileUpdater'
3
+
4
+ module Maintainer
5
+ class Setup
6
+ class << self
7
+
8
+ MAINTAIN_FOLDER = 'maintain'
9
+ MAINTAIN_FILE = 'Maintainfile'
10
+
11
+ def setup!()
12
+ self.create_folder!
13
+ self.create_maintainfile!
14
+ end
15
+ def create_folder!(path = nil)
16
+ maintainfolder_path = File.join(path || '.', MAINTAIN_FOLDER)
17
+
18
+ # Sanity check
19
+ return if File.directory?(maintainfolder_path)
20
+
21
+ Writer.write(message: "\n\nYou already have a maintain folder...skipping creation") if File.exist?(maintainfolder_path)
22
+ FileUtils.mkdir_p(maintainfolder_path)
23
+ Writer.write(message: "\nCreated new folder '#{maintainfolder_path}'.")
24
+ end
25
+ def create_maintainfile!(path = nil)
26
+ Writer.write(message: "Creating Maintainfile...")
27
+ FileUtils.cd "./#{MAINTAIN_FOLDER}"
28
+ FileUtils.touch "#{MAINTAIN_FILE}"
29
+ Writer.write(message: "Maintainfile Created")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ require 'colorize'
2
+
3
+ module Maintainer
4
+ class Writer
5
+ class << self
6
+ def welcome!()
7
+ print "\nHi there!".green
8
+ puts " Welcome to maintainer 🤘\n"
9
+ puts "\nUnsure what this is? Read below!"
10
+ puts "\nWith maintainer install/downloads and updates have never been easier"
11
+ puts "Maintainer will keep track of all of your depenencies."
12
+ puts "Updating those that need updating and keeping the dependency files out of the way"
13
+ puts "\nMaintainer currently supports [cocoapods, git]\n\n"
14
+ end
15
+ def setup_guide!()
16
+ puts "Starting setup guide...\n".green
17
+ end
18
+ def newline!()
19
+ puts"\n"
20
+ end
21
+ def show_success(message: nil)
22
+ puts "#{message}".green
23
+ end
24
+ def show_error(message: nil)
25
+ puts "#{message}".red
26
+ end
27
+ def write(message: nil)
28
+ puts message
29
+ end
30
+ def file_replace(filepath, regexp, *args, &block)
31
+ content = File.read(filepath).gsub(regexp, *args, &block)
32
+ File.open(filepath, 'wb') { |file| file.write(content) }
33
+ end
34
+ def file_write(filepath, text)
35
+ filepath.puts "#{text}"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,82 @@
1
+
2
+ require_relative 'writer'
3
+ require_relative 'commandRunner'
4
+ require_relative 'maintainFileUpdater'
5
+ require_relative 'commands'
6
+
7
+ module Maintainer
8
+ class CocoapodRunner
9
+ class << self
10
+
11
+ def uninstall_cocoapods!()
12
+ CommandRunner.execute(command: Commands::Cocoapods::Uninstall, error: nil)
13
+ end
14
+
15
+ def install_cocoapods!()
16
+ Writer.write(message: "Seems like you don't have cocoapods installed on your machine. Would you like me to set that up for you?")
17
+ Writer.write(message: "Awesome! This will require sudo access. Sudo access means .... but don't worry, you'll be entering it directly into your machine, I can't see what you type.")
18
+ CommandRunner.execute(command: Commands::Cocoapods::Install, error: nil)
19
+ end
20
+
21
+ def are_cocoapods_installed!()
22
+ version = CommandRunner.execute(command: Commands::Cocoapods::Version, error: nil)
23
+
24
+ if /^(\d+)(.\d+)?(.\d+)?$/ =~ version
25
+ return true
26
+ end
27
+ puts "VERSION: #{version}"
28
+ return false
29
+ end
30
+
31
+ def add_pod(pod: nil)
32
+ puts "HELLO"
33
+ self.install_cocoapods!() if !self.are_cocoapods_installed!
34
+ self.create_podfile! if !File.file?("Podfile")
35
+ self.adding_pod_message(pod: pod)
36
+
37
+ file = File.open("Podfile", "a+")
38
+ Writer.file_replace(file, /use_frameworks!.*/i) do |match|
39
+ "#{match}\n\tpod '#{pod}'"
40
+ end
41
+
42
+ file.close
43
+ self.pod_update!
44
+ MaintainerUpdater.new_pod(podname: pod)
45
+ end
46
+
47
+ def create_podfile!(path = nil)
48
+ Writer.newline!
49
+ Writer.write(message: "Did not find podfile...Creating a new one for you")
50
+ CommandRunner.execute(command: Commands::Cocoapods::Init, error: nil)
51
+
52
+ if !File.file?("Podfile")
53
+ error(
54
+ message: "Error while trying to set up podfile",
55
+ willExit: true
56
+ )
57
+ else
58
+ success(message: "Podfile set up - Successful 🤘")
59
+ end
60
+
61
+ end
62
+
63
+ def pod_update!()
64
+ CommandRunner.execute(command: Commands::Cocoapods::Update, error: nil)
65
+ end
66
+
67
+ def adding_pod_message(pod: nil)
68
+ Writer.newline!
69
+ Writer.write(message: "Writing the pod #{pod} to Podfile")
70
+ end
71
+
72
+ def success(message: nil)
73
+ Writer.show_success(message: message)
74
+ end
75
+
76
+ def error(message: nil, willExit: nil)
77
+ Writer.show_error(message: message)
78
+ exit(0) if willExit
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,101 @@
1
+ module Maintainer
2
+ class Commands
3
+
4
+ class Cocoapods
5
+ class Install
6
+ class << self
7
+ def requires_sudo!()
8
+ return true
9
+ end
10
+ def command!()
11
+ return ['gem install cocoapods']
12
+ end
13
+ end
14
+ end
15
+ class Uinstall
16
+ class << self
17
+ def requires_sudo!()
18
+ return true
19
+ end
20
+ def command!()
21
+ return ['gem uninstall cocoapods']
22
+ end
23
+ end
24
+ end
25
+ class Version
26
+ class << self
27
+ def requires_sudo!()
28
+ return false
29
+ end
30
+ def command!()
31
+ return ['pod --version']
32
+ end
33
+ end
34
+ end
35
+ class Init
36
+ class << self
37
+ def requires_sudo!()
38
+ return false
39
+ end
40
+ def command!()
41
+ return ['pod init']
42
+ end
43
+ end
44
+ end
45
+ class Update
46
+ class << self
47
+ def requires_sudo!()
48
+ return false
49
+ end
50
+ def command!()
51
+ return ['pod update']
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ class Git
58
+ class Install
59
+ class << self
60
+ def requires_sudo!()
61
+ return true
62
+ end
63
+ def command!()
64
+ return ['sudo apt update', 'sudo apt install git']
65
+ end
66
+ end
67
+ end
68
+ class Version
69
+ class << self
70
+ def requires_sudo!()
71
+ return false
72
+ end
73
+ def command!()
74
+ return ['git --version']
75
+ end
76
+ end
77
+ end
78
+ class Init
79
+ class << self
80
+ def requires_sudo!()
81
+ return false
82
+ end
83
+ def command!()
84
+ return ['git init']
85
+ end
86
+ end
87
+ end
88
+ class Update
89
+ class << self
90
+ def requires_sudo!()
91
+ return false
92
+ end
93
+ def command!()
94
+ return ['sudo apt install git']
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ end
101
+ end
@@ -0,0 +1,29 @@
1
+ require_relative 'writer'
2
+ require_relative 'commandRunner'
3
+ require_relative 'maintainFileUpdater'
4
+ require_relative 'commands'
5
+
6
+ module Maintainer
7
+ class GitRunner
8
+ class << self
9
+ def uninstall_git!()
10
+ CommandRunner.execute(command: Commands::Git::Uninstall, error: nil), error: nil)
11
+ end
12
+
13
+ def install_git!()
14
+ Writer.write(message: "Setting up git..\n This will require sudo access. Sudo access means .... but don't worry, you'll be entering it directly into your machine, I can't see what you type.")
15
+ CommandRunner.execute(command: Commands::Git::Install, error: nil)
16
+ end
17
+
18
+ def is_git_installed!()
19
+ version = CommandRunner.execute(command: Commands::Git::Version, error: nil)
20
+
21
+ if /^(\d+)(.\d+)?(.\d+)?$/ =~ version
22
+ return true
23
+ end
24
+ puts "VERSION: #{version}"
25
+ return false
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,46 @@
1
+ require_relative 'writer'
2
+ require_relative 'commandRunner'
3
+ require_relative 'cocoapodRunner'
4
+
5
+ module Maintainer
6
+ class MaintainerUpdater
7
+ class << self
8
+ def new_pod(podname: nil)
9
+ puts "Adding #{podname} to Maintainfile"
10
+ file = File.open("./maintain/Maintainfile", "a+")
11
+
12
+ Writer.file_replace(file, /^#Pods.*/i) do |match|
13
+ "#{match}\n#{podname}"
14
+ end
15
+
16
+ file.puts "#Pods"
17
+ file.puts("#{podname}")
18
+ file.close
19
+ puts "Successfully added #{podname} to Maintainfile"
20
+ end
21
+
22
+ def update_all!()
23
+ file = File.open("./maintain/Maintainfile", "a+")
24
+
25
+ # state = ":pods"
26
+
27
+ file.each_line do |line|
28
+ if line =~ /^#Pods.*/i then
29
+ CocoapodRunner.pod_update!
30
+ elsif line =~ /^#npm.*/i then
31
+ elsif line =~ /^#spm.*/i then
32
+ elsif line =~ /^#gem.*/i then
33
+ else
34
+ end
35
+ # if state == ":pods" then
36
+ # elsif state == ":npm" then
37
+ # elsif state == ":spm" then
38
+ # elsif state == ":gem" then
39
+ # else
40
+ # puts "Cant maintain this: #{line}"
41
+ # end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,14 @@
1
+
2
+ require_relative 'Writer'
3
+ require_relative 'CommandRunner'
4
+ require_relative 'maintainFileUpdater'
5
+
6
+ module Maintainer
7
+ class Updater
8
+ class << self
9
+ def update_all!()
10
+ MaintainerUpdater.update_all!
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Maintainer
2
+ VERSION = "1.0.0"
3
+ end
Binary file
@@ -0,0 +1,28 @@
1
+ require File.expand_path('../lib/maintainer/version', __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "pkg-maintainer"
5
+ spec.version = Maintainer::VERSION
6
+ spec.authors = ["Ehud Adler"]
7
+ spec.email = ["adlerehud@gmail.com"]
8
+
9
+ spec.files = `git ls-files`.split($\)
10
+ spec.executables = ["maintain"]
11
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
12
+ spec.require_paths = ["lib"]
13
+ spec.version = Maintainer::VERSION
14
+
15
+ spec.summary = %q{Maintain multiple installers}
16
+ spec.description = %q{Maintain mutliple installers and set up different gems/bundles...etc}
17
+ spec.homepage = "http://www.ehudadler.com"
18
+ spec.license = "MIT"
19
+
20
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
21
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
22
+ #if spec.respond_to?(:metadata)
23
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
24
+ #else
25
+ # raise "RubyGems 2.0 or newer is required to protect against " \
26
+ # "public gem pushes."
27
+ #end
28
+ end
@@ -0,0 +1,9 @@
1
+ RSpec.describe Maintainer do
2
+ it "has a version number" do
3
+ expect(Maintainer::VERSION).not_to be nil
4
+ end
5
+
6
+ it "does something useful" do
7
+ expect(false).to eq(true)
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ require "bundler/setup"
2
+ require "maintainer"
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = ".rspec_status"
7
+
8
+ # Disable RSpec exposing methods globally on `Module` and `main`
9
+ config.disable_monkey_patching!
10
+
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pkg-maintainer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ehud Adler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Maintain mutliple installers and set up different gems/bundles...etc
14
+ email:
15
+ - adlerehud@gmail.com
16
+ executables:
17
+ - maintain
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - ".rspec"
23
+ - ".travis.yml"
24
+ - CODE_OF_CONDUCT.md
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - bin/console
31
+ - bin/maintain
32
+ - bin/setup
33
+ - lib/maintainer.rb
34
+ - lib/maintainer/CommandRunner.rb
35
+ - lib/maintainer/Setup.rb
36
+ - lib/maintainer/Writer.rb
37
+ - lib/maintainer/cocoapodRunner.rb
38
+ - lib/maintainer/commands.rb
39
+ - lib/maintainer/gitRunner.rb
40
+ - lib/maintainer/maintainFileUpdater.rb
41
+ - lib/maintainer/updater.rb
42
+ - lib/maintainer/version.rb
43
+ - maintainer-1.0.0.gem
44
+ - maintainer.gemspec
45
+ - spec/maintainer_spec.rb
46
+ - spec/spec_helper.rb
47
+ homepage: http://www.ehudadler.com
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 2.7.6
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Maintain multiple installers
71
+ test_files:
72
+ - spec/maintainer_spec.rb
73
+ - spec/spec_helper.rb