v0.2.8
Add the application REPL
@adonisjs/core/repl had no counterpart. Same shape and same names:
addMethod / getMethods / ready / notify / useCompiler / start,
the chainable ones chainable.
node:repl is the prompt. What this adds is what makes it an
APPLICATION repl: a context seeded with the booted services, helpers a
project registers itself, and .ls to list them — a prompt full of
undiscoverable helpers is a prompt nobody uses. The listing aligns the
names into a column, which is why the width is recorded when a helper is
registered rather than measured again at print time.
useCompiler takes the host's compiler rather than ream carrying one:
node:repl evaluates JavaScript, a TypeScript project wants to paste
TypeScript, and the host already runs a compiler for its own code.
Helpers are bound to the context BEFORE the prompt appears. One that
only exists after the first keystroke is one the user finds missing.
describeMethods is public because it IS .ls, and a caller driving the
repl programmatically — a test, a custom command — needs the same
listing without a live prompt.
Add the dumper and dd()
@adonisjs/core/dumper and services/dumper had no counterpart here,
so inspecting a value mid-request meant console.log and reading a
truncated [Object].
Same shape: configureAnsiOutput / configureHtmlOutput chainable,
dumpToAnsi, dumpToHtml, getHeadElements(cspNonce), and dd(value)
from the service.
The rendering is node:util's inspect, not a dependency. It already
knows depth limits, circular references, getters, Maps, Sets and typed
arrays, and colours for a terminal — which is the whole ANSI side. The
HTML side escapes that same output rather than growing a second
formatter, so the two cannot describe a value differently.
Two decisions the tests pin:
Long strings and arrays are NOT truncated. Their length is usually why
someone is dumping, and […200 more items] defeats the call.
The HTML output is escaped. A dumped value is by definition data someone
else may control, and a dump is reached for while debugging — exactly
when a script tag in a field name is least expected. getHeadElements
takes a CSP nonce for the same reason renderPage does: a page on a
nonce policy drops an unattributed inline <style>, and a dump that
lands unstyled is worse than none.
Add the HTTP and boot debug channels
AdonisJS traces its own plumbing through util.debuglog, off unless
NODE_DEBUG names the channel: adonisjs:http reports route matching,
middleware execution and response generation, adonisjs:core the boot.
ream had one channel, ream:health, and nothing for HTTP — so seeing
why a request took the route it did meant adding print statements.
NODE_DEBUG=ream:http ream serve
reports the matched route (by name when it has one), each middleware as
it runs with its position in the stack, and the status with the
correlation id.
To be clear about what this is NOT: neither framework logs successful
requests to the TTY by default, and this does not change that. A
production request log belongs to ctx.logger, which is
correlation-scoped and structured. This is the switch for when the
plumbing itself is what you need to see.
Every per-request probe is behind .enabled, because the arguments cost
something to build — the response probe reads the status and the
correlation id. An inactive debuglog is a no-op, so a probe with cheap
arguments needs no guard.
Changes since v0.2.7.