Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit 7b69a3e

Browse files
committed
adapt to new structure
1 parent 7bb0e50 commit 7b69a3e

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

php-saas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (file_exists(__DIR__.'/../../autoload.php')) {
77
require __DIR__.'/vendor/autoload.php';
88
}
99

10-
$app = new Symfony\Component\Console\Application('PHP-SaaS Cli', '0.5.0');
10+
$app = new Symfony\Component\Console\Application('PHP-SaaS Cli', '0.6.0');
1111
$app->add(new PHPSaaS\Cli\NewCommand);
1212

1313
$app->run();

src/NewCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class NewCommand extends Command
3434

3535
protected string $name = '';
3636

37+
protected string $tmpPath = '';
38+
3739
protected string $path = '';
3840

3941
protected string $frontend = '';
@@ -80,6 +82,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8082

8183
$this->path = getcwd().'/'.$this->name;
8284

85+
$this->tmpPath = sys_get_temp_dir().'/php-saas-'.str_replace(' ', '-', strtolower($this->name)).'-'.time();
86+
8387
$this->collectInputs();
8488

8589
// setup modules

src/Traits/Application.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ protected function setupApplication(): void
1515
$repositoryUrl = '[email protected]:php-saas/php-saas.git';
1616

1717
$this->runCommands([
18-
"git clone {$repositoryUrl} {$this->path}",
18+
"git clone {$repositoryUrl} {$this->tmpPath}",
1919
]);
2020

21+
$this->fileSystem->moveDirectory($this->tmpPath.'/laravel', $this->path);
22+
2123
if (! file_exists($this->path.'/.env')) {
2224
$this->fileSystem->copy($this->path.'/.env.example', $this->path.'/.env');
2325
}
@@ -30,9 +32,6 @@ protected function setupApplication(): void
3032

3133
protected function cleanupApplication(): void
3234
{
33-
$this->fileSystem->deleteDirectory($this->path.'/.github');
34-
$this->fileSystem->deleteDirectory($this->path.'/.git');
35-
$this->fileSystem->delete($this->path.'/.gitignore');
36-
$this->fileSystem->move($this->path.'/.gitignore.final', $this->path.'/.gitignore');
35+
//
3736
}
3837
}

src/Traits/Frontend.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@ protected function setupFrontend(): void
1212
throw new RuntimeException('Vue stack is not supported yet.');
1313
}
1414

15-
$renames = [
16-
'resources/js-%s' => 'resources/js',
17-
'vite-%s.config.ts' => 'vite.config.ts',
18-
'tsconfig-%s.json' => 'tsconfig.json',
19-
'eslint-%s.config.js' => 'eslint.config.js',
20-
'package-%s.json' => 'package.json',
21-
];
22-
23-
foreach ($renames as $from => $to) {
24-
$from = $this->path.'/'.sprintf($from, strtolower($this->frontend));
25-
$to = $this->path.'/'.sprintf($to, strtolower($this->frontend));
15+
$this->fileSystem->moveDirectory($this->tmpPath.'/'.$this->frontend.'/src', $this->path.'/resources/js');
2616

27-
if (! $this->fileSystem->exists($from)) {
28-
throw new RuntimeException("File {$from} does not exist. Please check the template.");
29-
}
17+
$filesToCopy = [
18+
'vite.config.ts',
19+
'tsconfig.json',
20+
'eslint.config.js',
21+
'package.json',
22+
];
3023

31-
$this->fileSystem->move($from, $to);
24+
foreach ($filesToCopy as $file) {
25+
$this->fileSystem->copy($this->tmpPath.'/'.$this->frontend.'/'.$file, $this->path.'/'.$file);
3226
}
3327
}
3428

3529
protected function cleanupFrontend(): void
3630
{
37-
$this->fileSystem->deleteDirectory($this->path.'/resources/js-vue');
38-
$this->fileSystem->deleteDirectory($this->path.'/resources/js-react');
31+
//
3932
}
4033
}

0 commit comments

Comments
 (0)