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
6 changes: 6 additions & 0 deletions .easytree.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"scripts": [
"composer install",
"cp $PROJECT_PATH/.env .env"
]
Comment on lines +2 to +5
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file appears to be unrelated to the PR's purpose of adding NodeJS website support using mise. The .easytree.json configuration seems to be a project setup file that was accidentally included in this pull request. Consider removing it if it's not intentionally part of this change.

Suggested change
"scripts": [
"composer install",
"cp $PROJECT_PATH/.env .env"
]

Copilot uses AI. Check for mistakes.
}
4 changes: 3 additions & 1 deletion app/Actions/Worker/CreateWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function create(Server $server, array $input, ?Site $site = null): Worker
'auto_start' => $input['auto_start'] ? 1 : 0,
'auto_restart' => $input['auto_restart'] ? 1 : 0,
'numprocs' => $input['numprocs'],
'environment' => $input['environment'] ?? null,
'status' => WorkerStatus::CREATING,
]);
$worker->save();
Expand All @@ -56,7 +57,8 @@ public function create(Server $server, array $input, ?Site $site = null): Worker
$worker->numprocs,
$worker->getLogFile(),
$worker->site?->path,
$worker->site_id
$worker->site_id,
$worker->environment,
);
$worker->status = WorkerStatus::RUNNING;
$worker->save();
Expand Down
56 changes: 56 additions & 0 deletions app/Enums/NodePackageManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App\Enums;

use App\Contracts\VitoEnum;
use App\Traits\HasEnumHelpers;

enum NodePackageManager: string implements VitoEnum
{
use HasEnumHelpers;

case Npm = 'npm';
case Pnpm = 'pnpm';
case Yarn = 'yarn';

public function getColor(): string
{
return 'default';
}

public function getText(): string
{
return match ($this) {
self::Npm => 'npm',
self::Pnpm => 'pnpm',
self::Yarn => 'yarn',
};
}

public function installCommand(): string
{
return match ($this) {
self::Npm => 'npm install',
self::Pnpm => 'pnpm install',
self::Yarn => 'yarn install',
};
}

public function buildCommand(): string
{
return match ($this) {
self::Npm => 'npm run build',
self::Pnpm => 'pnpm run build',
self::Yarn => 'yarn build',
};
}

public function startCommand(): string
{
return match ($this) {
self::Npm => 'npm start',
self::Pnpm => 'pnpm start',
self::Yarn => 'yarn start',
};
}
}
3 changes: 3 additions & 0 deletions app/Models/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @property bool $auto_start
* @property bool $auto_restart
* @property int $numprocs
* @property ?array<string, string> $environment
* @property int $redirect_stderr
* @property string $stdout_logfile
* @property WorkerStatus $status
Expand All @@ -38,6 +39,7 @@ class Worker extends AbstractModel
'auto_start',
'auto_restart',
'numprocs',
'environment',
'redirect_stderr',
'stdout_logfile',
'status',
Expand All @@ -50,6 +52,7 @@ class Worker extends AbstractModel
'auto_start' => 'boolean',
'auto_restart' => 'boolean',
'numprocs' => 'integer',
'environment' => 'array',
'redirect_stderr' => 'boolean',
'status' => WorkerStatus::class,
];
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/ServiceTypeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private function node(): void
{
RegisterServiceType::make(NodeJS::id())
->type(NodeJS::type())
->label('Node.js')
->label('Node.js (Deprecated)')
->handler(NodeJS::class)
->versions([
'22',
Expand Down
51 changes: 50 additions & 1 deletion app/Providers/SiteTypeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
use App\DTOs\DynamicField;
use App\DTOs\DynamicForm;
use App\Enums\LoadBalancerMethod;
use App\Enums\NodePackageManager;
use App\Plugins\RegisterSiteFeature;
use App\Plugins\RegisterSiteFeatureAction;
use App\Plugins\RegisterSiteType;
use App\SiteTypes\Laravel;
use App\SiteTypes\LoadBalancer;
use App\SiteTypes\MiseNodeJS;
use App\SiteTypes\NodeJS;
use App\SiteTypes\PHPBlank;
use App\SiteTypes\PHPMyAdmin;
Expand All @@ -27,6 +29,7 @@ public function boot(): void
$this->phpBlank();
$this->laravel();
$this->nodeJS();
$this->miseNodeJS();
$this->loadBalancer();
$this->phpMyAdmin();
$this->wordpress();
Expand Down Expand Up @@ -135,7 +138,7 @@ private function laravel(): void
private function nodeJS(): void
{
RegisterSiteType::make(NodeJS::id())
->label('NodeJS with NPM')
->label('NodeJS with NPM (Deprecated)')
->handler(NodeJS::class)
->form(DynamicForm::make([
DynamicField::make('source_control')
Expand All @@ -159,6 +162,52 @@ private function nodeJS(): void
->register();
}

private function miseNodeJS(): void
{
RegisterSiteType::make(MiseNodeJS::id())
->label('Node.js')
->handler(MiseNodeJS::class)
->form(DynamicForm::make([
DynamicField::make('node_version')
->select()
->label('Node.js Version')
->options(MiseNodeJS::NODE_VERSIONS)
->default('22'),
DynamicField::make('package_manager')
->select()
->label('Package Manager')
->options(array_column(NodePackageManager::cases(), 'value'))
->default(NodePackageManager::Npm->value),
DynamicField::make('source_control')
->component()
->label('Source Control'),
DynamicField::make('port')
->text()
->label('Port')
->placeholder('3000')
->description('On which port your app will be running'),
DynamicField::make('repository')
->text()
->label('Repository')
->placeholder('organization/repository'),
DynamicField::make('branch')
->text()
->label('Branch')
->default('main'),
DynamicField::make('build_command')
->text()
->label('Build Command')
->placeholder('e.g., npm run build')
->description('Command to build your application. Leave empty to use the build script of package.json'),
DynamicField::make('start_command')
->text()
->label('Start Command')
->placeholder('e.g., npm start')
->description('Command to start your application. Leave empty to use the start script of package.json'),
]))
->register();
}

public function loadBalancer(): void
{
RegisterSiteType::make(LoadBalancer::id())
Expand Down
48 changes: 48 additions & 0 deletions app/SSH/Mise/Mise.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace App\SSH\Mise;

use App\Exceptions\SSHError;
use App\Models\Server;
use App\Models\Site;

class Mise
{
public function __construct(protected Server $server) {}

/**
* @throws SSHError
*/
public function ensureInstalled(): void
{
$this->server->ssh()->exec(
view('ssh.mise.ensure-installed'),
'ensure-mise-installed'
);
}

/**
* @throws SSHError
*/
public function isInstalled(): bool
{
$result = $this->server->ssh()->exec('which mise || echo "not-found"');

return ! str_contains($result, 'not-found');
}

/**
* @throws SSHError
*/
public function installRuntime(Site $site, string $runtime, string $version): void
{
$this->server->ssh($site->user)->exec(
view('ssh.mise.install-runtime', [
'runtime' => $runtime,
'version' => $version,
]),
'mise-install-'.$runtime.'-'.$version,
$site->id
);
}
}
4 changes: 4 additions & 0 deletions app/Services/ProcessManager/ProcessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

interface ProcessManager extends ServiceInterface
{
/**
* @param ?array<string, string> $environment
*/
public function create(
int $id,
string $command,
Expand All @@ -16,6 +19,7 @@ public function create(
string $logFile,
?string $directory = null,
?int $siteId = null,
?array $environment = null,
): void;

public function delete(int $id, ?int $siteId = null): void;
Expand Down
6 changes: 5 additions & 1 deletion app/Services/ProcessManager/Supervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public function uninstall(): void
}

/**
* @param ?array<string, string> $environment
*
* @throws SSHError
*/
public function create(
Expand All @@ -60,7 +62,8 @@ public function create(
int $numprocs,
string $logFile,
?string $directory = null,
?int $siteId = null
?int $siteId = null,
?array $environment = null,
): void {
$this->service->server->ssh()->write(
"/etc/supervisor/conf.d/$id.conf",
Expand All @@ -73,6 +76,7 @@ public function create(
'autoRestart' => var_export($autoRestart, true),
'numprocs' => (string) $numprocs,
'logFile' => $logFile,
'environment' => $environment,
]),
'root'
);
Expand Down
Loading