@artilingo/artiframe-cli 1.0.9 → 1.1.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.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/bin/artiframe.php +1 -1
  3. package/core-stubs/app/Database.php +1 -1
  4. package/core-stubs/app/DotEnv.php +1 -1
  5. package/core-stubs/app/R2Manager.php +1 -1
  6. package/core-stubs/bin/SystemMethod.php +292 -16
  7. package/core-stubs/bin/ViewMethod.php +146 -37
  8. package/core-stubs/docs/de.html +4419 -955
  9. package/core-stubs/docs/en.html +4419 -956
  10. package/core-stubs/docs/es.html +4419 -951
  11. package/core-stubs/docs/fr.html +4101 -536
  12. package/core-stubs/docs/tr.html +4978 -955
  13. package/core-stubs/stubs/service/image.stub +334 -0
  14. package/core-stubs/stubs/service/iyzico.stub +637 -0
  15. package/core-stubs/stubs/service/jwt.stub +312 -0
  16. package/core-stubs/stubs/service/pusher.stub +232 -0
  17. package/core-stubs/stubs/service/redis.stub +361 -0
  18. package/core-stubs/stubs/service/s3.stub +377 -0
  19. package/core-stubs/stubs/service/sentry.stub +139 -0
  20. package/core-stubs/stubs/service/stripe.stub +526 -0
  21. package/core-stubs/stubs/service/twilio.stub +361 -0
  22. package/package.json +4 -4
  23. package/src/App.php +69 -0
  24. package/src/Commands/AddCommand.php +392 -0
  25. package/src/Commands/GoCommand.php +48 -0
  26. package/src/Commands/ListCommand.php +67 -0
  27. package/src/Commands/NewProjectCommand.php +184 -30
  28. package/src/Commands/RemoveCommand.php +121 -0
  29. package/src/Commands/ServeCommand.php +71 -0
  30. package/src/Commands/ShowCommand.php +24 -0
  31. package/src/Lang/de.php +56 -0
  32. package/src/Lang/en.php +56 -0
  33. package/src/Lang/es.php +56 -0
  34. package/src/Lang/fr.php +56 -0
  35. package/src/Lang/tr.php +56 -0
@@ -5,7 +5,7 @@
5
5
  * @package ArtiFrame
6
6
  * @author Artilingo
7
7
  * @license AGPLv3 (Attribution-ShareAlike Required)
8
- * @link https://artiframe.org
8
+ * @link https://artiframe.artilingo.com
9
9
  *
10
10
  * NOTICE: This file is part of the ArtiFrame ecosystem.
11
11
  * Any derivative works or patches MUST retain this original copyright notice
@@ -35,9 +35,10 @@ class ViewMethod
35
35
  /**
36
36
  * URL'leri güvenli hale getirir, zararlı karakterleri temizler.
37
37
  */
38
- public static function escapeUrl(string $url): string
38
+ public static function escapeUrl(?string $url): string
39
39
  {
40
- return filter_var($url, FILTER_SANITIZE_URL);
40
+ if (empty($url)) return '#';
41
+ return self::display(filter_var($url, FILTER_SANITIZE_URL));
41
42
  }
42
43
 
43
44
  /**
@@ -47,7 +48,7 @@ class ViewMethod
47
48
  {
48
49
  if (empty($date)) return '-';
49
50
  $time = strtotime($date);
50
- return $time ? date($format, $time) : '-';
51
+ return self::display($time ? date($format, $time) : '-');
51
52
  }
52
53
 
53
54
  /**
@@ -68,7 +69,7 @@ class ViewMethod
68
69
  public static function day($date): string
69
70
  {
70
71
  if (empty($date)) return '-';
71
- return date('d', is_numeric($date) ? $date : strtotime($date));
72
+ return self::display(date('d', is_numeric($date) ? $date : strtotime($date)));
72
73
  }
73
74
 
74
75
  /**
@@ -77,7 +78,7 @@ class ViewMethod
77
78
  public static function month($date): string
78
79
  {
79
80
  if (empty($date)) return '-';
80
- return date('m', is_numeric($date) ? $date : strtotime($date));
81
+ return self::display(date('m', is_numeric($date) ? $date : strtotime($date)));
81
82
  }
82
83
 
83
84
  /**
@@ -86,7 +87,7 @@ class ViewMethod
86
87
  public static function year($date): string
87
88
  {
88
89
  if (empty($date)) return '-';
89
- return date('Y', is_numeric($date) ? $date : strtotime($date));
90
+ return self::display(date('Y', is_numeric($date) ? $date : strtotime($date)));
90
91
  }
91
92
 
92
93
  /**
@@ -95,7 +96,7 @@ class ViewMethod
95
96
  public static function timeOnly($date): string
96
97
  {
97
98
  if (empty($date)) return '-';
98
- return date('H:i', is_numeric($date) ? $date : strtotime($date));
99
+ return self::display(date('H:i', is_numeric($date) ? $date : strtotime($date)));
99
100
  }
100
101
 
101
102
  /**
@@ -104,7 +105,7 @@ class ViewMethod
104
105
  public static function fulldate($date): string
105
106
  {
106
107
  if (empty($date)) return '-';
107
- return date('d.m.Y', is_numeric($date) ? $date : strtotime($date));
108
+ return self::display(date('d.m.Y', is_numeric($date) ? $date : strtotime($date)));
108
109
  }
109
110
 
110
111
  /**
@@ -123,7 +124,7 @@ class ViewMethod
123
124
  ];
124
125
  $lang = strtolower($lang);
125
126
  if (!isset($months[$lang])) $lang = 'en';
126
- return $months[$lang][$m];
127
+ return self::display($months[$lang][$m]);
127
128
  }
128
129
 
129
130
  /**
@@ -139,9 +140,9 @@ class ViewMethod
139
140
 
140
141
  // İngilizce'de ay öne gelebilir (July 24, 2026) ama basitlik açısından formatı koruyabiliriz veya dile göre değiştirebiliriz.
141
142
  if (strtolower($lang) === 'en') {
142
- return "{$mName} {$d}, {$y}";
143
+ return self::display("{$mName} {$d}, {$y}");
143
144
  }
144
- return "{$d} {$mName} {$y}";
145
+ return self::display("{$d} {$mName} {$y}");
145
146
  }
146
147
 
147
148
  /**
@@ -152,7 +153,7 @@ class ViewMethod
152
153
  if (empty($date)) return '-';
153
154
  $time = is_numeric($date) ? $date : strtotime($date);
154
155
  $diff = time() - $time;
155
- if ($diff < 1) return ($lang === 'tr') ? 'şimdi' : 'just now';
156
+ if ($diff < 1) return self::display(($lang === 'tr') ? 'şimdi' : 'just now');
156
157
 
157
158
  $tokens = [
158
159
  31536000 => 'year',
@@ -192,7 +193,7 @@ class ViewMethod
192
193
  if ($lang === 'de') {
193
194
  $formatted = str_replace(['Jahren', 'Monaten', 'Wocheen', 'Tagen', 'Stundeen', 'Minuteen', 'Sekundeen'], ['Jahren', 'Monaten', 'Wochen', 'Tagen', 'Stunden', 'Minuten', 'Sekunden'], $formatted);
194
195
  }
195
- return $formatted;
196
+ return self::display($formatted);
196
197
  }
197
198
  return '-';
198
199
  }
@@ -202,10 +203,11 @@ class ViewMethod
202
203
  /**
203
204
  * Uzun metinleri keser ve sonuna ... ekler
204
205
  */
205
- public static function truncate(string $text, int $length = 100, string $append = '...'): string
206
+ public static function truncate(?string $text, int $length = 100, string $append = '...'): string
206
207
  {
208
+ if (empty($text)) return '';
207
209
  $text = strip_tags($text);
208
- if (mb_strlen($text, 'UTF-8') <= $length) return $text;
210
+ if (mb_strlen($text, 'UTF-8') <= $length) return self::display($text);
209
211
 
210
212
  $truncated = mb_substr($text, 0, $length, 'UTF-8');
211
213
  // Son kelimeyi bölmemek için son boşluğa kadar al
@@ -215,7 +217,7 @@ class ViewMethod
215
217
  $truncated = mb_substr($truncated, 0, $lastSpace, 'UTF-8');
216
218
  }
217
219
  }
218
- return $truncated . $append;
220
+ return self::display($truncated . $append);
219
221
  }
220
222
 
221
223
  // --- Para Birimi Formatlama ---
@@ -223,8 +225,11 @@ class ViewMethod
223
225
  /**
224
226
  * Tutar ve para birimi sembolü formatlama
225
227
  */
226
- public static function money(float $amount, string $currency = 'usd'): string
228
+ public static function money($amount, string $currency = 'usd'): string
227
229
  {
230
+ if ($amount === null || $amount === '') return '-';
231
+ $amount = (float)$amount;
232
+
228
233
  $currencies = [
229
234
  'usd' => '$', // US Dollar
230
235
  'eur' => '€', // Euro
@@ -261,94 +266,198 @@ class ViewMethod
261
266
 
262
267
  // USD ve GBP gibi birimlerde sembol genelde başa gelir, TL veya EUR'da sona.
263
268
  if (in_array($currency, ['usd', 'gbp', 'aud', 'cad', 'sgd', 'hkd', 'nzd', 'mxn', 'brl'])) {
264
- return $symbol . $formattedAmount;
269
+ return self::display($symbol . $formattedAmount);
265
270
  }
266
271
 
267
- return $formattedAmount . ' ' . $symbol;
272
+ return self::display($formattedAmount . ' ' . $symbol);
273
+ }
274
+
275
+ /**
276
+ * Metni URL dostu bir slug'a çevirir (Örn: "Merhaba Dünya!" -> "merhaba-dunya")
277
+ */
278
+ public static function slugify(string ...$texts): string
279
+ {
280
+ $text = implode('-', $texts);
281
+ $text = mb_strtolower($text, 'UTF-8');
282
+
283
+ $search = [
284
+ 'ç', 'ğ', 'ı', 'ö', 'ş', 'ü', // TR
285
+ 'ä', 'ß', // DE
286
+ 'ñ', // ES
287
+ 'é', 'è', 'ê', 'ë', 'à', 'á', 'â', 'î', 'ï', 'í', 'ô', 'ó', 'ú', 'û', 'ù', 'æ', 'œ' // FR & ES
288
+ ];
289
+ $replace = [
290
+ 'c', 'g', 'i', 'o', 's', 'u',
291
+ 'ae', 'ss',
292
+ 'n',
293
+ 'e', 'e', 'e', 'e', 'a', 'a', 'a', 'i', 'i', 'i', 'o', 'o', 'u', 'u', 'u', 'ae', 'oe'
294
+ ];
295
+
296
+ $text = str_replace($search, $replace, $text);
297
+ $text = preg_replace('/[^a-z0-9\-]/', '-', $text);
298
+ $text = preg_replace('/-+/', '-', $text);
299
+ return self::display(trim($text, '-'));
300
+ }
301
+
302
+ /**
303
+ * Menülerde geçerli sayfa ise belirtilen class'ı döndürür.
304
+ */
305
+ public static function activeClass(?string $path, string $className = 'active'): string
306
+ {
307
+ $currentUri = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH);
308
+ return ($currentUri === $path) ? self::display($className) : '';
309
+ }
310
+
311
+ /**
312
+ * Dosya boyutlarını okunabilir formata çevirir (KB, MB, GB vb.)
313
+ */
314
+ public static function formatSize(int $bytes): string
315
+ {
316
+ if ($bytes <= 0) return '0 B';
317
+ $units = ['B', 'KB', 'MB', 'GB', 'TB'];
318
+ $power = floor(log($bytes, 1024));
319
+ return self::display(number_format($bytes / pow(1024, $power), 2, ',', '.') . ' ' . $units[$power]);
320
+ }
321
+
322
+ /**
323
+ * E-posta adresini KVKK/GDPR kapsamında maskeler (Örn: u***@artilingo.com)
324
+ */
325
+ public static function maskEmail(?string $email): string
326
+ {
327
+ if (empty($email)) return '-';
328
+ if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) return self::display($email);
329
+ list($first, $last) = explode('@', $email);
330
+ $first = mb_substr($first, 0, 1, 'UTF-8') . str_repeat('*', max(mb_strlen($first, 'UTF-8') - 1, 3));
331
+ return self::display($first . '@' . $last);
332
+ }
333
+
334
+ /**
335
+ * Telefon numarasını KVKK kapsamında maskeler (Örn: +90 555 *** ** 67)
336
+ */
337
+ public static function maskPhone(?string $phone): string
338
+ {
339
+ if (empty($phone)) return '-';
340
+ $phoneStr = preg_replace('/[^\d\+]/', '', $phone);
341
+ $len = strlen($phoneStr);
342
+ if ($len < 6) return self::display($phone);
343
+ $start = substr($phoneStr, 0, 3);
344
+ $end = substr($phoneStr, -2);
345
+ $masked = $start . str_repeat('*', max($len - 5, 3)) . $end;
346
+ return self::display($masked);
268
347
  }
269
348
  }
270
349
 
271
350
  // Geliştiriciler (Özellikle Juniorlar) için kullanımı en kolay global yardımcı fonksiyonlar
272
- if (!function_exists('display')) {
351
+ if (!function_exists(__NAMESPACE__ . '\\display')) {
273
352
  function display($data, string $default = ''): string {
274
353
  return \Bin\ViewMethod::display($data, $default);
275
354
  }
276
355
  }
277
356
 
278
- if (!function_exists('escapeUrl')) {
279
- function escapeUrl(string $url): string {
357
+ if (!function_exists(__NAMESPACE__ . '\\escapeUrl')) {
358
+ function escapeUrl(?string $url): string {
280
359
  return \Bin\ViewMethod::escapeUrl($url);
281
360
  }
282
361
  }
283
362
 
284
- if (!function_exists('formatDate')) {
363
+ if (!function_exists(__NAMESPACE__ . '\\formatDate')) {
285
364
  function formatDate(?string $date, string $format = 'd.m.Y H:i'): string {
286
365
  return \Bin\ViewMethod::formatDate($date, $format);
287
366
  }
288
367
  }
289
368
 
290
- if (!function_exists('csrfField')) {
369
+ if (!function_exists(__NAMESPACE__ . '\\csrfField')) {
291
370
  function csrfField(): string {
292
371
  return \Bin\ViewMethod::csrfField();
293
372
  }
294
373
  }
295
374
 
296
- if (!function_exists('day')) {
375
+ if (!function_exists(__NAMESPACE__ . '\\day')) {
297
376
  function day($date): string {
298
377
  return \Bin\ViewMethod::day($date);
299
378
  }
300
379
  }
301
380
 
302
- if (!function_exists('month')) {
381
+ if (!function_exists(__NAMESPACE__ . '\\month')) {
303
382
  function month($date): string {
304
383
  return \Bin\ViewMethod::month($date);
305
384
  }
306
385
  }
307
386
 
308
- if (!function_exists('year')) {
387
+ if (!function_exists(__NAMESPACE__ . '\\year')) {
309
388
  function year($date): string {
310
389
  return \Bin\ViewMethod::year($date);
311
390
  }
312
391
  }
313
392
 
314
- if (!function_exists('timeOnly')) {
393
+ if (!function_exists(__NAMESPACE__ . '\\timeOnly')) {
315
394
  function timeOnly($date): string {
316
395
  return \Bin\ViewMethod::timeOnly($date);
317
396
  }
318
397
  }
319
398
 
320
- if (!function_exists('fulldate')) {
399
+ if (!function_exists(__NAMESPACE__ . '\\fulldate')) {
321
400
  function fulldate($date): string {
322
401
  return \Bin\ViewMethod::fulldate($date);
323
402
  }
324
403
  }
325
404
 
326
- if (!function_exists('monthName')) {
405
+ if (!function_exists(__NAMESPACE__ . '\\monthName')) {
327
406
  function monthName($date, string $lang = 'tr'): string {
328
407
  return \Bin\ViewMethod::monthName($date, $lang);
329
408
  }
330
409
  }
331
410
 
332
- if (!function_exists('fulldateName')) {
411
+ if (!function_exists(__NAMESPACE__ . '\\fulldateName')) {
333
412
  function fulldateName($date, string $lang = 'tr'): string {
334
413
  return \Bin\ViewMethod::fulldateName($date, $lang);
335
414
  }
336
415
  }
337
416
 
338
- if (!function_exists('timeAgo')) {
417
+ if (!function_exists(__NAMESPACE__ . '\\timeAgo')) {
339
418
  function timeAgo($date, string $lang = 'tr'): string {
340
419
  return \Bin\ViewMethod::timeAgo($date, $lang);
341
420
  }
342
421
  }
343
422
 
344
- if (!function_exists('truncate')) {
345
- function truncate(string $text, int $length = 100, string $append = '...'): string {
423
+ if (!function_exists(__NAMESPACE__ . '\\truncate')) {
424
+ function truncate(?string $text, int $length = 100, string $append = '...'): string {
346
425
  return \Bin\ViewMethod::truncate($text, $length, $append);
347
426
  }
348
427
  }
349
428
 
350
- if (!function_exists('money')) {
351
- function money(float $amount, string $currency = 'usd'): string {
429
+ if (!function_exists(__NAMESPACE__ . '\\money')) {
430
+ function money($amount, string $currency = 'usd'): string {
352
431
  return \Bin\ViewMethod::money($amount, $currency);
353
432
  }
354
433
  }
434
+
435
+ if (!function_exists(__NAMESPACE__ . '\\slugify')) {
436
+ function slugify(string ...$texts): string {
437
+ return \Bin\ViewMethod::slugify(...$texts);
438
+ }
439
+ }
440
+
441
+ if (!function_exists(__NAMESPACE__ . '\\activeClass')) {
442
+ function activeClass(string $path, string $className = 'active'): string {
443
+ return \Bin\ViewMethod::activeClass($path, $className);
444
+ }
445
+ }
446
+
447
+ if (!function_exists(__NAMESPACE__ . '\\formatSize')) {
448
+ function formatSize(int $bytes): string {
449
+ return \Bin\ViewMethod::formatSize($bytes);
450
+ }
451
+ }
452
+
453
+ if (!function_exists(__NAMESPACE__ . '\\maskEmail')) {
454
+ function maskEmail(?string $email): string {
455
+ return \Bin\ViewMethod::maskEmail($email);
456
+ }
457
+ }
458
+
459
+ if (!function_exists(__NAMESPACE__ . '\\maskPhone')) {
460
+ function maskPhone(?string $phone): string {
461
+ return \Bin\ViewMethod::maskPhone($phone);
462
+ }
463
+ }