swiftly 4.0.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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +2 -0
  4. data/Dropbox/Development/www/Swiftlyfile +8 -0
  5. data/Gemfile +3 -0
  6. data/bin/swiftly +15 -0
  7. data/lib/swiftly/Rakefile +38 -0
  8. data/lib/swiftly/app_module.rb +320 -0
  9. data/lib/swiftly/clean.rb +33 -0
  10. data/lib/swiftly/cli.rb +36 -0
  11. data/lib/swiftly/config.rb +131 -0
  12. data/lib/swiftly/config_global_generator.rb +35 -0
  13. data/lib/swiftly/config_plugins_generator.rb +33 -0
  14. data/lib/swiftly/config_project_generator.rb +32 -0
  15. data/lib/swiftly/config_swiftlyfile_generator.rb +34 -0
  16. data/lib/swiftly/config_templates_generator.rb +33 -0
  17. data/lib/swiftly/configure.rb +27 -0
  18. data/lib/swiftly/configure_all.rb +181 -0
  19. data/lib/swiftly/configure_local.rb +34 -0
  20. data/lib/swiftly/configure_production.rb +42 -0
  21. data/lib/swiftly/configure_staging.rb +41 -0
  22. data/lib/swiftly/create.rb +94 -0
  23. data/lib/swiftly/create_git.rb +40 -0
  24. data/lib/swiftly/create_project.rb +67 -0
  25. data/lib/swiftly/create_wordpress.rb +185 -0
  26. data/lib/swiftly/database.rb +213 -0
  27. data/lib/swiftly/destroy.rb +53 -0
  28. data/lib/swiftly/enable.rb +13 -0
  29. data/lib/swiftly/enable_wordpress.rb +22 -0
  30. data/lib/swiftly/generate.rb +23 -0
  31. data/lib/swiftly/generate_post_type.rb +50 -0
  32. data/lib/swiftly/init.rb +130 -0
  33. data/lib/swiftly/packages.rb +137 -0
  34. data/lib/swiftly/project.rb +127 -0
  35. data/lib/swiftly/pull.rb +25 -0
  36. data/lib/swiftly/push.rb +60 -0
  37. data/lib/swiftly/rollback.rb +78 -0
  38. data/lib/swiftly/setup.rb +34 -0
  39. data/lib/swiftly/ssh.rb +36 -0
  40. data/lib/swiftly/templates/config_global.erb +3 -0
  41. data/lib/swiftly/templates/config_project.erb +11 -0
  42. data/lib/swiftly/templates/gitignore.erb +7 -0
  43. data/lib/swiftly/templates/post_type.erb +98 -0
  44. data/lib/swiftly/templates/swiftlyfile.erb +21 -0
  45. data/lib/swiftly/version.rb +4 -0
  46. data/swiftly.gemspec +61 -0
  47. data/test/test_swiftly_spec.rb +18 -0
  48. metadata +175 -0
@@ -0,0 +1,34 @@
1
+ require "thor/group"
2
+
3
+ module Swiftly
4
+ class ConfigSwiftlyfileGenerator < Thor::Group
5
+
6
+ include Thor::Actions
7
+
8
+ argument :db_host
9
+ argument :db_user
10
+ argument :db_pass
11
+
12
+ desc "Handles the creation of the _templates file."
13
+
14
+ def self.source_root
15
+ File.dirname(__FILE__)
16
+ end
17
+
18
+ def create
19
+
20
+ settings = Swiftly::Config.load :global
21
+
22
+ template(
23
+ File.join(
24
+ 'templates',
25
+ 'swiftlyfile.erb'
26
+ ),
27
+ File.join(
28
+ settings[:sites_path],
29
+ 'Swiftlyfile',
30
+ )
31
+ )
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,33 @@
1
+ require "thor/group"
2
+
3
+ module Swiftly
4
+ class ConfigTemplateGenerator < Thor::Group
5
+
6
+ include Thor::Actions
7
+
8
+ desc "Handles the creation of the _templates file."
9
+
10
+ def self.source_root
11
+ File.dirname(__FILE__)
12
+ end
13
+
14
+ def create
15
+
16
+ settings = Swiftly::Config.load :global
17
+
18
+ template(
19
+ File.join(
20
+ 'templates',
21
+ 'config_templates.erb'
22
+ ),
23
+ File.join(
24
+ settings[:sites_path],
25
+ 'config',
26
+ 'templates',
27
+ '_templates.yml'
28
+ )
29
+ )
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,27 @@
1
+ require 'yaml'
2
+ require 'swiftly/configure_all'
3
+ require 'swiftly/configure_local'
4
+ require 'swiftly/configure_staging'
5
+ require 'swiftly/configure_production'
6
+ require 'swiftly/app_module'
7
+
8
+ module Swiftly
9
+ class Configure < Thor
10
+
11
+ include Thor::Actions
12
+ include Helpers
13
+
14
+ desc "local [COMMAND]", "Configure local settings"
15
+ subcommand "local", Local
16
+
17
+ desc "staging [COMMAND]", "configure staging settings"
18
+ subcommand "staging", Staging
19
+
20
+ desc "production [COMMAND]", "configure production settings"
21
+ subcommand "production", Production
22
+
23
+ desc "all", "Configure all"
24
+ subcommand "all", All
25
+
26
+ end
27
+ end
@@ -0,0 +1,181 @@
1
+ require 'yaml'
2
+ require 'swiftly/app_module'
3
+ require 'swiftly/configure'
4
+
5
+ module Swiftly
6
+ class All < Thor
7
+
8
+ include Helpers
9
+
10
+ desc "all", "Configure all"
11
+
12
+ def all()
13
+
14
+ say # spacer
15
+
16
+ say "\t\t#{APP_NAME} #{VERSION} Development Manager\n\n", :blue
17
+
18
+ say_status "#{APP_NAME}:", "Thanks for trying out #{APP_NAME}. Lets get started!", :green
19
+
20
+ current = Swiftly::Config.load :global
21
+
22
+ global_settings = {
23
+ version: VERSION,
24
+ sites_path: current[:sites_path].nil? ? 'not set' : current[:sites_path],
25
+ }
26
+
27
+ swiftly_settings = {
28
+ local: {
29
+ db_host: current[:local][:db_host].nil? ? 'not set' : current[:local][:db_host],
30
+ db_user: current[:local][:db_user].nil? ? 'not set' : current[:local][:db_user],
31
+ db_pass: current[:local][:db_pass].nil? ? 'not set' : current[:local][:db_pass]
32
+ },
33
+ staging: {
34
+ domain: current[:staging][:domain].nil? ? 'not set' : current[:staging][:domain],
35
+ db_host: current[:staging][:db_host].nil? ? 'not set' : current[:staging][:db_host],
36
+ db_user: current[:staging][:db_user].nil? ? 'not set' : current[:staging][:db_user],
37
+ db_pass: current[:staging][:db_pass].nil? ? 'not set' : current[:staging][:db_pass]
38
+ },
39
+ production: {
40
+ domain: current[:production][:domain].nil? ? 'not set' : current[:production][:domain],
41
+ db_host: current[:production][:db_host].nil? ? 'not set' : current[:production][:db_host],
42
+ db_user: current[:production][:db_user].nil? ? 'not set' : current[:production][:db_user],
43
+ db_pass: current[:production][:db_pass].nil? ? 'not set' : current[:production][:db_pass]
44
+ }
45
+ }
46
+
47
+ questions = {
48
+ sites_path: "\n\n--> What is the absolute path to the folder \n\s\s\s\swhere you keep all of your sites? Currently: (\e[0;m#{global_settings[:sites_path]}\e[33;m):",
49
+ local_db_host: "\n--> What is your local hostname? Currently: (\e[0;m#{swiftly_settings[:local][:db_host]}\e[33;m):",
50
+ local_db_user: "\n--> What is your local mysql username? Currently: (\e[0;m#{swiftly_settings[:local][:db_user]}\e[33;m):",
51
+ local_db_pass: "\n--> What is your local mysql password?",
52
+ staging_server_domain: "\n--> What is your staging server domain? Currently: (\e[0;m#{swiftly_settings[:staging][:domain]}\e[33;m):",
53
+ staging_db_host: "\n--> What is your staging server hostname? Currently: (\e[0;m#{swiftly_settings[:staging][:db_host]}\e[33;m):",
54
+ staging_db_user: "\n--> What is your staging server mysql username? Currently: (\e[0;m#{swiftly_settings[:staging][:db_user]}\e[33;m):",
55
+ staging_db_pass: "\n--> What is your staging server mysql password?",
56
+ production_server_domain: "\n--> What is your production server domain? Currently: (\e[0;m#{swiftly_settings[:production][:domain]}\e[33;m):",
57
+ production_db_host: "\n--> What is your production server hostname? Currently: (\e[0;m#{swiftly_settings[:production][:db_host]}\e[33;m):",
58
+ production_db_user: "\n--> What is your production server mysql username? Currently: (\e[0;m#{swiftly_settings[:production][:db_user]}\e[33;m):",
59
+ production_db_pass: "\n--> What is your production server mysql password?"
60
+ }
61
+
62
+ responses = ['y','Y','']
63
+
64
+ questions.each do |type, question|
65
+
66
+ confirm = false
67
+
68
+ until confirm == true do
69
+
70
+ if type === :sites_path
71
+
72
+ answer = File.expand_path( ask question, :yellow, :path => true )
73
+
74
+ elsif type === :local_db_pass ||
75
+ type === :staging_db_pass ||
76
+ type === :production_db_pass
77
+
78
+ answer = ask question, :yellow, :echo => false
79
+
80
+ else
81
+
82
+ answer = ask question, :yellow
83
+
84
+ end
85
+
86
+ if type === :sites_path && answer == ''
87
+
88
+ answer = global_settings[:sites_path]
89
+
90
+ elsif type === :local_db_pass ||
91
+ type === :staging_db_pass ||
92
+ type === :production_db_pass
93
+
94
+ password = ask "\n\n--> Please re-enter your password?", :yellow, :echo => false
95
+
96
+ say #spacer
97
+
98
+ until password == answer
99
+
100
+ say_status "#{APP_NAME}:", "Passwords did not match please try again.\n", :yellow
101
+
102
+ answer = ask question, :yellow, :echo => false
103
+
104
+ password = ask "\n--> Please re-enter your password?\n", :yellow, :echo => false
105
+
106
+ end
107
+
108
+ if password == answer
109
+
110
+ if answer == ''
111
+
112
+ answer = nil
113
+
114
+ end
115
+
116
+ confirm = true
117
+
118
+ end
119
+
120
+ elsif answer == ''
121
+
122
+ if question[/\e\[[0-9;]*[a-zA-Z](.*)\e\[[0-9;]*[a-zA-Z]/, 1] == ''
123
+
124
+ answer = nil
125
+
126
+ else
127
+
128
+ answer = question[/\e\[[0-9;]*[a-zA-Z](.*)\e\[[0-9;]*[a-zA-Z]/, 1]
129
+
130
+ end
131
+ end
132
+
133
+ unless type === :local_db_pass ||
134
+ type === :staging_db_pass ||
135
+ type === :production_db_pass
136
+
137
+ if responses.include? ask( "\n--> Got it! Is this correct? \e[32;m#{answer}\e[0;m [Y|n]")
138
+
139
+ confirm = true
140
+
141
+ end
142
+ end
143
+
144
+ end
145
+
146
+ if type === :sites_path
147
+
148
+ global_settings[type] = answer
149
+
150
+ else
151
+
152
+ split = type.to_s.split('_')
153
+ environment = split.first.to_sym
154
+ setting = split[1] + '_' + split.last
155
+
156
+ if type === :staging_server_domain ||
157
+ type === :production_server_domain
158
+
159
+ setting = split.last
160
+
161
+ end
162
+
163
+ swiftly_settings[environment][setting.to_sym] = answer
164
+
165
+ end
166
+
167
+ end
168
+
169
+ say_status "\n\s\s\s\sAll done thanks!", "From now on I will use your new settings."
170
+
171
+ File.open(Swiftly::Config.global_file,'w') do |h|
172
+
173
+ h.write swiftly_settings.to_yaml
174
+
175
+ end
176
+ end
177
+
178
+ default_task :all
179
+
180
+ end
181
+ end
@@ -0,0 +1,34 @@
1
+ require 'yaml'
2
+ require 'swiftly/app_module'
3
+ require 'swiftly/configure'
4
+
5
+ module Swiftly
6
+ class Local < Thor
7
+
8
+ include Helpers
9
+
10
+ desc "configure local host", "Configure local hostname"
11
+
12
+ def host( value = false )
13
+
14
+ update_setting_dialog( :local, :db_host, value )
15
+
16
+ end
17
+
18
+ desc "configure local username", "Configure local database username"
19
+
20
+ def username( value = false )
21
+
22
+ update_setting_dialog( :local, :db_user, value )
23
+
24
+ end
25
+
26
+ desc "configure local password", "Configure local database password"
27
+
28
+ def password( value = false )
29
+
30
+ update_setting_dialog( :local, :db_pass, value )
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,42 @@
1
+ require 'yaml'
2
+ require 'swiftly/app_module'
3
+ require 'swiftly/configure'
4
+
5
+ module Swiftly
6
+ class Production < Thor
7
+
8
+ include Helpers
9
+
10
+ desc "configure production domain", "Configure production domain"
11
+
12
+ def domain( value = false )
13
+
14
+ update_setting_dialog( :production, :domain, value )
15
+
16
+ end
17
+
18
+ desc "configure production host", "Configure production hostname"
19
+
20
+ def host( value = false )
21
+
22
+ update_setting_dialog( :production, :db_host, value )
23
+
24
+ end
25
+
26
+ desc "configure production username", "Configure production database username"
27
+
28
+ def username( value = false )
29
+
30
+ update_setting_dialog( :production, :db_user, value )
31
+
32
+ end
33
+
34
+ desc "configure production password", "Configure production database password"
35
+
36
+ def password( value = false )
37
+
38
+ update_setting_dialog( :production, :db_pass, value )
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,41 @@
1
+ require 'yaml'
2
+ require 'swiftly/app_module'
3
+
4
+ module Swiftly
5
+ class Staging < Thor
6
+
7
+ include Helpers
8
+
9
+ desc "configure staging domain", "Configure staging domain"
10
+
11
+ def domain( value = false )
12
+
13
+ update_setting_dialog( :staging, :domain, value)
14
+
15
+ end
16
+
17
+ desc "configure staging host", "Configure staging hostname"
18
+
19
+ def host( hostname = false )
20
+
21
+ update_setting_dialog( :staging, :db_host, value)
22
+
23
+ end
24
+
25
+ desc "configure staging username", "Configure staging database username"
26
+
27
+ def username( username = false )
28
+
29
+ update_setting_dialog( :staging, :db_user, value)
30
+
31
+ end
32
+
33
+ desc "configure staging password", "Configure staging database password"
34
+
35
+ def password( password = false )
36
+
37
+ update_setting_dialog( :staging, :db_pass, value)
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,94 @@
1
+ require 'fileutils'
2
+ require 'zip'
3
+ require 'swiftly/project'
4
+ require 'swiftly/database'
5
+ require 'swiftly/app_module'
6
+ require 'swiftly/create_project'
7
+ require 'swiftly/create_git'
8
+ require 'swiftly/create_wordpress'
9
+
10
+ module Swiftly
11
+ class Create < Thor
12
+
13
+ include Helpers
14
+
15
+ desc "create project PROJECT_NAME", "Create a create project"
16
+
17
+ def project( project_name )
18
+
19
+ project_path = File.join(
20
+ Swiftly::Config.load( :global )[:sites_path],
21
+ project_name
22
+ )
23
+
24
+ CreateProject.new([
25
+ project_name,
26
+ project_path
27
+ ]).invoke_all
28
+
29
+ end
30
+
31
+ desc "create git PROJECT_NAME", "Create a create git enabled project"
32
+
33
+ def git( project_name )
34
+
35
+ settings = Swiftly::Config.load :global
36
+
37
+ project_path = File.join(
38
+ settings[:sites_path],
39
+ project_name
40
+ )
41
+
42
+ CreateProject.new( [
43
+ project_name,
44
+ project_path
45
+ ] ).invoke_all
46
+
47
+ CreateGit.new([
48
+ project_path
49
+ ]).invoke_all
50
+
51
+ end
52
+
53
+ desc "create git PROJECT_NAME", "Create a create wordpress (git enabled) project"
54
+ method_option :template, aliases: '-t', type: :string, default: :default, desc: 'Provide the name of the template to use'
55
+
56
+
57
+ def wordpress project_name
58
+
59
+ global_settings = Swiftly::Config.load :global
60
+ project_settings = Swiftly::Config.load :swiftly
61
+
62
+ template = Swiftly::Packages.load({
63
+ framework: :wordpress,
64
+ type: :template,
65
+ name: options[:template]
66
+ })
67
+
68
+ project_path = File.join(
69
+ global_settings[:sites_path],
70
+ project_name
71
+ )
72
+
73
+ CreateProject.new([
74
+ project_name,
75
+ project_path
76
+ ]).invoke_all
77
+
78
+ CreateWordpress.new([
79
+ project_name,
80
+ template,
81
+ project_settings,
82
+ project_path
83
+ ]).invoke_all
84
+
85
+ CreateGit.new([
86
+ project_path
87
+ ]).invoke_all
88
+
89
+ end
90
+ end
91
+ end
92
+
93
+
94
+
@@ -0,0 +1,40 @@
1
+ require "thor/group"
2
+ require 'rubygems'
3
+ require 'active_support'
4
+ require 'active_support/core_ext/string'
5
+ require 'git'
6
+
7
+ module Swiftly
8
+ class CreateGit < Thor::Group
9
+
10
+ include Thor::Actions
11
+
12
+ argument :project_path
13
+
14
+ desc "Handles the creation of a git project."
15
+
16
+ def self.source_root
17
+
18
+ File.dirname(__FILE__)
19
+
20
+ end
21
+
22
+ def create_git()
23
+
24
+ git = Git.init( @project_path )
25
+
26
+ template(
27
+ File.join(
28
+ 'templates',
29
+ 'gitignore.erb'
30
+ ),
31
+ File.join( @project_path, '.gitignore' )
32
+ ) unless File.exists? File.join( @project_path, '.gitignore' )
33
+
34
+
35
+ git.add
36
+ git.commit_all('initial commit')
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,67 @@
1
+ require "thor/group"
2
+ require 'rubygems'
3
+ require 'active_support'
4
+ require 'swiftly/project'
5
+ require 'swiftly/app_module'
6
+ require 'swiftly/config_project_generator'
7
+ require 'active_support/core_ext/string'
8
+
9
+ module Swiftly
10
+ class CreateProject < Thor::Group
11
+
12
+ include Thor::Actions
13
+ include Helpers
14
+
15
+ argument :project_name
16
+ argument :project_path
17
+
18
+ desc "Handles the creation of project files."
19
+
20
+ def self.source_root
21
+
22
+ File.dirname(__FILE__)
23
+
24
+ end
25
+
26
+ def no_commands
27
+
28
+ def allow_project_creation
29
+
30
+ if Swiftly::Project.exists?(@project_name)
31
+
32
+ say #spacer
33
+ say_status "#{APP_NAME}:", "There is already a project named #{@project_path}", :red
34
+ abort
35
+
36
+ end
37
+ end
38
+ end
39
+
40
+ def create_assets()
41
+
42
+ allow_project_creation
43
+
44
+ ['architecture', 'doc', 'emails', 'fonts', 'images', 'raster', 'vector'].each do |path|
45
+
46
+ empty_directory( File.join( @project_path ,"_resources", "assets", path ) )
47
+
48
+ end
49
+ end
50
+
51
+ def create_dump_directories
52
+
53
+ ['local','production','staging','temp'].each do |path|
54
+
55
+ empty_directory( File.join( @project_path , "_backups", "dumps", path ) )
56
+
57
+ end
58
+
59
+ end
60
+
61
+ def create_project_config
62
+
63
+ ConfigProjectGenerator.new.create(@project_path)
64
+
65
+ end
66
+ end
67
+ end