Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions skills/vefaas-cli/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: vefaas
description: Deploy and manage serverless applications on Volcengine veFaaS. Use when the user wants to deploy web apps, manage functions (pull code, upload and deploy), configure environment variables, or work with veFaaS services.
allowed-tools: Bash(vefaas:*)
---

# vefaas: Volcengine FaaS CLI

**vefaas** is the command-line tool for Volcengine Function Service (veFaaS). It enables serverless application deployment, function management, and configuration through a streamlined workflow.

## Installation

```bash
npm i -g https://vefaas-cli.tos-cn-beijing.volces.com/volcengine-vefaas-latest.tgz
```

Verify installation:
```bash
vefaas --version
```

## Core Workflow

The typical deployment pattern:

1. **Check Node.js**: `node --version` (requires >= 18, recommended 20+)
- If version is too low, switch using nvm (`nvm use 20`) or fnm (`fnm use 20`), or manually install a newer version
2. **Check CLI**: `vefaas --version` to verify installation
3. **Check Auth**: `vefaas login --check` to verify login status
- If not logged in, run `vefaas login --sso` (opens browser, auto-completes when user authorizes - no manual input needed)
4. **Deploy**: `vefaas deploy --newApp <name> --gatewayName $(vefaas run listgateways --first) --yes`
5. **Access**: `vefaas domains` to view URLs

## Quick Commands

| Purpose | Command |
|---------|---------|
| Check auth | `vefaas login --check` |
| Login (SSO) | `vefaas login --sso` (non-interactive: opens browser, auto-completes when authorized, **recommended**) |
| Login (AK/SK) | `vefaas login --accessKey <AK> --secretKey <SK>` |
| Init from template | `vefaas init --template <name>` |
| Deploy new app | `vefaas deploy --newApp <name> --gatewayName $(vefaas run listgateways --first) --yes` |
| Deploy existing | `vefaas deploy --app <name> --yes` |
| List gateways | `vefaas run listgateways --first` |
| View URLs | `vefaas domains` |
| Set env var | `vefaas env set KEY VALUE` |
| View config | `vefaas config list` |
| Pull code | `vefaas pull --func <name>` |
| Inspect project | `vefaas inspect` |

## Global Options

| Option | Description |
|--------|-------------|
| `-d, --debug` | Enable debug mode for troubleshooting |
| `--yes` | Non-interactive mode (required for CI/AI coding) |
| `--region` | Region override (e.g., cn-beijing) |

## Cookbooks

Step-by-step guides for common scenarios:

- **[Template Quickstart](cookbooks/template-quickstart.md)** - Create and deploy from official templates
- **[Deploy Existing Code](cookbooks/deploy-existing-code.md)** - Deploy your existing project
- **[Manage Functions](cookbooks/manage-functions.md)** - Manage functions (pull code, upload and deploy)

## References

Detailed documentation on specific topics:

- **[Authentication](references/authentication.md)** - Login methods and credentials
- **[Configuration](references/configuration.md)** - Config files and settings
- **[Environment Variables](references/environment-variables.md)** - Managing env vars
- **[Framework Detection](references/framework-detection.md)** - Supported frameworks and auto-detection
- **[Troubleshooting](references/troubleshooting.md)** - Debug mode, common issues, and solutions

## Important Notes

- Always use `--yes` for non-interactive mode in CI/CD and AI coding scenarios
- Use `$(vefaas run listgateways --first)` to get an available gateway
- Config is stored in `.vefaas/config.json` after linking
- Use `--debug` or `-d` to troubleshoot issues
144 changes: 144 additions & 0 deletions skills/vefaas-cli/cookbooks/deploy-existing-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Cookbook: Deploy Existing Code

Deploy your existing project to veFaaS with automatic framework detection.

## Prerequisites

- vefaas CLI installed
- Valid credentials (AKSK/SSO)
- Existing project with supported framework

## Scenario A: Simple Deployment (No Env Dependencies)

For projects without database or external service dependencies.

### One-liner Deployment

```bash
cd your-project

# Deploy with auto-detection
vefaas deploy --newApp my-app --gatewayName $(vefaas run listgateways --first) --yes
```

The CLI will:
1. Auto-detect framework (Next.js, Nuxt, FastAPI, etc.)
2. Configure build command and output path
3. Run local build
4. Package and upload
5. Deploy and return access URL

> [!NOTE]
> - **Static sites**: Auto-detected static projects (Vite, Vitepress, etc.) will be served via auto-generated Caddyfile
> - **Server apps**: If your app requires server logic, ensure it listens on port **8000** by default

### Verify Detection

```bash
# Check what vefaas detected
vefaas inspect

# Output:
# > Detected Settings:
# > - Build Command: npm run build
# > - Output Directory: .next
# > - Start Command: node server.js
# > - Port: 3000
# > - Runtime: native-node20/v1
# > - Framework: next.js
```

## Scenario B: With Environment Dependencies

For projects requiring database connections, API keys, etc.

### Step 1: Link Without Deploying

```bash
cd your-project

# Create app and link, but don't deploy yet
vefaas link --newApp my-app --gatewayName $(vefaas run listgateways --first) --yes
```

### Step 2: Configure Environment Variables

```bash
# Set individual variables
vefaas env set DATABASE_URL "postgres://user:pass@host:5432/db"
vefaas env set API_KEY "your-api-key"

# Or import from .env file
vefaas env import ./.env.prod
```

Example `.env.prod` file:
```
PGHOST=db.volces.com
PGDATABASE=mydb
PGUSER=admin
PGPASSWORD=secret
API_KEY="your-api-key"
```

### Step 3: Deploy

```bash
vefaas deploy
```

## Scenario C: Custom Build Configuration

When auto-detection doesn't match your setup.

### Override via Command Line

```bash
vefaas deploy \
--newApp my-app \
--gatewayName $(vefaas run listgateways --first) \
--buildCommand "npm run build" \
--outputPath dist \
--command "node dist/index.js" \
--port 3000 \
--yes
```

### Or Configure Persistently

```bash
# Set config first
vefaas config --buildCommand "npm run build" --outputPath dist --command "node dist/index.js" --port 3000

# Then deploy
vefaas deploy --newApp my-app --gatewayName $(vefaas run listgateways --first) --yes
```

## Scenario D: Deploy to Existing Application

When you already have a veFaaS application.

```bash
# By app name
vefaas deploy --app my-existing-app --yes

# By app ID
vefaas deploy --appId app-xxxxx --yes
```

## Supported Frameworks

| Framework | Runtime | Auto-detected |
|-----------|---------|---------------|
| FastAPI | native-python3.12/v1 | Yes |
| Django | native-python3.12/v1 | Yes |
| Flask | native-python3.12/v1 | Yes |
| Express | native-node20/v1 | Yes |
| Next.js | native-node20/v1 | Yes |
| Nuxt | native-node20/v1 | Yes |
| NestJS | native-node20/v1 | Yes |
| Remix | native-node20/v1 | Yes |
| Vite | native-node20/v1 | Yes |
| Astro | native-node20/v1 | Yes |
| Vitepress | native-node20/v1 | Yes |
| Angular | native-node20/v1 | Yes |
162 changes: 162 additions & 0 deletions skills/vefaas-cli/cookbooks/manage-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Cookbook: Manage Functions

Pull, modify, and redeploy existing veFaaS functions.

## Prerequisites

- vefaas CLI installe
- Valid credentials (AKSK/SSO)
- Existing function in veFaaS console

## Scenario A: Pull and Modify Function Code

### Step 1: Pull Function Code

```bash
# By function name
vefaas pull --func my-function-name

# By function ID
vefaas pull --funcId func-xxxxx
```

This creates a directory with the function code:
```
my-function-name/
├── app.py (or index.js)
├── requirements.txt (or package.json)
├── run.sh
└── .vefaas/
└── config.json
```

### Step 2: Modify Code

```bash
cd my-function-name
# Edit your code
```

### Step 3: Redeploy

```bash
vefaas deploy
# or with explicit function reference
vefaas deploy --func my-function-name --yes
```

## Scenario B: Push Code to Existing Function

> [!NOTE]
> `push` only uploads code without triggering deployment. For most cases, use `deploy` instead.

```bash
# Push code only (no deployment)
vefaas push --func my-function-name --yes
```

## Scenario C: Manage Environment Variables

### List Variables

```bash
vefaas env list
# Output:
# > Environment Variables:
# DATABASE_URL=postgres://...
# API_KEY=xxx
```

### Get Single Variable

```bash
vefaas env get DATABASE_URL
```

### Set Variables

```bash
# Set single variable
vefaas env set NEW_KEY "new-value"

# Update existing variable
vefaas env set DATABASE_URL "new-connection-string"
```

### Import from File

```bash
vefaas env import .env
```

## Scenario D: View and Update Configuration

### View Current Config

```bash
vefaas config list

# Output:
# > Config Summary:
# - Application ID: app-xxxxx
# - Function ID: func-xxxxx
# - Region: cn-beijing
# - Gateway ID: gw-xxxxx
# - System URL: https://xxx.apigateway-cn-beijing.volceapi.com/
#
# > Remote Function Settings:
# - Build Command: npm run build
# - Output Directory: dist
# - Start Command: node dist/index.js
# - Port: 3000
```

### Pull Config from Cloud

```bash
# By app name
vefaas config pull --app my-app

# By function name
vefaas config pull --func my-function
```

### Update Settings

```bash
vefaas config --buildCommand "npm run build:prod" --port 8080
```

## Scenario E: Debug Issues

### Enable Debug Mode

```bash
vefaas --debug deploy
# or
vefaas -d inspect
```

### View Debug Logs

```bash
# Logs are saved to ~/.vefaas/logs/
ls -lt ~/.vefaas/logs/ | head -5

# View latest log
cat ~/.vefaas/logs/$(ls -t ~/.vefaas/logs/ | head -1)
```

### Common Issues

**Authentication Failed:**
```bash
vefaas login --check
vefaas login # Re-authenticate
```

**Framework Not Detected:**
```bash
vefaas inspect # Check detection
vefaas deploy --buildCommand "..." --command "..." --port 8000 --yes
```
Loading
Loading