Skip to main content

Module pack

Module pack 

Source
Expand description

Packs: folders of ordinary node files (planes, types, link types, rules) that can be added to a model.

A pack folder holds one pack node (the manifest) and the nodes it provides. Every provided node carries fields.pack: <name>@<version>, so once copied into a model it is still known to come from the pack. Adding is a copy with checks: required packs must be there, and a node that already exists is only replaced if it came from the same pack (an upgrade). Anything else is a conflict, and nothing is written.

The manifest kept in a model also records installed: a hash of every node as the pack provided it. That is what lets us tell a node you changed from one you did not, so an upgrade replaces what is untouched, keeps what you edited, and a removal does not throw your work away.

Structs§

Added
Pack
Problem
Something wrong, or worth a look, in a pack. error means it should not be shared as it is.
Removed
What remove did.
Status
What has become of an installed pack’s nodes.

Enums§

Clash
What to do when a pack defines a type or link type whose name the model already defines.

Functions§

add
Copy a single pack into a model whose requirements are already in place. See add_tree for the checks.
add_tree
Add name and everything it needs or includes to a model (see plan). Nothing is written unless every pack in the plan can go in: requirements met (at a version that satisfies the range), no namespace shared with a different pack, and no clash with something the pack does not own (unless force). Nodes you changed since an earlier version of the pack went in are kept, not overwritten (unless force). Returns what happened to each pack, in the order added.
add_tree_with
add_tree, with a choice for what to do when a type or link type name is already defined (see Clash).
export
Write a pack that was made in the model out to a pack folder <packs>/<name>/, so other models can add it: the manifest (without the install record) and every node that carries its tag. Returns the node count. The folder is checked as a pack before it replaces an earlier export.
installed
The packs a model already has, as (name, version), from its pack nodes.
lint
Check packs against each other and against what a pack is for:
list_packs
Every pack folder directly inside dir, by name.
node_hash
A hash of what a node says, not how its file is laid out: reformatting a file does not change it.
pack_from_texts
Build a pack from (file stem, file text) pairs; label names it in errors. Folders and the copy in the binary both come here.
plan
The packs to add for name, dependencies first: its requires, then the pack itself, then its includes. only limits which of the root’s children come along (a collection lets you pick); None takes them all.
read_pack
Read one pack folder and check it hangs together.
remove
Take a pack out of a model: its manifest and every node it provided. Refused (nothing is deleted) while another pack in the model requires it, while nodes of yours link to, sit under or are placed on its nodes, or while you have changed some of its nodes; force deletes anyway.
satisfies
Does version satisfy range? A range is one or more space-separated comparators, all of which must hold: ^1.2.3 (compatible: below the next major, or next minor while major is 0), ~1.2.3 (below the next minor), >=, >, <=, <, = or a bare 1.2.3 (exact). Empty or * accepts anything, even a version that is not x.y.z.
status
For every pack in the model: which of its nodes you have changed or deleted. Needs no copy of the pack, because the manifest remembers what it installed. A pack installed before hashes were recorded reports everything clean.
valid_namespace
Lower-case letters and digits in words joined by single dashes: it sits before the -- in every id.