@primitivedotdev/cli 0.35.0 → 0.35.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,4 +1,4 @@
|
|
|
1
|
-
import { b as
|
|
1
|
+
import { b as normalizeApiBaseUrl, c as resolveConfigEnvironment, i as loadCliConfig } from "../cli-config-DREZ2BxT.js";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { homedir } from "node:os";
|
|
@@ -20,17 +20,18 @@ function readRootCredentials(configDir) {
|
|
|
20
20
|
const parsed = JSON.parse(raw);
|
|
21
21
|
if (parsed.auth_method !== "oauth") return null;
|
|
22
22
|
if (typeof parsed.access_token !== "string" || !parsed.access_token.trim()) return null;
|
|
23
|
-
|
|
23
|
+
const apiBaseUrl = parsed.api_base_url ?? parsed.api_base_url_1;
|
|
24
|
+
if (typeof apiBaseUrl !== "string" || !apiBaseUrl.trim()) return null;
|
|
24
25
|
return {
|
|
25
26
|
accessToken: parsed.access_token,
|
|
26
|
-
|
|
27
|
+
apiBaseUrl: apiBaseUrl.replace(/\/+$/, "")
|
|
27
28
|
};
|
|
28
29
|
} catch {
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
function accountEndpoint(
|
|
33
|
-
return `${
|
|
33
|
+
function accountEndpoint(apiBaseUrl) {
|
|
34
|
+
return `${apiBaseUrl.replace(/\/+$/, "")}/account`;
|
|
34
35
|
}
|
|
35
36
|
function parseRootAccount(payload) {
|
|
36
37
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) return null;
|
|
@@ -49,11 +50,11 @@ function rootAuthLine(account) {
|
|
|
49
50
|
}
|
|
50
51
|
function rootRequestConfig(configDir, env) {
|
|
51
52
|
const currentEnvironment = resolveConfigEnvironment(loadCliConfig(configDir));
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
if (currentEnvironment !== null && currentEnvironment.name !== "default" && !
|
|
53
|
+
const configuredApiBaseUrl = currentEnvironment?.config.api_base_url;
|
|
54
|
+
const envApiBaseUrl = env.PRIMITIVE_API_BASE_URL?.trim();
|
|
55
|
+
if (currentEnvironment !== null && currentEnvironment.name !== "default" && !envApiBaseUrl && !configuredApiBaseUrl) return null;
|
|
55
56
|
return {
|
|
56
|
-
|
|
57
|
+
apiBaseUrl: normalizeApiBaseUrl(envApiBaseUrl || configuredApiBaseUrl),
|
|
57
58
|
headers: currentEnvironment?.config.headers
|
|
58
59
|
};
|
|
59
60
|
}
|
|
@@ -61,7 +62,7 @@ async function fetchRootAccount(params) {
|
|
|
61
62
|
const controller = new AbortController();
|
|
62
63
|
const timer = setTimeout(() => controller.abort(), params.timeoutMs);
|
|
63
64
|
try {
|
|
64
|
-
const response = await params.fetch(accountEndpoint(params.
|
|
65
|
+
const response = await params.fetch(accountEndpoint(params.apiBaseUrl), {
|
|
65
66
|
headers: {
|
|
66
67
|
...params.headers ?? {},
|
|
67
68
|
accept: "application/json",
|
|
@@ -93,7 +94,7 @@ async function rootSignedInSummary(options = {}) {
|
|
|
93
94
|
const apiKey = explicitApiKey || stored?.accessToken;
|
|
94
95
|
if (!apiKey) return null;
|
|
95
96
|
const account = await fetchRootAccount({
|
|
96
|
-
|
|
97
|
+
apiBaseUrl: stored?.apiBaseUrl ?? requestConfig.apiBaseUrl,
|
|
97
98
|
apiKey,
|
|
98
99
|
fetch: options.fetch ?? fetch,
|
|
99
100
|
headers: requestConfig.headers,
|
package/man/primitive.1
CHANGED
|
@@ -99,11 +99,8 @@ API key used when
|
|
|
99
99
|
.B --api-key
|
|
100
100
|
is not supplied and no saved OAuth credential should be used.
|
|
101
101
|
.TP
|
|
102
|
-
.B
|
|
103
|
-
Override the
|
|
104
|
-
.TP
|
|
105
|
-
.B PRIMITIVE_API_BASE_URL_2
|
|
106
|
-
Override the secondary API base URL used for selected send flows. Intended for development and testing.
|
|
102
|
+
.B PRIMITIVE_API_BASE_URL
|
|
103
|
+
Override the API base URL. Intended for development and testing.
|
|
107
104
|
.SH FILES
|
|
108
105
|
.TP
|
|
109
106
|
.I ~/.config/primitive
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primitivedotdev/cli",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.1",
|
|
4
4
|
"description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|