Library API

Open a project

import { openProject, resumeActions, summarize } from "pixelkiln"

const project = await openProject("pixelkiln.manifest.json")
const plan = await project.plan()
const remaining = resumeActions(project.specs, project.lock)

console.log(summarize(plan))
for (const group of plan.groups) {
  console.log(`${group.provider}: ${group.cost} ${group.costUnit}`)
}
for (const action of remaining) console.log(`pixelkiln ${action.command}`, action.keys)

openProject(manifestPath, options) is the sequence the CLI runs before any command: read .env.local and .env beside the manifest (and in the working directory) into process.env without overriding anything already set, load the manifest, resolve specs, load the lockfile, and canonicalise its output paths for this checkout. Options: lockPath (default pixelkiln.lock.json beside the manifest), styles and assets filters, and env: false to leave process.env alone.

The returned Project carries manifestPath, root, lockPath, loaded, specs, and lock, plus plan(), saveLock(), reload(), providers(), and provider(id, mode), which hands out one adapter per id for the life of the object ("online" needs credentials; "downloads" only fetches recorded objects). The lower-level calls below take project.specs, project.lock, and project.lockPath directly:

const provider = project.provider("pixellab")
await submit(provider, project.loaded, plan.actionable, project.lock, project.lockPath)
await poll(provider, project.lock, project.lockPath, { specs: project.specs })
await fetchAssets(provider, project.specs, project.lock, project.lockPath)