-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit d8f7cc6.
- Loading branch information
Showing
4 changed files
with
207 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\File; | ||
|
||
use function Laravel\Prompts\confirm; | ||
use function Laravel\Prompts\info; | ||
use function Laravel\Prompts\text; | ||
use function Laravel\Prompts\warning; | ||
|
||
class FissionInstall extends Command | ||
{ | ||
protected $signature = 'fission:install {name? : The project name}'; | ||
|
||
protected $description = 'Run the Fission installation process'; | ||
|
||
private $authJsonExists = false; | ||
|
||
private $additionalPackages = []; | ||
|
||
public function handle() | ||
{ | ||
app()->detectEnvironment(function () { | ||
return 'local'; | ||
}); | ||
|
||
info('Starting Fission installation...'); | ||
|
||
$this->copyAuthJson(); | ||
|
||
// Run npm install | ||
if (! File::exists('node_modules')) { | ||
info('Running npm install...'); | ||
exec('npm install'); | ||
} else { | ||
warning('Node modules already exist. Skipping npm install.'); | ||
} | ||
|
||
// Run flux:activate only if auth.json doesn't exist | ||
if (! $this->authJsonExists) { | ||
info('Activating Flux...'); | ||
$this->call('flux:activate'); | ||
} else { | ||
info('auth.json found. Skipping Flux manual activation.'); | ||
} | ||
|
||
$this->setupEnvFile(); | ||
$this->reloadEnvironment(); | ||
$this->generateAppKey(); | ||
$this->runMigrations(); | ||
$this->installPan(); | ||
$this->setProjectName(); | ||
|
||
$this->cleanup(); | ||
|
||
info('Fission installation completed successfully! ☢️'); | ||
info('👉 Run `php artisan solo` or `composer run dev` to start the local server.'); | ||
info('Keep creating. 🫡'); | ||
} | ||
|
||
private function setupEnvFile() | ||
{ | ||
info('Setting up .env file...'); | ||
if (! File::exists('.env')) { | ||
File::copy('.env.example', '.env'); | ||
info('.env file created successfully.'); | ||
} else { | ||
warning('.env file already exists. Skipping creation.'); | ||
} | ||
|
||
// Ensure APP_ENV is set to local | ||
$envContent = File::get('.env'); | ||
if (! preg_match('/^APP_ENV=/', $envContent)) { | ||
$this->updateEnv('APP_ENV', 'local'); | ||
info('APP_ENV set to local.'); | ||
} else { | ||
$envContent = preg_replace('/^APP_ENV=(.*)$/m', 'APP_ENV=local', $envContent); | ||
$this->updateEnv('APP_ENV', 'local'); | ||
info('APP_ENV updated to local.'); | ||
} | ||
} | ||
|
||
private function generateAppKey() | ||
{ | ||
info('Checking application key...'); | ||
if (empty(env('APP_KEY'))) { | ||
$this->call('key:generate'); | ||
} else { | ||
warning('Application key already exists. Skipping.'); | ||
} | ||
} | ||
|
||
private function runMigrations() | ||
{ | ||
if (confirm('Do you want to run database migrations?', true)) { | ||
info('Running database migrations...'); | ||
$this->call('migrate', [ | ||
'--force' => true, // This will bypass the production check | ||
]); | ||
} | ||
} | ||
|
||
private function setProjectName() | ||
{ | ||
$defaultName = $this->argument('name') ?: basename(getcwd()); | ||
$name = text( | ||
label: 'What is the name of your project?', | ||
placeholder: $defaultName, | ||
default: $defaultName, | ||
required: true | ||
); | ||
|
||
$this->updateEnv('APP_NAME', $name); | ||
|
||
$defaultUrl = 'http://localhost:8000'; | ||
$url = text( | ||
label: 'What is the URL of your project?', | ||
placeholder: $defaultUrl, | ||
default: $defaultUrl, | ||
required: true | ||
); | ||
|
||
$this->updateEnv('APP_URL', $url); | ||
} | ||
|
||
private function updateEnv($key, $value) | ||
{ | ||
$path = base_path('.env'); | ||
|
||
if (File::exists($path)) { | ||
file_put_contents($path, preg_replace( | ||
"/^{$key}=.*/m", | ||
"{$key}=\"{$value}\"", | ||
file_get_contents($path) | ||
)); | ||
} | ||
} | ||
|
||
private function cleanup() | ||
{ | ||
if (confirm('Do you want to remove the installation files?', true)) { | ||
info('Removing installation files...'); | ||
|
||
// Remove the entire Commands folder | ||
File::deleteDirectory(app_path('Console')); | ||
|
||
// Remove the install.sh script | ||
File::delete(base_path('install.sh')); | ||
|
||
info('Installation files removed.'); | ||
} else { | ||
info('Installation files kept. You can manually remove them later if needed.'); | ||
} | ||
} | ||
|
||
private function reloadEnvironment() | ||
{ | ||
$app = app(); | ||
$app->bootstrapWith([ | ||
\Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class, | ||
]); | ||
} | ||
|
||
private function installPan() | ||
{ | ||
$this->call('install:pan'); | ||
} | ||
|
||
private function copyAuthJson() | ||
{ | ||
$sourceAuthJson = $_SERVER['HOME'].'/Code/flux-auth.json'; | ||
$destinationAuthJson = base_path('auth.json'); | ||
|
||
if (File::exists($sourceAuthJson)) { | ||
info('Found auth.json in ~/Code/ directory. Copying to application...'); | ||
File::copy($sourceAuthJson, $destinationAuthJson); | ||
info('auth.json copied successfully.'); | ||
|
||
// Run composer install again to ensure Flux Pro is properly installed | ||
info('Running composer install to activate Flux Pro...'); | ||
exec('composer install'); | ||
info('Flux Pro activated.'); | ||
|
||
$this->authJsonExists = true; | ||
} else { | ||
warning('No preset auth.json found. You can add your credentials for Flux in a bit.'); | ||
$this->authJsonExists = false; | ||
} | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
database/migrations/2024_11_12_163449_create_pan_analytics_table.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Ensure script is run from the project root | ||
if [ ! -f "composer.json" ]; then | ||
echo "Please run this script from the project root directory." | ||
exit 1 | ||
fi | ||
|
||
# Run composer install | ||
echo "Installing Composer dependencies..." | ||
composer install | ||
|
||
# Run the Fission installation | ||
php artisan fission:install |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.