@fixprompt/cli 0.0.1 → 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 (2) hide show
  1. package/dist/cli.js +39 -17
  2. package/package.json +5 -2
package/dist/cli.js CHANGED
@@ -88,7 +88,7 @@ function detectContext() {
88
88
 
89
89
  // src/version.ts
90
90
  var CLI_NAME = "@fixprompt/cli";
91
- var CLI_VERSION = "0.0.1";
91
+ var CLI_VERSION = "0.1.0";
92
92
 
93
93
  // src/cli.ts
94
94
  var DEFAULT_ENDPOINT = "https://geosloghub-production.up.railway.app";
@@ -125,10 +125,16 @@ Usage:
125
125
  fixprompt deploy-start [options]
126
126
  fixprompt help
127
127
 
128
+ deploy-start auth (pick one):
129
+ --deploy-token <fpd_...> Deploy-only token from dashboard (recommended for CI)
130
+ (or $FIXPROMPT_DEPLOY_TOKEN env)
131
+ --key <k_...> Runtime SDK key, paired with --source
132
+ (or $LOGHUB_KEY / $FIXPROMPT_KEY env)
133
+
128
134
  deploy-start options:
129
- --source <slug> LOGHUB_SOURCE (default: $LOGHUB_SOURCE or $FIXPROMPT_SOURCE env)
130
- --key <k_...> LOGHUB_KEY (default: $LOGHUB_KEY or $FIXPROMPT_KEY env)
131
- --endpoint <url> Broker URL (default: $FIXPROMPT_ENDPOINT or ${DEFAULT_ENDPOINT})
135
+ --source <slug> LOGHUB_SOURCE (required only with --key; optional with --deploy-token)
136
+ (default: $LOGHUB_SOURCE or $FIXPROMPT_SOURCE env)
137
+ --endpoint <url> Broker URL (default: $FIXPROMPT_ENDPOINT or ${DEFAULT_ENDPOINT})
132
138
  --status <state> in_progress | success | failed (default: in_progress)
133
139
  --commit-sha <sha> Override auto-detected commit
134
140
  --branch <name> Override auto-detected branch
@@ -137,9 +143,14 @@ deploy-start options:
137
143
  Auto-detected CI providers: GitHub Actions, Vercel, Railway.
138
144
  `;
139
145
  }
140
- function readSource(flags) {
146
+ function readDeployToken(flags) {
147
+ const v = flags["deploy-token"] ?? process.env.FIXPROMPT_DEPLOY_TOKEN;
148
+ return v || null;
149
+ }
150
+ function readSource(flags, required) {
141
151
  const v = flags.source ?? process.env.LOGHUB_SOURCE ?? process.env.FIXPROMPT_SOURCE;
142
152
  if (!v) {
153
+ if (!required) return null;
143
154
  console.error("Missing --source (or $LOGHUB_SOURCE / $FIXPROMPT_SOURCE)");
144
155
  process.exit(1);
145
156
  }
@@ -147,19 +158,26 @@ function readSource(flags) {
147
158
  }
148
159
  function readKey(flags) {
149
160
  const v = flags.key ?? process.env.LOGHUB_KEY ?? process.env.FIXPROMPT_KEY;
150
- if (!v) {
151
- console.error("Missing --key (or $LOGHUB_KEY / $FIXPROMPT_KEY)");
152
- process.exit(1);
153
- }
154
- return v;
161
+ return v || null;
155
162
  }
156
163
  function readEndpoint(flags) {
157
164
  const v = flags.endpoint ?? process.env.FIXPROMPT_ENDPOINT ?? DEFAULT_ENDPOINT;
158
165
  return v.replace(/\/$/, "");
159
166
  }
160
167
  async function deployStart(args) {
161
- const source = readSource(args.flags);
162
- const key = readKey(args.flags);
168
+ const deployToken = readDeployToken(args.flags);
169
+ const key = deployToken ? null : readKey(args.flags);
170
+ const source = readSource(
171
+ args.flags,
172
+ /* required */
173
+ !deployToken
174
+ );
175
+ if (!deployToken && !key) {
176
+ console.error(
177
+ "Missing auth: pass --deploy-token (fpd_\u2026) or --key (k_\u2026).\n $FIXPROMPT_DEPLOY_TOKEN, $LOGHUB_KEY, $FIXPROMPT_KEY env vars are checked."
178
+ );
179
+ process.exit(1);
180
+ }
163
181
  const endpoint = readEndpoint(args.flags);
164
182
  const status = args.flags.status ?? "in_progress";
165
183
  const ctx = detectContext();
@@ -180,14 +198,18 @@ async function deployStart(args) {
180
198
  fixprompt_version: CLI_VERSION,
181
199
  status
182
200
  };
201
+ const headers = { "Content-Type": "application/json" };
202
+ if (deployToken) {
203
+ headers["x-fixprompt-deploy-token"] = deployToken;
204
+ if (source) headers["x-loghub-source"] = source;
205
+ } else {
206
+ headers["x-loghub-source"] = source;
207
+ headers["x-loghub-key"] = key;
208
+ }
183
209
  const url = `${endpoint}/deployments`;
184
210
  const res = await fetch(url, {
185
211
  method: "POST",
186
- headers: {
187
- "Content-Type": "application/json",
188
- "x-loghub-source": source,
189
- "x-loghub-key": key
190
- },
212
+ headers,
191
213
  body: JSON.stringify(payload)
192
214
  });
193
215
  const text = await res.text();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fixprompt/cli",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "FixPrompt CLI — annotate deployments and ship them to the broker so the dashboard knows what changed.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -15,7 +15,10 @@
15
15
  "bin": {
16
16
  "fixprompt": "dist/cli.js"
17
17
  },
18
- "files": ["dist", "README.md"],
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
19
22
  "scripts": {
20
23
  "build": "tsup",
21
24
  "dev": "tsup --watch",