@yobekasbah/cli 1.0.0 → 1.0.1

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 (2) hide show
  1. package/bin/kasbah.js +17 -4
  2. package/package.json +10 -4
package/bin/kasbah.js CHANGED
@@ -67,7 +67,11 @@ for (let i = 0; i < argv.length; i++) {
67
67
  } else positional.push(a);
68
68
  }
69
69
 
70
- const API_BASE = flags.api || process.env.KASBAH_API_URL || 'http://127.0.0.1:8788';
70
+ // Default to the live hosted gateway so `npx @yobekasbah/cli scan "..."` works
71
+ // out of the box for a stranger with zero setup — that's the whole point of
72
+ // the one-command mechanic. Point at a local dev server with --api or
73
+ // KASBAH_API_URL (e.g. running `node packages/api-server/server.js`).
74
+ const API_BASE = flags.api || process.env.KASBAH_API_URL || 'https://kasbah-api.fly.dev';
71
75
  const EMIT_JSON = !!flags.json;
72
76
  const QUIET = !!flags.quiet;
73
77
 
@@ -83,7 +87,7 @@ function request(method, path, body = null) {
83
87
  headers: Object.assign(
84
88
  { Accept: 'application/json' },
85
89
  data ? { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) } : {},
86
- process.env.KASBAH_API_KEY ? { Authorization: 'Bearer ' + process.env.KASBAH_API_KEY } : {}
90
+ process.env.KASBAH_API_KEY ? { 'x-api-key': process.env.KASBAH_API_KEY } : {}
87
91
  )
88
92
  }, (res) => {
89
93
  let chunks = '';
@@ -796,7 +800,16 @@ Supported clouds: aws, gcp, azure
796
800
  }
797
801
 
798
802
  main().catch((e) => {
799
- if (EMIT_JSON) console.log(JSON.stringify({ error: e.message, status: e.status, body: e.body }, null, 2));
800
- else console.error(c('red', '✕ ') + e.message + (e.status ? c('dim', ' (HTTP ' + e.status + ')') : ''));
803
+ const refused = /ECONNREFUSED|ENOTFOUND|ETIMEDOUT/.test(e.message || '');
804
+ const hint = refused
805
+ ? `Couldn't reach ${API_BASE}. Point at a different gateway with --api <url> or KASBAH_API_URL.`
806
+ : (e.status === 401
807
+ ? 'Missing or invalid API key. Get a free one: POST ' + API_BASE + '/v1/auth/signup, then set KASBAH_API_KEY.'
808
+ : null);
809
+ if (EMIT_JSON) console.log(JSON.stringify({ error: e.message, status: e.status, body: e.body, hint }, null, 2));
810
+ else {
811
+ console.error(c('red', '✕ ') + e.message + (e.status ? c('dim', ' (HTTP ' + e.status + ')') : ''));
812
+ if (hint) console.error(c('dim', ' → ' + hint));
813
+ }
801
814
  process.exit(1);
802
815
  });
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@yobekasbah/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Kasbah Guard — unified command-line interface. Talks to the local or remote api-server.",
5
- "bin": { "kasbah": "bin/kasbah.js" },
5
+ "bin": {
6
+ "kasbah": "bin/kasbah.js"
7
+ },
6
8
  "main": "bin/kasbah.js",
7
- "scripts": { "test": "node bin/kasbah.js --help" },
8
- "engines": { "node": ">=18" },
9
+ "scripts": {
10
+ "test": "node bin/kasbah.js --help"
11
+ },
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
9
15
  "license": "MIT"
10
16
  }