Skip to main content

Where the server looks

A schema usually belongs to the tool that reads the scripts. The tool then brings it, through its plugin of Gradle or Maven or in its npm package, and a project that uses the tool has nothing to write.

The order​

The server looks from the folder of the script upwards. A schema in a .dsl folder, in any folder above the script, goes before every other, so a project can always put its own in the place of the one a tool brings. When there is none, each folder from that of the script upwards is tried for:

  1. build/dsl/<name>.json, where a plugin of Gradle writes the schema of its DSL.
  2. target/dsl/<name>.json, where a plugin of Maven does.
  3. The schema of an npm package, when the folder has a package.json.
my-project/
build/dsl/byterails.json written by the Gradle plugin of byterails, or
target/dsl/byterails.json by its Maven plugin
package.json "devDependencies": { "some-tool": "^1.0.0" }
node_modules/some-tool/.dsl/sometool.json comes with the package
byterails.dsl
sometool.dsl

Many scripts, one schema​

A DSL with many scripts gives each a name of its own and puts its kind before the extension: shop.intent.dsl, billing.intent.dsl. Such a script takes the schema of its own name, shop.intent.json, when there is one in any of the places above. When there is none it takes the schema of its kind, intent.json, looked for in the same order.

my-project/
.dsl/intent.json the schema of every *.intent.dsl
shop.intent.dsl
billing.intent.dsl

A plugin of Gradle or Maven​

A plugin writes the schema when it runs, so a script is checked against it once the build has run, or once the IDE has imported it when the plugin writes at that moment. The build folder is not in version control, and after a clean the schema is back with the next build.

An npm package​

An npm package puts its schemas in a .dsl folder at its root, and lists that folder in files if its package.json has that list. The server reads the dependencies, devDependencies, optionalDependencies and peerDependencies of the package.json and looks for each of those packages in node_modules as Node.js does: in the folder of the package.json and then in the folders above it, which is where a workspace installs them. So:

  • Only a package the project depends on itself is looked at, not what that package depends on.
  • When two packages have a schema of the same name, the script gets a warning that names both and is checked for syntax errors only. A schema in a .dsl folder of the project says which one it is.
  • An install without node_modules, such as Yarn Plug'n'Play, is not read.

When a schema is read​

The server reads the schema when a script is opened, and again when a schema, a package.json or the lock file of npm, pnpm or Yarn changes on disk, if the editor watches files for the server (VS Code does), or else when a script is saved.