IMUII LogoIMUII

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)

Terminal
npm install -g imuii

Menggunakan npx (Tanpa Install)

Terminal
npx imuii init

Verifikasi Instalasi

Terminal
imuii --version


🔍 Command: check

Mengecek apakah semua prerequisites sudah terpenuhi sebelum inisialisasi.

Terminal
imuii check
imuii check --quiet  # Minimal output

Yang Dicek

  1. Akun/Login Check
  • ✅ Apakah user sudah login (imuii login)
  • ✅ Apakah JWT token valid
  • ✅ Informasi user (email, user ID)
  1. 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

Terminal
imuii login

#### Setup Git

Terminal
# 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

Terminal
# 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

Opsi 2: GitHub CLI

Terminal
# 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.

Terminal
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
Project Existing:
  • CLI akan auto-detect framework dan language
  • CLI akan menambahkan imuii.json ke 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 + TypeScript
  • nextjs-js: Next.js + JavaScript
  • vite-react-ts: Vite + React + TypeScript
  • vite-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 (.env dengan IMUII_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.

Terminal
imuii login
imuii login --force  # Force login even if already logged in

Flow:
  1. Buka browser untuk OAuth flow
  2. User login di web
  3. Redirect kembali ke CLI dengan token
  4. Simpan token untuk penggunaan selanjutnya

Token disimpan di:

  • Linux/Mac: ~/.imuii/credentials.json
  • Windows: %APPDATA%/imuii/credentials.json

🚪 Command: logout

Logout dari IMUII CLI.

Terminal
imuii logout

Ini akan menghapus token yang tersimpan.


👤 Command: whoami

Menampilkan informasi user yang sedang login.

Terminal
imuii whoami

Output:

Logged in as: user@example.com
User ID: 550e8400-e29b-41d4-a716-446655440000


📊 Command: status

Menampilkan status project dan konfigurasi.

Terminal
imuii status

Output:

Project: my-project
Status: deployed
Domain: my-project.imuii.id
Framework: nextjs
Language: typescript


⚙️ Command: config view

Menampilkan konfigurasi dari imuii.json.

Terminal
imuii config view


✅ Command: config validate

Validasi file imuii.json.

Terminal
imuii config validate


🔄 Command: git sync

Sync local repository dengan remote (pull + push).

Terminal
imuii git sync


📋 Command: git status

Menampilkan Git status.

Terminal
imuii git status


⬇️ Command: git pull

Pull latest changes dari remote.

Terminal
imuii git pull


📄 Config File: imuii.json

Stores essential info for deployment.

FieldDescription
nameProject name
frameworkFramework type (nextjs, vite, dll)
languageLanguage used (js, ts)
buildCommandBuild command
startCommandStart command
domainSubdomain name
emailOwner email
repo_urlGitHub repository URL (from server)
secret_keySecret key untuk deployment (from server)

Example:

{
  "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:

Terminal
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:

Terminal
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 .env ke 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:
  1. Not Logged In

Terminal
imuii login

  1. Git Not Configured

Terminal
git config --global user.name "Your Name"
   git config --global user.email "your.email@example.com"

  1. GitHub Authentication Missing
  • Opsi 1: Setup SSH keys

Terminal
ssh-keygen -t ed25519 -C "your.email@example.com"
     # Add public key to GitHub

  • Opsi 2: Install GitHub CLI

Terminal
gh auth login

Project Creation Timeout

Problem: Project creation timeout atau sangat lambat. Solutions:
  1. Clear npm cache

Terminal
npm cache clean --force

  1. Check internet connection
  • Pastikan koneksi internet stabil
  • Coba lagi setelah beberapa saat
  1. Use cached version
  • CLI sudah menggunakan --prefer-offline secara otomatis
  • Pastikan npm cache tidak corrupt
  1. Manual template creation
  • Buat project manual dengan create-next-app atau npm create vite
  • Lalu jalankan imuii init di project yang sudah dibuat

Server Registration Gagal

Problem: Project tidak terdaftar di server. Solutions:
  1. Check server connection

Terminal
# Test server connection
   curl https://api.imuii.id/health

  1. Check JWT token

Terminal
imuii whoami
   # Jika gagal, login lagi
   imuii login

  1. 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
  1. 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:
  1. Check Git installation

Terminal
git --version

  1. Check remote repository

Terminal
git remote -v

  1. Manual Git setup

Terminal
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:
  1. Check GitHub CLI

Terminal
gh --version
   gh auth status

  1. Login GitHub CLI

Terminal
gh auth login

  1. Check repository access
  • Pastikan user memiliki write access ke repository
  • Pastikan repository sudah dibuat
  1. Manual setup
  • Buka GitHub repository settings
  • Go to Secrets and variables > Actions
  • Add secret IMUII_SECRET dengan value dari imuii.json > secretKey

Project Tidak Muncul di Web

Problem: Project sudah terdaftar tapi tidak muncul di web. Solutions:
  1. Check user ID

Terminal
imuii whoami
   # Pastikan user ID sama dengan yang di web

  1. Check server response
  • Lihat output saat imuii init
  • Pastikan "Project registered on IM-UII server" muncul
  • Pastikan tidak menggunakan fallback mode
  1. Check web API
  • Buka browser console di web
  • Check network request ke /api/v1/projects?owner_id=...
  • Pastikan response berisi project yang dibuat
  1. 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 check sebelum imuii 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