my-simon 0.1.9 → 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.
- data/Gemfile.lock +3 -3
- data/VERSION +1 -1
- data/bin/simon +2 -2
- data/lib/simon.rb +21 -0
- data/my-simon.gemspec +2 -3
- metadata +2 -3
- data/simon +0 -282
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/simon
CHANGED
@@ -30,12 +30,12 @@ command :create do |c|
|
|
30
30
|
c.option '--some-switch', 'Some switch that does something'
|
31
31
|
c.action do |args, options|
|
32
32
|
# Do something or c.when_called My-simon::Commands::Create,
|
33
|
-
|
33
|
+
simon_controller.msg ">>> simon's requesting the boilerplate <<<"
|
34
34
|
cmd = "svn export #{svn_path} app --quiet"
|
35
35
|
Kernel::system(cmd)
|
36
36
|
cmd = "cd ./app/"
|
37
37
|
Kernel::system(cmd)
|
38
|
-
simon_controller.msg "Boilerplate added"
|
38
|
+
simon_controller.msg "-----> Boilerplate added"
|
39
39
|
|
40
40
|
simon_controller.setup
|
41
41
|
|
data/lib/simon.rb
CHANGED
@@ -50,6 +50,15 @@ class Simon
|
|
50
50
|
cmd = "find . -type f -name '*.tpl' -exec sed -i '' s/CHANGE_ME/#{@nms}/g {} +"
|
51
51
|
Kernel::system(cmd)
|
52
52
|
|
53
|
+
# localhost setup
|
54
|
+
choice = choose("Setup Localhost domain?", :yes, :no)
|
55
|
+
|
56
|
+
if choice === :yes
|
57
|
+
|
58
|
+
self.setup_localhost
|
59
|
+
|
60
|
+
end
|
61
|
+
|
53
62
|
# database setup
|
54
63
|
choice = choose("Setup Local DB?", :yes, :no)
|
55
64
|
|
@@ -130,6 +139,18 @@ class Simon
|
|
130
139
|
end
|
131
140
|
|
132
141
|
|
142
|
+
def setup_localhost
|
143
|
+
|
144
|
+
host = ask("What is the virtual host name? : ") { |q| q.echo = true }
|
145
|
+
|
146
|
+
config = "./app/www/lib/php/system/Config.php"
|
147
|
+
self.replace_once(config, "%l_vhost%", host)
|
148
|
+
|
149
|
+
self.msg "#{config} modified"
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
|
133
154
|
def setup_db
|
134
155
|
|
135
156
|
# self.check_hidden
|
data/my-simon.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "my-simon"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aaron McGuire"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-05-06"
|
13
13
|
s.description = "CLI tool for Simon, the simple PHP project boilerplate!"
|
14
14
|
s.email = "aaron.mcguire@evb.com"
|
15
15
|
s.executables = ["/simon"]
|
@@ -31,7 +31,6 @@ Gem::Specification.new do |s|
|
|
31
31
|
"bin/simon",
|
32
32
|
"lib/simon.rb",
|
33
33
|
"my-simon.gemspec",
|
34
|
-
"simon",
|
35
34
|
"test/helper.rb",
|
36
35
|
"test/test_simon.rb"
|
37
36
|
]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my-simon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
@@ -241,7 +241,6 @@ files:
|
|
241
241
|
- bin/simon
|
242
242
|
- lib/simon.rb
|
243
243
|
- my-simon.gemspec
|
244
|
-
- simon
|
245
244
|
- test/helper.rb
|
246
245
|
- test/test_simon.rb
|
247
246
|
homepage: https://github.com/samcreate/simon-cli
|
data/simon
DELETED
@@ -1,282 +0,0 @@
|
|
1
|
-
#!/usr/bin/php
|
2
|
-
<?php
|
3
|
-
|
4
|
-
|
5
|
-
$command = $argv[1];
|
6
|
-
$repo_url = "";
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
switch ($command) {
|
11
|
-
case 'setup':
|
12
|
-
|
13
|
-
|
14
|
-
$resonse = strtolower(askQuestion("Do you want to setup your project namespace? [y/n]"));
|
15
|
-
|
16
|
-
if($resonse === "y"){
|
17
|
-
|
18
|
-
_replace_namespace();
|
19
|
-
|
20
|
-
}elseif($resonse != "n"){
|
21
|
-
e_check("","Invalid Answer: ".$resonse);
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
|
-
$resonse = strtolower(askQuestion("Do you want to setup your local DB? [y/n]"));
|
26
|
-
|
27
|
-
if($resonse === "y"){
|
28
|
-
|
29
|
-
_setup_db();
|
30
|
-
}elseif($resonse != "n"){
|
31
|
-
e_check("","Invalid Answer: ".$resonse);
|
32
|
-
}
|
33
|
-
|
34
|
-
$resonse = strtolower(askQuestion("Do you want to set the Google Analytics tracking id? [y/n]"));
|
35
|
-
|
36
|
-
if($resonse === "y"){
|
37
|
-
|
38
|
-
_setup_tracking();
|
39
|
-
}elseif($resonse != "n"){
|
40
|
-
e_check("","Invalid Answer: ".$resonse);
|
41
|
-
}
|
42
|
-
|
43
|
-
_sucess_msg();
|
44
|
-
break;
|
45
|
-
case "add" :
|
46
|
-
|
47
|
-
if($argv[2] === "section"){
|
48
|
-
|
49
|
-
_add_section();
|
50
|
-
|
51
|
-
_sucess_msg();
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
|
56
|
-
if($argv[2] === "repo"){
|
57
|
-
|
58
|
-
_add_repo();
|
59
|
-
|
60
|
-
_sucess_msg();
|
61
|
-
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
break;
|
68
|
-
case 'help':
|
69
|
-
//TODO
|
70
|
-
break;
|
71
|
-
default:
|
72
|
-
echo "WTF are you trying to do? \n";
|
73
|
-
break;
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
function _setup_boilerplate(){
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
|
82
|
-
function _SearchandReplaceFILE($p_file, $stringsearch, $stringreplace){
|
83
|
-
// read the file
|
84
|
-
$file = file_get_contents($p_file);
|
85
|
-
// replace the data
|
86
|
-
$file = str_replace($stringsearch, $stringreplace, $file);
|
87
|
-
// write the file
|
88
|
-
file_put_contents($p_file, $file);
|
89
|
-
}
|
90
|
-
|
91
|
-
function _SearchandReplaceDIR($dir, $stringsearch, $stringreplace){
|
92
|
-
$listDir = array();
|
93
|
-
if($handler = opendir($dir)) {
|
94
|
-
while (($sub = readdir($handler)) !== FALSE) {
|
95
|
-
if ($sub != "." && $sub != ".." && $sub != "Thumb.db") {
|
96
|
-
if(is_file($dir."/".$sub)) {
|
97
|
-
if(substr_count($sub,'.php') || substr_count($sub,'.js') || substr_count($sub,'.html') || substr_count($sub,'.tpl'))
|
98
|
-
{
|
99
|
-
$getfilecontents = file_get_contents($dir."/".$sub);
|
100
|
-
if(substr_count($getfilecontents,$stringsearch)>0)
|
101
|
-
{
|
102
|
-
$replacer = str_replace($stringsearch,$stringreplace,$getfilecontents);
|
103
|
-
// Let's make sure the file exists and is writable first.
|
104
|
-
if (is_writable($dir."/".$sub)) {
|
105
|
-
if (!$handle = fopen($dir."/".$sub, 'w')) {
|
106
|
-
echo "Cannot open file (".$dir."/".$sub.")\n";
|
107
|
-
exit;
|
108
|
-
}
|
109
|
-
// Write $somecontent to our opened file.
|
110
|
-
if (fwrite($handle, $replacer) === FALSE) {
|
111
|
-
echo "Cannot write to file (".$dir."/".$sub.")\n";
|
112
|
-
exit;
|
113
|
-
}
|
114
|
-
|
115
|
-
fclose($handle);
|
116
|
-
} else {
|
117
|
-
//echo "The file ".$dir."/".$sub." is not writable \n";
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
|
-
$listDir[] = $sub;
|
122
|
-
}elseif(is_dir($dir."/".$sub)){
|
123
|
-
$listDir[$sub] = _SearchandReplaceDIR($dir."/".$sub,$stringsearch,$stringreplace);
|
124
|
-
}
|
125
|
-
}
|
126
|
-
}
|
127
|
-
closedir($handler);
|
128
|
-
}
|
129
|
-
return $listDir;
|
130
|
-
}
|
131
|
-
|
132
|
-
function e_check($p,$msg,$try_again=false){
|
133
|
-
|
134
|
-
if(isset($p) && strlen($p) != 0){
|
135
|
-
echo $p;
|
136
|
-
return $p;
|
137
|
-
}else if($try_again == 1 ){
|
138
|
-
return askQuestion("\n-> Cannot be blank! Try again: ");
|
139
|
-
}else{
|
140
|
-
echo "Missing parameter: ".$msg."! Try again. \n";
|
141
|
-
exit;
|
142
|
-
}
|
143
|
-
}
|
144
|
-
|
145
|
-
function askQuestion($p_question){
|
146
|
-
echo $p_question.": ";
|
147
|
-
system('stty -echo');
|
148
|
-
$answer = trim(fgets(STDIN));
|
149
|
-
system('stty echo');
|
150
|
-
$answer = e_check($answer, "Please enter a value.",true);
|
151
|
-
echo "\n";
|
152
|
-
return $answer;
|
153
|
-
}
|
154
|
-
|
155
|
-
function _setup_db(){
|
156
|
-
|
157
|
-
$host = askQuestion("-> What is the DB host?");
|
158
|
-
$username = askQuestion("-> What is the DB Username?");
|
159
|
-
$password = askQuestion("-> What is the DB password?");
|
160
|
-
$dbname = askQuestion("-> What is the DB name?");
|
161
|
-
|
162
|
-
$file = "./www/lib/php/system/Config.php";
|
163
|
-
_SearchandReplaceFILE($file, "%l_host%", $host);
|
164
|
-
_SearchandReplaceFILE($file, "%l_user%", $username);
|
165
|
-
_SearchandReplaceFILE($file, "%l_pass%", $password);
|
166
|
-
_SearchandReplaceFILE($file, "%l_dbname%", $dbname);
|
167
|
-
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
function _replace_namespace(){
|
172
|
-
$stringsearch = "CHANGE_ME";
|
173
|
-
$stringreplace = askQuestion("-> What do you want as the namespace? (no spaces [aA-zZ]) ");
|
174
|
-
$dir = "./";
|
175
|
-
_SearchandReplaceDIR($dir,$stringsearch,$stringreplace);
|
176
|
-
echo "\n";
|
177
|
-
}
|
178
|
-
|
179
|
-
function _setup_tracking(){
|
180
|
-
$tracking_id = askQuestion("-> Google Tracking ID");
|
181
|
-
$file = "./www/lib/php/system/Config.php";
|
182
|
-
_SearchandReplaceFILE($file, "%google_id%", $tracking_id);
|
183
|
-
}
|
184
|
-
|
185
|
-
function _add_section(){
|
186
|
-
|
187
|
-
$section_name = askQuestion("-> Name (no spaces [aA-zZ]) ");
|
188
|
-
// $section_name = ucfirst($section_name);
|
189
|
-
|
190
|
-
// controller
|
191
|
-
$ctrl_startpoint = "./scaffolding/simon/controller.tpl";
|
192
|
-
$ctrl_endpoint = "./www/lib/php/controller/".$section_name.".php";
|
193
|
-
exec ("cp ".$ctrl_startpoint." ".$ctrl_endpoint );
|
194
|
-
_SearchandReplaceFILE($ctrl_endpoint, "%name%", $section_name);
|
195
|
-
|
196
|
-
// view
|
197
|
-
$ctrl_startpoint = "./scaffolding/simon/view.tpl";
|
198
|
-
$ctrl_endpoint = "./www/lib/php/view/".$section_name.".php";
|
199
|
-
exec ("cp ".$ctrl_startpoint." ".$ctrl_endpoint );
|
200
|
-
|
201
|
-
//javascript singleton
|
202
|
-
$ctrl_startpoint = "./scaffolding/standards/js_template.js";
|
203
|
-
$ctrl_endpoint = "./www/lib/js/".$section_name.".js";
|
204
|
-
exec ("cp ".$ctrl_startpoint." ".$ctrl_endpoint );
|
205
|
-
_SearchandReplaceFILE($ctrl_endpoint, "CLASS_NAME", $section_name);
|
206
|
-
_SearchandReplaceFILE("./www/lib/php/template/footer.php", "<!-- END_DEV: javascript -->", "<script src=\"lib/js/".$section_name.".js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n\t<!-- END_DEV: javascript -->");
|
207
|
-
_SearchandReplaceFILE("./www/lib/js/master.js", "*/", "* @depends ".$section_name.".js \n */");
|
208
|
-
|
209
|
-
// routes
|
210
|
-
$routes = "./www/lib/php/system/config.routes.php";
|
211
|
-
$current_routedata = file_get_contents($routes, true);
|
212
|
-
$current_routedata = str_replace("?>", "", $current_routedata);
|
213
|
-
$current_routedata .= "Router::add('/".$section_name."', DIR_CTRL.'/".$section_name.".php');\n ?>";
|
214
|
-
file_put_contents($routes, $current_routedata);
|
215
|
-
|
216
|
-
$resonse = strtolower(askQuestion("Do you want to add a Model? [y/n]"));
|
217
|
-
|
218
|
-
if($resonse === "y"){
|
219
|
-
|
220
|
-
// model
|
221
|
-
$ctrl_startpoint = "./scaffolding/simon/model.tpl";
|
222
|
-
$ctrl_endpoint = "./www/lib/php/model/".$section_name.".php";
|
223
|
-
exec ("cp ".$ctrl_startpoint." ".$ctrl_endpoint );
|
224
|
-
_SearchandReplaceFILE($ctrl_endpoint, "%name%", $section_name);
|
225
|
-
|
226
|
-
}
|
227
|
-
|
228
|
-
}
|
229
|
-
|
230
|
-
function _add_repo(){
|
231
|
-
|
232
|
-
$repo_name = askQuestion("-> What do you want to call the repository? (no spaces [aA-zZ])");
|
233
|
-
$repo_username = askQuestion("-> Beanstalk Username?");
|
234
|
-
$repo_pass = askQuestion("-> Beanstalk Password?");
|
235
|
-
$beanstalkapp_account = askQuestion("-> Beanstalk Account name?");
|
236
|
-
|
237
|
-
$url = "https://".$repo_username.":".$repo_pass."@".$beanstalkapp_account.".beanstalkapp.com/api/repositories.json";
|
238
|
-
|
239
|
-
$data_array = array('repository' => array());
|
240
|
-
$data_array['repository']['name'] = $repo_name;
|
241
|
-
$data_array['repository']['type_id'] = "git";
|
242
|
-
$data_array['repository']['title'] = $repo_name;
|
243
|
-
$data_array['repository']['color_label'] = "label-blue";
|
244
|
-
$data = json_encode($data_array);
|
245
|
-
|
246
|
-
//open connection
|
247
|
-
$ch = curl_init();
|
248
|
-
|
249
|
-
//set the url, number of POST vars, POST data
|
250
|
-
$headers = array('Content-type: application/json');
|
251
|
-
curl_setopt($ch,CURLOPT_USERAGENT,'evolveit');
|
252
|
-
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
253
|
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
254
|
-
curl_setopt($ch,CURLOPT_URL, $url);
|
255
|
-
curl_setopt($ch,CURLOPT_POST, count($data_array));
|
256
|
-
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
|
257
|
-
|
258
|
-
//execute post
|
259
|
-
$result = curl_exec($ch);
|
260
|
-
|
261
|
-
$result = json_decode($result);
|
262
|
-
|
263
|
-
if(!empty($result->errors)){
|
264
|
-
echo $result->errors[0]."\n";
|
265
|
-
exit;
|
266
|
-
}else{
|
267
|
-
$repo_url = $result->git_repository->repository_url;
|
268
|
-
echo "-> Repo location: ".$result->git_repository->repository_url;
|
269
|
-
}
|
270
|
-
|
271
|
-
//close connection
|
272
|
-
curl_close($ch);
|
273
|
-
|
274
|
-
}
|
275
|
-
|
276
|
-
function _sucess_msg(){
|
277
|
-
|
278
|
-
echo "\n-> Simon: Finished! ( ͡° ͜ʖ ͡°) \n";
|
279
|
-
|
280
|
-
}
|
281
|
-
|
282
|
-
?>
|