diff --git a/localinfra/github-stub/server.py b/localinfra/github-stub/server.py index 84336c331..ffda0c666 100644 --- a/localinfra/github-stub/server.py +++ b/localinfra/github-stub/server.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import json import os +import random import re import struct import subprocess @@ -100,6 +101,52 @@ REPO_METADATA = { } +# filler so the import list has enough rows to page, scroll and truncate; seeded so it's stable +def _filler(count: int): + rng = random.Random(7) + adjectives = ["tiny", "rusty", "quiet", "brisk", "lazy", "shiny", "fuzzy", "bold", "spare", "odd", + "swift", "mellow", "plain", "wild", "sleepy", "eager", "hollow", "neon", "paper", "frozen"] + nouns = ["parser", "kettle", "badger", "lantern", "compiler", "garden", "relay", "sketch", "atlas", + "widget", "harbor", "beacon", "notebook", "cache", "spindle", "loom", "orbit", "pebble", + "toolbox", "ledger", "router", "canvas", "sampler", "daemon", "shelf"] + subjects = ["A small library", "Experimental tooling", "Personal dotfiles", "A toy interpreter", + "Benchmarks and notes", "A static site", "Bindings", "A CLI", "Config and scripts", + "Half-finished prototype"] + purposes = ["for parsing odd file formats", "for syncing things between machines", + "that nobody asked for", "for the homelab", "for learning the language", + "kept around for reference", "for a weekend hackathon", "extracted from a bigger project", + "for generating release notes", "for poking at network protocols"] + tails = ["", "", "", " Mostly works, occasionally surprises. Contributions welcome but expect slow reviews.", + " Includes a test suite, a fuzzing harness, a handful of examples and a README that is more" + " aspirational than accurate."] + languages = ["Rust", "Go", "TypeScript", "Python", "Shell", "C", "Haskell", "Nix", "Lua", "Zig", + "OCaml", "Elixir", "JavaScript", "Svelte", None] + + names = set(REPO_METADATA) + seeds = [] + while len(seeds) < count: + name = f"{rng.choice(adjectives)}-{rng.choice(nouns)}" + if name in names: + name = f"{name}-{rng.randint(2, 99)}" + if name in names: + continue + names.add(name) + description = "" if rng.random() < 0.1 else f"{rng.choice(subjects)} {rng.choice(purposes)}.{rng.choice(tails)}" + seeds.append((name, description, {"README.md": f"# {name}\n\n{description}\n"}, "sha1")) + REPO_METADATA[name] = { + "language": rng.choice(languages), + "stars": rng.choice([rng.randint(0, 40)] * 8 + [rng.randint(40, 2000)] * 3 + [rng.randint(2000, 25000)]), + "issues": rng.randint(0, 40), + "forks": rng.randint(0, 200), + "size_kb": rng.randint(8, 50000), + "days_ago": rng.randint(0, 1500), + } + return seeds + + +SEED += _filler(93) + + def _iso_age(**kwargs) -> str: return (datetime.now(timezone.utc) - timedelta(**kwargs)).strftime("%Y-%m-%dT%H:%M:%SZ") diff --git a/web/package.json b/web/package.json index 337bed4fb..f4c1570b8 100644 --- a/web/package.json +++ b/web/package.json @@ -90,6 +90,7 @@ "d3-geo": "3.1.1", "d3-path": "3.1.0", "d3-shape": "3.2.0", + "fuse.js": "^7.5.0", "markdown-it": "^14.3.0", "markdown-it-anchor": "^9.2.1", "markdown-it-emoji": "^3.1.0", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index f1b0a297b..d424d2424 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: d3-shape: specifier: 3.2.0 version: 3.2.0 + fuse.js: + specifier: ^7.5.0 + version: 7.5.0 markdown-it: specifier: ^14.3.0 version: 14.3.0 @@ -2561,6 +2564,10 @@ packages: function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + fuse.js@7.5.0: + resolution: {integrity: sha512-sQtrEfA+ez/3G0cCZecF70oqpCRttCexYUG4mUrtWL49ULUzUyxokt5kyqwtKzj1270RaKih+hcP3qLcumccow==} + engines: {node: '>=10'} + glob-parent@6.0.2: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} @@ -5844,6 +5851,8 @@ snapshots: function-bind@1.1.2: {} + fuse.js@7.5.0: {} + glob-parent@6.0.2: dependencies: is-glob: 4.0.3 diff --git a/web/src/lib/components/import/GitHubRepoSelectStep.svelte b/web/src/lib/components/import/GitHubRepoSelectStep.svelte index a86cf671c..b79d30feb 100644 --- a/web/src/lib/components/import/GitHubRepoSelectStep.svelte +++ b/web/src/lib/components/import/GitHubRepoSelectStep.svelte @@ -1,14 +1,21 @@ + -