Change an app while it runs
matterdata dev serves one application on your computer. It watches the application directory.
When you save a file, it compiles the application and applies the change to the running tenant. You
do not stop the server and you do not install again.
1. Start it
Section titled “1. Start it”Give the command the application directory:
matterdata dev dsl/examples/expensesIf the tenant does not exist, dev creates it from the application and loads the files of
seed/. It prints the address and a login that holds every role of the application:
dev tenant "expenses" at http://expenses.localhost:8080/ sign in as dev@expenses.example password dev-password (dept_head, employee, finance)Use a browser on the same computer. *.localhost always points to your computer.
| Flag | Effect |
|---|---|
-tenant <name> |
The tenant name. The default is the name of the directory. |
-dir <dir> |
The directory of the tenant file. The default is .matterdata-dev. Keep it outside the application directory. |
-addr <host:port> |
The address. The default is 127.0.0.1:8080. dev accepts only a loopback address. |
-login <email>:<password>[:<roles>] |
A login of a new tenant. Repeat the flag for more logins. The first login is the tenant administrator. A login with no roles holds every role of the application. |
-reset |
Delete the tenant and create it again from the application. The data is lost. |
dev runs like serve -dev: the cookies have no Secure flag, and dev() is true. See
Show a page only in development.
2. Edit and save
Section titled “2. Edit and save”dev checks the .mtd files, the .ts hook modules and seed/*.csv every 500 ms. It waits 200 ms
after the last change, then it:
- compiles the application and prints each error as
file:line:column; - runs the whole migration on a copy of the tenant file and deletes the copy;
- applies the change, and prints one line.
dev: deployed expenses: 1 step (add_column claims.note), model v1 -> v2; window 12 ms; digest 47afc2f085068affA change is served within two seconds of the save. The window is the time that a request waited, in milliseconds.
When the application has a tsconfig.json, a tsc is found, and .matterdata/sdk.d.ts exists,
dev also runs the type check of the hooks in the background after each save. It does not wait
for it. The errors appear later as warnings, and they never block a deploy. When the check cannot
run, dev says why once. See
Write a hook in TypeScript with types. dev
also brings an existing .matterdata/sdk.d.ts up to date with the schema, and never creates it.
If the application does not compile, dev deploys nothing. The tenant keeps the last good
version. Fix the file and save again.
3. A change that dev refuses
Section titled “3. A change that dev refuses”dev does not delete data and does not leave a new column empty on rows that exist, unless you allow
it. It prints the refusal, and the refusal names the flag:
dev: refused; nothing was applied and expenses keeps serving its last model: - drop_column expenses.claims.note destroys data … Pass -allow-destructive expenses.claims.note …Do one of these:
- Stop
devand start it again with the flag, for example-allow-destructive expenses.claims.note. The other flags are-allow-policyand-accept-null. They have the same meaning as formatterdata upgrade. - Start
devwith-reset.
What dev does not do
Section titled “What dev does not do”- A changed file in
seed/is checked and not loaded, because the tenant already holds rows. Use-resetto load it. devshows the errors in the terminal only. The browser does not show them.devis not for a tenant with data that you need. To change an application on a server that is serving, usematterdata deploy. To move a stopped node to a new engine version, usematterdata upgrade.