FullStacked

packages

import packages from "fullstacked/packages";

An npm-compatible package installer written in Go, inside the core. It reads and writes package.json and package-lock.json, and lays out node_modules the way npm does, following npm’s own reify step (arborist). It needs no Node or npm on the device. In the app, the shell’s npm install and packages install commands use it.

install

install(directory: string, saveDev: boolean, ...packages: string[]): Promise<EventEmitter<{ progress: Progress }>>
const progress = await packages.install("/my-app", false, "react", "react-dom");
progress.on("progress", (p) => {
    if (p.stage === "Extracting")
        console.log(p.name, p.version, Math.round(p.progress * 100) + "%");
    if (p.stage === "Done") console.log(`${p.progress} packages`);
});
type Progress = {
    stage: string; // see below
    name?: string;
    version?: string;
    progress?: number; // 0..1 while extracting; the number of packages downloaded on Done
    error?: string;
};
Stage Meaning
Initialization Reading package.json
Verifying Lockfile Installing straight from package-lock.json (no names given and a lockfile exists)
Resolving Fetching metadata and resolving the tree
Extracting Downloading and extracting one package (name, version, progress)
Finalizing Writing package-lock.json and node_modules/.package-lock.json
Done Finished. The stream ends.
Error The stream fails with error

Behavior

uninstall

uninstall(directory: string, ...packages: string[]): Promise<EventEmitter<{ progress: Progress }>>

Removes the names from dependencies and devDependencies, deletes them from node_modules, and reconciles the rest of the tree (the stage is Uninstalling, then the install stages).

audit

audit(directory: string): Promise<any>

Posts the installed versions from package-lock.json to npm’s bulk advisory endpoint (/-/npm/v1/security/advisories/bulk) and resolves with the report, keyed by package name. It fails if there’s no package-lock.json.

resolve

resolve(moduleName: string, startDir?: string): Promise<string>

Node-style module resolution. A relative or absolute spec is tried as a file (as is, then with .ts, .tsx, .js, .json, .node) and as a directory (package.json main, a string exports, index.*). A bare name walks up node_modules from startDir (default: the current working directory) to the project root. It resolves with a path relative to the working directory, using forward slashes, or rejects with cannot find module '…' from '…'. The CLI uses it to find plugins (-p @fullstacked/sass) and scripts (--file).

addNodePath

addNodePath(inputPath: string): Promise<void>

Reserved. It validates that the path stays in the project and currently has no other effect.