@@ -12,9 +12,9 @@ |
||
12 | 12 | */ |
13 | 13 | class Event extends BaseThing implements EventInterface |
14 | 14 | { |
15 | - /** |
|
16 | - * @inheritdoc |
|
17 | - */ |
|
15 | + /** |
|
16 | + * @inheritdoc |
|
17 | + */ |
|
18 | 18 | public function typeDefintion() |
19 | 19 | { |
20 | 20 | return 'Event'; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * Display config data and location. |
25 | 25 | * |
26 | - * @return boolean|void |
|
26 | + * @return integer|null |
|
27 | 27 | */ |
28 | 28 | public function actionConfigInfo() |
29 | 29 | { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * Save a value in the config for a given key. |
74 | 74 | * |
75 | 75 | * @param string $key |
76 | - * @param mixed $value |
|
76 | + * @param string $value |
|
77 | 77 | * @return mixed |
78 | 78 | */ |
79 | 79 | protected function saveConfig($key, $value) |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class BaseDevCommand extends Command |
17 | 17 | { |
18 | - /** |
|
19 | - * @var string The location of the devconfig json where data is stored. |
|
20 | - */ |
|
18 | + /** |
|
19 | + * @var string The location of the devconfig json where data is stored. |
|
20 | + */ |
|
21 | 21 | public $configFile = '@appFolder/devconfig.json'; |
22 | 22 | |
23 | 23 | /** |
@@ -27,17 +27,17 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function actionConfigInfo() |
29 | 29 | { |
30 | - $this->outputInfo("dev config file: " . Yii::getAlias($this->configFile)); |
|
30 | + $this->outputInfo("dev config file: " . Yii::getAlias($this->configFile)); |
|
31 | 31 | |
32 | - $config = $this->readConfig(); |
|
32 | + $config = $this->readConfig(); |
|
33 | 33 | |
34 | - if (!$config) { |
|
35 | - return $this->outputError("Unable to open config file."); |
|
36 | - } |
|
34 | + if (!$config) { |
|
35 | + return $this->outputError("Unable to open config file."); |
|
36 | + } |
|
37 | 37 | |
38 | - foreach ($config as $key => $value) { |
|
39 | - $this->output("{$key} => {$value}"); |
|
40 | - } |
|
38 | + foreach ($config as $key => $value) { |
|
39 | + $this->output("{$key} => {$value}"); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function actionConfigInfo() |
29 | 29 | { |
30 | - $this->outputInfo("dev config file: " . Yii::getAlias($this->configFile)); |
|
30 | + $this->outputInfo("dev config file: ".Yii::getAlias($this->configFile)); |
|
31 | 31 | |
32 | 32 | $config = $this->readConfig(); |
33 | 33 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $save = FileHelper::writeFile($this->configFile, Json::encode($content)); |
90 | 90 | |
91 | 91 | if (!$save) { |
92 | - return $this->outputError("Unable to find config file " . $this->configFile. ". Please create and provide Permissions."); |
|
92 | + return $this->outputError("Unable to find config file ".$this->configFile.". Please create and provide Permissions."); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $value; |
@@ -192,6 +192,10 @@ discard block |
||
192 | 192 | return $this->_gitWrapper; |
193 | 193 | } |
194 | 194 | |
195 | + /** |
|
196 | + * @param boolean $isFork |
|
197 | + * @param boolean $exists |
|
198 | + */ |
|
195 | 199 | private function summaryItem($repo, $isFork, $exists) |
196 | 200 | { |
197 | 201 | return [$repo, $exists, $isFork]; |
@@ -202,6 +206,9 @@ discard block |
||
202 | 206 | return 'repos' . DIRECTORY_SEPARATOR . $repo; |
203 | 207 | } |
204 | 208 | |
209 | + /** |
|
210 | + * @param string|boolean $username |
|
211 | + */ |
|
205 | 212 | private function forkExists($username, $repo) |
206 | 213 | { |
207 | 214 | return (new Curl())->get('https://api.github.com/repos/'.$username.'/'.$repo)->isSuccess(); |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class RepoController extends BaseDevCommand |
33 | 33 | { |
34 | - const CONFIG_VAR_USERNAME = 'username'; |
|
34 | + const CONFIG_VAR_USERNAME = 'username'; |
|
35 | 35 | |
36 | - const CONFIG_VAR_CLONETYPE = 'cloneType'; |
|
36 | + const CONFIG_VAR_CLONETYPE = 'cloneType'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var string Default action is actionInit(); |
|
40 | - */ |
|
41 | - public $defaultAction = 'init'; |
|
38 | + /** |
|
39 | + * @var string Default action is actionInit(); |
|
40 | + */ |
|
41 | + public $defaultAction = 'init'; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var array The default repos from luyadev |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var array The default repos from luyadev |
|
45 | + */ |
|
46 | 46 | public $repos = [ |
47 | 47 | 'luya', |
48 | 48 | 'luya-module-admin', |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function actionClone($repo = null, $vendor = null) |
168 | 168 | { |
169 | - if (empty($repo)) { |
|
170 | - $repo = $this->prompt("Enter the name of the repo you like to clone (e.g. luya-module-news)"); |
|
171 | - } |
|
169 | + if (empty($repo)) { |
|
170 | + $repo = $this->prompt("Enter the name of the repo you like to clone (e.g. luya-module-news)"); |
|
171 | + } |
|
172 | 172 | |
173 | - if (empty($vendor)) { |
|
174 | - $vendor = $this->prompt("Enter the username/vendor for this repo (e.g. luyadev)"); |
|
175 | - } |
|
173 | + if (empty($vendor)) { |
|
174 | + $vendor = $this->prompt("Enter the username/vendor for this repo (e.g. luyadev)"); |
|
175 | + } |
|
176 | 176 | |
177 | - return $this->cloneRepo($repo, $this->getCloneUrlBasedOnType($repo, $vendor), $this->getFilesystemRepoPath($repo), $vendor); |
|
177 | + return $this->cloneRepo($repo, $this->getCloneUrlBasedOnType($repo, $vendor), $this->getFilesystemRepoPath($repo), $vendor); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | private $_gitWrapper; |
@@ -184,38 +184,38 @@ discard block |
||
184 | 184 | */ |
185 | 185 | protected function getGitWrapper() |
186 | 186 | { |
187 | - if ($this->_gitWrapper === null) { |
|
188 | - $this->_gitWrapper = new GitWrapper(); |
|
189 | - $this->_gitWrapper->setTimeout(300); |
|
190 | - } |
|
187 | + if ($this->_gitWrapper === null) { |
|
188 | + $this->_gitWrapper = new GitWrapper(); |
|
189 | + $this->_gitWrapper->setTimeout(300); |
|
190 | + } |
|
191 | 191 | |
192 | - return $this->_gitWrapper; |
|
192 | + return $this->_gitWrapper; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | private function summaryItem($repo, $isFork, $exists) |
196 | 196 | { |
197 | - return [$repo, $exists, $isFork]; |
|
197 | + return [$repo, $exists, $isFork]; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | private function getFilesystemRepoPath($repo) |
201 | 201 | { |
202 | - return 'repos' . DIRECTORY_SEPARATOR . $repo; |
|
202 | + return 'repos' . DIRECTORY_SEPARATOR . $repo; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | private function forkExists($username, $repo) |
206 | 206 | { |
207 | - return (new Curl())->get('https://api.github.com/repos/'.$username.'/'.$repo)->isSuccess(); |
|
207 | + return (new Curl())->get('https://api.github.com/repos/'.$username.'/'.$repo)->isSuccess(); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | private function markdown($text, $paragraph = false) |
211 | 211 | { |
212 | - $parser = new Markdown(); |
|
212 | + $parser = new Markdown(); |
|
213 | 213 | |
214 | - if ($paragraph) { |
|
215 | - return $parser->parseParagraph($text); |
|
216 | - } |
|
214 | + if ($paragraph) { |
|
215 | + return $parser->parseParagraph($text); |
|
216 | + } |
|
217 | 217 | |
218 | - return $parser->parse($text); |
|
218 | + return $parser->parse($text); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | private function getCloneUrlBasedOnType($repo, $username) |
229 | 229 | { |
230 | - return ($this->getConfig(self::CONFIG_VAR_CLONETYPE) == 'ssh') ? "[email protected]:{$username}/{$repo}.git" : "https://github.com/{$username}/{$repo}.git"; |
|
230 | + return ($this->getConfig(self::CONFIG_VAR_CLONETYPE) == 'ssh') ? "[email protected]:{$username}/{$repo}.git" : "https://github.com/{$username}/{$repo}.git"; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | */ |
241 | 241 | private function cloneRepo($repo, $cloneUrl, $newRepoHome, $upstreamUsername) |
242 | 242 | { |
243 | - $this->outputSuccess("{$repo}: cloning ..."); |
|
244 | - $this->getGitWrapper()->cloneRepository($cloneUrl, $newRepoHome); |
|
245 | - if (!empty($upstreamUsername)) { |
|
246 | - $this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git', $newRepoHome); |
|
247 | - $this->outputInfo("Configure upstream https://github.com/{$upstreamUsername}/{$repo}.git"); |
|
248 | - } |
|
249 | - $this->outputSuccess("{$repo}: ✔ complete"); |
|
243 | + $this->outputSuccess("{$repo}: cloning ..."); |
|
244 | + $this->getGitWrapper()->cloneRepository($cloneUrl, $newRepoHome); |
|
245 | + if (!empty($upstreamUsername)) { |
|
246 | + $this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git', $newRepoHome); |
|
247 | + $this->outputInfo("Configure upstream https://github.com/{$upstreamUsername}/{$repo}.git"); |
|
248 | + } |
|
249 | + $this->outputSuccess("{$repo}: ✔ complete"); |
|
250 | 250 | } |
251 | 251 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | // generate summary overview |
89 | 89 | foreach ($this->repos as $repo) { |
90 | 90 | $newRepoHome = $this->getFilesystemRepoPath($repo); |
91 | - if (file_exists($newRepoHome . DIRECTORY_SEPARATOR . '.git')) { |
|
91 | + if (file_exists($newRepoHome.DIRECTORY_SEPARATOR.'.git')) { |
|
92 | 92 | $summary[] = $this->summaryItem($repo, false, true); |
93 | 93 | } elseif ($this->forkExists($username, $repo)) { |
94 | 94 | $summary[] = $this->summaryItem($repo, true, false); |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | $wrapper = new GitWrapper(); |
148 | 148 | |
149 | 149 | foreach ($this->repos as $repo) { |
150 | - $wrapper->git('checkout master', 'repos' . DIRECTORY_SEPARATOR . $repo); |
|
150 | + $wrapper->git('checkout master', 'repos'.DIRECTORY_SEPARATOR.$repo); |
|
151 | 151 | $this->outputInfo("{$repo}: checkout master ✔"); |
152 | 152 | |
153 | - $wrapper->git('fetch upstream', 'repos' . DIRECTORY_SEPARATOR . $repo); |
|
153 | + $wrapper->git('fetch upstream', 'repos'.DIRECTORY_SEPARATOR.$repo); |
|
154 | 154 | $this->outputInfo("{$repo}: fetch upstream ✔"); |
155 | 155 | |
156 | - $wrapper->git('rebase upstream/master master', 'repos' . DIRECTORY_SEPARATOR . $repo); |
|
156 | + $wrapper->git('rebase upstream/master master', 'repos'.DIRECTORY_SEPARATOR.$repo); |
|
157 | 157 | $this->outputInfo("{$repo}: rebase master ✔"); |
158 | 158 | } |
159 | 159 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | private function getFilesystemRepoPath($repo) |
201 | 201 | { |
202 | - return 'repos' . DIRECTORY_SEPARATOR . $repo; |
|
202 | + return 'repos'.DIRECTORY_SEPARATOR.$repo; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | private function forkExists($username, $repo) |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->outputSuccess("{$repo}: cloning ..."); |
244 | 244 | $this->getGitWrapper()->cloneRepository($cloneUrl, $newRepoHome); |
245 | 245 | if (!empty($upstreamUsername)) { |
246 | - $this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git', $newRepoHome); |
|
246 | + $this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git', $newRepoHome); |
|
247 | 247 | $this->outputInfo("Configure upstream https://github.com/{$upstreamUsername}/{$repo}.git"); |
248 | 248 | } |
249 | 249 | $this->outputSuccess("{$repo}: ✔ complete"); |