storebound/apps/desktop/src/lib/identity.ts
CRT 2165322c02 CLI workspace for many apps and studios, credential profiles, release trains (release status / plan)
- storebound.workspace.json: app folders (globs), studios with accounts by credential profile, ignore list, the
  desktop's pairing overrides; ws init | list | status | check | validate | run | apps import | desktop export/import
- credential profiles in ~/.storebound/credentials/<profile>.json or env, --account <profile> on any command
- release status / release plan <version>, table or --json; MCP workspace_list, workspace_status, release_status,
  release_plan (read-only)
- pairing rules (cli/lib/identity.ts), release lanes (cli/lib/train.ts) and the per-app status read
  (cli/lib/app-status.ts) shared with the desktop instead of copied
- tests with sanitized fixtures, README, skills, CHANGELOG
2026-10-11 23:35:45 +08:00

43 lines
2.5 KiB
TypeScript

// One app card per product, across studios and store accounts. The pairing rules live in cli/lib/identity.ts (shared
// with the CLI workspace, `storebound ws`); this file adds the desktop's types and the portfolio list helpers.
import type { Project } from '../api';
import type { UnifiedApp as CoreApp } from '../../../../cli/lib/identity';
export {
buildApps, type BuildInput, NO_OVERRIDES, normId, normName, type Overrides, type Pair, pairCandidates, type Pairing, refKey, type StoreRef, storeTarget,
withIgnored, withLink, withPair, withStudio, withUnpair,
} from '../../../../cli/lib/identity';
export type UnifiedApp = CoreApp<Project>;
// ---- Portfolio list: filter, search, sort, group ----
export type SortBy = 'attention' | 'recent' | 'name';
export interface ListRow { app: UnifiedApp; attention: number; blockers: number; updated: string | null }
export function filterSort(rows: ListRow[], o: { studio: string | 'all' | 'none'; query: string; sort: SortBy }): ListRow[] {
const q = o.query.trim().toLowerCase();
const hit = (r: ListRow) => !q || [r.app.name, r.app.ios?.app.bundleId, r.app.android?.app.id, r.app.project?.path.split(/[\\/]/).pop()]
.some(s => s && s.toLowerCase().includes(q));
const inStudio = (r: ListRow) => o.studio === 'all' || (o.studio === 'none' ? !r.app.studio : r.app.studio === o.studio);
const by = {
attention: (a: ListRow, b: ListRow) => b.blockers - a.blockers || b.attention - a.attention || a.app.name.localeCompare(b.app.name),
recent: (a: ListRow, b: ListRow) => (b.updated ?? '').localeCompare(a.updated ?? '') || a.app.name.localeCompare(b.app.name),
name: (a: ListRow, b: ListRow) => a.app.name.localeCompare(b.app.name),
}[o.sort];
return rows.filter(r => !r.app.ignored && inStudio(r) && hit(r)).sort(by);
}
/** Groups by studio in the studios' order, apps without a studio last. */
export function groupByStudio<T extends { app: UnifiedApp }>(rows: T[], studios: { id: string }[]): { studio: string | null; rows: T[] }[] {
const order = [...studios.map(s => s.id as string | null), null];
const known = new Set(studios.map(s => s.id));
return order.map(id => ({ studio: id, rows: rows.filter(r => (id === null ? !r.app.studio || !known.has(r.app.studio) : r.app.studio === id)) })).filter(g => g.rows.length);
}
/** Per studio: visible apps (not ignored). */
export function studioCounts(apps: UnifiedApp[]): Record<string, number> {
const m: Record<string, number> = {};
for (const a of apps) if (!a.ignored) m[a.studio ?? ''] = (m[a.studio ?? ''] ?? 0) + 1;
return m;
}