stack_car 0.9.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +64 -1
  3. data/lib/stack_car.rb +1 -0
  4. data/lib/stack_car/cli.rb +112 -36
  5. data/lib/stack_car/dot_rc.rb +25 -0
  6. data/lib/stack_car/version.rb +1 -1
  7. data/stack_car.gemspec +1 -0
  8. data/templates/.dockerignore.erb +2 -2
  9. data/templates/.env.development.erb +2 -0
  10. data/templates/.env.erb +15 -16
  11. data/templates/.gitlab-ci.yml.erb +94 -62
  12. data/templates/Dockerfile.base.erb +28 -19
  13. data/templates/Dockerfile.erb +26 -7
  14. data/templates/chart-fcrepo/fcrepo-deploy.yaml +63 -0
  15. data/templates/chart-fcrepo/fcrepo-env-cm.yaml +8 -0
  16. data/templates/chart-fcrepo/fcrepo-env-secret.yaml.tt +10 -0
  17. data/templates/chart-fcrepo/fcrepo-pvc.yaml +20 -0
  18. data/templates/chart-fcrepo/fcrepo-svc.yaml +19 -0
  19. data/templates/chart-sidekiq/sidekiq-deploy.yaml +80 -0
  20. data/templates/chart/.gitignore +3 -0
  21. data/templates/chart/.helmignore +23 -0
  22. data/templates/chart/Chart.yaml.tt +29 -0
  23. data/templates/chart/README.md +223 -0
  24. data/templates/chart/bin/check_sidekiq.rb +0 -0
  25. data/templates/chart/bin/decrypt +17 -0
  26. data/templates/chart/bin/deploy +14 -0
  27. data/templates/chart/bin/encrypt +15 -0
  28. data/templates/chart/bin/remove +15 -0
  29. data/templates/chart/sample-values.yaml.tt +138 -0
  30. data/templates/chart/templates/_helpers.tpl.tt +85 -0
  31. data/templates/chart/templates/rails-env-cm.yaml.tt +47 -0
  32. data/templates/chart/templates/rails-env-secret.yaml +10 -0
  33. data/templates/chart/templates/rails-pvc-shared.yml +20 -0
  34. data/templates/chart/templates/setup-job.yaml +73 -0
  35. data/templates/chart/templates/web-deploy.yaml +67 -0
  36. data/templates/chart/templates/web-ing-wildcard.yaml +20 -0
  37. data/templates/chart/templates/web-ing.yaml +20 -0
  38. data/templates/chart/templates/web-svc.yaml +20 -0
  39. data/templates/database.yml.erb +10 -10
  40. data/templates/docker-compose.yml.erb +53 -12
  41. data/templates/env.conf.erb +11 -11
  42. data/templates/nginx.sh.erb +17 -0
  43. metadata +47 -10
  44. data/templates/docker-compose.ci.yml.erb +0 -87
  45. data/templates/docker-compose.production.yml.erb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c7301a4a9e6745ea63c51217c2351ba840cb4ebf
4
- data.tar.gz: a312f4b382681fcdd9a25e9347e0fcff2ebf409f
2
+ SHA256:
3
+ metadata.gz: 0e8df8e8dbd70e738de0a61cd09489c72e4cd822326b237269d21ebe4dacd258
4
+ data.tar.gz: 11214bdf66ad316ad4feec518f0ef0e39f9e146aea500c3b7e187a67ecaa33fe
5
5
  SHA512:
6
- metadata.gz: 44ee3efc1d3dcbc2b6cdf7f8875f46cb74e0daa8ce9254a37516bde59f0a022f502c7db3bc0fdf8d5f850f88bb2d0827ddfdc90159f7af1967c6b7c34e9914f0
7
- data.tar.gz: f649a49b69c16c437ab8fece76db95d768ffb7f54325a2d1ce0a2f9f7cc082130a75587fac9d2ed5699bad5201de312feb4910d21d6eac987e0e37bc49b5ce41
6
+ metadata.gz: 65b81508cd79dd4fdff903820133034b4dc894eeaff69a3033e2439b9cae81f5b34e48055a83485e56f3236ea7111cc9dc24d3c8a3a8cdb8341a5b64490e070a
7
+ data.tar.gz: 60223a2ce56c3173e4c62b8d08e05e1d8c6c5fcd2c64027864cef6aa76857c88e3b9a9ae2d6c88cd4a229f2c858f1f1359959b849faffe129119258500b97b2c
data/README.md CHANGED
@@ -33,7 +33,70 @@ Commands:
33
33
 
34
34
  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.
35
35
 
36
- 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).
36
+ **To install this gem onto your local machine**
37
+ - Run `bundle exec rake install`
38
+
39
+ ### Workflow
40
+
41
+ **Create a dummy rails app**
42
+
43
+ Developing stack_car often requires a rails application for you to run updated commands and templates against. Generate one for this purpose:
44
+ - `rails new <dummy-app-name>`
45
+
46
+ **Make and test your changes**
47
+ - In stack_car, make your command / template changes
48
+ - Run `rake install` to update your local gem
49
+ - In your dummy application, test the updated command
50
+ - Commit your changes
51
+
52
+ ### Releasing a new version
53
+ - Update the version number in `version.rb`
54
+ - Run `bundle exec rake release`
55
+ - This will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+
57
+ ## Generating a Helm Chart
58
+
59
+ stack_car's **dockerize** command can be used in conjunction with available flags to generate a **Helm chart** template for your application. You will need to create the *values* files with necessary configuration values from the *sample-values* provided by stack_car, but the command will effectively give you the baseline Notch8 template (scripts, template files, template helpers, sample values file) for a **Helm base Kubernetes deploy**
60
+
61
+ The following examples are to be run in the repo of the application you are creating the chart for.
62
+
63
+ **To generate a Helm chart template**
64
+
65
+ - `sc dockerize --helm`
66
+ - This command without additional flags will only generate Rails web related template files
67
+
68
+ In broad strokes adding additional flags signals stack_car to generate template files for other services. Note that any configuration that would normally be applied for these services in a non Helm context (without the `--helm` flag) still apply.
69
+
70
+ **For example**:
71
+ - `sc dockerize --helm --fcrepo --solr`
72
+ - This command will add templates for the **fcrepo** service and add a **solr chart dependency** in the `Chart.yaml` (You can think of `Chart.yaml` like the **Gemfile** or **package.json** of a Helm chart)
73
+
74
+ **Creating values files**
75
+
76
+ Values files allows you to configure your helm deploy from number of web instances to hostname for your ingress to environment variables required by your application.
77
+
78
+ When starting from a new helm chart, you'll want to copy the sample values file to one named after the environment you're creating a deployment for.
79
+
80
+ For example:
81
+ `cp sample-values.yaml staging-values.yaml`
82
+
83
+ *Note: You will do this once for every environment you'd like to deploy*
84
+
85
+ **Handling values files**
86
+
87
+ Since values files are likely to contain sensitive information like API keys, they should never be committed to your repository. The scripts that stack_car includes in your chart simplifies encrypting and decrypting values for version control.
88
+
89
+ Example workflow (given values file is already created):
90
+ - Edit values file
91
+ - `chart/bin/encrypt staging <keybase-team-name>`
92
+ - This command will create `staging-values.yaml.enc`
93
+ - `git add staging-values.yaml.enc`
94
+ - Commit and push
95
+
96
+ When pulling down a repo or branch, you will need to start by decrypting.
97
+
98
+ Example:
99
+ - `chart/bin/decrypt staging`
37
100
 
38
101
  ## Contributing
39
102
 
data/lib/stack_car.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "stack_car/version"
2
2
  require "stack_car/cli"
3
+ require "stack_car/dot_rc"
3
4
 
4
5
  module StackCar
5
6
  # Your code goes here...
data/lib/stack_car/cli.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'thor'
2
2
  require 'erb'
3
3
  require 'dotenv/load'
4
-
4
+ require 'json'
5
+ require 'byebug'
5
6
  module StackCar
6
7
  class HammerOfTheGods < Thor
7
8
  include Thor::Actions
@@ -19,21 +20,23 @@ module StackCar
19
20
  method_option :logs, default: true, type: :boolean
20
21
  desc "up", "starts docker-compose with rebuild and orphan removal, defaults to web"
21
22
  def up
23
+ setup
22
24
  ensure_development_env
23
25
  args = ['--remove-orphans']
24
26
  args << '--build' if options[:build]
25
27
  if options[:build]
26
- run("docker-compose pull #{options[:service]}")
28
+ run("#{dotenv} docker-compose pull #{options[:service]}")
27
29
  end
28
30
 
29
- run_with_exit("docker-compose up #{args.join(' ')} #{options[:service]}")
31
+ run_with_exit("#{dotenv} docker-compose up #{args.join(' ')} #{options[:service]}")
30
32
  end
31
33
 
32
34
  method_option :service, default: '', type: :string, aliases: '-s'
33
35
  desc "stop", "stops the specified running service, defaults to all"
34
36
  def stop
37
+ setup
35
38
  ensure_development_env
36
- run("docker-compose stop #{options[:service]}")
39
+ run("#{dotenv} docker-compose stop #{options[:service]}")
37
40
  run_with_exit("rm -rf tmp/pids/*")
38
41
  end
39
42
  map down: :stop
@@ -41,95 +44,108 @@ module StackCar
41
44
  method_option :service, default: 'web', type: :string, aliases: '-s'
42
45
  desc "build", "builds specified service, defaults to web"
43
46
  def build
47
+ setup
44
48
  ensure_development_env
45
- run_with_exit("docker-compose build #{options[:service]}")
49
+ run_with_exit("#{dotenv} docker-compose build #{options[:service]}")
46
50
  end
47
51
 
48
52
  method_option :service, default: 'web', type: :string, aliases: '-s'
49
53
  desc "push ARGS", "wraps docker-compose push web unless --service is used to specify"
50
54
  def push(*args)
51
- run_with_exit("docker-compose push #{options[:service]} #{args.join(' ')}")
55
+ setup
56
+ run_with_exit("#{dotenv} docker-compose push #{options[:service]} #{args.join(' ')}")
52
57
  end
53
58
 
54
59
  method_option :service, default: 'web', type: :string, aliases: '-s'
55
60
  desc "pull ARGS", "wraps docker-compose pull web unless --service is used to specify"
56
61
  def pull(*args)
57
- run_with_exit("docker-compose pull #{options[:service]} #{args.join(' ')}")
62
+ setup
63
+ run_with_exit("#{dotenv} docker-compose pull #{options[:service]} #{args.join(' ')}")
58
64
  end
59
65
 
60
66
  method_option :service, default: '', type: :string, aliases: '-s'
61
67
  desc "ps ARGS", "wraps docker-compose pull web unless --service is used to specify"
62
68
  def ps(*args)
63
- run_with_exit("docker-compose ps #{options[:service]} #{args.join(' ')}")
69
+ setup
70
+ run_with_exit("#{dotenv} docker-compose ps #{options[:service]} #{args.join(' ')}")
64
71
  end
65
72
  map status: :ps
66
73
 
67
74
  method_option :service, default: 'web', type: :string, aliases: '-s'
68
75
  desc "bundle ARGS", "wraps docker-compose run web unless --service is used to specify"
69
76
  def bundle(*args)
70
- run_with_exit("docker-compose exec #{options[:service]} bundle")
77
+ setup
78
+ run_with_exit("#{dotenv} docker-compose exec #{options[:service]} bundle")
71
79
  end
72
80
 
73
81
  method_option :service, default: 'web', type: :string, aliases: '-s'
74
82
  desc "walk ARGS", "wraps docker-compose run web unless --service is used to specify"
75
83
  def walk(*args)
76
- run_with_exit("docker-compose run #{options[:service]} #{args.join(' ')}")
84
+ setup
85
+ run_with_exit("#{dotenv} docker-compose run #{options[:service]} #{args.join(' ')}")
77
86
  end
78
87
 
79
88
  method_option :service, default: 'web', type: :string, aliases: '-s'
80
89
  desc "exec ARGS", "wraps docker-compose exec web unless --service is used to specify"
81
90
  def exec(*args)
82
- run_with_exit("docker-compose exec #{options[:service]} #{args.join(' ')}")
91
+ setup
92
+ run_with_exit("#{dotenv} docker-compose exec #{options[:service]} #{args.join(' ')}")
83
93
  end
84
94
  map ex: :exec
85
95
 
86
96
  method_option :service, default: 'web', type: :string, aliases: '-s'
87
97
  desc 'sh ARGS', "launch a shell using docker-compose exec, sets tty properly"
88
98
  def sh(*args)
89
- run_with_exit("docker-compose exec -e COLUMNS=\"\`tput cols\`\" -e LINES=\"\`tput lines\`\" #{options[:service]} bash #{args.join(' ')}")
99
+ setup
100
+ run_with_exit("#{dotenv} docker-compose exec -e COLUMNS=\"\`tput cols\`\" -e LINES=\"\`tput lines\`\" #{options[:service]} bash #{args.join(' ')}")
90
101
  end
91
102
 
92
103
  method_option :service, default: 'web', type: :string, aliases: '-s'
93
104
  desc "bundle_exec ARGS", "wraps docker-compose exec web bundle exec unless --service is used to specify"
94
105
  def bundle_exec(*args)
95
- run_with_exit("docker-compose exec #{options[:service]} bundle exec #{args.join(' ')}")
106
+ setup
107
+ run_with_exit("#{dotenv} docker-compose exec #{options[:service]} bundle exec #{args.join(' ')}")
96
108
  end
97
109
  map be: :bundle_exec
98
110
 
99
111
  method_option :service, default: 'web', type: :string, aliases: '-s'
100
112
  desc "console ARGS", "shortcut to start rails console"
101
113
  def console(*args)
102
- run_with_exit("docker-compose exec #{options[:service]} bundle exec rails console #{args.join(' ')}")
114
+ setup
115
+ run_with_exit("#{dotenv} docker-compose exec #{options[:service]} bundle exec rails console #{args.join(' ')}")
103
116
  end
104
117
  map rc: :console
105
118
 
106
119
  desc "release ENVIRONTMENT", "tag and push and image to the registry"
107
120
  def release(environment)
121
+ setup
108
122
  timestamp = Time.now.strftime("%Y%m%d%I%M%S")
109
123
  sha = `git rev-parse HEAD`[0..8]
110
124
  registry = "#{ENV['REGISTRY_HOST']}#{ENV['REGISTRY_URI']}"
111
125
  tag = ENV["TAG"] || 'latest'
112
126
  unless File.exists?("#{ENV['HOME']}/.docker/config.json") && File.readlines("#{ENV['HOME']}/.docker/config.json").grep(/#{ENV['REGISTRY_HOST']}/).size > 0
113
- run_with_exit("docker login #{ENV['REGISTRY_HOST']}")
127
+ run_with_exit("#{dotenv(environment)} docker login #{ENV['REGISTRY_HOST']}")
114
128
  end
115
- run_with_exit("docker tag #{registry}:#{tag} #{registry}:#{environment}-#{timestamp}")
116
- run_with_exit("docker push #{registry}:#{environment}-#{timestamp}")
117
- run_with_exit("docker tag #{registry}:#{tag} #{registry}:#{sha}")
118
- run_with_exit("docker push #{registry}:#{sha}")
119
- run_with_exit("docker tag #{registry}:#{tag} #{registry}:#{environment}-latest")
120
- run_with_exit("docker push #{registry}:#{environment}-latest")
121
- run_with_exit("docker tag #{registry}:#{tag} #{registry}:latest")
122
- run_with_exit("docker push #{registry}:latest")
129
+ run_with_exit("#{dotenv(environment)} docker tag #{registry}:#{tag} #{registry}:#{environment}-#{timestamp}")
130
+ run_with_exit("#{dotenv(environment)} docker push #{registry}:#{environment}-#{timestamp}")
131
+ run_with_exit("#{dotenv(environment)} docker tag #{registry}:#{tag} #{registry}:#{sha}")
132
+ run_with_exit("#{dotenv(environment)} docker push #{registry}:#{sha}")
133
+ run_with_exit("#{dotenv(environment)} docker tag #{registry}:#{tag} #{registry}:#{environment}-latest")
134
+ run_with_exit("#{dotenv(environment)} docker push #{registry}:#{environment}-latest")
135
+ run_with_exit("#{dotenv(environment)} docker tag #{registry}:#{tag} #{registry}:latest")
136
+ run_with_exit("#{dotenv(environment)} docker push #{registry}:latest")
123
137
  end
124
138
 
125
139
  desc "provision ENVIRONMENT", "configure the servers for docker and then deploy an image"
126
140
  def provision(environment)
141
+ setup
127
142
  # TODO make dotenv load a specific environment?
128
- run_with_exit("DEPLOY_ENV=#{environment} dotenv ansible-playbook -i ops/hosts -l #{environment}:localhost ops/provision.yml")
143
+ run_with_exit("DEPLOY_ENV=#{environment} #{dotenv(environment)} ansible-playbook -i ops/hosts -l #{environment}:localhost ops/provision.yml")
129
144
  end
130
145
 
131
146
  desc "ssh ENVIRONMENT", "log in to a running instance - requires PRODUCTION_SSH to be set"
132
147
  def ssh(environment)
148
+ setup
133
149
  target = ENV["#{environment.upcase}_SSH"]
134
150
  if target
135
151
  run_with_exit(target)
@@ -140,22 +156,27 @@ module StackCar
140
156
 
141
157
  desc "deploy ENVIRONMENT", "deploy an image from the registry"
142
158
  def deploy(environment)
143
- run_with_exit("DEPLOY_HOOK=$DEPLOY_HOOK_#{environment.upcase} dotenv ansible-playbook -i ops/hosts -l #{environment}:localhost ops/deploy.yml")
159
+ setup
160
+ run_with_exit("DEPLOY_HOOK=$DEPLOY_HOOK_#{environment.upcase} #{dotenv(environment)} ansible-playbook -i ops/hosts -l #{environment}:localhost ops/deploy.yml")
144
161
  end
145
162
 
146
- method_option :elasticsearch, default: false, type: :boolean, aliases: '-e'
147
- method_option :solr, default: false, type: :boolean, aliases: '-s'
148
- method_option :postgres, default: false, type: :boolean, aliases: '-p'
149
- method_option :mysql, default: false, type: :boolean, aliases: '-m'
150
- method_option :redis, default: false, type: :boolean, aliases: '-r'
151
163
  method_option :delayed_job, default: false, type: :boolean, aliases: '-j'
152
- method_option :fcrepo, default: false, type: :boolean, aliases: '-f'
153
164
  method_option :deploy, default: false, type: :boolean, aliases: '-d'
165
+ method_option :elasticsearch, default: false, type: :boolean, aliases: '-e'
166
+ method_option :fcrepo, default: false, type: :boolean, aliases: '-f'
167
+ method_option :helm, default: false, type: :boolean, aliases: '-h'
168
+ method_option :git, default: true, type: :boolean, aliases: '-g'
154
169
  method_option :heroku, default: false, type: :boolean, aliases: '-h'
170
+ method_option :hyku, default: false, type: :boolean, aliases: '-u'
171
+ method_option :imagemagick, default: false, type: :boolean, aliases: '-i'
172
+ method_option :memcached, default: false, type: :boolean, aliases: '-mc'
173
+ method_option :mongodb, default: false, type: :boolean, aliases: '-mg'
174
+ method_option :mysql, default: false, type: :boolean, aliases: '-m'
175
+ method_option :postgres, default: false, type: :boolean, aliases: '-p'
155
176
  method_option :rancher, default: false, type: :boolean, aliases: '-dr'
177
+ method_option :redis, default: false, type: :boolean, aliases: '-r'
156
178
  method_option :sidekiq, default: false, type: :boolean, aliases: '-sq' # TODO
157
- method_option :mongodb, default: false, type: :boolean, aliases: '-mg'
158
- method_option :memcached, default: false, type: :boolean, aliases: '-mc'
179
+ method_option :solr, default: false, type: :boolean, aliases: '-s'
159
180
  method_option :yarn, default: false, type: :boolean, aliases: '-y'
160
181
  desc 'dockerize DIR', 'Will copy the docker tempates in to your project, see options for supported dependencies'
161
182
  long_desc <<-DOCKERIZE
@@ -166,9 +187,14 @@ module StackCar
166
187
  DOCKERIZE
167
188
  def dockerize(dir=".")
168
189
  Dir.chdir(dir)
190
+ self.destination_root = dir
191
+ setup
192
+ # Commandline overrides config files
193
+ # options = file_config.merge(options)
169
194
  @project_name = File.basename(File.expand_path(dir))
170
195
  apt_packages << "libpq-dev postgresql-client" if options[:postgres]
171
196
  apt_packages << "mysql-client" if options[:mysql]
197
+ apt_packages << "imagemagick" if options[:imagemagick]
172
198
  pre_apt << "echo 'Downloading Packages'"
173
199
  post_apt << "echo 'Packages Downloaded'"
174
200
 
@@ -188,7 +214,7 @@ module StackCar
188
214
  post_apt << "cd /opt && unzip fits-1.0.5.zip && chmod +X fits-1.0.5/fits.sh"
189
215
  end
190
216
 
191
- ['.dockerignore', 'Dockerfile', 'Dockerfile.base', 'docker-compose.yml', 'docker-compose.ci.yml', 'docker-compose.production.yml', '.gitlab-ci.yml', '.env'].each do |template_file|
217
+ ['.dockerignore', 'Dockerfile', 'Dockerfile.base', 'docker-compose.yml', '.gitlab-ci.yml', '.env'].each do |template_file|
192
218
  puts template_file
193
219
  template("#{template_file}.erb", template_file)
194
220
  end
@@ -205,14 +231,33 @@ module StackCar
205
231
  File.read("#{self.class.source_root}/README.md")
206
232
  end
207
233
  end
208
- append_to_file("Gemfile", "gem 'activerecord-nulldb-adapter'")
234
+
235
+ if File.exist?('Gemfile')
236
+ append_to_file('Gemfile', "gem 'activerecord-nulldb-adapter'")
237
+ else
238
+ append_to_file('../Gemfile', "gem 'activerecord-nulldb-adapter'", { verbose: false })
239
+ # TODO: remove '../' from message after other status messages are prepended with 'stack_car/'
240
+ append_to_file("../Gemfile", "gem 'pronto', groups: [:development, :test]")
241
+ append_to_file("../Gemfile", "gem 'pronto-rubocop', groups: [:development, :test]")
242
+ say_status(:append, '../Gemfile')
243
+ end
244
+
209
245
  if options[:deploy] || options[:rancher]
210
246
  directory('ops')
211
247
  ['hosts', 'deploy.yml', 'provision.yml'].each do |template_file|
212
248
  template("#{template_file}.erb", "ops/#{template_file}")
213
249
  end
250
+
214
251
  say 'Please update ops/hosts with the correct server addresses'
215
- else
252
+ elsif options[:helm]
253
+ directory('chart')
254
+ if options[:fcrepo]
255
+ directory('chart-fcrepo', 'chart/templates')
256
+ end
257
+ if options[:sidekiq]
258
+ directory('chart-sidekiq', 'chart/templates')
259
+ end
260
+ else
216
261
  empty_directory('ops')
217
262
  end
218
263
 
@@ -267,11 +312,42 @@ module StackCar
267
312
  end
268
313
  end
269
314
 
315
+ def file_config
316
+ path = find_config(Dir.pwd)
317
+ if path
318
+ JSON.parse(File.read(path))
319
+ else
320
+ {}
321
+ end
322
+ end
323
+
324
+ def find_config(dir)
325
+ path = File.join(dir, '.stackcar_rc')
326
+ if File.exists?(path)
327
+ return path
328
+ elsif dir == "/"
329
+ return nil
330
+ else
331
+ return find_config(File.dirname(dir))
332
+ end
333
+ end
334
+
270
335
  def ensure_development_env
271
336
  if !File.exists?('.env.development')
272
337
  template(".env.development.erb", ".env.development")
273
338
  end
274
339
  end
275
340
 
341
+ def dotenv(environment='development')
342
+ "dotenv -f .env.#{environment},.env"
343
+ end
344
+
345
+ def setup
346
+ if File.exists?('stack_car')
347
+ Dir.chdir('stack_car')
348
+ self.destination_root += "/stack_car"
349
+ end
350
+ DotRc.new
351
+ end
276
352
  end
277
353
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ require 'pathname'
3
+ module StackCar
4
+ class DotRc
5
+ include Thor::Shell
6
+
7
+ def initialize
8
+ @file = find_file
9
+ say_status :load, 'not found', :red && return unless @file
10
+ say_status :load, @file
11
+ load(@file)
12
+ end
13
+
14
+ def find_file
15
+ path = nil
16
+ Pathname(Dir.pwd).ascend do |p|
17
+ if File.directory?(p) && File.exist?(File.join(p, '.stack_car_rc'))
18
+ path = File.join(p, '.stack_car_rc')
19
+ break
20
+ end
21
+ end
22
+ path
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module StackCar
2
- VERSION = "0.9.0"
2
+ VERSION = "0.12.0"
3
3
  end
data/stack_car.gemspec CHANGED
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "yard-thor"
27
27
  spec.add_development_dependency "pry"
28
28
  spec.add_runtime_dependency "dotenv", "~> 2.2"
29
+ spec.add_runtime_dependency "json", "~> 2.3"
29
30
  spec.add_runtime_dependency "thor", "~> 0.19"
30
31
  end
@@ -2,9 +2,9 @@
2
2
  .convox
3
3
  .env
4
4
  .env.*
5
- node_modules
6
- .git
5
+ .ruby-*
7
6
  db/*.sqlite3
8
7
  db/*.sqlite3-journal
9
8
  log/*
9
+ node_modules
10
10
  tmp