Repository navigation
feat(dev): prisma dev runs a service with its build adapter's dev server (ADR-0056) - #381
Conversation
…rves unassembled services ADR-0056. A build descriptor gains an optional serve step returning a DevServer (cwd, argv for a port and host, display). LowerOptions gains unassembled: those services are provisioned and serialized as always, but reserve() runs in place of package() and deploy(), so dependents get the same URL without an artifact. The local-target attachment gains serve() and logs() an addresses filter; a local node location may report the command it runs. Signed-off-by: Shane Neubauer <[email protected]>
…assembled
ADR-0056. assembleServices takes { devServers }. With it, each service build
descriptor is asked for a dev server first; a returned DevServer is recorded in
AssembledServices.devServers and the service gets no bundle and no assemble
events. A serve step that throws is DEV.DEV_SERVER_UNAVAILABLE with the address.
prisma deploy passes nothing and assembles every service as before.
Signed-off-by: Shane Neubauer <[email protected]>
ADR-0056. The Next.js descriptor serve step runs `next dev -p <port> -H <host>` in appDir, with the next binary resolved from the app own dependencies. It uses createRequire, because Node ignores import.meta.resolve parent argument without --experimental-import-meta-resolve and would resolve from this package install instead. node() gains an optional dev argv, run verbatim in the authoring module directory; an empty one is rejected when declared. Signed-off-by: Shane Neubauer <[email protected]>
ADR-0056. The deployment body gains a command form ({ cwd, argv }) beside the
artifact form; a body with both or neither is malformed. argv[0] is used when
absolute, else resolved on the deployment env PATH like bun. Change detection
compares the form, then the hash or cwd/argv, env and listens. A put now
answers 200 { started }, true only for a fresh start. The instance view
reports command. Readiness failures of a command add that a dev server must
listen on its PORT. Readiness, logs, supervision, stop and resume are shared.
Signed-off-by: Shane Neubauer <[email protected]>
ADR-0056. The stash, stashProviderParams and stashInput functions become one pure stashRows(node, address, env), which run() applies to process.env, so a dev server is started with exactly the rows run() writes. configKey and ORIGIN_KEY_NAME move to a leaf module so serializer.ts can import the reserved provider params without a TDZ import cycle. The compute descriptor gains reserve: deploy outputs and entity without the Deployment, the URL taken from the App. The local attachment gains serve, which materializes the deployment environment, stashes it, lays it over the shell environment and puts a command deployment on the instance; logs takes an addresses filter; a located service reports the command it runs. Signed-off-by: Shane Neubauer <[email protected]>
…r output ADR-0056. prisma dev asks build descriptors for dev servers; those services are announced (dev-server event), lowered unassembled, and served on their instance after the converge and the resume, and again after every successful reconverge, where a restart is reported (dev-server-restarted). A descriptor without reserve or an attachment without serve is DEV.DEV_SERVER_UNSUPPORTED before anything converges, so attachments are now made before the first converge. The foreground session follows the dev servers logs and emits each line (dev-server-output), rendered as [address] line. The entry and every service authoring module are watched, so a topology edit reconverges when every service runs a dev server. ServiceEndpoint gains devServer (the endpoint event data) and dev url gains runs. Signed-off-by: Shane Neubauer <[email protected]>
Signed-off-by: Shane Neubauer <[email protected]>
Running locally gains a Dev servers section: Next.js services run next dev with no build, node() services run their dev argv, output is streamed with the address prefix, the environment is the deployment one over the shell, and the gotcha that a secret only in a framework-loaded .env reaches the app as the local placeholder (load .env in prisma.config.ts instead). Getting started and the core-concepts skill mirror it. local-dev.md registers DEV.DEV_SERVER_UNAVAILABLE and DEV.DEV_SERVER_UNSUPPORTED and records that the session keeps the topology it started with. Signed-off-by: Shane Neubauer <[email protected]>
Replaces scripts/dev.ts, which ran next dev against in-memory fakes with pre-COMPOSER_ env names the storefront no longer reads. catalog, orders and promotions declare dev: [bun, --watch, server.ts] and the storefront runs next dev, so pnpm dev is prisma dev module.ts with nothing to build. Signed-off-by: Shane Neubauer <[email protected]>
|
✅ Gizmo reviewed 5e68e8a — posted 0 inline comment(s) this pass. Open findings: none Change walkthroughThis incremental delta touches only packages/0-framework/3-tooling/cli/src/dev/tests/watch.test.ts: the
In the context of the larger PR (ADR-0056: |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
… agrees Signed-off-by: Shane Neubauer <[email protected]>
commit: |
…s a drive letter Signed-off-by: Shane Neubauer <[email protected]>
The local-dev store integration proof (criterion 2) touches catalog dist and expects exactly that service to restart; with a dev command catalog no longer ran its artifact and the proof timed out. Catalog keeps the rebuild loop, orders, promotions and the storefront keep their dev servers, so the proof now also shows a rebuild does not restart dev servers. pnpm dev builds catalog first. Signed-off-by: Shane Neubauer <[email protected]>
Brings in ADR-0057 (#384): addresses start with the app name and COMPOSER_ keys normalise - to _. configKey moved to config-key.ts on this branch, so addressKeySegments moves there with it and serializer.ts re-exports both; stashRows keeps building keys through configKey and needs no other change. The dev-server tests use full addresses (shop.auth, hello-dev.app, fixture-module.web), and the stashRows test uses my-shop.web so it covers the - to _ rule. Signed-off-by: Shane Neubauer <[email protected]>
…R-0057) After the merge of #384 every address starts with the app name, so the front door, the dev-server lines and dev url read shop.web, not app. Signed-off-by: Shane Neubauer <[email protected]>
…rive letter Signed-off-by: Shane Neubauer <[email protected]>
Brings in dev servers (#381), full node addresses (#384, ADR-0057), the deploy entry in prisma.config.ts (#387) and prisma deploy list (#388). The secrets decision becomes ADR-0058, and every reference to it moves with it. A dev server gets its environment from materializeEnv, so it receives the same per-service secret values from process.env, an unset optional secret is absent, and a changed value restarts it; the serve test now covers both. The docs that described placeholders for dev servers now describe reading secrets before the dev server starts. Tests and expected error text use full addresses. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Linked issue
Implements ADR-0056 (#377).
Summary
Under
prisma dev, a Next.js service could only run its assembled standalone build. Every edit needednext buildand a reconverge, its logs never reached the terminal, and plainnext devcouldn't readservice.load()orservice.input(). Following ADR-0056, a service now runs the dev server its build adapter declares, on its own instance and port, with the environment a deployment would give it.nextjs()runsnext dev;node({ dev: [...] })runs the command the author wrote. There is no flag:prisma dev module.tsis the whole command.servestep, returning aDevServer.LowerOptions.unassembledlowers a service through a new optionalreservehook in place ofpackage+deploy.LocalTargetAttachmentgainsserve,logsgainsaddresses, andLocalNodeLocationgainscommand.assembleServices(…, { devServers }). A serve step that throws isDEV.DEV_SERVER_UNAVAILABLE.servesteps;node()gainsdev.{ command: { cwd, argv } }. A put answers{ started }, and the instance view reportscommand.stash/stashProviderParams/stashInputbecome one purestashRows, whichrun()applies, so a dev server gets exactly the rowsrun()writes. The compute descriptor gainsreserve, and the local attachment gainsserve.unassembled, and served after resume and after every reconverge (dev-server-restartedwhen the emulator restarts one). Their output is streamed as[address] line. The entry and authoring modules are watched.ServiceEndpoint.devServerandDevUrl.runsare new. A missingreserveorserveisDEV.DEV_SERVER_UNSUPPORTEDbefore anything converges.examples/storedropsscripts/dev.ts, which ran against in-memory fakes with env names the storefront no longer reads:pnpm devis nowprisma dev module.tswith nothing to build.Testing performed
pnpm typecheck,pnpm lint,pnpm lint:deps,pnpm lint:casts,lint:control-bytes,lint:retired-binary-name,scripts/check-skill-packaging.mjsand the website content tests all pass.unassembled/reserveassembleServices({ devServers })servestepsstashRowsserveagainst a real emulator: secret value, address-free stash, sibling rows hidden, shell env keptdev()operation tests: event order,unassembledin the stack file, serve after resume, output streaming, authoring-module reconverge + restart event, bothUNSUPPORTEDcases, start failure rollbackdev urlrunsinitdb: program "postgres" is needederrors come frompostgres-harness.tsbecause this machine has no systempostgresbinary. No named test fails.[email protected]Next.js app with packed 0.34.0 tarballs of this branch and[email protected]:prisma dev module.ts, with nonext build, runsnext devon the service URL./_next/hmrwebsocket opens on that URL.service.load().databaseis the local Postgres.envSecretfrom.envreachesservice.input(), once.envis loaded inprisma.config.ts(see notes).console.loglines appear as[app] ….--detachanddev stopleave no orphanednext/next-server, anddev url --jsonreports"runs":"dev-server".examples/store:pnpm devbrings up catalog, orders and promotions underbun --watchand the storefront undernext devwith no build; the storefront renders the Postgres-backed catalog over RPC.Checklist
git commit -s) per the DCO. The DCO status check will block merge if any commit is missing aSigned-off-by:trailer.feat,fix,chore,docs,refactor,test,build) — PR titles drive the auto-generated release notes.n/aif the change is doc-only / refactor with no behavioural delta).Notes for the reviewer
Where the code departs from the ADR's literal text:
next. The ADR saysimport.meta.resolve('next/package.json', pathToFileURL(appDir + '/')), but Node (24 and 26) ignores the parent argument without--experimental-import-meta-resolve. It would resolve from this package's install, not the app's.createRequire(appDir).resolve(...)does what the ADR intends.tail: 0. Otherwise Next's startup banner, which is written whiledevwaits for readiness, never shows, though the ADR's own example output shows it. The emulator clears the log on each fresh start, so the backlog is only the current process's output.configKey/ORIGIN_KEY_NAMEmoved to a leafconfig-key.ts, re-exported fromserializer.ts. HavingstashRowsinserializer.tsimportRESERVED_PROVIDER_PARAMSotherwise creates a TDZ import cycle, becauseorigin-key.tsandstreams-keys.tsuse those values at module load.node({ dev: [] })is rejected whennode()is called. Builds are not validated when the graph is loaded, so there was no load-time check to hook into.Known gaps:
.envand secrets. A secret that is only in a.envloaded by Next reaches the app aslocal-placeholder-…, because Composer sets the variable first and Next never overrides a set one. The guide documents the fix (process.loadEnvFile('.env')inprisma.config.ts). The create-prisma Next template doesn't do this today, so the template needs a follow-up.running-locally.mdLogs section will conflict trivially with theprisma dev logsPR (feat(cli): addprisma dev logsand point the dev front door at it #378), whichever merges second.