inflight-cli 2.1.1 → 2.1.2
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/setup.js
CHANGED
|
@@ -182,5 +182,5 @@ export async function setupCommand() {
|
|
|
182
182
|
// ── Done ──
|
|
183
183
|
p.log.success(pc.green("Setup complete!") + " Run " + pc.cyan("inflight share") + " anytime to share your staging URL.");
|
|
184
184
|
// ── Step 6: Share ──
|
|
185
|
-
await shareCommand(
|
|
185
|
+
await shareCommand();
|
|
186
186
|
}
|
package/dist/commands/share.d.ts
CHANGED
package/dist/commands/share.js
CHANGED
|
@@ -19,15 +19,69 @@ export async function shareCommand(opts = {}) {
|
|
|
19
19
|
process.exit(1);
|
|
20
20
|
}
|
|
21
21
|
const gitInfo = getGitInfo(cwd);
|
|
22
|
-
// ──
|
|
23
|
-
|
|
22
|
+
// ── Step 2: Resolve workspace ──
|
|
23
|
+
const me = await apiGetMe(auth.apiKey).catch((e) => {
|
|
24
|
+
if (opts.json) {
|
|
25
|
+
console.log(JSON.stringify({ error: "api_error", message: e.message }));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
p.log.error(e.message);
|
|
29
|
+
}
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
const workspaces = me.workspaces;
|
|
33
|
+
let workspaceId;
|
|
34
|
+
const savedConfig = readWorkspaceConfig();
|
|
35
|
+
const savedWorkspace = savedConfig ? workspaces.find((w) => w.id === savedConfig.workspaceId) : null;
|
|
36
|
+
if (savedWorkspace) {
|
|
37
|
+
workspaceId = savedWorkspace.id;
|
|
38
|
+
}
|
|
39
|
+
else if (workspaces.length === 0) {
|
|
40
|
+
if (opts.json) {
|
|
41
|
+
console.log(JSON.stringify({
|
|
42
|
+
error: "no_workspaces",
|
|
43
|
+
message: "No workspaces found. Create one at inflight.co first.",
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
p.log.error("No workspaces found. Create one at " + pc.cyan("inflight.co") + " first.");
|
|
48
|
+
}
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
else if (workspaces.length === 1) {
|
|
52
|
+
workspaceId = workspaces[0].id;
|
|
53
|
+
if (!opts.json)
|
|
54
|
+
p.log.success(`Workspace: ${pc.bold(workspaces[0].name)}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
if (opts.json) {
|
|
58
|
+
console.log(JSON.stringify({
|
|
59
|
+
error: "no_workspace_set",
|
|
60
|
+
message: "Multiple workspaces found. Run 'inflight workspace --set=ID' first.",
|
|
61
|
+
workspaces: workspaces.map((w) => ({ id: w.id, name: w.name })),
|
|
62
|
+
}));
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
const selected = await p.select({
|
|
66
|
+
message: "Select a workspace " + pc.dim("(change anytime with inflight workspace)"),
|
|
67
|
+
options: workspaces.map((w) => ({ value: w.id, label: w.name })),
|
|
68
|
+
});
|
|
69
|
+
if (p.isCancel(selected)) {
|
|
70
|
+
p.cancel("Cancelled.");
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
workspaceId = selected;
|
|
74
|
+
}
|
|
75
|
+
writeWorkspaceConfig({ workspaceId });
|
|
76
|
+
// ── Fast path: URL provided (agent / scripting) ──
|
|
77
|
+
if (opts.url) {
|
|
24
78
|
let stagingUrl = opts.url;
|
|
25
79
|
if (!stagingUrl.startsWith("http")) {
|
|
26
80
|
stagingUrl = `https://${stagingUrl}`;
|
|
27
81
|
}
|
|
28
82
|
const result = await apiCreateVersion({
|
|
29
83
|
apiKey: auth.apiKey,
|
|
30
|
-
workspaceId
|
|
84
|
+
workspaceId,
|
|
31
85
|
stagingUrl,
|
|
32
86
|
gitInfo,
|
|
33
87
|
}).catch((e) => {
|
|
@@ -49,43 +103,6 @@ export async function shareCommand(opts = {}) {
|
|
|
49
103
|
await open(stagingUrl);
|
|
50
104
|
return;
|
|
51
105
|
}
|
|
52
|
-
// ── Step 2: Get workspaces ──
|
|
53
|
-
const me = await apiGetMe(auth.apiKey).catch((e) => {
|
|
54
|
-
p.log.error(e.message);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
});
|
|
57
|
-
const workspaces = me.workspaces;
|
|
58
|
-
let workspaceId;
|
|
59
|
-
// Check if a workspace is already configured and still valid
|
|
60
|
-
const existingConfig = readWorkspaceConfig();
|
|
61
|
-
const existingWorkspace = existingConfig ? workspaces.find((w) => w.id === existingConfig.workspaceId) : null;
|
|
62
|
-
if (existingWorkspace) {
|
|
63
|
-
workspaceId = existingWorkspace.id;
|
|
64
|
-
}
|
|
65
|
-
else if (workspaces.length === 0) {
|
|
66
|
-
p.log.error("No workspaces found. Create one at " + pc.cyan("inflight.co") + " first.");
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
else if (me.workspaces.length === 1) {
|
|
70
|
-
workspaceId = me.workspaces[0].id;
|
|
71
|
-
p.log.success(`Workspace: ${pc.bold(workspaces[0].name)}`);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
const selected = await p.select({
|
|
75
|
-
message: "Select a workspace " + pc.dim("(change anytime with inflight workspace)"),
|
|
76
|
-
options: me.workspaces.map((w) => ({ value: w.id, label: w.name })),
|
|
77
|
-
});
|
|
78
|
-
if (p.isCancel(selected)) {
|
|
79
|
-
p.cancel("Cancelled.");
|
|
80
|
-
process.exit(0);
|
|
81
|
-
}
|
|
82
|
-
workspaceId = selected;
|
|
83
|
-
}
|
|
84
|
-
writeWorkspaceConfig({ workspaceId });
|
|
85
|
-
if (!workspaceId) {
|
|
86
|
-
p.log.error("No workspace configured. Run " + pc.cyan("inflight workspace") + " or " + pc.cyan("inflight setup") + ".");
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
106
|
// Resolve staging URL
|
|
90
107
|
const providerChoice = await p.select({
|
|
91
108
|
message: "Where is your staging URL hosted?",
|
package/dist/commands/vercel.js
CHANGED
|
@@ -53,10 +53,7 @@ async function listDeployments(opts) {
|
|
|
53
53
|
const gitInfo = getGitInfo(cwd);
|
|
54
54
|
const currentBranch = gitInfo.branch;
|
|
55
55
|
const [deployments, branchAlias] = await Promise.all([
|
|
56
|
-
getRecentDeployments(token, teamId, projectId,
|
|
57
|
-
limit: parseInt(opts.limit ?? "10"),
|
|
58
|
-
branch: opts.branch,
|
|
59
|
-
}),
|
|
56
|
+
getRecentDeployments(token, teamId, projectId),
|
|
60
57
|
currentBranch ? getBranchAlias(token, teamId, projectId, currentBranch) : Promise.resolve(null),
|
|
61
58
|
]);
|
|
62
59
|
console.log(JSON.stringify({
|
|
@@ -85,7 +82,5 @@ export function registerVercelCommand(program) {
|
|
|
85
82
|
.description("List recent deployments + branch alias (JSON)")
|
|
86
83
|
.option("--team <id>", "Vercel team ID (auto-detected if omitted)")
|
|
87
84
|
.option("--project <id>", "Vercel project ID (auto-detected if omitted)")
|
|
88
|
-
.option("--branch <name>", "Filter deployments by branch")
|
|
89
|
-
.option("--limit <n>", "Number of deployments", "10")
|
|
90
85
|
.action(listDeployments);
|
|
91
86
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
import { readGlobalAuth, readWorkspaceConfig, writeWorkspaceConfig } from "../lib/config.js";
|
|
4
|
+
import { apiGetMe } from "../lib/api.js";
|
|
5
|
+
export async function workspaceCommand(opts) {
|
|
6
|
+
const auth = readGlobalAuth();
|
|
7
|
+
if (!auth) {
|
|
8
|
+
if (opts.json) {
|
|
9
|
+
console.log(JSON.stringify({ error: "not_authenticated", message: "Not logged in. Run inflight login first." }));
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
p.log.error("Not logged in. Run " + pc.cyan("inflight login") + " first.");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
// ── Fetch workspaces ──
|
|
16
|
+
const me = await apiGetMe(auth.apiKey).catch((e) => {
|
|
17
|
+
if (opts.json) {
|
|
18
|
+
console.log(JSON.stringify({ error: "api_error", message: e.message }));
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
p.log.error(e.message);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
});
|
|
24
|
+
const workspaces = me.workspaces;
|
|
25
|
+
// ── Set active workspace ──
|
|
26
|
+
if (opts.set) {
|
|
27
|
+
const workspace = workspaces.find((w) => w.id === opts.set);
|
|
28
|
+
if (!workspace) {
|
|
29
|
+
const msg = `Workspace '${opts.set}' not found.`;
|
|
30
|
+
if (opts.json) {
|
|
31
|
+
console.log(JSON.stringify({
|
|
32
|
+
error: "workspace_not_found",
|
|
33
|
+
message: msg,
|
|
34
|
+
available: workspaces.map((w) => ({ id: w.id, name: w.name })),
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
p.log.error(msg);
|
|
39
|
+
}
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
writeWorkspaceConfig({ workspaceId: workspace.id });
|
|
43
|
+
if (opts.json) {
|
|
44
|
+
console.log(JSON.stringify({ success: true, active: workspace.id, name: workspace.name }));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
p.outro(pc.green(`Workspace set to ${pc.bold(workspace.name)}`));
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// ── JSON mode: list + active ──
|
|
52
|
+
if (opts.json) {
|
|
53
|
+
const active = readWorkspaceConfig()?.workspaceId ?? null;
|
|
54
|
+
console.log(JSON.stringify({ active, workspaces }));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// ── Interactive mode: select workspace ──
|
|
58
|
+
if (workspaces.length === 0) {
|
|
59
|
+
p.log.error("No workspaces found. Create one at inflight.co");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
const currentWorkspaceId = readWorkspaceConfig()?.workspaceId;
|
|
63
|
+
if (currentWorkspaceId) {
|
|
64
|
+
const currentWs = workspaces.find((w) => w.id === currentWorkspaceId);
|
|
65
|
+
if (currentWs) {
|
|
66
|
+
p.log.info(`Current workspace: ${pc.bold(currentWs.name)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const selected = await p.select({
|
|
70
|
+
message: "Select a workspace",
|
|
71
|
+
options: workspaces.map((w) => ({
|
|
72
|
+
value: w.id,
|
|
73
|
+
label: w.name,
|
|
74
|
+
hint: currentWorkspaceId === w.id ? "current" : undefined,
|
|
75
|
+
})),
|
|
76
|
+
});
|
|
77
|
+
if (p.isCancel(selected)) {
|
|
78
|
+
p.cancel("Cancelled.");
|
|
79
|
+
process.exit(0);
|
|
80
|
+
}
|
|
81
|
+
const workspaceId = selected;
|
|
82
|
+
writeWorkspaceConfig({ workspaceId });
|
|
83
|
+
const name = workspaces.find((w) => w.id === workspaceId)?.name ?? workspaceId;
|
|
84
|
+
p.outro(pc.green(`Workspace set to ${pc.bold(name)}`));
|
|
85
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,12 @@ import { loginCommand } from "./commands/login.js";
|
|
|
5
5
|
import { shareCommand } from "./commands/share.js";
|
|
6
6
|
import { logoutCommand } from "./commands/logout.js";
|
|
7
7
|
import { resetCommand } from "./commands/reset.js";
|
|
8
|
-
import {
|
|
8
|
+
import { workspaceCommand } from "./commands/workspace.js";
|
|
9
9
|
import { registerVercelCommand } from "./commands/vercel.js";
|
|
10
10
|
import { setupCommand } from "./commands/setup.js";
|
|
11
11
|
import pkg from "../package.json" with { type: "json" };
|
|
12
12
|
const { version } = pkg;
|
|
13
|
-
updateNotifier({ pkg }).notify();
|
|
13
|
+
updateNotifier({ pkg, updateCheckInterval: 1000 * 60 * 60 }).notify();
|
|
14
14
|
const program = new Command();
|
|
15
15
|
program
|
|
16
16
|
.name("inflight")
|
|
@@ -23,7 +23,6 @@ program
|
|
|
23
23
|
.command("share")
|
|
24
24
|
.description("Get feedback on your staging URL")
|
|
25
25
|
.option("--url <url>", "Staging URL (skips provider selection)")
|
|
26
|
-
.option("--workspace <id>", "Workspace ID (skips workspace selection)")
|
|
27
26
|
.option("--json", "Output result as JSON")
|
|
28
27
|
.action((opts) => shareCommand(opts));
|
|
29
28
|
program
|
|
@@ -31,7 +30,7 @@ program
|
|
|
31
30
|
.description("Get or set your active workspace")
|
|
32
31
|
.option("--json", "Output as JSON")
|
|
33
32
|
.option("--set <id>", "Set the active workspace")
|
|
34
|
-
.action((opts) =>
|
|
33
|
+
.action((opts) => workspaceCommand(opts));
|
|
35
34
|
registerVercelCommand(program);
|
|
36
35
|
program.command("logout").description("Disconnect your Inflight account").action(logoutCommand);
|
|
37
36
|
program.command("reset").description("Clear all Inflight auth and config").action(resetCommand);
|