CLI reference¶
LessonKit CLI (1.0+)¶
The @lessonkit/cli package provides the developer workflow for LessonKit projects: scaffold, dev, build, and dual export packaging.
Install¶
npm install -g @lessonkit/cli
# or use without installing:
npx @lessonkit/cli init my-course
Node.js: dev, build, and LMS packaging targets work on Node 18+ (see Packaging reference).
Quick start¶
lessonkit init my-course
cd my-course
lessonkit dev
lessonkit build
lessonkit package --target scorm12
Project manifest: lessonkit.json¶
Every LessonKit project includes a lessonkit.json at the project root. The CLI walks up from --cwd to find it.
{
"schemaVersion": 1,
"name": "my-course",
"course": {
"courseId": "my-course",
"title": "My LessonKit Course",
"layout": "single-spa",
"lessons": [{ "id": "lesson-1", "title": "My first lesson" }],
"assessments": [
{
"checkId": "ready-to-build",
"question": "Ready to build?",
"choices": ["Not yet", "Yes"],
"answer": "Yes",
"passingScore": 1
}
],
"theme": { "preset": "default" },
"tracking": {
"xapi": {
"activityIri": "https://example.com/courses/my-course"
}
}
},
"paths": {
"spaDistDir": "dist",
"lxpackOutDir": ".lxpack/course",
"outputBaseDir": ".lxpack/out"
}
}
Field |
Description |
|---|---|
|
Must be |
|
Project slug (used by |
|
|
|
Vite build output (default |
|
LXPack project directory (default |
|
Packaged artifact base under the LXPack project dir (default |
Keep course.courseId, course.lessons[].id, and course.assessments[].checkId aligned with your React component props. lessonkit init updates lessonkit.json and patches src/App.tsx courseId / course title for you. See Identity reference.
The CLI only recognizes project manifests with schemaVersion: 1 (not the interchange lessonkit.json written under .lxpack/course). per-lesson-spa layout is not supported by lessonkit package (1.0.0) — use single-spa. Use @lessonkit/lxpack directly if you need per-lesson-spa. SPA build output is controlled by paths.spaDistDir (not course.spaDistDir).
Commands¶
lessonkit init [name]¶
Scaffold a Vite + React project from the bundled template.
lessonkit init my-course
lessonkit init --here # init in current directory
lessonkit init my-course --skip-install
lessonkit init my-course --force
Flag |
Description |
|---|---|
|
Initialize in the current directory instead of creating a subdirectory |
|
Skip |
|
With |
lessonkit dev¶
Run the Vite dev server. Extra Vite args pass through after --:
lessonkit dev
lessonkit dev -- --port 3000
lessonkit dev --cwd ./apps/training
lessonkit build¶
Production Vite build to dist/ (or paths.spaDistDir from lessonkit.json; the CLI passes --outDir when it differs from dist).
lessonkit build
lessonkit build --json
lessonkit package --target <target>¶
Canonical dual-export entrypoint.
Target |
Output |
|---|---|
|
Verifies |
|
SCORM 1.2 ZIP under |
|
SCORM 2004 ZIP |
|
xAPI ZIP |
|
cmi5 ZIP |
|
Unpacked standalone directory |
lessonkit package --target react-vite
lessonkit package --target scorm12
lessonkit package --target standalone --json
lessonkit package --target scorm12 --no-build
lessonkit package --target scorm12 --out .lxpack/out/custom.zip
Flag |
Description |
|---|---|
|
Required. Export target (see table above) |
|
Project root (default: current directory) |
|
Skip the implicit Vite build; requires an existing |
|
Override output artifact path (must resolve inside the project root) |
|
Structured JSON result on stdout (CI/codegen) |
Lxpack targets run packageLessonkitCourse() from @lessonkit/lxpack. Output layout matches Packaging reference.
lessonkit publish¶
Stub — use npm and the tag-based workflow in RELEASING.
Exit codes¶
Code |
Meaning |
|---|---|
|
Success |
|
Command/runtime failure (build failed, spawn error) |
|
Invalid or missing project config |
|
Packaging/validation failure |
JSON output (--json)¶
Successful build:
{ "ok": true, "command": "build", "projectRoot": "/path/to/project" }
Successful package:
{
"ok": true,
"target": "scorm12",
"projectRoot": "/path/to/project",
"outputPath": "/path/to/project/.lxpack/course/.lxpack/out/course-scorm12.zip",
"fileCount": 42
}
Failure:
{
"ok": false,
"code": "INVALID_PROJECT",
"message": "lessonkit.json not found",
"exitCode": 2
}