Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Domains/Cloud/new repo/console/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace CloudinaryLabs\CloudinaryLaravel\Console;

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

class InstallCommand extends Command
{
protected $signature = 'cloudinary:install';

protected $description = 'Install the Cloudinary Laravel SDK';

public function handle()
{
if ($this->callSilently('vendor:publish', ['--tag' => 'cloudinary-config']) === 0) {
$this->info('Configuration published successfully.');
}

match ($this->getDependencies()) {
'react' => $this->call('cloudinary:react'),
'vue' => $this->call('cloudinary:vue'),
'svelte' => $this->call('cloudinary:svelte'),
default => $this->info('No JavaScript framework detected.'),
};
}

private function getDependencies(): ?string
{
$package = json_decode(File::get(base_path('package.json')), true);

$dependencies = array_merge(
$package['dependencies'] ?? [],
$package['devDependencies'] ?? []
);

if (isset($dependencies['@vitejs/plugin-react'])) {
return 'react';
}

if (isset($dependencies['@vitejs/plugin-vue'])) {
return 'vue';
}

if (isset($dependencies['@sveltejs/vite-plugin-svelte'])) {
return 'svelte';
}

return null;
}
}

30 changes: 30 additions & 0 deletions Domains/Cloud/new repo/console/React.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace CloudinaryLabs\CloudinaryLaravel\Console;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;

class ReactCommand extends Command
{
protected $signature = 'cloudinary:react';

protected $description = 'Install the React SDK';

protected $hidden = true;

public function handle()
{
$this->info('Installing Cloudinary React SDK...');

$process = new Process(['npm', 'install', '@cloudinary/react', '@cloudinary/url-gen']);

$process->run(function ($type, $line) {
$this->output->write($line);
});

$this->line(' ');
$this->info('Cloudinary React SDK installed successfully.');
$this->line('Read getting started: https://cloudinary.com/documentation/react_quick_start');
}
}
30 changes: 30 additions & 0 deletions Domains/Cloud/new repo/console/SvelteCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace CloudinaryLabs\CloudinaryLaravel\Console;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;

class SvelteCommand extends Command
{
protected $signature = 'cloudinary:svelte';

protected $description = 'Install the Svelte SDK';

protected $hidden = true;

public function handle()
{
$this->info('Installing Cloudinary Svelte SDK...');

$process = new Process(['npm', 'install', 'svelte-cloudinary']);

$process->run(function ($type, $line) {
$this->output->write($line);
});

$this->line(' ');
$this->info('Cloudinary Svelte SDK installed successfully.');
$this->line('Read getting started: https://svelte.cloudinary.dev/get-started');
}
}
30 changes: 30 additions & 0 deletions Domains/Cloud/new repo/console/VueCommmand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace CloudinaryLabs\CloudinaryLaravel\Console;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;

class SvelteCommand extends Command
{
protected $signature = 'cloudinary:svelte';

protected $description = 'Install the Svelte SDK';

protected $hidden = true;

public function handle()
{
$this->info('Installing Cloudinary Svelte SDK...');

$process = new Process(['npm', 'install', 'svelte-cloudinary']);

$process->run(function ($type, $line) {
$this->output->write($line);
});

$this->line(' ');
$this->info('Cloudinary Svelte SDK installed successfully.');
$this->line('Read getting started: https://svelte.cloudinary.dev/get-started');
}
}
Loading