renuo-cli 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: d499ae8ec9708a797078d0c6b04d2291113f58e4
4
- data.tar.gz: f845531ef8552609aa150f32571fb72c90f04416
3
+ metadata.gz: 5a0ce6db8427a12ad6f7d7337958e50a048b6a1a
4
+ data.tar.gz: cc117b680088c4e8cecabe581c1f9f1634121ebf
5
5
  SHA512:
6
- metadata.gz: d1acbfc27e530a4658117577cbf19710adbb41824929d4749931b8cbf9f775f0a532962864c9a993a8c5adad43d2833a78b608a74eba23fd0ec25a55600f542f
7
- data.tar.gz: 06869b6ab734494e1b3e2c13329b6f73fdc91d6e7b32117d0ec8a4845e1a5b8a98780d711cc36b4c27345753b91aab433ce8b4bd144032a80c3076778e03abeb
6
+ metadata.gz: 53820f3e806119541cb4376db32592de390af68120484d9fcd56f974f15351eac9dd48e7d9474478f7f2216059bedf4cfc54aa5e8faedbec54293e3494e323db
7
+ data.tar.gz: 1f203ca7d7e3d58fe171029fd78f95f3740acb5e17c55b040c276036eaab5e2f9abb3442d17cb9dd248b84d8bb41f3edd26f3003d1548b3c3c8257b5e66c054f
data/.rubocop.yml CHANGED
@@ -10,6 +10,9 @@ Style/Documentation:
10
10
  Style/NonNilCheck:
11
11
  IncludeSemanticChanges: true
12
12
 
13
+ Metrics/ClassLength:
14
+ Max: 120
15
+
13
16
  AllCops:
14
17
  Include:
15
18
  - '**/Rakefile'
@@ -18,4 +21,5 @@ AllCops:
18
21
  - '*.gemspec'
19
22
  Exclude:
20
23
  - 'bin/**/*'
24
+ - 'lib/renuo/cli.rb'
21
25
 
data/.travis.yml CHANGED
@@ -9,5 +9,5 @@ before_install: gem install bundler -v 1.10.6
9
9
  install:
10
10
  - bundle install --retry=3
11
11
  script:
12
- - bundle exec rspec
12
+ - bundle exec rake test_with_coveralls
13
13
  - bundle exec rubocop
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- renuo-cli (0.1.0)
4
+ renuo-cli (0.0.2)
5
5
  commander
6
6
 
7
7
  GEM
data/Rakefile CHANGED
@@ -1,6 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
+ require 'coveralls/rake/task'
4
+ require 'cucumber/rake/task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
7
+ Cucumber::Rake::Task.new
8
+ Coveralls::RakeTask.new
5
9
 
6
- task default: :spec
10
+ task test_with_coveralls: [:spec, :cucumber, 'coveralls:push']
11
+ task default: [:spec, :cucumber]
data/bin/check CHANGED
@@ -13,3 +13,15 @@ if [ ! $RC -eq 0 ]; then
13
13
  exit 1
14
14
  fi
15
15
 
16
+ bundle exec rspec
17
+ if [ ! $RC -eq 0 ]; then
18
+ echo 'rspec errors'
19
+ exit 1
20
+ fi
21
+
22
+ bundle exec cucumber
23
+ if [ ! $RC -eq 0 ]; then
24
+ echo 'cucumber errors'
25
+ exit 1
26
+ fi
27
+
data/bin/setup CHANGED
@@ -3,5 +3,5 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
 
5
5
  bundle install
6
+ ln -s ../../bin/check .git/hooks/pre-commit
6
7
 
7
- # Do any other automated setup that you need to do here
data/exe/renuo CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'renuo/cli'
3
- Renuo::CLI.start
3
+ Renuo::CLI.new.start
@@ -0,0 +1,7 @@
1
+ class ListLargeGitFiles
2
+ def run
3
+ cmd = 'join -o "1.1 1.2 2.3" <(git rev-list --objects --all | sort) '\
4
+ '<(git verify-pack -v objects/pack/*.idx | sort -k3 -n | tail -5 | sort) | sort -k3 -n`'
5
+ puts `#{cmd}`
6
+ end
7
+ end
@@ -0,0 +1,139 @@
1
+ class MigrateToGithub
2
+ def initialize(project_name)
3
+ @project_name = project_name
4
+ @pwd = `pwd`.strip
5
+ end
6
+
7
+ def run
8
+ return stop unless check_requirements
9
+ return stop unless check_pwd
10
+
11
+ transfer_git
12
+ update_readme
13
+ repo_settings
14
+ check_deploy
15
+ rename_repo
16
+ setup_ci
17
+ congrats
18
+ end
19
+
20
+ private
21
+
22
+ def check_requirements
23
+ say('Please ensure that hub is installed (brew install hub)')
24
+ agree('Ready?')
25
+ end
26
+
27
+ def check_pwd
28
+ say("Project to transfer is called '#{@project_name}'. For the transfer, we will need these temporary directories")
29
+ say("* #{@pwd}/#{@project_name}")
30
+ say("* #{@pwd}/#{@project_name}.git")
31
+ say('If you want to use different directories, cd to a another directory, and run the command again.')
32
+ say("E.g.: cd ~/tmp ; mkdir transfer ; cd transfer ; renuo migrate-to-github #{@project_name}")
33
+ agree('Is that ok?')
34
+ end
35
+
36
+ def transfer_git
37
+ `git clone --mirror git@git.renuo.ch:renuo/#{@project_name}.git`
38
+ `cd #{@project_name}.git && hub create -p renuo/#{@project_name}`
39
+ `cd #{@project_name}.git && git push --mirror git@github.com:renuo/#{@project_name}.git`
40
+ `rm -rf #{@project_name}.git`
41
+ end
42
+
43
+ def update_readme
44
+ agree('Let us update the README.md now. Ready?')
45
+
46
+ `git clone git@github.com:renuo/#{@project_name}.git`
47
+ `cd #{@project_name} && git fetch --all && git checkout develop && git pull && git flow init -d`
48
+ File.write("#{@project_name}/README.md", File.read("#{@project_name}/README.md").gsub('git.renuo.ch', 'github.com'))
49
+
50
+ update_readme_loop
51
+
52
+ `cd #{@project_name} && git commit -m 'migrate to github' && git push --set-upstream origin develop`
53
+ `rm -rf #{@project_name}`
54
+ end
55
+
56
+ def update_readme_loop
57
+ loop do
58
+ puts `cd #{@project_name} && git add . && git status && git diff --staged`
59
+ break if agree('Does this look ok?')
60
+ ask("Please change it manually in #{@pwd}/#{@project_name}. Hit enter when you are done.")
61
+ end
62
+ end
63
+
64
+ def repo_settings
65
+ general_repo_settings
66
+ repo_collaborators
67
+ repo_branches
68
+ copy_hooks
69
+ end
70
+
71
+ def general_repo_settings
72
+ say('The repo settings are next')
73
+ say('Remove the features "Wikis" and "Issues"')
74
+ say('Close the tab when you are done')
75
+ agree('The browser will open automatically. Ready?')
76
+ `open https://github.com/renuo/#{@project_name}/settings`
77
+ end
78
+
79
+ def repo_collaborators
80
+ say("Next, assign Renuo-Team 'Renuo | Master' to project")
81
+ agree('Ready?')
82
+ `open https://github.com/renuo/#{@project_name}/settings/collaboration`
83
+ end
84
+
85
+ def repo_branches
86
+ say('Choose develop as default branch')
87
+ say('Protect branches master and develop')
88
+ agree('Ready?')
89
+ `open https://github.com/renuo/#{@project_name}/settings/branches`
90
+ end
91
+
92
+ def copy_hooks
93
+ say('Copy the hooks from gitlab to github. We will open two tabs this time (gitlab and github)')
94
+ agree('Ready?')
95
+ `open https://github.com/renuo/#{@project_name}/settings/hooks`
96
+ `open https://git.renuo.ch/renuo/#{@project_name}/hooks`
97
+ end
98
+
99
+ def check_deploy
100
+ say('Check the deployment scripts for the correct repository')
101
+ agree('Ready?')
102
+ `open https://deploy.renuo.ch/deployment_configs`
103
+ say('Now login to the deployment server, and change the remotes. E.g.')
104
+ cd = "cd deployments/#{@project_name}"
105
+ say("#{cd}-master && git remote set-url origin git@github.com:renuo/#{@project_name}.git && cd ..")
106
+ say("#{cd}-develop && git remote set-url origin git@github.com:renuo/#{@project_name}.git && cd ..")
107
+ say("#{cd}-testing && git remote set-url origin git@github.com:renuo/#{@project_name}.git && cd ..")
108
+ agree('Ready?')
109
+ end
110
+
111
+ def rename_repo
112
+ say("Almost done. Rename the old repo to zzz-old-#{@project_name}")
113
+ say('* Project name')
114
+ say('* Path')
115
+ agree('Ready?')
116
+ `open https://git.renuo.ch/renuo/#{@project_name}/edit`
117
+ end
118
+
119
+ def setup_ci
120
+ say('One last thing: CI')
121
+ say('Find your CI script on the old CI:')
122
+ say('Click on <project> --> Settings --> preview')
123
+ agree('Ready?')
124
+ `open https://ci.renuo.ch/`
125
+ say("Enable TravisCI for #{@project_name}")
126
+ agree('Ready?')
127
+ `open https://magnum.travis-ci.com/profile/renuo`
128
+ end
129
+
130
+ def congrats
131
+ agree("That's it! Congrats!!")
132
+ agree('I hope you enjoy Github and TravisCI!')
133
+ agree('Cheers!')
134
+ end
135
+
136
+ def stop
137
+ say('Command aborted.')
138
+ end
139
+ end
@@ -1,5 +1,17 @@
1
1
  class NameDisplay
2
+ def run(args, options)
3
+ return display_name('') if options.delete
4
+
5
+ return say('invalid customer name') if args.empty?
6
+
7
+ display_name(args.join(' '))
8
+ end
9
+
2
10
  def display_name(name)
3
11
  puts "TODO: display #{name}"
4
12
  end
13
+
14
+ def delete_current
15
+ display_name('')
16
+ end
5
17
  end
@@ -1,5 +1,5 @@
1
1
  module Renuo
2
2
  module Cli
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
data/lib/renuo/cli.rb CHANGED
@@ -2,34 +2,59 @@ require 'renuo/cli/version'
2
2
  require 'rubygems'
3
3
  require 'renuo/cli/app/name_display'
4
4
  require 'renuo/cli/app/local_storage'
5
+ require 'renuo/cli/app/migrate_to_github'
6
+ require 'renuo/cli/app/list_large_git_files'
5
7
 
6
- class Renuo::CLI
7
- def self.start
8
- require 'commander/import'
9
- program :version, '0.0.1'
10
- program :description, 'renuo CLI'
8
+ module Renuo
9
+ class CLI
10
+ def start
11
+ require 'commander/import'
12
+ program :version, Renuo::Cli::VERSION
13
+ program :description, 'renuo CLI'
11
14
 
12
- command 'display-name'.to_sym do |c|
13
- c.syntax = 'renuo display-name [options]'
14
- c.summary = 'displays the name of a customer'
15
- c.description = ''
16
- c.example 'description', 'command example'
17
- c.option '--delete', 'Deletes the current name'
18
- c.action do |args, _options|
19
- NameDisplay.new.display_name(args)
15
+ command 'display-name'.to_sym do |c|
16
+ c.syntax = 'renuo display-name [options]'
17
+ c.summary = 'Sets the name of a customer on the Renuo dashboard'
18
+ c.description = 'Sets the name of a customer on the Renuo dashboard'
19
+ c.example 'Display "Peter Muster" on the dashboard', 'renuo display-name "Peter Muster"'
20
+ c.example 'Remove the current name from the dashboard', 'renuo display-name --delete'
21
+ c.option '--delete', 'Deletes the current name'
22
+ c.action do |args, options|
23
+ NameDisplay.new.run(args, options)
24
+ end
25
+ end
26
+
27
+ command :config do |c|
28
+ c.syntax = 'renuo config [options]'
29
+ c.summary = 'Setup the config (API keys)'
30
+ c.description = 'Setup the config (API keys)'
31
+ c.action do
32
+ key = ask('API Key?') { |q| q.echo = '*' }
33
+ LocalStorage.new.store(:api_key, key)
34
+ say('stored the api key')
35
+ end
36
+ end
37
+
38
+ command 'migrate-to-github' do |c|
39
+ c.syntax = 'renuo migrate-to-github [project]'
40
+ c.summary = 'A guide how to migrate from gitlab to github'
41
+ c.description = 'A guide how to migrate from gitlab to github'
42
+ c.example 'migrate the renuo-cli project', 'renuo migrate-to-github renuo-cli'
43
+ c.action do |args, _options|
44
+ MigrateToGithub.new(args.first).run
45
+ end
20
46
  end
21
- end
22
47
 
23
- command :config do |c|
24
- c.syntax = 'renuo config [options]'
25
- c.summary = ''
26
- c.description = ''
27
- c.example 'description', 'command example'
28
- c.option '--some-switch', 'Some switch that does something'
29
- c.action do |_args, _options|
30
- key = ask('API Key?') { |q| q.echo = '*' }
31
- LocalStorage.new.store(:api_key, key)
32
- say('stored the api key')
48
+ command 'list-large-git-files' do |c|
49
+ c.syntax = 'renuo list-large-git-files'
50
+ c.summary = 'Lists the 5 largest files in a git repository. Warning: must be a bare checkout of the repo!'
51
+ c.description = "Lists the 5 largest files in a git repository.\nWarning: must be a bare checkout of the repo!"
52
+ c.example 'list the 5 largest git files of github.com/renuo/renuo-cli',
53
+ 'git clone --bare git@github.com:renuo/renuo-cli.git && '\
54
+ 'cd renuo-cli.git && renuo list-large-git-files'
55
+ c.action do
56
+ ListLargeGitFiles.new.run
57
+ end
33
58
  end
34
59
  end
35
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renuo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Elmer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-08 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -163,7 +163,9 @@ files:
163
163
  - bin/setup
164
164
  - exe/renuo
165
165
  - lib/renuo/cli.rb
166
+ - lib/renuo/cli/app/list_large_git_files.rb
166
167
  - lib/renuo/cli/app/local_storage.rb
168
+ - lib/renuo/cli/app/migrate_to_github.rb
167
169
  - lib/renuo/cli/app/name_display.rb
168
170
  - lib/renuo/cli/version.rb
169
171
  - renuo-cli.gemspec