npm package: @olenbetong/appframe-cli
Description: Utility functions for AppframeWeb
Latest version: 4.4.8

# Appframe CLI

Utility commands for deploying and maintaining Appframe Web applications.

## Installation

```sh
pnpm install --save-dev @olenbetong/appframe-cli
```

## Commands

Use `af <command> --help` for full usage with options.

### Core

- `af update`: Installs latest `@olenbetong/appframe-cli` globally. If in a workspace, also updates local dev dependency when present.
- `af launch`:
  - Opens the updater web app. Options: `--server <host>` (default `dev.obet.no`), `--all`, `--browser <chrome|firefox|msedge>`.
- `af auth [env]`:
  - Logs in to `dev|stage|prod` (or a hostname) and stores session cookies in `~/.af`. Options: `--username <user>`.
- `af auth-cookie [env]`:
  - Prints the auth cookie string for scripting. `env` as above.

### Change Management

- `af namespace-to-prod [namespace]` (alias `ntp`):
  - From dev → stage → prod: generate + deploy on dev, download+apply+deploy on stage, and download on prod.
  - Options: `--skip-generate` (dev), `--apply` (apply on prod after download), `--hold` (put transactions on hold on prod/test).
- `af generate [namespace]`:
  - Generates transactions on a server and lists them. Options: `--server <host>` (default `dev.obet.no`).
- `af list [namespace]`:
  - Lists transactions to apply or deploy. Options:
    - `--server <host>`
    - `--type <apply|deploy>` (interactive prompt if TTY; defaults to `apply` in non‑TTY)
    - `--group` (show count per namespace)
- `af apply [namespace]`:
  - Applies updates. Interactive confirmation by default. Options:
    - `--server <host>` (default `test.obet.no`)
    - `--preapprove <name>` (repeatable; names to apply without prompt)
- `af deploy [namespace]`:
  - Deploys transactions. Options: `--server <host>`.
- `af check-updates`:
  - Shows how many updates are available to download per namespace. Options: `--server <host>`.
- `af download [namespace]`:
  - Downloads transactions. Options: `--server <host>`.

### Data Resources (Data API)

- `af resources list [search]`:
  - Lists available resources (table/view/procedure). Options: `--server <host>`.
- `af resources view [resource]`:
  - Prints the resource definition. Options: `--server <host>`.
- `af resources generate <resource>`:
  - Generates a data object or procedure client snippet. Common options:
    - `--id <id>` (default `dsDataObject`)
    - `--global` (use `af.data` globals)
    - `--types` (include generated TS types)
    - `--fields [f1,f2]` (limit fields; supports interactive selection with `--fields`)
    - `--permissions <IUD>` (Insert/Update/Delete flags)
    - `--max-records <n>` (default `50` for data objects)
    - `--sort-order <field:Asc|Desc|AscNullsLast|DescNullsFirst,...>`
    - `--master <Name[:path]>` and `--link-fields <this:master,...>`
    - `--expose [id]` (expose on `af.article.dataObjects`)
    - `--dynamic`, `--unique <table>`
    - `--overrides "Field:Type,Param:Type"`
    - `--group-by <a,b>`, `--aggregates <Field:SUM,...>`, `--distinct`, `--where <clause>`
- `af resources add <id>`: Adds a data resource by DB object id. Options: `--server <host>`, `--name [name]`.
- `af resources delete <id>`: Deletes a data resource by id or name. Options: `--server <host>`.

### Bundles

- `af bundle create`: Scaffold a new bundle project.
- `af bundle upload [package]`:
  - Packs and uploads an npm package as a bundle. Options: `--bundle <name>` to override default.
- `af bundle publish [package]`:
  - Publishes the latest bundle version and deploys it (dev→stage→prod download). Uses current package if none provided.

### Website Assets

- `af assets deploy`:
  - Uploads site scripts, styles, and templates based on `package.json.appframe.assets`.
  - Options: `--server <host>` (default `dev.obet.no`), `--no-test`, `--production`, `--hostname <host>` (limit to one site).
- `af assets publish`:
  - Publishes uploaded assets with a description `v<version> (<git sha>)`.
  - Options: `--server <host>`, `--hostname <host>`.