[data-reveal]{opacity:1!important;transform:none!important}
DocumentationProject module commands

Project module commands

Reference for the ajs project modules commands that add, remove, list, update and install the modules of a project, and for the module locks that pin their dependencies.

Overview

The ajs project modules command group edits the modules of antelope.config.ts and downloads them. Every command of the group accepts the global options and the -p, --project and -e, --env options that Project commands describes.

The commands that write antelope.config.ts edit only the values they change, in place. Imports, constants, process.env reads, calls such as resolve(__dirname, ...), comments and formatting stay as you wrote them. A command changes a value only when the file holds it as a plain literal, such as a string, a number or an object of literals. When the value is an expression, such as version: CORE_VERSION, the command fails, names the value and the edit to make by hand, and leaves the file unchanged. ajs project logging set writes the file the same way.

Module management

These subcommands add, remove, list and update the modules of a project, and add the modules that its unresolved interfaces need.

ajs project modules add

Add one or more modules to the project configuration and download them.

terminal
ajs project modules add <modules...> [options]
ArgumentDescription
modulesnpm packages, repository URLs or paths, depending on --mode
OptionDescription
-m, --mode <mode>Source of the modules: package, git, local or dir (default: package)
-p, --project <path>Path of the project folder (default: current directory)
-e, --env <environment>Environment of antelope.config.ts to add the modules to
ModeArgumentListed as
packageAn npm package name, optionally with a version, range or dist-tagnpm
gitA repository URLgit
localThe folder of one module, with a package.jsonlocal
dirA folder whose every subfolder is a modulefolder

The last column is the source that ajs project modules list shows for the module.

In package mode, give a module as <name> or <name>@<spec>. The spec is an exact version, a semver range or a dist-tag. Without a spec, the command writes the latest published version as a caret range (^1.3.2), so the module follows new minor and patch releases. To pin the module, pass an exact version. The command rejects an invalid spec at once, and it does not add a module whose download fails.

In local mode, the module is added under the name of its package.json. When that package.json has no name, the folder name is used instead.

Examples:

terminal
# Add the latest version of an npm package (writes a ^ range)
ajs project modules add @antelopejs/api

# Pin an exact version
ajs project modules add @antelopejs/[email protected]

# Use a semver range or a dist-tag
ajs project modules add @antelopejs/api@~1.3.0
ajs project modules add @antelopejs/api@next

# Add a module from a local folder
ajs project modules add ./modules/auth --mode local

# Add several npm modules at once
ajs project modules add @antelopejs/api @antelopejs/mongodb
text
✔ Added @antelopejs/api 1.3.2 5.0s
1 module added to antelope.config.ts · 5.2s

Next steps
  ajs project modules install  resolve the interfaces they need

ajs project modules remove

Remove one or more modules from the project. The alias is rm.

terminal
ajs project modules remove <modules...> [options]
ajs project modules rm <modules...> [options]
ArgumentDescription
modulesNames of the modules to remove
OptionDescription
-p, --project <path>Path of the project folder (default: current directory)
-e, --env <environment>Environment of antelope.config.ts to remove them from
-f, --forceRemove the modules found even if some names are unknown

Without --force, the command removes nothing when one of the names is not in the configuration.

Example:

terminal
ajs project modules remove @antelopejs/api --force

ajs project modules list

List the modules of the project. The alias is ls.

terminal
ajs project modules list [options]
ajs project modules ls [options]
OptionDescription
-p, --project <path>Path of the project folder (default: current directory)
-e, --env <environment>Environment of antelope.config.ts to list
-j, --jsonPrint the result as JSON on stdout

The command prints a table of the modules with their name, source (npm, git, local or folder) and reference (version, repository or path). On a narrow terminal, an ellipsis cuts long references. On a terminal too narrow even for that, each module is a block of NAME, SOURCE and REFERENCE lines. When stdout is piped, each module is one tab-separated line without a header. With --json, the command prints an array of { "name", "source" } objects, where source is the module source as configured.

Examples:

terminal
ajs project modules list

# Print the module names only
ajs project modules list | cut -f1
text
ℹ 3 modules in acme-shop (default)
NAME                  SOURCE  REFERENCE
@antelopejs/api       npm     1.0.0
@antelopejs/auth-jwt  npm     ^1.0.0
billing               local   modules/billing

ajs project modules update

Check npm for newer versions of the npm modules of the project and write them to the project configuration. Without arguments, the command updates every npm module. To update only some modules, pass their names. The command leaves modules from git or local folders as they are.

An exact version moves to the newest release. A ^ or ~ range stays as it is when the newest release satisfies it, and moves to the newest release when it does not: ^1.5.0 stays while 1.6.0 is the newest, and becomes ^2.0.0 once 2.0.0 is out. Any other range keeps the bound the configuration gives: >=0.20.2 <0.21.0 and the partial 1.2 stay, and the lock records the newest release it accepts. To leave such a range, edit it in antelope.config.ts.

The command also resolves the dependencies of each updated module again, without its lock, and writes the new lockfile to antelope-lock/. It does so even when the version of the module does not change, which is how a dependency fix reaches a project. It then removes the locks that no environment uses. --dry-run changes no lock.

Then, unless --dry-run is set, the command checks the interface packages of the environment as install does. Interface version check describes the check and --fix.

text
✔ antelope-lock/@antelopejs/[email protected] changed
✔ antelope-lock/@antelopejs/[email protected] added
✔ Removed antelope-lock/@antelopejs/[email protected]: no environment uses it
terminal
ajs project modules update [modules...] [options]
ArgumentDescription
modulesModules to update (default: every npm module)
OptionDescription
-p, --project <path>Path of the project folder (default: current directory)
-e, --env <environment>Environment of antelope.config.ts to update
--dry-runShow the updates without applying them
--fixApply the interface package bumps the check finds

Examples:

terminal
# Update all npm modules
ajs project modules update

# Preview updates without applying
ajs project modules update --dry-run

# Update a specific module
ajs project modules update @antelopejs/api

ajs project modules install

Find the interfaces that the modules of the project import but no module implements, and add a module from the interface repository that implements each of them. The command does not install npm dependencies, whatever its name suggests. It completes the module set of the project.

terminal
ajs project modules install [options]
OptionDescription
-p, --project <path>Path of the project folder (default: current directory)
-e, --env <environment>Environment of antelope.config.ts to complete
-g, --git <url>Interface repository URL, overriding the git CLI setting (ajs config get git)
-y, --yesAdd the first module listed when several implement an interface
--fixApply the interface package bumps the check finds

Examples:

terminal
ajs project modules install

# In CI: never prompt, take the first implementation when there is a choice
ajs project modules install --yes
Note

install looks in your modules for interface imports that no module in the project implements. It then looks up the modules that implement them in the interface repository and adds them. When a single module implements an interface, the command adds it without a question. When several modules implement it, the command asks which one to add. Without a terminal, it exits with code 2 and asks for --yes instead.

After it adds the modules, the command runs the interface version check on each analyzed environment. It prints its summary of the added modules first, without the next steps when the check fails, and the modules stay in antelope.config.ts.

ajs project modules release-leases

Delete the leases of runs that are gone.

terminal
ajs project modules release-leases [options]
OptionDescription
-p, --project <path>Path of the project folder (default: current directory)
-e, --env <environment>Environment of antelope.config.ts whose cacheFolder to read
--foreignAlso delete the leases of runs on other hosts or in other pid namespaces
-y, --yesDelete the foreign leases without a confirmation

The command lists every lease of the module cache: its file, whether its run is running, has exited or is foreign, the host, pid namespace and pid of that run, and the folders the lease keeps. It deletes the leases of runs of this host and pid namespace that have exited, and prints each lease it removes. A prune deletes those leases too.

It deletes a foreign lease only with --foreign, since it cannot tell whether that run still uses the cache. It then asks for a confirmation. Without a terminal, it exits with code 2 and asks for --yes instead. It never deletes the lease of a running run. No age limit applies to any lease, since the clock of another host cannot be trusted.

Examples:

terminal
ajs project modules release-leases

# After a container run was killed, and in CI
ajs project modules release-leases --foreign --yes

Interface version check

Modules share one copy of each interface package. install and update load the modules of the environment as ajs project build does and look, for each interface package, for the highest installed copy that every module's range accepts. When the copy a launch would share is older than that version, the command exits with code 1 and names the change each module needs:

text
✖ Interface packages need a newer copy
  mongodb installs @antelopejs/interface-database 0.3.0; resolving its dependencies again gives 0.3.1, required by [email protected]
  → Run ajs project modules install --fix to apply the changes
  → Or run ajs project modules update mongodb
  • A local module of the project that holds an older copy gets a raised floor in its package.json, such as ^0.1.8 → ^0.1.9. @antelopejs/interface-core is raised at most to the copy of the running @antelopejs/core, the copy every module loads. A range keeps its shape: >=0.3.0 <0.4.0 becomes >=0.3.1 <0.4.0. A prerelease target is pinned exactly instead: ^0.4.3 becomes 0.4.4-next.121.g5d83533. A spec without a floor, such as an npm: alias, a workspace: or file: link or a dist-tag, is left as it is.
  • A local module whose folder lies under node_modules, such as ./node_modules/@antelopejs/file-storage-local, belongs to a dependency of the project, and the next install of the project overwrites its package.json. The command names that dependency instead: raise it in the project's package.json to a release that depends on the newer copy. --fix leaves it alone.
  • An npm module whose older copy is the shared one resolves its dependencies again, as ajs project modules update <module> does, which writes a new lock to antelope-lock/.
  • Other npm modules keep their own copy. A launch redirects them to the shared one.

--fix applies these changes, installs the dependencies of each local module it edits, and checks again. A local module that a pnpm workspace lists in its pnpm-workspace.yaml is installed through that workspace, so its workspace: dependencies resolve; any other local module is installed alone. When only a local module of the project holds an older copy and the launch would still work, the command prints the same lines as a warning and exits with code 0: the runtime uses the shared copy while TypeScript compiled the module against its own. When no installed copy satisfies every range, the command prints the Incompatible interface package resolution error with each module, its range and the shared version.

For an interface that no module implements, the shared copy is the highest installed copy that every module's range accepts, whatever the order of the modules in antelope.config.ts.


Module cache

ajs project dev, ajs project run and ajs project build remove the cached module folders that no live run, build or pin keeps. Module cache describes the rule, the leases and locks behind it, and how to turn it off.



Module locks

An npm module installs its own dependencies in .antelope/cache/<package>@<version>, from the ranges in its package.json. Pinning the version of the module in antelope.config.ts does not pin those dependencies, so the same commit built on two different days can install two different sets of versions.

The first time the core installs an npm module, it records in the project the lockfile that the package manager of the module wrote:

text
antelope-lock/
├── @antelopejs/[email protected]/pnpm-lock.yaml
└── @antelopejs/[email protected]/package-lock.json

Commit antelope-lock/ with antelope.config.ts. From then on, build, dev, and modules add|install install each module from its lock, with the frozen install of its package manager (pnpm install --frozen-lockfile or npm ci). The core installs a cached module again when another lockfile installed it. A locked range such as ^1.5.0 stays on its recorded version until ajs project modules update. Each version has its own lock, so environments that pin different versions of a module get one lock each, whichever --env you build.

In CI and image builds, pass --frozen-modules to ajs project build. The build then fails on an npm module without a lock, an optional module included, instead of resolving its dependencies on the day of the build. It writes nothing in antelope-lock/.

ajs project start and the embedded runtime only replay the locks. A module loaded while the project runs installs from its lock when it has one, and nothing at run time writes in antelope-lock/.

terminal
ajs project build -e production --frozen-modules
text
✖ No module lock for @antelopejs/[email protected]
  --frozen-modules installs only from antelope-lock/@antelopejs/[email protected], and the project has none.
  → Run ajs project build without --frozen-modules (or ajs project modules update @antelopejs/api) and commit the lock it writes

Git and local modules have no lock. They install from their own working tree and lockfile.

A dist-tag such as latest has no lock of its own. The registry resolves it to a version on every install, and each version it resolves to gets its own lock. ajs project modules update resolves every npm module it selects again, whether or not a newer version exists. It records the lockfiles that result and removes the locks that no environment uses. Review the diff of antelope-lock/ as you would review a dependency bump.