Path: blob/master/src/packages/next/lib/landing/get-libraries.ts
1450 views
/*1* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { field_cmp } from "@cocalc/util/misc";6import {7ComputeComponents,8ComputeInventory,9Item,10LanguageName,11SoftwareSpec,12} from "./types";1314// client side processing, used to generate the data for the Antd tables15export function getLibaries(16spec: SoftwareSpec[LanguageName],17inventory: ComputeInventory[LanguageName],18components: ComputeComponents[LanguageName]19): Item[] {20const libs: Item[] = [];21for (const name in components) {22const { url, summary } = components[name] ?? {};23const item: Item = {24index: libs.length,25name,26key: name.toLowerCase(),27summary: summary ?? "",28// there may be multiple url's separated by commas in some cases29// TODO show all URLs30url: url?.split(",")[0],31search: (name + (summary ?? "")).toLowerCase(),32};33for (const env in spec) {34const envInfo = inventory[spec[env].cmd]?.[name];35if (envInfo != null) item[env] = envInfo;36}37libs.push(item);38}39libs.sort(field_cmp("key"));40return libs;41}424344