sprouts-cli 0.1.0 → 0.1.2

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 CHANGED
@@ -8,9 +8,14 @@ Terminal helper for **Sprouts IDE pairing**: starts a device session, opens the
8
8
  npx sprouts-cli login
9
9
  ```
10
10
 
11
- ## Environment
11
+ ## API URL
12
12
 
13
- - `SPROUTS_API_URL` API base URL (default `https://api.getsprouts.io`).
13
+ Default is **`http://127.0.0.1:3000`** (local Sprouts backend). Override if your API is elsewhere:
14
+
15
+ - **Env:** `SPROUTS_API_URL=https://your-tunnel.example.ngrok-free.dev npx sprouts-cli login`
16
+ - **File:** `~/.sprouts/config.json` → `{ "apiUrl": "https://..." }` (no trailing slash)
17
+
18
+ When production is live at `https://api.getsprouts.io`, set one of the above or export `SPROUTS_API_URL` before running.
14
19
 
15
20
  ## Publish
16
21
 
package/dist/index.js CHANGED
@@ -2,10 +2,34 @@
2
2
  import { spawn } from "node:child_process";
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
- const DEFAULT_API = "https://api.getsprouts.io";
5
+ /** Local backend default — production API is not always deployed at api.getsprouts.io yet. */
6
+ const DEFAULT_API = "http://127.0.0.1:3000";
7
+ function configPath() {
8
+ const home = process.env.HOME || process.env.USERPROFILE || ".";
9
+ return path.join(home, ".sprouts", "config.json");
10
+ }
11
+ function readConfigApiUrl() {
12
+ try {
13
+ const p = configPath();
14
+ if (!fs.existsSync(p))
15
+ return undefined;
16
+ const raw = fs.readFileSync(p, "utf8");
17
+ const j = JSON.parse(raw);
18
+ const u = j.apiUrl?.trim().replace(/\/$/, "");
19
+ return u || undefined;
20
+ }
21
+ catch {
22
+ return undefined;
23
+ }
24
+ }
6
25
  function getApiBase() {
7
- const u = process.env.SPROUTS_API_URL?.replace(/\/$/, "");
8
- return u || DEFAULT_API;
26
+ const fromEnv = process.env.SPROUTS_API_URL?.trim().replace(/\/$/, "");
27
+ if (fromEnv)
28
+ return fromEnv;
29
+ const fromFile = readConfigApiUrl();
30
+ if (fromFile)
31
+ return fromFile;
32
+ return DEFAULT_API;
9
33
  }
10
34
  function openUrl(url) {
11
35
  const platform = process.platform;
@@ -71,7 +95,8 @@ async function cmdLogin() {
71
95
  fs.mkdirSync(dir, { recursive: true });
72
96
  fs.writeFileSync(tokenPath(), JSON.stringify({ access_token: access_token, savedAt: new Date().toISOString() }, null, 2), "utf8");
73
97
  console.log("\nDone. Token saved to:", tokenPath());
74
- console.log("Paste this token into the Sprouts extension settings if prompted, or sign in from the extension UI.\n");
98
+ console.log("In Cursor/VS Code: open the Sprouts sidebar (activity bar) → click Refresh, or run “Sprouts: Refresh panel”.\n" +
99
+ "The extension loads this token automatically when its secret store is empty.\n");
75
100
  }
76
101
  function printHelp() {
77
102
  console.log(`
@@ -80,8 +105,10 @@ Sprouts CLI — pair your editor session
80
105
  Usage:
81
106
  npx sprouts-cli login Start browser sign-in and save IDE token to ~/.sprouts/ide-token.json
82
107
 
83
- Environment:
84
- SPROUTS_API_URL Backend base URL (default: ${DEFAULT_API})
108
+ Environment & config:
109
+ SPROUTS_API_URL Backend base URL (overrides everything if set)
110
+ ~/.sprouts/config.json Optional: { "apiUrl": "https://your-ngrok-url.ngrok-free.dev" }
111
+ Default API: ${DEFAULT_API} (local backend; set env or config for a public URL)
85
112
  `);
86
113
  }
87
114
  async function main() {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "sprouts-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Sprouts CLI — IDE pairing (opens browser to sign in)",
5
5
  "type": "module",
6
6
  "bin": {
7
- "sprouts": "./dist/index.js"
7
+ "sprouts": "dist/index.js"
8
8
  },
9
9
  "files": [
10
10
  "dist"