UNPKG

expo-router-auth-guard

Version:

A minimal yet powerful starter to quickly launch a mobile app using Expo and Supabase, including:

61 lines (48 loc) 1.71 kB
#!/usr/bin/env node import { execSync } from "child_process"; import fs from "fs-extra"; import path from "path"; import { fileURLToPath } from "url"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Nom du dossier cible const appName = process.argv[2]; if (!appName) { console.error("❌ Please specify a project name :"); console.log(" npm create expo-auth-guard@latest my-app"); process.exit(1); } const isCurrentDir = appName === "." || appName === "./"; const targetDir = isCurrentDir ? process.cwd() : path.resolve(process.cwd(), appName); if (!isCurrentDir && fs.existsSync(targetDir)) { console.error( `❌ Folder "${appName}" already exists. Please choose another name.` ); process.exit(1); } if (isCurrentDir && fs.readdirSync(targetDir).length > 0) { console.warn( "⚠️ Current directory is not empty. Files may be overwritten." ); } const templateDir = path.resolve(__dirname, "../template"); if (fs.existsSync(targetDir)) { console.error( `❌ Folder "${appName}" already exists. Please choose another name.` ); process.exit(1); } try { console.log(`🚀 Creation of the project ${appName}...`); fs.copySync(templateDir, targetDir); process.chdir(targetDir); // Initialisation Git + npm install (optionnel) execSync("git init", { stdio: "inherit" }); execSync("npm install", { stdio: "inherit" }); console.log("✅ Project created successfully !"); console.log(`👉 cd ${appName}`); console.log(" npm run start"); } catch (err) { console.error("❌ Error creating project :", err); }