capistrano-craft 0.1.4 → 0.2.0

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
- SHA1:
3
- metadata.gz: 4b39c1f2e7079239d641d0901b6d96987e1476dc
4
- data.tar.gz: 43ab2d884852edda936c18db39a15ac723e097e3
2
+ SHA256:
3
+ metadata.gz: fceeba041e1f430d60d18f014f8f5f17688a0bed40e0c162286ecd76a5b56b84
4
+ data.tar.gz: 0fc17f5c3ff63a0199cdaf5d44834824397fe19a128478aea2e93484fe4c2be5
5
5
  SHA512:
6
- metadata.gz: 6ee4649ff1d73b28364b369ca1a78b93eed8af5dee426befe1cfc574b48065d08915fb93ec2018e03045b2f7e1526376934acfaf5fb5b7d85998a52fc9f9c6cb
7
- data.tar.gz: a8c6e723374e2bf626d4f3c14c4aa43d4848625b904be564210488f49a627184e818c8bf6b53fdb8691cba493e77becfa5763f40c7cc52310cdcdd2c0123f6b6
6
+ metadata.gz: a3046e543a9900d4476eba382e240df0a95a725ccce70432685f7fae494f2fe459666863599c719dcbba65f898a54b9ea909967fd82024d041eee3c4519d43d9
7
+ data.tar.gz: 501bf426899abe035c403c1e69d35a00715e3f574211a74ca155ddb1cdfe92c90c0a96178448bc9d411758421c6a72b18f89c71d194e3a80789654c6e71a654f
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in capitrano-craft.gemspec
4
4
  gemspec
5
+
6
+ gem "rspec"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-craft (0.1.4)
4
+ capistrano-craft (0.2.0)
5
5
  capistrano (~> 3.1)
6
6
  capistrano-composer (~> 0.0.6)
7
7
 
@@ -10,7 +10,7 @@ GEM
10
10
  specs:
11
11
  airbrussh (1.4.0)
12
12
  sshkit (>= 1.6.1, != 1.7.0)
13
- capistrano (3.11.2)
13
+ capistrano (3.12.0)
14
14
  airbrussh (>= 1.0.0)
15
15
  i18n
16
16
  rake (>= 10.0.0)
@@ -18,12 +18,26 @@ GEM
18
18
  capistrano-composer (0.0.6)
19
19
  capistrano (>= 3.0.0.pre)
20
20
  concurrent-ruby (1.1.5)
21
- i18n (1.7.0)
21
+ diff-lcs (1.3)
22
+ i18n (1.8.2)
22
23
  concurrent-ruby (~> 1.0)
23
24
  net-scp (2.0.0)
24
25
  net-ssh (>= 2.6.5, < 6.0.0)
25
26
  net-ssh (5.2.0)
26
- rake (13.0.0)
27
+ rake (13.0.1)
28
+ rspec (3.9.0)
29
+ rspec-core (~> 3.9.0)
30
+ rspec-expectations (~> 3.9.0)
31
+ rspec-mocks (~> 3.9.0)
32
+ rspec-core (3.9.1)
33
+ rspec-support (~> 3.9.1)
34
+ rspec-expectations (3.9.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.9.0)
37
+ rspec-mocks (3.9.1)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.9.0)
40
+ rspec-support (3.9.2)
27
41
  sshkit (1.20.0)
28
42
  net-scp (>= 1.1.2)
29
43
  net-ssh (>= 2.8.0)
@@ -33,6 +47,7 @@ PLATFORMS
33
47
 
34
48
  DEPENDENCIES
35
49
  capistrano-craft!
50
+ rspec
36
51
 
37
52
  BUNDLED WITH
38
53
  2.0.2
@@ -17,7 +17,8 @@ set :craft_local_backups, "backups"
17
17
  set :craft_remote_backups, "shared/backups"
18
18
 
19
19
  # assets
20
- set :craft_compile_assets, "production"
20
+ set :craft_compile_assets, true
21
+ set :craft_compile_assets_command, "yarn install && yarn run production"
21
22
 
22
23
  # console
23
24
  set :craft_console_path, -> { "craft" }
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Craft
3
- VERSION = "0.1.4"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -47,55 +47,88 @@ module Capistrano
47
47
  File.join(fetch(:craft_local_backups), "#{backup_date.join('-')}_#{backup_time.join('-')}.sql")
48
48
  end
49
49
 
50
- def postgres_dump(env, output)
50
+ def postgres_dump(env, config, output)
51
51
  execute SSHKit::Command.new <<-EOCOMMAND
52
52
  source "#{env}"
53
- PGPASSWORD=$DB_PASSWORD pg_dump -U $DB_USER -h $DB_SERVER -p $DB_PORT -F p --no-owner $DB_DATABASE > #{output}
53
+ PGPASSWORD=$DB_PASSWORD pg_dump -U $DB_USER -h #{config[:host]} -p #{config[:port]} -F p --no-owner #{config[:database]} > #{output}
54
54
  EOCOMMAND
55
55
  end
56
56
 
57
57
  def mysql_dump(env, output)
58
58
  end
59
59
 
60
- def postgres_restore(env, input)
60
+ def postgres_restore(env, config, input)
61
61
  execute SSHKit::Command.new <<-EOCOMMAND
62
62
  source "#{env}"
63
- PGPASSWORD=$DB_PASSWORD dropdb -U $DB_USER -h $DB_SERVER -p $DB_PORT $DB_DATABASE
64
- PGPASSWORD=$DB_PASSWORD createdb -U $DB_USER -h $DB_SERVER -p $DB_PORT $DB_DATABASE
65
- PGPASSWORD=$DB_PASSWORD psql -U $DB_USER -d $DB_DATABASE -h $DB_SERVER -p $DB_PORT -q < "#{input}"
63
+ PGPASSWORD=$DB_PASSWORD dropdb -U $DB_USER -h #{config[:host]} -p #{config[:port]} #{config[:database]}
64
+ PGPASSWORD=$DB_PASSWORD createdb -U $DB_USER -h #{config[:host]} -p #{config[:port]} #{config[:database]}
65
+ PGPASSWORD=$DB_PASSWORD psql -U $DB_USER -d #{config[:database]} -h #{config[:host]} -p #{config[:port]} -q < "#{input}"
66
66
  EOCOMMAND
67
67
  end
68
68
 
69
69
  def mysql_restore(env, input)
70
70
  end
71
71
 
72
- def craft_database(env)
73
- driver = capture SSHKit::Command.new <<-EOCOMMAND
72
+ def database_config(env)
73
+ config = capture SSHKit::Command.new <<-EOCOMMAND
74
74
  source "#{env}"
75
- echo $DB_DRIVER
75
+ echo "$DB_DSN,$DB_DRIVER,$DB_SERVER,$DB_PORT,$DB_DATABASE"
76
76
  EOCOMMAND
77
77
 
78
- case driver.strip
79
- when "pgsql" then return :pgsql
80
- when "mysql" then return :mysql
78
+ params = config.split(",")
79
+ parsed = {}
80
+
81
+ if params[0].length > 0
82
+ # Using the newer style DB_DSN config style
83
+ dsn = params[0].split(":")
84
+
85
+ # Split in config chunks eg. host=<host>
86
+ database = dsn[1].split(";").map { |str|
87
+ tuple = str.split("=")
88
+ [tuple[0], tuple[1]]
89
+ }.to_h
90
+
91
+ parsed = {
92
+ driver: dsn[0],
93
+ host: database["host"],
94
+ port: database["port"],
95
+ database: database["dbname"]
96
+ }
81
97
  else
82
- raise "Unable to determine database driver: \"#{driver.strip}\""
98
+ # Using the older style config style
99
+ parsed = {
100
+ driver: params[1],
101
+ host: params[2],
102
+ port: params[3],
103
+ database: params[4]
104
+ }
83
105
  end
106
+
107
+ case parsed[:driver].strip
108
+ when "pgsql" then parsed[:driver] = :pgsql
109
+ when "mysql" then parsed[:driver] = :mysql
110
+ else
111
+ raise "Unable to determine database driver: \"#{parsed[:driver].strip}\""
112
+ end
113
+
114
+ return parsed
84
115
  end
85
116
 
86
117
  def database_dump(env, input)
87
- if craft_database(env) == :pgsql
88
- postgres_dump(env, input)
118
+ config = database_config(env)
119
+ if config[:driver] == :pgsql
120
+ postgres_dump(env, config, input)
89
121
  else
90
- mysql_dump(env, input)
122
+ mysql_dump(env, config, input)
91
123
  end
92
124
  end
93
125
 
94
126
  def database_restore(env, input)
95
- if craft_database(env) == :pgsql
96
- postgres_restore(env, input)
127
+ config = database_config(env)
128
+ if config[:driver] == :pgsql
129
+ postgres_restore(env, config, input)
97
130
  else
98
- mysql_restore(env, input)
131
+ mysql_restore(env, config, input)
99
132
  end
100
133
  end
101
134
  end
@@ -5,10 +5,11 @@ namespace :deploy do
5
5
 
6
6
  desc 'Compile assets'
7
7
  task :compile_assets do
8
- on release_roles(fetch(:craft_deploy_roles)) do
9
- within release_path do
10
- execute :yarn, "install"
11
- execute :yarn, "run", fetch(:craft_compile_assets)
8
+ if fetch(:craft_compile_assets)
9
+ on release_roles(fetch(:craft_deploy_roles)) do
10
+ within release_path do
11
+ execute fetch(:craft_compile_assets_command)
12
+ end
12
13
  end
13
14
  end
14
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-craft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Dyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-13 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
+ - ".rspec"
49
50
  - CODE_OF_CONDUCT.md
50
51
  - Gemfile
51
52
  - Gemfile.lock
@@ -82,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  - !ruby/object:Gem::Version
83
84
  version: '0'
84
85
  requirements: []
85
- rubyforge_project:
86
- rubygems_version: 2.6.14.3
86
+ rubygems_version: 3.0.3
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Capistrano Craft - Easy deployment of Symfony 4 apps with Ruby over SSH