Repository navigation
luarocks install lapis-console 1.3.0A modernization release. The frontend has been rewritten on CodeMirror 6, the console now runs on Lua 5.1 through 5.4, and results are much more useful: return values, tracebacks, and timings.
Breaking changes
runhas a new signature. It now takes source code instead of a function:run(self, code, lang="moonscript"). It returns a result table{ lines, queries, returns, time, error, traceback }instead oflines, queries, and returnsnil, erronly when the code fails to compile. Queries are now{ query, duration }objects instead of strings. This only affects code callingrundirectly;console.makeis unchanged.- POST requests require a CSRF token. The console page embeds a token generated by
lapis.csrf, which is checked against a cookie when code is submitted. This stops other websites from submitting code to a console running on your machine. The token is signed with your app'ssecret. - Requires Lapis 1.7.0 or newer, for the cookie based
lapis.csrfAPI.
New
- Lua mode: choose MoonScript or Lua from the dropdown. Lua code previously passed validation but returned nothing.
- Lua 5.1 through 5.4 and LuaJIT are supported. Code is loaded with its environment instead of using
setfenv. - Return values are shown in the result. MoonScript returns its last expression, so
User\find 1works withoutprint. In Lua mode, usereturn. - Errors keep their output: anything printed before an error is still shown, along with a collapsible stack traceback.
- Timings: each result shows how long it took to run, and each query shows its duration when
measure_performanceis enabled. - History: each result shows the code that produced it; click it to load it back into the editor. Press up on the first line, or down on the last line, to browse previous runs, like a browser's developer console.
- Dark mode, applied automatically from the system color scheme.
- Table keys are sorted: array indexes first, then strings alphabetically.
- Cmd+Enter / Cmd+K on macOS, a Clear log button, and runs are ignored while one is in progress.
Fixed
- The query logger is restored when submitted code raises an error. Previously each error left another wrapper around
lapis.logging.query. - The console no longer changes the app's shared
cjsonencode_max_depthsetting. moonscriptis declared as a dependency, since the default MoonScript mode requires it.
Internal
- The frontend is plain JavaScript and CSS bundled with esbuild, replacing CoffeeScript, SCSS, jQuery 1.9, CodeMirror 3.1, and Tup. See the README for build instructions.
- Specs run with busted, and GitHub Actions tests Lua 5.1 through 5.4, LuaJIT, and OpenResty's LuaJIT, and checks that the committed generated files are up to date.
Full Changelog: v1.2.0...v1.3.0