inflight-cli 2.3.1 → 2.4.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.
- package/dist/commands/share.js +22 -0
- package/package.json +1 -1
package/dist/commands/share.js
CHANGED
|
@@ -22,6 +22,15 @@ function formatRelativeTime(timestampMs) {
|
|
|
22
22
|
return `${days}d ago`;
|
|
23
23
|
return new Date(timestampMs).toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
24
24
|
}
|
|
25
|
+
function isLocalhostUrl(url) {
|
|
26
|
+
try {
|
|
27
|
+
const hostname = new URL(url.startsWith("http") ? url : `https://${url}`).hostname;
|
|
28
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "[::1]";
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
25
34
|
/**
|
|
26
35
|
* Checks local git state and prompts the user to commit/push if needed.
|
|
27
36
|
* Returns { justPushed: true } if changes were pushed, { justPushed: false } otherwise.
|
|
@@ -250,6 +259,16 @@ export async function shareCommand(opts = {}) {
|
|
|
250
259
|
if (!stagingUrl.startsWith("http")) {
|
|
251
260
|
stagingUrl = `https://${stagingUrl}`;
|
|
252
261
|
}
|
|
262
|
+
if (isLocalhostUrl(stagingUrl)) {
|
|
263
|
+
const message = "Inflight needs a hosted URL — localhost isn't accessible to your team. Deploy to Vercel, Netlify, or another hosting provider first.";
|
|
264
|
+
if (opts.json) {
|
|
265
|
+
console.log(JSON.stringify({ error: "localhost_url", message }));
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
p.log.error(message);
|
|
269
|
+
}
|
|
270
|
+
process.exit(1);
|
|
271
|
+
}
|
|
253
272
|
const result = await apiCreateVersion({
|
|
254
273
|
apiKey: auth.apiKey,
|
|
255
274
|
workspaceId,
|
|
@@ -309,6 +328,9 @@ export async function shareCommand(opts = {}) {
|
|
|
309
328
|
catch {
|
|
310
329
|
return "Must be a valid URL";
|
|
311
330
|
}
|
|
331
|
+
if (isLocalhostUrl(v)) {
|
|
332
|
+
return "Inflight needs a hosted URL — localhost isn't accessible to your team. Deploy to Vercel, Netlify, or another hosting provider first.";
|
|
333
|
+
}
|
|
312
334
|
},
|
|
313
335
|
});
|
|
314
336
|
if (p.isCancel(input)) {
|