@biaspay/cli 0.0.0 → 0.1.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.
Files changed (4) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +86 -2
  3. package/bin/bias.js +41 -0
  4. package/package.json +27 -1
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2026 Bias. (https://biaspay.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,87 @@
1
- # @biaspay/cli
1
+ # Bias CLI
2
2
 
3
- A placeholder, published so the release workflow in [BiasPay/cli](https://github.com/BiasPay/cli) can publish this package with npm trusted publishing. Install `@biaspay/cli` 0.1.0 or later.
3
+ `bias` runs every operation in the [Bias API](https://biaspay.com/docs/api) from your terminal. You
4
+ sign in through the Bias dashboard, and it completes commands and parameters in zsh, bash and fish.
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ brew install biaspay/tap/bias # macOS and Linux
10
+ npm install -g @biaspay/cli # any platform with Node 18+
11
+ curl -fsSL https://biaspay.com/docs/install.sh | sh # macOS and Linux, into ~/.local/bin
12
+ ```
13
+
14
+ Windows builds are on [the releases page](https://github.com/BiasPay/cli/releases), and npm installs
15
+ them too. Each archive is listed in the release's `SHA256SUMS` and has a build provenance attestation
16
+ (`gh attestation verify <archive> --repo BiasPay/cli`).
17
+
18
+ ## Usage
19
+
20
+ ```sh
21
+ bias login # opens the dashboard to approve this device
22
+ bias customers list --limit 3 --table
23
+ bias customers create --name "Jane Doe" --email jane@example.com
24
+ bias listen --forward-to http://localhost:3000/webhooks
25
+ ```
26
+
27
+ `bias help` lists the commands, and `bias help <command>` shows a command's parameters. Signed in to
28
+ a live account, a command that makes a change needs `--live`.
29
+
30
+ | Variable | Effect |
31
+ | ----------------- | ----------------------------------------------------------------- |
32
+ | `BIAS_API_KEY` | Authenticates with an API key instead of a sign-in, such as in CI |
33
+ | `BIAS_CONFIG_DIR` | Where profiles and tokens are kept (default `~/.config/bias`) |
34
+ | `BIAS_NO_BROWSER` | Set to `1` to print the sign-in link instead of opening a browser |
35
+ | `BIAS_OUTPUT` | Set to `table` to print tables by default |
36
+
37
+ To sign a device out, delete its key under Developers → API keys in the dashboard, or run
38
+ `bias logout` on it.
39
+
40
+ ## Development
41
+
42
+ This repository is published from the Bias monorepo, where the CLI lives in `packages/cli`; changes
43
+ made here are overwritten by the next release.
44
+
45
+ ```sh
46
+ cargo build --release # target/release/bias
47
+ cargo test
48
+ ```
49
+
50
+ `manifest.json` is the command table, with each command's response schema and the columns `--table`
51
+ shows by default (`COLUMN_OVERRIDES` in the generator adjusts them). `bun sdk:generate cli` (or
52
+ `--all`) regenerates it from `packages/backend/openapi/openapi.json`, and the binary embeds it. CI
53
+ fails when it drifts from the spec (`.buildkite/scripts/check-sdk-drift.sh`).
54
+
55
+ Against the local stack:
56
+
57
+ ```sh
58
+ export BIAS_API_URL=https://api.bias.localhost # the dashboard URL follows: api. → app.
59
+ bias login # or --device, --read-only, --profile <name>
60
+ ```
61
+
62
+ | File | What it does |
63
+ | ------------- | ------------------------------------------------------------------------------- |
64
+ | `cli.rs` | Reads argv into a command, path params, a body and flags; runs it |
65
+ | `params.rs` | Path notation (`--a.b[0].c=3`) and schema-typed values |
66
+ | `loose.rs` | The forgiving JSON reader: unquoted keys, trailing commas, comments, bare words |
67
+ | `manifest.rs` | The embedded command table and schema lookups |
68
+ | `client.rs` | Requests: token refresh under a file lock, retries, idempotency keys |
69
+ | `auth.rs` | `login` (PKCE with a loopback redirect, or a device code), `logout`, `auth …` |
70
+ | `config.rs` | Profiles in `config.json`; tokens in `credentials.json` (0600) |
71
+ | `complete.rs` | `bias __complete` and the zsh, bash and fish scripts |
72
+ | `table.rs` | `--table` rows and columns, and `--fields` picking |
73
+ | `help.rs` | Help text from the manifest |
74
+
75
+ The server side is `packages/backend/src/ops/oauth` and `src/api/routes/oauth` (token, device and
76
+ revoke endpoints), with the consent pages at `/oauth/authorize` and `/device` in the dashboard. Each
77
+ sign-in is a grant backed by its own API key, so requests log against it and deleting the key signs
78
+ the CLI out.
79
+
80
+ ### Releasing
81
+
82
+ Bump `version` in `Cargo.toml`. After the next deploy from `main`, the publisher pushes this package
83
+ to [BiasPay/cli](https://github.com/BiasPay/cli) with a `v<version>` tag, and its release workflow
84
+ builds each platform's binary, publishes the GitHub release, the npm packages (`@biaspay/cli` and one
85
+ `@biaspay/cli-<os>-<cpu>` per platform) and the Homebrew formula. The checks fail when anything that
86
+ ships in the binary changed since the last release without a version bump
87
+ (`.buildkite/scripts/check-cli-version.sh`).
package/bin/bias.js ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ // Runs the bias binary from the package for this platform, which npm installs as an optional
3
+ // dependency of @biaspay/cli. release/npm.mjs writes the platform table below into the copy it publishes.
4
+ "use strict";
5
+
6
+ const { spawnSync } = require("node:child_process");
7
+
8
+ const PLATFORMS = {
9
+ "darwin arm64": "@biaspay/cli-darwin-arm64",
10
+ "darwin x64": "@biaspay/cli-darwin-x64",
11
+ "linux arm64": "@biaspay/cli-linux-arm64",
12
+ "linux x64": "@biaspay/cli-linux-x64",
13
+ "win32 x64": "@biaspay/cli-win32-x64"
14
+ };
15
+
16
+ const name = PLATFORMS[`${process.platform} ${process.arch}`];
17
+ if (!name) {
18
+ console.error(
19
+ `bias: there's no build for ${process.platform} ${process.arch}. ` +
20
+ "Download one from https://github.com/BiasPay/cli/releases if your platform is listed.",
21
+ );
22
+ process.exit(1);
23
+ }
24
+
25
+ let binary;
26
+ try {
27
+ binary = require.resolve(`${name}/bin/bias${process.platform === "win32" ? ".exe" : ""}`);
28
+ } catch {
29
+ console.error(
30
+ `bias: ${name} isn't installed. Reinstall @biaspay/cli without --no-optional or --omit=optional.`,
31
+ );
32
+ process.exit(1);
33
+ }
34
+
35
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
36
+ if (result.error) {
37
+ console.error(`bias: ${result.error.message}`);
38
+ process.exit(1);
39
+ }
40
+ if (result.signal) process.kill(process.pid, result.signal);
41
+ process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1 +1,27 @@
1
- {"name":"@biaspay/cli","version":"0.0.0","description":"Placeholder. Install @biaspay/cli 0.1.0 or later.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/BiasPay/cli.git"}}
1
+ {
2
+ "name": "@biaspay/cli",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "homepage": "https://biaspay.com/docs",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/BiasPay/cli.git"
9
+ },
10
+ "description": "Command-line interface for the Bias payments API",
11
+ "bin": {
12
+ "bias": "bin/bias.js"
13
+ },
14
+ "files": [
15
+ "bin"
16
+ ],
17
+ "engines": {
18
+ "node": ">=18"
19
+ },
20
+ "optionalDependencies": {
21
+ "@biaspay/cli-darwin-arm64": "0.1.0",
22
+ "@biaspay/cli-darwin-x64": "0.1.0",
23
+ "@biaspay/cli-linux-arm64": "0.1.0",
24
+ "@biaspay/cli-linux-x64": "0.1.0",
25
+ "@biaspay/cli-win32-x64": "0.1.0"
26
+ }
27
+ }