Update: 2026-05-03 17:32:57
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
import os
|
||||
|
||||
def aggregate_project(root_dir, output_file, exclude_dirs=None, exclude_files=None, extensions=None):
|
||||
if exclude_dirs is None:
|
||||
exclude_dirs = {'.git', 'vendor', 'node_modules', 'storage', '.gemini', 'artifacts', 'brain', 'scratch'}
|
||||
if exclude_files is None:
|
||||
exclude_files = {'composer.lock', 'package-lock.json', 'aggregate_project.py', output_file}
|
||||
if extensions is None:
|
||||
extensions = {'.php', '.js', '.css', '.html', '.sql', '.json', '.md', '.py', '.env.example', '.xml', '.env'}
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
f.write("# مُصادَق — ملخص كود المشروع الكامل\n\n")
|
||||
f.write("هذا الملف يحتوي على كافة ملفات المصدر للمشروع مجمعة لتسهيل المراجعة.\n\n")
|
||||
|
||||
for root, dirs, files in os.walk(root_dir):
|
||||
# Exclude directories
|
||||
dirs[:] = [d for d in dirs if d not in exclude_dirs]
|
||||
|
||||
for file in files:
|
||||
if file in exclude_files:
|
||||
continue
|
||||
|
||||
_, ext = os.path.splitext(file)
|
||||
# Include specific files or extensions
|
||||
if ext not in extensions and file not in {'.env', 'phpunit.xml'}:
|
||||
continue
|
||||
|
||||
full_path = os.path.join(root, file)
|
||||
rel_path = os.path.relpath(full_path, root_dir)
|
||||
|
||||
f.write(f"## الملف: `{rel_path}`\n\n")
|
||||
|
||||
# Determine language for markdown block
|
||||
lang = ext.replace('.', '')
|
||||
if lang == 'php': lang = 'php'
|
||||
elif lang == 'js': lang = 'javascript'
|
||||
elif lang == 'sql': lang = 'sql'
|
||||
else: lang = ''
|
||||
|
||||
f.write(f"```{lang}\n")
|
||||
try:
|
||||
with open(full_path, 'r', encoding='utf-8') as src:
|
||||
f.write(src.read())
|
||||
except Exception as e:
|
||||
f.write(f"// تعذر قراءة الملف: {str(e)}")
|
||||
f.write("\n```\n\n")
|
||||
f.write("---\n\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
aggregate_project('.', 'musadaq_full_code.md')
|
||||
print("تم تجميع الكود بنجاح في: musadaq_full_code.md")
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../app/Core/helpers.php';
|
||||
|
||||
use App\Core\{Application, Database};
|
||||
|
||||
// Initialize app to load .env and configs
|
||||
$app = new Application(dirname(__DIR__));
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
||||
echo "🗄️ Musadaq Migration Tool\n";
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
||||
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
|
||||
// Create migrations table if not exists
|
||||
$db->exec("CREATE TABLE IF NOT EXISTS migrations (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
migration VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
|
||||
|
||||
$stmt = $db->query("SELECT migration FROM migrations");
|
||||
$executed = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
$migrationsDir = dirname(__DIR__) . '/database/migrations';
|
||||
$files = glob($migrationsDir . '/*.sql');
|
||||
sort($files); // Ensure order
|
||||
|
||||
$count = 0;
|
||||
foreach ($files as $file) {
|
||||
$name = basename($file);
|
||||
if (!in_array($name, $executed)) {
|
||||
echo "🚀 Running: $name... ";
|
||||
|
||||
$sql = file_get_contents($file);
|
||||
|
||||
// Execute the SQL. Since it might contain multiple statements,
|
||||
// and PDO::exec doesn't always handle them well in one go
|
||||
// depending on the driver, we'll try to run it.
|
||||
$db->exec($sql);
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO migrations (migration) VALUES (?)");
|
||||
$stmt->execute([$name]);
|
||||
|
||||
echo "✅ Done\n";
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($count === 0) {
|
||||
echo "✨ Nothing to migrate. Database is up to date.\n";
|
||||
} else {
|
||||
echo "🎉 Migrations completed successfully ($count ran).\n";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "❌ Error: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use App\Core\{Application, Database};
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
$app = new Application(dirname(__DIR__));
|
||||
$db = Database::getInstance();
|
||||
|
||||
echo "🌱 Seeding initial data...\n";
|
||||
|
||||
try {
|
||||
// 1. Create Tenant
|
||||
$tenantId = Uuid::uuid4()->toString();
|
||||
$db->prepare("INSERT INTO tenants (id, name, email, status) VALUES (?, ?, ?, 'active')")
|
||||
->execute([$tenantId, 'شركة انطلاق للحلول الرقمية', 'admin@intaleqapp.com']);
|
||||
|
||||
// 2. Create Super Admin User
|
||||
$userId = Uuid::uuid4()->toString();
|
||||
$passwordHash = password_hash('Musadaq@2026', PASSWORD_ARGON2ID);
|
||||
|
||||
$db->prepare("INSERT INTO users (id, tenant_id, name, email, password_hash, role, is_active) VALUES (?, ?, ?, ?, ?, 'super_admin', 1)")
|
||||
->execute([$userId, $tenantId, 'Hamza Admin', 'admin@musadaq.app', $passwordHash]);
|
||||
|
||||
// 3. Create initial subscription
|
||||
$db->prepare("INSERT INTO subscriptions (tenant_id, plan, max_companies, max_invoices_per_month, max_users) VALUES (?, 'pro', 10, 500, 5)")
|
||||
->execute([$tenantId]);
|
||||
|
||||
echo "✅ Success! You can now log in with:\n";
|
||||
echo "📧 Email: admin@musadaq.app\n";
|
||||
echo "🔑 Password: Musadaq@2026\n";
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
echo "❌ Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
Reference in New Issue
Block a user