inflight-cli 2.1.5 → 2.1.6

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,7 +1,7 @@
1
1
  import * as p from "@clack/prompts";
2
2
  import pc from "picocolors";
3
3
  import { readGlobalAuth, readWorkspaceConfig, writeWorkspaceConfig } from "../lib/config.js";
4
- import { getGitInfo, getGitSyncState, generateCommitMessage, commitAndPush, pushBranch } from "../lib/git.js";
4
+ import { getGitInfo, getGitSyncState, generateCommitMessage, commitAndPush, pushBranch, hasCommitsAhead } from "../lib/git.js";
5
5
  import open from "open";
6
6
  import { providers } from "../providers/index.js";
7
7
  import { apiGetMe, apiCreateVersion } from "../lib/api.js";
@@ -126,7 +126,13 @@ async function checkAndSyncGit(cwd) {
126
126
  }
127
127
  }
128
128
  if (state.status === "no_remote") {
129
- // Working tree is clean (uncommitted was checked first in getGitSyncState), just need to push
129
+ // Working tree is clean (uncommitted was checked first in getGitSyncState).
130
+ // Check if this branch actually has commits ahead of the default branch —
131
+ // if not, pushing won't trigger a deployment.
132
+ if (!hasCommitsAhead(cwd)) {
133
+ p.log.info(`Branch ${pc.bold(branch)} has no new commits — using existing deployments.`);
134
+ return { justPushed: false };
135
+ }
130
136
  p.log.warn(`Branch ${pc.bold(branch)} hasn't been pushed yet — no deployment exists.`);
131
137
  const confirm = await p.confirm({
132
138
  message: "Push to create a deployment?",
@@ -154,14 +160,15 @@ async function checkAndSyncGit(cwd) {
154
160
  }
155
161
  export async function shareCommand(opts = {}) {
156
162
  const cwd = process.cwd();
163
+ // TODO: Add a step to login if not authenticated
157
164
  // ── Step 1: Auth ──
158
165
  const auth = readGlobalAuth();
159
166
  if (!auth) {
160
167
  if (opts.json) {
161
- console.log(JSON.stringify({ error: "not_authenticated", message: "Not logged in. Run inflight login first." }));
168
+ console.log(JSON.stringify({ error: "not_authenticated", message: "Not logged in. Run inflight setup first." }));
162
169
  }
163
170
  else {
164
- p.log.error("Not logged in. Run " + pc.cyan("inflight login") + " first.");
171
+ p.log.error("Not logged in. Run " + pc.cyan("inflight setup") + " first.");
165
172
  }
166
173
  process.exit(1);
167
174
  }
package/dist/lib/git.d.ts CHANGED
@@ -74,4 +74,9 @@ export declare function commitAndPush(cwd: string, message: string, branch: stri
74
74
  /**
75
75
  * Pushes existing commits. Uses `-u` if no upstream exists.
76
76
  */
77
+ /**
78
+ * Returns true if the current branch has commits ahead of the default branch (main/master).
79
+ * Used to avoid pushing branches with no new commits (which won't trigger a deployment).
80
+ */
81
+ export declare function hasCommitsAhead(cwd: string): boolean;
77
82
  export declare function pushBranch(cwd: string, branch: string): void;
package/dist/lib/git.js CHANGED
@@ -315,6 +315,15 @@ export function commitAndPush(cwd, message, branch) {
315
315
  /**
316
316
  * Pushes existing commits. Uses `-u` if no upstream exists.
317
317
  */
318
+ /**
319
+ * Returns true if the current branch has commits ahead of the default branch (main/master).
320
+ * Used to avoid pushing branches with no new commits (which won't trigger a deployment).
321
+ */
322
+ export function hasCommitsAhead(cwd) {
323
+ const defaultBranch = getDefaultBranch(cwd);
324
+ const count = run(`git rev-list ${defaultBranch}..HEAD --count`, cwd);
325
+ return count !== null && count !== "0";
326
+ }
318
327
  export function pushBranch(cwd, branch) {
319
328
  const upstream = run(`git rev-parse --abbrev-ref ${branch}@{upstream}`, cwd);
320
329
  if (upstream) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inflight-cli",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "Get feedback directly on your staging URL",
5
5
  "bin": {
6
6
  "inflight": "dist/index.js",