Work on several packages together
Keep related packages in one folder with a workspace.kdl, and each one
uses the others as they are on your disk.
Declare the workspace
A workspace.kdl at the top of the folder lists its members, the
packages you develop together. Only the folders it lists are members:
workspace {
member "words"
member "hello"
}
A member can also be a pattern: member "apps/*" takes every folder
directly under apps/ that holds a package.kdl.
Use one member from another
Here words is an asset pack of names, and hello an app that reads
them. The app lists the asset pack with workspace=#true, which takes it
from the workspace rather than from a release:
name "@me/words"
version "0.1.0"
api_version "*"
kind "asset_pack"
license "0BSD"
name
Ada
Grace
name "@me/hello"
version "0.1.0"
api_version "*"
kind "app"
license "0BSD"
requires {
package "@me/words" workspace=#true
}
local dir = datumhue.package:dir()
local names = dir:read("deps/@me/words/assets/names.csv")
print(names:text())
In this example: datumhue.package Package:dir Dir:read Bytes:text
Run the app, or check it, from the workspace's folder. Each finds
@me/words in the workspace, and a change to a member shows on the next
run:
$ datumhue pkg check hello
$ datumhue run hello
A library member works the same way: the app loads it with
require("@me/greeter")
(Modules and dependencies).
Publish the workspace
datumhue pkg update --workspace refreshes every member's lock file in
one pass. datumhue pkg push --workspace publishes the members in the
order they depend on each other, a library before the app that uses it,
so each published package pins the published content of its
dependencies. Publishing writes each workspace dependency as a version
range from the member's version at the time.
$ datumhue pkg update --workspace
$ datumhue pkg push --workspace --dry-run
$ datumhue pkg push --workspace
--dry-run prints the order without publishing anything. A member
already published at its version is skipped, so running the push again
after a failure carries on where it stopped. A namespace line inside
the workspace block names the namespace members publish to, and
namespace= on a member line overrides it for that member. Running
pkg update or pkg push on one member uses the same namespace.
See also
Reference used on this page: datumhue.package Package:dir Dir:read Bytes:text