orats 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,8 +23,6 @@ end
23
23
  }
24
24
  end
25
25
 
26
- app_name_upper = app_name.upcase
27
-
28
26
  # ----- Delete application.css ------------------------------------------------------------------------
29
27
 
30
28
  # This gets created by rails automatically when you make a new project
@@ -737,7 +735,7 @@ CODE
737
735
  end
738
736
 
739
737
  inject_into_file '.env', before: "\nDATABASE_NAME" do <<-CODE
740
- ACTION_MAILER_DEVISE_DEFAULT_EMAIL: info@#{app_name}.com
738
+ ACTION_MAILER_DEVISE_DEFAULT_FROM: info@#{app_name}.com
741
739
  CODE
742
740
  end
743
741
 
@@ -57,6 +57,10 @@ append_to_file '.gitignore' do <<-TEXT
57
57
  # Ignore app specific folders.
58
58
  /vendor/bundle
59
59
  /public/assets/*
60
+
61
+ # Ignore backup paths.
62
+ /lib/backup/log/*
63
+ /lib/backup/tmp/*
60
64
  TEXT
61
65
  end
62
66
 
@@ -69,7 +73,7 @@ puts
69
73
  say_status 'root', 'Creating root files...', :yellow
70
74
  puts '-'*80, ''; sleep 0.25
71
75
 
72
- file '.ruby-version', '2.1.1'
76
+ file '.ruby-version', '2.1.2'
73
77
 
74
78
  git add: '-A'
75
79
  git commit: "-m 'Add .ruby-version file for common ruby version managers'"
@@ -94,21 +98,25 @@ RAILS_ENV: development
94
98
 
95
99
  PROJECT_PATH: /full/path/to/your/project
96
100
 
97
- GOOGLE_ANALYTICS_UA:
98
- DISQUS_SHORT_NAME:
101
+ GOOGLE_ANALYTICS_UA: ""
102
+ DISQUS_SHORT_NAME: ""
103
+ S3_ACCESS_KEY_ID: ""
104
+ S3_SECRET_ACCESS_KEY: ""
105
+ S3_REGION: ""
99
106
 
100
107
  TOKEN_RAILS_SECRET: #{generate_token}
101
108
 
102
109
  SMTP_ADDRESS: smtp.gmail.com
103
- SMTP_PORT: 587
110
+ SMTP_PORT: 587 # 465 if you use ssl
104
111
  SMTP_DOMAIN: gmail.com
105
112
  SMTP_USERNAME: #{app_name}@gmail.com
106
113
  SMTP_PASSWORD: thebestpassword
107
114
  SMTP_AUTH: plain
108
- SMTP_STARTTTLS_AUTO: true
115
+ SMTP_ENCRYPTION: starttls
109
116
 
110
117
  ACTION_MAILER_HOST: localhost:3000
111
- ACTION_MAILER_DEFAULT_EMAIL: info@#{app_name}.com
118
+ ACTION_MAILER_DEFAULT_FROM: info@#{app_name}.com
119
+ ACTION_MAILER_DEFAULT_TO: me@#{app_name}.com
112
120
 
113
121
  DATABASE_NAME: #{app_name}
114
122
  DATABASE_HOST: localhost
@@ -120,7 +128,7 @@ DATABASE_PASSWORD: supersecrets
120
128
  CACHE_HOST: localhost
121
129
  CACHE_PORT: 6379
122
130
  CACHE_DATABASE: 0
123
- CACHE_PASSWORD:
131
+ CACHE_PASSWORD: ""
124
132
 
125
133
  PUMA_THREADS_MIN: 0
126
134
  PUMA_THREADS_MAX: 1
@@ -177,16 +185,18 @@ inject_into_file 'config/application.rb', after: "automatically loaded.\n" do <<
177
185
  :domain => ENV['SMTP_DOMAIN'],
178
186
  :user_name => ENV['SMTP_USERNAME'],
179
187
  :password => ENV['SMTP_PASSWORD'],
180
- :authentication => ENV['SMTP_AUTH'],
181
- :enable_starttls_auto => ENV['SMTP_STARTTTLS_AUTO'] == 'true'
188
+ :authentication => ENV['SMTP_AUTH']
182
189
  }
190
+ config.action_mailer.smtp_settings[:enable_starttls_auto] = true if ENV['SMTP_ENCRYPTION'] == 'starttls'
191
+ config.action_mailer.smtp_settings[:ssl] = true if ENV['SMTP_ENCRYPTION'] == 'ssl'
183
192
 
193
+ config.action_mailer.default_options = { from: ENV['ACTION_MAILER_DEFAULT_FROM'] }
184
194
  config.action_mailer.default_url_options = { host: ENV['ACTION_MAILER_HOST'] }
185
195
 
186
196
  config.cache_store = :redis_store, { host: ENV['CACHE_HOST'],
187
197
  port: ENV['CACHE_PORT'].to_i,
188
198
  db: ENV['CACHE_DATABASE'].to_i,
189
- # password: ENV['CACHE_PASSWORD'].to_i,
199
+ # password: ENV['CACHE_PASSWORD'],
190
200
  namespace: '#{app_name}::cache'
191
201
  }
192
202
  CODE
@@ -313,6 +323,10 @@ git add: '-A'
313
323
  git commit: "-m 'Add the sitemap config'"
314
324
 
315
325
  file 'config/schedule.rb', <<-CODE
326
+ every 1.day, at: '3:00 am' do
327
+ rake 'backup:production'
328
+ end
329
+
316
330
  every 1.day, at: '4:00 am' do
317
331
  rake 'sitemap:refresh'
318
332
  end
@@ -415,7 +429,7 @@ git commit: "-m 'Add a route concern for pagination'"
415
429
  # ----- Creating application tasks --------------------------------------------------------------------
416
430
 
417
431
  puts
418
- say_status 'Tasks', 'Creating application tasks...', :yellow
432
+ say_status 'tasks', 'Creating application tasks...', :yellow
419
433
  puts '-'*80, ''; sleep 0.25
420
434
 
421
435
  file 'lib/tasks/favicon.rake', <<-'CODE'
@@ -451,6 +465,224 @@ CODE
451
465
  git add: '-A'
452
466
  git commit: "-m 'Add a favicon generator task'"
453
467
 
468
+ file 'lib/tasks/backup.rake', <<-'CODE'
469
+ namespace :backup do
470
+ desc 'Create a backup of your production application'
471
+ task :production do
472
+ project_name = File.basename(Rails.root)
473
+ project_name = project_name.split('.').first if project_name.include?('.')
474
+
475
+ # source the production environment
476
+ # using a best guess of the name based on the folder name, you may have to change it if it does not match
477
+ sourced_env = ". /etc/default/#{project_name}"
478
+
479
+ system "#{sourced_env} && backup perform -t production_backup -c '#{Rails.root.join('lib', 'backup', 'config.rb')}'"
480
+ end
481
+ end
482
+ CODE
483
+
484
+ git add: '-A'
485
+ git commit: "-m 'Add a favicon generator task'"
486
+
487
+ # ----- Creating application backup --------------------------------------------------------------------
488
+
489
+ puts
490
+ say_status 'backup', 'Creating application backup script...', :yellow
491
+ puts '-'*80, ''; sleep 0.25
492
+
493
+ file 'lib/backup/config.rb', <<-'CODE'
494
+ ##
495
+ # Backup v4.x Configuration
496
+ #
497
+ # Documentation: http://meskyanichi.github.io/backup
498
+ # Issue Tracker: https://github.com/meskyanichi/backup/issues
499
+
500
+ ##
501
+ # Config Options
502
+ #
503
+ # The options here may be overridden on the command line, but the result
504
+ # will depend on the use of --root-path on the command line.
505
+ #
506
+ # If --root-path is used on the command line, then all paths set here
507
+ # will be overridden. If a path (like --tmp-path) is not given along with
508
+ # --root-path, that path will use it's default location _relative to --root-path_.
509
+ #
510
+ # If --root-path is not used on the command line, a path option (like --tmp-path)
511
+ # given on the command line will override the tmp_path set here, but all other
512
+ # paths set here will be used.
513
+ #
514
+ # Note that relative paths given on the command line without --root-path
515
+ # are relative to the current directory. The root_path set here only applies
516
+ # to relative paths set here.
517
+ #
518
+ # ---
519
+ #
520
+ # Sets the root path for all relative paths, including default paths.
521
+ # May be an absolute path, or relative to the current working directory.
522
+ #
523
+
524
+ root_path 'lib/backup'
525
+
526
+ #
527
+ # Sets the path where backups are processed until they're stored.
528
+ # This must have enough free space to hold apx. 2 backups.
529
+ # May be an absolute path, or relative to the current directory or +root_path+.
530
+ #
531
+
532
+ tmp_path 'tmp'
533
+
534
+ #
535
+ # Sets the path where backup stores persistent information.
536
+ # When Backup's Cycler is used, small YAML files are stored here.
537
+ # May be an absolute path, or relative to the current directory or +root_path+.
538
+ #
539
+
540
+ data_path 'data'
541
+
542
+ ##
543
+ # Utilities
544
+ #
545
+ # If you need to use a utility other than the one Backup detects,
546
+ # or a utility can not be found in your $PATH.
547
+ #
548
+ # Utilities.configure do
549
+ # tar '/usr/bin/gnutar'
550
+ # redis_cli '/opt/redis/redis-cli'
551
+ # end
552
+
553
+ ##
554
+ # Logging
555
+ #
556
+ # Logging options may be set on the command line, but certain settings
557
+ # may only be configured here.
558
+ #
559
+ # Logger.configure do
560
+ # console.quiet = true # Same as command line: --quiet
561
+ # logfile.max_bytes = 2_000_000 # Default: 500_000
562
+ # syslog.enabled = true # Same as command line: --syslog
563
+ # syslog.ident = 'my_app_backup' # Default: 'backup'
564
+ # end
565
+ #
566
+ # Command line options will override those set here.
567
+ # For example, the following would override the example settings above
568
+ # to disable syslog and enable console output.
569
+ # backup perform --trigger my_backup --no-syslog --no-quiet
570
+
571
+ ##
572
+ # Component Defaults
573
+ #
574
+ # Set default options to be applied to components in all models.
575
+ # Options set within a model will override those set here.
576
+ #
577
+ # Storage::S3.defaults do |s3|
578
+ # s3.access_key_id = "my_access_key_id"
579
+ # s3.secret_access_key = "my_secret_access_key"
580
+ # end
581
+ #
582
+ # Notifier::Mail.defaults do |mail|
583
+ # mail.from = 'sender@email.com'
584
+ # mail.to = 'receiver@email.com'
585
+ # mail.address = 'smtp.gmail.com'
586
+ # mail.port = 587
587
+ # mail.domain = 'your.host.name'
588
+ # mail.user_name = 'sender@email.com'
589
+ # mail.password = 'my_password'
590
+ # mail.authentication = 'plain'
591
+ # mail.encryption = :starttls
592
+ # end
593
+
594
+ ##
595
+ # Preconfigured Models
596
+ #
597
+ # Create custom models with preconfigured components.
598
+ # Components added within the model definition will
599
+ # +add to+ the preconfigured components.
600
+ #
601
+ # preconfigure 'MyModel' do
602
+ # archive :user_pictures do |archive|
603
+ # archive.add '~/pictures'
604
+ # end
605
+ #
606
+ # notify_by Mail do |mail|
607
+ # mail.to = 'admin@email.com'
608
+ # end
609
+ # end
610
+ #
611
+ # MyModel.new(:john_smith, 'John Smith Backup') do
612
+ # archive :user_music do |archive|
613
+ # archive.add '~/music'
614
+ # end
615
+ #
616
+ # notify_by Mail do |mail|
617
+ # mail.to = 'john.smith@email.com'
618
+ # end
619
+ # end
620
+ CODE
621
+
622
+ git add: '-A'
623
+ git commit: "-m 'Add backup config'"
624
+
625
+ file 'lib/backup/models/production_backup.rb', <<-'CODE'
626
+ Model.new(:production_backup, 'Production backup') do
627
+ split_into_chunks_of 10
628
+ compress_with Gzip
629
+
630
+ database PostgreSQL do |db|
631
+ # To dump all databases, set `db.name = :all` (or leave blank)
632
+ db.name = ENV['DATABASE_NAME']
633
+ db.username = ENV['DATABASE_USERNAME']
634
+ db.password = ENV['DATABASE_PASSWORD']
635
+ db.host = ENV['DATABASE_HOST']
636
+ db.port = 5432
637
+ db.socket = '/var/run/postgresql'
638
+ #db.skip_tables = ['skip', 'these', 'tables']
639
+ #db.only_tables = ['only', 'these', 'tables']
640
+ end
641
+
642
+ # uncomment the block below to archive a specific path
643
+ # this may be useful if you have user supplied content
644
+
645
+ # archive :app_archive do |archive|
646
+ # archive.add File.join(ENV['PROJECT_PATH'], 'public', 'system')
647
+ # end
648
+
649
+ # uncomment the block below and fill in the required information
650
+ # to use S3 to store your backups
651
+
652
+ # don't want to use S3? check out the other available options:
653
+ # http://meskyanichi.github.io/backup/v4/storages/
654
+
655
+ # store_with S3 do |s3|
656
+ # s3.access_key_id = ENV['S3_ACCESS_KEY_ID']
657
+ # s3.secret_access_key = ENV['S3_SECRET_ACCESS_KEY']
658
+ # s3.region = ENV['S3_REGION']
659
+ # s3.bucket = 'backup'
660
+ # s3.path = '/production/database'
661
+ # end
662
+
663
+ ENV['SMTP_ENCRYPTION'].empty? ? mail_encryption = 'none' : mail_encryption = ENV['SMTP_ENCRYPTION']
664
+
665
+ notify_by Mail do |mail|
666
+ mail.on_success = false
667
+ #mail.on_warning = true
668
+ mail.on_failure = true
669
+
670
+ mail.from = ENV['ACTION_MAILER_DEFAULT_FROM']
671
+ mail.to = ENV['ACTION_MAILER_DEFAULT_TO']
672
+ mail.address = ENV['SMTP_ADDRESS']
673
+ mail.port = ENV['SMTP_PORT'].to_i
674
+ mail.domain = ENV['SMTP_DOMAIN']
675
+ mail.user_name = ENV['SMTP_USERNAME']
676
+ mail.password = ENV['SMTP_PASSWORD']
677
+ mail.authentication = ENV['SMTP_AUTH']
678
+ mail.encryption = mail_encryption.to_sym
679
+ end
680
+ end
681
+ CODE
682
+
683
+ git add: '-A'
684
+ git commit: "-m 'Add backup model'"
685
+
454
686
  # ----- Creating application helpers ------------------------------------------------------------------
455
687
 
456
688
  puts
@@ -4,7 +4,7 @@ nickjj.postgres,v0.1.1
4
4
  nickjj.ruby,v0.1.3
5
5
  nickjj.nodejs,v0.1.1
6
6
  nickjj.nginx,v0.1.3
7
- nickjj.rails,v0.1.9
7
+ nickjj.rails,v0.1.92
8
8
  nickjj.whenever,v0.1.0
9
9
  nickjj.pumacorn,v0.1.1
10
10
  nickjj.sidekiq,v0.1.1
@@ -13,7 +13,6 @@ gem 'redis-rails', '~> 4.0.0'
13
13
  gem 'puma', '~> 2.8.2'
14
14
  gem 'sidekiq', '~> 3.1.2'
15
15
  gem 'sinatra', '>= 1.4.5', require: false
16
- gem 'whenever', '~> 0.9.2', require: false
17
16
  #gem 'jbuilder'
18
17
 
19
18
  gem 'kaminari', '~> 0.15.1'
@@ -34,6 +33,11 @@ group :development, :test do
34
33
  gem 'dotenv-rails', '~> 0.7.0'
35
34
  end
36
35
 
36
+ group :staging, :production do
37
+ gem 'whenever', '~> 0.9.2', require: false
38
+ gem 'backup', '~> 4.0.1', require: false
39
+ end
40
+
37
41
  group :assets do
38
42
  gem 'sass-rails', '~> 4.0.1'
39
43
  gem 'coffee-rails', '~> 4.0.1'
@@ -6,7 +6,8 @@ ansible_ssh_user: deploy
6
6
  user_name: "{{ ansible_ssh_user }}"
7
7
 
8
8
  # load all passwords from a local location outside of version control
9
- secrets_load_path: ~/tmp/testproj/secrets/
9
+ # do not add a trailing slash to the path
10
+ secrets_load_path: /home/yourname/dev/testproj/secrets
10
11
 
11
12
  secrets_postgres_password: "{{ lookup('password', secrets_load_path + 'postgres_password') }}"
12
13
  secrets_redis_password: "{{ lookup('password', secrets_load_path + 'redis_password') }}"
@@ -50,8 +51,11 @@ rails_deploy_env:
50
51
 
51
52
  PROJECT_PATH: "{{ rails_deploy_path }}"
52
53
 
53
- GOOGLE_ANALYTICS_UA:
54
- DISQUS_SHORT_NAME:
54
+ GOOGLE_ANALYTICS_UA: ""
55
+ DISQUS_SHORT_NAME: ""
56
+ S3_ACCESS_KEY_ID: ""
57
+ S3_SECRET_ACCESS_KEY: ""
58
+ S3_REGION: ""
55
59
 
56
60
  DATABASE_HOST: localhost
57
61
  DATABASE_NAME: "{{ rails_deploy_app_name }}"
@@ -69,17 +73,18 @@ rails_deploy_env:
69
73
  TOKEN_DEVISE_SECRET: "{{ secrets_devise_token }}"
70
74
  TOKEN_DEVISE_PEPPER: "{{ secrets_devise_pepper_token }}"
71
75
 
72
- SMTP_ADDRESS: smtp.testproj.com
73
- SMTP_PORT: 25
74
- SMTP_DOMAIN: testproj.com
76
+ SMTP_ADDRESS: smtp.gmail.com
77
+ SMTP_PORT: 587 # 465 if you use ssl
78
+ SMTP_DOMAIN: gmail.com
75
79
  SMTP_USERNAME: info@testproj.com
76
80
  SMTP_PASSWORD: "{{ secrets_mail_password }}"
77
81
  SMTP_AUTH: plain
78
- SMTP_STARTTTLS_AUTO: true
82
+ SMTP_ENCRYPTION: starttls
79
83
 
80
84
  ACTION_MAILER_HOST: www.testproj.com
81
- ACTION_MAILER_DEFAULT_EMAIL: info@testproj.com
82
- ACTION_MAILER_DEVISE_DEFAULT_EMAIL: info@testproj.com
85
+ ACTION_MAILER_DEFAULT_FROM: info@testproj.com
86
+ ACTION_MAILER_DEFAULT_TO: me@testproj.com
87
+ ACTION_MAILER_DEVISE_DEFAULT_FROM: info@testproj.com
83
88
 
84
89
  PUMA_THREADS_MIN: 0
85
90
  PUMA_THREADS_MAX: 16
@@ -18,9 +18,6 @@ def git_config(field)
18
18
  git_field_value.to_s.empty? ? default_value : git_field_value
19
19
  end
20
20
 
21
- app_name_upper = app_name.upcase
22
- app_name_class = app_name.humanize
23
-
24
21
  author_name = git_config 'name'
25
22
  author_email = git_config 'email'
26
23
 
@@ -1,3 +1,3 @@
1
1
  module Orats
2
- VERSION = '0.5.1'
2
+ VERSION = '0.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Janetakis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-05 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -77,16 +77,23 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - ".gitignore"
79
79
  - Gemfile
80
- - Gemfile.lock
81
80
  - LICENSE.txt
82
81
  - README.md
83
82
  - Rakefile
84
83
  - bin/orats
85
84
  - lib/orats.rb
86
85
  - lib/orats/cli.rb
87
- - lib/orats/command.rb
88
- - lib/orats/foreman.rb
89
- - lib/orats/shell.rb
86
+ - lib/orats/commands/common.rb
87
+ - lib/orats/commands/new/ansible.rb
88
+ - lib/orats/commands/new/exec.rb
89
+ - lib/orats/commands/new/foreman.rb
90
+ - lib/orats/commands/new/rails.rb
91
+ - lib/orats/commands/nuke.rb
92
+ - lib/orats/commands/outdated/compare.rb
93
+ - lib/orats/commands/outdated/exec.rb
94
+ - lib/orats/commands/outdated/parse.rb
95
+ - lib/orats/commands/play.rb
96
+ - lib/orats/commands/ui.rb
90
97
  - lib/orats/templates/auth.rb
91
98
  - lib/orats/templates/base.rb
92
99
  - lib/orats/templates/includes/Galaxyfile