ai-hero-cli 0.0.13 → 0.0.15

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.
Files changed (2) hide show
  1. package/bin.cjs +53 -21
  2. package/package.json +1 -1
package/bin.cjs CHANGED
@@ -67969,6 +67969,15 @@ var Lesson = class {
67969
67969
  this.sectionPath = opts.sectionPath;
67970
67970
  this.root = opts.root;
67971
67971
  }
67972
+ isExplainer() {
67973
+ return this.subfolders().pipe(
67974
+ Effect_exports.map(
67975
+ Array_exports.some((subfolder) => {
67976
+ return subfolder.includes("explainer");
67977
+ })
67978
+ )
67979
+ );
67980
+ }
67972
67981
  absolutePath() {
67973
67982
  return path4__namespace.resolve(this.root, this.sectionPath, this.path);
67974
67983
  }
@@ -68225,12 +68234,14 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
68225
68234
  if (nextSubfolder) {
68226
68235
  nextExerciseToRun = {
68227
68236
  lessonNumber: foundLesson.num,
68237
+ lessonName: foundLesson.name,
68228
68238
  subfolderIndex: subfolderIndex + 1,
68229
68239
  subfolder: nextSubfolder
68230
68240
  };
68231
68241
  } else if (nextLesson) {
68232
68242
  nextExerciseToRun = {
68233
68243
  lessonNumber: nextLesson.num,
68244
+ lessonName: nextLesson.name,
68234
68245
  subfolderIndex: 0,
68235
68246
  subfolder: (yield* nextLesson.subfolders())[0]
68236
68247
  };
@@ -68241,6 +68252,7 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
68241
68252
  if (subfolderIndex > 0) {
68242
68253
  previousExerciseToRun = {
68243
68254
  lessonNumber: foundLesson.num,
68255
+ lessonName: foundLesson.name,
68244
68256
  subfolderIndex: subfolderIndex - 1,
68245
68257
  subfolder: subfolders[subfolderIndex - 1]
68246
68258
  };
@@ -68249,6 +68261,7 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
68249
68261
  const previousLessonLastSubfolderIndex = previousLessonSubfolders.length - 1;
68250
68262
  previousExerciseToRun = {
68251
68263
  lessonNumber: previousLesson.num,
68264
+ lessonName: previousLesson.name,
68252
68265
  subfolderIndex: previousLessonLastSubfolderIndex,
68253
68266
  subfolder: previousLessonSubfolders[previousLessonLastSubfolderIndex]
68254
68267
  };
@@ -68276,14 +68289,7 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
68276
68289
  util.styleText("dim", " Press h + enter for more shortcuts\n")
68277
68290
  );
68278
68291
  if (readmeFile) {
68279
- yield* Console_exports.log(
68280
- `${util.styleText([], "Instructions:")}
68281
- ${util.styleText(
68282
- "dim",
68283
- readmeFile
68284
- )}
68285
- `
68286
- );
68292
+ yield* logReadmeFile({ readmeFile });
68287
68293
  }
68288
68294
  const command2 = Command_exports.make(
68289
68295
  "pnpm",
@@ -68357,26 +68363,39 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
68357
68363
  cwd
68358
68364
  });
68359
68365
  }
68366
+ const isExplainer = yield* foundLesson.isExplainer();
68367
+ if (isExplainer && readmeFile) {
68368
+ yield* logReadmeFile({ readmeFile });
68369
+ }
68370
+ const lessonNoun = isExplainer ? {
68371
+ successMessage: `Explainer executed! Once you've read the readme and understand the code, you can go to the next exercise.`,
68372
+ failureMessage: `Looks like the explainer errored! Want to try again?`,
68373
+ lowercase: "explainer"
68374
+ } : {
68375
+ successMessage: "Exercise complete! What's next?",
68376
+ failureMessage: `Looks like the exercise errored! Want to try again?`,
68377
+ lowercase: "exercise"
68378
+ };
68360
68379
  const { choice: choice6 } = yield* runPrompt(
68361
68380
  () => (0, import_prompts.default)([
68362
68381
  {
68363
68382
  type: "select",
68364
68383
  name: "choice",
68365
- message: processOutcome === "exit" ? "Exercise complete! What's next?" : "Looks like the exercise errored! What's next?",
68384
+ message: processOutcome === "exit" ? lessonNoun.successMessage : lessonNoun.failureMessage,
68366
68385
  choices: [
68367
68386
  {
68368
- title: processOutcome === "failed" ? "\u{1F504} Run the exercise again" : "\u{1F504} Try the exercise again",
68387
+ title: processOutcome === "failed" ? `\u{1F504} Run the ${lessonNoun.lowercase} again` : `\u{1F504} Try the ${lessonNoun.lowercase} again`,
68369
68388
  value: "run-again"
68370
68389
  },
68371
68390
  ...nextExerciseToRun ? [
68372
68391
  {
68373
- title: `\u27A1\uFE0F Run the next exercise: ${nextExerciseToRun?.lessonNumber} ${nextExerciseToRun?.subfolder}`,
68392
+ title: `\u27A1\uFE0F Run the next exercise: ${nextExerciseToRun?.lessonNumber}-${nextExerciseToRun?.lessonName} ${nextExerciseToRun?.subfolder}`,
68374
68393
  value: "next-exercise"
68375
68394
  }
68376
68395
  ] : [],
68377
68396
  ...previousExerciseToRun ? [
68378
68397
  {
68379
- title: `\u2B05\uFE0F Run the previous exercise: ${previousExerciseToRun?.lessonNumber} ${previousExerciseToRun?.subfolder}`,
68398
+ title: `\u2B05\uFE0F Run the previous exercise: ${previousExerciseToRun?.lessonNumber}-${previousExerciseToRun?.lessonName} ${previousExerciseToRun?.subfolder}`,
68380
68399
  value: "previous-exercise"
68381
68400
  }
68382
68401
  ] : [],
@@ -68429,6 +68448,18 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
68429
68448
  });
68430
68449
  }
68431
68450
  });
68451
+ var logReadmeFile = Effect_exports.fn("logReadmeFile")(
68452
+ function* (opts) {
68453
+ yield* Console_exports.log(
68454
+ `${util.styleText([], "Instructions:")}
68455
+ ${util.styleText(
68456
+ "dim",
68457
+ opts.readmeFile
68458
+ )}
68459
+ `
68460
+ );
68461
+ }
68462
+ );
68432
68463
  var chooseLessonAndRunIt = (opts) => Effect_exports.gen(function* () {
68433
68464
  const lessonService = yield* LessonParserService;
68434
68465
  const lessons = yield* lessonService.getLessonsFromRepo(
@@ -68586,14 +68617,7 @@ var runLessonSimple = (opts) => Effect_exports.gen(function* () {
68586
68617
  subfolder
68587
68618
  });
68588
68619
  if (readmeFile) {
68589
- yield* Console_exports.log(
68590
- `${util.styleText([], "Instructions:")}
68591
- ${util.styleText(
68592
- "dim",
68593
- readmeFile
68594
- )}
68595
- `
68596
- );
68620
+ yield* logReadmeFile({ readmeFile });
68597
68621
  }
68598
68622
  yield* Console_exports.log(
68599
68623
  util.styleText("bold", `Running ${lesson} ${subfolder}...`)
@@ -68602,6 +68626,9 @@ var runLessonSimple = (opts) => Effect_exports.gen(function* () {
68602
68626
  stdio: "inherit",
68603
68627
  cwd
68604
68628
  });
68629
+ if ((yield* foundLesson.isExplainer()) && readmeFile) {
68630
+ yield* logReadmeFile({ readmeFile });
68631
+ }
68605
68632
  });
68606
68633
  var notFound2 = Symbol("notFound");
68607
68634
  var getNumberFromPathSegment = (path10) => {
@@ -68750,7 +68777,12 @@ var updateCVM = Command_exports2.make(
68750
68777
  yield* Effect_exports.log(
68751
68778
  "[update-cvm] Successfully updated the CVM"
68752
68779
  );
68753
- })
68780
+ }).pipe(
68781
+ Effect_exports.catchAll((e) => {
68782
+ process.exitCode = 1;
68783
+ return Effect_exports.logError(e);
68784
+ })
68785
+ )
68754
68786
  );
68755
68787
  var createErrorTracker = () => {
68756
68788
  const groupedErrors = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hero-cli",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "description": "The CLI used to run exercises for the AI Hero course",
6
6
  "bin": "bin.cjs",