theme-juice 0.7.7 → 0.7.8

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 +204 -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 +221 -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 -70
  11. data/lib/theme-juice/env.rb +25 -25
  12. data/lib/theme-juice/io.rb +323 -323
  13. data/lib/theme-juice/project.rb +35 -35
  14. data/lib/theme-juice/task.rb +42 -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 +6 -7
@@ -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,221 @@
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
+ 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