@topolo/cli 0.9.4 → 0.9.5
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/index.js +57 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { platform as platform2 } from "os";
|
|
|
9
9
|
import { createInterface } from "readline/promises";
|
|
10
10
|
import { stdin as input } from "process";
|
|
11
11
|
|
|
12
|
-
// node_modules/@topolo/sdk/dist/index.js
|
|
12
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.11/node_modules/@topolo/sdk/dist/index.js
|
|
13
13
|
function applyAuthHeaders(headers, credential) {
|
|
14
14
|
if (credential.kind === "api_key") {
|
|
15
15
|
headers.set("X-Api-Key", credential.apiKey);
|
|
@@ -2432,7 +2432,7 @@ function createTopolo(options) {
|
|
|
2432
2432
|
};
|
|
2433
2433
|
}
|
|
2434
2434
|
|
|
2435
|
-
// node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2435
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.11/node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2436
2436
|
import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
|
|
2437
2437
|
import { existsSync } from "fs";
|
|
2438
2438
|
import { homedir, platform } from "os";
|
|
@@ -5105,20 +5105,66 @@ function registerContextCommand(program2) {
|
|
|
5105
5105
|
const activeKey = profile.activeContext;
|
|
5106
5106
|
const rows = /* @__PURE__ */ new Map();
|
|
5107
5107
|
for (const [key, ctx] of Object.entries(stored)) {
|
|
5108
|
-
rows.set(key, {
|
|
5108
|
+
rows.set(key, {
|
|
5109
|
+
key,
|
|
5110
|
+
type: ctx.contextType,
|
|
5111
|
+
label: labelFor(ctx),
|
|
5112
|
+
signedIn: false,
|
|
5113
|
+
available: false,
|
|
5114
|
+
active: key === activeKey
|
|
5115
|
+
});
|
|
5109
5116
|
}
|
|
5117
|
+
const serviceUrls = resolvedProfileConfig(config, environment).serviceUrls;
|
|
5110
5118
|
const cred = await refreshCredentialIfNeeded(environment);
|
|
5119
|
+
let activeIdentity = null;
|
|
5111
5120
|
if (cred) {
|
|
5112
5121
|
try {
|
|
5113
|
-
|
|
5122
|
+
activeIdentity = await fetchMe(cred, serviceUrls);
|
|
5123
|
+
} catch {
|
|
5124
|
+
activeIdentity = null;
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5127
|
+
await Promise.all(Object.entries(stored).map(async ([key, ctx]) => {
|
|
5128
|
+
try {
|
|
5129
|
+
const contextCredential = key === activeKey ? cred : await refreshContextCredentialIfNeeded(environment, key);
|
|
5130
|
+
if (!contextCredential) return;
|
|
5131
|
+
const identity = key === activeKey && activeIdentity ? activeIdentity : await fetchMe(contextCredential, serviceUrls);
|
|
5132
|
+
if (!identityMatchesContext(identity, ctx)) return;
|
|
5133
|
+
const row = rows.get(key);
|
|
5134
|
+
if (row) rows.set(key, { ...row, signedIn: true, available: true });
|
|
5135
|
+
} catch {
|
|
5136
|
+
}
|
|
5137
|
+
}));
|
|
5138
|
+
if (activeIdentity) {
|
|
5139
|
+
try {
|
|
5114
5140
|
const personalKey = contextKey("personal");
|
|
5115
5141
|
if (!rows.has(personalKey)) {
|
|
5116
|
-
rows.set(personalKey, {
|
|
5142
|
+
rows.set(personalKey, {
|
|
5143
|
+
key: personalKey,
|
|
5144
|
+
type: "personal",
|
|
5145
|
+
label: "Personal",
|
|
5146
|
+
signedIn: false,
|
|
5147
|
+
available: true,
|
|
5148
|
+
active: personalKey === activeKey
|
|
5149
|
+
});
|
|
5150
|
+
} else {
|
|
5151
|
+
const row = rows.get(personalKey);
|
|
5152
|
+
rows.set(personalKey, { ...row, available: true });
|
|
5117
5153
|
}
|
|
5118
|
-
for (const m of
|
|
5154
|
+
for (const m of activeIdentity.memberships) {
|
|
5119
5155
|
const key = contextKey("organization", m.id);
|
|
5120
5156
|
if (!rows.has(key)) {
|
|
5121
|
-
rows.set(key, {
|
|
5157
|
+
rows.set(key, {
|
|
5158
|
+
key,
|
|
5159
|
+
type: "organization",
|
|
5160
|
+
label: m.name || m.slug || m.id,
|
|
5161
|
+
signedIn: false,
|
|
5162
|
+
available: true,
|
|
5163
|
+
active: key === activeKey
|
|
5164
|
+
});
|
|
5165
|
+
} else {
|
|
5166
|
+
const row = rows.get(key);
|
|
5167
|
+
rows.set(key, { ...row, available: true });
|
|
5122
5168
|
}
|
|
5123
5169
|
}
|
|
5124
5170
|
} catch {
|
|
@@ -5129,7 +5175,10 @@ function registerContextCommand(program2) {
|
|
|
5129
5175
|
if (list.length === 0) return "No contexts yet. Run `topolo auth login` first.";
|
|
5130
5176
|
const lines = [`Contexts (${environmentLabel(environment)}):`, ""];
|
|
5131
5177
|
for (const r of list) {
|
|
5132
|
-
const marks = [
|
|
5178
|
+
const marks = [
|
|
5179
|
+
r.active ? "active" : "",
|
|
5180
|
+
r.signedIn ? "signed in" : r.available ? "available" : "sign in required"
|
|
5181
|
+
].filter(Boolean).join(", ");
|
|
5133
5182
|
lines.push(` ${r.active ? "*" : " "} ${r.label} (${r.type}) [${marks}]`);
|
|
5134
5183
|
}
|
|
5135
5184
|
lines.push("", "Switch with: topolo context use <organization|personal>");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/cli",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"topoloPublishedVersion": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
|
+
"topoloPublishedVersion": "0.9.5",
|
|
5
5
|
"description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Topolo",
|