CLI Reference
CLI Reference
The IMUII CLI is your gateway to the entire IMUII ecosystem.
From project initialization to deployment, every interaction happens here.
📌 Note: Dokumentasi ini khusus untuk CLI Users. Untuk Web Users, lihat [Getting Started](/docs/get-started) bagian Web Users.
📦 Installation
Global Install (Recommended)
npm install -g imuii
Menggunakan npx (Tanpa Install)
npx imuii init
Verifikasi Instalasi
imuii --version
🔍 Command: check
Mengecek apakah semua prerequisites sudah terpenuhi sebelum inisialisasi.
imuii check
imuii check --quiet # Minimal output
Yang Dicek
- Akun/Login Check
- ✅ Apakah user sudah login (
imuii login) - ✅ Apakah JWT token valid
- ✅ Informasi user (email, user ID)
- Git Setup Check
- ✅ Apakah Git terinstall
- ✅ Apakah Git sudah dikonfigurasi (user.name & user.email)
- ✅ Apakah ada SSH keys atau GitHub CLI sudah authenticated
- ✅ Test koneksi aktual ke GitHub (HTTPS atau SSH)
- ✅ Apakah ada remote GitHub yang sudah dikonfigurasi
Output Contoh
✅ Semua Prerequisites Terpenuhi:🔍 IM-UII CLI — Check Prerequisites
📋 Prerequisites Check
✅ Logged in
Email: user@example.com
✅ GitHub setup complete
Git user: John Doe
Connection: Can connect via HTTPS
SSH keys: 2 found
GitHub CLI: Authenticated as johndoe
✅ All prerequisites met
✨ All prerequisites are ready! You can proceed with imuii init
❌ Prerequisites Belum Terpenuhi:
🔍 IM-UII CLI — Check Prerequisites
📋 Prerequisites Check
❌ Not logged in
No token found. Please run "imuii login" first.
Run: imuii login
❌ GitHub setup incomplete
Git is not configured: Git user.name or user.email is not configured
SSH keys not found: No SSH keys found in ~/.ssh
Alternative: Install GitHub CLI (gh) and run 'gh auth login'
❌ Prerequisites check failed
Please fix the issues above before continuing.
Tips untuk Memenuhi Prerequisites
#### Login ke IMUII
imuii login
#### Setup Git
# Configure Git user
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
#### Setup GitHub Authentication (Pilih salah satu)
Opsi 1: SSH Keys# Generate SSH key
ssh-keygen -t ed25519 -C "your.email@example.com"
# Add to SSH agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Add public key to GitHub
cat ~/.ssh/id_ed25519.pub
# Copy output dan paste ke GitHub Settings > SSH and GPG keys
# Install GitHub CLI
# Windows: winget install GitHub.cli
# macOS: brew install gh
# Linux: sudo apt install gh
# Login
gh auth login
🚀 Command: init
Inisialisasi project baru atau menambahkan IM-UII ke project existing.
imuii init
imuii init --quiet # Suppress output
imuii init --verbose # Verbose output
Flow Lengkap
#### 1. Prerequisites Check (Otomatis)
Sebelum memulai, CLI akan otomatis menjalankan prerequisites check:
🚀 IM-UII CLI — init
📋 Prerequisites Check
✅ Logged in
Email: user@example.com
✅ GitHub setup complete
Git user: John Doe
Connection: Can connect via HTTPS
✅ All prerequisites met
Jika prerequisites tidak terpenuhi, proses akan dihentikan dengan pesan error yang jelas.
#### 2. Project Type Detection
CLI akan mendeteksi apakah ini project baru atau existing:
Detecting project...
Project detected
Project Baru:
- User akan diminta memilih template
- CLI akan membuat project dari template yang dipilih
- CLI akan auto-detect framework dan language
- CLI akan menambahkan
imuii.jsonke project yang sudah ada
#### 3. Template Selection (Hanya untuk Project Baru)
User akan diminta memilih template:
? Select template:
❯ Next.js + TypeScript
Next.js + JavaScript
Vite + React + TypeScript
Vite + React + JavaScript
Templates Available:
nextjs-ts: Next.js + TypeScriptnextjs-js: Next.js + JavaScriptvite-react-ts: Vite + React + TypeScriptvite-react-js: Vite + React + JavaScript
#### 4. Project Configuration
CLI akan meminta konfigurasi project:
- Nama Project: Nama project (default: dari folder atau template)
- Build Command: Command untuk build project (default:
npm run build) - Start Command: Command untuk start development server (default:
npm run dev) - Domain: Subdomain untuk deployment (contoh:
my-project) - Email: Email untuk menerima deployment reports
- GitHub Repo: Repository GitHub (opsional, format:
owner/repo)
#### 5. Project Creation (Hanya untuk Project Baru)
Jika project baru, CLI akan membuat project dari template:
📝 Creating new project...
📦 Creating Next.js project with TypeScript...
⏳ This may take a moment, please wait...
Creating project from template...
✅ Project my-project created
Optimasi yang Diterapkan:
- ✅ Menggunakan npm cache (
--prefer-offline) - ✅ Skip npm install (
--skip-install) - ✅ Skip Git init (
--no-git) - ✅ Disable telemetry Next.js
- ✅ Timeout protection (2 menit untuk Next.js, 1 menit untuk Vite)
#### 6. Configuration File Creation
CLI akan membuat file imuii.json:
{
"name": "my-project",
"framework": "nextjs",
"language": "typescript",
"buildCommand": "npm install && npm run build",
"startCommand": "npm start",
"domain": "my-project",
"email": "user@example.com"
}
#### 7. Server Registration
CLI akan mendaftarkan project ke IM-UII server:
Registering project...
✅ Project registered on IM-UII server
🔑 Secret key received from server
🔗 Repository URL: https://github.com/Lab-Sisjarkom-IMUII/my-project-abc123.git
💾 Configuration updated with API response data
Data yang Dikirim ke Server:
{
"project_name": "my-project",
"owner_email": "user@example.com",
"owner_name": "John Doe",
"user_id": "uuid-from-jwt-token"
}
Response dari Server:
{
"success": true,
"data": {
"secret_key": "imuii_9132748520d28439e9dcc186e7ab1a2d...",
"project": {
"id": "uuid",
"name": "my-project",
"repo_url": "https://github.com/Lab-Sisjarkom-IMUII/my-project-abc123.git",
"status": "pending"
}
}
}
Fallback Mode:
Jika server tidak bisa diakses, CLI akan menggunakan fallback mode:
⚠️ Server registration failed, using fallback mode...
📝 Project info untuk testing:
- Project Name: my-project
- Owner Email: user@example.com
- Repo: owner/repo
- Secret: abc12345...
#### 8. Git Workflow Setup
CLI akan setup Git workflow otomatis:
Setting up Git workflow...
✅ Git workflow configured
Yang Dilakukan:
- Initialize Git repository (
git init) - Create initial commit
- Setup environment variables (
.envdenganIMUII_SECRET) - Connect to remote repository dari server
- Push to remote (jika repo sudah ada)
#### 9. GitHub Secret Setup (Opsional)
Jika GitHub repo disediakan dan GitHub CLI terinstall:
Setting GitHub secret...
✅ GitHub secret set
CLI akan otomatis set secret IMUII_SECRET di GitHub repository.
#### 10. Completion
🎉 Project created and configured!
📁 Project location: /path/to/my-project
📋 Next steps:
cd my-project
npm install
npm run dev
🚀 Your project is ready for development!
🔐 Command: login
Login ke IMUII CLI.
imuii login
imuii login --force # Force login even if already logged in
- Buka browser untuk OAuth flow
- User login di web
- Redirect kembali ke CLI dengan token
- Simpan token untuk penggunaan selanjutnya
Token disimpan di:
- Linux/Mac:
~/.imuii/credentials.json - Windows:
%APPDATA%/imuii/credentials.json
🚪 Command: logout
Logout dari IMUII CLI.
imuii logout
Ini akan menghapus token yang tersimpan.
👤 Command: whoami
Menampilkan informasi user yang sedang login.
imuii whoami
Logged in as: user@example.com
User ID: 550e8400-e29b-41d4-a716-446655440000
📊 Command: status
Menampilkan status project dan konfigurasi.
imuii status
Project: my-project
Status: deployed
Domain: my-project.imuii.id
Framework: nextjs
Language: typescript
⚙️ Command: config view
Menampilkan konfigurasi dari imuii.json.
imuii config view
✅ Command: config validate
Validasi file imuii.json.
imuii config validate
🔄 Command: git sync
Sync local repository dengan remote (pull + push).
imuii git sync
📋 Command: git status
Menampilkan Git status.
imuii git status
⬇️ Command: git pull
Pull latest changes dari remote.
imuii git pull
📄 Config File: imuii.json
Stores essential info for deployment.
| Field | Description |
|---|---|
name | Project name |
framework | Framework type (nextjs, vite, dll) |
language | Language used (js, ts) |
buildCommand | Build command |
startCommand | Start command |
domain | Subdomain name |
email | Owner email |
repo_url | GitHub repository URL (from server) |
secret_key | Secret key untuk deployment (from server) |
{
"name": "my-project",
"framework": "nextjs",
"language": "typescript",
"buildCommand": "npm install && npm run build",
"startCommand": "npm start",
"domain": "my-project",
"email": "user@example.com",
"repo_url": "https://github.com/Lab-Sisjarkom-IMUII/my-project-abc123.git",
"secret_key": "imuii_9132748520d28439e9dcc186e7ab1a2d..."
}
🔑 Environment Variables
File .env akan dibuat dengan:
IMUII_SECRET=imuii_9132748520d28439e9dcc186e7ab1a2d92f455d8a87fd9f717c0b825032cd761
IMUII_PROJECT_ID=my-project
⚠️ Important: File .env sudah otomatis di-ignore oleh Git. Jangan commit file ini!
🎯 Best Practices
1. Selalu Check Prerequisites
Sebelum menjalankan imuii init, selalu jalankan imuii check terlebih dahulu:
imuii check
imuii init
2. Gunakan Template yang Sesuai
Pilih template yang sesuai dengan kebutuhan:
- Next.js: Untuk project yang memerlukan SSR, SEO, atau full-stack
- Vite + React: Untuk project yang lebih sederhana, SPA, atau client-side only
3. Setup Git Sebelum Init
Untuk project existing, pastikan Git sudah di-setup:
git init
git add .
git commit -m "Initial commit"
imuii init
4. Simpan Secret Key dengan Aman
Secret key dari server sangat penting:
- Jangan commit
.envke Git (sudah di-ignore otomatis) - Jangan share secret key dengan orang lain
- Jika secret key ter-expose, hubungi admin untuk regenerate
5. Monitor Server Status
Pastikan server IM-UII berjalan sebelum melakukan init:
- Check server health endpoint
- Pastikan environment variables sudah di-set dengan benar
🐛 Troubleshooting
Prerequisites Check Gagal
Problem:imuii check menunjukkan prerequisites tidak terpenuhi.
Solutions:
- Not Logged In
imuii login
- Git Not Configured
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
- GitHub Authentication Missing
- Opsi 1: Setup SSH keys
ssh-keygen -t ed25519 -C "your.email@example.com"
# Add public key to GitHub
- Opsi 2: Install GitHub CLI
gh auth login
Project Creation Timeout
Problem: Project creation timeout atau sangat lambat. Solutions:- Clear npm cache
npm cache clean --force
- Check internet connection
- Pastikan koneksi internet stabil
- Coba lagi setelah beberapa saat
- Use cached version
- CLI sudah menggunakan
--prefer-offlinesecara otomatis - Pastikan npm cache tidak corrupt
- Manual template creation
- Buat project manual dengan
create-next-appataunpm create vite - Lalu jalankan
imuii initdi project yang sudah dibuat
Server Registration Gagal
Problem: Project tidak terdaftar di server. Solutions:- Check server connection
# Test server connection
curl https://api.imuii.id/health
- Check JWT token
imuii whoami
# Jika gagal, login lagi
imuii login
- User not found error
- Pastikan user sudah login di web terlebih dahulu
- User harus ter-sync dari Supabase Auth ke database server
- Hubungi admin jika masalah persist
- Fallback mode
- CLI akan otomatis menggunakan fallback mode jika server tidak bisa diakses
- Fallback mode hanya untuk testing, tidak ter-record di server
- Untuk production, pastikan server bisa diakses
Git Setup Gagal
Problem: Git workflow tidak ter-setup dengan benar. Solutions:- Check Git installation
git --version
- Check remote repository
git remote -v
- Manual Git setup
git init
git add .
git commit -m "Initial commit"
git remote add origin <repo_url>
git push -u origin main
GitHub Secret Tidak Ter-Set
Problem: GitHub secret tidak ter-set otomatis. Solutions:- Check GitHub CLI
gh --version
gh auth status
- Login GitHub CLI
gh auth login
- Check repository access
- Pastikan user memiliki write access ke repository
- Pastikan repository sudah dibuat
- Manual setup
- Buka GitHub repository settings
- Go to Secrets and variables > Actions
- Add secret
IMUII_SECRETdengan value dariimuii.json>secretKey
Project Tidak Muncul di Web
Problem: Project sudah terdaftar tapi tidak muncul di web. Solutions:- Check user ID
imuii whoami
# Pastikan user ID sama dengan yang di web
- Check server response
- Lihat output saat
imuii init - Pastikan "Project registered on IM-UII server" muncul
- Pastikan tidak menggunakan fallback mode
- Check web API
- Buka browser console di web
- Check network request ke
/api/v1/projects?owner_id=... - Pastikan response berisi project yang dibuat
- Refresh web page
- Coba refresh halaman di web
- Clear browser cache jika perlu
📚 Related Documentation
- [Getting Started](/docs/get-started) - Quick start guide untuk CLI dan Web
- [Deployment Flow](/docs/deployment-flow) - Memahami proses deployment
- [Troubleshooting](/docs/troubleshooting) - Solusi untuk masalah umum
- [API Reference](/docs/api-reference) - API endpoints yang digunakan CLI
💡 Tips
- Selalu jalankan
imuii checksebelumimuii init - Project yang dibuat via CLI otomatis muncul di web dashboard
- Anda bisa menggunakan CLI dan Web secara bersamaan
- CLI untuk setup, Web untuk monitoring dan management