@fixprompt/cli 0.2.0 → 0.2.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.
- package/dist/cli.js +30 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -139,7 +139,7 @@ async function mintDeployToken(opts) {
|
|
|
139
139
|
}
|
|
140
140
|
return JSON.parse(text);
|
|
141
141
|
}
|
|
142
|
-
function writeEas(token, env) {
|
|
142
|
+
function writeEas(token, env, force) {
|
|
143
143
|
console.log(`
|
|
144
144
|
\u2022 Writing ${TOKEN_ENV_VAR_NAME} to EAS env '${env}'\u2026`);
|
|
145
145
|
const useShell = process.platform === "win32";
|
|
@@ -152,11 +152,12 @@ function writeEas(token, env) {
|
|
|
152
152
|
"--value",
|
|
153
153
|
token,
|
|
154
154
|
"--type",
|
|
155
|
-
"
|
|
155
|
+
"string",
|
|
156
156
|
"--visibility",
|
|
157
157
|
"plaintext",
|
|
158
158
|
"--non-interactive"
|
|
159
159
|
];
|
|
160
|
+
if (force) args.push("--force");
|
|
160
161
|
const r = spawnSync("npx", useShell ? args.map((a) => `"${a.replace(/"/g, '\\"')}"`) : args, {
|
|
161
162
|
stdio: "inherit",
|
|
162
163
|
shell: useShell
|
|
@@ -166,7 +167,7 @@ function writeEas(token, env) {
|
|
|
166
167
|
`eas env:create exited ${r.status}. Common causes:
|
|
167
168
|
\u2022 Not logged in to EAS \u2014 run 'eas login'
|
|
168
169
|
\u2022 Wrong env name \u2014 pass --eas-env <production|preview|development>
|
|
169
|
-
\u2022 Variable already exists
|
|
170
|
+
\u2022 Variable already exists \u2014 re-run with --force to overwrite.`
|
|
170
171
|
);
|
|
171
172
|
}
|
|
172
173
|
}
|
|
@@ -237,13 +238,6 @@ directory or pass --vercel-project-id <prj_\u2026>.`
|
|
|
237
238
|
}
|
|
238
239
|
async function connect(args) {
|
|
239
240
|
const cwd = process.cwd();
|
|
240
|
-
const projectId = args.flags["project-id"] ?? process.env.FIXPROMPT_PROJECT_ID;
|
|
241
|
-
if (!projectId) {
|
|
242
|
-
console.error(
|
|
243
|
-
"Missing --project-id (or $FIXPROMPT_PROJECT_ID).\n Find it in the FixPrompt dashboard URL after picking your project."
|
|
244
|
-
);
|
|
245
|
-
process.exit(1);
|
|
246
|
-
}
|
|
247
241
|
const adminToken = args.flags["admin-token"] ?? process.env.FIXPROMPT_ADMIN_TOKEN ?? process.env.INTERNAL_ADMIN_TOKEN;
|
|
248
242
|
if (!adminToken) {
|
|
249
243
|
console.error(
|
|
@@ -252,6 +246,27 @@ async function connect(args) {
|
|
|
252
246
|
process.exit(1);
|
|
253
247
|
}
|
|
254
248
|
const endpoint = (args.flags.endpoint ?? process.env.FIXPROMPT_ENDPOINT ?? DEFAULT_ENDPOINT).replace(/\/$/, "");
|
|
249
|
+
let projectId = args.flags["project-id"] ?? process.env.FIXPROMPT_PROJECT_ID ?? null;
|
|
250
|
+
const projectSlug = args.flags["project-slug"] ?? null;
|
|
251
|
+
if (!projectId && projectSlug) {
|
|
252
|
+
const res = await fetch(`${endpoint}/admin/projects/by-slug/${encodeURIComponent(projectSlug)}`, {
|
|
253
|
+
headers: { "x-internal-admin-token": adminToken }
|
|
254
|
+
});
|
|
255
|
+
const text = await res.text();
|
|
256
|
+
if (!res.ok) {
|
|
257
|
+
console.error(`Project lookup failed (${res.status}): ${text.slice(0, 200)}`);
|
|
258
|
+
process.exit(1);
|
|
259
|
+
}
|
|
260
|
+
const parsed = JSON.parse(text);
|
|
261
|
+
projectId = parsed.id;
|
|
262
|
+
console.log(` resolved --project-slug=${projectSlug} \u2192 ${parsed.id} (${parsed.name})`);
|
|
263
|
+
}
|
|
264
|
+
if (!projectId) {
|
|
265
|
+
console.error(
|
|
266
|
+
"Need --project-id or --project-slug (or $FIXPROMPT_PROJECT_ID).\n --project-slug is easiest: it matches the value you see in the dashboard."
|
|
267
|
+
);
|
|
268
|
+
process.exit(1);
|
|
269
|
+
}
|
|
255
270
|
const explicit = args.flags.provider;
|
|
256
271
|
const provider = explicit ?? detectProvider(cwd);
|
|
257
272
|
if (!provider) {
|
|
@@ -284,9 +299,10 @@ async function connect(args) {
|
|
|
284
299
|
label
|
|
285
300
|
});
|
|
286
301
|
console.log(` \u2713 token_id ${minted.token_id} (value hidden \u2014 written to CI store only)`);
|
|
302
|
+
const force = args.flags.force === true;
|
|
287
303
|
switch (provider) {
|
|
288
304
|
case "eas":
|
|
289
|
-
writeEas(minted.token, target.easEnv);
|
|
305
|
+
writeEas(minted.token, target.easEnv, force);
|
|
290
306
|
break;
|
|
291
307
|
case "github-actions":
|
|
292
308
|
writeGitHubActions(minted.token, cwd);
|
|
@@ -311,7 +327,7 @@ async function connect(args) {
|
|
|
311
327
|
|
|
312
328
|
// src/version.ts
|
|
313
329
|
var CLI_NAME = "@fixprompt/cli";
|
|
314
|
-
var CLI_VERSION = "0.2.
|
|
330
|
+
var CLI_VERSION = "0.2.1";
|
|
315
331
|
|
|
316
332
|
// src/cli.ts
|
|
317
333
|
var DEFAULT_ENDPOINT2 = "https://geosloghub-production.up.railway.app";
|
|
@@ -357,6 +373,8 @@ connect options:
|
|
|
357
373
|
--vercel-project-id <id> Override Vercel project id (default: .vercel/project.json)
|
|
358
374
|
--vercel-targets <list> Comma-separated (default: production,preview)
|
|
359
375
|
--label <text> Token label (default: <provider>-<timestamp>)
|
|
376
|
+
--force Overwrite an existing FIXPROMPT_DEPLOY_TOKEN value
|
|
377
|
+
--project-slug <slug> Look up project_id by slug (no UUID needed)
|
|
360
378
|
|
|
361
379
|
deploy-start auth (pick one):
|
|
362
380
|
--deploy-token <fpd_...> Deploy-only token from dashboard (recommended for CI)
|
package/package.json
CHANGED