@selectfromuser/cli
v2.1.1
Published
Command line tool for Select app deployments
Readme
Select CLI
Command line tool for connecting a local project to Select and deploying static app builds.
Install
npm install -g @selectfromuser/cliUsage
sapp init [template]
sapp connect --key <key>
sapp connect --local --key <key>
sapp env [prod|dev]
sapp use <alias>
sapp deploy
sapp deploy <alias> <path> -m="message"
sapp deployments
sapp deployments <alias>
sapp deployments <alias> files <deployment-id>
sapp deployments <alias> set <deployment-id>
sapp rollback <deployment-id>
sapp rollback <alias> <deployment-id>
sapp apps
sapp apps <id|alias>
sapp apps <id|alias> get
sapp apps <id|alias> update <file>
sapp app create <alias>
sapp member
sapp member signup -loginid <id> --email <email> --phone <phone> --password <password>
sapp member <id|loginid>
sapp member <id|loginid> set --permission=Admin,User,Manager
sapp member <id|loginid> set --propertyKey=LEVEL --propertyValue="1"
sapp member <id|loginid> set --profile="{\"a\":1}"
sapp member login [-loginid <id>] [--password <password>]
sapp api
sapp api list
sapp api info <service>
sapp api describe <service>
sapp api call /<prefix>/<path> --input '{"a":1}'
sapp api call GET /<prefix>/<path>
sapp api call POST /<prefix>/<path> --input '{"a":1}'
sapp api get <service>
sapp api validate <file>
sapp api plan <file>
sapp api apply <file>
sapp api delete <file>
sapp data list
sapp data <id|name>
sapp data <id|name> query --input="SELECT 1"
sapp data <id|name> query --prod --input="SELECT 1"
sapp data <id|name> query
sapp data <id|name> history
sapp db list
sapp open [alias]sapp connect creates an app.json file in the current directory. Keep app.json private because it contains credentials.
Commands
init
Create a starter app in the current directory.
sapp init
sapp init local-single-htmlTemplates:
local-single-html: local single HTML app with Tailwind CSS CDN. This is the default.local,html,single-html: aliases forlocal-single-html.
This writes index.html and does not overwrite an existing file.
connect
Connect the current directory to a Select project.
sapp connect --key <key>
sapp connect --local --key <key>Options:
--key <key>: App Deploy Key(pat_) or Agent API Key(pa_). If omitted, the CLI prompts for it.--deployToken <token>,--apiKey <key>: legacy aliases for--key.--local: usehttp://localhost:9502/v3.--api-base-url <url>: API base URL for this project.
This writes app.json in the current directory and creates or updates AGENTS.md. App Deploy Key login also creates or updates app starter files. Agent API Key login skips app starter files.
use
Set the default app alias for later commands.
sapp use <alias>After this, commands such as sapp deploy, sapp deployments, and sapp rollback <deployment-id> can use the saved alias.
env
Set the API execution environment used by sapp api call.
sapp env
sapp env dev
sapp env prodThe default environment is dev. sapp api call uses a different endpoint for each environment:
dev:apihub-dev...prod:apihub...
For local API base URLs, the CLI uses apihub-dev.localhost:9502 or apihub.localhost:9502.
deploy
Deploy a static app directory. The target directory must contain index.html.
sapp deploy
sapp deploy <alias>
sapp deploy <alias> <path>
sapp deploy <alias> -m="message"
sapp deploy <alias> <path> -m="message"Arguments:
<alias>: app alias. If omitted, the alias saved bysapp use <alias>is used.<path>: directory to deploy. Defaults to the current directory.
Options:
-m, --message <message>: deployment message.--path <path>: directory to deploy.
The CLI respects .gitignore and .sappignore in the deploy directory and skips .git, .gitignore, .sappignore, node_modules, and app.json.
deployments
List deployments for an app.
sapp deployments
sapp deployments <alias>The active deployment is marked with *.
Show the files saved in a deployment:
sapp deployments <alias> files <deployment-id>Set a previous deployment as the active deployment:
sapp deployments <alias> set <deployment-id>This is equivalent to rolling back to that deployment.
rollback
Set a deployment as the active deployment.
sapp rollback <deployment-id>
sapp rollback <alias> <deployment-id>If <alias> is omitted, the alias saved by sapp use <alias> is used.
app
List, inspect, export, update, and create apps.
sapp apps
sapp apps <id|alias>
sapp apps <id|alias> get
sapp apps <id|alias> update <file>
sapp app create <alias>Commands:
sapp apps: list apps for the connected project.sapp apps <id|alias>: show one app summary, access settings, and connected API services.sapp apps <id|alias> get: print editable app YAML.sapp apps <id|alias> update <file>: update app metadata, deploy config, and access settings from YAML.sapp app create <alias>: create an app using the alias as its title. If omitted, the CLI prompts for the alias.
App commands require an App Deploy Key or Agent API Key with the app scope.
open
Open the Select console or app URL in your browser.
sapp open
sapp open <alias>Without an alias, this opens the Select project console. With an alias, this opens the app URL.
member
Manage project members.
sapp member
sapp member signup -loginid <id> --email <email> --phone <phone> --password <password>
sapp member <id>
sapp member <loginid>
sapp member <id|loginid> set --permission=Admin,User,Manager
sapp member <id|loginid> set --propertyKey=LEVEL --propertyValue="1"
sapp member <id|loginid> set --profile="{\"a\":1}"
sapp member login
sapp member login -loginid <id> --password <password>Commands:
sapp member: list members.sapp member signup: create a member.sapp member <id|loginid>: show member details.sapp member <id|loginid> set --permission=...: replace member roles.sapp member <id|loginid> set --propertyKey=... --propertyValue=...: set one internal property.sapp member <id|loginid> set --profile=...: replaceprofile_json.sapp member login: call/api/loginand save the session token inapp.json.
Member commands require an App Deploy Key or Agent API Key with the member scope. sapp member login uses the project API login flow and stores memberSessionToken; sapp api call uses that token when it exists.
api
Inspect, call, and manage project API definitions.
sapp api
sapp api list
sapp api info <service>
sapp api describe <service>
sapp api call /<prefix>/<path> --input '{"a":1}'
sapp api call GET /<prefix>/<path>
sapp api call POST /<prefix>/<path> --input '{"a":1}'
sapp api get <service>
sapp api validate <file>
sapp api plan <file>
sapp api apply <file>
sapp api delete <file>Commands:
sapp api: show API help.sapp api list: list API services and child APIs.sapp api info <service>: show service summary, endpoints, and connected apps.sapp api describe <service>: show the current API service definition as JSON.sapp api call /<prefix>/<path> --input '{"a":1}': test the child API withPOST.sapp api call GET /<prefix>/<path>: test the child API withGET.sapp api call POST /<prefix>/<path> --input '{"a":1}': test the child API withPOST.sapp api get <service>: show the current API service definition as YAML.sapp api validate <file>: parse and validate a local API service YAML file.sapp api plan <file>: show create/update/no-change status. Updates show only changed lines with-and+.sapp api apply <file>: create or update API services and child APIs from YAML.sapp api delete <file>: delete the child APIs listed under each service in the YAML file.
API commands require an App Deploy Key or Agent API Key with the api scope. sapp api call uses the same internal test endpoints as the API Service page.
Example API service YAML:
name: CRM
prefix: crm
readme: ""
acl:
mode: owner
apis:
- method: GET
path: properties
query:
type: http
method: GET
url: https://httpbin.selectfromuser.com/anything
params:
page: "{{int:page=1}}"
keyword: "{{keyword=sample}}"
headers:
Accept: application/json
_variables:
missing: error
acl:
mode: publishedMultiple API services can be stored in one file with YAML document separators:
name: CRM
prefix: crm
apis:
- method: GET
path: properties
query:
type: http
method: GET
url: https://httpbin.selectfromuser.com/anything
---
name: SQL Tools
prefix: sql-tools
apis:
- method: POST
path: users
query:
type: sql
resourceType: mysql
sql: |
SELECT *
FROM users
WHERE name LIKE CONCAT('%', {{keyword=sample}}, '%')data
List data resources and run MySQL data queries.
sapp data list
sapp data <id|name>
sapp data <id|name> query --input="SELECT 1"
sapp data <id|name> query --prod --input="SELECT 1"
sapp data <id|name> query
sapp data <id|name> history
sapp db listCommands:
sapp data list: list project resources.sapp data <id|name>: show resource summary.sapp data <id|name> query --input="...": run SQL against the selected resource.sapp data <id|name> query --prod --input="...": run SQL against the production connection.sapp data <id|name> query: prompt for SQL, then run it.sapp data <id|name> history: show recent query pad history.
Data query defaults to dev; pass --prod to use the production connection. Query runs are saved to GenProjectResourcePad with the agent id. Data commands require an App Deploy Key or Agent API Key with the resource scope. sapp db is an alias for sapp data.
Configuration
The default API endpoint is https://apihub.selectfromuser.com/v3.
Set SELECT_API_BASE_URL to override the default API endpoint.
SELECT_API_BASE_URL=http://localhost:9502/v3 sapp connect --key <key>