renuo-cli 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/README.md +11 -18
- data/{exe → bin}/renuo +1 -0
- data/lib/renuo/cli.rb +35 -11
- data/lib/renuo/cli/app/create_aws_project.rb +0 -2
- data/lib/renuo/cli/app/create_heroku_app.rb +53 -0
- data/lib/renuo/cli/app/fetch_emails.rb +17 -0
- data/lib/renuo/cli/app/heroku_apps.rb +13 -0
- data/lib/renuo/cli/app/heroku_users.rb +15 -0
- data/lib/renuo/cli/version.rb +1 -1
- data/renuo-cli.gemspec +1 -2
- metadata +8 -8
- data/lib/renuo/cli/app/application_setup_auto_config.rb +0 -22
- data/lib/renuo/cli/app/create_heroku_app +0 -32
- data/lib/renuo/cli/app/fetch_all_emails +0 -3
- data/lib/renuo/cli/app/heroku_users +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b67688fed5f652dc01a5283457f10d71fac5bd191e72c2042d3aacc484de02
|
4
|
+
data.tar.gz: 27add8e6809975d9efd9cf25cca0b1f1e49e21d9d2eb6b8b5ca2a4986357c2f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 840ffedbf8fe036e6b1edbf0f24fce15ec5c384f8c543c92e1532b6a7628a03c781ea3a06a656543c58a933e548407f01cd2e46f678d191f55c97245ee21f9b5
|
7
|
+
data.tar.gz: a61798ec8e24e7e7bf7efba128d2d6b1b2be30b4c6e692ebd413481c55b7d9e80055f07942f335f260ce4b941724324aaf4f1ad5cdf3e993b7130dc875e1b5d5
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -8,20 +8,6 @@ The Renuo command line. Used for various (internal) stuff.
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
Add this line to your application's Gemfile:
|
12
|
-
|
13
|
-
```ruby
|
14
|
-
gem 'renuo-cli'
|
15
|
-
```
|
16
|
-
|
17
|
-
And then execute:
|
18
|
-
|
19
|
-
```sh
|
20
|
-
bundle
|
21
|
-
```
|
22
|
-
|
23
|
-
Or install it yourself as:
|
24
|
-
|
25
11
|
```sh
|
26
12
|
gem install renuo-cli
|
27
13
|
```
|
@@ -34,12 +20,19 @@ renuo -h
|
|
34
20
|
|
35
21
|
## Development
|
36
22
|
|
37
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
24
|
+
|
25
|
+
Run `rake spec` to run the tests.
|
26
|
+
|
27
|
+
Run `ruby -Ilib ./bin/renuo` to run the executable.
|
28
|
+
|
38
29
|
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
39
30
|
|
40
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
41
|
-
|
42
|
-
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
32
|
+
|
33
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
|
34
|
+
which will create a git tag for the version, push git commits and tags, and push the `.gem` file to
|
35
|
+
[rubygems.org](https://rubygems.org).
|
43
36
|
|
44
37
|
## Release
|
45
38
|
|
data/{exe → bin}/renuo
RENAMED
data/lib/renuo/cli.rb
CHANGED
@@ -7,9 +7,11 @@ require 'renuo/cli/app/list_large_git_files'
|
|
7
7
|
require 'renuo/cli/app/generate_password'
|
8
8
|
require 'renuo/cli/app/upgrade_laptop.rb'
|
9
9
|
require 'renuo/cli/app/create_aws_project'
|
10
|
+
require 'renuo/cli/app/create_heroku_app'
|
10
11
|
require 'renuo/cli/app/create_new_logins'
|
11
|
-
require 'renuo/cli/app/application_setup_auto_config'
|
12
12
|
require 'renuo/cli/app/release_project.rb'
|
13
|
+
require 'renuo/cli/app/fetch_emails.rb'
|
14
|
+
require 'renuo/cli/app/heroku_users.rb'
|
13
15
|
|
14
16
|
module Renuo
|
15
17
|
class CLI
|
@@ -110,16 +112,6 @@ module Renuo
|
|
110
112
|
end
|
111
113
|
end
|
112
114
|
|
113
|
-
command 'application-setup-auto-config' do |c|
|
114
|
-
c.syntax = 'renuo application-setup-auto-config'
|
115
|
-
c.summary = 'Sets up the application setup using the default config'
|
116
|
-
c.description = 'Generates a phrase of random 0-9a-zA-Z characters. Choose a substring of it as a new password.'
|
117
|
-
c.example 'renuo application-setup-auto-config', 'applies the default config'
|
118
|
-
c.action do
|
119
|
-
ApplicationSetupAutoConfig.new.run
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
115
|
command 'release' do |c|
|
124
116
|
c.syntax = 'renuo release'
|
125
117
|
c.summary = 'Deploy a project to master in one command.'
|
@@ -130,6 +122,38 @@ module Renuo
|
|
130
122
|
ReleaseProject.new.run(args)
|
131
123
|
end
|
132
124
|
end
|
125
|
+
|
126
|
+
command 'create-heroku-app' do |c|
|
127
|
+
c.syntax = 'renuo create-heroku-app'
|
128
|
+
c.summary = 'Generates the script necessary to setup an application on Heroku.'
|
129
|
+
c.description = 'Generates the script necessary to setup an application on Heroku.'
|
130
|
+
c.example 'renuo create-heroku-app hello', 'generates the command to create hello on Heroku'
|
131
|
+
c.action do|args|
|
132
|
+
CreateHerokuApp.new.run(args)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
command 'fetch-emails' do |c|
|
137
|
+
c.syntax = 'renuo fetch-emails'
|
138
|
+
c.summary = 'Retrieves all renuo employees email addresses'
|
139
|
+
c.description = 'Retrieves all renuo employees email addresses. One per line.'
|
140
|
+
c.action do|args|
|
141
|
+
FetchEmails.new.run(args)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
command 'heroku-users' do |c|
|
146
|
+
c.syntax = 'renuo heroku-users add/remove emailaddress'
|
147
|
+
c.summary = 'Prints a list of commands to add or remove an email address from all Heroku projects'
|
148
|
+
c.description = 'Useful when a new person is hired or a person quits.'
|
149
|
+
c.example 'renuo heroku-users add alessandro.rodi@renuo.ch',
|
150
|
+
'Adds the user alessandro.rodi@renuo.ch to all the Heroku projects'
|
151
|
+
c.example 'renuo heroku-users remove alessandro.rodi@renuo.ch',
|
152
|
+
'Removes the user alessandro.rodi@renuo.ch from all the Heroku projects'
|
153
|
+
c.action do|args|
|
154
|
+
HerokuUsers.new.run(args)
|
155
|
+
end
|
156
|
+
end
|
133
157
|
end
|
134
158
|
end
|
135
159
|
end
|
@@ -74,14 +74,12 @@ class CreateAwsProject
|
|
74
74
|
def print_setup_commands(branch)
|
75
75
|
say "\n# AWS #{branch} \n".colorize :green
|
76
76
|
# wrap_at inserts newlines, after that, the command is no longer copyable
|
77
|
-
# rubocop:disable Style/GlobalVars
|
78
77
|
$terminal.wrap_at = nil
|
79
78
|
say aws_iam_setup(@aws_profile, aws_user(branch), @aws_app_group)
|
80
79
|
say aws_s3_setup(@aws_profile, aws_user(branch), @aws_region, @redmine_project)
|
81
80
|
say aws_s3_versioning_setup(@aws_profile, aws_user(branch)) if branch == 'master'
|
82
81
|
cloudfront_setup(aws_user(branch), branch)
|
83
82
|
$terminal.wrap_at = :auto
|
84
|
-
# rubocop:enable Style/GlobalVars
|
85
83
|
end
|
86
84
|
|
87
85
|
def cloudfront_setup(bucket, branch)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'commander'
|
2
|
+
require_relative './fetch_emails.rb'
|
3
|
+
|
4
|
+
class CreateHerokuApp
|
5
|
+
MASTER = 'master'.freeze
|
6
|
+
DEVELOP = 'develop'.freeze
|
7
|
+
TESTING = 'testing'.freeze
|
8
|
+
ENVIRONMENTS = [MASTER, DEVELOP, TESTING].freeze
|
9
|
+
ADMIN_EMAIL = 'admin@renuo.ch'.freeze
|
10
|
+
|
11
|
+
def initialize; end
|
12
|
+
|
13
|
+
def run(args)
|
14
|
+
project_name = args[0]
|
15
|
+
abort('>> No project name given.') unless project_name
|
16
|
+
emails = FetchEmails.new.fetch_emails
|
17
|
+
|
18
|
+
say "# Commands to setup your Heroku application\n".colorize :green
|
19
|
+
ENVIRONMENTS.each do |env|
|
20
|
+
print_environment_commands(emails, env, project_name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def print_environment_commands(emails, env, project_name)
|
27
|
+
heroku_name = "#{project_name}-#{env}"
|
28
|
+
say "heroku apps:create --region eu #{heroku_name}"
|
29
|
+
say "heroku domains:add #{heroku_name}.renuoapp.ch --app #{heroku_name}"
|
30
|
+
say "heroku addons:create heroku-postgresql --app #{heroku_name}"
|
31
|
+
say "heroku addons:create papertrail --app #{heroku_name}"
|
32
|
+
say "heroku pg:backups:schedule DATABASE_URL --at '02:00 Europe/Zurich' --app #{heroku_name}"
|
33
|
+
print_ownership_commands(emails, heroku_name)
|
34
|
+
print_pipelines_commands(heroku_name, project_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def print_pipelines_commands(heroku_name, project_name)
|
38
|
+
say "heroku apps:transfer -a #{heroku_name} #{ADMIN_EMAIL}"
|
39
|
+
say "heroku pipelines:create #{project_name} --app #{project_name}-#{MASTER} -s production"
|
40
|
+
say "heroku pipelines:add #{project_name} --app #{project_name}-#{DEVELOP} -s staging"
|
41
|
+
say "heroku pipelines:add #{project_name} --app #{project_name}-#{TESTING} -s staging"
|
42
|
+
say "\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
def print_ownership_commands(emails, heroku_name)
|
46
|
+
say "\n"
|
47
|
+
emails.each do |email|
|
48
|
+
say "heroku access:add #{email} --app #{heroku_name}"
|
49
|
+
say "heroku access:add #{ADMIN_EMAIL} --app #{heroku_name}"
|
50
|
+
end
|
51
|
+
say "\n"
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class FetchEmails
|
5
|
+
def initialize; end
|
6
|
+
|
7
|
+
def fetch_emails
|
8
|
+
uri = URI.parse('https://docs.google.com/spreadsheets/d/1rJFJQCgpz6GajMlGf0anKwVl5AY6TrYjMnJ4W-_0MK4/pub?gid=703649940&single=true&output=csv')
|
9
|
+
response = Net::HTTP.get_response(uri)
|
10
|
+
response.body.gsub(/\r\n/, "\n").split("\n").reject { |add| add == 'n/a' }
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(_args)
|
14
|
+
say '# Here is a complete lit of Renuo email addresses'.colorize :green
|
15
|
+
say fetch_emails.join("\n")
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative './heroku_apps.rb'
|
2
|
+
|
3
|
+
class HerokuUsers
|
4
|
+
def initialize; end
|
5
|
+
|
6
|
+
def run(args)
|
7
|
+
action, email_address = args
|
8
|
+
abort('>> action is either add or remove') unless %w[add remove].include? action
|
9
|
+
abort('>> specify an email address') unless email_address
|
10
|
+
heroku_apps = HerokuApps.new.run
|
11
|
+
heroku_apps.each do |app|
|
12
|
+
say "heroku access:#{action} #{email_address} --app #{app}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/renuo/cli/version.rb
CHANGED
data/renuo-cli.gemspec
CHANGED
@@ -14,8 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
|
+
spec.executables << 'renuo'
|
19
18
|
spec.require_paths = ['lib']
|
20
19
|
|
21
20
|
spec.add_dependency 'colorize', '~> 0'
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renuo AG
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -216,17 +216,17 @@ files:
|
|
216
216
|
- Rakefile
|
217
217
|
- bin/check
|
218
218
|
- bin/console
|
219
|
+
- bin/renuo
|
219
220
|
- bin/run
|
220
221
|
- bin/setup
|
221
|
-
- exe/renuo
|
222
222
|
- lib/renuo/cli.rb
|
223
|
-
- lib/renuo/cli/app/application_setup_auto_config.rb
|
224
223
|
- lib/renuo/cli/app/create_aws_project.rb
|
225
|
-
- lib/renuo/cli/app/create_heroku_app
|
224
|
+
- lib/renuo/cli/app/create_heroku_app.rb
|
226
225
|
- lib/renuo/cli/app/create_new_logins.rb
|
227
|
-
- lib/renuo/cli/app/
|
226
|
+
- lib/renuo/cli/app/fetch_emails.rb
|
228
227
|
- lib/renuo/cli/app/generate_password.rb
|
229
|
-
- lib/renuo/cli/app/
|
228
|
+
- lib/renuo/cli/app/heroku_apps.rb
|
229
|
+
- lib/renuo/cli/app/heroku_users.rb
|
230
230
|
- lib/renuo/cli/app/list_large_git_files.rb
|
231
231
|
- lib/renuo/cli/app/local_storage.rb
|
232
232
|
- lib/renuo/cli/app/name_display.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'renuo/cli/app/services/markdown_parser_service'
|
2
|
-
require 'net/http'
|
3
|
-
|
4
|
-
# see https://www.gitbook.com/book/renuo/rails-application-setup-guide/edit#/edit/master/templates/auto_copy_files.md
|
5
|
-
|
6
|
-
class ApplicationSetupAutoConfig
|
7
|
-
def run
|
8
|
-
url = 'https://raw.githubusercontent.com/renuo/rails-application-setup-guide/master/templates/auto_copy_files.md'
|
9
|
-
data = Net::HTTP.get(URI(url))
|
10
|
-
files = MarkdownParserService.new.parse_markdown(data)
|
11
|
-
files.each { |file, hint| handle_file(file, hint) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def handle_file(file, hint)
|
15
|
-
base_url = 'https://raw.githubusercontent.com/renuo/rails-application-setup-guide/master/templates/'
|
16
|
-
if agree("Overwrite #{file}?#{" Hint: #{hint})" if hint}")
|
17
|
-
`curl #{base_url}#{file} > #{file}`
|
18
|
-
else
|
19
|
-
puts "Skipping file #{base_url}#{file}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
NAME=$1
|
4
|
-
ENVIRONMENTS=(master develop testing)
|
5
|
-
tmp_emails=`./fetch_all_emails`
|
6
|
-
EMAILS=(${tmp_emails//\\n/ })
|
7
|
-
ADMIN_EMAIL=admin@renuo.ch
|
8
|
-
|
9
|
-
if [ "$NAME" = "" ]
|
10
|
-
then
|
11
|
-
echo "Missing app name"
|
12
|
-
echo "Usage: $0 <app name>"
|
13
|
-
exit 1
|
14
|
-
fi
|
15
|
-
|
16
|
-
for var in "${ENVIRONMENTS[@]}"
|
17
|
-
do
|
18
|
-
HEROKU_NAME=$NAME-$var
|
19
|
-
echo "heroku apps:create --region eu $HEROKU_NAME"
|
20
|
-
echo "heroku domains:add $HEROKU_NAME.renuoapp.ch --app $HEROKU_NAME"
|
21
|
-
echo "heroku addons:create heroku-postgresql --app $HEROKU_NAME"
|
22
|
-
echo "heroku addons:create papertrail --app $HEROKU_NAME"
|
23
|
-
echo "heroku pg:backups:schedule DATABASE_URL --at '02:00 Europe/Zurich' --app $HEROKU_NAME"
|
24
|
-
for email in "${EMAILS[@]}"
|
25
|
-
do
|
26
|
-
echo "heroku access:add $email --app $HEROKU_NAME"
|
27
|
-
done
|
28
|
-
echo "heroku access:add $ADMIN_EMAIL --app $HEROKU_NAME"
|
29
|
-
echo "heroku apps:transfer -a $HEROKU_NAME $ADMIN_EMAIL"
|
30
|
-
echo
|
31
|
-
done
|
32
|
-
|
@@ -1,34 +0,0 @@
|
|
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
|