Skip to content

Commit

Permalink
Merge pull request #1 from 24aitor/master
Browse files Browse the repository at this point in the history
Creation of REAMDE.md and LICENSE
  • Loading branch information
ConsoleTVs authored Aug 23, 2017
2 parents a1577a1 + f41e3a0 commit 38c6bce
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
39 changes: 32 additions & 7 deletions src/Commands/BootpackCreatePackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,14 @@ public function handle()

$this->table(array_keys(get_object_vars($package)), [get_object_vars($package)]);

while(!$this->confirm('Everything looks cool?', 'yes')) {
while (!$this->confirm('Everything looks cool?', 'yes')) {
$this->comment('Woah! Let me ask you everything again!');

$package = $this->package($name);

$this->comment('Great, confirm the following data before we go ahead!');

$this->table(array_keys(get_object_vars($package)), [get_object_vars($package)]);

};

$this->comment('Fantastic! Let me create the composer.json for your...');
Expand Down Expand Up @@ -127,10 +126,11 @@ public function handle()
$this->comment('Hey we are almost done with this! Let me add the class loader to the current composer project...');

$l_composer = json_decode(file_get_contents(base_path('composer.json')), true);
$l_composer['autoload']['psr-4'][$package->namespace . '\\'] = str_replace(base_path() . '/', '', $path) . '/src';
file_put_contents(base_path('composer.json'), json_encode($l_composer,
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
));
$l_composer['autoload']['psr-4'][$package->namespace.'\\'] = str_replace(base_path().'/', '', $path).'/src';
file_put_contents(
base_path('composer.json'),
json_encode($l_composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
);

$this->info('Your main composer.json file has been updated.');
$this->comment('Seems like the only thing left is to dump the composer autoload...');
Expand All @@ -155,6 +155,32 @@ public function handle()
$this->line('Pleae manually dump the autoload: composer dump-autoload');
}

if ($this->confirm('Do you want to create REAMDE.md?', 'yes')) {
$this->comment('Creating REAMDE.md...');

$readme = fopen("$path/README.md", "w");
fwrite($readme, "# $package->name\n\n$package->description");
fclose($readme);

$this->info('Very cool! The REAMDE.md has been created!');
} else {
$this->line('Skipping the creation of REAMDE.md...');
}

$this->comment('Searching for license File...');

$licenses = scandir(__DIR__ . '/../Licenses');

if (in_array($package->license, $licenses)) {
copy(__DIR__ . "/../Licenses/$package->license", "$path/LICENSE");
Helpers::strReplaceFile('{{ YEAR }}', date('Y'), "$path/LICENSE");
Helpers::strReplaceFile('{{ AUTHOR }}', $package->author, "$path/LICENSE");
$this->info('Nice! The LICENSE file is ready!');
} else {
$this->error("Whoops! The License of your package is unknown for Bootpack so cannot be created automatically");
}


if ($this->confirm('Do you want to continue? Make sure the auto-load was dumped', 'yes')) {
$this->comment('Registering the service provider in the current laravel application...');

Expand Down Expand Up @@ -186,7 +212,6 @@ public function handle()
$this->info('Aborted package extra steps...');
$this->line('Package location: ' . $path);
}

} else {
$this->error("The folder '{$path}' already exists");
}
Expand Down
21 changes: 21 additions & 0 deletions src/Licenses/MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) {{ YEAR }} {{ AUTHOR }}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

0 comments on commit 38c6bce

Please sign in to comment.