Skip to content

Commit 454114d

Browse files
add git config
1 parent 950ff56 commit 454114d

File tree

1 file changed

+24
-43
lines changed

1 file changed

+24
-43
lines changed

src/App/Script.php

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,28 @@ public static function install(Event $event): void
5656
$installer = new self($event->getIO(), $event->getComposer());
5757

5858
$installer->answers['Service_Name'] = $installer->io->ask("\n <question>>>> What is the 'micro-service' name?</question> [default: <comment>my service</comment>] ", 'my service');
59-
// $installer->answers['Resource_Name'] = $installer->io->ask("\n <question>>>> What is the 'resource' name?</question> [default: <comment>my resource</comment>] ", 'my resource');
60-
// $installer->answers['PHPStorm_Config'] = $installer->io->askConfirmation("\n <question>>>> Are you using PHPStorm? Do you want to auto add Docker image config?</question> (y/n) [default: <comment>yes</comment>] ", true);
61-
// if ($installer->answers['PHPStorm_Config']) {
62-
// $installer->io->write("\n <info>>>> Please provide your AWS credentials</info>");
63-
// $installer->answers['Access_Key_ID'] = $installer->io->ask("\n <question>>>> Access Key ID:</question> ", 'not-provided');
64-
// $installer->answers['Secret_Access_Key'] = $installer->io->ask("\n <question>>>> Secret Access Key:</question> ", 'not-provided');
65-
// $installer->answers['PHPStorm_Config'] = 'yes';
66-
// } else {
67-
// unset($installer->answers['PHPStorm_Config']);
68-
// }
59+
$installer->answers['Resource_Name'] = $installer->io->ask("\n <question>>>> What is the 'resource' name?</question> [default: <comment>my resource</comment>] ", 'my resource');
60+
$installer->answers['PHPStorm_Config'] = $installer->io->askConfirmation("\n <question>>>> Are you using PHPStorm? Do you want to auto add Docker image config?</question> (y/n) [default: <comment>yes</comment>] ", true);
61+
if ($installer->answers['PHPStorm_Config']) {
62+
$installer->io->write("\n <info>>>> Please provide your AWS credentials</info>");
63+
$installer->answers['Access_Key_ID'] = $installer->io->ask("\n <question>>>> Access Key ID:</question> ", 'not-provided');
64+
$installer->answers['Secret_Access_Key'] = $installer->io->ask("\n <question>>>> Secret Access Key:</question> ", 'not-provided');
65+
$installer->answers['PHPStorm_Config'] = 'yes';
66+
} else {
67+
unset($installer->answers['PHPStorm_Config']);
68+
}
6969

7070
$installer->answers['Github_Config'] = $installer->io->askConfirmation("\n <question>>>> Do you want to auto add Github repository?</question> (y/n) [default: <comment>yes</comment>] ", true);
7171
if ($installer->answers['Github_Config']) {
7272
$installer->io->write("\n <info>>>> Please provide your Github configurations</info>");
73-
$installer->answers['Github_Access_Key_Token'] = $installer->io->ask("\n <question>>>> Access Key Token:</question> ", 'c56c839089358145afde1ab47904ce6f072399b1');
73+
$installer->answers['Github_Access_Key_Token'] = $installer->io->ask("\n <question>>>> Access Key Token:</question> ", 'not-provided');
7474
$installer->answers['Github_Team_ID'] = $installer->io->askAndValidate("\n <question>>>> Team ID (numbers only):</question> ", function ($value) {
7575
if (!intval($value)) {
7676
throw new \Exception('Team ID should be number only.');
7777
}
7878

7979
return $value;
80-
}, 1, 2833513);
80+
}, 1);
8181

8282
$installer->answers['Github_Config'] = 'yes';
8383
} else {
@@ -97,13 +97,13 @@ public static function install(Event $event): void
9797
exit(0);
9898
}
9999

100-
// $$installer->replaceFilesContentResource($installer->answers['Resource_Name']);
101-
// $$installer->replaceFilesContentService($installer->answers['Service_Name']);
102-
// $$installer->renameFiles($installer->answers['Resource_Name']);
100+
$installer->replaceFilesContentResource($installer->answers['Resource_Name']);
101+
$installer->replaceFilesContentService($installer->answers['Service_Name']);
102+
$installer->renameFiles($installer->answers['Resource_Name']);
103103

104104
if (isset($installer->answers['PHPStorm_Config'])) {
105105
$installer->io->write("\n <info>>>> Creating PHPStorm Configurations...</info>");
106-
$$installer->addPHPStormConfig();
106+
$installer->addPHPStormConfig();
107107
}
108108

109109
if (isset($installer->answers['Github_Config'])) {
@@ -114,7 +114,7 @@ public static function install(Event $event): void
114114
$installer->finishScript();
115115
}
116116

117-
public function __construct(IOInterface $io, Composer $composer, string $projectRoot = null)
117+
public function __construct(IOInterface $io, Composer $composer)
118118
{
119119
$this->io = $io;
120120
$this->composer = $composer;
@@ -180,6 +180,10 @@ private function finishScript()
180180

181181
unlink('./src/App/docker_image_config.xml');
182182
unlink('./src/App/Script.php');
183+
184+
if (isset($installer->answers['Github_Config'])) {
185+
$this->io->write("\n <info>>>> Your new repository is: {$this->answers['Github_Clone_Url']}</info>");
186+
}
183187
}
184188

185189
private function toCamelCase($string): string
@@ -212,27 +216,6 @@ private function addPHPStormConfig(): void
212216
private function createGithubConfig()
213217
{
214218
$this->createRepository();
215-
$this->execGitCommands();
216-
217-
$this->io->write("\n ::: Your current configuration:");
218-
$this->io->write(" -------------------------------");
219-
foreach ($this->answers as $key => $answer) {
220-
$this->io->write(" ::: {$key}: <info>{$answer}</info>");
221-
}
222-
223-
exit;
224-
}
225-
226-
private function execGitCommands()
227-
{
228-
229-
exec('git init', $output, $return);
230-
exec('git config --local user.name "mobingideployer"', $output, $return);
231-
exec('git config --local user.email "dev@mobingi.com"', $output, $return);
232-
exec('git add .', $output, $return);
233-
exec('git commit -m "first commit"', $output, $return);
234-
exec('git remote add origin ' . $this->answers['Github_SSH_Url'], $output, $return);
235-
exec('git push -u origin master', $output, $return);
236219
}
237220

238221
/**
@@ -265,11 +248,9 @@ private function createRepository()
265248

266249
if ($err) {
267250
throw new \Exception("cURL Error #: {$err}");
268-
} else {
269-
echo $response;
270-
$data = json_decode($response);
271-
272-
$this->answers['Github_SSH_Url'] = $data->ssh_url;
273251
}
252+
253+
$data = json_decode($response);
254+
$this->answers['Github_Clone_Url'] = $data->clone_url;
274255
}
275256
}

0 commit comments

Comments
 (0)