@f5-sales-demo/xcsh 21.29.2 → 21.29.3
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 +8 -8
- package/src/cli/plugin-cli.ts +24 -2
- package/src/discovery/helpers.ts +15 -3
- package/src/extensibility/plugins/marketplace/builtin-marketplace-snapshot.ts +445 -0
- package/src/extensibility/plugins/marketplace/builtin-marketplace.provenance.json +7 -0
- package/src/extensibility/plugins/marketplace/builtin.ts +49 -0
- package/src/extensibility/plugins/marketplace/index.ts +1 -0
- package/src/extensibility/plugins/marketplace/manager.ts +140 -19
- package/src/extensibility/plugins/marketplace/registry.ts +19 -4
- package/src/extensibility/plugins/marketplace/types.ts +24 -1
- package/src/internal-urls/build-info.generated.ts +8 -8
- package/src/internal-urls/docs-index.generated.ts +46 -47
- package/src/locales/en.json +2 -2
- package/src/modes/components/plugins/state-manager.ts +1 -1
- package/src/remote-control/router.ts +7 -1
- package/src/remote-control/session.ts +6 -1
- package/src/slash-commands/builtin-registry.ts +37 -1
- package/src/slash-commands/plugin-reviewed-actions.ts +34 -0
|
@@ -12,6 +12,12 @@ import * as path from "node:path";
|
|
|
12
12
|
|
|
13
13
|
import { isEnoent, logger } from "@f5-sales-demo/pi-utils";
|
|
14
14
|
|
|
15
|
+
import {
|
|
16
|
+
BUILTIN_MARKETPLACE_NAME,
|
|
17
|
+
createBuiltinMarketplaceEntry,
|
|
18
|
+
getBuiltinMarketplaceSnapshot,
|
|
19
|
+
isBuiltinMarketplaceSource,
|
|
20
|
+
} from "./builtin";
|
|
15
21
|
import { cachePlugin } from "./cache";
|
|
16
22
|
import { classifySource, fetchMarketplace, parseMarketplaceCatalog, promoteCloneToCache } from "./fetcher";
|
|
17
23
|
import {
|
|
@@ -36,7 +42,7 @@ import type {
|
|
|
36
42
|
MarketplacePluginEntry,
|
|
37
43
|
MarketplaceRegistryEntry,
|
|
38
44
|
} from "./types";
|
|
39
|
-
import { buildPluginId, parsePluginId } from "./types";
|
|
45
|
+
import { buildPluginId, isInstalledPluginEffectivelyEnabled, parsePluginId } from "./types";
|
|
40
46
|
|
|
41
47
|
// ── Options ──────────────────────────────────────────────────────────────────
|
|
42
48
|
|
|
@@ -60,6 +66,8 @@ export interface MarketplaceManagerOptions {
|
|
|
60
66
|
* Receives any additional file paths that should also be invalidated from the fs cache.
|
|
61
67
|
*/
|
|
62
68
|
clearPluginRootsCache?: (extraPaths?: readonly string[]) => void;
|
|
69
|
+
/** Test-only escape hatch; production always includes the built-in marketplace. */
|
|
70
|
+
includeBuiltinMarketplace?: boolean;
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
export interface PluginUpdate {
|
|
@@ -95,13 +103,60 @@ export class MarketplaceManager {
|
|
|
95
103
|
this.#opts.clearPluginRootsCache?.(extra);
|
|
96
104
|
}
|
|
97
105
|
|
|
106
|
+
async #readMarketplacesRegistry(): Promise<Awaited<ReturnType<typeof readMarketplacesRegistry>>> {
|
|
107
|
+
const reg = await readMarketplacesRegistry(this.#opts.marketplacesRegistryPath);
|
|
108
|
+
if (this.#opts.includeBuiltinMarketplace === false) return reg;
|
|
109
|
+
const catalogPath = path.join(this.#opts.marketplacesCacheDir, BUILTIN_MARKETPLACE_NAME, "marketplace.json");
|
|
110
|
+
const canonical = createBuiltinMarketplaceEntry(catalogPath);
|
|
111
|
+
const existing = reg.marketplaces.find(entry => entry.name === BUILTIN_MARKETPLACE_NAME);
|
|
112
|
+
const reconciled = existing
|
|
113
|
+
? {
|
|
114
|
+
...existing,
|
|
115
|
+
name: canonical.name,
|
|
116
|
+
sourceType: canonical.sourceType,
|
|
117
|
+
sourceUri: canonical.sourceUri,
|
|
118
|
+
catalogPath: canonical.catalogPath,
|
|
119
|
+
enabled: existing.enabled !== false,
|
|
120
|
+
builtIn: true,
|
|
121
|
+
}
|
|
122
|
+
: canonical;
|
|
123
|
+
const marketplaces = [
|
|
124
|
+
reconciled,
|
|
125
|
+
...reg.marketplaces.filter(
|
|
126
|
+
entry => entry.name !== BUILTIN_MARKETPLACE_NAME && !isBuiltinMarketplaceSource(entry.sourceUri),
|
|
127
|
+
),
|
|
128
|
+
];
|
|
129
|
+
const updated = { version: 2 as const, marketplaces };
|
|
130
|
+
|
|
131
|
+
const { json: snapshot } = getBuiltinMarketplaceSnapshot();
|
|
132
|
+
let catalogUsable = false;
|
|
133
|
+
try {
|
|
134
|
+
parseMarketplaceCatalog(await Bun.file(catalogPath).text(), catalogPath);
|
|
135
|
+
catalogUsable = true;
|
|
136
|
+
} catch {
|
|
137
|
+
// A missing or invalid cache is repaired from the integrity-checked embedded snapshot.
|
|
138
|
+
}
|
|
139
|
+
if (!catalogUsable) {
|
|
140
|
+
await fs.mkdir(path.dirname(catalogPath), { recursive: true });
|
|
141
|
+
await Bun.write(catalogPath, snapshot);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (JSON.stringify(updated) !== JSON.stringify(reg)) {
|
|
145
|
+
await writeMarketplacesRegistry(this.#opts.marketplacesRegistryPath, updated);
|
|
146
|
+
}
|
|
147
|
+
return updated;
|
|
148
|
+
}
|
|
149
|
+
|
|
98
150
|
// ── Marketplace lifecycle ─────────────────────────────────────────────────
|
|
99
151
|
|
|
100
152
|
async addMarketplace(
|
|
101
153
|
source: string,
|
|
102
154
|
validateCatalogBeforeCommit?: (catalog: MarketplaceCatalog) => void,
|
|
103
155
|
): Promise<MarketplaceRegistryEntry> {
|
|
104
|
-
const reg = await readMarketplacesRegistry(
|
|
156
|
+
const reg = await this.#readMarketplacesRegistry();
|
|
157
|
+
if (isBuiltinMarketplaceSource(source)) {
|
|
158
|
+
throw new Error(`Marketplace "${BUILTIN_MARKETPLACE_NAME}" is built in and its canonical source is reserved.`);
|
|
159
|
+
}
|
|
105
160
|
const existingNames = new Set(reg.marketplaces.map(m => m.name));
|
|
106
161
|
|
|
107
162
|
const { catalog, clonePath } = await fetchMarketplace(source, this.#opts.marketplacesCacheDir);
|
|
@@ -143,6 +198,8 @@ export class MarketplaceManager {
|
|
|
143
198
|
catalogPath,
|
|
144
199
|
addedAt: now,
|
|
145
200
|
updatedAt: now,
|
|
201
|
+
enabled: true,
|
|
202
|
+
builtIn: false,
|
|
146
203
|
};
|
|
147
204
|
|
|
148
205
|
const updated = addMarketplaceEntry(reg, entry);
|
|
@@ -153,7 +210,11 @@ export class MarketplaceManager {
|
|
|
153
210
|
}
|
|
154
211
|
|
|
155
212
|
async removeMarketplace(name: string): Promise<void> {
|
|
156
|
-
const reg = await readMarketplacesRegistry(
|
|
213
|
+
const reg = await this.#readMarketplacesRegistry();
|
|
214
|
+
const existing = getMarketplaceEntry(reg, name);
|
|
215
|
+
if (existing?.builtIn) {
|
|
216
|
+
throw new Error(`Marketplace "${name}" is built in and cannot be removed. Disable it instead.`);
|
|
217
|
+
}
|
|
157
218
|
// removeMarketplaceEntry throws if not found — propagate to caller.
|
|
158
219
|
const updated = removeMarketplaceEntry(reg, name);
|
|
159
220
|
await writeMarketplacesRegistry(this.#opts.marketplacesRegistryPath, updated);
|
|
@@ -167,11 +228,14 @@ export class MarketplaceManager {
|
|
|
167
228
|
}
|
|
168
229
|
|
|
169
230
|
async updateMarketplace(name: string): Promise<MarketplaceRegistryEntry> {
|
|
170
|
-
const reg = await readMarketplacesRegistry(
|
|
231
|
+
const reg = await this.#readMarketplacesRegistry();
|
|
171
232
|
const existing = getMarketplaceEntry(reg, name);
|
|
172
233
|
if (!existing) {
|
|
173
234
|
throw new Error(`Marketplace "${name}" not found`);
|
|
174
235
|
}
|
|
236
|
+
if (!existing.enabled) {
|
|
237
|
+
throw new Error(`Marketplace "${name}" is disabled. Enable it before updating.`);
|
|
238
|
+
}
|
|
175
239
|
|
|
176
240
|
const fetchResult: { catalog: MarketplaceCatalog; clonePath?: string } = await fetchMarketplace(
|
|
177
241
|
existing.sourceUri,
|
|
@@ -215,7 +279,7 @@ export class MarketplaceManager {
|
|
|
215
279
|
}
|
|
216
280
|
|
|
217
281
|
async updateAllMarketplaces(): Promise<MarketplaceRegistryEntry[]> {
|
|
218
|
-
const marketplaces = await this.listMarketplaces();
|
|
282
|
+
const marketplaces = (await this.listMarketplaces()).filter(marketplace => marketplace.enabled);
|
|
219
283
|
const results: MarketplaceRegistryEntry[] = [];
|
|
220
284
|
for (const m of marketplaces) {
|
|
221
285
|
const updated = await this.updateMarketplace(m.name);
|
|
@@ -225,19 +289,41 @@ export class MarketplaceManager {
|
|
|
225
289
|
}
|
|
226
290
|
|
|
227
291
|
async listMarketplaces(): Promise<MarketplaceRegistryEntry[]> {
|
|
228
|
-
const reg = await readMarketplacesRegistry(
|
|
292
|
+
const reg = await this.#readMarketplacesRegistry();
|
|
229
293
|
return reg.marketplaces;
|
|
230
294
|
}
|
|
231
295
|
|
|
296
|
+
async setMarketplaceEnabled(name: string, enabled: boolean): Promise<MarketplaceRegistryEntry> {
|
|
297
|
+
const reg = await this.#readMarketplacesRegistry();
|
|
298
|
+
const existing = getMarketplaceEntry(reg, name);
|
|
299
|
+
if (!existing) throw new Error(`Marketplace "${name}" not found`);
|
|
300
|
+
if (existing.enabled === enabled) return existing;
|
|
301
|
+
const now = new Date().toISOString();
|
|
302
|
+
const updatedEntry: MarketplaceRegistryEntry = {
|
|
303
|
+
...existing,
|
|
304
|
+
enabled,
|
|
305
|
+
...(!enabled ? { pluginsDisabledAt: now } : {}),
|
|
306
|
+
};
|
|
307
|
+
await writeMarketplacesRegistry(this.#opts.marketplacesRegistryPath, {
|
|
308
|
+
...reg,
|
|
309
|
+
marketplaces: reg.marketplaces.map(entry => (entry.name === name ? updatedEntry : entry)),
|
|
310
|
+
});
|
|
311
|
+
this.#clearCache();
|
|
312
|
+
return updatedEntry;
|
|
313
|
+
}
|
|
314
|
+
|
|
232
315
|
/**
|
|
233
316
|
* Best-effort interactive refresh. Unlike refreshStaleMarketplaces(), this always
|
|
234
317
|
* fetches every selected marketplace and isolates failures so cached catalogs remain usable.
|
|
235
318
|
*/
|
|
236
319
|
async refreshMarketplaces(names?: readonly string[]): Promise<MarketplaceRefreshResult> {
|
|
237
|
-
const
|
|
320
|
+
const enabled = (await this.listMarketplaces()).filter(marketplace => marketplace.enabled);
|
|
321
|
+
const enabledNames = new Set(enabled.map(marketplace => marketplace.name));
|
|
322
|
+
const selected = names ?? [...enabledNames];
|
|
238
323
|
const result: MarketplaceRefreshResult = { successful: [], failed: [] };
|
|
239
324
|
|
|
240
325
|
for (const name of new Set(selected)) {
|
|
326
|
+
if (!enabledNames.has(name)) continue;
|
|
241
327
|
try {
|
|
242
328
|
await this.updateMarketplace(name);
|
|
243
329
|
result.successful.push(name);
|
|
@@ -255,9 +341,10 @@ export class MarketplaceManager {
|
|
|
255
341
|
|
|
256
342
|
/** Fetch current catalogs without mutating persistent state (used by dry-run workflows). */
|
|
257
343
|
async previewMarketplacePlugins(names?: readonly string[]): Promise<MarketplaceCatalogPreview> {
|
|
258
|
-
const reg = await readMarketplacesRegistry(
|
|
259
|
-
const
|
|
260
|
-
const
|
|
344
|
+
const reg = await this.#readMarketplacesRegistry();
|
|
345
|
+
const enabledMarketplaces = reg.marketplaces.filter(marketplace => marketplace.enabled);
|
|
346
|
+
const selectedNames = names ?? enabledMarketplaces.map(marketplace => marketplace.name);
|
|
347
|
+
const selected = new Map(enabledMarketplaces.map(marketplace => [marketplace.name, marketplace]));
|
|
261
348
|
const previewDir = await fs.mkdtemp(path.join(os.tmpdir(), "xcsh-marketplace-preview-"));
|
|
262
349
|
const result: MarketplaceCatalogPreview = { successful: [], failed: [], plugins: [] };
|
|
263
350
|
|
|
@@ -297,19 +384,21 @@ export class MarketplaceManager {
|
|
|
297
384
|
// ── Plugin discovery ──────────────────────────────────────────────────────
|
|
298
385
|
|
|
299
386
|
async listAvailablePlugins(marketplace?: string): Promise<MarketplacePluginEntry[]> {
|
|
300
|
-
const reg = await readMarketplacesRegistry(
|
|
387
|
+
const reg = await this.#readMarketplacesRegistry();
|
|
301
388
|
|
|
302
389
|
if (marketplace !== undefined) {
|
|
303
390
|
const entry = reg.marketplaces.find(m => m.name === marketplace);
|
|
304
391
|
if (!entry) {
|
|
305
392
|
throw new Error(`Marketplace "${marketplace}" not found`);
|
|
306
393
|
}
|
|
394
|
+
if (!entry.enabled) return [];
|
|
307
395
|
const catalog = await this.#readCatalog(entry);
|
|
308
396
|
return catalog.plugins;
|
|
309
397
|
}
|
|
310
398
|
|
|
311
399
|
const all: MarketplacePluginEntry[] = [];
|
|
312
400
|
for (const entry of reg.marketplaces) {
|
|
401
|
+
if (!entry.enabled) continue;
|
|
313
402
|
try {
|
|
314
403
|
const catalog = await this.#readCatalog(entry);
|
|
315
404
|
all.push(...catalog.plugins);
|
|
@@ -337,11 +426,14 @@ export class MarketplaceManager {
|
|
|
337
426
|
const registryPath = this.#registryPath(scope);
|
|
338
427
|
|
|
339
428
|
// 1. Find marketplace entry
|
|
340
|
-
const mktReg = await readMarketplacesRegistry(
|
|
429
|
+
const mktReg = await this.#readMarketplacesRegistry();
|
|
341
430
|
const mktEntry = getMarketplaceEntry(mktReg, marketplace);
|
|
342
431
|
if (!mktEntry) {
|
|
343
432
|
throw new Error(`Marketplace "${marketplace}" not found`);
|
|
344
433
|
}
|
|
434
|
+
if (!mktEntry.enabled) {
|
|
435
|
+
throw new Error(`Marketplace "${marketplace}" is disabled. Enable it before installing plugins.`);
|
|
436
|
+
}
|
|
345
437
|
|
|
346
438
|
// 2. Find plugin in catalog
|
|
347
439
|
const catalog = await this.#readCatalog(mktEntry);
|
|
@@ -547,6 +639,8 @@ export class MarketplaceManager {
|
|
|
547
639
|
// ── Plugin state ──────────────────────────────────────────────────────────
|
|
548
640
|
|
|
549
641
|
async listInstalledPlugins(): Promise<InstalledPluginSummary[]> {
|
|
642
|
+
const marketplaceReg = await this.#readMarketplacesRegistry();
|
|
643
|
+
const marketplaces = new Map(marketplaceReg.marketplaces.map(entry => [entry.name, entry]));
|
|
550
644
|
const userReg = await readInstalledPluginsRegistry(this.#opts.installedRegistryPath);
|
|
551
645
|
const projectReg = this.#opts.projectInstalledRegistryPath
|
|
552
646
|
? await readInstalledPluginsRegistry(this.#opts.projectInstalledRegistryPath)
|
|
@@ -557,7 +651,16 @@ export class MarketplaceManager {
|
|
|
557
651
|
const activeProjectIds = new Set(
|
|
558
652
|
projectReg
|
|
559
653
|
? Object.entries(projectReg.plugins)
|
|
560
|
-
.filter(([, entries]) =>
|
|
654
|
+
.filter(([id, entries]) => {
|
|
655
|
+
const parsed = parsePluginId(id);
|
|
656
|
+
return (
|
|
657
|
+
entries.length > 0 &&
|
|
658
|
+
isInstalledPluginEffectivelyEnabled(
|
|
659
|
+
entries[0],
|
|
660
|
+
parsed ? marketplaces.get(parsed.marketplace) : undefined,
|
|
661
|
+
)
|
|
662
|
+
);
|
|
663
|
+
})
|
|
561
664
|
.map(([id]) => id)
|
|
562
665
|
: [],
|
|
563
666
|
);
|
|
@@ -566,15 +669,27 @@ export class MarketplaceManager {
|
|
|
566
669
|
// Project entries first
|
|
567
670
|
if (projectReg) {
|
|
568
671
|
for (const [id, entries] of Object.entries(projectReg.plugins)) {
|
|
569
|
-
|
|
672
|
+
const parsed = parsePluginId(id);
|
|
673
|
+
results.push({
|
|
674
|
+
id,
|
|
675
|
+
scope: "project",
|
|
676
|
+
entries,
|
|
677
|
+
effectiveEnabled: entries.some(entry =>
|
|
678
|
+
isInstalledPluginEffectivelyEnabled(entry, parsed ? marketplaces.get(parsed.marketplace) : undefined),
|
|
679
|
+
),
|
|
680
|
+
});
|
|
570
681
|
}
|
|
571
682
|
}
|
|
572
683
|
// User entries (shadow-marked if overridden by project)
|
|
573
684
|
for (const [id, entries] of Object.entries(userReg.plugins)) {
|
|
685
|
+
const parsed = parsePluginId(id);
|
|
574
686
|
results.push({
|
|
575
687
|
id,
|
|
576
688
|
scope: "user",
|
|
577
689
|
entries,
|
|
690
|
+
effectiveEnabled: entries.some(entry =>
|
|
691
|
+
isInstalledPluginEffectivelyEnabled(entry, parsed ? marketplaces.get(parsed.marketplace) : undefined),
|
|
692
|
+
),
|
|
578
693
|
...(activeProjectIds.has(id) ? { shadowedBy: "project" as const } : {}),
|
|
579
694
|
});
|
|
580
695
|
}
|
|
@@ -620,7 +735,11 @@ export class MarketplaceManager {
|
|
|
620
735
|
...reg,
|
|
621
736
|
plugins: {
|
|
622
737
|
...reg.plugins,
|
|
623
|
-
[pluginId]: entries.map(e => ({
|
|
738
|
+
[pluginId]: entries.map(e => ({
|
|
739
|
+
...e,
|
|
740
|
+
enabled,
|
|
741
|
+
...(enabled ? { enabledAt: new Date().toISOString() } : {}),
|
|
742
|
+
})),
|
|
624
743
|
},
|
|
625
744
|
};
|
|
626
745
|
await writeInstalledPluginsRegistry(registryPath, updated);
|
|
@@ -635,9 +754,10 @@ export class MarketplaceManager {
|
|
|
635
754
|
// Refresh marketplace catalogs that haven't been updated in more than 24 h.
|
|
636
755
|
// Per-marketplace failures are silently swallowed — offline is fine.
|
|
637
756
|
async refreshStaleMarketplaces(): Promise<void> {
|
|
638
|
-
const reg = await readMarketplacesRegistry(
|
|
757
|
+
const reg = await this.#readMarketplacesRegistry();
|
|
639
758
|
const staleMs = 24 * 60 * 60 * 1000;
|
|
640
759
|
for (const entry of reg.marketplaces) {
|
|
760
|
+
if (!entry.enabled) continue;
|
|
641
761
|
if (Date.now() - Date.parse(entry.updatedAt) >= staleMs) {
|
|
642
762
|
try {
|
|
643
763
|
await this.updateMarketplace(entry.name);
|
|
@@ -656,7 +776,7 @@ export class MarketplaceManager {
|
|
|
656
776
|
// comparing, so freshly-published versions are seen. Passive callers (startup notify,
|
|
657
777
|
// dashboard poll) omit it and rely on the 24h TTL (refreshStaleMarketplaces).
|
|
658
778
|
if (opts?.refresh) await this.refreshMarketplaces();
|
|
659
|
-
const mktReg = await readMarketplacesRegistry(
|
|
779
|
+
const mktReg = await this.#readMarketplacesRegistry();
|
|
660
780
|
return this.#collectUpdates(mktReg);
|
|
661
781
|
}
|
|
662
782
|
|
|
@@ -665,11 +785,12 @@ export class MarketplaceManager {
|
|
|
665
785
|
* No registry, persistent cache, installed plugin, or timestamp is changed.
|
|
666
786
|
*/
|
|
667
787
|
async previewPluginUpdates(): Promise<PluginUpdate[]> {
|
|
668
|
-
const mktReg = await readMarketplacesRegistry(
|
|
788
|
+
const mktReg = await this.#readMarketplacesRegistry();
|
|
669
789
|
const previewDir = await fs.mkdtemp(path.join(os.tmpdir(), "xcsh-plugin-upgrade-preview-"));
|
|
670
790
|
try {
|
|
671
791
|
const catalogs = new Map<string, MarketplaceCatalog>();
|
|
672
792
|
for (const marketplace of mktReg.marketplaces) {
|
|
793
|
+
if (!marketplace.enabled) continue;
|
|
673
794
|
const { catalog } = await fetchMarketplace(marketplace.sourceUri, previewDir);
|
|
674
795
|
if (catalog.name !== marketplace.name) {
|
|
675
796
|
throw new Error(
|
|
@@ -712,7 +833,7 @@ export class MarketplaceManager {
|
|
|
712
833
|
if (!installed) continue;
|
|
713
834
|
|
|
714
835
|
const mktEntry = mktReg.marketplaces.find(m => m.name === parsed.marketplace);
|
|
715
|
-
if (!mktEntry) continue;
|
|
836
|
+
if (!mktEntry?.enabled) continue;
|
|
716
837
|
|
|
717
838
|
let catalogVersion: string | undefined;
|
|
718
839
|
if (catalogs) {
|
|
@@ -76,18 +76,33 @@ async function atomicWriteJson(filePath: string, data: unknown): Promise<void> {
|
|
|
76
76
|
// ── Marketplaces registry ────────────────────────────────────────────
|
|
77
77
|
|
|
78
78
|
function emptyMarketplacesRegistry(): MarketplacesRegistry {
|
|
79
|
-
return { version:
|
|
79
|
+
return { version: 2, marketplaces: [] };
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export async function readMarketplacesRegistry(filePath: string): Promise<MarketplacesRegistry> {
|
|
83
83
|
try {
|
|
84
84
|
const content = await Bun.file(filePath).text();
|
|
85
|
-
const data = tryParseJson<
|
|
86
|
-
if (
|
|
85
|
+
const data = tryParseJson<{ version?: unknown; marketplaces?: unknown }>(content);
|
|
86
|
+
if (
|
|
87
|
+
!data ||
|
|
88
|
+
typeof data !== "object" ||
|
|
89
|
+
(data.version !== 1 && data.version !== 2) ||
|
|
90
|
+
!Array.isArray(data.marketplaces)
|
|
91
|
+
) {
|
|
87
92
|
logger.warn("Invalid marketplaces registry, returning empty", { path: filePath });
|
|
88
93
|
return emptyMarketplacesRegistry();
|
|
89
94
|
}
|
|
90
|
-
|
|
95
|
+
|
|
96
|
+
const migrated: MarketplacesRegistry = {
|
|
97
|
+
version: 2,
|
|
98
|
+
marketplaces: (data.marketplaces as MarketplaceRegistryEntry[]).map(entry => ({
|
|
99
|
+
...entry,
|
|
100
|
+
enabled: entry.enabled !== false,
|
|
101
|
+
builtIn: entry.builtIn === true,
|
|
102
|
+
})),
|
|
103
|
+
};
|
|
104
|
+
if (data.version === 1) await atomicWriteJson(filePath, migrated);
|
|
105
|
+
return migrated;
|
|
91
106
|
} catch (err) {
|
|
92
107
|
if (isEnoent(err)) return emptyMarketplacesRegistry();
|
|
93
108
|
throw err;
|
|
@@ -145,7 +145,7 @@ export interface PluginSourceNpm {
|
|
|
145
145
|
// ── Marketplaces registry (stored in <configRoot>/marketplaces.json) ─
|
|
146
146
|
|
|
147
147
|
export interface MarketplacesRegistry {
|
|
148
|
-
version:
|
|
148
|
+
version: 2;
|
|
149
149
|
marketplaces: MarketplaceRegistryEntry[];
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -158,6 +158,12 @@ export interface MarketplaceRegistryEntry {
|
|
|
158
158
|
catalogPath: string;
|
|
159
159
|
addedAt: string;
|
|
160
160
|
updatedAt: string;
|
|
161
|
+
/** Whether discovery and lifecycle operations are allowed for this marketplace. */
|
|
162
|
+
enabled: boolean;
|
|
163
|
+
/** Built-in entries are reconciled by xcsh and cannot be removed. */
|
|
164
|
+
builtIn: boolean;
|
|
165
|
+
/** Most recent marketplace disable time. Used to keep older installs inactive after re-enable. */
|
|
166
|
+
pluginsDisabledAt?: string;
|
|
161
167
|
}
|
|
162
168
|
|
|
163
169
|
// ── Installed plugins registry ───────────────────────────────────────
|
|
@@ -183,6 +189,8 @@ export interface InstalledPluginEntry {
|
|
|
183
189
|
gitCommitSha?: string;
|
|
184
190
|
/** OMP extension — CLI/UI concern only in v1. */
|
|
185
191
|
enabled?: boolean;
|
|
192
|
+
/** Most recent explicit plugin enable time. */
|
|
193
|
+
enabledAt?: string;
|
|
186
194
|
}
|
|
187
195
|
|
|
188
196
|
/**
|
|
@@ -196,6 +204,21 @@ export interface InstalledPluginSummary {
|
|
|
196
204
|
id: string;
|
|
197
205
|
scope: "user" | "project" | "local";
|
|
198
206
|
entries: InstalledPluginEntry[];
|
|
207
|
+
/** Effective state after applying both plugin and marketplace enablement. */
|
|
208
|
+
effectiveEnabled?: boolean;
|
|
199
209
|
/** Set when a user-scoped plugin is overridden by a project-scoped install. */
|
|
200
210
|
shadowedBy?: "project";
|
|
201
211
|
}
|
|
212
|
+
|
|
213
|
+
export function isInstalledPluginEffectivelyEnabled(
|
|
214
|
+
entry: Pick<InstalledPluginEntry, "enabled" | "enabledAt" | "installedAt">,
|
|
215
|
+
marketplace?: Pick<MarketplaceRegistryEntry, "enabled" | "pluginsDisabledAt">,
|
|
216
|
+
): boolean {
|
|
217
|
+
if (entry.enabled === false || marketplace?.enabled === false) return false;
|
|
218
|
+
if (!marketplace?.pluginsDisabledAt) return true;
|
|
219
|
+
const disabledAt = Date.parse(marketplace.pluginsDisabledAt);
|
|
220
|
+
if (!Number.isFinite(disabledAt)) return true;
|
|
221
|
+
const installedAt = Date.parse(entry.installedAt);
|
|
222
|
+
const explicitlyEnabledAt = entry.enabledAt ? Date.parse(entry.enabledAt) : Number.NEGATIVE_INFINITY;
|
|
223
|
+
return installedAt > disabledAt || explicitlyEnabledAt > disabledAt;
|
|
224
|
+
}
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "21.29.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
20
|
+
"version": "21.29.3",
|
|
21
|
+
"commit": "15446dd8e4ac725d395e5664e370820113f0c882",
|
|
22
|
+
"shortCommit": "15446dd",
|
|
23
23
|
"branch": "main",
|
|
24
|
-
"tag": "v21.29.
|
|
25
|
-
"commitDate": "2026-09-
|
|
26
|
-
"buildDate": "2026-09-
|
|
24
|
+
"tag": "v21.29.3",
|
|
25
|
+
"commitDate": "2026-09-16T19:59:36+00:00",
|
|
26
|
+
"buildDate": "2026-09-16T20:54:14.595Z",
|
|
27
27
|
"dirty": true,
|
|
28
28
|
"prNumber": "",
|
|
29
29
|
"repoUrl": "https://github.com/f5-sales-demo/xcsh",
|
|
30
30
|
"repoSlug": "f5-sales-demo/xcsh",
|
|
31
|
-
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/
|
|
32
|
-
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.29.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/15446dd8e4ac725d395e5664e370820113f0c882",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.29.3"
|
|
33
33
|
};
|