@lessonkit/cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -158,6 +158,12 @@ async function runInit(opts, logger) {
158
158
  exitCode: EXIT_INVALID_PROJECT
159
159
  });
160
160
  }
161
+ if (opts.force && !opts.here) {
162
+ throw new CliError("--force requires --here (initialize in the current directory).", {
163
+ code: "INVALID_PROJECT",
164
+ exitCode: EXIT_INVALID_PROJECT
165
+ });
166
+ }
161
167
  const slug = slugifyId(rawName ?? "my-course");
162
168
  const projectName = rawName ?? slug;
163
169
  const projectDir = opts.here ? cwd : resolve(cwd, slug);
@@ -253,11 +259,8 @@ async function loadLessonkitJson(projectRoot) {
253
259
  throwManifestCliError(configPath, parsed.issues);
254
260
  }
255
261
  return {
256
- root: projectRoot,
257
- schemaVersion: 1,
258
- name: parsed.manifest.name,
259
- course: parsed.manifest.course,
260
- paths: parsed.manifest.paths
262
+ ...parsed.manifest,
263
+ root: projectRoot
261
264
  };
262
265
  }
263
266
  function throwManifestCliError(configPath, issues) {
@@ -360,6 +363,18 @@ function assertNode18ForLxpack() {
360
363
  // src/lib/paths.ts
361
364
  import { resolve as resolve3 } from "path";
362
365
  import { resolveSafePackageOutputOverride } from "@lessonkit/lxpack";
366
+
367
+ // src/lib/targetTypes.ts
368
+ var PACKAGE_TARGETS = [
369
+ "react-vite",
370
+ "scorm12",
371
+ "scorm2004",
372
+ "xapi",
373
+ "cmi5",
374
+ "standalone"
375
+ ];
376
+
377
+ // src/lib/paths.ts
363
378
  function resolveDistDir(project) {
364
379
  return resolve3(project.root, project.paths.spaDistDir);
365
380
  }
@@ -390,14 +405,6 @@ function resolveViteBuildArgs(project) {
390
405
  }
391
406
  return args;
392
407
  }
393
- var PACKAGE_TARGETS = [
394
- "react-vite",
395
- "scorm12",
396
- "scorm2004",
397
- "xapi",
398
- "cmi5",
399
- "standalone"
400
- ];
401
408
  function parsePackageTarget(value) {
402
409
  if (!value) {
403
410
  throw new Error("TARGET_REQUIRED");
@@ -448,8 +455,17 @@ async function runPackage(opts) {
448
455
  }
449
456
  const project = await loadProject(opts.cwd ?? process.cwd());
450
457
  const distDir = resolveDistDir(project);
458
+ if (opts.noBuild && !existsSync3(distDir)) {
459
+ throw new CliError(
460
+ `dist directory not found at ${distDir}. Run lessonkit build before packaging with --no-build.`,
461
+ {
462
+ code: "INVALID_PROJECT",
463
+ exitCode: EXIT_INVALID_PROJECT
464
+ }
465
+ );
466
+ }
451
467
  if (target === "react-vite") {
452
- if (!opts.noBuild || !existsSync3(distDir)) {
468
+ if (!opts.noBuild) {
453
469
  await runBuild({ cwd: project.root, json: opts.json });
454
470
  }
455
471
  if (!existsSync3(distDir)) {
@@ -458,10 +474,10 @@ async function runPackage(opts) {
458
474
  exitCode: EXIT_INVALID_PROJECT
459
475
  });
460
476
  }
461
- return { ok: true, target, projectRoot: project.root, distDir };
477
+ return { ok: true, command: "package", target, projectRoot: project.root, distDir };
462
478
  }
463
479
  assertNode18ForLxpack();
464
- if (!opts.noBuild || !existsSync3(distDir)) {
480
+ if (!opts.noBuild) {
465
481
  await runBuild({ cwd: project.root, json: opts.json });
466
482
  }
467
483
  if (!existsSync3(distDir)) {
@@ -491,6 +507,7 @@ async function runPackage(opts) {
491
507
  }
492
508
  return {
493
509
  ok: true,
510
+ command: "package",
494
511
  target,
495
512
  projectRoot: project.root,
496
513
  outputPath: result.outputPath,
@@ -536,7 +553,7 @@ function createProgram(baseLogger = console) {
536
553
  program.name("lessonkit").description("LessonKit CLI").version(version);
537
554
  program.command("init").description("Initialize a LessonKit project from the Vite + React template").argument("[name]", "Project directory name").option("--here", "Initialize in the current directory").option("--skip-install", "Skip npm install").option(
538
555
  "--force",
539
- "With --here, allow init when the directory is empty or contains only dotfiles"
556
+ "Requires --here: allow init when the directory is empty or contains only dotfiles"
540
557
  ).option("--json", "Emit structured JSON result").action(async (name, opts) => {
541
558
  const logger = createLogger({ json: opts.json });
542
559
  await handleCommand(
@@ -557,7 +574,9 @@ function createProgram(baseLogger = console) {
557
574
  Boolean(opts.json)
558
575
  );
559
576
  });
560
- addCwdAndJson(program.command("build").description("Production Vite build")).action(
577
+ addCwdAndJson(
578
+ program.command("build").description("Production Vite build").allowUnknownOption().allowExcessArguments()
579
+ ).action(
561
580
  async (opts, command) => {
562
581
  const logger = createLogger({ json: opts.json });
563
582
  const viteArgs = command.args;
@@ -580,13 +599,12 @@ function createProgram(baseLogger = console) {
580
599
  json: opts.json
581
600
  });
582
601
  if (!opts.json && result.ok) {
583
- if (result.target === "react-vite" && "distDir" in result) {
602
+ if (result.command === "package" && result.target === "react-vite") {
584
603
  logger.log(`Built react-vite \u2192 ${result.distDir}`);
585
- } else if ("outputPath" in result || "outputDir" in result) {
604
+ } else if (result.command === "package") {
586
605
  const dest = result.outputPath ?? result.outputDir;
587
- const count = "fileCount" in result ? result.fileCount : void 0;
588
606
  logger.log(
589
- `Packaged ${result.target}${dest ? ` \u2192 ${dest}` : ""}${count != null ? ` (${count} files)` : ""}`
607
+ `Packaged ${result.target}${dest ? ` \u2192 ${dest}` : ""} (${result.fileCount} files)`
590
608
  );
591
609
  }
592
610
  }
package/dist/index.js CHANGED
@@ -156,6 +156,12 @@ async function runInit(opts, logger) {
156
156
  exitCode: EXIT_INVALID_PROJECT
157
157
  });
158
158
  }
159
+ if (opts.force && !opts.here) {
160
+ throw new CliError("--force requires --here (initialize in the current directory).", {
161
+ code: "INVALID_PROJECT",
162
+ exitCode: EXIT_INVALID_PROJECT
163
+ });
164
+ }
159
165
  const slug = slugifyId(rawName ?? "my-course");
160
166
  const projectName = rawName ?? slug;
161
167
  const projectDir = opts.here ? cwd : resolve(cwd, slug);
@@ -251,11 +257,8 @@ async function loadLessonkitJson(projectRoot) {
251
257
  throwManifestCliError(configPath, parsed.issues);
252
258
  }
253
259
  return {
254
- root: projectRoot,
255
- schemaVersion: 1,
256
- name: parsed.manifest.name,
257
- course: parsed.manifest.course,
258
- paths: parsed.manifest.paths
260
+ ...parsed.manifest,
261
+ root: projectRoot
259
262
  };
260
263
  }
261
264
  function throwManifestCliError(configPath, issues) {
@@ -358,6 +361,18 @@ function assertNode18ForLxpack() {
358
361
  // src/lib/paths.ts
359
362
  import { resolve as resolve3 } from "path";
360
363
  import { resolveSafePackageOutputOverride } from "@lessonkit/lxpack";
364
+
365
+ // src/lib/targetTypes.ts
366
+ var PACKAGE_TARGETS = [
367
+ "react-vite",
368
+ "scorm12",
369
+ "scorm2004",
370
+ "xapi",
371
+ "cmi5",
372
+ "standalone"
373
+ ];
374
+
375
+ // src/lib/paths.ts
361
376
  function resolveDistDir(project) {
362
377
  return resolve3(project.root, project.paths.spaDistDir);
363
378
  }
@@ -388,14 +403,6 @@ function resolveViteBuildArgs(project) {
388
403
  }
389
404
  return args;
390
405
  }
391
- var PACKAGE_TARGETS = [
392
- "react-vite",
393
- "scorm12",
394
- "scorm2004",
395
- "xapi",
396
- "cmi5",
397
- "standalone"
398
- ];
399
406
  function parsePackageTarget(value) {
400
407
  if (!value) {
401
408
  throw new Error("TARGET_REQUIRED");
@@ -446,8 +453,17 @@ async function runPackage(opts) {
446
453
  }
447
454
  const project = await loadProject(opts.cwd ?? process.cwd());
448
455
  const distDir = resolveDistDir(project);
456
+ if (opts.noBuild && !existsSync3(distDir)) {
457
+ throw new CliError(
458
+ `dist directory not found at ${distDir}. Run lessonkit build before packaging with --no-build.`,
459
+ {
460
+ code: "INVALID_PROJECT",
461
+ exitCode: EXIT_INVALID_PROJECT
462
+ }
463
+ );
464
+ }
449
465
  if (target === "react-vite") {
450
- if (!opts.noBuild || !existsSync3(distDir)) {
466
+ if (!opts.noBuild) {
451
467
  await runBuild({ cwd: project.root, json: opts.json });
452
468
  }
453
469
  if (!existsSync3(distDir)) {
@@ -456,10 +472,10 @@ async function runPackage(opts) {
456
472
  exitCode: EXIT_INVALID_PROJECT
457
473
  });
458
474
  }
459
- return { ok: true, target, projectRoot: project.root, distDir };
475
+ return { ok: true, command: "package", target, projectRoot: project.root, distDir };
460
476
  }
461
477
  assertNode18ForLxpack();
462
- if (!opts.noBuild || !existsSync3(distDir)) {
478
+ if (!opts.noBuild) {
463
479
  await runBuild({ cwd: project.root, json: opts.json });
464
480
  }
465
481
  if (!existsSync3(distDir)) {
@@ -489,6 +505,7 @@ async function runPackage(opts) {
489
505
  }
490
506
  return {
491
507
  ok: true,
508
+ command: "package",
492
509
  target,
493
510
  projectRoot: project.root,
494
511
  outputPath: result.outputPath,
@@ -534,7 +551,7 @@ function createProgram(baseLogger = console) {
534
551
  program.name("lessonkit").description("LessonKit CLI").version(version);
535
552
  program.command("init").description("Initialize a LessonKit project from the Vite + React template").argument("[name]", "Project directory name").option("--here", "Initialize in the current directory").option("--skip-install", "Skip npm install").option(
536
553
  "--force",
537
- "With --here, allow init when the directory is empty or contains only dotfiles"
554
+ "Requires --here: allow init when the directory is empty or contains only dotfiles"
538
555
  ).option("--json", "Emit structured JSON result").action(async (name, opts) => {
539
556
  const logger = createLogger({ json: opts.json });
540
557
  await handleCommand(
@@ -555,7 +572,9 @@ function createProgram(baseLogger = console) {
555
572
  Boolean(opts.json)
556
573
  );
557
574
  });
558
- addCwdAndJson(program.command("build").description("Production Vite build")).action(
575
+ addCwdAndJson(
576
+ program.command("build").description("Production Vite build").allowUnknownOption().allowExcessArguments()
577
+ ).action(
559
578
  async (opts, command) => {
560
579
  const logger = createLogger({ json: opts.json });
561
580
  const viteArgs = command.args;
@@ -578,13 +597,12 @@ function createProgram(baseLogger = console) {
578
597
  json: opts.json
579
598
  });
580
599
  if (!opts.json && result.ok) {
581
- if (result.target === "react-vite" && "distDir" in result) {
600
+ if (result.command === "package" && result.target === "react-vite") {
582
601
  logger.log(`Built react-vite \u2192 ${result.distDir}`);
583
- } else if ("outputPath" in result || "outputDir" in result) {
602
+ } else if (result.command === "package") {
584
603
  const dest = result.outputPath ?? result.outputDir;
585
- const count = "fileCount" in result ? result.fileCount : void 0;
586
604
  logger.log(
587
- `Packaged ${result.target}${dest ? ` \u2192 ${dest}` : ""}${count != null ? ` (${count} files)` : ""}`
605
+ `Packaged ${result.target}${dest ? ` \u2192 ${dest}` : ""} (${result.fileCount} files)`
588
606
  );
589
607
  }
590
608
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lessonkit/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "description": "LessonKit CLI — init, dev, build, and package learning experiences.",
6
6
  "license": "Apache-2.0",
@@ -42,8 +42,8 @@
42
42
  "lint": "echo \"(no lint configured yet)\""
43
43
  },
44
44
  "dependencies": {
45
- "@lessonkit/core": "1.0.0",
46
- "@lessonkit/lxpack": "1.0.0",
45
+ "@lessonkit/core": "1.0.1",
46
+ "@lessonkit/lxpack": "1.0.1",
47
47
  "commander": "^14.0.1"
48
48
  },
49
49
  "engines": {
@@ -13,16 +13,16 @@
13
13
  "test:coverage": "vitest run --coverage --passWithNoTests=false"
14
14
  },
15
15
  "dependencies": {
16
- "@lessonkit/core": "^1.0.0",
17
- "@lessonkit/react": "^1.0.0",
18
- "@lessonkit/themes": "^1.0.0",
19
- "@lessonkit/xapi": "^1.0.0",
16
+ "@lessonkit/core": "^1.0.1",
17
+ "@lessonkit/react": "^1.0.1",
18
+ "@lessonkit/themes": "^1.0.1",
19
+ "@lessonkit/xapi": "^1.0.1",
20
20
  "react": "^18.3.1",
21
21
  "react-dom": "^18.3.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@lessonkit/cli": "^1.0.0",
25
- "@lessonkit/lxpack": "^1.0.0",
24
+ "@lessonkit/cli": "^1.0.1",
25
+ "@lessonkit/lxpack": "^1.0.1",
26
26
  "@testing-library/react": "^16.3.0",
27
27
  "@types/react": "^18.3.23",
28
28
  "@types/react-dom": "^18.3.7",