Skip to content

Commit

Permalink
update install command to use stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
inmanturbo committed Feb 24, 2024
1 parent ad7a0a6 commit f209ef0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/Commands/JetstreamPassportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace HeaderX\JetstreamPassport\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;

class JetstreamPassportCommand extends Command
{
Expand All @@ -16,5 +17,42 @@ public function handle()
$this->call('passport:keys');
$this->call('passport:install', ['--uuids']);
$this->call('passport:client', ['--personal' => true, '--name' => 'Laravel Personal Access Client']);

$this->replaceInFile('Laravel\\Sanctum\\HasApiTokens' , 'Laravel\\Passport\\HasApiTokens', app_path('Models/User.php'));

$this->copyFiles();
}

/**
* Replace a given string within a given file.
*
* @param string $search
* @param string $replace
* @param string $path
* @return void
*/
protected function replaceInFile($search, $replace, $path)
{
file_put_contents($path, str_replace($search, $replace, file_get_contents($path)));
}

protected function copyFiles()
{
$this->info('Copying files...');

$sourceDir = realpath(__DIR__.'/../../stubs/');
$destinationDir = base_path();

$files = File::allFiles($sourceDir);

foreach ($files as $file) {
$destinationFilePath = $destinationDir.'/'.$file->getRelativePathname();
File::ensureDirectoryExists(dirname($destinationFilePath));
File::copy($sourceFile = $file->getPathname(), $destinationFilePath);
// check verbosity
if ($this->output->isVerbose()) {
$this->line('<info>Copied</info> '.$sourceFile.' <info>to</info> '.$destinationFilePath);
}
}
}
}
2 changes: 1 addition & 1 deletion stubs/config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'driver' => 'session',
'provider' => 'users',
],

'api' => [
'driver' => 'passport',
'provider' => 'users',
Expand Down
24 changes: 24 additions & 0 deletions stubs/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import defaultTheme from 'tailwindcss/defaultTheme';
import forms from '@tailwindcss/forms';
import typography from '@tailwindcss/typography';

/** @type {import('tailwindcss').Config} */
export default {
content: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./vendor/headerx/laravel-jetstream-passport/resources/views/**/*.blade.php',
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],

theme: {
extend: {
fontFamily: {
sans: ['Figtree', ...defaultTheme.fontFamily.sans],
},
},
},

plugins: [forms, typography],
};

0 comments on commit f209ef0

Please sign in to comment.