capistrano-alchemy 1.0.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: 684d80312257f263f4c49c0555a294d42bd65a0d
4
- data.tar.gz: 4e0b941e723102baf911eeefd1ba18dd5744e9c2
2
+ SHA256:
3
+ metadata.gz: b73822a4e394141f9c35c6296e9bbb7f86030fda9cc78765c5aa23c70abcd275
4
+ data.tar.gz: e4422807f16f7915717d7c0d9037d543ac5a879feb30658f7af3f3bff371e297
5
5
  SHA512:
6
- metadata.gz: e800e509de2c5d1c3ef634d0146339bb9e32e2651ff6ae774117783ef3abd157b540d67b348c3a4a9f25b8bc36eea17c3288ea96e7a90057ebf8254bde29baa3
7
- data.tar.gz: 51ea67118c423567d57db00a16192775ec7445c44c8d9dc8bfd7b8ac7ceac295b1700586f8d17152f46ee7e8290cdc5d7661ac50eec3c15277d6f7c4bbde7f79
6
+ metadata.gz: b35211b07a8189a0c7142893e52e7f452ac0249613b0b00ec8af0dd3d95dc3e4658f4d8e23d54a86e08cbf8437abf3d1822b3b5a497cfcd0e3d5c0fa5418a23c
7
+ data.tar.gz: 5fb58e7895293a10575830e85b43b1aa1844d12e1eb2820f9739e4c8b923858ee6a3c68b7acf0f2fc2dd0e7b1935a805bb28cc6d0559fd41b8dd4619dae72c41
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -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 = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -1,11 +1,7 @@
1
1
  require "capistrano/alchemy/version"
2
2
 
3
3
  require 'fileutils'
4
- require 'alchemy/tasks/helpers'
5
- require 'capistrano/alchemy/deploy_support'
6
-
7
- include Alchemy::Tasks::Helpers
8
- include Capistrano::Alchemy::DeploySupport
4
+ require 'capistrano-db-tasks'
9
5
 
10
6
  load File.expand_path('../tasks/alchemy.rake', __FILE__)
11
7
  load File.expand_path('../tasks/alchemy_capistrano_hooks.rake', __FILE__)
@@ -2,100 +2,72 @@ namespace :alchemy do
2
2
 
3
3
  # Prepare Alchemy for deployment
4
4
  task :default_paths do
5
- set :linked_dirs, fetch(:linked_dirs, []) + %w(uploads)
5
+ set :linked_dirs, fetch(:linked_dirs, []) + %w(uploads public/pictures)
6
6
  end
7
7
 
8
8
  namespace :db do
9
9
  desc "Dumps the database into 'db/dumps' on the server."
10
10
  task dump: ['alchemy:default_paths', 'deploy:check'] do
11
+
11
12
  on roles :db do
12
- within release_path do
13
- timestamp = Time.now.strftime('%Y-%m-%d-%H-%M')
14
- execute :mkdir, '-p', 'db/dumps'
15
- with dump_filename: "db/dumps/#{timestamp}.sql", rails_env: fetch(:rails_env, 'production') do
16
- execute :rake, 'alchemy:db:dump'
17
- end
18
- end
13
+ Database::Remote.new(self).dump
19
14
  end
20
15
  end
21
16
  end
22
17
 
23
18
  namespace :import do
24
19
  desc "Imports all data (Pictures, attachments and the database) into your local development machine."
25
- task all: ['alchemy:default_paths', 'deploy:check'] do
26
- on roles [:app, :db] do
27
- invoke('alchemy:import:pictures')
28
- puts "\n"
29
- invoke('alchemy:import:attachments')
30
- puts "\n"
31
- invoke('alchemy:import:database')
32
- end
33
- end
20
+ task all: [
21
+ 'alchemy:import:attachments',
22
+ 'alchemy:import:pictures',
23
+ 'alchemy:import:database'
24
+ ]
34
25
 
35
26
  desc "Imports the server database into your local development machine."
36
- task database: ['alchemy:default_paths', 'deploy:check'] do
37
- on roles :db do |server|
38
- puts '## Importing database'
39
- puts ' Please wait! This may take some time...'
40
- system db_import_cmd(server)
41
- puts ' done.'
42
- end
43
- end
27
+ task database: ['db:local:sync', 'alchemy:default_paths', 'deploy:check']
44
28
 
45
29
  desc "Imports attachments into your local machine using rsync."
46
30
  task attachments: ['alchemy:default_paths', 'deploy:check'] do
47
- on roles :app do |server|
48
- 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')
49
35
  end
50
36
  end
51
37
 
52
38
  desc "Imports pictures into your local machine using rsync."
53
39
  task pictures: ['alchemy:default_paths', 'deploy:check'] do
54
- on roles :app do |server|
55
- 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')
56
44
  end
57
45
  end
58
46
  end
59
47
 
60
48
  namespace :export do
61
49
  desc "Sends all data (Pictures, attachments and the database) to your remote machine."
62
- task all: ['alchemy:default_paths', 'deploy:check'] do
63
- invoke 'alchemy:export:pictures'
64
- invoke 'alchemy:export:attachments'
65
- invoke 'alchemy:export:database'
66
- end
50
+ task all: [
51
+ 'alchemy:export:attachments',
52
+ 'alchemy:export:pictures',
53
+ 'alchemy:export:database'
54
+ ]
67
55
 
68
- desc "Imports the server database into your local development machine."
69
- task database: ['alchemy:default_paths', 'deploy:check'] do
70
- on roles :db do |host|
71
- within release_path do
72
- if ask(:backup_confirm, 'WARNING: This task will overwrite your remote database. Do you want me to make a backup? (y/n)') == "y"
73
- backup_database
74
- export_database(host)
75
- else
76
- if ask(:overwrite_confirm, 'Are you sure? (y/n)') == "y"
77
- export_database(host)
78
- else
79
- backup_database
80
- export_database(host)
81
- end
82
- end
83
- end
84
- end
85
- end
56
+ desc "Exports the local database into your server."
57
+ task database: ['db:remote:sync', 'alchemy:default_paths', 'deploy:check']
86
58
 
87
59
  desc "Sends attachments to your remote machine using rsync."
88
60
  task attachments: ['alchemy:default_paths', 'deploy:check'] do
89
- on roles :app do |host|
90
- send_files :attachments, host
91
- end
61
+ set :assets_dir, %w(uploads/attachments)
62
+ set :local_assets_dir, %w(uploads)
63
+ invoke('assets:remote:sync')
92
64
  end
93
65
 
94
66
  desc "Sends pictures to your remote machine using rsync."
95
67
  task pictures: ['alchemy:default_paths', 'deploy:check'] do
96
- on roles :app do |host|
97
- send_files :pictures, host
98
- end
68
+ set :assets_dir, %w(public/pictures uploads/attachments)
69
+ set :local_assets_dir, %w(public uploads)
70
+ invoke('assets:remote:sync')
99
71
  end
100
72
  end
101
73
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-alchemy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
8
  - Thomas von Deyen
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-15 00:00:00.000000000 Z
12
+ date: 2023-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano-rails
@@ -26,48 +26,20 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.1'
28
28
  - !ruby/object:Gem::Dependency
29
- name: bundler
29
+ name: capistrano-db-tasks
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.7'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '1.7'
42
- - !ruby/object:Gem::Dependency
43
- name: rake
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '10.0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '10.0'
56
- - !ruby/object:Gem::Dependency
57
- name: alchemy_cms
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '3.0'
63
- type: :development
34
+ version: '0.6'
35
+ type: :runtime
64
36
  prerelease: false
65
37
  version_requirements: !ruby/object:Gem::Requirement
66
38
  requirements:
67
39
  - - "~>"
68
40
  - !ruby/object:Gem::Version
69
- version: '3.0'
70
- description:
41
+ version: '0.6'
42
+ description:
71
43
  email:
72
44
  - mamhoff@googlemail.com
73
45
  - thomas@vondeyen.com
@@ -76,6 +48,7 @@ extensions: []
76
48
  extra_rdoc_files: []
77
49
  files:
78
50
  - ".gitignore"
51
+ - ".rspec"
79
52
  - Gemfile
80
53
  - LICENSE.txt
81
54
  - README.md
@@ -83,7 +56,6 @@ files:
83
56
  - capistrano-alchemy.gemspec
84
57
  - lib/capistrano-alchemy.rb
85
58
  - lib/capistrano/alchemy.rb
86
- - lib/capistrano/alchemy/deploy_support.rb
87
59
  - lib/capistrano/alchemy/version.rb
88
60
  - lib/capistrano/tasks/alchemy.rake
89
61
  - lib/capistrano/tasks/alchemy_capistrano_hooks.rake
@@ -91,7 +63,7 @@ homepage: https://alchemy-cms.com
91
63
  licenses:
92
64
  - MIT
93
65
  metadata: {}
94
- post_install_message:
66
+ post_install_message:
95
67
  rdoc_options: []
96
68
  require_paths:
97
69
  - lib
@@ -106,9 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
78
  - !ruby/object:Gem::Version
107
79
  version: '0'
108
80
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 2.5.1
111
- signing_key:
81
+ rubygems_version: 3.2.33
82
+ signing_key:
112
83
  specification_version: 4
113
84
  summary: Capistrano Tasks for AlchemyCMS.
114
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