CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

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