renuo-cli 0.0.11 → 0.0.12

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: 3c48de2d34c66bf57c3b95d164400e722acb674b
4
- data.tar.gz: d61896aa77a91cee15963ea89d48c37e57b59256
3
+ metadata.gz: 27278c4ab97231d81b003ac7d91333dbd83fffa8
4
+ data.tar.gz: 520f7e82b52a3f55731ed9cfa7aafac53ccd2a50
5
5
  SHA512:
6
- metadata.gz: 78fc60731e5421c40ccf0ee9ba72e3eda2c69827b7fc5dcf4f30075cf4625b9fef375a59278d1a100eb51657719d02250a272ca90499230008724ef2e64c7d98
7
- data.tar.gz: 0b6f81219659d0f75340f80fdd57edf8e969549faf0c2fc1ffb9aa0ba11badc0babe6eb3d2b235bcdd8c41c157dc690647447406a9670ec3c84e065b336e5c68
6
+ metadata.gz: 2041015650a4337d286a78e9a2d2fec528ecff9c60f9e73c78101ae038f5e65dc2df8d36cd4c2da9ce7054e6f7e7c6167a3a6e749ae18d4e11baf14b7c5e116a
7
+ data.tar.gz: 8f339ba792311283bbdb68e3a0d72936127a352f77794bd07a1481fcbfc3e283208cfa776c6dc11416b78bdd38ee6c58e186f72e7179ce31f6ace3ae00149335
data/.gitignore CHANGED
@@ -101,4 +101,4 @@ build/
101
101
  /pkg/
102
102
  /spec/reports/
103
103
  /tmp/
104
- .rubocop-https---raw-githubusercontent-com-renuo-rails-application-setup-guide-master-templates--rubocop-base-yml
104
+ .rubocop-https---raw-githubusercontent-com-renuo-applications-setup-guide-master-templates--rubocop-yml
data/.rubocop.yml CHANGED
@@ -1,12 +1,3 @@
1
- inherit_from:
2
- - https://raw.githubusercontent.com/renuo/rails-application-setup-guide/master/templates/.rubocop_base.yml
3
-
4
- Rails:
5
- Enabled: false
6
-
7
- Metrics/ClassLength:
8
- Max: 160
9
-
10
1
  AllCops:
11
2
  Include:
12
3
  - 'lib/**/*'
@@ -15,3 +6,36 @@ AllCops:
15
6
  Exclude:
16
7
  - 'bin/**/*'
17
8
  - 'lib/renuo/cli.rb'
9
+ - 'lib/renuo/cli/app/heroku_users'
10
+ - 'lib/renuo/cli/app/fetch_all_emails'
11
+ - 'lib/renuo/cli/app/create_heroku_app'
12
+
13
+ Naming/FileName:
14
+ Exclude:
15
+ - 'Gemfile'
16
+ - 'Rakefile'
17
+
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - 'Rakefile'
21
+ - '**/*.rake'
22
+ - 'spec/**/*.rb'
23
+
24
+ Metrics/ClassLength:
25
+ Max: 160
26
+
27
+ Metrics/LineLength:
28
+ Max: 120
29
+
30
+ Style/Documentation:
31
+ Enabled: false
32
+
33
+ Style/NonNilCheck:
34
+ IncludeSemanticChanges: true
35
+
36
+ Style/FormatStringToken:
37
+ Enabled: false
38
+
39
+ Style/FrozenStringLiteralComment:
40
+ Enabled: false
41
+
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/renuo/renuo-cli.svg?branch=master)](https://travis-ci.org/renuo/renuo-cli)
1
+ [![Build Status Master](https://semaphoreci.com/api/v1/projects/a6f6bfd7-e48b-4035-858d-fc7cfa190608/1707289/badge.svg)](https://semaphoreci.com/renuo/renuo-cli)
2
2
  [![Coverage Status](https://coveralls.io/repos/renuo/renuo-cli/badge.svg?branch=master&service=github)](https://coveralls.io/github/renuo/renuo-cli?branch=master)
3
3
  [![Code Climate](https://codeclimate.com/github/renuo/renuo-cli/badges/gpa.svg)](https://codeclimate.com/github/renuo/renuo-cli)
4
4
 
data/Rakefile CHANGED
@@ -8,4 +8,4 @@ Cucumber::Rake::Task.new
8
8
  Coveralls::RakeTask.new
9
9
 
10
10
  task test_with_coveralls: [:spec, :cucumber, 'coveralls:push']
11
- task default: [:spec, :cucumber]
11
+ task default: %i[spec cucumber]
data/bin/check CHANGED
@@ -1,32 +1,29 @@
1
- #!/bin/zsh
1
+ #!/bin/sh
2
2
 
3
- if ! command -v bundle > /dev/null; then
4
- source ~/.zshrc
5
- fi
6
3
 
7
- bundle exec rubocop -D -c .rubocop.yml
8
- RC=$?
9
- if [ ! $RC -eq 0 ]; then
4
+ if ! bundle exec rubocop -D -c .rubocop.yml
5
+ then
10
6
  echo 'rubocop detected issues!'
11
- bundle exec rubocop -a -D -c .rubocop.yml
12
- echo 'Tried to auto correct the issues, but must be reviewed manually. Commit aborted!'
13
7
  exit 1
14
8
  fi
15
9
 
16
- mdl .
17
- if [ ! $? -eq 0 ]; then
10
+
11
+ if ! bundle exec mdl .
12
+ then
18
13
  echo 'Violated markdown rules, see https://github.com/mivok/markdownlint/blob/master/docs/RULES.md, commit aborted'
19
14
  exit 1
20
15
  fi
21
16
 
22
- bundle exec rspec
23
- if [ ! $RC -eq 0 ]; then
17
+
18
+ if ! bundle exec rspec
19
+ then
24
20
  echo 'rspec errors'
25
21
  exit 1
26
22
  fi
27
23
 
28
- bundle exec cucumber
29
- if [ ! $RC -eq 0 ]; then
24
+
25
+ if ! bundle exec cucumber
26
+ then
30
27
  echo 'cucumber errors'
31
28
  exit 1
32
29
  fi
data/exe/renuo CHANGED
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'renuo/cli'
4
3
  Renuo::CLI.new.start
@@ -0,0 +1,63 @@
1
+ class CreateAwsProject
2
+ def initialize
3
+ unless agree('Did you set up AWSCLI and the IAM profile (renuo-app-setup) yet?')
4
+ abort('You can find setup instructions here: https://redmine.renuo.ch/projects/internal/wiki/Amazon_S3#Setup-AWS-CLI')
5
+ end
6
+
7
+ @project_name = ask('Project name (eg: renuo-cli): ') { |q| q.validate = /.+/ }
8
+ @project_purpose = ask('Suffix describing purpose (eg: assets): ') { |q| q.default = 'none' }
9
+ @project_purpose = nil if @project_purpose.empty? || @project_purpose == 'none'
10
+ @redmine_project = ask('Redmine project name for billing (eg: internal): ') { |q| q.validate = /.+/ }
11
+ @aws_profile = 'renuo-app-setup'
12
+ @aws_region = ask('AWS bucket region: ') { |q| q.default = 'eu-central-1' }
13
+ @aws_app_group = 'renuo-apps-v2'
14
+ end
15
+
16
+ def run
17
+ say "\n# master:\n"
18
+ print_common_setup 'master'
19
+ print_versioning_setup 'master'
20
+
21
+ say "\n# develop:\n"
22
+ print_common_setup 'develop'
23
+
24
+ say "\n# testing:\n"
25
+ print_common_setup 'testing'
26
+ end
27
+
28
+ private
29
+
30
+ def print_common_setup(branch)
31
+ say common_setup(@aws_profile, @aws_region, aws_user(branch), @aws_app_group)
32
+ say tag_setup(@aws_profile, aws_user(branch), @redmine_project)
33
+ end
34
+
35
+ def print_versioning_setup(branch)
36
+ say versioning_setup(@aws_profile, aws_user(branch))
37
+ end
38
+
39
+ def aws_user(branch)
40
+ [@project_name, branch, @project_purpose].compact.join('-')
41
+ end
42
+
43
+ def common_setup(profile, region, user, app_group)
44
+ <<-SETUP_COMMANDS
45
+ aws --profile #{profile} iam create-user --user-name #{user}
46
+ aws --profile #{profile} iam add-user-to-group --user-name #{user} --group-name #{app_group}
47
+ aws --profile #{profile} iam create-access-key --user-name #{user}
48
+ aws --profile #{profile} s3 mb s3://#{user} --region #{region}
49
+ SETUP_COMMANDS
50
+ end
51
+
52
+ def versioning_setup(profile, bucket)
53
+ <<-VERSIONING_COMMANDS
54
+ aws --profile #{profile} s3api put-bucket-versioning --bucket #{bucket} --versioning-configuration Status=Enabled
55
+ VERSIONING_COMMANDS
56
+ end
57
+
58
+ def tag_setup(profile, bucket, redmine_project)
59
+ <<-TAGGING_COMMANDS
60
+ aws --profile #{profile} s3api put-bucket-tagging --bucket #{bucket} --tagging "TagSet=[{Key=redmine_project,Value=#{redmine_project}}]"
61
+ TAGGING_COMMANDS
62
+ end
63
+ end
@@ -0,0 +1,29 @@
1
+ #!/bin/sh
2
+
3
+ NAME=$1
4
+ ENVIRONMENTS=(master develop testing)
5
+ tmp_emails=`./fetch_all_emails`
6
+ EMAILS=(${tmp_emails//\\n/ })
7
+
8
+ if [ "$NAME" = "" ]
9
+ then
10
+ echo "Missing app name"
11
+ echo "Usage: $0 <app name>"
12
+ exit 1
13
+ fi
14
+
15
+ for var in "${ENVIRONMENTS[@]}"
16
+ do
17
+ HEROKU_NAME=$NAME-$var
18
+ echo "heroku apps:create --region eu $HEROKU_NAME"
19
+ echo "heroku domains:add $HEROKU_NAME.renuoapp.ch --app $HEROKU_NAME"
20
+ echo "heroku addons:create heroku-postgresql --app $HEROKU_NAME"
21
+ echo "heroku addons:create papertrail --app $HEROKU_NAME"
22
+ echo "heroku pg:backups:schedule DATABASE_URL --at '02:00 Europe/Zurich' --app $HEROKU_NAME"
23
+ for email in "${EMAILS[@]}"
24
+ do
25
+ echo "heroku access:add $email --app $HEROKU_NAME"
26
+ done
27
+ echo
28
+ done
29
+
@@ -0,0 +1,32 @@
1
+ class CreateNewLogins
2
+ include RunCommand
3
+
4
+ @logins = [{ name: 'Sentry', sign_up_url: 'https://sentry.io/organizations/renuo/members/new/',
5
+ steps: ['Click on add new Member'] },
6
+ { name: 'NewRelic', sign_up_url: 'https://rpm.newrelic.com/',
7
+ steps: ['Click on Renuo', 'Account Settings > Add user'] }]
8
+
9
+ def run
10
+ @logins.each do |login|
11
+ say login[:name].yellow
12
+ login[:steps].each_with_index do |step, index|
13
+ say "\t#{index + 1}. #{step}"
14
+ end
15
+ open_site login[:sign_up_url]
16
+ end
17
+ say 'every thing is set up'.green
18
+ end
19
+
20
+ private
21
+
22
+ def open_site(website)
23
+ say website.blue
24
+ system "open '#{website}'"
25
+ wait_to_continue
26
+ end
27
+
28
+ def wait_to_continue
29
+ system "read -n 1 -s -p 'Press any key to continue...'"
30
+ say "\n"
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ # this script returns all Renuo (current) Employees email addresses
3
+ curl -s https://docs.google.com/spreadsheets/d/1rJFJQCgpz6GajMlGf0anKwVl5AY6TrYjMnJ4W-_0MK4/pub\?gid\=703649940\&single\=true\&output\=csv | dos2unix | grep -Ev "^$"
@@ -0,0 +1,34 @@
1
+ #!/bin/sh
2
+
3
+ # this is the action you want to perform. can either be 'add' or 'remove'
4
+ ACTION=$1
5
+
6
+ # email to add or remove
7
+ EMAIL=$2
8
+
9
+ check_jq() {
10
+ command -v jq >/dev/null 2>&1 || { echo "I require jq but it's not installed. Aborting." >&2; exit 1; }
11
+ }
12
+
13
+ check_params() {
14
+ if [[ ! $ACTION =~ ^(add|remove)$ ]]
15
+ then
16
+ echo "Missing or wrong action"
17
+ echo "Usage: $0 <action to perform (add|remove)> <email address>"
18
+ exit 1
19
+ fi
20
+
21
+ if [ "$EMAIL" = "" ]
22
+ then
23
+ echo "Missing email address"
24
+ echo "Usage: $0 <action to perform (add|remove)> <email address>"
25
+ exit 1
26
+ fi
27
+ }
28
+
29
+ check_jq
30
+ check_params
31
+
32
+ for i in $( heroku apps --json | jq '.[] | .name' -r ); do
33
+ heroku access:$1 $2 --app $i
34
+ done
@@ -0,0 +1,116 @@
1
+ class ReleaseProject
2
+ UPDATE_TYPES = %w[major minor patch custom].freeze
3
+ TEMP_FOLDER_NAME = ('_RENUO_RELEASE_TEMP_' + rand(100_000_000).to_s).freeze
4
+ MOVE_TO_TEMP = "mkdir -p #{TEMP_FOLDER_NAME} && cd #{TEMP_FOLDER_NAME}".freeze
5
+
6
+ def run(args)
7
+ project_name, @update_type, @version = args
8
+
9
+ validate_update_type(@update_type, @version)
10
+ @version = validate_version(@version)
11
+ validate_project_name(project_name)
12
+
13
+ release(project_name, @update_type, @version)
14
+ ensure
15
+ cleanup
16
+ end
17
+
18
+ def validate_update_type(update_type, version)
19
+ say('>> Do not specify a version for a non-custom release. Given version will be ignored.') if
20
+ version && update_type != UPDATE_TYPES[3]
21
+
22
+ if !version && update_type == UPDATE_TYPES[3]
23
+ @version = ask('>> Please enter your desired version for your custom release (X.Y.Z):')
24
+ validate_update_type(@update_type, @version)
25
+ end
26
+
27
+ return if UPDATE_TYPES.include? update_type
28
+
29
+ @update_type = ask('>> Please enter your desired update type (major minor patch custom):')
30
+ validate_update_type(@update_type, version)
31
+ end
32
+
33
+ def validate_version(version)
34
+ return nil if version.nil?
35
+ version = version.match(/\d+\.\d+\.\d+/)
36
+ return version if version
37
+ abort('>> Invalid Version Number. Use format X.Y.Z for your version.')
38
+ end
39
+
40
+ def validate_project_name(project_name)
41
+ abort('>> No project name given.') unless project_name
42
+ unless system("#{MOVE_TO_TEMP} && hub clone #{project_name} && " \
43
+ "cd #{project_name} && git checkout master && git flow init -d")
44
+ cleanup
45
+ abort('>> Project not found on Github.')
46
+ end
47
+ end
48
+
49
+ def release(project_name, update_type, version)
50
+ version ||= update_version_number(current_version(project_name), update_type)
51
+
52
+ release_start project_name, update_type, version
53
+
54
+ say '>> Project successfully released.'
55
+ end
56
+
57
+ def release_start(project_name, update_type, version)
58
+ abort('>> Unable to pull from Github. Cancelling release.') unless checkout? project_name
59
+
60
+ abort('>> Please bump the version in files manually. Cancelling release.') if
61
+ update_type != UPDATE_TYPES[3] && !version_bump?(project_name, current_version(project_name))
62
+
63
+ abort('>> Cancelling Release.') unless
64
+ agree(">> Are you sure you wish to deploy '#{project_name}' " \
65
+ "as a #{update_type} release (#{current_version(project_name)} => #{version})?")
66
+ abort('>> Unable to finish release and push to master. Cancelling release.') unless
67
+ release_flow project_name, version
68
+ end
69
+
70
+ def checkout?(project_name)
71
+ system("#{move_and_cd(project_name)} && " \
72
+ 'git checkout master && git pull origin master && ' \
73
+ 'git checkout develop && git pull origin develop')
74
+ end
75
+
76
+ def version_bump?(project_name, current_version)
77
+ return true unless
78
+ system("#{move_and_cd(project_name)} && grep -R --color --exclude-dir=.git '#{current_version}' .")
79
+ agree('>> Current version number found in above files! Do you wish to continue without changing it?')
80
+ end
81
+
82
+ def release_flow(project_name, version)
83
+ system("#{move_and_cd(project_name)} &&" \
84
+ "git flow release start #{version} && " \
85
+ "GIT_MERGE_AUTOEDIT=no git flow release finish -m #{version} #{version} && " \
86
+ 'git checkout master && git push origin master && ' \
87
+ 'git checkout develop && git push origin develop && ' \
88
+ 'git push --tags')
89
+ end
90
+
91
+ def current_version(project_name)
92
+ describe = "#{move_and_cd(project_name)} && git describe --tags"
93
+ tag = '`git rev-list --tags --max-count=1`'
94
+ if `#{move_and_cd(project_name)} && git tag` == ''
95
+ '0.0.0'
96
+ else
97
+ `#{describe} #{tag}`.strip
98
+ end
99
+ end
100
+
101
+ def update_version_number(version, update_type)
102
+ version = version.split('.').map(&:to_i)
103
+ type_index = UPDATE_TYPES.index(update_type)
104
+ version[type_index + 1..-1] = [0] * (2 - type_index)
105
+ version[type_index] += 1
106
+ version.join('.')
107
+ end
108
+
109
+ def move_and_cd(project_name)
110
+ "#{MOVE_TO_TEMP} && cd #{project_name}"
111
+ end
112
+
113
+ def cleanup
114
+ system("rm -rf #{TEMP_FOLDER_NAME}")
115
+ end
116
+ end
@@ -1,5 +1,5 @@
1
1
  module Renuo
2
2
  module Cli
3
- VERSION = '0.0.11'.freeze
3
+ VERSION = '0.0.12'.freeze
4
4
  end
5
5
  end
data/lib/renuo/cli.rb CHANGED
@@ -3,12 +3,13 @@ require 'rubygems'
3
3
  require 'colorize'
4
4
  require 'renuo/cli/app/name_display'
5
5
  require 'renuo/cli/app/local_storage'
6
- require 'renuo/cli/app/migrate_to_github'
7
6
  require 'renuo/cli/app/list_large_git_files'
8
7
  require 'renuo/cli/app/generate_password'
9
8
  require 'renuo/cli/app/upgrade_laptop.rb'
9
+ require 'renuo/cli/app/create_aws_project'
10
+ require 'renuo/cli/app/create_new_logins'
10
11
  require 'renuo/cli/app/application_setup_auto_config'
11
- require 'renuo/cli/app/import_redmine_issues'
12
+ require 'renuo/cli/app/release_project.rb'
12
13
 
13
14
  module Renuo
14
15
  class CLI
@@ -40,16 +41,6 @@ module Renuo
40
41
  end
41
42
  end
42
43
 
43
- command 'migrate-to-github' do |c|
44
- c.syntax = 'renuo migrate-to-github [project]'
45
- c.summary = 'A guide how to migrate from gitlab to github'
46
- c.description = 'A guide how to migrate from gitlab to github'
47
- c.example 'migrate the renuo-cli project', 'renuo migrate-to-github renuo-cli'
48
- c.action do |args, _options|
49
- MigrateToGithub.new(args.first).run
50
- end
51
- end
52
-
53
44
  command 'list-large-git-files' do |c|
54
45
  c.syntax = 'renuo list-large-git-files'
55
46
  c.summary = 'Lists the 5 largest files in a git repository. Warning: must be a bare checkout of the repo!'
@@ -82,6 +73,38 @@ module Renuo
82
73
  end
83
74
  end
84
75
 
76
+ command 'create-new-logins' do |c|
77
+ c.syntax = 'renuo create-new-logins'
78
+ c.summary = 'Guides you through the sign up pages for Sentry, NewRelic and Gemnasium'
79
+ c.description = 'Guides you through the sign up pages for Sentry, NewRelic and Gemnasium'
80
+ c.example 'renuo create-new-logins', 'creates new logins'
81
+ c.action do
82
+ CreateNewLogins.new.run
83
+ end
84
+ end
85
+
86
+ command 'create-aws-project' do |c|
87
+ c.syntax = 'renuo create-aws-project'
88
+ c.summary = 'Generates necessary commands for our project setup on AWS.'
89
+ c.description = <<-DESCRIPTION
90
+ This creates commands for creating AWS users, buckets an versioning policies.
91
+
92
+ You will be asked for:
93
+ - project name and suffix so that the script can respect our naming conventions
94
+ - the Redmine project name to tag buckets for AWS billing references
95
+
96
+ The generated commands do the following:
97
+ - create an IAM user for each environment (master, develop, testing) and add it to the renuo apps group.
98
+ - create S3 buckets for each user who owns it
99
+ - tag the buckets
100
+ - enable versioning for master buckets
101
+ DESCRIPTION
102
+ c.example 'Setup a project (you will be asked for details)', 'renuo create-aws-project'
103
+ c.action do |_args, _options|
104
+ CreateAwsProject.new.run
105
+ end
106
+ end
107
+
85
108
  command 'application-setup-auto-config' do |c|
86
109
  c.syntax = 'renuo application-setup-auto-config'
87
110
  c.summary = 'Sets up the application setup using the default config'
@@ -92,14 +115,14 @@ module Renuo
92
115
  end
93
116
  end
94
117
 
95
- command 'import-redmine-issues' do |c|
96
- c.syntax = 'renuo import-redmine-issues [csv_path]'
97
- c.summary = 'Import Redmine Issues from CSV'
98
- c.description = 'Automatically create redmine issues from a CSV file (format project_id,subject,description,estimated_hours)'
99
- c.example 'Create Redmine issues from downloaded CSV file', 'renuo import-redmine-issues ~/Downloads/issues.csv'
100
- c.action do |args, _options|
101
- api_key = ask('Redmine API Key: ') { |q| q.echo = '*' }
102
- ImportRedmineIssues.new(api_key).run(args.first)
118
+ command 'release' do |c|
119
+ c.syntax = 'renuo release'
120
+ c.summary = 'Deploy a project to master in one command.'
121
+ c.description = 'Deploys a project to master as either a Major, Minor, Patch or Custom release.'
122
+ c.example 'renuo release my-project minor', 'release a minor release of my-project'
123
+ c.example 'renuo release my-project custom 2.5.0', 'release my-project as release 2.5.0'
124
+ c.action do|args|
125
+ ReleaseProject.new.run(args)
103
126
  end
104
127
  end
105
128
  end
data/renuo-cli.gemspec CHANGED
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'renuo/cli/version'
@@ -19,17 +18,18 @@ Gem::Specification.new do |spec|
19
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
19
  spec.require_paths = ['lib']
21
20
 
22
- spec.add_dependency 'commander'
23
21
  spec.add_dependency 'colorize'
22
+ spec.add_dependency 'commander'
23
+ spec.add_dependency 'redcarpet'
24
24
 
25
+ spec.add_development_dependency 'aruba'
25
26
  spec.add_development_dependency 'bundler', '~> 1.10'
26
- spec.add_development_dependency 'rake', '~> 10.0'
27
- spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'coveralls'
28
28
  spec.add_development_dependency 'cucumber'
29
- spec.add_development_dependency 'aruba'
30
- spec.add_development_dependency 'rubocop'
31
29
  spec.add_development_dependency 'mdl'
32
30
  spec.add_development_dependency 'pry'
33
- spec.add_development_dependency 'coveralls'
34
- spec.add_development_dependency 'redcarpet'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec'
33
+ spec.add_development_dependency 'rubocop', '0.52.1'
34
+ spec.add_development_dependency 'simplecov', '0.10.0' # TODO: update and fix coverage
35
35
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renuo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Elmer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-21 00:00:00.000000000 Z
11
+ date: 2018-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: commander
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,7 +39,7 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: colorize
42
+ name: redcarpet
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,35 +53,35 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: bundler
56
+ name: aruba
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '1.10'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '1.10'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rake
70
+ name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '10.0'
75
+ version: '1.10'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '10.0'
82
+ version: '1.10'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rspec
84
+ name: coveralls
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: aruba
112
+ name: mdl
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -109,7 +123,7 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: rubocop
126
+ name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - ">="
@@ -123,21 +137,21 @@ dependencies:
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: mdl
140
+ name: rake
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
- - - ">="
143
+ - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '0'
145
+ version: '10.0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
- - - ">="
150
+ - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '0'
152
+ version: '10.0'
139
153
  - !ruby/object:Gem::Dependency
140
- name: pry
154
+ name: rspec
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - ">="
@@ -151,33 +165,33 @@ dependencies:
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
- name: coveralls
168
+ name: rubocop
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
- - - ">="
171
+ - - '='
158
172
  - !ruby/object:Gem::Version
159
- version: '0'
173
+ version: 0.52.1
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
- - - ">="
178
+ - - '='
165
179
  - !ruby/object:Gem::Version
166
- version: '0'
180
+ version: 0.52.1
167
181
  - !ruby/object:Gem::Dependency
168
- name: redcarpet
182
+ name: simplecov
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
- - - ">="
185
+ - - '='
172
186
  - !ruby/object:Gem::Version
173
- version: '0'
187
+ version: 0.10.0
174
188
  type: :development
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
- - - ">="
192
+ - - '='
179
193
  - !ruby/object:Gem::Version
180
- version: '0'
194
+ version: 0.10.0
181
195
  description: The Renuo CLI automates some commonly used workflows by providing a command
182
196
  line interface.
183
197
  email:
@@ -206,12 +220,16 @@ files:
206
220
  - exe/renuo
207
221
  - lib/renuo/cli.rb
208
222
  - lib/renuo/cli/app/application_setup_auto_config.rb
223
+ - lib/renuo/cli/app/create_aws_project.rb
224
+ - lib/renuo/cli/app/create_heroku_app
225
+ - lib/renuo/cli/app/create_new_logins.rb
226
+ - lib/renuo/cli/app/fetch_all_emails
209
227
  - lib/renuo/cli/app/generate_password.rb
210
- - lib/renuo/cli/app/import_redmine_issues.rb
228
+ - lib/renuo/cli/app/heroku_users
211
229
  - lib/renuo/cli/app/list_large_git_files.rb
212
230
  - lib/renuo/cli/app/local_storage.rb
213
- - lib/renuo/cli/app/migrate_to_github.rb
214
231
  - lib/renuo/cli/app/name_display.rb
232
+ - lib/renuo/cli/app/release_project.rb
215
233
  - lib/renuo/cli/app/services/markdown_parser_service.rb
216
234
  - lib/renuo/cli/app/upgrade_laptop.rb
217
235
  - lib/renuo/cli/app/upgrade_laptop/run_command.rb
@@ -239,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
257
  version: '0'
240
258
  requirements: []
241
259
  rubyforge_project:
242
- rubygems_version: 2.5.1
260
+ rubygems_version: 2.6.12
243
261
  signing_key:
244
262
  specification_version: 4
245
263
  summary: The Renuo CLI automates some commonly used workflows by providing a command
@@ -1,65 +0,0 @@
1
- require 'net/http'
2
- require 'json'
3
- require 'csv'
4
-
5
- class ImportRedmineIssues
6
- def initialize(redmine_api_key)
7
- @redmine_api_key = redmine_api_key
8
- @html_uri = URI('https://redmine.renuo.ch/issues')
9
- @json_uri = URI('https://redmine.renuo.ch/issues.json')
10
- end
11
-
12
- def run(csv_path)
13
- https = Net::HTTP.new(@json_uri.host, @json_uri.port)
14
- https.use_ssl = true
15
-
16
- parsed_issues(csv_path).each do |issue|
17
- request = build_request(issue)
18
- response = https.request(request)
19
- handle_response(response)
20
- end
21
-
22
- rescue SocketError => details
23
- say "Are you connected to the internet? SocketError: #{details}"
24
- exit 1
25
- end
26
-
27
- private
28
-
29
- def build_request(issue)
30
- request = Net::HTTP::Post.new(@json_uri)
31
- request.add_field('Content-Type', 'application/json')
32
- request.add_field('X-Redmine-API-Key', @redmine_api_key)
33
- request.body = JSON.generate(issue)
34
- request
35
- end
36
-
37
- def handle_response(response)
38
- if response.is_a? Net::HTTPCreated
39
- issue_id = JSON.parse(response.body)['issue']['id']
40
- issue_url = URI.join(@html_uri, issue_id.to_s)
41
- say issue_url
42
- else
43
- say "#{response.code} #{response.message}"
44
- end
45
- end
46
-
47
- def parsed_issues(csv_path)
48
- issues = []
49
-
50
- CSV.foreach(csv_path) do |row|
51
- issues << { 'issue' => parse_issue(row) }
52
- end
53
-
54
- issues
55
- end
56
-
57
- def parse_issue(csv_row)
58
- {
59
- 'project_id' => csv_row[0],
60
- 'subject' => csv_row[1],
61
- 'description' => csv_row[2],
62
- 'estimated_hours' => csv_row[3]
63
- }
64
- end
65
- end
@@ -1,173 +0,0 @@
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
- run_tasks
12
- end
13
-
14
- private
15
-
16
- def task(description)
17
- say("=> #{description}")
18
- end
19
-
20
- def ready
21
- agree('Ready?')
22
- end
23
-
24
- def run_tasks
25
- transfer_git
26
- update_readme
27
- repo_settings
28
- check_deploy
29
- rename_repo
30
- replace_other_old_links
31
- setup_gemnasium
32
- setup_ci
33
- congrats
34
- end
35
-
36
- def check_requirements
37
- say('Please ensure that hub is installed (brew install hub) and connected to your account')
38
- ready
39
- end
40
-
41
- def check_pwd
42
- say("Project to transfer is called '#{@project_name}'. For the transfer, we will need these temporary directories")
43
- say("* #{@pwd}/#{@project_name}")
44
- say("* #{@pwd}/#{@project_name}.git")
45
- say('If you want to use different directories, cd to a another directory, and run the command again.')
46
- say("E.g.: cd ~/tmp ; mkdir transfer ; cd transfer ; renuo migrate-to-github #{@project_name}")
47
- agree('Is that ok?')
48
- end
49
-
50
- def transfer_git
51
- puts `git clone --mirror git@git.renuo.ch:renuo/#{@project_name}.git`
52
- puts `cd #{@project_name}.git && hub create -p renuo/#{@project_name}`
53
- puts `cd #{@project_name}.git && git push --mirror git@github.com:renuo/#{@project_name}.git`
54
- `rm -rf #{@project_name}.git`
55
- end
56
-
57
- def update_readme
58
- agree('Let us update the README.md now. Ready?')
59
-
60
- puts `git clone git@github.com:renuo/#{@project_name}.git`
61
- puts `cd #{@project_name} && git fetch --all && git checkout develop && git pull && git flow init -d`
62
- File.write("#{@project_name}/README.md", File.read("#{@project_name}/README.md").gsub('git.renuo.ch', 'github.com'))
63
-
64
- update_readme_loop
65
-
66
- puts `cd #{@project_name} && git commit -m 'migrate to github' && git push --set-upstream origin develop`
67
- `rm -rf #{@project_name}`
68
- end
69
-
70
- def update_readme_loop
71
- loop do
72
- puts `cd #{@project_name} && git add . && git status && git diff --staged`
73
- break if agree('Does this look ok?')
74
- ask("Please change it manually in #{@pwd}/#{@project_name}. Hit enter when you are done.")
75
- end
76
- end
77
-
78
- def repo_settings
79
- general_repo_settings
80
- repo_collaborators
81
- repo_branches
82
- copy_hooks
83
- end
84
-
85
- def general_repo_settings
86
- say('The repo settings are next')
87
- task('Remove the features "Wikis" and "Issues"')
88
- task('Close the tab when you are done')
89
- agree('The browser will open automatically. Ready?')
90
- `open https://github.com/renuo/#{@project_name}/settings`
91
- end
92
-
93
- def repo_collaborators
94
- task("Next, assign Renuo-Team 'renuo' to project and grant 'write' permissions")
95
- ready
96
- `open https://github.com/renuo/#{@project_name}/settings/collaboration`
97
- end
98
-
99
- def repo_branches
100
- task('Choose develop as default branch')
101
- task('Protect branches master and develop')
102
- ready
103
- `open https://github.com/renuo/#{@project_name}/settings/branches`
104
- end
105
-
106
- def copy_hooks
107
- task('Copy the hooks from gitlab to github. We will open two tabs this time (gitlab and github)')
108
- ready
109
- `open https://github.com/renuo/#{@project_name}/settings/hooks`
110
- `open https://git.renuo.ch/renuo/#{@project_name}/hooks`
111
- end
112
-
113
- def check_deploy
114
- task('Check the deployment scripts for the correct repository')
115
- ready
116
- `open https://deploy.renuo.ch/deployment_configs`
117
- task('Now login to the deployment server as www-data, and change the remotes. E.g.')
118
- cd = "cd deployments/#{@project_name}"
119
- say("#{cd}-master && git remote set-url origin git@github.com:renuo/#{@project_name}.git && cd ../..")
120
- say("#{cd}-develop && git remote set-url origin git@github.com:renuo/#{@project_name}.git && cd ../..")
121
- say("#{cd}-testing && git remote set-url origin git@github.com:renuo/#{@project_name}.git && cd ../..")
122
- ready
123
- end
124
-
125
- def rename_repo
126
- task("Almost done. Rename the old repo to zzz-old-#{@project_name}")
127
- say(' * Project name')
128
- say(' * Path')
129
- ready
130
- `open https://git.renuo.ch/renuo/#{@project_name}/edit`
131
- end
132
-
133
- def replace_other_old_links
134
- say('Now let\'s replace other old links in the repo!')
135
- ready
136
- `open https://github.com/renuo/#{@project_name}/search?q=git.renuo.ch`
137
- task('Replace all those links!')
138
- ready
139
- task('Now let\'s replace other old links in the wiki!')
140
- `open https://redmine.renuo.ch/search?q=git.renuo.ch/renuo/#{@project_name}&wiki_pages=1&attachments=0&options=0`
141
- task('Replace all those links!')
142
- ready
143
- end
144
-
145
- def setup_gemnasium
146
- say('Now the security monitoring: Gemnasium')
147
- task('Go to https://gemnasium.com/dashboard and add the new project via GitHub')
148
- task("Add new project --> Hosted on GitHub --> Renuo --> Check #{@project_name} and click submit")
149
- ready
150
- `open https://gemnasium.com/dashboard`
151
- end
152
-
153
- def setup_ci
154
- say('One last thing: CI')
155
- say('Find your CI script on the old CI:')
156
- task('Click on <project> --> Settings --> preview')
157
- ready
158
- `open https://ci.renuo.ch/`
159
- say("Enable TravisCI for #{@project_name}")
160
- ready
161
- `open https://magnum.travis-ci.com/profile/renuo`
162
- end
163
-
164
- def congrats
165
- agree("That's it! Congrats!!")
166
- agree('I hope you enjoy Github and TravisCI!')
167
- agree('Cheers!')
168
- end
169
-
170
- def stop
171
- say('Command aborted.')
172
- end
173
- end