Many of the sample Origami projects like the language tutorial and the minimal starter project contain npm start
and run
commands that invoke the ori CLI using stock “incantations”. This page explains how those incantations work.
Starting an Origami server with debugging
The npm run start
command for most Origami sample projects will issue the following command:
ori serve watch src, =debug src/site.ori
The purpose of the incantation is to serve the site.ori
file locally, reloading the file if it or anything else in the src
folder changes.
- The expression omits parentheses to avoid needing to quote them.
- The
=
is a shorthand for an unnamed function call that could also be written as() =>
. - So the incantation could also be rewritten with explicit parentheses and the longer function syntax
ori "serve(watch(src, () => debug(src/site.ori)))"
. - The
debug
call wraps the virtual tree defined insrc/site.ori
a tree that adds various values of interest while debugging. - The
watch
function here monitors thesrc
folder for changes. The result of thewatch
call is a tree that delegates calls to the result of calling the second argument (the function) — with the additional behavior that, if anything changes in the monitored folder, the function will be re-evaluated to get a new tree; the initial treewatch
returned will now delegate calls to the new tree. - The
serve
function serves the result ofwatch
, which in turn is the tree in the latestsite.ori
plus debugging features.
Building a site as static files
The npm run build
command for most Origami sample projects will issue this command:
ori copy src/site.ori, clear files:build
This copies the virtual tree of files in site.ori
into the local build
folder, creating build
and cleaning out any existing contents as necessary.
- As above, this expression omits parentheses. Adding them:
ori copy(src/site.ori, clear(files:build))
. - The
files:
protocol finds the localbuild
folder and returns it as a tree. If this folder doesn’t exist, then the first attempt to write to the tree will create thebuild
folder. - The
clean
call deletes any existing files inbuild
. - The
copy
call copies the virtual tree insrc/site.ori
to thebuild
folder, thereby creating the static files necessary to deploy the site.