@backmatter/core 0.0.24 → 0.0.25

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/bin/backmatter.js CHANGED
@@ -1,2 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- import "../src/node/cli.ts";
2
+ import { main } from "../src/node/cli.ts";
3
+
4
+ process.exit(await main(process.argv.slice(2)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backmatter/core",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "Experimental Backmatter SDK. APIs will break. Not ready for production.",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/src/node/cli.ts CHANGED
@@ -554,7 +554,7 @@ export async function runInit(args: CliArgs): Promise<string[]> {
554
554
  return notes;
555
555
  }
556
556
 
557
- async function main(argv: string[]): Promise<number> {
557
+ export async function main(argv: string[]): Promise<number> {
558
558
  if (argv[0] === "login" || argv[0] === "media") {
559
559
  return runMediaCli(argv);
560
560
  }
@@ -12,6 +12,7 @@ export const MEDIA_USAGE = `Usage:
12
12
  backmatter media url <id> [--width <px>] [--origin <url>]
13
13
 
14
14
  login opens the browser and stores a personal token in ~/.backmatter/credentials.json.
15
+ media upload and list use --workspace, else BACKMATTER_WORKSPACE, else BACKMATTER_WORKSPACE_ID.
15
16
  media url prints a CDN url. --width <px> appends width and format=auto.`;
16
17
 
17
18
  type Credentials = { api: string; token: string; origin?: string };
@@ -121,9 +122,10 @@ async function media(
121
122
  const creds = await readCredentials(io.home);
122
123
  const api = (flags.api || creds?.api || io.env.BACKMATTER_API_URL || "").replace(/\/$/, "");
123
124
  const token = creds?.token;
124
- const workspace = flags.workspace || io.env.BACKMATTER_WORKSPACE;
125
+ const workspace =
126
+ flags.workspace || io.env.BACKMATTER_WORKSPACE || io.env.BACKMATTER_WORKSPACE_ID;
125
127
  if (!api || !token) throw new Error("run backmatter login first");
126
- if (!workspace) throw new Error("pass --workspace <id>");
128
+ if (!workspace) throw new Error("pass --workspace <id> or set BACKMATTER_WORKSPACE_ID");
127
129
  const fetchImpl = io.fetch ?? fetch;
128
130
  if (sub === "list") {
129
131
  const params = new URLSearchParams();