renuo-cli 0.0.13 → 0.1.1

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
- SHA256:
3
- metadata.gz: adca29c33ee3aac89d50a5caf15553d14e4ae8e5bc42c141077d4ee6871218e8
4
- data.tar.gz: 6ab51df5e5254b1d3662bb1623fdfe2bf57a4dde522559c7a91397e904ab9782
2
+ SHA1:
3
+ metadata.gz: 41b05b933185d067661c4c49c8705d9fc0307300
4
+ data.tar.gz: 07f8c22d60a2ef4f42fe1a56662e83b163876db5
5
5
  SHA512:
6
- metadata.gz: b7ad94fe437809b62be431f1862c7f6d02baa55a85deeca1f855e9ce378c4c17461c7cfc91514d283a3f2417c9167a37d44f404bc32e40c00c5a5e3ecc68118f
7
- data.tar.gz: 6b6b7c62cdeba54b28abff6e57e30a3ee26299c7becea5ca05784f8220f7d78fbaebdadcb25cdefca76d2b9c422854da439ec3a1293420e0fd3218efcb6952b9
6
+ metadata.gz: db13152572f6e31b41868b4f7c0d404b5377b1ecae20d56e98bde27d922e343fc761c39cb41240e47e1b33b62e8dd1c65d15295c3afa57c076550e33913be33a
7
+ data.tar.gz: 3c5b4bfb4581dbafe2c639fbb1f4984757479dbbd6759a7f2bbb097136a491afbb34344efb5e3db1faaff56d3a9fcf231655b3914e51b5fc2dc70cda89989785
data/README.md CHANGED
@@ -50,7 +50,7 @@ bundle install
50
50
  git commit -av
51
51
  git flow release finish [.....]
52
52
  git push origin develop:develop
53
- git push origin master:master
53
+ git push origin master:master --tags
54
54
  git checkout master
55
55
  bundle exec rake release
56
56
  git checkout develop
data/bin/check CHANGED
@@ -1,27 +1,23 @@
1
1
  #!/bin/sh
2
2
 
3
-
4
3
  if ! bundle exec rubocop -D -c .rubocop.yml
5
4
  then
6
5
  echo 'rubocop detected issues!'
7
6
  exit 1
8
7
  fi
9
8
 
10
-
11
9
  if ! bundle exec mdl .
12
10
  then
13
11
  echo 'Violated markdown rules, see https://github.com/mivok/markdownlint/blob/master/docs/RULES.md, commit aborted'
14
12
  exit 1
15
13
  fi
16
14
 
17
-
18
15
  if ! bundle exec rspec
19
16
  then
20
17
  echo 'rspec errors'
21
18
  exit 1
22
19
  fi
23
20
 
24
-
25
21
  if ! bundle exec cucumber
26
22
  then
27
23
  echo 'cucumber errors'
data/bin/run ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'renuo/cli'
6
+
7
+ Renuo::CLI.new.start
@@ -76,21 +76,22 @@ class CreateAwsProject
76
76
  # wrap_at inserts newlines, after that, the command is no longer copyable
77
77
  # rubocop:disable Style/GlobalVars
78
78
  $terminal.wrap_at = nil
79
- say aws_iam_setup(@aws_profile, @aws_region, aws_user(branch), @aws_app_group)
80
- say tag_setup(aws_user(branch), @redmine_project)
81
- say versioning_setup(@aws_profile, aws_user('master')) if branch == 'master'
82
- cloudfront_setup(branch)
79
+ say aws_iam_setup(@aws_profile, aws_user(branch), @aws_app_group)
80
+ say aws_s3_setup(@aws_profile, aws_user(branch), @aws_region, @redmine_project)
81
+ say aws_s3_versioning_setup(@aws_profile, aws_user(branch)) if branch == 'master'
82
+ cloudfront_setup(aws_user(branch), branch)
83
83
  $terminal.wrap_at = :auto
84
84
  # rubocop:enable Style/GlobalVars
85
85
  end
86
86
 
87
- def cloudfront_setup(branch)
87
+ def cloudfront_setup(bucket, branch)
88
88
  return unless @setup_cloudfront
89
- say setup_cloudfront(@aws_profile, branch)
89
+ say aws_cloudfront_setup(@aws_profile, bucket, branch, @redmine_project)
90
90
  if @cloudfront_alias[branch.to_sym]
91
- say "\nWarning: Don't forget to set up `#{cloudfront_alias(branch)}` on the DNS if not yet done".colorize :yellow
91
+ say "\n# Warning: Don't forget to set up `#{cloudfront_alias(branch)}` on the DNS "\
92
+ 'if not yet done'.colorize :yellow
92
93
  else
93
- say "\nHint: The domain name for your S3 files, can be found after running the" \
94
+ say "\n# Hint: The domain name for your S3 files, can be found after running the" \
94
95
  ' commands on https://console.aws.amazon.com/cloudfront/home'.colorize :yellow
95
96
  end
96
97
  end
@@ -103,35 +104,33 @@ class CreateAwsProject
103
104
  @cloudfront_alias[branch.to_sym]
104
105
  end
105
106
 
106
- def aws_iam_setup(profile, region, user, app_group)
107
- <<-SETUP_COMMANDS
107
+ def aws_iam_setup(profile, user, app_group)
108
+ <<-IAM_COMMANDS
108
109
  aws --profile #{profile} iam create-user --user-name #{user}
109
110
  aws --profile #{profile} iam add-user-to-group --user-name #{user} --group-name #{app_group}
110
111
  aws --profile #{profile} iam create-access-key --user-name #{user}
111
- aws --profile #{profile} s3 mb s3://#{user} --region #{region}
112
- SETUP_COMMANDS
112
+ IAM_COMMANDS
113
113
  end
114
114
 
115
- def setup_cloudfront(profile, branch)
116
- <<-SETUP_COMMANDS
117
- aws cloudfront create-distribution --profile #{profile} --cli-input-json '#{cloudfront_config_string(aws_user(branch), branch)}'
118
- SETUP_COMMANDS
115
+ def aws_s3_setup(profile, bucket, region, redmine_project)
116
+ <<-S3_COMMANDS
117
+ aws --profile #{profile} s3 mb s3://#{bucket} --region #{region}
118
+ aws --profile #{profile} s3api put-bucket-tagging --bucket #{bucket} --tagging "TagSet=[{Key=redmine_project,Value=#{redmine_project}}]"
119
+ S3_COMMANDS
119
120
  end
120
121
 
121
- def versioning_setup(profile, bucket)
122
- <<-VERSIONING_COMMANDS
122
+ def aws_s3_versioning_setup(profile, bucket)
123
+ <<-S3_VERSIONING_COMMANDS
123
124
  aws --profile #{profile} s3api put-bucket-versioning --bucket #{bucket} --versioning-configuration Status=Enabled
124
- VERSIONING_COMMANDS
125
+ S3_VERSIONING_COMMANDS
125
126
  end
126
127
 
127
- def tag_setup(bucket, redmine_project)
128
- tag_set = "[{Key=redmine_project,Value=#{redmine_project}}]"
129
- <<-TAGGING_COMMANDS
130
- aws --profile #{@aws_profile} s3api put-bucket-tagging --bucket #{bucket} --tagging "TagSet=#{tag_set}"
131
- TAGGING_COMMANDS
132
- end
128
+ def aws_cloudfront_setup(profile, bucket, branch, redmine_project)
129
+ tags = [{ "redmine_project": redmine_project }]
130
+ cloudfront_config_string = CloudfrontConfigService.new(bucket, cloudfront_alias(branch), tags).to_s
133
131
 
134
- def cloudfront_config_string(bucket, branch)
135
- CloudfrontConfigService.new(bucket, cloudfront_alias(branch)).to_s
132
+ <<-CLOUDFRONT_COMMANDS
133
+ aws --profile #{profile} cloudfront create-distribution-with-tags --cli-input-json '#{cloudfront_config_string}'
134
+ CLOUDFRONT_COMMANDS
136
135
  end
137
136
  end
@@ -16,8 +16,9 @@ class ReleaseProject
16
16
  end
17
17
 
18
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]
19
+ if version && update_type != UPDATE_TYPES[3]
20
+ say('>> Do not specify a version for a non-custom release. Given version will be ignored.')
21
+ end
21
22
 
22
23
  if !version && update_type == UPDATE_TYPES[3]
23
24
  @version = ask('>> Please enter your desired version for your custom release (X.Y.Z):')
@@ -40,7 +41,7 @@ class ReleaseProject
40
41
  def validate_project_name(project_name)
41
42
  abort('>> No project name given.') unless project_name
42
43
  unless system("#{MOVE_TO_TEMP} && hub clone #{project_name} && " \
43
- "cd #{project_name} && git checkout master && git flow init -d")
44
+ "cd #{folder_name(project_name)} && git checkout master && git flow init -d")
44
45
  cleanup
45
46
  abort('>> Project not found on Github.')
46
47
  end
@@ -51,20 +52,23 @@ class ReleaseProject
51
52
 
52
53
  release_start project_name, update_type, version
53
54
 
54
- say '>> Project successfully released.'
55
+ say ">> Project successfully released with version #{version}."
55
56
  end
56
57
 
57
58
  def release_start(project_name, update_type, version)
58
59
  abort('>> Unable to pull from Github. Cancelling release.') unless checkout? project_name
59
60
 
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))
61
+ if update_type != UPDATE_TYPES[3] && !version_bump?(project_name, current_version(project_name))
62
+ abort('>> Please bump the version in files manually. Cancelling release.')
63
+ end
62
64
 
63
- abort('>> Cancelling Release.') unless
64
- agree(">> Are you sure you wish to deploy '#{project_name}' " \
65
+ unless agree(">> Are you sure you wish to deploy '#{project_name}' " \
65
66
  "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
67
+ abort('>> Cancelling Release.')
68
+ end
69
+
70
+ return if release_flow(project_name, version)
71
+ abort('>> Unable to finish release and push to master. Cancelling release.')
68
72
  end
69
73
 
70
74
  def checkout?(project_name)
@@ -74,9 +78,12 @@ class ReleaseProject
74
78
  end
75
79
 
76
80
  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?')
81
+ if system("#{move_and_cd(project_name)} && grep -R -F --color --exclude-dir=.git '#{current_version}' .")
82
+ agree(">> Current version number (#{current_version}) found in above files. " \
83
+ ' Do you wish to continue without changing it?')
84
+ else
85
+ true
86
+ end
80
87
  end
81
88
 
82
89
  def release_flow(project_name, version)
@@ -107,7 +114,11 @@ class ReleaseProject
107
114
  end
108
115
 
109
116
  def move_and_cd(project_name)
110
- "#{MOVE_TO_TEMP} && cd #{project_name}"
117
+ "#{MOVE_TO_TEMP} && cd #{folder_name(project_name)}"
118
+ end
119
+
120
+ def folder_name(project_name)
121
+ project_name.split('/').last
111
122
  end
112
123
 
113
124
  def cleanup
@@ -1,7 +1,8 @@
1
1
  class CloudfrontConfigService
2
- def initialize(bucket, bucket_alias)
2
+ def initialize(bucket, bucket_alias, tags = [])
3
3
  @bucket = bucket
4
4
  @bucket_alias = bucket_alias
5
+ @tags = tags
5
6
  end
6
7
 
7
8
  def to_s
@@ -103,6 +104,9 @@ class CloudfrontConfigService
103
104
  "WebACLId": '',
104
105
  "HttpVersion": 'http2',
105
106
  "IsIPV6Enabled": true
107
+ },
108
+ "Tags": {
109
+ "Items": @tags
106
110
  }
107
111
  }
108
112
  end
@@ -1,5 +1,5 @@
1
1
  module Renuo
2
2
  module Cli
3
- VERSION = '0.0.13'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -1,12 +1,12 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'renuo/cli/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'renuo-cli'
7
7
  spec.version = Renuo::Cli::VERSION
8
- spec.authors = ['Lukas Elmer']
9
- spec.email = ['lukas.elmer@gmail.com']
8
+ spec.authors = ['Renuo AG']
9
+ spec.email = ['info@renuo.ch']
10
10
 
11
11
  spec.summary = 'The Renuo CLI automates some commonly used workflows by providing a command line interface.'
12
12
  spec.description = 'The Renuo CLI automates some commonly used workflows by providing a command line interface.'
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'pry'
31
31
  spec.add_development_dependency 'rake', '~> 10.0'
32
32
  spec.add_development_dependency 'rspec'
33
- spec.add_development_dependency 'rubocop', '0.52.1'
33
+ spec.add_development_dependency 'rubocop', '0.55'
34
34
  spec.add_development_dependency 'simplecov', '0.10.0' # TODO: update and fix coverage
35
35
  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.13
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - Lukas Elmer
7
+ - Renuo AG
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-12 00:00:00.000000000 Z
11
+ date: 2018-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 0.52.1
173
+ version: '0.55'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 0.52.1
180
+ version: '0.55'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: simplecov
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -195,7 +195,7 @@ dependencies:
195
195
  description: The Renuo CLI automates some commonly used workflows by providing a command
196
196
  line interface.
197
197
  email:
198
- - lukas.elmer@gmail.com
198
+ - info@renuo.ch
199
199
  executables:
200
200
  - renuo
201
201
  extensions: []
@@ -216,6 +216,7 @@ files:
216
216
  - Rakefile
217
217
  - bin/check
218
218
  - bin/console
219
+ - bin/run
219
220
  - bin/setup
220
221
  - exe/renuo
221
222
  - lib/renuo/cli.rb
@@ -258,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
259
  version: '0'
259
260
  requirements: []
260
261
  rubyforge_project:
261
- rubygems_version: 2.7.5
262
+ rubygems_version: 2.5.1
262
263
  signing_key:
263
264
  specification_version: 4
264
265
  summary: The Renuo CLI automates some commonly used workflows by providing a command