@instafy/cli 0.1.6 → 0.1.8-staging.348
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/README.md +8 -2
- package/dist/api.js +132 -0
- package/dist/auth.js +112 -0
- package/dist/config-command.js +104 -0
- package/dist/config.js +111 -0
- package/dist/errors.js +10 -0
- package/dist/git-credential.js +201 -0
- package/dist/git-setup.js +56 -0
- package/dist/git.js +99 -0
- package/dist/index.js +335 -64
- package/dist/org.js +5 -18
- package/dist/project.js +11 -24
- package/dist/runtime.js +273 -212
- package/dist/tunnel.js +300 -13
- package/package.json +2 -1
package/dist/org.js
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import kleur from "kleur";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (!value)
|
|
5
|
-
return "http://127.0.0.1:8788";
|
|
6
|
-
return value.replace(/\/$/, "");
|
|
7
|
-
}
|
|
8
|
-
function normalizeToken(raw) {
|
|
9
|
-
if (!raw)
|
|
10
|
-
return null;
|
|
11
|
-
const trimmed = raw.trim();
|
|
12
|
-
return trimmed.length ? trimmed : null;
|
|
13
|
-
}
|
|
2
|
+
import { resolveControllerUrl, resolveUserAccessToken } from "./config.js";
|
|
3
|
+
import { formatAuthRequiredError } from "./errors.js";
|
|
14
4
|
export async function listOrganizations(params) {
|
|
15
|
-
const controllerUrl =
|
|
16
|
-
const token =
|
|
17
|
-
normalizeToken(process.env["INSTAFY_ACCESS_TOKEN"]) ??
|
|
18
|
-
normalizeToken(process.env["CONTROLLER_ACCESS_TOKEN"]) ??
|
|
19
|
-
normalizeToken(process.env["SUPABASE_ACCESS_TOKEN"]);
|
|
5
|
+
const controllerUrl = resolveControllerUrl({ controllerUrl: params.controllerUrl ?? null });
|
|
6
|
+
const token = resolveUserAccessToken({ accessToken: params.accessToken ?? null });
|
|
20
7
|
if (!token) {
|
|
21
|
-
throw
|
|
8
|
+
throw formatAuthRequiredError({ retryCommand: "instafy org:list" });
|
|
22
9
|
}
|
|
23
10
|
const response = await fetch(`${controllerUrl}/orgs`, {
|
|
24
11
|
headers: { authorization: `Bearer ${token}` },
|
package/dist/project.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import kleur from "kleur";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!value)
|
|
7
|
-
return "http://127.0.0.1:8788";
|
|
8
|
-
return value.replace(/\/$/, "");
|
|
9
|
-
}
|
|
10
|
-
function normalizeToken(raw) {
|
|
11
|
-
if (!raw)
|
|
12
|
-
return null;
|
|
13
|
-
const trimmed = raw.trim();
|
|
14
|
-
return trimmed.length ? trimmed : null;
|
|
15
|
-
}
|
|
4
|
+
import { resolveControllerUrl, resolveUserAccessToken } from "./config.js";
|
|
5
|
+
import { formatAuthRequiredError } from "./errors.js";
|
|
16
6
|
async function fetchOrganizations(controllerUrl, token) {
|
|
17
7
|
const response = await fetch(`${controllerUrl}/orgs`, {
|
|
18
8
|
headers: {
|
|
@@ -73,13 +63,10 @@ async function resolveOrg(controllerUrl, token, options) {
|
|
|
73
63
|
return { orgId, orgName: json.org_name ?? null };
|
|
74
64
|
}
|
|
75
65
|
export async function listProjects(options) {
|
|
76
|
-
const controllerUrl =
|
|
77
|
-
const token =
|
|
78
|
-
normalizeToken(process.env["INSTAFY_ACCESS_TOKEN"]) ??
|
|
79
|
-
normalizeToken(process.env["CONTROLLER_ACCESS_TOKEN"]) ??
|
|
80
|
-
normalizeToken(process.env["SUPABASE_ACCESS_TOKEN"]);
|
|
66
|
+
const controllerUrl = resolveControllerUrl({ controllerUrl: options.controllerUrl ?? null });
|
|
67
|
+
const token = resolveUserAccessToken({ accessToken: options.accessToken ?? null });
|
|
81
68
|
if (!token) {
|
|
82
|
-
throw
|
|
69
|
+
throw formatAuthRequiredError({ retryCommand: "instafy project:list" });
|
|
83
70
|
}
|
|
84
71
|
const orgs = await fetchOrganizations(controllerUrl, token);
|
|
85
72
|
let targetOrgs = orgs;
|
|
@@ -124,13 +111,13 @@ export async function listProjects(options) {
|
|
|
124
111
|
}
|
|
125
112
|
export async function projectInit(options) {
|
|
126
113
|
const rootDir = path.resolve(options.path ?? process.cwd());
|
|
127
|
-
const controllerUrl =
|
|
128
|
-
const token =
|
|
129
|
-
normalizeToken(process.env["INSTAFY_ACCESS_TOKEN"]) ??
|
|
130
|
-
normalizeToken(process.env["CONTROLLER_ACCESS_TOKEN"]) ??
|
|
131
|
-
normalizeToken(process.env["SUPABASE_ACCESS_TOKEN"]);
|
|
114
|
+
const controllerUrl = resolveControllerUrl({ controllerUrl: options.controllerUrl ?? null });
|
|
115
|
+
const token = resolveUserAccessToken({ accessToken: options.accessToken ?? null });
|
|
132
116
|
if (!token) {
|
|
133
|
-
throw
|
|
117
|
+
throw formatAuthRequiredError({
|
|
118
|
+
retryCommand: "instafy project:init",
|
|
119
|
+
advancedHint: "pass --access-token or set INSTAFY_ACCESS_TOKEN / SUPABASE_ACCESS_TOKEN",
|
|
120
|
+
});
|
|
134
121
|
}
|
|
135
122
|
const org = await resolveOrg(controllerUrl, token, options);
|
|
136
123
|
const body = {
|