@raster-app/cli 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -25
- package/dist/index.js +978 -148
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -14,48 +14,109 @@ Run a single command without installing — the binary is `raster`:
|
|
|
14
14
|
npx -p @raster-app/cli raster whoami
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
A standalone macOS (Apple Silicon) binary ships with each [GitHub release](https://github.com/raster-app/raster-cli/releases) — no Node required.
|
|
18
|
-
|
|
19
17
|
## Authenticate
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
There are two ways to sign in: an interactive OAuth login tied to your user account, or an organization API key for CI.
|
|
22
20
|
|
|
23
21
|
```sh
|
|
24
22
|
raster auth login
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
With no `--api-key`, `raster auth login` signs you in over OAuth. When a browser is available (an interactive session with a display) it opens a **browser authorization-code flow** with a local loopback redirect; otherwise — over SSH or on a headless machine — it falls back to the **device authorization grant**, printing a short code and a URL you approve in a browser on any device. Pass `--browser` or `--device` to force either.
|
|
26
|
+
|
|
27
|
+
OAuth tokens (access + refresh) are stored in `~/.config/raster/config.json` with owner-only permissions. The CLI refreshes the access token automatically before it expires and rotates the refresh token; when the saved login can no longer be refreshed, it asks you to run `raster auth login` again.
|
|
28
|
+
|
|
29
|
+
For CI and scripts, use an organization API key instead (create one in Raster under Settings → API Keys):
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
raster auth login --api-key pk_…
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or set `RASTER_API_KEY`. The bearer credential resolves from the `--api-key` flag, then a stored OAuth token, then `RASTER_API_KEY`, then a stored config API key. `raster auth status` shows which credential is active. `raster auth logout` revokes an OAuth token and removes stored credentials.
|
|
28
36
|
|
|
29
|
-
|
|
37
|
+
## Org and library are derived from the key
|
|
38
|
+
|
|
39
|
+
An API key is scoped to one organization and a set of libraries. `raster auth login` captures that scope into the config file, so commands resolve it locally — no extra request per command:
|
|
40
|
+
|
|
41
|
+
- **`--org` is optional** — the organization comes from the key.
|
|
42
|
+
- **`--library` is optional when the key has a single library.** When the key can reach several, commands that act on one library ask you to pass `--library <id>` and list the choices.
|
|
43
|
+
|
|
44
|
+
Pass `--org` / `--library` to override, or to pick a library when the key spans more than one. A key supplied via `RASTER_API_KEY` with no prior login resolves its scope from the API on first use. If a key's library access changes in Raster, re-run `raster auth login` to refresh the cached list, or pass `--library`.
|
|
45
|
+
|
|
46
|
+
A **broad OAuth login is scoped to your user**, reaching every organization you belong to. Because no single org is implied, commands that act on one organization require you to choose it: pass `--org <id>`, set `RASTER_ORG`, or rely on a `defaultOrg` in config; run `raster whoami` to list the organizations you can reach. Without a selection the command stops with a clear error rather than guessing. An OAuth login narrowed to a single organization resolves that org automatically.
|
|
47
|
+
|
|
48
|
+
## Global flags
|
|
49
|
+
|
|
50
|
+
These work on every command, before or after the subcommand.
|
|
51
|
+
|
|
52
|
+
| Flag | Purpose |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `--api-key <key>` | API key (overrides `RASTER_API_KEY` and the config file) |
|
|
55
|
+
| `--org <organizationId>` | Organization id (derived from an API key or an org-scoped OAuth login; for a broad OAuth login pass this, set `RASTER_ORG`, or a config `defaultOrg`) |
|
|
56
|
+
| `--library <libraryId>` | Library id (derived from the key when it has one library) |
|
|
57
|
+
| `--json` | Print the raw API payload to stdout and nothing else |
|
|
58
|
+
| `--verbose` | Log each request to stderr (method, path, masked key, status, duration) |
|
|
30
59
|
|
|
31
60
|
## Commands
|
|
32
61
|
|
|
33
|
-
|
|
34
|
-
|
|
62
|
+
Asset ids are always positional. `--library` selects the library when the key can reach more than one. `raster <command> --help` lists every flag.
|
|
63
|
+
|
|
64
|
+
### `auth`
|
|
65
|
+
|
|
66
|
+
| Command | Description | Example |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `raster auth login` | Sign in over OAuth (browser when available, otherwise a device code; force with `--device`/`--browser`), or validate an API key with `--api-key`. | `raster auth login` |
|
|
69
|
+
| `raster auth logout` | Revoke the OAuth token (if any) and remove stored credentials. | `raster auth logout` |
|
|
70
|
+
| `raster auth status` | Show which credential is in use, its source, and the organization it reaches. | `raster auth status` |
|
|
71
|
+
|
|
72
|
+
### `whoami`
|
|
73
|
+
|
|
74
|
+
```sh
|
|
35
75
|
raster whoami
|
|
36
|
-
raster libraries ls|create|rename
|
|
37
|
-
raster assets ls|get|search|download|upload|rm|describe|transfer
|
|
38
|
-
raster tags ls|add|rm
|
|
39
|
-
raster orgs create
|
|
40
76
|
```
|
|
41
77
|
|
|
42
|
-
|
|
78
|
+
Show the organizations, plan, and libraries the current credential can access. An OAuth login lists every organization you belong to, so you can pick one with `--org`.
|
|
79
|
+
|
|
80
|
+
### `libraries`
|
|
81
|
+
|
|
82
|
+
| Command | Description | Example |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| `raster libraries ls` | List libraries in the organization (`--page`, `--page-size`). | `raster libraries ls` |
|
|
85
|
+
| `raster libraries create --name <name>` | Create a library (`--slug` optional). | `raster libraries create --name "Brand"` |
|
|
86
|
+
| `raster libraries rename --name <name>` | Rename the library. | `raster libraries rename --name "Brand assets"` |
|
|
87
|
+
|
|
88
|
+
### `assets`
|
|
89
|
+
|
|
90
|
+
| Command | Description | Example |
|
|
91
|
+
| --- | --- | --- |
|
|
92
|
+
| `raster assets ls` | List assets; filter with `--tag` (up to 5), page with `--page`/`--page-size`. | `raster assets ls --library brand --tag sunset` |
|
|
93
|
+
| `raster assets get <assetId>` | Show one asset's metadata. | `raster assets get asset_123` |
|
|
94
|
+
| `raster assets search <query>` | Search across the organization (`--library` scopes to one). | `raster assets search "golden hour"` |
|
|
95
|
+
| `raster assets download <assetId>` | Download the file (`-o` path, `--force` to overwrite). | `raster assets download asset_123 -o photo.png` |
|
|
96
|
+
| `raster assets upload <files...>` | Upload local files (batched at 20 per request). | `raster assets upload ./photos/*.png` |
|
|
97
|
+
| `raster assets rm <assetIds...>` | Move assets to trash (`--yes` skips the prompt). | `raster assets rm asset_123 asset_456` |
|
|
98
|
+
| `raster assets describe <assetId> --text <text>` | Set an asset's description. | `raster assets describe asset_123 --text "Hero shot"` |
|
|
99
|
+
| `raster assets transfer <assetIds...> --to <libraryId>` | Move assets to another library. | `raster assets transfer asset_123 --to archive` |
|
|
100
|
+
|
|
101
|
+
### `tags`
|
|
102
|
+
|
|
103
|
+
| Command | Description | Example |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| `raster tags ls` | List tags in the library (`--limit`). | `raster tags ls --library brand` |
|
|
106
|
+
| `raster tags add <assetIds...> --tag <tag...>` | Add tags to assets. | `raster tags add asset_123 --tag launch` |
|
|
107
|
+
| `raster tags rm <assetIds...> --tag <tag...>` | Remove tags from assets. | `raster tags rm asset_123 --tag launch` |
|
|
108
|
+
|
|
109
|
+
### `orgs`
|
|
43
110
|
|
|
44
111
|
```sh
|
|
45
|
-
raster
|
|
46
|
-
raster assets ls --org org_123 --library lib_456 --tag sunset
|
|
47
|
-
raster assets upload --org org_123 --library lib_456 ./photos/*.png
|
|
48
|
-
raster assets search --org org_123 "golden hour" --json | jq '.hits[].id'
|
|
49
|
-
raster orgs create --email you@example.com --save
|
|
112
|
+
raster orgs create --email <email> [--name <name>] [--save]
|
|
50
113
|
```
|
|
51
114
|
|
|
52
|
-
|
|
115
|
+
Create an organization and library with no account (held 30 days until claimed). Prints the claim URL; `--save` stores the minted key. Anonymous — sends no API key.
|
|
53
116
|
|
|
54
|
-
## Output
|
|
117
|
+
## Output and scripting
|
|
55
118
|
|
|
56
|
-
|
|
57
|
-
- `--json` prints the raw API payload to stdout and nothing else.
|
|
58
|
-
- `--verbose` logs each request (method, path, masked key, status, duration) to stderr.
|
|
119
|
+
Human-readable tables print to stdout; progress and notes go to stderr, so stdout stays pipeable. Add `--json` for machine-readable output — e.g. `raster assets search "sunset" --json | jq '.hits[].id'`.
|
|
59
120
|
|
|
60
121
|
## Exit codes
|
|
61
122
|
|
|
@@ -74,9 +135,11 @@ raster orgs create --email you@example.com --save
|
|
|
74
135
|
|
|
75
136
|
| Variable | Purpose |
|
|
76
137
|
| --- | --- |
|
|
77
|
-
| `RASTER_API_KEY` | API key (
|
|
78
|
-
| `
|
|
138
|
+
| `RASTER_API_KEY` | API key (sits below a stored OAuth token, above a config-file key) |
|
|
139
|
+
| `RASTER_ORG` | Default organization id for an OAuth login when `--org` is omitted |
|
|
79
140
|
| `RASTER_CONFIG_HOME` | Config directory override (default `~/.config/raster`) |
|
|
141
|
+
| `RASTER_AUTH_ISSUER` | OAuth authorization-server issuer (default `https://raster.app`; a `raster.app` host or localhost only) |
|
|
142
|
+
| `RASTER_OAUTH_CLIENT_ID` | Pin a client id to skip dynamic client registration |
|
|
80
143
|
|
|
81
144
|
## Development
|
|
82
145
|
|
|
@@ -88,7 +151,7 @@ bun run gen:types # regenerate src/api/openapi.d.ts from the live OpenAPI docu
|
|
|
88
151
|
bun run build # bundle dist/index.js
|
|
89
152
|
```
|
|
90
153
|
|
|
91
|
-
Types are generated from the public OpenAPI document at `https://api.raster.app/openapi.json`; CI fails when the committed types drift from production. The published package bundles its three libraries (`commander`, `zod`, `openapi-fetch`) into `dist/index.js` — installing the CLI pulls zero dependencies.
|
|
154
|
+
Types are generated from the public OpenAPI document at `https://api.raster.app/openapi.json`; CI fails when the committed types drift from production. The published package bundles its three libraries (`commander`, `zod`, `openapi-fetch`) into `dist/index.js` — installing the CLI pulls zero dependencies.
|
|
92
155
|
|
|
93
156
|
## License
|
|
94
157
|
|