inflight-cli 2.3.0 → 2.3.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.
@@ -1,6 +1,6 @@
1
1
  import { readNetlifyConfig } from "../lib/config.js";
2
2
  import { getGitInfo, parseGitRepo, getGitRoot } from "../lib/git.js";
3
- import { getNetlifyToken, getNetlifyDeploys, getNetlifySites, readLocalNetlifySite, matchSitesByRepo, } from "../lib/netlify.js";
3
+ import { getNetlifyToken, getNetlifyDeploys, getNetlifySites, getNetlifySiteById, readLocalNetlifySite, matchSitesByRepo, } from "../lib/netlify.js";
4
4
  // --- Action handlers ---
5
5
  async function listSites() {
6
6
  const token = requireNetlifyToken();
@@ -17,16 +17,23 @@ async function listSites() {
17
17
  * Priority: explicit flag → .netlify/state.json → git remote match → saved global config → error
18
18
  */
19
19
  async function resolveSite(opts) {
20
- if (opts.site)
21
- return opts.site;
20
+ const token = requireNetlifyToken();
21
+ if (opts.site) {
22
+ const detail = await getNetlifySiteById(token, opts.site);
23
+ if (detail)
24
+ return { siteId: detail.id, siteName: detail.name };
25
+ return { siteId: opts.site, siteName: opts.site };
26
+ }
22
27
  const cwd = process.cwd();
23
28
  const gitRoot = getGitRoot(cwd);
24
29
  if (gitRoot) {
25
30
  const local = readLocalNetlifySite(gitRoot);
26
- if (local)
27
- return local.siteId;
31
+ if (local) {
32
+ const detail = await getNetlifySiteById(token, local.siteId);
33
+ if (detail)
34
+ return { siteId: detail.id, siteName: detail.name };
35
+ }
28
36
  }
29
- const token = requireNetlifyToken();
30
37
  const gitInfo = getGitInfo(cwd);
31
38
  if (gitInfo.remoteUrl) {
32
39
  const gitRepo = parseGitRepo(gitInfo.remoteUrl);
@@ -35,14 +42,14 @@ async function resolveSite(opts) {
35
42
  const allSites = await getNetlifySites(token);
36
43
  const matches = matchSitesByRepo(allSites, gitRepo.owner, gitRepo.name);
37
44
  if (matches.length === 1)
38
- return matches[0].id;
45
+ return { siteId: matches[0].id, siteName: matches[0].name };
39
46
  }
40
47
  catch { }
41
48
  }
42
49
  }
43
50
  const config = readNetlifyConfig();
44
51
  if (config)
45
- return config.siteId;
52
+ return { siteId: config.siteId, siteName: config.siteName };
46
53
  console.log(JSON.stringify({
47
54
  error: "netlify_not_configured",
48
55
  message: "Could not auto-detect Netlify site. Run 'inflight netlify sites' to list available sites, then pass --site to 'inflight netlify deploys'.",
@@ -51,8 +58,8 @@ async function resolveSite(opts) {
51
58
  }
52
59
  async function listDeploys(opts) {
53
60
  const token = requireNetlifyToken();
54
- const siteId = await resolveSite(opts);
55
- const deploys = await getNetlifyDeploys(token, siteId);
61
+ const { siteId, siteName } = await resolveSite(opts);
62
+ const deploys = await getNetlifyDeploys(token, siteId, siteName);
56
63
  console.log(JSON.stringify({ deploys }));
57
64
  }
58
65
  /** Gets token silently, exits with JSON error if unavailable. */
@@ -55,7 +55,7 @@ export declare function getNetlifyUser(token: string): Promise<{
55
55
  } | null>;
56
56
  export declare function getNetlifySites(token: string): Promise<NetlifySite[]>;
57
57
  export declare function getNetlifySiteById(token: string, siteId: string): Promise<NetlifySite | null>;
58
- export declare function getNetlifyDeploys(token: string, siteId: string, opts?: {
58
+ export declare function getNetlifyDeploys(token: string, siteId: string, siteName: string, opts?: {
59
59
  branch?: string;
60
60
  limit?: number;
61
61
  }): Promise<NetlifyDeploy[]>;
@@ -160,7 +160,7 @@ export async function getNetlifySiteById(token, siteId) {
160
160
  return null;
161
161
  return (await res.json());
162
162
  }
163
- export async function getNetlifyDeploys(token, siteId, opts) {
163
+ export async function getNetlifyDeploys(token, siteId, siteName, opts) {
164
164
  const params = new URLSearchParams({ per_page: String(opts?.limit ?? 20) });
165
165
  if (opts?.branch)
166
166
  params.set("branch", opts.branch);
@@ -176,7 +176,8 @@ export async function getNetlifyDeploys(token, siteId, opts) {
176
176
  branch: d.branch,
177
177
  commitRef: d.commit_ref?.slice(0, 7) ?? null,
178
178
  commitMessage: d.title,
179
- deploySslUrl: d.deploy_ssl_url,
179
+ // Construct the immutable per-deploy permalink
180
+ deploySslUrl: `https://${d.id}--${siteName}.netlify.app`,
180
181
  context: d.context,
181
182
  createdAt: new Date(d.created_at).getTime(),
182
183
  }));
@@ -141,7 +141,7 @@ export async function resolveNetlifyUrl(cwd, gitInfo, opts) {
141
141
  const localRepoPath = gitRepo ? `${gitRepo.owner}/${gitRepo.name}`.toLowerCase() : null;
142
142
  const repoMatches = site.repoPath && localRepoPath ? site.repoPath.toLowerCase() === localRepoPath : false;
143
143
  // Only filter by branch if we're in the matching repo — otherwise show all deploys
144
- let deploys = await getNetlifyDeploys(token, site.siteId, {
144
+ let deploys = await getNetlifyDeploys(token, site.siteId, site.siteName, {
145
145
  branch: repoMatches ? (gitInfo.branch ?? undefined) : undefined,
146
146
  });
147
147
  let commitDeploy = repoMatches ? deploys.find((d) => d.commitRef === commitSha) : undefined;
@@ -151,7 +151,7 @@ export async function resolveNetlifyUrl(cwd, gitInfo, opts) {
151
151
  pollSpinner.start("Waiting for Netlify deployment...");
152
152
  for (let i = 0; i < 30; i++) {
153
153
  await new Promise((r) => setTimeout(r, 2000));
154
- deploys = await getNetlifyDeploys(token, site.siteId, {
154
+ deploys = await getNetlifyDeploys(token, site.siteId, site.siteName, {
155
155
  branch: repoMatches ? (gitInfo.branch ?? undefined) : undefined,
156
156
  });
157
157
  commitDeploy = deploys.find((d) => d.commitRef === commitSha);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inflight-cli",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Get feedback directly on your staging URL",
5
5
  "bin": {
6
6
  "inflight": "dist/index.js",