Scaffold the ERP sync
This chapter creates my-erp/, the workspace for the SAP-to-Dynamics sync. You add the
workers and triggers plugins and boot the stack under Aspire, so the rest of the track has
a running system to build on.
What you will build
my-erp/ on disk: a NetScript workspace with a Postgres database, the workers plugin at
plugins/workers/ (the background-job engine) and the triggers plugin at plugins/triggers/
(the ingress engine), all running under one aspire start, with the Aspire dashboard available at the URL Aspire prints.
Before you begin
You need:
- Deno 2.x on your
PATH. Check withdeno --version. - The Aspire CLI. Check with
aspire --version. Aspire provisions your database and cache locally, so you don't wire up Docker by hand. - Docker running, so Aspire can start the Postgres and Redis containers. Check with
docker info.
Install the NetScript CLI from JSR once, then confirm it:
deno install --global --allow-all --name netscript --minimum-dependency-age=0 jsr:@netscript/cli@0.0.9
netscript --help
The public command groups are agent, config, contract, db, deploy, generate, init, marketplace, plugin, service, tokens, ui:add, ui:init, ui:list, ui:remove and ui:update. If netscript is not found, add Deno's install directory to your PATH and open a new terminal.
Step 1 — Preview the scaffold with a dry run
--dry-run plans the scaffold and prints the file and directory totals per phase without writing
to disk:
netscript init my-erp --dry-run
The CLI rejects invalid option combinations here, such as an unknown --db engine, before any
files exist. A clean dry run means your flags are valid.
Step 2 — Create the workspace
Durable execution needs a database, so scaffold with Postgres, the recommended default. You can
swap postgres for mysql, mssql or sqlite and the rest of the track works the same; this
track uses postgres throughout:
netscript init my-erp --db postgres
cd my-erp
The CLI scaffolds my-erp/, formats the output with deno fmt, initializes a git repository and
prints a next steps summary for your options.
| Option | What it does |
|---|---|
| --db postgres | Scaffold a Postgres database workspace. Durable execution and queue persistence anchor on it. |
| --dry-run | Plan the scaffold and print totals without writing any files. |
| --no-aspire | Skip the Aspire orchestration files. Do NOT pass this — the rest of the track runs under Aspire. |
Step 3 — Add the workers plugin
Add the workers plugin with its sample jobs, which give you a working reference to read and adapt:
netscript plugin install worker --name workers --samples
The plugin lands at plugins/workers/, the config-referenced install location, and is
registered in netscript.config.ts (./plugins/workers/mod.ts) and appsettings.json. It ships
an API service and a separate background processor that drains the job queue.
Step 4 — Add the triggers plugin
Add the triggers plugin. Triggers are how NetScript receives events, including the file-watch trigger you build in chapter 2:
netscript plugin install trigger --name triggers --samples
The plugin lands at plugins/triggers/ and is registered in netscript.config.ts
(./plugins/triggers/mod.ts) and appsettings.json. Confirm both plugins registered:
netscript plugin list
You should see workers and triggers in the registry.
Step 5 — Bring up orchestration
Aspire provisions your database and cache and starts every process. You don't start containers by
hand, and Aspire must be running before any netscript db command (chapter 5 runs them; see also
Deploy locally with Aspire). Run it from the
aspire/ subfolder so the CLI sees apphost.mts:
cd aspire
aspire restore # once per machine: restores the Aspire SDK modules into .aspire/
aspire start # starts the AppHost and every declared resource
aspire start brings up Postgres, the Redis cache, the workers API and processor, and the
triggers API and processor, then prints the allocated URL for the
Aspire dashboard:
the URL Aspire prints
The dashboard's Resources tab is the authority for the port each resource bound. You installed
these plugins without --port, so their entries carry no HostPort, and Aspire allocates their
host ports at every start. Copy the workers-api and triggers-api endpoints from that tab now;
the rest of the track writes them as <workers-endpoint> and <triggers-endpoint>. Re-read them
after any restart.
Leave aspire start running in this terminal. It is your control plane for the rest of the track.
Verify your progress
-
In a second terminal, confirm both plugin APIs are alive:
Shellcurl <workers-endpoint>/health # workers API curl <triggers-endpoint>/health # triggers APIBoth should return a healthy JSON response.
-
Type-check the workspace from the project root:
Shelldeno task checkA clean check means the scaffold, both plugins and the database wiring line up.
- [ ]
my-erp/exists withplugins/workers/andplugins/triggers/on disk. - [ ]
netscript plugin listshows bothworkersandtriggers. - [ ]
aspire startis up; the dashboard at the URL Aspire prints listspostgres,redis, and both plugin APIs. - [ ]
curl <workers-endpoint>/healthandcurl <triggers-endpoint>/healthboth return healthy. - [ ]
deno task checkis clean.
What you built
my-erp/, with the workers and triggers plugins installed and the stack (Postgres, Redis,
both plugin APIs and their background processors) running under one aspire start. Next, you give
it the SAP export to ingest.