@artilingo/artiframe-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/logo.png +0 -0
- package/assets/logo.svg +22 -0
- package/assets/logo.webp +0 -0
- package/assets/logo@0.5x.png +0 -0
- package/assets/logo@0.75x.png +0 -0
- package/assets/logo@1.5x.png +0 -0
- package/assets/logo@2x.png +0 -0
- package/assets/logo@3x.png +0 -0
- package/assets/logo@4x.png +0 -0
- package/bin/artiframe.js +57 -0
- package/bin/artiframe.php +45 -0
- package/core-stubs/app/ApiControl.php +81 -0
- package/core-stubs/app/Database.php +69 -0
- package/core-stubs/app/DotEnv.php +63 -0
- package/core-stubs/app/R2Manager.php +130 -0
- package/core-stubs/app/ViewControl.php +24 -0
- package/core-stubs/bin/SystemMethod.php +271 -0
- package/core-stubs/bin/ViewMethod.php +354 -0
- package/core-stubs/docs/de.html +951 -0
- package/core-stubs/docs/en.html +952 -0
- package/core-stubs/docs/es.html +947 -0
- package/core-stubs/docs/fr.html +850 -0
- package/core-stubs/docs/tr.html +951 -0
- package/core-stubs/public/assets/css/components/footer.css +0 -0
- package/core-stubs/public/assets/css/components/header.css +0 -0
- package/core-stubs/public/assets/css/components/mobilenav.css +0 -0
- package/core-stubs/public/assets/css/components/sidebar.css +0 -0
- package/core-stubs/public/assets/css/components/theme-modal.css +0 -0
- package/core-stubs/public/assets/css/root/app.css +61 -0
- package/core-stubs/public/assets/js/components/header.js +0 -0
- package/core-stubs/public/assets/js/components/mobilenav.js +0 -0
- package/core-stubs/public/assets/js/components/sidebar.js +0 -0
- package/core-stubs/public/assets/js/components/theme-modal.js +0 -0
- package/core-stubs/public/assets/js/root/app.js +30 -0
- package/core-stubs/public/includes/footer.php +5 -0
- package/core-stubs/public/includes/head.php +26 -0
- package/core-stubs/public/includes/header.php +5 -0
- package/core-stubs/public/includes/mobilenav.php +5 -0
- package/core-stubs/public/includes/sidebar.php +5 -0
- package/core-stubs/public/includes/theme-modal.php +5 -0
- package/core-stubs/readme/de.md +29 -0
- package/core-stubs/readme/en.md +29 -0
- package/core-stubs/readme/es.md +29 -0
- package/core-stubs/readme/fr.md +29 -0
- package/core-stubs/readme/tr.md +29 -0
- package/package.json +49 -0
- package/scripts/postinstall.js +21 -0
- package/src/App.php +266 -0
- package/src/Commands/MakeApiCommand.php +71 -0
- package/src/Commands/MakeClassCommand.php +88 -0
- package/src/Commands/MakeViewCommand.php +95 -0
- package/src/Commands/NewProjectCommand.php +633 -0
- package/src/Commands/VersionCommand.php +92 -0
- package/src/Lang/de.php +53 -0
- package/src/Lang/en.php +53 -0
- package/src/Lang/es.php +53 -0
- package/src/Lang/fr.php +53 -0
- package/src/Lang/tr.php +53 -0
- package/src/Services/Safeguard.php +48 -0
- package/src/Services/Translator.php +52 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
namespace ArtiFrame\Cli\Commands;
|
|
3
|
+
|
|
4
|
+
use ArtiFrame\Cli\Services\Translator;
|
|
5
|
+
|
|
6
|
+
class VersionCommand
|
|
7
|
+
{
|
|
8
|
+
private Translator $translator;
|
|
9
|
+
|
|
10
|
+
public function __construct(Translator $translator)
|
|
11
|
+
{
|
|
12
|
+
$this->translator = $translator;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public function execute(array $args): void
|
|
16
|
+
{
|
|
17
|
+
$action = $args[0] ?? null; // upgrade or downgrade
|
|
18
|
+
$level = $args[1] ?? null; // major, minor, or patch
|
|
19
|
+
|
|
20
|
+
if (!$action || !in_array($action, ['upgrade', 'downgrade'])) {
|
|
21
|
+
echo "❌ " . $this->translator->get('ERROR_VERSION_ACTION') . PHP_EOL;
|
|
22
|
+
exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!$level || !in_array($level, ['major', 'minor', 'patch'])) {
|
|
26
|
+
echo "❌ " . $this->translator->get('ERROR_VERSION_LEVEL') . PHP_EOL;
|
|
27
|
+
exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
$projectRoot = getcwd();
|
|
31
|
+
$versionFile = $projectRoot . '/config/app-version.php';
|
|
32
|
+
|
|
33
|
+
if (!file_exists($versionFile)) {
|
|
34
|
+
echo "❌ " . $this->translator->get('ERROR_VERSION_FILE', ['path' => $versionFile]) . PHP_EOL;
|
|
35
|
+
exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
$content = file_get_contents($versionFile);
|
|
39
|
+
|
|
40
|
+
// Match define('APP_VERSION', 'x.y.z');
|
|
41
|
+
if (!preg_match('/define\(\'APP_VERSION\',\s*\'(\d+)\.(\d+)\.(\d+)\'\);/', $content, $matches)) {
|
|
42
|
+
echo "❌ " . $this->translator->get('ERROR_VERSION_PARSE') . PHP_EOL;
|
|
43
|
+
exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
$major = (int)$matches[1];
|
|
47
|
+
$minor = (int)$matches[2];
|
|
48
|
+
$patch = (int)$matches[3];
|
|
49
|
+
$oldVersion = "{$major}.{$minor}.{$patch}";
|
|
50
|
+
|
|
51
|
+
if ($action === 'upgrade') {
|
|
52
|
+
if ($level === 'major') {
|
|
53
|
+
$major++;
|
|
54
|
+
$minor = 0;
|
|
55
|
+
$patch = 0;
|
|
56
|
+
} elseif ($level === 'minor') {
|
|
57
|
+
$minor++;
|
|
58
|
+
$patch = 0;
|
|
59
|
+
} elseif ($level === 'patch') {
|
|
60
|
+
$patch++;
|
|
61
|
+
}
|
|
62
|
+
} else { // downgrade
|
|
63
|
+
if ($level === 'major') {
|
|
64
|
+
$major = max(1, $major - 1);
|
|
65
|
+
$minor = 0;
|
|
66
|
+
$patch = 0;
|
|
67
|
+
} elseif ($level === 'minor') {
|
|
68
|
+
$minor = max(0, $minor - 1);
|
|
69
|
+
$patch = 0;
|
|
70
|
+
} elseif ($level === 'patch') {
|
|
71
|
+
$patch = max(0, $patch - 1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
$newVersion = "{$major}.{$minor}.{$patch}";
|
|
76
|
+
|
|
77
|
+
if ($oldVersion === $newVersion) {
|
|
78
|
+
echo $this->translator->get('WARN_VERSION_UNCHANGED', ['version' => $newVersion]) . PHP_EOL;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
$newContent = preg_replace(
|
|
83
|
+
'/define\(\'APP_VERSION\',\s*\'\d+\.\d+\.\d+\'\);/',
|
|
84
|
+
"define('APP_VERSION', '{$newVersion}');",
|
|
85
|
+
$content
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
file_put_contents($versionFile, $newContent);
|
|
89
|
+
|
|
90
|
+
echo $this->translator->get('SUCCESS_VERSION', ['old' => $oldVersion, 'new' => $newVersion]) . PHP_EOL;
|
|
91
|
+
}
|
|
92
|
+
}
|
package/src/Lang/de.php
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
return [
|
|
3
|
+
'WELCOME' => 'Willkommen beim ArtiFrame CLI!',
|
|
4
|
+
'CORE_WARNING_TITLE' => 'ArtiFrame Kern-Warnung!',
|
|
5
|
+
'CORE_WARNING_BODY' => 'Achtung! Dieses Verzeichnis und diese Dateien enthalten die Kernarchitektur von ArtiFrame.' . PHP_EOL . 'Änderungen hier können das gesamte System, die Sicherheitsschichten' . PHP_EOL . 'und API-Abhängigkeiten global betreffen.' . PHP_EOL . 'Sofern Sie kein spezielles Kernverhalten konfigurieren oder einen Framework-Patch entwickeln,' . PHP_EOL . 'wird empfohlen, diese Dateien nicht zu ändern.',
|
|
6
|
+
'CONFIRM_PROMPT' => 'Akzeptieren Sie? [j/N]: ',
|
|
7
|
+
'ABORTED' => 'Vorgang vom Benutzer abgebrochen.',
|
|
8
|
+
'DIR_REQUIRED_ERROR' => 'Fehler: Zielverzeichnis für die Klasse muss angegeben werden! (z.B. /app oder /src)',
|
|
9
|
+
'COMPOSER_MISSING_TITLE' => 'Composer nicht gefunden!',
|
|
10
|
+
'COMPOSER_MISSING_BODY' => "ArtiFrame erfordert Composer (PHP-Paketmanager), um Projekte zu erstellen.\n\nInstallation:\n- Windows: Laden Sie https://getcomposer.org/Composer-Setup.exe herunter\n- macOS: Führen Sie 'brew install composer' aus\n- Linux: Führen Sie 'sudo apt install composer' aus\n\nBitte starten Sie Ihr Terminal nach der Installation neu. No composer, no project!",
|
|
11
|
+
'INSTALL_SUCCESS' => '[ERFOLG] Installation abgeschlossen. Bitte starten Sie Ihr Terminal neu, um die neuen Umgebungsvariablen anzuwenden.',
|
|
12
|
+
|
|
13
|
+
// NewProjectCommand
|
|
14
|
+
'PROJECT_BUILDER_TITLE' => '🚀 ArtiFrame Projekt-Builder',
|
|
15
|
+
'PROJECT_LABEL' => '📁 Projekt',
|
|
16
|
+
'LOCATION_LABEL' => '📍 Pfad',
|
|
17
|
+
'PHASE_COPYING' => 'Kern-Templates werden kopiert...',
|
|
18
|
+
'PHASE_DIRS' => 'Modul-Verzeichnisse werden erstellt...',
|
|
19
|
+
'PHASE_FILES' => 'Projektdateien werden generiert...',
|
|
20
|
+
'PHASE_DEPS' => 'Abhängigkeiten werden installiert...',
|
|
21
|
+
'PHASE_HEADER' => 'Phase :current/:total —',
|
|
22
|
+
'FILES_TO_PROCESS' => ':count Dateien werden verarbeitet',
|
|
23
|
+
'SUCCESS_TITLE' => '✅ Projekt erfolgreich erstellt!',
|
|
24
|
+
'NEXT_STEPS' => '🎯 Erste Schritte:',
|
|
25
|
+
'NEXT_STEPS_EDIT_ENV' => '.env-Datei bearbeiten und mit der Entwicklung beginnen!',
|
|
26
|
+
'DIR_ITEM_COUNT' => '(:count Elemente)',
|
|
27
|
+
|
|
28
|
+
// MakeViewCommand
|
|
29
|
+
'ERROR_VIEW_PATH_REQUIRED' => 'Fehler: View-Pfad ist erforderlich (z.B. dashboard.php oder /admin/benutzer/liste.php)',
|
|
30
|
+
'ERROR_STUB_NOT_FOUND' => 'Fehler: Stub-Datei nicht gefunden: :path',
|
|
31
|
+
'ERROR_RUN_FROM_ROOT' => 'Stellen Sie sicher, dass Sie diesen Befehl vom Stammverzeichnis eines ArtiFrame-Projekts ausführen.',
|
|
32
|
+
'SUCCESS_VIEW' => '✅ View erstellt: /public/:path',
|
|
33
|
+
'SUCCESS_CSS' => '✅ CSS erstellt: /public:path',
|
|
34
|
+
'SUCCESS_JS' => '✅ JS erstellt: /public:path',
|
|
35
|
+
|
|
36
|
+
// MakeApiCommand
|
|
37
|
+
'ERROR_API_TYPE' => "Fehler: API-Typ muss 'standart' oder 'switch-case' sein.",
|
|
38
|
+
'ERROR_API_PATH_REQUIRED' => 'Fehler: Zielpfad ist erforderlich (z.B. /v1/auth/login.php).',
|
|
39
|
+
'SUCCESS_API' => '✅ API-Endpunkt erstellt: /public/api/:type/:path',
|
|
40
|
+
|
|
41
|
+
// MakeClassCommand
|
|
42
|
+
'ERROR_CLASS_ROOT' => 'Fehler: Ziel muss innerhalb der /app/- oder /src/-Verzeichnisse liegen.',
|
|
43
|
+
'SUCCESS_CLASS' => '✅ Klasse erstellt: /:path',
|
|
44
|
+
'NAMESPACE_LABEL' => ' Namespace:',
|
|
45
|
+
|
|
46
|
+
// VersionCommand
|
|
47
|
+
'ERROR_VERSION_ACTION' => "Fehler: Aktion muss 'upgrade' oder 'downgrade' sein.",
|
|
48
|
+
'ERROR_VERSION_LEVEL' => "Fehler: Ebene muss 'major', 'minor' oder 'patch' sein.",
|
|
49
|
+
'ERROR_VERSION_FILE' => 'Fehler: app-version.php nicht gefunden: :path',
|
|
50
|
+
'ERROR_VERSION_PARSE' => 'Fehler: APP_VERSION in app-version.php konnte nicht gelesen werden.',
|
|
51
|
+
'WARN_VERSION_UNCHANGED' => '⚠️ Warnung: Version ist bereits am Minimum (:version) oder hat sich nicht geändert.',
|
|
52
|
+
'SUCCESS_VERSION' => '✅ Version aktualisiert: :old → :new',
|
|
53
|
+
];
|
package/src/Lang/en.php
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
return [
|
|
3
|
+
'WELCOME' => 'Welcome to ArtiFrame CLI!',
|
|
4
|
+
'CORE_WARNING_TITLE' => 'ArtiFrame Core Warning!',
|
|
5
|
+
'CORE_WARNING_BODY' => "Warning! This directory and files contain ArtiFrame's core architecture.\nChanges here will globally affect the application's overall functionality, security layers, and API dependencies.\nUnless you are implementing custom core behavior or developing a framework patch, it is recommended not to modify files in this directory.",
|
|
6
|
+
'CONFIRM_PROMPT' => 'Do you approve? [y/N]: ',
|
|
7
|
+
'ABORTED' => 'Operation aborted by user.',
|
|
8
|
+
'DIR_REQUIRED_ERROR' => 'Error: Target class directory must be specified! (e.g. /app or /src)',
|
|
9
|
+
'COMPOSER_MISSING_TITLE' => 'Composer Not Found!',
|
|
10
|
+
'COMPOSER_MISSING_BODY' => "ArtiFrame requires Composer (PHP package manager) to build projects.\n\nHow to Install:\n- Windows: Download from https://getcomposer.org/Composer-Setup.exe\n- macOS: Run 'brew install composer'\n- Linux: Run 'sudo apt install composer' or check official docs.\n\nPlease restart your terminal after installation. No composer, no project!",
|
|
11
|
+
'INSTALL_SUCCESS' => '[SUCCESS] Installation complete. Please restart your terminal to apply the new environment variables.',
|
|
12
|
+
|
|
13
|
+
// NewProjectCommand
|
|
14
|
+
'PROJECT_BUILDER_TITLE' => '🚀 ArtiFrame Project Builder',
|
|
15
|
+
'PROJECT_LABEL' => '📁 Project',
|
|
16
|
+
'LOCATION_LABEL' => '📍 Location',
|
|
17
|
+
'PHASE_COPYING' => 'Copying core templates...',
|
|
18
|
+
'PHASE_DIRS' => 'Creating module directories...',
|
|
19
|
+
'PHASE_FILES' => 'Generating project files...',
|
|
20
|
+
'PHASE_DEPS' => 'Installing dependencies...',
|
|
21
|
+
'PHASE_HEADER' => 'Phase :current/:total —',
|
|
22
|
+
'FILES_TO_PROCESS' => ':count files to process',
|
|
23
|
+
'SUCCESS_TITLE' => '✅ Project created successfully!',
|
|
24
|
+
'NEXT_STEPS' => '🎯 Get started:',
|
|
25
|
+
'NEXT_STEPS_EDIT_ENV' => 'Edit your .env file and start building!',
|
|
26
|
+
'DIR_ITEM_COUNT' => '(:count items)',
|
|
27
|
+
|
|
28
|
+
// MakeViewCommand
|
|
29
|
+
'ERROR_VIEW_PATH_REQUIRED' => 'Error: View path is required (e.g., dashboard.php or /admin/users/list.php)',
|
|
30
|
+
'ERROR_STUB_NOT_FOUND' => 'Error: Stub file not found at: :path',
|
|
31
|
+
'ERROR_RUN_FROM_ROOT' => 'Make sure you are running this command from the root of an ArtiFrame project.',
|
|
32
|
+
'SUCCESS_VIEW' => '✅ View generated: /public/:path',
|
|
33
|
+
'SUCCESS_CSS' => '✅ CSS generated: /public:path',
|
|
34
|
+
'SUCCESS_JS' => '✅ JS generated: /public:path',
|
|
35
|
+
|
|
36
|
+
// MakeApiCommand
|
|
37
|
+
'ERROR_API_TYPE' => "Error: API type must be 'standart' or 'switch-case'.",
|
|
38
|
+
'ERROR_API_PATH_REQUIRED' => 'Error: Target path is required (e.g., /v1/auth/login.php).',
|
|
39
|
+
'SUCCESS_API' => '✅ API Endpoint generated: /public/api/:type/:path',
|
|
40
|
+
|
|
41
|
+
// MakeClassCommand
|
|
42
|
+
'ERROR_CLASS_ROOT' => 'Error: Target must be inside /app/ or /src/ directories.',
|
|
43
|
+
'SUCCESS_CLASS' => '✅ Class generated: /:path',
|
|
44
|
+
'NAMESPACE_LABEL' => ' Namespace:',
|
|
45
|
+
|
|
46
|
+
// VersionCommand
|
|
47
|
+
'ERROR_VERSION_ACTION' => "Error: Action must be 'upgrade' or 'downgrade'.",
|
|
48
|
+
'ERROR_VERSION_LEVEL' => "Error: Level must be 'major', 'minor', or 'patch'.",
|
|
49
|
+
'ERROR_VERSION_FILE' => 'Error: app-version.php not found at: :path',
|
|
50
|
+
'ERROR_VERSION_PARSE' => 'Error: Could not parse APP_VERSION in app-version.php.',
|
|
51
|
+
'WARN_VERSION_UNCHANGED' => '⚠️ Warning: Version is already at minimum (:version) or did not change.',
|
|
52
|
+
'SUCCESS_VERSION' => '✅ Version updated: :old → :new',
|
|
53
|
+
];
|
package/src/Lang/es.php
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
return [
|
|
3
|
+
'WELCOME' => '¡Bienvenido a ArtiFrame CLI!',
|
|
4
|
+
'CORE_WARNING_TITLE' => '¡Advertencia del Núcleo ArtiFrame!',
|
|
5
|
+
'CORE_WARNING_BODY' => "¡Atención! Este directorio y estos archivos contienen la arquitectura central de ArtiFrame.\nLos cambios aquí afectarán globalmente la funcionalidad de la aplicación, las capas de seguridad y las dependencias de la API.\nA menos que esté implementando un comportamiento central personalizado o desarrollando un parche de framework, se recomienda no modificar archivos en este directorio.",
|
|
6
|
+
'CONFIRM_PROMPT' => '¿Aprueba esta acción? [s/N]: ',
|
|
7
|
+
'ABORTED' => 'Operación cancelada por el usuario.',
|
|
8
|
+
'DIR_REQUIRED_ERROR' => 'Error: ¡Debe especificar el directorio de la clase! (ej. /app o /src)',
|
|
9
|
+
'COMPOSER_MISSING_TITLE' => '¡Composer no encontrado!',
|
|
10
|
+
'COMPOSER_MISSING_BODY' => "ArtiFrame requiere Composer (gestor de paquetes PHP) para crear proyectos.\n\nInstalación:\n- Windows: Descargue https://getcomposer.org/Composer-Setup.exe\n- macOS: Ejecute 'brew install composer'\n- Linux: Ejecute 'sudo apt install composer'\n\nPor favor, reinicie su terminal después de la instalación. ¡No composer, no project!",
|
|
11
|
+
'INSTALL_SUCCESS' => '[ÉXITO] Instalación completada. Por favor, reinicie su terminal para aplicar las nuevas variables de entorno.',
|
|
12
|
+
|
|
13
|
+
// NewProjectCommand
|
|
14
|
+
'PROJECT_BUILDER_TITLE' => '🚀 Generador de Proyectos ArtiFrame',
|
|
15
|
+
'PROJECT_LABEL' => '📁 Proyecto',
|
|
16
|
+
'LOCATION_LABEL' => '📍 Ubicación',
|
|
17
|
+
'PHASE_COPYING' => 'Copiando plantillas del núcleo...',
|
|
18
|
+
'PHASE_DIRS' => 'Creando directorios de módulos...',
|
|
19
|
+
'PHASE_FILES' => 'Generando archivos del proyecto...',
|
|
20
|
+
'PHASE_DEPS' => 'Instalando dependencias...',
|
|
21
|
+
'PHASE_HEADER' => 'Fase :current/:total —',
|
|
22
|
+
'FILES_TO_PROCESS' => ':count archivos a procesar',
|
|
23
|
+
'SUCCESS_TITLE' => '✅ ¡Proyecto creado exitosamente!',
|
|
24
|
+
'NEXT_STEPS' => '🎯 Para comenzar:',
|
|
25
|
+
'NEXT_STEPS_EDIT_ENV' => '¡Edite su archivo .env y comience a desarrollar!',
|
|
26
|
+
'DIR_ITEM_COUNT' => '(:count elementos)',
|
|
27
|
+
|
|
28
|
+
// MakeViewCommand
|
|
29
|
+
'ERROR_VIEW_PATH_REQUIRED' => 'Error: Se requiere la ruta de la vista (ej. dashboard.php o /admin/usuarios/lista.php)',
|
|
30
|
+
'ERROR_STUB_NOT_FOUND' => 'Error: Archivo stub no encontrado: :path',
|
|
31
|
+
'ERROR_RUN_FROM_ROOT' => 'Asegúrese de ejecutar este comando desde la raíz de un proyecto ArtiFrame.',
|
|
32
|
+
'SUCCESS_VIEW' => '✅ Vista generada: /public/:path',
|
|
33
|
+
'SUCCESS_CSS' => '✅ CSS generado: /public:path',
|
|
34
|
+
'SUCCESS_JS' => '✅ JS generado: /public:path',
|
|
35
|
+
|
|
36
|
+
// MakeApiCommand
|
|
37
|
+
'ERROR_API_TYPE' => "Error: El tipo de API debe ser 'standart' o 'switch-case'.",
|
|
38
|
+
'ERROR_API_PATH_REQUIRED' => 'Error: Se requiere la ruta de destino (ej. /v1/auth/login.php).',
|
|
39
|
+
'SUCCESS_API' => '✅ Endpoint API generado: /public/api/:type/:path',
|
|
40
|
+
|
|
41
|
+
// MakeClassCommand
|
|
42
|
+
'ERROR_CLASS_ROOT' => 'Error: El destino debe estar dentro de los directorios /app/ o /src/.',
|
|
43
|
+
'SUCCESS_CLASS' => '✅ Clase generada: /:path',
|
|
44
|
+
'NAMESPACE_LABEL' => ' Espacio de nombres (Namespace):',
|
|
45
|
+
|
|
46
|
+
// VersionCommand
|
|
47
|
+
'ERROR_VERSION_ACTION' => "Error: La acción debe ser 'upgrade' o 'downgrade'.",
|
|
48
|
+
'ERROR_VERSION_LEVEL' => "Error: El nivel debe ser 'major', 'minor' o 'patch'.",
|
|
49
|
+
'ERROR_VERSION_FILE' => 'Error: app-version.php no encontrado: :path',
|
|
50
|
+
'ERROR_VERSION_PARSE' => 'Error: No se pudo leer APP_VERSION en app-version.php.',
|
|
51
|
+
'WARN_VERSION_UNCHANGED' => '⚠️ Advertencia: La versión ya está en el mínimo (:version) o no cambió.',
|
|
52
|
+
'SUCCESS_VERSION' => '✅ Versión actualizada: :old → :new',
|
|
53
|
+
];
|
package/src/Lang/fr.php
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
return [
|
|
3
|
+
'WELCOME' => 'Bienvenue dans la CLI ArtiFrame !',
|
|
4
|
+
'CORE_WARNING_TITLE' => 'Avertissement du Noyau ArtiFrame !',
|
|
5
|
+
'CORE_WARNING_BODY' => 'Attention ! Ce répertoire et ces fichiers contiennent l\'architecture centrale d\'ArtiFrame.' . PHP_EOL . 'Les modifications apportées ici affecteront globalement le fonctionnement de l\'application,' . PHP_EOL . 'les couches de sécurité et les dépendances de l\'API.' . PHP_EOL . 'À moins que vous ne configuriez un comportement personnalisé ou un correctif de framework,' . PHP_EOL . 'il est recommandé de ne pas modifier les fichiers de ce répertoire.',
|
|
6
|
+
'CONFIRM_PROMPT' => 'Approuvez-vous ? [o/N] : ',
|
|
7
|
+
'ABORTED' => 'Opération annulée par l\'utilisateur.',
|
|
8
|
+
'DIR_REQUIRED_ERROR' => 'Erreur : Le répertoire de destination de la classe doit être spécifié ! (ex. /app ou /src)',
|
|
9
|
+
'COMPOSER_MISSING_TITLE' => 'Composer introuvable !',
|
|
10
|
+
'COMPOSER_MISSING_BODY' => 'ArtiFrame nécessite Composer (gestionnaire de paquets PHP) pour créer des projets.' . PHP_EOL . PHP_EOL . 'Installation :' . PHP_EOL . '- Windows : Téléchargez https://getcomposer.org/Composer-Setup.exe' . PHP_EOL . '- macOS : Exécutez \'brew install composer\'' . PHP_EOL . '- Linux : Exécutez \'sudo apt install composer\'' . PHP_EOL . PHP_EOL . 'Veuillez redémarrer votre terminal après l\'installation. No composer, no project !',
|
|
11
|
+
'INSTALL_SUCCESS' => '[SUCCÈS] Installation terminée. Veuillez redémarrer votre terminal pour appliquer les nouvelles variables d\'environnement.',
|
|
12
|
+
|
|
13
|
+
// NewProjectCommand
|
|
14
|
+
'PROJECT_BUILDER_TITLE' => '🚀 Générateur de Projet ArtiFrame',
|
|
15
|
+
'PROJECT_LABEL' => '📁 Projet',
|
|
16
|
+
'LOCATION_LABEL' => '📍 Emplacement',
|
|
17
|
+
'PHASE_COPYING' => 'Copie des modèles de base...',
|
|
18
|
+
'PHASE_DIRS' => 'Création des répertoires de modules...',
|
|
19
|
+
'PHASE_FILES' => 'Génération des fichiers du projet...',
|
|
20
|
+
'PHASE_DEPS' => 'Installation des dépendances...',
|
|
21
|
+
'PHASE_HEADER' => 'Phase :current/:total —',
|
|
22
|
+
'FILES_TO_PROCESS' => ':count fichiers à traiter',
|
|
23
|
+
'SUCCESS_TITLE' => '✅ Projet créé avec succès !',
|
|
24
|
+
'NEXT_STEPS' => '🎯 Pour commencer :',
|
|
25
|
+
'NEXT_STEPS_EDIT_ENV' => 'Modifiez votre fichier .env et commencez à développer !',
|
|
26
|
+
'DIR_ITEM_COUNT' => '(:count éléments)',
|
|
27
|
+
|
|
28
|
+
// MakeViewCommand
|
|
29
|
+
'ERROR_VIEW_PATH_REQUIRED' => 'Erreur : Le chemin de la vue est requis (ex. dashboard.php ou /admin/utilisateurs/liste.php)',
|
|
30
|
+
'ERROR_STUB_NOT_FOUND' => 'Erreur : Fichier stub introuvable : :path',
|
|
31
|
+
'ERROR_RUN_FROM_ROOT' => 'Assurez-vous d\'exécuter cette commande depuis la racine d\'un projet ArtiFrame.',
|
|
32
|
+
'SUCCESS_VIEW' => '✅ Vue créée : /public/:path',
|
|
33
|
+
'SUCCESS_CSS' => '✅ CSS créé : /public:path',
|
|
34
|
+
'SUCCESS_JS' => '✅ JS créé : /public:path',
|
|
35
|
+
|
|
36
|
+
// MakeApiCommand
|
|
37
|
+
'ERROR_API_TYPE' => "Erreur : Le type d'API doit être 'standart' ou 'switch-case'.",
|
|
38
|
+
'ERROR_API_PATH_REQUIRED' => 'Erreur : Le chemin cible est requis (ex. /v1/auth/connexion.php).',
|
|
39
|
+
'SUCCESS_API' => '✅ Point de terminaison API créé : /public/api/:type/:path',
|
|
40
|
+
|
|
41
|
+
// MakeClassCommand
|
|
42
|
+
'ERROR_CLASS_ROOT' => 'Erreur : La cible doit se trouver dans les répertoires /app/ ou /src/.',
|
|
43
|
+
'SUCCESS_CLASS' => '✅ Classe créée : /:path',
|
|
44
|
+
'NAMESPACE_LABEL' => ' Espace de noms (Namespace) :',
|
|
45
|
+
|
|
46
|
+
// VersionCommand
|
|
47
|
+
'ERROR_VERSION_ACTION' => "Erreur : L'action doit être 'upgrade' ou 'downgrade'.",
|
|
48
|
+
'ERROR_VERSION_LEVEL' => "Erreur : Le niveau doit être 'major', 'minor' ou 'patch'.",
|
|
49
|
+
'ERROR_VERSION_FILE' => 'Erreur : app-version.php introuvable : :path',
|
|
50
|
+
'ERROR_VERSION_PARSE' => 'Erreur : Impossible de lire APP_VERSION dans app-version.php.',
|
|
51
|
+
'WARN_VERSION_UNCHANGED' => '⚠️ Avertissement : La version est déjà au minimum (:version) ou n\'a pas changé.',
|
|
52
|
+
'SUCCESS_VERSION' => '✅ Version mise à jour : :old → :new',
|
|
53
|
+
];
|
package/src/Lang/tr.php
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
return [
|
|
3
|
+
'WELCOME' => 'ArtiFrame CLI aracına hoş geldiniz!',
|
|
4
|
+
'CORE_WARNING_TITLE' => 'ArtiFrame Çekirdek Uyarısı!',
|
|
5
|
+
'CORE_WARNING_BODY' => 'Dikkat! Bu dizin ve dosyalar ArtiFrame\'in çekirdek mimarisini barındırır.' . PHP_EOL . 'Burada yapacağınız değişiklikler uygulamanın tüm genel işleyişini,' . PHP_EOL . 'güvenlik katmanlarını ve API bağımlılıklarını küresel (global) olarak etkileyecektir.' . PHP_EOL . 'Özel bir çekirdek davranışı kurgulamıyor veya bir framework yaması (patch)' . PHP_EOL . 'geliştirmiyorsanız bu dizin üzerindeki dosyaları değiştirmemeniz önerilir.',
|
|
6
|
+
'CONFIRM_PROMPT' => 'Onaylıyor musunuz? [e/H]: ',
|
|
7
|
+
'ABORTED' => 'İşlem kullanıcı tarafından iptal edildi.',
|
|
8
|
+
'DIR_REQUIRED_ERROR' => 'Hata: Sınıfın oluşturulacağı dizin belirtilmeli! (örn: /app veya /src)',
|
|
9
|
+
'COMPOSER_MISSING_TITLE' => 'Composer Bulunamadı!',
|
|
10
|
+
'COMPOSER_MISSING_BODY' => 'ArtiFrame projeleri çalışabilmek için PHP paket yöneticisi olan Composer\'a ihtiyaç duyar.' . PHP_EOL . PHP_EOL . 'Nasıl Kurulur?' . PHP_EOL . '- Windows: https://getcomposer.org/Composer-Setup.exe adresinden indirip kurun.' . PHP_EOL . '- macOS: \'brew install composer\' komutunu kullanın.' . PHP_EOL . '- Linux: \'sudo apt install composer\' veya resmi dokümantasyonu takip edin.' . PHP_EOL . PHP_EOL . 'Kurulumdan sonra terminali yeniden başlatmayı unutmayın. No composer, no project!',
|
|
11
|
+
'INSTALL_SUCCESS' => '[BAŞARILI] Kurulum tamamlandı. Komutların aktif olması için lütfen terminalinizi yeniden başlatın.',
|
|
12
|
+
|
|
13
|
+
// NewProjectCommand
|
|
14
|
+
'PROJECT_BUILDER_TITLE' => '🚀 ArtiFrame Proje Oluşturucu',
|
|
15
|
+
'PROJECT_LABEL' => '📁 Proje',
|
|
16
|
+
'LOCATION_LABEL' => '📍 Konum',
|
|
17
|
+
'PHASE_COPYING' => 'Çekirdek şablonlar kopyalanıyor...',
|
|
18
|
+
'PHASE_DIRS' => 'Modül dizinleri oluşturuluyor...',
|
|
19
|
+
'PHASE_FILES' => 'Proje dosyaları oluşturuluyor...',
|
|
20
|
+
'PHASE_DEPS' => 'Bağımlılıklar kuruluyor...',
|
|
21
|
+
'PHASE_HEADER' => 'Faz :current/:total —',
|
|
22
|
+
'FILES_TO_PROCESS' => ':count dosya işlenecek',
|
|
23
|
+
'SUCCESS_TITLE' => '✅ Proje başarıyla oluşturuldu!',
|
|
24
|
+
'NEXT_STEPS' => '🎯 Başlamak için:',
|
|
25
|
+
'NEXT_STEPS_EDIT_ENV' => '.env dosyasını düzenleyin ve geliştirmeye başlayın!',
|
|
26
|
+
'DIR_ITEM_COUNT' => '(:count öğe)',
|
|
27
|
+
|
|
28
|
+
// MakeViewCommand
|
|
29
|
+
'ERROR_VIEW_PATH_REQUIRED' => 'Hata: View yolu gerekli (örn: dashboard.php veya /admin/kullanicilar/liste.php)',
|
|
30
|
+
'ERROR_STUB_NOT_FOUND' => 'Hata: Stub dosyası bulunamadı: :path',
|
|
31
|
+
'ERROR_RUN_FROM_ROOT' => 'Bu komutu ArtiFrame projenizin kök dizininden çalıştırın.',
|
|
32
|
+
'SUCCESS_VIEW' => '✅ View oluşturuldu: /public/:path',
|
|
33
|
+
'SUCCESS_CSS' => '✅ CSS oluşturuldu: /public:path',
|
|
34
|
+
'SUCCESS_JS' => '✅ JS oluşturuldu: /public:path',
|
|
35
|
+
|
|
36
|
+
// MakeApiCommand
|
|
37
|
+
'ERROR_API_TYPE' => 'Hata: API türü \'standart\' veya \'switch-case\' olmalıdır.',
|
|
38
|
+
'ERROR_API_PATH_REQUIRED' => 'Hata: Hedef yol gerekli (örn: /v1/auth/giris.php)',
|
|
39
|
+
'SUCCESS_API' => '✅ API Endpoint oluşturuldu: /public/api/:type/:path',
|
|
40
|
+
|
|
41
|
+
// MakeClassCommand
|
|
42
|
+
'ERROR_CLASS_ROOT' => 'Hata: Hedef /app/ veya /src/ dizininin içinde olmalıdır.',
|
|
43
|
+
'SUCCESS_CLASS' => '✅ Sınıf oluşturuldu: /:path',
|
|
44
|
+
'NAMESPACE_LABEL' => ' Ad Alanı (Namespace):',
|
|
45
|
+
|
|
46
|
+
// VersionCommand
|
|
47
|
+
'ERROR_VERSION_ACTION' => 'Hata: Eylem \'upgrade\' veya \'downgrade\' olmalıdır.',
|
|
48
|
+
'ERROR_VERSION_LEVEL' => 'Hata: Seviye \'major\', \'minor\' veya \'patch\' olmalıdır.',
|
|
49
|
+
'ERROR_VERSION_FILE' => 'Hata: app-version.php bulunamadı: :path',
|
|
50
|
+
'ERROR_VERSION_PARSE' => 'Hata: app-version.php içindeki APP_VERSION okunamadı.',
|
|
51
|
+
'WARN_VERSION_UNCHANGED' => '⚠️ Uyarı: Sürüm zaten minimum değerde (:version) veya değişmedi.',
|
|
52
|
+
'SUCCESS_VERSION' => '✅ Sürüm güncellendi: :old → :new',
|
|
53
|
+
];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
namespace ArtiFrame\Cli\Services;
|
|
3
|
+
|
|
4
|
+
class Safeguard
|
|
5
|
+
{
|
|
6
|
+
private Translator $translator;
|
|
7
|
+
|
|
8
|
+
public function __construct(Translator $translator)
|
|
9
|
+
{
|
|
10
|
+
$this->translator = $translator;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the target path is inside the protected /bin/ directory.
|
|
15
|
+
* If so, interrupts and asks for user confirmation.
|
|
16
|
+
* Returns true if safe to proceed, false if aborted.
|
|
17
|
+
*/
|
|
18
|
+
public function checkTarget(string $targetPath): bool
|
|
19
|
+
{
|
|
20
|
+
// Normalize slashes
|
|
21
|
+
$normalizedPath = str_replace('\\', '/', $targetPath);
|
|
22
|
+
|
|
23
|
+
// Check if the path targets /bin/
|
|
24
|
+
if (strpos($normalizedPath, '/bin/') !== false || strpos($normalizedPath, 'bin/') === 0) {
|
|
25
|
+
echo PHP_EOL . "⚠️ " . $this->translator->get('CORE_WARNING_TITLE') . PHP_EOL;
|
|
26
|
+
echo str_repeat("-", 60) . PHP_EOL;
|
|
27
|
+
echo $this->translator->get('CORE_WARNING_BODY') . PHP_EOL;
|
|
28
|
+
echo str_repeat("-", 60) . PHP_EOL;
|
|
29
|
+
|
|
30
|
+
$prompt = $this->translator->get('CONFIRM_PROMPT');
|
|
31
|
+
echo $prompt;
|
|
32
|
+
|
|
33
|
+
$handle = fopen("php://stdin", "r");
|
|
34
|
+
$line = fgets($handle);
|
|
35
|
+
fclose($handle);
|
|
36
|
+
|
|
37
|
+
$response = strtolower(trim($line));
|
|
38
|
+
$approvedResponses = ['y', 'yes', 'j', 'o', 's', 'evet'];
|
|
39
|
+
|
|
40
|
+
if (!in_array($response, $approvedResponses)) {
|
|
41
|
+
echo PHP_EOL . "[ABORT] Operation cancelled by user." . PHP_EOL;
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
namespace ArtiFrame\Cli\Services;
|
|
3
|
+
|
|
4
|
+
class Translator
|
|
5
|
+
{
|
|
6
|
+
private string $locale;
|
|
7
|
+
private array $messages = [];
|
|
8
|
+
|
|
9
|
+
public function __construct(string $locale)
|
|
10
|
+
{
|
|
11
|
+
// Support tr, en, de, es, fr. Default to en if not found.
|
|
12
|
+
$supportedLocales = ['tr', 'en', 'de', 'es', 'fr'];
|
|
13
|
+
|
|
14
|
+
if (!in_array($locale, $supportedLocales)) {
|
|
15
|
+
$locale = 'en';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
$this->locale = $locale;
|
|
19
|
+
$this->loadMessages();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private function loadMessages(): void
|
|
23
|
+
{
|
|
24
|
+
$langFile = ARTIFRAME_CLI_ROOT . '/src/Lang/' . $this->locale . '.php';
|
|
25
|
+
|
|
26
|
+
if (file_exists($langFile)) {
|
|
27
|
+
$this->messages = require $langFile;
|
|
28
|
+
} else {
|
|
29
|
+
// Fallback to english
|
|
30
|
+
$fallbackFile = ARTIFRAME_CLI_ROOT . '/src/Lang/en.php';
|
|
31
|
+
if (file_exists($fallbackFile)) {
|
|
32
|
+
$this->messages = require $fallbackFile;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public function get(string $key, array $replacements = []): string
|
|
38
|
+
{
|
|
39
|
+
$message = $this->messages[$key] ?? $key;
|
|
40
|
+
|
|
41
|
+
foreach ($replacements as $placeholder => $value) {
|
|
42
|
+
$message = str_replace(':' . $placeholder, $value, $message);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return $message;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public function getLang(): string
|
|
49
|
+
{
|
|
50
|
+
return $this->locale;
|
|
51
|
+
}
|
|
52
|
+
}
|