From d8f7cc6202115800b92b89db339cc640d421d603 Mon Sep 17 00:00:00 2001 From: Josh Cirre Date: Tue, 12 Nov 2024 09:36:16 -0700 Subject: [PATCH] push demo --- app/Console/Commands/FissionInstall.php | 192 ------------------ ...1_12_163449_create_pan_analytics_table.php | 31 +++ install.sh | 14 -- package-lock.json | 2 +- 4 files changed, 32 insertions(+), 207 deletions(-) delete mode 100644 app/Console/Commands/FissionInstall.php create mode 100644 database/migrations/2024_11_12_163449_create_pan_analytics_table.php delete mode 100755 install.sh diff --git a/app/Console/Commands/FissionInstall.php b/app/Console/Commands/FissionInstall.php deleted file mode 100644 index c42a5cd..0000000 --- a/app/Console/Commands/FissionInstall.php +++ /dev/null @@ -1,192 +0,0 @@ -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; - } - } -} diff --git a/database/migrations/2024_11_12_163449_create_pan_analytics_table.php b/database/migrations/2024_11_12_163449_create_pan_analytics_table.php new file mode 100644 index 0000000..6a38f65 --- /dev/null +++ b/database/migrations/2024_11_12_163449_create_pan_analytics_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('name'); + + $table->unsignedBigInteger('impressions')->default(0); + $table->unsignedBigInteger('hovers')->default(0); + $table->unsignedBigInteger('clicks')->default(0); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('pan_analytics'); + } +}; diff --git a/install.sh b/install.sh deleted file mode 100755 index b342b9e..0000000 --- a/install.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 diff --git a/package-lock.json b/package-lock.json index 64b81ef..d1f0d76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "fission", + "name": "clouddemo", "lockfileVersion": 3, "requires": true, "packages": {