ai-hero-cli 0.1.0 → 0.1.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/bin.cjs +195 -49
- package/package.json +1 -1
package/bin.cjs
CHANGED
|
@@ -83385,7 +83385,195 @@ var LessonEntrypointNotFoundError = class extends Data_exports.TaggedError(
|
|
|
83385
83385
|
) {
|
|
83386
83386
|
};
|
|
83387
83387
|
var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
|
|
83388
|
-
|
|
83388
|
+
const { cwd, envFilePath, lesson, root } = opts;
|
|
83389
|
+
const service2 = yield* LessonParserService;
|
|
83390
|
+
const lessons = yield* service2.getLessonsFromRepo(root);
|
|
83391
|
+
const foundLessonIndex = lessons.findIndex(
|
|
83392
|
+
(l) => l.num === lesson
|
|
83393
|
+
);
|
|
83394
|
+
if (foundLessonIndex === -1) {
|
|
83395
|
+
return yield* new LessonNotFoundError({
|
|
83396
|
+
lesson,
|
|
83397
|
+
message: `Lesson ${lesson} not found`
|
|
83398
|
+
});
|
|
83399
|
+
}
|
|
83400
|
+
const foundLesson = lessons[foundLessonIndex];
|
|
83401
|
+
const previousLesson = lessons[foundLessonIndex - 1];
|
|
83402
|
+
const nextLesson = lessons[foundLessonIndex + 1];
|
|
83403
|
+
const subfolders = yield* foundLesson.subfolders();
|
|
83404
|
+
if (subfolders.length === 0) {
|
|
83405
|
+
return yield* new LessonEntrypointNotFoundError({
|
|
83406
|
+
lesson,
|
|
83407
|
+
message: `No subfolders found for lesson ${lesson}`
|
|
83408
|
+
});
|
|
83409
|
+
}
|
|
83410
|
+
let subfolderIndex = opts.forceSubfolderIndex;
|
|
83411
|
+
if (subfolderIndex === void 0) {
|
|
83412
|
+
if (subfolders.length === 1) {
|
|
83413
|
+
subfolderIndex = 0;
|
|
83414
|
+
} else {
|
|
83415
|
+
const result2 = yield* selectSubfolderIndex({
|
|
83416
|
+
lesson: foundLesson
|
|
83417
|
+
});
|
|
83418
|
+
subfolderIndex = result2.subfolderIndex;
|
|
83419
|
+
}
|
|
83420
|
+
}
|
|
83421
|
+
const subfolder = subfolders[subfolderIndex];
|
|
83422
|
+
let nextExerciseToRun;
|
|
83423
|
+
const nextSubfolder = subfolders[subfolderIndex + 1];
|
|
83424
|
+
if (nextSubfolder) {
|
|
83425
|
+
nextExerciseToRun = {
|
|
83426
|
+
lessonNumber: foundLesson.num,
|
|
83427
|
+
lessonName: foundLesson.name,
|
|
83428
|
+
subfolderIndex: subfolderIndex + 1,
|
|
83429
|
+
subfolder: nextSubfolder
|
|
83430
|
+
};
|
|
83431
|
+
} else if (nextLesson) {
|
|
83432
|
+
nextExerciseToRun = {
|
|
83433
|
+
lessonNumber: nextLesson.num,
|
|
83434
|
+
lessonName: nextLesson.name,
|
|
83435
|
+
subfolderIndex: 0,
|
|
83436
|
+
subfolder: (yield* nextLesson.subfolders())[0]
|
|
83437
|
+
};
|
|
83438
|
+
} else {
|
|
83439
|
+
nextExerciseToRun = void 0;
|
|
83440
|
+
}
|
|
83441
|
+
let previousExerciseToRun;
|
|
83442
|
+
if (subfolderIndex > 0) {
|
|
83443
|
+
previousExerciseToRun = {
|
|
83444
|
+
lessonNumber: foundLesson.num,
|
|
83445
|
+
lessonName: foundLesson.name,
|
|
83446
|
+
subfolderIndex: subfolderIndex - 1,
|
|
83447
|
+
subfolder: subfolders[subfolderIndex - 1]
|
|
83448
|
+
};
|
|
83449
|
+
} else if (previousLesson) {
|
|
83450
|
+
const previousLessonSubfolders = yield* previousLesson.subfolders();
|
|
83451
|
+
const previousLessonLastSubfolderIndex = previousLessonSubfolders.length - 1;
|
|
83452
|
+
previousExerciseToRun = {
|
|
83453
|
+
lessonNumber: previousLesson.num,
|
|
83454
|
+
lessonName: previousLesson.name,
|
|
83455
|
+
subfolderIndex: previousLessonLastSubfolderIndex,
|
|
83456
|
+
subfolder: previousLessonSubfolders[previousLessonLastSubfolderIndex]
|
|
83457
|
+
};
|
|
83458
|
+
} else {
|
|
83459
|
+
previousExerciseToRun = void 0;
|
|
83460
|
+
}
|
|
83461
|
+
const { mainFile, readmeFile } = yield* getMainAndReadmeFiles({
|
|
83462
|
+
lesson: foundLesson,
|
|
83463
|
+
subfolder
|
|
83464
|
+
});
|
|
83465
|
+
yield* Console_exports.clear;
|
|
83466
|
+
yield* Console_exports.log(
|
|
83467
|
+
util.styleText(
|
|
83468
|
+
"bold",
|
|
83469
|
+
`Running ${foundLesson.num} ${subfolder}...`
|
|
83470
|
+
)
|
|
83471
|
+
);
|
|
83472
|
+
yield* Console_exports.log(
|
|
83473
|
+
util.styleText(
|
|
83474
|
+
"dim",
|
|
83475
|
+
" Press n + enter to go to the next exercise"
|
|
83476
|
+
)
|
|
83477
|
+
);
|
|
83478
|
+
yield* Console_exports.log(
|
|
83479
|
+
util.styleText("dim", " Press h + enter for more shortcuts\n")
|
|
83480
|
+
);
|
|
83481
|
+
if (readmeFile) {
|
|
83482
|
+
yield* logReadmeFile({ readmeFile });
|
|
83483
|
+
}
|
|
83484
|
+
const result = yield* Effect_exports.try({
|
|
83485
|
+
try: () => ChildProcess.execSync(
|
|
83486
|
+
`pnpm tsx --env-file="${envFilePath}" "${mainFile}"`,
|
|
83487
|
+
{
|
|
83488
|
+
stdio: "inherit",
|
|
83489
|
+
cwd
|
|
83490
|
+
}
|
|
83491
|
+
),
|
|
83492
|
+
catch: (error4) => new RunLessonSimpleError({ cause: error4 })
|
|
83493
|
+
}).pipe(
|
|
83494
|
+
Effect_exports.map(() => "success"),
|
|
83495
|
+
Effect_exports.catchAll(() => Effect_exports.succeed("failed"))
|
|
83496
|
+
);
|
|
83497
|
+
const isExplainer = yield* foundLesson.isExplainer();
|
|
83498
|
+
if (isExplainer && readmeFile) {
|
|
83499
|
+
yield* logReadmeFile({ readmeFile });
|
|
83500
|
+
}
|
|
83501
|
+
const lessonNoun = isExplainer ? {
|
|
83502
|
+
successMessage: `Explainer executed! Once you've read the readme and understand the code, you can go to the next exercise.`,
|
|
83503
|
+
failureMessage: `Looks like the explainer errored! Want to try again?`,
|
|
83504
|
+
lowercase: "explainer"
|
|
83505
|
+
} : {
|
|
83506
|
+
successMessage: "Exercise complete! What's next?",
|
|
83507
|
+
failureMessage: `Looks like the exercise errored! Want to try again?`,
|
|
83508
|
+
lowercase: "exercise"
|
|
83509
|
+
};
|
|
83510
|
+
const { choice: choice6 } = yield* runPrompt(
|
|
83511
|
+
() => (0, import_prompts.default)([
|
|
83512
|
+
{
|
|
83513
|
+
type: "select",
|
|
83514
|
+
name: "choice",
|
|
83515
|
+
message: result === "success" ? lessonNoun.successMessage : lessonNoun.failureMessage,
|
|
83516
|
+
choices: [
|
|
83517
|
+
{
|
|
83518
|
+
title: result === "failed" ? `\u{1F504} Run the ${lessonNoun.lowercase} again` : `\u{1F504} Try the ${lessonNoun.lowercase} again`,
|
|
83519
|
+
value: "run-again"
|
|
83520
|
+
},
|
|
83521
|
+
...nextExerciseToRun ? [
|
|
83522
|
+
{
|
|
83523
|
+
title: `\u27A1\uFE0F Run the next exercise: ${nextExerciseToRun?.lessonNumber}-${nextExerciseToRun?.lessonName} ${nextExerciseToRun?.subfolder}`,
|
|
83524
|
+
value: "next-exercise"
|
|
83525
|
+
}
|
|
83526
|
+
] : [],
|
|
83527
|
+
...previousExerciseToRun ? [
|
|
83528
|
+
{
|
|
83529
|
+
title: `\u2B05\uFE0F Run the previous exercise: ${previousExerciseToRun?.lessonNumber}-${previousExerciseToRun?.lessonName} ${previousExerciseToRun?.subfolder}`,
|
|
83530
|
+
value: "previous-exercise"
|
|
83531
|
+
}
|
|
83532
|
+
] : [],
|
|
83533
|
+
{
|
|
83534
|
+
title: "\u{1F4CB} Choose a new exercise",
|
|
83535
|
+
value: "choose-exercise"
|
|
83536
|
+
},
|
|
83537
|
+
{
|
|
83538
|
+
title: "\u2705 Finish",
|
|
83539
|
+
value: "finish"
|
|
83540
|
+
}
|
|
83541
|
+
]
|
|
83542
|
+
}
|
|
83543
|
+
])
|
|
83544
|
+
);
|
|
83545
|
+
if (choice6 === "run-again") {
|
|
83546
|
+
return yield* runLesson({
|
|
83547
|
+
lesson,
|
|
83548
|
+
root,
|
|
83549
|
+
envFilePath,
|
|
83550
|
+
cwd,
|
|
83551
|
+
// Run the same exercise again, with the same subfolder index
|
|
83552
|
+
forceSubfolderIndex: subfolderIndex
|
|
83553
|
+
});
|
|
83554
|
+
} else if (choice6 === "choose-exercise") {
|
|
83555
|
+
return yield* chooseLessonAndRunIt({
|
|
83556
|
+
root,
|
|
83557
|
+
envFilePath,
|
|
83558
|
+
cwd
|
|
83559
|
+
});
|
|
83560
|
+
} else if (choice6 === "next-exercise" && nextExerciseToRun) {
|
|
83561
|
+
return yield* runLesson({
|
|
83562
|
+
lesson: nextExerciseToRun.lessonNumber,
|
|
83563
|
+
root,
|
|
83564
|
+
envFilePath,
|
|
83565
|
+
cwd,
|
|
83566
|
+
forceSubfolderIndex: nextExerciseToRun.subfolderIndex
|
|
83567
|
+
});
|
|
83568
|
+
} else if (choice6 === "previous-exercise" && previousExerciseToRun) {
|
|
83569
|
+
return yield* runLesson({
|
|
83570
|
+
lesson: previousExerciseToRun.lessonNumber,
|
|
83571
|
+
root,
|
|
83572
|
+
envFilePath,
|
|
83573
|
+
cwd,
|
|
83574
|
+
forceSubfolderIndex: previousExerciseToRun.subfolderIndex
|
|
83575
|
+
});
|
|
83576
|
+
}
|
|
83389
83577
|
});
|
|
83390
83578
|
var logReadmeFile = Effect_exports.fn("logReadmeFile")(
|
|
83391
83579
|
function* (opts) {
|
|
@@ -83466,10 +83654,8 @@ var exercise = Command_exports2.make(
|
|
|
83466
83654
|
({ cwd, debug: debug3, envFilePath, lesson, root, simple: simple3 }) => {
|
|
83467
83655
|
return Effect_exports.gen(function* () {
|
|
83468
83656
|
if (simple3) {
|
|
83469
|
-
return yield*
|
|
83470
|
-
|
|
83471
|
-
"Simple is now the default mode, so you no longer need to include the --simple flag"
|
|
83472
|
-
)
|
|
83657
|
+
return yield* Console_exports.log(
|
|
83658
|
+
"Simple mode is now the default mode! No need to use the --simple flag."
|
|
83473
83659
|
);
|
|
83474
83660
|
}
|
|
83475
83661
|
const resolvedEnvFilePath = path4__namespace.relative(
|
|
@@ -83501,20 +83687,6 @@ var exercise = Command_exports2.make(
|
|
|
83501
83687
|
});
|
|
83502
83688
|
}
|
|
83503
83689
|
);
|
|
83504
|
-
var findLesson = Effect_exports.fn("findLesson")(function* (opts) {
|
|
83505
|
-
const service2 = yield* LessonParserService;
|
|
83506
|
-
const lessons = yield* service2.getLessonsFromRepo(opts.root);
|
|
83507
|
-
const foundLessonIndex = lessons.findIndex(
|
|
83508
|
-
(l) => l.num === opts.lesson
|
|
83509
|
-
);
|
|
83510
|
-
if (foundLessonIndex === -1) {
|
|
83511
|
-
return yield* new LessonNotFoundError({
|
|
83512
|
-
lesson: opts.lesson,
|
|
83513
|
-
message: `Lesson ${opts.lesson} not found`
|
|
83514
|
-
});
|
|
83515
|
-
}
|
|
83516
|
-
return lessons[foundLessonIndex];
|
|
83517
|
-
});
|
|
83518
83690
|
var selectSubfolderIndex = Effect_exports.fn("selectSubfolder")(
|
|
83519
83691
|
function* (opts) {
|
|
83520
83692
|
const subfolders = yield* opts.lesson.subfolders();
|
|
@@ -83568,36 +83740,10 @@ var getMainAndReadmeFiles = Effect_exports.fn("getMainAndReadmeFiles")(
|
|
|
83568
83740
|
return { mainFile, readmeFile };
|
|
83569
83741
|
}
|
|
83570
83742
|
);
|
|
83571
|
-
var
|
|
83572
|
-
|
|
83573
|
-
|
|
83574
|
-
|
|
83575
|
-
root
|
|
83576
|
-
});
|
|
83577
|
-
const { subfolder } = yield* selectSubfolderIndex({
|
|
83578
|
-
lesson: foundLesson
|
|
83579
|
-
});
|
|
83580
|
-
const { mainFile, readmeFile } = yield* getMainAndReadmeFiles({
|
|
83581
|
-
lesson: foundLesson,
|
|
83582
|
-
subfolder
|
|
83583
|
-
});
|
|
83584
|
-
if (readmeFile) {
|
|
83585
|
-
yield* logReadmeFile({ readmeFile });
|
|
83586
|
-
}
|
|
83587
|
-
yield* Console_exports.log(
|
|
83588
|
-
util.styleText("bold", `Running ${lesson} ${subfolder}...`)
|
|
83589
|
-
);
|
|
83590
|
-
ChildProcess.execSync(
|
|
83591
|
-
`pnpm tsx --env-file="${envFilePath}" "${mainFile}"`,
|
|
83592
|
-
{
|
|
83593
|
-
stdio: "inherit",
|
|
83594
|
-
cwd
|
|
83595
|
-
}
|
|
83596
|
-
);
|
|
83597
|
-
if ((yield* foundLesson.isExplainer()) && readmeFile) {
|
|
83598
|
-
yield* logReadmeFile({ readmeFile });
|
|
83599
|
-
}
|
|
83600
|
-
});
|
|
83743
|
+
var RunLessonSimpleError = class extends Data_exports.TaggedError(
|
|
83744
|
+
"RunLessonSimpleError"
|
|
83745
|
+
) {
|
|
83746
|
+
};
|
|
83601
83747
|
var notFound2 = Symbol("notFound");
|
|
83602
83748
|
var getNumberFromPathSegment = (path11) => {
|
|
83603
83749
|
const numberSegment = path11.split("-")[0];
|