Public
Edited
Feb 12, 2024
Importers
Insert cell
Insert cell
Insert cell
fs = new LightningFs("fs")
Insert cell
Insert cell
pfs = fs.promises
Insert cell
Insert cell
dir = "/eol-repo"
Insert cell
Insert cell
files = {
// Delete dir if already created
if ((await pfs.readdir("/")).includes(dir.slice(1))) {
await rmDirRecursive(dir);
}
await pfs.mkdir(dir);
// Sparse checkout
await git.clone({
fs,
http,
dir,
corsProxy: "https://cors.isomorphic-git.org",
url: "https://github.com/endoflife-date/release-data",
ref: "main",
singleBranch: true,
depth: 1,
noCheckout: true
});

// Checkout release dir only
await git.checkout({
fs,
dir,
filepaths: ["releases"]
});

return pfs.readdir(dir + "/releases");
}
Insert cell
Insert cell
files.length ? await pfs.readdir(dir) : null
Insert cell
Insert cell
data = {
const jsDocs = await Promise.all(
files.map(async (filename) => {
const doc = await pfs.readFile(dir + "/releases/" + filename, "utf8");
const jsObj = JSON.parse(doc);
jsObj.filename = filename;
return jsObj;
})
);
return jsDocs;
}
Insert cell
Insert cell
async function rmDirRecursive(dirname) {
const dirContent = await pfs.readdir(dirname);
for (let item of dirContent) {
const path = dirname + "/" + item;
const stat = await pfs.stat(path);
if (stat.type === "file") {
await pfs.unlink(path);
} else {
await rmDirRecursive(path);
}
}
await pfs.rmdir(dirname);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more