inflight-cli 2.0.7 → 2.0.8
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/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createCommand(): Promise<void>;
|
package/dist/commands/create.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import * as p from "@clack/prompts";
|
|
2
|
-
import pc from "picocolors";
|
|
3
|
-
import { readGlobalAuth, readWorkspaceConfig, writeWorkspaceConfig } from "../lib/config.js";
|
|
4
|
-
import { getGitInfo, isGitRepo } from "../lib/git.js";
|
|
5
|
-
import { providers } from "../providers/index.js";
|
|
6
|
-
import { apiGetMe, apiCreateVersion } from "../lib/api.js";
|
|
7
|
-
export async function createCommand() {
|
|
8
|
-
const cwd = process.cwd();
|
|
9
|
-
const auth = readGlobalAuth();
|
|
10
|
-
if (!auth) {
|
|
11
|
-
p.log.error("Not logged in. Run " + pc.cyan("inflight login") + " first.");
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
p.intro(pc.bgBlue(pc.white(" inflight share ")));
|
|
15
|
-
// Resolve workspace — read from .inflight/workspace.json, prompt if not linked
|
|
16
|
-
let workspaceId = readWorkspaceConfig(cwd)?.workspaceId;
|
|
17
|
-
if (!workspaceId) {
|
|
18
|
-
const spinner = p.spinner();
|
|
19
|
-
spinner.start("Loading workspaces...");
|
|
20
|
-
const me = await apiGetMe(auth.apiKey, auth.apiUrl).catch((e) => {
|
|
21
|
-
spinner.stop("Failed.");
|
|
22
|
-
p.log.error(e.message);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
});
|
|
25
|
-
spinner.stop("");
|
|
26
|
-
if (me.workspaces.length === 0) {
|
|
27
|
-
p.log.error("No workspaces found. Create one at inflight.co first.");
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
else if (me.workspaces.length === 1) {
|
|
31
|
-
workspaceId = me.workspaces[0].id;
|
|
32
|
-
p.log.info(`Workspace: ${pc.bold(me.workspaces[0].name)}`);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const selected = await p.select({
|
|
36
|
-
message: "Select a workspace",
|
|
37
|
-
options: me.workspaces.map((w) => ({ value: w.id, label: w.name })),
|
|
38
|
-
});
|
|
39
|
-
if (p.isCancel(selected)) {
|
|
40
|
-
p.cancel("Cancelled.");
|
|
41
|
-
process.exit(0);
|
|
42
|
-
}
|
|
43
|
-
workspaceId = selected;
|
|
44
|
-
}
|
|
45
|
-
writeWorkspaceConfig(cwd, { workspaceId });
|
|
46
|
-
}
|
|
47
|
-
// Git info
|
|
48
|
-
const gitInfo = isGitRepo(cwd)
|
|
49
|
-
? getGitInfo(cwd)
|
|
50
|
-
: { branch: null, commitShort: null, commitFull: null, commitMessage: null, remoteUrl: null, isDirty: false, diff: null };
|
|
51
|
-
// Title is auto-generated server-side from the diff/branch/commit
|
|
52
|
-
const title = gitInfo.branch ?? "Untitled";
|
|
53
|
-
// Staging URL — user picks provider
|
|
54
|
-
const providerChoice = await p.select({
|
|
55
|
-
message: "Where is your staging URL hosted?",
|
|
56
|
-
options: [
|
|
57
|
-
...providers.map((prov) => ({ value: prov.id, label: prov.label })),
|
|
58
|
-
{ value: "manual", label: "Paste a URL" },
|
|
59
|
-
],
|
|
60
|
-
});
|
|
61
|
-
if (p.isCancel(providerChoice)) {
|
|
62
|
-
p.cancel("Cancelled.");
|
|
63
|
-
process.exit(0);
|
|
64
|
-
}
|
|
65
|
-
const providerSpinner = p.spinner();
|
|
66
|
-
const provider = providers.find((prov) => prov.id === providerChoice);
|
|
67
|
-
let stagingUrl;
|
|
68
|
-
if (provider) {
|
|
69
|
-
stagingUrl = (await provider.resolve(cwd, gitInfo, providerSpinner)) ?? undefined;
|
|
70
|
-
}
|
|
71
|
-
// Manual input (or fallback if provider returned no URL)
|
|
72
|
-
if (!stagingUrl) {
|
|
73
|
-
const input = await p.text({
|
|
74
|
-
message: "Staging URL",
|
|
75
|
-
placeholder: "https://my-branch.vercel.app",
|
|
76
|
-
validate: (v) => {
|
|
77
|
-
if (!v)
|
|
78
|
-
return "Staging URL is required";
|
|
79
|
-
try {
|
|
80
|
-
new URL(v);
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return "Must be a valid URL (include https://)";
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
if (p.isCancel(input)) {
|
|
88
|
-
p.cancel("Cancelled.");
|
|
89
|
-
process.exit(0);
|
|
90
|
-
}
|
|
91
|
-
stagingUrl = input;
|
|
92
|
-
}
|
|
93
|
-
const spinner = p.spinner();
|
|
94
|
-
spinner.start("Creating version...");
|
|
95
|
-
const result = await apiCreateVersion({
|
|
96
|
-
apiKey: auth.apiKey,
|
|
97
|
-
apiUrl: auth.apiUrl,
|
|
98
|
-
workspaceId,
|
|
99
|
-
title,
|
|
100
|
-
stagingUrl,
|
|
101
|
-
gitInfo,
|
|
102
|
-
}).catch((e) => {
|
|
103
|
-
spinner.stop("Failed.");
|
|
104
|
-
p.log.error(e.message);
|
|
105
|
-
process.exit(1);
|
|
106
|
-
});
|
|
107
|
-
spinner.stop("Version created");
|
|
108
|
-
p.note(result.inflightUrl, "Your Inflight version");
|
|
109
|
-
p.outro(pc.green("✓ Done") + " — open Inflight to add feedback and publish when ready");
|
|
110
|
-
process.exit(0);
|
|
111
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function workspaceCommand(): Promise<void>;
|
|
@@ -1,49 +0,0 @@
|
|
|
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() {
|
|
6
|
-
const auth = readGlobalAuth();
|
|
7
|
-
if (!auth) {
|
|
8
|
-
p.log.error("Not logged in. Run " + pc.cyan("inflight login") + " first.");
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
11
|
-
const current = readWorkspaceConfig();
|
|
12
|
-
const spinner = p.spinner();
|
|
13
|
-
spinner.start("Loading workspaces...");
|
|
14
|
-
const me = await apiGetMe(auth.apiKey).catch((e) => {
|
|
15
|
-
spinner.stop("Failed.");
|
|
16
|
-
p.log.error(e.message);
|
|
17
|
-
process.exit(1);
|
|
18
|
-
});
|
|
19
|
-
spinner.stop("");
|
|
20
|
-
const workspaces = me.workspaces;
|
|
21
|
-
if (workspaces.length === 0) {
|
|
22
|
-
p.log.error("No workspaces found. Create one at " + pc.cyan("inflight.co") + " first.");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
// Show current workspace if set
|
|
26
|
-
if (current) {
|
|
27
|
-
const currentWs = workspaces.find((w) => w.id === current.workspaceId);
|
|
28
|
-
if (currentWs) {
|
|
29
|
-
p.log.info(`Current workspace: ${pc.bold(currentWs.name)}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const selected = await p.select({
|
|
33
|
-
message: "Select a workspace",
|
|
34
|
-
options: workspaces.map((w) => ({
|
|
35
|
-
value: w.id,
|
|
36
|
-
label: w.name,
|
|
37
|
-
hint: current?.workspaceId === w.id ? "current" : undefined,
|
|
38
|
-
})),
|
|
39
|
-
});
|
|
40
|
-
if (p.isCancel(selected)) {
|
|
41
|
-
p.cancel("Cancelled.");
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
const workspaceId = selected;
|
|
45
|
-
writeWorkspaceConfig({ workspaceId });
|
|
46
|
-
const name = workspaces.find((w) => w.id === workspaceId)?.name ?? workspaceId;
|
|
47
|
-
p.outro(pc.green(`Workspace set to ${pc.bold(name)}`));
|
|
48
|
-
process.exit(0);
|
|
49
|
-
}
|