You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
Generate playground command list from coreutils feat_wasm
Previously the list of WASM-bundled utilities was hardcoded in wasm-terminal.js and playground.md, which drifted from the actual feat_wasm feature in coreutils/Cargo.toml (e.g. dd, tty, yes were missing). The website workflow now parses feat_wasm at build time and emits static/wasm/commands.js, which the terminal prefers over its built-in fallback list.
This commit is contained in:
@@ -138,6 +138,14 @@ jobs:
|
|||||||
echo "const WASM_LOCALES = [$(echo "$locales" | sed 's/[^,]*/\"&\"/g')];" \
|
echo "const WASM_LOCALES = [$(echo "$locales" | sed 's/[^,]*/\"&\"/g')];" \
|
||||||
> ../uutils.github.io/static/wasm/locales.js
|
> ../uutils.github.io/static/wasm/locales.js
|
||||||
echo "Available locales: $locales"
|
echo "Available locales: $locales"
|
||||||
|
# Generate the list of available commands from the feat_wasm feature
|
||||||
|
# in Cargo.toml so the playground stays in sync with the WASM build.
|
||||||
|
commands=$(sed -n '/^feat_wasm = \[/,/^\]/p' Cargo.toml \
|
||||||
|
| grep -oE '"[a-zA-Z0-9_]+"' | tr -d '"' \
|
||||||
|
| sort -u | paste -sd, -)
|
||||||
|
echo "const WASM_COMMANDS = [$(echo "$commands" | sed 's/[^,]*/\"&\"/g')];" \
|
||||||
|
> ../uutils.github.io/static/wasm/commands.js
|
||||||
|
echo "Available commands: $commands"
|
||||||
# Record the coreutils commit used to build the WASM binary
|
# Record the coreutils commit used to build the WASM binary
|
||||||
commit_hash=$(git rev-parse HEAD)
|
commit_hash=$(git rev-parse HEAD)
|
||||||
commit_short=$(git rev-parse --short HEAD)
|
commit_short=$(git rev-parse --short HEAD)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ template = "page.html"
|
|||||||
|
|
||||||
<script src="/wasm/locales.js" defer></script>
|
<script src="/wasm/locales.js" defer></script>
|
||||||
<script src="/wasm/version.js" defer></script>
|
<script src="/wasm/version.js" defer></script>
|
||||||
|
<script src="/wasm/commands.js" defer></script>
|
||||||
<script src="/js/wasm-terminal.js" defer></script>
|
<script src="/js/wasm-terminal.js" defer></script>
|
||||||
<script defer>
|
<script defer>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
@@ -104,7 +105,7 @@ Multiple commands can be separated by newlines (`%0A` in the URL):
|
|||||||
The following commands run as **real Rust coreutils compiled to WebAssembly**:
|
The following commands run as **real Rust coreutils compiled to WebAssembly**:
|
||||||
|
|
||||||
`arch` `b2sum` `base32` `base64` `basenc` `basename` `cat` `cksum`
|
`arch` `b2sum` `base32` `base64` `basenc` `basename` `cat` `cksum`
|
||||||
`comm` `cp` `csplit` `cut` `date` `dir` `dircolors` `dirname`
|
`comm` `cp` `csplit` `cut` `date` `dd` `dir` `dircolors` `dirname`
|
||||||
`echo` `expand` `expr` `factor` `false` `fmt` `fold` `head`
|
`echo` `expand` `expr` `factor` `false` `fmt` `fold` `head`
|
||||||
`join` `link` `ln` `ls` `md5sum` `mkdir` `mv` `nl` `nproc` `numfmt`
|
`join` `link` `ln` `ls` `md5sum` `mkdir` `mv` `nl` `nproc` `numfmt`
|
||||||
`od` `paste` `pathchk` `printenv` `printf` `pr` `ptx` `pwd`
|
`od` `paste` `pathchk` `printenv` `printf` `pr` `ptx` `pwd`
|
||||||
|
|||||||
@@ -33,10 +33,13 @@ const SAMPLE_FILES = {
|
|||||||
"words.txt": "hello world\nfoo bar baz\nthe quick brown fox\njumps over the lazy dog\n",
|
"words.txt": "hello world\nfoo bar baz\nthe quick brown fox\njumps over the lazy dog\n",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Commands available in the feat_wasm build
|
// Commands available in the feat_wasm build.
|
||||||
const AVAILABLE_COMMANDS = [
|
// The workflow generates /wasm/commands.js from coreutils' Cargo.toml feat_wasm
|
||||||
|
// list and exposes it as `WASM_COMMANDS`. The hardcoded list below is a fallback
|
||||||
|
// for local dev or when the generated file isn't available.
|
||||||
|
const FALLBACK_COMMANDS = [
|
||||||
"arch", "b2sum", "base32", "base64", "basenc", "basename", "cat", "cksum",
|
"arch", "b2sum", "base32", "base64", "basenc", "basename", "cat", "cksum",
|
||||||
"comm", "cp", "csplit", "cut", "date", "dir", "dircolors", "dirname",
|
"comm", "cp", "csplit", "cut", "date", "dd", "dir", "dircolors", "dirname",
|
||||||
"echo", "expand", "expr", "factor", "false", "fmt", "fold", "head",
|
"echo", "expand", "expr", "factor", "false", "fmt", "fold", "head",
|
||||||
"join", "link", "ln", "ls", "md5sum", "mkdir", "mv", "nl", "numfmt",
|
"join", "link", "ln", "ls", "md5sum", "mkdir", "mv", "nl", "numfmt",
|
||||||
"nproc", "od", "paste", "pathchk", "printenv", "printf", "pr", "ptx", "pwd",
|
"nproc", "od", "paste", "pathchk", "printenv", "printf", "pr", "ptx", "pwd",
|
||||||
@@ -46,6 +49,10 @@ const AVAILABLE_COMMANDS = [
|
|||||||
"shred", "shuf", "sleep", "sum", "tee", "true", "truncate",
|
"shred", "shuf", "sleep", "sum", "tee", "true", "truncate",
|
||||||
"uname", "unexpand", "uniq", "unlink", "vdir", "wc",
|
"uname", "unexpand", "uniq", "unlink", "vdir", "wc",
|
||||||
];
|
];
|
||||||
|
const AVAILABLE_COMMANDS =
|
||||||
|
(typeof WASM_COMMANDS !== "undefined" && Array.isArray(WASM_COMMANDS) && WASM_COMMANDS.length > 0)
|
||||||
|
? WASM_COMMANDS
|
||||||
|
: FALLBACK_COMMANDS;
|
||||||
|
|
||||||
// Shortcut mappings for locale command (e.g. "fr" -> "fr-FR")
|
// Shortcut mappings for locale command (e.g. "fr" -> "fr-FR")
|
||||||
const LOCALE_SHORTCUTS = {
|
const LOCALE_SHORTCUTS = {
|
||||||
|
|||||||
Reference in New Issue
Block a user