theme-juice 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +216 -204
  3. data/bin/tj +15 -15
  4. data/lib/theme-juice.rb +46 -46
  5. data/lib/theme-juice/cli.rb +248 -248
  6. data/lib/theme-juice/command.rb +20 -20
  7. data/lib/theme-juice/commands/create.rb +220 -221
  8. data/lib/theme-juice/commands/delete.rb +51 -51
  9. data/lib/theme-juice/commands/deploy.rb +20 -20
  10. data/lib/theme-juice/config.rb +68 -68
  11. data/lib/theme-juice/env.rb +25 -25
  12. data/lib/theme-juice/io.rb +295 -323
  13. data/lib/theme-juice/project.rb +35 -35
  14. data/lib/theme-juice/task.rb +43 -42
  15. data/lib/theme-juice/tasks/create_confirm.rb +33 -33
  16. data/lib/theme-juice/tasks/create_success.rb +42 -42
  17. data/lib/theme-juice/tasks/database.rb +50 -50
  18. data/lib/theme-juice/tasks/delete_confirm.rb +24 -24
  19. data/lib/theme-juice/tasks/delete_success.rb +31 -31
  20. data/lib/theme-juice/tasks/dns.rb +45 -45
  21. data/lib/theme-juice/tasks/dot_env.rb +53 -53
  22. data/lib/theme-juice/tasks/entry.rb +50 -50
  23. data/lib/theme-juice/tasks/hosts.rb +43 -43
  24. data/lib/theme-juice/tasks/import_database.rb +28 -28
  25. data/lib/theme-juice/tasks/landrush.rb +33 -33
  26. data/lib/theme-juice/tasks/list.rb +50 -50
  27. data/lib/theme-juice/tasks/location.rb +23 -23
  28. data/lib/theme-juice/tasks/nginx.rb +51 -51
  29. data/lib/theme-juice/tasks/repo.rb +49 -49
  30. data/lib/theme-juice/tasks/synced_folder.rb +30 -30
  31. data/lib/theme-juice/tasks/theme.rb +34 -34
  32. data/lib/theme-juice/tasks/vm.rb +30 -30
  33. data/lib/theme-juice/tasks/vm_customfile.rb +42 -42
  34. data/lib/theme-juice/tasks/vm_location.rb +32 -32
  35. data/lib/theme-juice/tasks/vm_plugins.rb +32 -32
  36. data/lib/theme-juice/tasks/vm_provision.rb +39 -39
  37. data/lib/theme-juice/tasks/vm_restart.rb +25 -25
  38. data/lib/theme-juice/tasks/wp_cli.rb +52 -52
  39. data/lib/theme-juice/util.rb +45 -45
  40. data/lib/theme-juice/version.rb +5 -5
  41. metadata +63 -6
@@ -1,20 +1,20 @@
1
- # encoding: UTF-8
2
-
3
- module ThemeJuice
4
- class Command < Task
5
-
6
- def initialize(opts = {})
7
- super
8
-
9
- @list = Tasks::List.new
10
- end
11
-
12
- def execute
13
- @tasks.each { |task| task.execute }
14
- end
15
-
16
- def unexecute
17
- @tasks.each { |task| task.unexecute }
18
- end
19
- end
20
- end
1
+ # encoding: UTF-8
2
+
3
+ module ThemeJuice
4
+ class Command < Task
5
+
6
+ def initialize(opts = {})
7
+ super
8
+
9
+ @list = Tasks::List.new
10
+ end
11
+
12
+ def execute
13
+ @tasks.each { |task| task.execute }
14
+ end
15
+
16
+ def unexecute
17
+ @tasks.each { |task| task.unexecute }
18
+ end
19
+ end
20
+ end
@@ -1,221 +1,220 @@
1
- # encoding: UTF-8
2
-
3
- module ThemeJuice
4
- module Commands
5
- class Create < Command
6
-
7
- def initialize(opts = {})
8
- super
9
-
10
- @project.use_defaults = @opts.fetch("use_defaults", false)
11
- @project.bare = @opts.fetch("bare", false)
12
- @project.skip_repo = @opts.fetch("skip_repo", false)
13
- @project.skip_db = @opts.fetch("skip_db", false)
14
- @project.no_wp = @opts.fetch("no_wp", false)
15
- @project.no_db = @opts.fetch("no_db", false)
16
- @project.name = @opts.fetch("name") { name }
17
- @project.location = @opts.fetch("location") { location }
18
- @project.url = @opts.fetch("url") { url }
19
- @project.theme = @opts.fetch("theme") { theme }
20
- @project.repository = @opts.fetch("repository") { repository }
21
- @project.db_host = @opts.fetch("db_host") { db_host }
22
- @project.db_name = @opts.fetch("db_name") { db_name }
23
- @project.db_user = @opts.fetch("db_user") { db_user }
24
- @project.db_pass = @opts.fetch("db_pass") { db_pass }
25
- @project.db_import = @opts.fetch("db_import") { db_import }
26
- @project.vm_root = vm_root
27
- @project.vm_location = vm_location
28
- @project.vm_srv = vm_srv
29
-
30
- runner do |tasks|
31
- tasks << Tasks::CreateConfirm.new
32
- tasks << Tasks::Location.new
33
- tasks << Tasks::Theme.new
34
- tasks << Tasks::VM.new
35
- tasks << Tasks::VMPlugins.new
36
- tasks << Tasks::VMLocation.new
37
- tasks << Tasks::VMCustomfile.new
38
- tasks << Tasks::Hosts.new
39
- tasks << Tasks::Database.new
40
- tasks << Tasks::Nginx.new
41
- tasks << Tasks::DotEnv.new
42
- tasks << Tasks::Landrush.new
43
- tasks << Tasks::SyncedFolder.new
44
- tasks << Tasks::DNS.new
45
- tasks << Tasks::WPCLI.new
46
- tasks << Tasks::Repo.new
47
- tasks << Tasks::CreateSuccess.new
48
- tasks << Tasks::ImportDatabase.new
49
- end
50
- end
51
-
52
- private
53
-
54
- def name
55
- if @env.yolo
56
- name = Faker::Internet.domain_word
57
- else
58
- name = @io.prompt "What's the project name? (letters, numbers and dashes only)"
59
- end
60
-
61
- valid_name? name
62
-
63
- name
64
- end
65
-
66
- def valid_name?(name)
67
- if name.empty?
68
- @io.error "Project name '#{name}' looks like it's empty. Aborting mission."
69
- end
70
-
71
- "#{name}".match /[^0-9A-Za-z.\-]/ do |char|
72
- @io.error "Project name contains an invalid character '#{char}'. This name is used internally for a ton of stuff, so that's not gonna work. Aborting mission."
73
- end
74
-
75
- true
76
- end
77
-
78
- def clean_name
79
- "#{@project.name}".gsub(/[^\w]/, "_")[0..10]
80
- end
81
-
82
- def location
83
- path = "#{Dir.pwd}/"
84
-
85
- if @project.use_defaults
86
- location = File.expand_path path
87
- else
88
- location = File.expand_path @io.prompt("Where do you want to setup the project?", :default => path, :path => true)
89
- end
90
-
91
- location
92
- end
93
-
94
- def url
95
- if @project.use_defaults
96
- url = "#{@project.name}.dev"
97
- else
98
- url = @io.prompt "What do you want the development url to be? (this should end in '.dev')", :default => "#{@project.name}.dev"
99
- end
100
-
101
- valid_url? url
102
-
103
- url
104
- end
105
-
106
- def valid_url?(url)
107
- unless "#{url}".match /(.dev)$/
108
- @io.error "Your development url '#{url}' doesn't end with '.dev'. This is used internally by Landrush, so that's not gonna work. Aborting mission."
109
- end
110
-
111
- true
112
- end
113
-
114
- def theme
115
- return false if @project.bare
116
-
117
- theme = nil
118
- themes = {
119
- "theme-juice/theme-juice-starter" => "https://github.com/ezekg/theme-juice-starter.git",
120
- "other" => nil,
121
- "none" => nil
122
- }
123
-
124
- if @project.use_defaults
125
- theme = themes["theme-juice/theme-juice-starter"]
126
- else
127
- choice = @io.choose "Which starter theme would you like to use?", :blue, themes.keys
128
-
129
- case choice
130
- when "theme-juice/theme-juice-starter"
131
- @io.success "Awesome choice!"
132
- when "other"
133
- themes[choice] = @io.prompt "What is the repository URL for the starter theme that you would like to clone?"
134
- when "none"
135
- @io.notice "Next time you need to create a project without a starter theme, you can just run the 'setup' command instead."
136
- @project.bare = true
137
- end
138
-
139
- theme = themes[choice]
140
- end
141
-
142
- theme
143
- end
144
-
145
- def repository
146
- return false if @project.skip_repo || @project.use_defaults
147
-
148
- if @io.agree? "Would you like to initialize a new Git repository?"
149
- repo = @io.prompt "What is the repository's remote URL?", :indent => 2
150
- else
151
- repo = false
152
- end
153
-
154
- repo
155
- end
156
-
157
- def db_host
158
- return false if @project.no_db || @project.no_wp
159
-
160
- if @project.skip_db || @project.use_defaults
161
- db_host = "vvv"
162
- else
163
- db_host = @io.prompt "Database host", :default => "vvv"
164
- end
165
-
166
- db_host
167
- end
168
-
169
- def db_name
170
- return false if @project.no_db || @project.no_wp
171
-
172
- if @project.skip_db || @project.use_defaults
173
- db_name = "#{clean_name}_db"
174
- else
175
- db_name = @io.prompt "Database name", :default => "#{clean_name}_db"
176
- end
177
-
178
- db_name
179
- end
180
-
181
- def db_user
182
- return false if @project.no_db || @project.no_wp
183
-
184
- if @project.skip_db || @project.use_defaults
185
- db_user = "#{clean_name}_user"
186
- else
187
- db_user = @io.prompt "Database username", :default => "#{clean_name}_user"
188
- end
189
-
190
- db_user
191
- end
192
-
193
- def db_pass
194
- return false if @project.no_db || @project.no_wp
195
-
196
- pass = Faker::Internet.password 24
197
-
198
- if @project.skip_db || @project.use_defaults
199
- db_pass = pass
200
- else
201
- db_pass = @io.prompt "Database password", :default => pass
202
- end
203
-
204
- db_pass
205
- end
206
-
207
- def db_import
208
- return false if @project.no_db || @project.no_wp || @project.use_defaults
209
-
210
- if @io.agree? "Would you like to import an existing database?"
211
- db = @io.prompt "Where is the database file?", {
212
- :indent => 2, :path => true }
213
- else
214
- db = false
215
- end
216
-
217
- db
218
- end
219
- end
220
- end
221
- end
1
+ # encoding: UTF-8
2
+
3
+ module ThemeJuice
4
+ module Commands
5
+ class Create < Command
6
+
7
+ THEMES = {
8
+ "theme-juice/theme-juice-starter" => "https://github.com/ezekg/theme-juice-starter.git",
9
+ "other" => nil,
10
+ "none" => false
11
+ }
12
+
13
+ def initialize(opts = {})
14
+ super
15
+
16
+ @project.use_defaults = @opts.fetch("use_defaults", false)
17
+ @project.bare = @opts.fetch("bare", false)
18
+ @project.skip_repo = @opts.fetch("skip_repo", false)
19
+ @project.skip_db = @opts.fetch("skip_db", false)
20
+ @project.no_wp = @opts.fetch("no_wp", false)
21
+ @project.no_db = @opts.fetch("no_db", false)
22
+ @project.name = @opts.fetch("name") { name }
23
+ @project.location = @opts.fetch("location") { location }
24
+ @project.url = @opts.fetch("url") { url }
25
+ @project.theme = @opts.fetch("theme") { theme }
26
+ @project.repository = @opts.fetch("repository") { repository }
27
+ @project.db_host = @opts.fetch("db_host") { db_host }
28
+ @project.db_name = @opts.fetch("db_name") { db_name }
29
+ @project.db_user = @opts.fetch("db_user") { db_user }
30
+ @project.db_pass = @opts.fetch("db_pass") { db_pass }
31
+ @project.db_import = @opts.fetch("db_import") { db_import }
32
+ @project.vm_root = vm_root
33
+ @project.vm_location = vm_location
34
+ @project.vm_srv = vm_srv
35
+
36
+ runner do |tasks|
37
+ tasks << Tasks::CreateConfirm.new
38
+ tasks << Tasks::Location.new
39
+ tasks << Tasks::Theme.new
40
+ tasks << Tasks::VM.new
41
+ tasks << Tasks::VMPlugins.new
42
+ tasks << Tasks::VMLocation.new
43
+ tasks << Tasks::VMCustomfile.new
44
+ tasks << Tasks::Hosts.new
45
+ tasks << Tasks::Database.new
46
+ tasks << Tasks::Nginx.new
47
+ tasks << Tasks::DotEnv.new
48
+ tasks << Tasks::Landrush.new
49
+ tasks << Tasks::SyncedFolder.new
50
+ tasks << Tasks::DNS.new
51
+ tasks << Tasks::WPCLI.new
52
+ tasks << Tasks::Repo.new
53
+ tasks << Tasks::CreateSuccess.new
54
+ tasks << Tasks::ImportDatabase.new
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def name
61
+ if @env.yolo
62
+ name = Faker::Internet.domain_word
63
+ else
64
+ name = @io.prompt "What's the project name? (letters, numbers and dashes only)"
65
+ end
66
+
67
+ valid_name? name
68
+
69
+ name
70
+ end
71
+
72
+ def valid_name?(name)
73
+ if name.empty?
74
+ @io.error "Project name '#{name}' looks like it's empty. Aborting mission."
75
+ end
76
+
77
+ "#{name}".match /[^0-9A-Za-z.\-]/ do |char|
78
+ @io.error "Project name contains an invalid character '#{char}'. This name is used internally for a ton of stuff, so that's not gonna work. Aborting mission."
79
+ end
80
+
81
+ true
82
+ end
83
+
84
+ def clean_name
85
+ "#{@project.name}".gsub(/[^\w]/, "_")[0..10]
86
+ end
87
+
88
+ def location
89
+ path = "#{Dir.pwd}/"
90
+
91
+ if @project.use_defaults
92
+ location = File.expand_path path
93
+ else
94
+ location = File.expand_path @io.prompt("Where do you want to setup the project?", :default => path, :path => true)
95
+ end
96
+
97
+ location
98
+ end
99
+
100
+ def url
101
+ if @project.use_defaults
102
+ url = "#{@project.name}.dev"
103
+ else
104
+ url = @io.prompt "What do you want the development url to be? (this should end in '.dev')", :default => "#{@project.name}.dev"
105
+ end
106
+
107
+ valid_url? url
108
+
109
+ url
110
+ end
111
+
112
+ def valid_url?(url)
113
+ unless "#{url}".match /(.dev)$/
114
+ @io.error "Your development url '#{url}' doesn't end with '.dev'. This is used internally by Landrush, so that's not gonna work. Aborting mission."
115
+ end
116
+
117
+ true
118
+ end
119
+
120
+ def theme
121
+ return false if @project.bare
122
+
123
+ if @project.use_defaults
124
+ theme = THEMES["theme-juice/theme-juice-starter"]
125
+ else
126
+ choice = @io.choose "Which starter theme would you like to use?", :blue, THEMES.keys
127
+
128
+ case choice
129
+ when "theme-juice/theme-juice-starter"
130
+ @io.success "Awesome choice!"
131
+ when "other"
132
+ THEMES[choice] = @io.prompt "What is the repository URL for the starter theme that you would like to clone?"
133
+ when "none"
134
+ @io.notice "Next time you need to create a project without a starter theme, you can just run the 'setup' command instead."
135
+ @project.bare = true
136
+ end
137
+
138
+ theme = THEMES[choice]
139
+ end
140
+
141
+ theme
142
+ end
143
+
144
+ def repository
145
+ return false if @project.skip_repo || @project.use_defaults
146
+
147
+ if @io.agree? "Would you like to initialize a new Git repository?"
148
+ repo = @io.prompt "What is the repository's remote URL?", :indent => 2
149
+ else
150
+ repo = false
151
+ end
152
+
153
+ repo
154
+ end
155
+
156
+ def db_host
157
+ return false if @project.no_db || @project.no_wp
158
+
159
+ if @project.skip_db || @project.use_defaults
160
+ db_host = "vvv"
161
+ else
162
+ db_host = @io.prompt "Database host", :default => "vvv"
163
+ end
164
+
165
+ db_host
166
+ end
167
+
168
+ def db_name
169
+ return false if @project.no_db || @project.no_wp
170
+
171
+ if @project.skip_db || @project.use_defaults
172
+ db_name = "#{clean_name}_db"
173
+ else
174
+ db_name = @io.prompt "Database name", :default => "#{clean_name}_db"
175
+ end
176
+
177
+ db_name
178
+ end
179
+
180
+ def db_user
181
+ return false if @project.no_db || @project.no_wp
182
+
183
+ if @project.skip_db || @project.use_defaults
184
+ db_user = "#{clean_name}_user"
185
+ else
186
+ db_user = @io.prompt "Database username", :default => "#{clean_name}_user"
187
+ end
188
+
189
+ db_user
190
+ end
191
+
192
+ def db_pass
193
+ return false if @project.no_db || @project.no_wp
194
+
195
+ pass = Faker::Internet.password 24
196
+
197
+ if @project.skip_db || @project.use_defaults
198
+ db_pass = pass
199
+ else
200
+ db_pass = @io.prompt "Database password", :default => pass
201
+ end
202
+
203
+ db_pass
204
+ end
205
+
206
+ def db_import
207
+ return false if @project.no_db || @project.no_wp || @project.use_defaults
208
+
209
+ if @io.agree? "Would you like to import an existing database?"
210
+ db = @io.prompt "Where is the database file?", {
211
+ :indent => 2, :path => true }
212
+ else
213
+ db = false
214
+ end
215
+
216
+ db
217
+ end
218
+ end
219
+ end
220
+ end