@topolo/cli 0.9.4 → 0.9.6
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
|
@@ -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>");
|
|
@@ -5153,9 +5202,9 @@ function registerContextCommand(program2) {
|
|
|
5153
5202
|
const wantPersonal = /^(personal|me)$/i.test(target.trim());
|
|
5154
5203
|
let resolved;
|
|
5155
5204
|
const needle = target.trim().toLowerCase();
|
|
5156
|
-
const storedEntry = Object.entries(profile.contexts ?? {}).find(([, candidate]) => {
|
|
5205
|
+
const storedEntry = Object.entries(profile.contexts ?? {}).find(([key2, candidate]) => {
|
|
5157
5206
|
if (wantPersonal) return candidate.contextType === "personal";
|
|
5158
|
-
return candidate.contextType === "organization" && (candidate.organizationId === target || candidate.organizationSlug?.toLowerCase() === needle || candidate.organizationName?.toLowerCase() === needle);
|
|
5207
|
+
return key2.toLowerCase() === needle || candidate.contextType === "organization" && (candidate.organizationId === target || candidate.organizationSlug?.toLowerCase() === needle || candidate.organizationName?.toLowerCase() === needle);
|
|
5159
5208
|
});
|
|
5160
5209
|
const storedContext = storedEntry?.[1];
|
|
5161
5210
|
if (storedEntry && storedContext?.credential) {
|
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.6",
|
|
4
|
+
"topoloPublishedVersion": "0.9.6",
|
|
5
5
|
"description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Topolo",
|