capistrano-typo3 0.4.7 → 0.4.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c9db65bc915f2cc8eda5b8e4db074a31e02be3c
4
- data.tar.gz: 8b1d694b1d638659ddf96c60d6d2560c61cc3ab1
3
+ metadata.gz: 18ad521a406fd4ffd9502784269ce5119e4b1cb6
4
+ data.tar.gz: 5082d9b53a97bb96265a3364fdf16dd6c1681a16
5
5
  SHA512:
6
- metadata.gz: 382c4444504ee2ba3c8b40cca985cf6602dfb08ee0689837daf770421eeb1cef5d30e6836d86db10a54d679256e6194d6fb8f4e8c71e9db3f59232a1ef61e61e
7
- data.tar.gz: 7aa024ce92327c3c82d22cba5dcd912f10b4adf292cb78979d996a70bf869f258437001e73ec012111c852b2ea245c601c10fdf6b57b54caa9b0af84cd035602
6
+ metadata.gz: b16242087ee0fd2889cee854a95cbad09d210abc60cbef4351b564ecb466632165a8f8de33be5c5a951c97aa173966f3d35b544e35949fe6ac6cce55a696583a
7
+ data.tar.gz: 1e40c5181cb08672744851ba5a7cfbe69ba88e2057e2229f3e39ce87cbbf00bf2d6a3aed108a287148dbadb91699555b37a7e0d2f88af0fdf85b0e4855bc1872
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_runtime_dependency "capistrano", "~> 3"
24
+ spec.add_runtime_dependency "text-table", "~> 1"
25
+ require 'text-table'
24
26
  end
@@ -0,0 +1,132 @@
1
+ namespace :db do
2
+
3
+ desc 'test db connection'
4
+ task :conntest do
5
+ on roles(:all) do
6
+ stdout = capture DT3MySQL::mysql_execute('SHOW TABLES;')
7
+ if stdout.include? 'denied'
8
+ print "\nNO CORRECT DB CONNECTION. CHECK DB SETTINGS\n\n"
9
+ else
10
+ print "\nCORRECT DB CONNECTION.\n\n"
11
+ end
12
+ end
13
+ end
14
+
15
+ #### LIBRARY TASKS
16
+ task :create_dump_dir do
17
+ on roles(:all) do
18
+ execute "cd #{fetch(:deploy_to)}/current && mkdir -p #{TYPO3_DB_DUMP_DIR}"
19
+ end
20
+ end
21
+ #### END LIBRARY TASKS
22
+
23
+ desc 'dump a full sql-image'
24
+ task :dump do
25
+
26
+ invoke 'db:create_dump_dir'
27
+
28
+ on roles(:all) do
29
+ execute "cd #{fetch(:deploy_to)}/current && " + DT3MySQL::dump_db_version
30
+ end
31
+ end
32
+
33
+ desc 'list dumped sql-images'
34
+ task :imglist do
35
+ images_arr = DT3MySQL::db_image_list
36
+ print DT3Div::hashlist_to_table_string(images_arr)
37
+ end
38
+
39
+ desc 'show all tables'
40
+ task :tables do
41
+ print("Show tables:\n\n")
42
+ on roles(:all) do
43
+ execute DT3MySQL::show_tables
44
+ end
45
+ print("\n")
46
+ end
47
+
48
+ desc 'dump an sql-image with only the essential tables'
49
+ task :dump_essential do
50
+
51
+ on roles(:all) do
52
+ table_exclude_list = %w( be_users be_sessions cache_* cf_* fe_session_data fe_sessions static_countries \
53
+ static_country_zones static_currencies static_languages static_territories sys_history sys_log tx_devlog \
54
+ zzz_deleted_* )
55
+
56
+ tables = capture DT3MySQL::show_tables
57
+ table_arr = tables.split("\n")
58
+
59
+ substr_arr = []
60
+ excltable_arr = []
61
+ realexclude_list = []
62
+
63
+ table_exclude_list.each {|excltable|
64
+ if(excltable.include? '*')
65
+ substr_arr << excltable[0,excltable.index('*')]
66
+ else
67
+ excltable_arr << excltable
68
+ end
69
+ }
70
+
71
+ table_arr.each {|table|
72
+ if(excltable_arr.include?(table))
73
+ realexclude_list << table
74
+ else
75
+ substr_arr.each {|substr|
76
+ if(table[0,substr.length] == substr)
77
+ realexclude_list << table
78
+ end
79
+ }
80
+ end
81
+ }
82
+
83
+ table_exclude_list = realexclude_list.uniq
84
+
85
+ execute "cd #{fetch(:deploy_to)}/current && " + DT3MySQL::dump_db_version(table_exclude_list)
86
+ end
87
+ end
88
+
89
+ desc 'import one of the sql image into the current database'
90
+ task :import do
91
+
92
+ images_arr = DT3MySQL::db_image_list
93
+ print DT3Div::hashlist_to_table_string(images_arr)
94
+
95
+ print "\nEnter the index of the image you want to import from the list above: "
96
+
97
+ imageChoosen = STDIN.gets.chomp
98
+ if imageChoosen=~ /^[0-9]+$/
99
+ imageChoosen = imageChoosen.to_i-1
100
+ if images_arr[(imageChoosen)].nil?
101
+ print "ERR. You must enter an existing index from above."
102
+ else
103
+ print "\nImporting database #{images_arr[imageChoosen]['filename']}\n"
104
+
105
+ on roles(:all) do
106
+ execute "cd #{fetch(:deploy_to)}/current && " + DT3MySQL.mysql_import(images_arr[imageChoosen]['filename'])
107
+ end
108
+
109
+ end
110
+ else
111
+ print "ERR. You must enter a number"
112
+ end
113
+ end
114
+
115
+ desc 'delete all tables'
116
+ task :flush do
117
+ print "Flush tables in DB? Enter YES to confirm: "
118
+ cleanConfirm = STDIN.gets.chomp
119
+ if(cleanConfirm.downcase=='yes')
120
+ on roles(:all) do
121
+ tablelist = capture "#{DT3MySQL.create_mysql_base_command} -e \"show tables\" | grep -v Tables_in | grep -v \"+\""
122
+ dropsql = ''
123
+ tablelist.split("\n").each {|table|
124
+ dropsql +="drop table #{table};"
125
+ }
126
+ execute DT3MySQL::mysql_execute(dropsql)
127
+
128
+ end
129
+ end
130
+ end
131
+
132
+ end
@@ -6,9 +6,14 @@ require "capistrano/typo3/dt3_div"
6
6
  require "capistrano/typo3/dt3_mysql"
7
7
  require 'yaml' # Built in, no gem required
8
8
 
9
+
10
+
11
+ TYPO3_DB_DUMP_DIR = 'db_dumps'
12
+
9
13
  load File.expand_path('../tasks/typo3.cap', __FILE__)
10
14
  load File.expand_path('../tasks/deploy.cap', __FILE__)
11
15
  load File.expand_path('../tasks/git.cap', __FILE__)
16
+ load File.expand_path('../tasks/db.cap', __FILE__)
12
17
 
13
18
 
14
19
 
@@ -9,13 +9,12 @@ class DT3MySQL
9
9
  end
10
10
 
11
11
  def self.flush_tables
12
- tablelist = `#{self.create_mysql_base_command} -e "show tables" | grep -v Tables_in | grep -v "+"`
12
+ tablelist = `#{self.create_mysql_base_command} -e "show tables" | grep -v Tables_in | grep -v "+"`
13
13
  dropsql = ''
14
14
  tablelist.split("\n").each {|table|
15
15
  dropsql +="drop table #{table};"
16
16
  }
17
17
  self.mysql_execute(dropsql)
18
- return true
19
18
  end
20
19
 
21
20
  def self.show_tables
@@ -31,48 +30,6 @@ class DT3MySQL
31
30
  return cmd
32
31
  end
33
32
 
34
- def self.test_connection
35
- stdout = self.mysql_execute('SHOW TABLES;')
36
- if stdout.include? 'denied'
37
- return false
38
- else
39
- return 1
40
- end
41
- end
42
-
43
- def self.dump_db_version(name=nil, table_exclude_list=nil)
44
-
45
- if not File.directory?(TYPO3_DB_DUMP_DIR)
46
- FileUtils.mkdir TYPO3_DB_DUMP_DIR
47
- end
48
-
49
- filename =''
50
- numbers = []
51
- dbsettings = Typo3Helper::get_db_settings
52
-
53
- if name
54
- filename = File.join(TYPO3_DB_DUMP_DIR,"#{dbsettings['name']}-#{ENV['name']}.sql")
55
- version = name
56
- else
57
- Dir.foreach(TYPO3_DB_DUMP_DIR) {|sql|
58
- tmpname = sql.split('.')
59
- if(tmpname.count == 3)
60
- numbers << tmpname[1].to_i
61
- end
62
- }
63
- if(numbers.count > 0)
64
- version = (numbers.max + 1)
65
- else
66
- version = 1
67
- end
68
-
69
- filename = File.join(TYPO3_DB_DUMP_DIR,"#{dbsettings['name']}.#{version.to_s}.sql")
70
- end
71
-
72
- print "new image:#{dbsettings['name']} version:#{version}\n"
73
- DT3MySQL::mysqldump_to(filename,table_exclude_list)
74
- end
75
-
76
33
  def self.db_image_list
77
34
  images_arr = []
78
35
  idx = 0
@@ -96,7 +53,7 @@ class DT3MySQL
96
53
  image['version'] = '[MASTER]'
97
54
  image['name'] = File.basename(sql,'.*')
98
55
  end
99
- image['time'] = File.mtime(sql).strftime("%Y-%m-%d")
56
+ image['time'] = File.mtime(sql).strftime("%Y-%m-%d %H:%M")
100
57
  image['filename'] = sql
101
58
 
102
59
  images_arr << image
@@ -105,42 +62,29 @@ class DT3MySQL
105
62
  return images_arr
106
63
  end
107
64
 
108
- def self.create_exclude_list
65
+ def self.dump_db_version(table_exclude_list=nil)
109
66
 
110
- table_exclude_list = %w( be_users be_sessions cache_* cf_* fe_session_data fe_sessions static_countries \
111
- static_country_zones static_currencies static_languages static_territories sys_history sys_log tx_devlog \
112
- zzz_deleted_* )
113
-
114
- tables = self.show_tables
115
- table_arr = tables.split("\n")
116
-
117
- substr_arr = []
118
- excltable_arr = []
119
- realexclude_list = []
120
-
121
- table_exclude_list.each {|excltable|
122
- if(excltable.include? '*')
123
- substr_arr << excltable[0,excltable.index('*')]
124
- else
125
- excltable_arr << excltable
126
- end
127
- }
67
+ filename =''
68
+ numbers = []
128
69
 
129
- table_arr.each {|table|
130
- if(excltable_arr.include?(table))
131
- realexclude_list << table
132
- else
133
- substr_arr.each {|substr|
134
- if(table[0,substr.length] == substr)
135
- realexclude_list << table
136
- end
137
- }
70
+ Dir.foreach(TYPO3_DB_DUMP_DIR) {|sql|
71
+ tmpname = sql.split('.')
72
+ if(tmpname.count == 3)
73
+ numbers << tmpname[1].to_i
138
74
  end
139
75
  }
76
+ if(numbers.count > 0)
77
+ version = (numbers.max + 1)
78
+ else
79
+ version = 1
80
+ end
140
81
 
141
- return realexclude_list.uniq
82
+ filename = File.join(TYPO3_DB_DUMP_DIR,"#{fetch(:dbname)}-#{fetch(:branch)}.#{version.to_s}.sql")
83
+ print "new image:#{fetch(:dbname)} version:#{version}\n"
84
+ DT3MySQL::mysqldump_to(filename,table_exclude_list)
142
85
  end
143
86
 
87
+
144
88
  def self.create_mysql_base_command(exec='mysql')
145
89
  return self.create_mysql_base_command_with(fetch(:dbuser),fetch(:dbhost),fetch(:dbpass),fetch(:dbname),exec)
146
90
  end
@@ -149,13 +93,13 @@ class DT3MySQL
149
93
  "#{self.create_mysql_base_command} -e \"#{sql}\""
150
94
  end
151
95
 
152
- def self.create_exclude_string(excludelist,db)
96
+ def self.create_exclude_string(excludelist)
153
97
  s = ''
154
98
  excludelist.each {|extab|
155
99
  if(s.length>0)
156
100
  s += " "
157
101
  end
158
- s += "--ignore-table=#{db}.#{extab}"
102
+ s += "--ignore-table=#{fetch(:dbname)}.#{extab}"
159
103
  }
160
104
  return s
161
105
  end
@@ -163,17 +107,15 @@ class DT3MySQL
163
107
  def self.mysqldump_to(outputfile,excludelist=nil,no_schema=nil)
164
108
 
165
109
  if(not excludelist.nil?)
166
- excludestring = self.create_exclude_string(excludelist,db)
110
+ excludestring = self.create_exclude_string(excludelist)
167
111
  else
168
112
  excludestring = ''
169
113
  end
170
114
 
171
- cmd="#{create_mysql_base_command('mysqldump')} #{excludestring} > #{outputfile}"
172
- system(cmd)
115
+ "#{create_mysql_base_command('mysqldump')} #{excludestring} > #{outputfile}"
173
116
  end
174
117
 
175
- def self.mysql_import(user,pass,host,db,insqlfile)
176
- cmd ="#{create_mysql_base_command} < #{insqlfile}"
177
- system(cmd)
118
+ def self.mysql_import(insqlfile)
119
+ "#{create_mysql_base_command} < #{insqlfile}"
178
120
  end
179
121
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Typo3
3
- VERSION = "0.4.7"
3
+ VERSION = "0.4.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-typo3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pim Snel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-17 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: text-table
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1'
55
69
  description: Capistrano 3 deployment and continious delivery tasks for TYPO3 versions
56
70
  6.2+, 7.x, 8.x
57
71
  email:
@@ -73,6 +87,7 @@ files:
73
87
  - homestead_files/Vagrantfile
74
88
  - homestead_files/homestead.rb
75
89
  - homestead_files/vagrant.yml
90
+ - lib/capistrano/tasks/db.cap
76
91
  - lib/capistrano/tasks/deploy.cap
77
92
  - lib/capistrano/tasks/git.cap
78
93
  - lib/capistrano/tasks/typo3.cap