Skip to content

Commit 2816b28

Browse files
committed
💡 Update skeleton command
1 parent 4a36930 commit 2816b28

File tree

5 files changed

+61
-11
lines changed

5 files changed

+61
-11
lines changed

skeleton/Commands/Available.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Skeleton\Commands;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
use Symfony\Component\Finder\Finder;
9+
10+
class Available extends Command
11+
{
12+
protected function configure(): void
13+
{
14+
$this
15+
->setName('available')
16+
->setDescription('List of all available API skeletons');
17+
}
18+
19+
protected function execute(InputInterface $input, OutputInterface $output): ?int
20+
{
21+
$finder = new Finder();
22+
$folders = $finder->directories()
23+
->in(getcwd() . '/projects')
24+
->depth(0)
25+
->getIterator();
26+
27+
$output->write(PHP_EOL.' <fg=green>Available API skeletons:</>'.PHP_EOL.PHP_EOL);
28+
29+
foreach ($folders as $folder) {
30+
$output->write(' <fg=yellow> - '.$folder->getFilename().'</>'.PHP_EOL);
31+
}
32+
33+
return Command::SUCCESS;
34+
}
35+
}

skeleton/Commands/GenerateProject.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
4949
$output->write(PHP_EOL.' <fg=green>Generating project...</>'.PHP_EOL.PHP_EOL);
5050

5151
$folders = [
52-
".core",
52+
"core",
5353
"app",
5454
"bootstrap",
5555
"config",
@@ -59,6 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
5959
"resources",
6060
"routes",
6161
"storage",
62+
"stubs",
6263
"tests",
6364
];
6465

@@ -92,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
9293

9394
$output->writeln(' <bg=blue;fg=white> INFO 🚀 </> Skeleton API is ready! <options=bold>Build amazing Laravel API.</>'.PHP_EOL);
9495

95-
return 1;
96+
return Command::SUCCESS;
9697
}
9798

9899
protected function verifyProjectDoesntExist($project): void
@@ -101,12 +102,4 @@ protected function verifyProjectDoesntExist($project): void
101102
throw new RuntimeException('Project already exists!');
102103
}
103104
}
104-
105-
protected function replaceInFile(string $search, string $replace, string $file): void
106-
{
107-
file_put_contents(
108-
$file,
109-
str_replace($search, $replace, file_get_contents($file))
110-
);
111-
}
112105
}

skeleton/bin/project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ require __DIR__.'/../../vendor/autoload.php';
88
$app = new Symfony\Component\Console\Application('Laravel API Skeleton', '1.0.0');
99
$app->add(new Skeleton\Commands\GenerateProject);
1010
$app->add(new Skeleton\Commands\UseProject);
11+
$app->add(new Skeleton\Commands\Available);
1112

1213
$app->run();

skeleton/stubs/composer.stub

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"symfony/filesystem": "^6.3"
1818
},
1919
"require-dev": {
20-
"symfony/var-dumper": "^6.3",
2120
"phpstan/phpstan": "^1.10",
2221
"phpunit/phpunit": "^9.6"
2322
},

skeleton/stubs/phpunit.stub

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
beStrictAboutTestsThatDoNotTestAnything="false"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
convertDeprecationsToExceptions="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
processIsolation="false"
12+
stopOnError="false"
13+
stopOnFailure="false"
14+
verbose="true"
15+
>
16+
<testsuites>
17+
<testsuite name="Laravel Installer Test Suite">
18+
<directory suffix="Test.php">./skeleton/tests</directory>
19+
<exclude>./tests/scaffolds</exclude>
20+
</testsuite>
21+
</testsuites>
22+
</phpunit>

0 commit comments

Comments
 (0)