mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 10:17:23 -05:00
* Remove duplicate LICENSE. * Remove un-userd pyscript.sw directory and its content. * Remove ReadTheDocs settings (unused). * Remove un-used pyproject.toml * Remove now unused CHANGELOG. Changes now tracked via release notes on GitHub. * Updated / cleaned release page template and associated GH actions. * Update prettierignore to remove un-needed refs. * Move troubleshooting into correct README. * Add reason for the index.html * Rename the "pyscript.core" directory to "core". * Update PR template because CHANGELOG is no longer used. * Codespell configuration in pyproject.toml. * Update pyscript.core -> core in .githubignore * Remove test-results/.last-run.json. This should be ignored by git. * Pin nodejs version. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
74 lines
2.1 KiB
JavaScript
74 lines
2.1 KiB
JavaScript
const { join } = require("node:path");
|
|
const { lstatSync, readdirSync, writeFileSync } = require("node:fs");
|
|
|
|
// folders to not consider while crawling
|
|
const EXCLUDE_DIR = new Set(["ws"]);
|
|
|
|
const TEST_DIR = join(__dirname, "..", "tests");
|
|
|
|
const TEST_INDEX = join(TEST_DIR, "index.html");
|
|
|
|
const crawl = (path, tree = {}) => {
|
|
for (const file of readdirSync(path)) {
|
|
const current = join(path, file);
|
|
if (current === TEST_INDEX) continue;
|
|
if (lstatSync(current).isDirectory()) {
|
|
if (EXCLUDE_DIR.has(file)) continue;
|
|
const sub = {};
|
|
tree[file] = sub;
|
|
crawl(current, sub);
|
|
if (!Reflect.ownKeys(sub).length) {
|
|
delete tree[file];
|
|
}
|
|
} else if (file.endsWith(".html")) {
|
|
const name = file === "index.html" ? "." : file.slice(0, -5);
|
|
tree[name] = current.replace(TEST_DIR, "");
|
|
}
|
|
}
|
|
return tree;
|
|
};
|
|
|
|
const createList = (tree) => {
|
|
const ul = ["<ul>"];
|
|
for (const [key, value] of Object.entries(tree)) {
|
|
ul.push("<li>");
|
|
if (typeof value === "string") {
|
|
ul.push(`<a href=".${value}">${key}<small>.html</small></a>`);
|
|
} else {
|
|
if ("." in value) {
|
|
ul.push(`<strong><a href=".${value["."]}">${key}</a></strong>`);
|
|
delete value["."];
|
|
} else {
|
|
ul.push(`<strong><span>${key}</span></strong>`);
|
|
}
|
|
if (Reflect.ownKeys(value).length) ul.push(createList(value));
|
|
}
|
|
ul.push("</li>");
|
|
}
|
|
ul.push("</ul>");
|
|
return ul.join("");
|
|
};
|
|
|
|
writeFileSync(
|
|
TEST_INDEX,
|
|
`<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>PyScript tests</title>
|
|
<style>
|
|
body { font-family: sans-serif; }
|
|
a {
|
|
display: block;
|
|
transition: opacity .3s;
|
|
}
|
|
a, span { opacity: .7; }
|
|
a:hover { opacity: 1; }
|
|
</style>
|
|
</head>
|
|
<body>${createList(crawl(TEST_DIR))}</body>
|
|
</html>
|
|
`,
|
|
);
|