swiftly 5.0.1 → 5.0.2
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 +4 -4
- data/lib/swiftly/app_module.rb +1 -1
- data/lib/swiftly/config.rb +16 -12
- data/lib/swiftly/create.rb +4 -5
- data/lib/swiftly/create_wordpress.rb +185 -72
- data/lib/swiftly/database.rb +2 -2
- data/lib/swiftly/factory.rb +4 -2
- data/lib/swiftly/package.rb +116 -0
- data/lib/swiftly/plugin.rb +38 -0
- data/lib/swiftly/project.rb +10 -4
- data/lib/swiftly/resolver.rb +3 -3
- data/lib/swiftly/template.rb +19 -0
- data/lib/swiftly/version.rb +2 -2
- metadata +6 -5
- data/.DS_Store +0 -0
- data/lib/swiftly/packages.rb +0 -157
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e12a8d97534badf9317181eeeaa024c1c4c16f6c
|
4
|
+
data.tar.gz: 3d9f554f38f9fd5e9f71950efa6e5257c3c9ccf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b027195c39a0f8d5dd105ff9787fdf0874deb9375335ceb19d900690b6016a1c4e4da841844e87a0acee5db322daf5e6fd645fc38c32f1b9a618686a8c2a89c5
|
7
|
+
data.tar.gz: 9da671fffd068dc04374daacd325651883e62472d51a2ffd5a016de11ab576bebc828b1ca8a57ff0401148349bc51345aa90c14c5fa17bf6d3ab2661042c1cc3
|
data/lib/swiftly/app_module.rb
CHANGED
data/lib/swiftly/config.rb
CHANGED
@@ -69,6 +69,9 @@ module Swiftly
|
|
69
69
|
|
70
70
|
def self.set setting, *args, &block
|
71
71
|
|
72
|
+
# Ensure that we are only getting the server settings
|
73
|
+
return unless setting == :server
|
74
|
+
|
72
75
|
Swiftly::Smokestack.define do
|
73
76
|
|
74
77
|
factory setting, &block
|
@@ -79,6 +82,13 @@ module Swiftly
|
|
79
82
|
|
80
83
|
end
|
81
84
|
|
85
|
+
|
86
|
+
#
|
87
|
+
# Loads configuration files for swiftly to use
|
88
|
+
# @param file [string] string file path
|
89
|
+
# @param project_name = nil [string] name of the project
|
90
|
+
#
|
91
|
+
# @return [hash] hash of the settings
|
82
92
|
def self.load file, project_name = nil
|
83
93
|
|
84
94
|
case file
|
@@ -91,19 +101,15 @@ module Swiftly
|
|
91
101
|
|
92
102
|
when :project
|
93
103
|
|
94
|
-
|
104
|
+
eval( IO.read( project_file( project_name ) ) )
|
95
105
|
|
96
|
-
|
97
|
-
|
98
|
-
end
|
106
|
+
load_hash = Resolver.get :server == {} ? false : Resolver.get( :server )
|
99
107
|
|
100
108
|
when :swiftly
|
101
109
|
|
102
|
-
|
110
|
+
eval( IO.read( self.swiftlyfile ) )
|
103
111
|
|
104
|
-
|
105
|
-
|
106
|
-
end
|
112
|
+
load_hash = Resolver.get( :server ) == {} ? false : Resolver.get( :server )
|
107
113
|
|
108
114
|
when :global
|
109
115
|
|
@@ -111,7 +117,7 @@ module Swiftly
|
|
111
117
|
|
112
118
|
when :all
|
113
119
|
|
114
|
-
eval( IO.read( swiftlyfile ) ) unless eval( IO.read( swiftlyfile ) ).nil?
|
120
|
+
eval( IO.read( self.swiftlyfile ) ) unless eval( IO.read( self.swiftlyfile ) ).nil?
|
115
121
|
|
116
122
|
|
117
123
|
wp_config_parse project_name
|
@@ -120,13 +126,11 @@ module Swiftly
|
|
120
126
|
eval( IO.read( project_file( project_name ) ) ) unless eval( IO.read( project_file( project_name ) ) ).nil?
|
121
127
|
|
122
128
|
|
123
|
-
|
124
129
|
load_hash = Resolver.get :server
|
125
130
|
|
126
131
|
end
|
127
132
|
|
128
|
-
|
129
|
-
load_hash
|
133
|
+
return load_hash
|
130
134
|
|
131
135
|
end
|
132
136
|
|
data/lib/swiftly/create.rb
CHANGED
@@ -58,12 +58,11 @@ module Swiftly
|
|
58
58
|
|
59
59
|
global_settings = Swiftly::Config.load :global
|
60
60
|
project_settings = Swiftly::Config.load :swiftly
|
61
|
+
template = Swiftly::Template.retrieve :wordpress, options[:template]
|
61
62
|
|
62
|
-
template
|
63
|
-
|
64
|
-
|
65
|
-
name: options[:template]
|
66
|
-
})
|
63
|
+
say_status "#{APP_NAME}:", "Wordpress template #{options[:template]} cannot be found.", :yellow unless template
|
64
|
+
|
65
|
+
abort unless template
|
67
66
|
|
68
67
|
project_path = File.join(
|
69
68
|
global_settings[:sites_path],
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require "thor/group"
|
2
2
|
require 'rubygems'
|
3
3
|
require 'active_support'
|
4
|
-
require 'swiftly/packages'
|
5
4
|
require 'swiftly/app_module'
|
6
5
|
require 'active_support/core_ext/string'
|
7
6
|
require 'git'
|
@@ -14,156 +13,244 @@ module Swiftly
|
|
14
13
|
|
15
14
|
argument :project_name
|
16
15
|
argument :template
|
17
|
-
# argument :settings
|
18
16
|
argument :project_path
|
19
17
|
|
20
18
|
desc "Handles the creation of a wordpress project."
|
21
19
|
|
20
|
+
#
|
21
|
+
# Define the source root of this file
|
22
|
+
#
|
23
|
+
# @return [string] The path to this file
|
22
24
|
def self.source_root
|
23
25
|
|
24
26
|
File.dirname(__FILE__)
|
25
27
|
|
26
28
|
end
|
27
29
|
|
28
|
-
def get_wordpress()
|
29
30
|
|
30
|
-
|
31
|
+
#
|
32
|
+
# This method grabs the latest version of wordpress,
|
33
|
+
# unzips it and places it into the project directory
|
34
|
+
#
|
35
|
+
# @return [void]
|
36
|
+
def get_wordpress
|
37
|
+
|
38
|
+
# change directory into the project path
|
31
39
|
inside @project_path do
|
32
40
|
|
41
|
+
# download Wordpress unless it already exists
|
33
42
|
get 'https://wordpress.org/latest.zip', 'latest.zip' unless File.exist? 'wordpress'
|
34
43
|
|
44
|
+
# unzip the zip unless it is already unzipped
|
35
45
|
unzip 'latest.zip', 'wordpress' unless File.exist? 'wordpress'
|
36
46
|
|
47
|
+
# remove the zip file if the zip file exists
|
37
48
|
remove_file 'latest.zip' unless !File.exist? 'latest.zip'
|
38
49
|
|
39
|
-
|
50
|
+
# Grab all of the folders out of the wordpress directory
|
51
|
+
Dir[File.join('wordpress', '*')].each do |e|
|
40
52
|
|
53
|
+
# Move all of the folders our of the wordpress directory
|
54
|
+
# and into the root of the project if it exists
|
41
55
|
FileUtils.mv( e, @project_path ) unless File.exist? e.gsub(/^wordpress/, @project_path )
|
42
56
|
|
43
57
|
end
|
44
58
|
|
59
|
+
# Remove the empty wordpress directory if it still exits
|
45
60
|
remove_file 'wordpress' unless !(Dir.entries('wordpress') - %w{ . .. }).empty?
|
61
|
+
end
|
62
|
+
end
|
46
63
|
|
47
|
-
inside File.join( 'wp-content', 'themes') do
|
48
|
-
|
49
|
-
if @template[:location] =~ /^#{URI::regexp}\.zip$/
|
50
64
|
|
51
|
-
|
65
|
+
#
|
66
|
+
# Download or get theme for a location on the hard drive
|
67
|
+
# and add it to the Wordpress theme folder
|
68
|
+
#
|
69
|
+
# @return [void]
|
70
|
+
def get_theme
|
52
71
|
|
53
|
-
|
72
|
+
# Change directories to inside of the theme directory
|
73
|
+
inside File.join( @project_path, 'wp-content', 'themes') do
|
54
74
|
|
55
|
-
|
75
|
+
# Check to see if the theme is a zip file
|
76
|
+
if @template.location =~ /^#{URI::regexp}\.zip$/
|
56
77
|
|
57
|
-
|
78
|
+
# If the theme is a zip file then download the theme
|
79
|
+
zipfile = get @template.location, File.basename( @template.location )
|
58
80
|
|
59
|
-
|
81
|
+
# Unzip the theme if it has not been unzipped already
|
82
|
+
unzip zipfile, @template.name unless File.exist? @template.name.to_s
|
60
83
|
|
61
|
-
|
84
|
+
# Rmove the zipfile if it still exists
|
85
|
+
remove_file zipfile unless !File.exist? zipfile
|
62
86
|
|
63
|
-
|
87
|
+
else
|
64
88
|
|
65
|
-
|
89
|
+
# If the theme location does not point to a zip file
|
90
|
+
# then the theme to the theme folder
|
91
|
+
FileUtils.cp_r( File.join( @template.location, @template.name.to_s ), '.' )
|
66
92
|
|
67
|
-
|
68
|
-
'.git',
|
69
|
-
'_resources',
|
70
|
-
'.gitignore',
|
71
|
-
'.htaccess',
|
72
|
-
".#{APP_NAME}",
|
73
|
-
".#{APP_NAME}ignore"
|
74
|
-
].each do |e|
|
75
|
-
|
76
|
-
remove_file e
|
93
|
+
end
|
77
94
|
|
78
|
-
|
95
|
+
# Change the theme name from whatever it was named
|
96
|
+
# into the the name of the project
|
97
|
+
FileUtils.mv( @template.name.to_s, @project_name ) unless !File.exists? @template.name.to_s.capitalize
|
79
98
|
|
80
|
-
|
81
|
-
|
82
|
-
'wp-config.php',
|
83
|
-
'bower.json',
|
84
|
-
'config.rb',
|
85
|
-
'Guardfile',
|
86
|
-
'Gemfile',
|
87
|
-
'Gemfile.lock'
|
88
|
-
].each do |file|
|
99
|
+
# Change directories
|
100
|
+
inside @project_name do
|
89
101
|
|
90
|
-
|
102
|
+
# Loop through each of these files
|
103
|
+
# and delete them if the exist
|
104
|
+
[
|
105
|
+
'.git',
|
106
|
+
'_resources',
|
107
|
+
'.gitignore',
|
108
|
+
'.htaccess',
|
109
|
+
".#{APP_NAME}",
|
110
|
+
".#{APP_NAME}ignore"
|
111
|
+
].each do |file|
|
91
112
|
|
92
|
-
|
113
|
+
remove_file file unless !File.exists? file
|
93
114
|
|
94
|
-
|
115
|
+
end
|
95
116
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
117
|
+
# Loop through each of these files
|
118
|
+
# and perform a find and replace to change
|
119
|
+
# the theme name into the name of the project
|
120
|
+
[
|
121
|
+
'.htaccess',
|
122
|
+
'wp-config.php',
|
123
|
+
'bower.json',
|
124
|
+
'config.rb',
|
125
|
+
'Guardfile',
|
126
|
+
'Gemfile',
|
127
|
+
'Gemfile.lock'
|
128
|
+
].each do |file|
|
100
129
|
|
101
|
-
|
102
|
-
File.join( "wp-login-logo-#{@template[:name]}.png" ) ,
|
103
|
-
File.join( "wp-login-logo-#{@project_name}.png" )
|
104
|
-
) unless !File.exists? File.join( "wp-login-logo-#{@template[:name]}.png" )
|
130
|
+
gsub_file file, /(#{@template.name})/, @project_name.gsub(/\-|\./, '_') unless !File.exists? file
|
105
131
|
|
106
|
-
|
132
|
+
FileUtils.mv( file, @project_path ) unless !File.exists? file
|
107
133
|
|
108
134
|
end
|
109
|
-
end
|
110
135
|
|
111
|
-
|
136
|
+
# Move the project specific plugin into the
|
137
|
+
# plugins directory if it exists
|
138
|
+
FileUtils.mv(
|
139
|
+
"#{@template.name}-specific-plugin",
|
140
|
+
File.join( @project_path, "wp-content", "plugins", "#{@project_name}-specific-plugin")
|
141
|
+
) unless !File.exists? "#{@template.name}-specific-plugin"
|
112
142
|
|
143
|
+
# Change the name of the theme logo
|
144
|
+
# if it exists
|
113
145
|
FileUtils.mv(
|
114
|
-
"
|
115
|
-
"
|
116
|
-
) unless !File.exists? "
|
146
|
+
File.join( "wp-login-logo-#{@template.name}.png" ) ,
|
147
|
+
File.join( "wp-login-logo-#{@project_name}.png" )
|
148
|
+
) unless !File.exists? File.join( "wp-login-logo-#{@template.name}.png" )
|
117
149
|
|
118
|
-
|
150
|
+
# Perform a find and replace on the function file to
|
151
|
+
# change any mentions of the theme name into the name of the project
|
152
|
+
gsub_file 'functions.php', /(#{@template.name})/, @project_name
|
119
153
|
|
120
154
|
end
|
121
155
|
|
122
|
-
|
156
|
+
end
|
157
|
+
|
158
|
+
# Change directories into the project specific plugin
|
159
|
+
inside File.join( @project_path, "wp-content", "plugins", "#{@project_name}-specific-plugin") do
|
160
|
+
|
161
|
+
# Change the file name to match the project name
|
162
|
+
FileUtils.mv(
|
163
|
+
"#{@template.name}-plugin.php",
|
164
|
+
"#{@project_name}-plugin.php"
|
165
|
+
) unless !File.exists? "#{@template.name}-plugin.php"
|
166
|
+
|
167
|
+
# Perform a find and replace files to match the project name
|
168
|
+
gsub_file "#{@project_name}-plugin.php", /(#{@template.name})/, @project_name.capitalize unless !File.exists? "#{@template.name}-plugin.php"
|
169
|
+
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# Download or get plugins for a location on the hard drive
|
175
|
+
# and add it to the Wordpress plugins folder
|
176
|
+
#
|
177
|
+
# @return [void]
|
178
|
+
def get_plugins
|
179
|
+
|
180
|
+
# Change directories into the plugins directory
|
181
|
+
inside File.join( @project_path, "wp-content", "plugins" ) do
|
123
182
|
|
124
|
-
|
183
|
+
# Get all the Wordpress plugins from specified in
|
184
|
+
# the config and in the Swiftlyfolder
|
185
|
+
plugins = Swiftly::Plugin.all :wordpress
|
125
186
|
|
126
|
-
|
187
|
+
# Check to see if any plugins are available
|
188
|
+
if plugins
|
127
189
|
|
128
|
-
|
129
|
-
|
190
|
+
# If plugins are available then
|
191
|
+
# loop through all the plugins
|
192
|
+
plugins[:wordpress].each do |plugin|
|
130
193
|
|
131
|
-
|
194
|
+
# If a plugin is zipped up
|
195
|
+
if plugin.location =~ /^#{URI::regexp}\.zip$/
|
132
196
|
|
133
|
-
|
197
|
+
# Set the plugin up to be unzipped
|
198
|
+
zipfile = get plugin.location, File.basename( plugin.location )
|
134
199
|
|
135
|
-
|
200
|
+
# Unzip the plugin if it exists
|
201
|
+
unzip zipfile, plugin.name unless File.exist? plugin.name.to_s
|
136
202
|
|
137
|
-
|
203
|
+
# Remove the zip file if it exists
|
204
|
+
remove_file zipfile unless !File.exist? zipfile
|
138
205
|
|
139
|
-
|
206
|
+
else
|
140
207
|
|
141
|
-
|
208
|
+
# If the plugin is not zipped then just
|
209
|
+
# copy it to the plugin folder
|
210
|
+
FileUtils.cp_r( File.join( plugin.location, plugin.name.to_s ), '.' ) unless File.exist? plugin.name.to_s
|
142
211
|
|
143
|
-
end
|
144
212
|
end
|
145
213
|
end
|
146
214
|
end
|
215
|
+
end
|
216
|
+
end
|
147
217
|
|
148
|
-
|
149
|
-
|
218
|
+
#
|
219
|
+
# Handle the wp-config file in peperations for database set up
|
220
|
+
#
|
221
|
+
# @return [void]
|
222
|
+
def wp_config
|
150
223
|
|
224
|
+
# Change directories into the project directory
|
225
|
+
inside File.join @project_path do
|
226
|
+
|
227
|
+
# Get rid of the sample wp-config file
|
151
228
|
remove_file "wp-config-sample.php"
|
152
229
|
|
230
|
+
# Add salts to the wp-config file
|
153
231
|
gsub_file 'wp-config.php', /\/\/\s*Insert_Salts_Below/, Net::HTTP.get('api.wordpress.org', '/secret-key/1.1/salt')
|
232
|
+
|
233
|
+
# Change the table prefix for the database
|
154
234
|
gsub_file 'wp-config.php', /(table_prefix\s*=\s*')(wp_')/, '\1' + @project_name[0,3] + "_'"
|
155
235
|
|
236
|
+
# Retrieve the server settings for the
|
237
|
+
# local database
|
156
238
|
settings = Swiftly::Config.load :swiftly
|
157
239
|
|
240
|
+
# Check to see if all of the database settings
|
241
|
+
# are present
|
158
242
|
if !settings.nil? &&
|
159
243
|
!settings[:local][:db_host].nil? &&
|
160
244
|
!settings[:local][:db_user].nil? &&
|
161
245
|
!settings[:local][:db_pass].nil?
|
162
246
|
|
247
|
+
# If the database settings are present the
|
248
|
+
# perform a find and replace on the local wp-config
|
249
|
+
# database settings
|
163
250
|
gsub_file 'wp-config.php', /(\$local\s*?=[\s|\S]*?)({[\s|\S]*?})/ do |match|
|
164
251
|
|
165
252
|
'$local = \'{
|
166
|
-
"db_name": "' + @project_name + '_local_wp",
|
253
|
+
"db_name": "' + @project_name.gsub(/\-|\./, '_') + '_local_wp",
|
167
254
|
"db_host": "' + settings[:local][:db_host] + '",
|
168
255
|
"db_user": "' + settings[:local][:db_user] + '",
|
169
256
|
"db_pass": "' + settings[:local][:db_pass] + '",
|
@@ -174,14 +261,40 @@ module Swiftly
|
|
174
261
|
end
|
175
262
|
end
|
176
263
|
|
177
|
-
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
|
268
|
+
#
|
269
|
+
# Create the database for the project
|
270
|
+
#
|
271
|
+
# @return [void]
|
272
|
+
def create_database
|
273
|
+
|
274
|
+
# Create a new database object
|
275
|
+
database = Swiftly::Database.new @project_name
|
178
276
|
|
179
|
-
|
277
|
+
# Create a new database
|
278
|
+
database.create :local
|
279
|
+
|
280
|
+
end
|
180
281
|
|
282
|
+
|
283
|
+
#
|
284
|
+
# Take care of any of the project dependencies
|
285
|
+
#
|
286
|
+
# @return [void]
|
287
|
+
def dependencies
|
288
|
+
|
289
|
+
# Change directories into the project directory
|
290
|
+
inside File.join @project_path do
|
291
|
+
|
292
|
+
# Run all the possible installs if any of the
|
293
|
+
# package managers exists
|
181
294
|
run('bundle') unless !File.exists? 'Gemfile'
|
182
295
|
run('bundle exec guard') unless !File.exists? 'Guardfile'
|
296
|
+
run('npm install') unless !File.exists? 'package.json'
|
183
297
|
run('bower update') unless !File.exists? 'bower.json'
|
184
|
-
|
185
298
|
end
|
186
299
|
end
|
187
300
|
end
|
data/lib/swiftly/database.rb
CHANGED
data/lib/swiftly/factory.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
require "swiftly/server"
|
2
|
+
require "swiftly/template"
|
3
|
+
require "swiftly/plugin"
|
2
4
|
|
3
5
|
module Swiftly
|
4
6
|
class Factory < BasicObject
|
5
7
|
|
8
|
+
attr_reader :attributes
|
9
|
+
|
6
10
|
def initialize
|
7
11
|
|
8
12
|
@attributes = {}
|
9
13
|
|
10
14
|
end
|
11
15
|
|
12
|
-
attr_reader :attributes
|
13
|
-
|
14
16
|
def method_missing(name, *args, &block)
|
15
17
|
|
16
18
|
@attributes[name] = args[0]
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Swiftly
|
2
|
+
class Package
|
3
|
+
|
4
|
+
attr_accessor :name
|
5
|
+
attr_accessor :location
|
6
|
+
attr_accessor :status
|
7
|
+
|
8
|
+
def self.file
|
9
|
+
|
10
|
+
@settings = Swiftly::Config.load :global
|
11
|
+
|
12
|
+
File.join(
|
13
|
+
@settings[:sites_path],
|
14
|
+
"#{APP_NAME}file",
|
15
|
+
) unless !File.exists?(
|
16
|
+
File.join(
|
17
|
+
@settings[:sites_path],
|
18
|
+
"#{APP_NAME}file"
|
19
|
+
)
|
20
|
+
)
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.set package_type, *args, &block
|
25
|
+
|
26
|
+
unless package_type == @package_type &&
|
27
|
+
args[0][:type] == @type
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
Swiftly::Smokestack.define do
|
32
|
+
|
33
|
+
factory package_type, &block
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
self.load args[0][:type], Swiftly::Smokestack.build( package_type )
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Loads the class variable @package with an hash
|
43
|
+
# with package objects by package types
|
44
|
+
#
|
45
|
+
# @param type [symbol] Type of package either :plugin or :template
|
46
|
+
# @param attributes [obj] The package object
|
47
|
+
#
|
48
|
+
# @return [type] [description]
|
49
|
+
def self.load type, attributes
|
50
|
+
|
51
|
+
@packages[type] << attributes
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
#
|
56
|
+
# Return a package back to the requester
|
57
|
+
# @param type [symbol] Type of package either :plugin or :template
|
58
|
+
# @param name [string] The name of the package to be returned
|
59
|
+
#
|
60
|
+
# @return [obj] An object of the package
|
61
|
+
def self.retrieve type, name
|
62
|
+
|
63
|
+
# Gather all packages
|
64
|
+
self.gather type
|
65
|
+
|
66
|
+
# Check to see if the class variable packages
|
67
|
+
# contain packages that match the passed in type
|
68
|
+
if !@packages[type].nil?
|
69
|
+
|
70
|
+
# If so the loop over all the packages
|
71
|
+
@packages[type].each do |package|
|
72
|
+
|
73
|
+
# Check to see if one thereis one
|
74
|
+
# that matches the passed in name
|
75
|
+
if package.name == name
|
76
|
+
|
77
|
+
# If so the return it
|
78
|
+
return package
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
# If all goes bad then return false
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.all type
|
89
|
+
|
90
|
+
self.gather type
|
91
|
+
|
92
|
+
return false if @packages[type].nil? && type == :plugin
|
93
|
+
|
94
|
+
@packages
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.gather type
|
98
|
+
|
99
|
+
# Set the type
|
100
|
+
@type = type
|
101
|
+
|
102
|
+
# Ready the package hash
|
103
|
+
@packages = {
|
104
|
+
type => []
|
105
|
+
}
|
106
|
+
|
107
|
+
# Set defaults
|
108
|
+
self.defaults
|
109
|
+
|
110
|
+
proc = Proc.new {}
|
111
|
+
|
112
|
+
# Evalutes the config file and runs the methods on the file
|
113
|
+
eval( IO.read( self.file ), proc.binding, self.file)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "swiftly/package"
|
2
|
+
|
3
|
+
module Swiftly
|
4
|
+
class Plugin < Package
|
5
|
+
|
6
|
+
attr_accessor :muplugin
|
7
|
+
|
8
|
+
@package_type = :plugin
|
9
|
+
|
10
|
+
def self.defaults
|
11
|
+
|
12
|
+
global = Swiftly::Config.load :global
|
13
|
+
|
14
|
+
if File.directory? File.join(global[:sites_path], "#{APP_NAME}folder".capitalize)
|
15
|
+
|
16
|
+
app_folder = File.join(global[:sites_path], "#{APP_NAME}folder".capitalize)
|
17
|
+
|
18
|
+
if File.directory? File.join app_folder, 'plugins'
|
19
|
+
|
20
|
+
plugin_folder = File.join app_folder, 'plugins'
|
21
|
+
|
22
|
+
plugins = Dir.glob(File.join(plugin_folder, '*')).select {|f| File.directory? f}
|
23
|
+
|
24
|
+
plugins.each do |location|
|
25
|
+
|
26
|
+
self.set :plugin, :type => :wordpress do
|
27
|
+
|
28
|
+
name File.basename location
|
29
|
+
location File.join app_folder, 'plugins'
|
30
|
+
status :enabled
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/swiftly/project.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'thor'
|
2
2
|
require 'yaml'
|
3
3
|
require 'swiftly/app_module'
|
4
4
|
|
@@ -12,6 +12,8 @@ module Swiftly
|
|
12
12
|
|
13
13
|
def self.set setting, *args, &block
|
14
14
|
|
15
|
+
return unless setting == :server
|
16
|
+
|
15
17
|
Swiftly::Smokestack.define do
|
16
18
|
|
17
19
|
factory setting, &block
|
@@ -30,11 +32,15 @@ module Swiftly
|
|
30
32
|
project_file = Swiftly::Config.project_file project_name
|
31
33
|
wp_config = Swiftly::Config.wp_config_file project_name
|
32
34
|
|
33
|
-
|
35
|
+
proc = Proc.new {}
|
36
|
+
|
37
|
+
eval( IO.read( swiftlyfile ) ) unless eval( IO.read( swiftlyfile ), proc.binding, swiftlyfile ).nil?
|
34
38
|
|
35
39
|
wp_config_parse wp_config
|
36
40
|
|
37
|
-
|
41
|
+
proc = Proc.new {}
|
42
|
+
|
43
|
+
eval( IO.read( project_file ) ) unless eval( IO.read( project_file ), proc.binding, project_file ).nil?
|
38
44
|
|
39
45
|
settings = Resolver.get :server
|
40
46
|
|
@@ -165,4 +171,4 @@ module Swiftly
|
|
165
171
|
end
|
166
172
|
end
|
167
173
|
end
|
168
|
-
end
|
174
|
+
end
|
data/lib/swiftly/resolver.rb
CHANGED
@@ -3,13 +3,11 @@ module Swiftly
|
|
3
3
|
|
4
4
|
@@settings = {
|
5
5
|
server: [],
|
6
|
-
package: []
|
7
6
|
}
|
8
7
|
|
9
8
|
def self.load setting, type, attributes
|
10
9
|
|
11
10
|
@@settings[setting] << { type => attributes }
|
12
|
-
|
13
11
|
end
|
14
12
|
|
15
13
|
def self.get setting
|
@@ -17,8 +15,11 @@ module Swiftly
|
|
17
15
|
override = {}
|
18
16
|
final = {}
|
19
17
|
|
18
|
+
# Check to see if there is a setting in the array
|
19
|
+
# that matches the setting param
|
20
20
|
if !@@settings[setting].nil?
|
21
21
|
|
22
|
+
# If so loop through
|
22
23
|
@@settings[setting].each do |s|
|
23
24
|
|
24
25
|
s.each do |k, v|
|
@@ -41,7 +42,6 @@ module Swiftly
|
|
41
42
|
|
42
43
|
construct = {}
|
43
44
|
capture = {}
|
44
|
-
|
45
45
|
override[k].each do |o|
|
46
46
|
|
47
47
|
final.merge!( {k => {} } )
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "swiftly/package"
|
2
|
+
|
3
|
+
module Swiftly
|
4
|
+
class Template < Package
|
5
|
+
|
6
|
+
@package_type = :template
|
7
|
+
|
8
|
+
def self.defaults
|
9
|
+
|
10
|
+
self.set :template, :type => :wordpress do
|
11
|
+
|
12
|
+
name :default
|
13
|
+
location 'https://github.com/micalexander/mask/archive/master.zip'
|
14
|
+
status :enabled
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/swiftly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiftly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mic Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -103,7 +103,6 @@ executables:
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
-
- ".DS_Store"
|
107
106
|
- ".gitignore"
|
108
107
|
- Gemfile
|
109
108
|
- README.md
|
@@ -125,7 +124,8 @@ files:
|
|
125
124
|
- lib/swiftly/destroy.rb
|
126
125
|
- lib/swiftly/factory.rb
|
127
126
|
- lib/swiftly/init.rb
|
128
|
-
- lib/swiftly/
|
127
|
+
- lib/swiftly/package.rb
|
128
|
+
- lib/swiftly/plugin.rb
|
129
129
|
- lib/swiftly/project.rb
|
130
130
|
- lib/swiftly/pull.rb
|
131
131
|
- lib/swiftly/push.rb
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/swiftly/setup.rb
|
136
136
|
- lib/swiftly/smokestack.rb
|
137
137
|
- lib/swiftly/ssh.rb
|
138
|
+
- lib/swiftly/template.rb
|
138
139
|
- lib/swiftly/templates/config_global.erb
|
139
140
|
- lib/swiftly/templates/config_project.erb
|
140
141
|
- lib/swiftly/templates/gitignore.erb
|
@@ -162,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
163
|
version: 2.1.3
|
163
164
|
requirements: []
|
164
165
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.6.8
|
166
167
|
signing_key:
|
167
168
|
specification_version: 4
|
168
169
|
summary: Swiftly is a all-in-one WordPress development tool
|
data/.DS_Store
DELETED
Binary file
|
data/lib/swiftly/packages.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
require "swiftly/config"
|
2
|
-
require "swiftly/app_module"
|
3
|
-
require "yaml"
|
4
|
-
require "swiftly/factory"
|
5
|
-
|
6
|
-
module Swiftly
|
7
|
-
class Package < Thor
|
8
|
-
|
9
|
-
include Thor::Actions
|
10
|
-
include Helpers
|
11
|
-
|
12
|
-
no_commands do
|
13
|
-
|
14
|
-
attr_accessor :framework
|
15
|
-
attr_accessor :type
|
16
|
-
attr_accessor :name
|
17
|
-
attr_accessor :location
|
18
|
-
|
19
|
-
def self.file
|
20
|
-
|
21
|
-
@settings = Swiftly::Config.load :global
|
22
|
-
|
23
|
-
File.join(
|
24
|
-
@settings[:sites_path],
|
25
|
-
'Swiftlyfile',
|
26
|
-
) unless !File.exists?(
|
27
|
-
File.join(
|
28
|
-
@settings[:sites_path],
|
29
|
-
'Swiftlyfile'
|
30
|
-
)
|
31
|
-
)
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.check?
|
36
|
-
|
37
|
-
if File.exists? self.file
|
38
|
-
|
39
|
-
true
|
40
|
-
|
41
|
-
else
|
42
|
-
|
43
|
-
false
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.available
|
49
|
-
|
50
|
-
eval( IO.read( self.file ) )
|
51
|
-
|
52
|
-
load_hash = Resolver.get( :package ) == {} ? false : Resolver.get( :package )
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.set setting, *args, &block
|
57
|
-
|
58
|
-
Swiftly::Smokestack.define do
|
59
|
-
|
60
|
-
factory setting, &block
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
Swiftly::Resolver.load setting, args[0][:type], Swiftly::Smokestack.build( setting )
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.template
|
69
|
-
|
70
|
-
{
|
71
|
-
name: 'mask',
|
72
|
-
location: 'https://github.com/micalexander/mask/archive/master.zip'
|
73
|
-
}
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.load package = {}
|
78
|
-
|
79
|
-
approved_package = nil
|
80
|
-
|
81
|
-
if self.available &&
|
82
|
-
!self.available[:packages].nil? &&
|
83
|
-
!self.available[:packages][package[:framework]].nil? &&
|
84
|
-
!self.available[:packages][package[:framework]][package[:type]].nil?
|
85
|
-
|
86
|
-
self.available[:packages][package[:framework]][package[:type]].each do |p|
|
87
|
-
|
88
|
-
if ( p[:name] == package[:name] && p[:status] != :disabled ) ||
|
89
|
-
( p[:status] == :default )
|
90
|
-
|
91
|
-
approved_package = p
|
92
|
-
|
93
|
-
else
|
94
|
-
|
95
|
-
approved_package = self.template
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
elsif !self.available
|
101
|
-
|
102
|
-
|
103
|
-
approved_package = self.template
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
if !approved_package.nil? &&
|
108
|
-
(
|
109
|
-
approved_package[:location] =~ /^#{URI::regexp}\.zip$/ ||
|
110
|
-
File.exist?( File.join( approved_package[:location], approved_package[:name] ) )
|
111
|
-
)
|
112
|
-
|
113
|
-
return approved_package
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
false
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
def self.load_plugins framework
|
122
|
-
|
123
|
-
plugins = []
|
124
|
-
|
125
|
-
if self.available &&
|
126
|
-
!self.available[:packages].nil? &&
|
127
|
-
!self.available[:packages][framework].nil? &&
|
128
|
-
!self.available[:packages][framework][:plugins].nil?
|
129
|
-
|
130
|
-
self.available[:packages][framework][:plugins].each do |p|
|
131
|
-
|
132
|
-
verified = self.load({
|
133
|
-
framework: framework,
|
134
|
-
type: :plugins,
|
135
|
-
name: p[:name]
|
136
|
-
})
|
137
|
-
|
138
|
-
if verified
|
139
|
-
|
140
|
-
plugins << verified
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
if plugins.count > 0
|
146
|
-
|
147
|
-
return plugins
|
148
|
-
|
149
|
-
end
|
150
|
-
|
151
|
-
false
|
152
|
-
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|