capistrano-alchemy 0.3.0 → 2.0.0

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
- SHA1:
3
- metadata.gz: ccf9597911523ef71181e42d21c45c701c684205
4
- data.tar.gz: f0a7c1abd703d6246d6191ee6b698ffd35c03ae6
2
+ SHA256:
3
+ metadata.gz: b73822a4e394141f9c35c6296e9bbb7f86030fda9cc78765c5aa23c70abcd275
4
+ data.tar.gz: e4422807f16f7915717d7c0d9037d543ac5a879feb30658f7af3f3bff371e297
5
5
  SHA512:
6
- metadata.gz: d945b45ef595c8a332617d927e33ba6723730c0aee18c3a966c2d81cd18178ad35e78354592e0b0205a7c61f0f45c7026dea6e70001dc6dc214fc229d76ec9bd
7
- data.tar.gz: 1a7c210e28166b934666ee0fe6f17726fbfa8adde6d3def6ff56366d6c85bab312d9761b271963109e9a033d5074c82112c2734d5f30b3fbfd3b2a100ec4ae62
6
+ metadata.gz: b35211b07a8189a0c7142893e52e7f452ac0249613b0b00ec8af0dd3d95dc3e4658f4d8e23d54a86e08cbf8437abf3d1822b3b5a497cfcd0e3d5c0fa5418a23c
7
+ data.tar.gz: 5fb58e7895293a10575830e85b43b1aa1844d12e1eb2820f9739e4c8b923858ee6a3c68b7acf0f2fc2dd0e7b1935a805bb28cc6d0559fd41b8dd4619dae72c41
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .ruby-*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Capistrano Tasks for Alchemy CMS
2
2
 
3
- Capistrano::Alchemy adds four folders to Capistranos `linked_dirs` array: `uploads/pictures`, `uploads/attachments`, and Alchemy's picture cache folder.
3
+ Adds the Alchemy `uploads` folder to Capistranos `linked_dirs` array in order to survive deployments.
4
4
 
5
5
  In addition, it offers several tasks to synchronize your uploads folder and your database between environments.
6
6
 
@@ -10,7 +10,7 @@ In addition, it offers several tasks to synchronize your uploads folder and your
10
10
  Add this line to your application's Gemfile:
11
11
 
12
12
  ```ruby
13
- gem 'capistrano-alchemy', github: 'AlchemyCMS/capistrano-alchemy', branch: 'master', group: :development, require: false
13
+ gem 'capistrano-alchemy', '~> 1.0', group: :development, require: false
14
14
  ```
15
15
 
16
16
  And then execute:
@@ -35,6 +35,19 @@ require 'capistrano/alchemy'
35
35
  ## Usage
36
36
 
37
37
 
38
+ ### Upgrade Alchemy
39
+
40
+ We have a task to run the alchemy upgrader on your servers.
41
+
42
+ ```shell
43
+ $ bundle exec cap staging alchemy:upgrade
44
+ ```
45
+
46
+ **CAUTION:** Please be sure to run the upgrader locally before running this untested on your production system!
47
+
48
+ Cloning the production data to your local dev env is advised before running the upgrader. This can easily be done with
49
+ the next command.
50
+
38
51
  ### Synchronize your data
39
52
 
40
53
  Alchemy Capistrano receipts offer much more then only deployment related tasks. We also have tasks to make your local development easier. To get a list of all receipts type:
@@ -6,8 +6,8 @@ require 'capistrano/alchemy/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "capistrano-alchemy"
8
8
  spec.version = Capistrano::Alchemy::VERSION
9
- spec.authors = ["Martin Meyerhoff"]
10
- spec.email = ["mamhoff@googlemail.com"]
9
+ spec.authors = ["Martin Meyerhoff", "Thomas von Deyen"]
10
+ spec.email = ["mamhoff@googlemail.com", "thomas@vondeyen.com"]
11
11
  spec.summary = %q{Capistrano Tasks for AlchemyCMS.}
12
12
  spec.homepage = "https://alchemy-cms.com"
13
13
  spec.license = "MIT"
@@ -18,8 +18,5 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "capistrano-rails", "~> 1.1"
21
-
22
- spec.add_development_dependency "bundler", "~> 1.7"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency 'alchemy_cms', "~> 3.0"
21
+ spec.add_dependency "capistrano-db-tasks", "~> 0.6"
25
22
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Alchemy
3
- VERSION = "0.3.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -1,16 +1,7 @@
1
1
  require "capistrano/alchemy/version"
2
2
 
3
3
  require 'fileutils'
4
- require 'alchemy/tasks/helpers'
5
- # Loading the rails app
6
- # require './config/environment.rb'
7
- # so we can read the current mount point of Alchemy
8
- require 'alchemy/mount_point'
9
- require 'capistrano/alchemy/deploy_support'
10
-
11
- include Alchemy::Tasks::Helpers
12
- include Capistrano::Alchemy::DeploySupport
4
+ require 'capistrano-db-tasks'
13
5
 
14
6
  load File.expand_path('../tasks/alchemy.rake', __FILE__)
15
7
  load File.expand_path('../tasks/alchemy_capistrano_hooks.rake', __FILE__)
16
-
@@ -2,106 +2,72 @@ namespace :alchemy do
2
2
 
3
3
  # Prepare Alchemy for deployment
4
4
  task :default_paths do
5
- set :alchemy_picture_cache_path,
6
- -> { File.join('public', Alchemy::MountPoint.get, 'pictures') }
7
- set :linked_dirs, fetch(:linked_dirs, []) + [
8
- "uploads/pictures",
9
- "uploads/attachments",
10
- fetch(:alchemy_picture_cache_path)
11
- ]
5
+ set :linked_dirs, fetch(:linked_dirs, []) + %w(uploads public/pictures)
12
6
  end
13
7
 
14
8
  namespace :db do
15
9
  desc "Dumps the database into 'db/dumps' on the server."
16
10
  task dump: ['alchemy:default_paths', 'deploy:check'] do
11
+
17
12
  on roles :db do
18
- within release_path do
19
- timestamp = Time.now.strftime('%Y-%m-%d-%H-%M')
20
- execute :mkdir, '-p', 'db/dumps'
21
- with dump_filename: "db/dumps/#{timestamp}.sql", rails_env: fetch(:rails_env, 'production') do
22
- execute :rake, 'alchemy:db:dump'
23
- end
24
- end
13
+ Database::Remote.new(self).dump
25
14
  end
26
15
  end
27
16
  end
28
17
 
29
18
  namespace :import do
30
19
  desc "Imports all data (Pictures, attachments and the database) into your local development machine."
31
- task all: ['alchemy:default_paths', 'deploy:check'] do
32
- on roles [:app, :db] do
33
- invoke('alchemy:import:pictures')
34
- puts "\n"
35
- invoke('alchemy:import:attachments')
36
- puts "\n"
37
- invoke('alchemy:import:database')
38
- end
39
- end
20
+ task all: [
21
+ 'alchemy:import:attachments',
22
+ 'alchemy:import:pictures',
23
+ 'alchemy:import:database'
24
+ ]
40
25
 
41
26
  desc "Imports the server database into your local development machine."
42
- task database: ['alchemy:default_paths', 'deploy:check'] do
43
- on roles :db do |server|
44
- puts '## Importing database'
45
- puts ' Please wait! This may take some time...'
46
- system db_import_cmd(server)
47
- puts ' done.'
48
- end
49
- end
27
+ task database: ['db:local:sync', 'alchemy:default_paths', 'deploy:check']
50
28
 
51
29
  desc "Imports attachments into your local machine using rsync."
52
30
  task attachments: ['alchemy:default_paths', 'deploy:check'] do
53
- on roles :app do |server|
54
- get_files(:attachments, server)
31
+ set :assets_dir, %w(uploads/attachments)
32
+ set :local_assets_dir, %w(uploads)
33
+ on roles [:app, :db] do
34
+ invoke('assets:local:sync')
55
35
  end
56
36
  end
57
37
 
58
38
  desc "Imports pictures into your local machine using rsync."
59
39
  task pictures: ['alchemy:default_paths', 'deploy:check'] do
60
- on roles :app do |server|
61
- get_files(:pictures, server)
40
+ set :assets_dir, %w(public/pictures uploads/pictures)
41
+ set :local_assets_dir, %w(public uploads)
42
+ on roles [:app, :db] do
43
+ invoke('assets:local:sync')
62
44
  end
63
45
  end
64
46
  end
65
47
 
66
48
  namespace :export do
67
49
  desc "Sends all data (Pictures, attachments and the database) to your remote machine."
68
- task all: ['alchemy:default_paths', 'deploy:check'] do
69
- invoke 'alchemy:export:pictures'
70
- invoke 'alchemy:export:attachments'
71
- invoke 'alchemy:export:database'
72
- end
50
+ task all: [
51
+ 'alchemy:export:attachments',
52
+ 'alchemy:export:pictures',
53
+ 'alchemy:export:database'
54
+ ]
73
55
 
74
- desc "Imports the server database into your local development machine."
75
- task database: ['alchemy:default_paths', 'deploy:check'] do
76
- on roles :db do |host|
77
- within release_path do
78
- if ask(:backup_confirm, 'WARNING: This task will overwrite your remote database. Do you want me to make a backup? (y/n)') == "y"
79
- backup_database
80
- export_database(host)
81
- else
82
- if ask(:overwrite_confirm, 'Are you sure? (y/n)') == "y"
83
- export_database(host)
84
- else
85
- backup_database
86
- export_database(host)
87
- end
88
- end
89
- end
90
- end
91
- end
56
+ desc "Exports the local database into your server."
57
+ task database: ['db:remote:sync', 'alchemy:default_paths', 'deploy:check']
92
58
 
93
59
  desc "Sends attachments to your remote machine using rsync."
94
60
  task attachments: ['alchemy:default_paths', 'deploy:check'] do
95
- on roles :app do |host|
96
- send_files :attachments, host
97
- end
61
+ set :assets_dir, %w(uploads/attachments)
62
+ set :local_assets_dir, %w(uploads)
63
+ invoke('assets:remote:sync')
98
64
  end
99
65
 
100
66
  desc "Sends pictures to your remote machine using rsync."
101
67
  task pictures: ['alchemy:default_paths', 'deploy:check'] do
102
- on roles :app do |host|
103
- send_files :pictures, host
104
- end
68
+ set :assets_dir, %w(public/pictures uploads/attachments)
69
+ set :local_assets_dir, %w(public uploads)
70
+ invoke('assets:remote:sync')
105
71
  end
106
72
  end
107
73
 
@@ -0,0 +1 @@
1
+ require 'capistrano/alchemy'
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-alchemy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
- autorequire:
8
+ - Thomas von Deyen
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-01-07 00:00:00.000000000 Z
12
+ date: 2023-03-22 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: capistrano-rails
@@ -25,55 +26,29 @@ dependencies:
25
26
  - !ruby/object:Gem::Version
26
27
  version: '1.1'
27
28
  - !ruby/object:Gem::Dependency
28
- name: bundler
29
+ name: capistrano-db-tasks
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: '1.7'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.7'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: alchemy_cms
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
34
+ version: '0.6'
35
+ type: :runtime
63
36
  prerelease: false
64
37
  version_requirements: !ruby/object:Gem::Requirement
65
38
  requirements:
66
39
  - - "~>"
67
40
  - !ruby/object:Gem::Version
68
- version: '3.0'
69
- description:
41
+ version: '0.6'
42
+ description:
70
43
  email:
71
44
  - mamhoff@googlemail.com
45
+ - thomas@vondeyen.com
72
46
  executables: []
73
47
  extensions: []
74
48
  extra_rdoc_files: []
75
49
  files:
76
50
  - ".gitignore"
51
+ - ".rspec"
77
52
  - Gemfile
78
53
  - LICENSE.txt
79
54
  - README.md
@@ -81,7 +56,6 @@ files:
81
56
  - capistrano-alchemy.gemspec
82
57
  - lib/capistrano-alchemy.rb
83
58
  - lib/capistrano/alchemy.rb
84
- - lib/capistrano/alchemy/deploy_support.rb
85
59
  - lib/capistrano/alchemy/version.rb
86
60
  - lib/capistrano/tasks/alchemy.rake
87
61
  - lib/capistrano/tasks/alchemy_capistrano_hooks.rake
@@ -89,7 +63,7 @@ homepage: https://alchemy-cms.com
89
63
  licenses:
90
64
  - MIT
91
65
  metadata: {}
92
- post_install_message:
66
+ post_install_message:
93
67
  rdoc_options: []
94
68
  require_paths:
95
69
  - lib
@@ -104,9 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
78
  - !ruby/object:Gem::Version
105
79
  version: '0'
106
80
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.5.1
109
- signing_key:
81
+ rubygems_version: 3.2.33
82
+ signing_key:
110
83
  specification_version: 4
111
84
  summary: Capistrano Tasks for AlchemyCMS.
112
85
  test_files: []
@@ -1,59 +0,0 @@
1
- module Capistrano::Alchemy::DeploySupport
2
- # Makes a backup of the remote database and stores it in db/ folder
3
- def backup_database
4
- puts 'Backing up database'
5
- timestamp = Time.now.strftime('%Y-%m-%d-%H-%M')
6
- rake "RAILS_ENV=#{fetch(:rails_env, 'production')} alchemy:db:dump DUMP_FILENAME=db/dump-#{timestamp}.sql"
7
- end
8
-
9
- # Sends the database via ssh to the server
10
- def export_database(server)
11
- puts "Exporting the database. Please wait..."
12
- system db_export_cmd(server)
13
- end
14
-
15
- def db_import_cmd(server)
16
- raise "No server given" if !server
17
- env = "RAILS_ENV=#{fetch(:rails_env, 'production')}"
18
- dump_cmd = "cd #{release_path} && #{rake_cmd} alchemy:db:dump #{env}"
19
- sql_stream = "#{ssh_command(server)} '#{dump_cmd}'"
20
- "#{sql_stream} | #{database_import_command(database_config['adapter'])} 1>/dev/null 2>&1"
21
- end
22
-
23
- # The actual export command that sends the data
24
- def db_export_cmd(server)
25
- raise "No server given" if !server
26
- env = "RAILS_ENV=#{fetch(:rails_env, 'production')}"
27
- import_cmd = "cd #{release_path} && #{rake_cmd} alchemy:db:import #{env}"
28
- ssh_cmd = "#{ssh_command(server)} '#{import_cmd}'"
29
- "#{database_dump_command(database_config['adapter'])} | #{ssh_cmd}"
30
- end
31
-
32
- # Sends files of given type via rsync to server
33
- def send_files(type, server)
34
- raise "No server given" if !server
35
- FileUtils.mkdir_p "./uploads/#{type}"
36
- system "rsync --progress -rue 'ssh -p #{ssh_port(server)}' uploads/#{type} #{server.user}@#{server.hostname}:#{shared_path}/uploads/"
37
- end
38
-
39
- def get_files(type, server)
40
- raise "No server given" if !server
41
- FileUtils.mkdir_p "./uploads"
42
- puts "Importing #{type}. Please wait..."
43
- system "rsync --progress -rue 'ssh -p #{ssh_port(server)}' #{server.user}@#{server.hostname}:#{shared_path}/uploads/#{type} ./uploads/"
44
- end
45
-
46
- private
47
-
48
- def ssh_command(server)
49
- "ssh -C -p #{ssh_port(server)} #{server.user}@#{server.hostname}"
50
- end
51
-
52
- def ssh_port(server)
53
- server.port || 22
54
- end
55
-
56
- def rake_cmd
57
- SSHKit.config.command_map[:rake]
58
- end
59
- end