ai-hero-cli 0.0.26 → 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 +38 -188
- package/package.json +1 -1
package/bin.cjs
CHANGED
|
@@ -8,7 +8,6 @@ var OS = require('os');
|
|
|
8
8
|
var path4 = require('path');
|
|
9
9
|
var NodeUrl = require('url');
|
|
10
10
|
var readline = require('readline');
|
|
11
|
-
var readline2 = require('readline/promises');
|
|
12
11
|
var util = require('util');
|
|
13
12
|
|
|
14
13
|
function _interopNamespace(e) {
|
|
@@ -36,7 +35,6 @@ var OS__namespace = /*#__PURE__*/_interopNamespace(OS);
|
|
|
36
35
|
var path4__namespace = /*#__PURE__*/_interopNamespace(path4);
|
|
37
36
|
var NodeUrl__namespace = /*#__PURE__*/_interopNamespace(NodeUrl);
|
|
38
37
|
var readline__namespace = /*#__PURE__*/_interopNamespace(readline);
|
|
39
|
-
var readline2__namespace = /*#__PURE__*/_interopNamespace(readline2);
|
|
40
38
|
|
|
41
39
|
var __create = Object.create;
|
|
42
40
|
var __defProp = Object.defineProperty;
|
|
@@ -11646,7 +11644,7 @@ var require_util = __commonJS({
|
|
|
11646
11644
|
// node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/prompt.js
|
|
11647
11645
|
var require_prompt = __commonJS({
|
|
11648
11646
|
"node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/prompt.js"(exports, module) {
|
|
11649
|
-
var
|
|
11647
|
+
var readline2 = __require("readline");
|
|
11650
11648
|
var _require = require_util();
|
|
11651
11649
|
var action = _require.action;
|
|
11652
11650
|
var EventEmitter = __require("events");
|
|
@@ -11661,11 +11659,11 @@ var require_prompt = __commonJS({
|
|
|
11661
11659
|
this.in = opts.stdin || process.stdin;
|
|
11662
11660
|
this.out = opts.stdout || process.stdout;
|
|
11663
11661
|
this.onRender = (opts.onRender || (() => void 0)).bind(this);
|
|
11664
|
-
const rl =
|
|
11662
|
+
const rl = readline2.createInterface({
|
|
11665
11663
|
input: this.in,
|
|
11666
11664
|
escapeCodeTimeout: 50
|
|
11667
11665
|
});
|
|
11668
|
-
|
|
11666
|
+
readline2.emitKeypressEvents(this.in, rl);
|
|
11669
11667
|
if (this.in.isTTY) this.in.setRawMode(true);
|
|
11670
11668
|
const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1;
|
|
11671
11669
|
const keypress = (str, key) => {
|
|
@@ -14080,7 +14078,7 @@ var require_util2 = __commonJS({
|
|
|
14080
14078
|
// node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/prompt.js
|
|
14081
14079
|
var require_prompt2 = __commonJS({
|
|
14082
14080
|
"node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/prompt.js"(exports, module) {
|
|
14083
|
-
var
|
|
14081
|
+
var readline2 = __require("readline");
|
|
14084
14082
|
var { action } = require_util2();
|
|
14085
14083
|
var EventEmitter = __require("events");
|
|
14086
14084
|
var { beep: beep4, cursor } = require_src();
|
|
@@ -14092,8 +14090,8 @@ var require_prompt2 = __commonJS({
|
|
|
14092
14090
|
this.in = opts.stdin || process.stdin;
|
|
14093
14091
|
this.out = opts.stdout || process.stdout;
|
|
14094
14092
|
this.onRender = (opts.onRender || (() => void 0)).bind(this);
|
|
14095
|
-
const rl =
|
|
14096
|
-
|
|
14093
|
+
const rl = readline2.createInterface({ input: this.in, escapeCodeTimeout: 50 });
|
|
14094
|
+
readline2.emitKeypressEvents(this.in, rl);
|
|
14097
14095
|
if (this.in.isTTY) this.in.setRawMode(true);
|
|
14098
14096
|
const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1;
|
|
14099
14097
|
const keypress = (str, key) => {
|
|
@@ -83386,16 +83384,7 @@ var LessonEntrypointNotFoundError = class extends Data_exports.TaggedError(
|
|
|
83386
83384
|
"LessonEntrypointNotFoundError"
|
|
83387
83385
|
) {
|
|
83388
83386
|
};
|
|
83389
|
-
var shortcuts = {
|
|
83390
|
-
enter: "Choose a new exercise to run",
|
|
83391
|
-
n: "Go to the next exercise",
|
|
83392
|
-
p: "Go to the previous exercise",
|
|
83393
|
-
q: "Quit the exercise"
|
|
83394
|
-
};
|
|
83395
83387
|
var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
|
|
83396
|
-
if (opts.simple) {
|
|
83397
|
-
return yield* runLessonSimple(opts);
|
|
83398
|
-
}
|
|
83399
83388
|
const { cwd, envFilePath, lesson, root } = opts;
|
|
83400
83389
|
const service2 = yield* LessonParserService;
|
|
83401
83390
|
const lessons = yield* service2.getLessonsFromRepo(root);
|
|
@@ -83423,10 +83412,10 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
|
|
|
83423
83412
|
if (subfolders.length === 1) {
|
|
83424
83413
|
subfolderIndex = 0;
|
|
83425
83414
|
} else {
|
|
83426
|
-
const
|
|
83415
|
+
const result2 = yield* selectSubfolderIndex({
|
|
83427
83416
|
lesson: foundLesson
|
|
83428
83417
|
});
|
|
83429
|
-
subfolderIndex =
|
|
83418
|
+
subfolderIndex = result2.subfolderIndex;
|
|
83430
83419
|
}
|
|
83431
83420
|
}
|
|
83432
83421
|
const subfolder = subfolders[subfolderIndex];
|
|
@@ -83492,116 +83481,19 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
|
|
|
83492
83481
|
if (readmeFile) {
|
|
83493
83482
|
yield* logReadmeFile({ readmeFile });
|
|
83494
83483
|
}
|
|
83495
|
-
const
|
|
83496
|
-
|
|
83497
|
-
|
|
83498
|
-
|
|
83499
|
-
|
|
83500
|
-
|
|
83501
|
-
).pipe(
|
|
83502
|
-
Command_exports.stdout("inherit"),
|
|
83503
|
-
Command_exports.stderr("inherit"),
|
|
83504
|
-
Command_exports.workingDirectory(cwd)
|
|
83505
|
-
);
|
|
83506
|
-
const processOutcome = yield* Effect_exports.raceAll([
|
|
83507
|
-
Effect_exports.gen(function* () {
|
|
83508
|
-
const proc = yield* Command_exports.start(command2);
|
|
83509
|
-
const killWithLogging = () => Effect_exports.gen(function* () {
|
|
83510
|
-
if (yield* proc.isRunning) {
|
|
83511
|
-
return yield* proc.kill();
|
|
83512
|
-
}
|
|
83513
|
-
}).pipe(
|
|
83514
|
-
Effect_exports.catchAll(
|
|
83515
|
-
(e) => Effect_exports.logDebug(
|
|
83516
|
-
`Error occurred when killing child process.`,
|
|
83517
|
-
e
|
|
83518
|
-
)
|
|
83519
|
-
)
|
|
83520
|
-
);
|
|
83521
|
-
yield* Effect_exports.addFinalizer(() => killWithLogging());
|
|
83522
|
-
const killAsCallback = () => killWithLogging().pipe(Effect_exports.runPromise);
|
|
83523
|
-
yield* Effect_exports.fork(
|
|
83524
|
-
Effect_exports.sync(() => {
|
|
83525
|
-
process.on("SIGINT", killAsCallback);
|
|
83526
|
-
})
|
|
83527
|
-
);
|
|
83528
|
-
yield* Effect_exports.fork(
|
|
83529
|
-
Effect_exports.sync(() => {
|
|
83530
|
-
process.on("SIGTERM", killAsCallback);
|
|
83531
|
-
})
|
|
83532
|
-
);
|
|
83533
|
-
yield* Effect_exports.addFinalizer(() => {
|
|
83534
|
-
return Effect_exports.sync(
|
|
83535
|
-
() => process.removeListener("SIGINT", killAsCallback)
|
|
83536
|
-
);
|
|
83537
|
-
});
|
|
83538
|
-
yield* Effect_exports.addFinalizer(() => {
|
|
83539
|
-
return Effect_exports.sync(
|
|
83540
|
-
() => process.removeListener("SIGTERM", killAsCallback)
|
|
83541
|
-
);
|
|
83542
|
-
});
|
|
83543
|
-
const result = yield* proc.exitCode;
|
|
83544
|
-
return result === 0 ? "exit" : "failed";
|
|
83545
|
-
}),
|
|
83546
|
-
Effect_exports.gen(function* () {
|
|
83547
|
-
const rl = readline2__namespace.createInterface({
|
|
83548
|
-
input: process.stdin
|
|
83549
|
-
});
|
|
83550
|
-
yield* Effect_exports.addFinalizer(() => {
|
|
83551
|
-
return Effect_exports.succeed(rl.close());
|
|
83552
|
-
});
|
|
83553
|
-
while (true) {
|
|
83554
|
-
const line4 = yield* Effect_exports.promise(async (signal) => {
|
|
83555
|
-
const result = await rl.question("", { signal });
|
|
83556
|
-
rl.close();
|
|
83557
|
-
return result;
|
|
83558
|
-
});
|
|
83559
|
-
if (line4 === "h") {
|
|
83560
|
-
yield* Console_exports.log(util.styleText("bold", "Shortcuts:"));
|
|
83561
|
-
for (const [key, value5] of Object.entries(shortcuts)) {
|
|
83562
|
-
yield* Console_exports.log(
|
|
83563
|
-
` ${key} ${util.styleText("dim", `- ${value5}`)}`
|
|
83564
|
-
);
|
|
83565
|
-
}
|
|
83566
|
-
} else if (line4 === "q") {
|
|
83567
|
-
return "quit";
|
|
83568
|
-
} else if (line4 === "n") {
|
|
83569
|
-
return "next";
|
|
83570
|
-
} else if (line4 === "p") {
|
|
83571
|
-
return "previous";
|
|
83572
|
-
} else if (line4.trim() === "") {
|
|
83573
|
-
return "choose-exercise";
|
|
83574
|
-
}
|
|
83484
|
+
const result = yield* Effect_exports.try({
|
|
83485
|
+
try: () => ChildProcess.execSync(
|
|
83486
|
+
`pnpm tsx --env-file="${envFilePath}" "${mainFile}"`,
|
|
83487
|
+
{
|
|
83488
|
+
stdio: "inherit",
|
|
83489
|
+
cwd
|
|
83575
83490
|
}
|
|
83576
|
-
|
|
83577
|
-
|
|
83578
|
-
|
|
83579
|
-
|
|
83580
|
-
|
|
83581
|
-
|
|
83582
|
-
lesson: nextExerciseToRun.lessonNumber,
|
|
83583
|
-
root,
|
|
83584
|
-
envFilePath,
|
|
83585
|
-
cwd,
|
|
83586
|
-
forceSubfolderIndex: nextExerciseToRun.subfolderIndex
|
|
83587
|
-
});
|
|
83588
|
-
} else if (processOutcome === "previous" && previousExerciseToRun) {
|
|
83589
|
-
return yield* runLesson({
|
|
83590
|
-
simple: opts.simple,
|
|
83591
|
-
lesson: previousExerciseToRun.lessonNumber,
|
|
83592
|
-
root,
|
|
83593
|
-
envFilePath,
|
|
83594
|
-
cwd,
|
|
83595
|
-
forceSubfolderIndex: previousExerciseToRun.subfolderIndex
|
|
83596
|
-
});
|
|
83597
|
-
} else if (processOutcome === "choose-exercise") {
|
|
83598
|
-
return yield* chooseLessonAndRunIt({
|
|
83599
|
-
simple: opts.simple,
|
|
83600
|
-
root,
|
|
83601
|
-
envFilePath,
|
|
83602
|
-
cwd
|
|
83603
|
-
});
|
|
83604
|
-
}
|
|
83491
|
+
),
|
|
83492
|
+
catch: (error4) => new RunLessonSimpleError({ cause: error4 })
|
|
83493
|
+
}).pipe(
|
|
83494
|
+
Effect_exports.map(() => "success"),
|
|
83495
|
+
Effect_exports.catchAll(() => Effect_exports.succeed("failed"))
|
|
83496
|
+
);
|
|
83605
83497
|
const isExplainer = yield* foundLesson.isExplainer();
|
|
83606
83498
|
if (isExplainer && readmeFile) {
|
|
83607
83499
|
yield* logReadmeFile({ readmeFile });
|
|
@@ -83620,10 +83512,10 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
|
|
|
83620
83512
|
{
|
|
83621
83513
|
type: "select",
|
|
83622
83514
|
name: "choice",
|
|
83623
|
-
message:
|
|
83515
|
+
message: result === "success" ? lessonNoun.successMessage : lessonNoun.failureMessage,
|
|
83624
83516
|
choices: [
|
|
83625
83517
|
{
|
|
83626
|
-
title:
|
|
83518
|
+
title: result === "failed" ? `\u{1F504} Run the ${lessonNoun.lowercase} again` : `\u{1F504} Try the ${lessonNoun.lowercase} again`,
|
|
83627
83519
|
value: "run-again"
|
|
83628
83520
|
},
|
|
83629
83521
|
...nextExerciseToRun ? [
|
|
@@ -83657,15 +83549,13 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
|
|
|
83657
83549
|
envFilePath,
|
|
83658
83550
|
cwd,
|
|
83659
83551
|
// Run the same exercise again, with the same subfolder index
|
|
83660
|
-
forceSubfolderIndex: subfolderIndex
|
|
83661
|
-
simple: opts.simple
|
|
83552
|
+
forceSubfolderIndex: subfolderIndex
|
|
83662
83553
|
});
|
|
83663
83554
|
} else if (choice6 === "choose-exercise") {
|
|
83664
83555
|
return yield* chooseLessonAndRunIt({
|
|
83665
83556
|
root,
|
|
83666
83557
|
envFilePath,
|
|
83667
|
-
cwd
|
|
83668
|
-
simple: opts.simple
|
|
83558
|
+
cwd
|
|
83669
83559
|
});
|
|
83670
83560
|
} else if (choice6 === "next-exercise" && nextExerciseToRun) {
|
|
83671
83561
|
return yield* runLesson({
|
|
@@ -83673,8 +83563,7 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
|
|
|
83673
83563
|
root,
|
|
83674
83564
|
envFilePath,
|
|
83675
83565
|
cwd,
|
|
83676
|
-
forceSubfolderIndex: nextExerciseToRun.subfolderIndex
|
|
83677
|
-
simple: opts.simple
|
|
83566
|
+
forceSubfolderIndex: nextExerciseToRun.subfolderIndex
|
|
83678
83567
|
});
|
|
83679
83568
|
} else if (choice6 === "previous-exercise" && previousExerciseToRun) {
|
|
83680
83569
|
return yield* runLesson({
|
|
@@ -83682,8 +83571,7 @@ var runLesson = Effect_exports.fn("runLesson")(function* (opts) {
|
|
|
83682
83571
|
root,
|
|
83683
83572
|
envFilePath,
|
|
83684
83573
|
cwd,
|
|
83685
|
-
forceSubfolderIndex: previousExerciseToRun.subfolderIndex
|
|
83686
|
-
simple: opts.simple
|
|
83574
|
+
forceSubfolderIndex: previousExerciseToRun.subfolderIndex
|
|
83687
83575
|
});
|
|
83688
83576
|
}
|
|
83689
83577
|
});
|
|
@@ -83738,8 +83626,7 @@ var chooseLessonAndRunIt = (opts) => Effect_exports.gen(function* () {
|
|
|
83738
83626
|
root: opts.root,
|
|
83739
83627
|
envFilePath: opts.envFilePath,
|
|
83740
83628
|
cwd: opts.cwd,
|
|
83741
|
-
forceSubfolderIndex: void 0
|
|
83742
|
-
simple: opts.simple
|
|
83629
|
+
forceSubfolderIndex: void 0
|
|
83743
83630
|
});
|
|
83744
83631
|
}).pipe(Effect_exports.catchAll(Console_exports.log));
|
|
83745
83632
|
var exercise = Command_exports2.make(
|
|
@@ -83766,6 +83653,11 @@ var exercise = Command_exports2.make(
|
|
|
83766
83653
|
},
|
|
83767
83654
|
({ cwd, debug: debug3, envFilePath, lesson, root, simple: simple3 }) => {
|
|
83768
83655
|
return Effect_exports.gen(function* () {
|
|
83656
|
+
if (simple3) {
|
|
83657
|
+
return yield* Console_exports.log(
|
|
83658
|
+
"Simple mode is now the default mode! No need to use the --simple flag."
|
|
83659
|
+
);
|
|
83660
|
+
}
|
|
83769
83661
|
const resolvedEnvFilePath = path4__namespace.relative(
|
|
83770
83662
|
cwd,
|
|
83771
83663
|
envFilePath
|
|
@@ -83776,8 +83668,7 @@ var exercise = Command_exports2.make(
|
|
|
83776
83668
|
root,
|
|
83777
83669
|
envFilePath: resolvedEnvFilePath,
|
|
83778
83670
|
cwd,
|
|
83779
|
-
forceSubfolderIndex: void 0
|
|
83780
|
-
simple: simple3
|
|
83671
|
+
forceSubfolderIndex: void 0
|
|
83781
83672
|
}).pipe(
|
|
83782
83673
|
Logger_exports.withMinimumLogLevel(
|
|
83783
83674
|
debug3 ? LogLevel_exports.Debug : LogLevel_exports.Info
|
|
@@ -83787,8 +83678,7 @@ var exercise = Command_exports2.make(
|
|
|
83787
83678
|
return yield* chooseLessonAndRunIt({
|
|
83788
83679
|
root,
|
|
83789
83680
|
envFilePath: resolvedEnvFilePath,
|
|
83790
|
-
cwd
|
|
83791
|
-
simple: simple3
|
|
83681
|
+
cwd
|
|
83792
83682
|
}).pipe(
|
|
83793
83683
|
Logger_exports.withMinimumLogLevel(
|
|
83794
83684
|
debug3 ? LogLevel_exports.Debug : LogLevel_exports.Info
|
|
@@ -83797,20 +83687,6 @@ var exercise = Command_exports2.make(
|
|
|
83797
83687
|
});
|
|
83798
83688
|
}
|
|
83799
83689
|
);
|
|
83800
|
-
var findLesson = Effect_exports.fn("findLesson")(function* (opts) {
|
|
83801
|
-
const service2 = yield* LessonParserService;
|
|
83802
|
-
const lessons = yield* service2.getLessonsFromRepo(opts.root);
|
|
83803
|
-
const foundLessonIndex = lessons.findIndex(
|
|
83804
|
-
(l) => l.num === opts.lesson
|
|
83805
|
-
);
|
|
83806
|
-
if (foundLessonIndex === -1) {
|
|
83807
|
-
return yield* new LessonNotFoundError({
|
|
83808
|
-
lesson: opts.lesson,
|
|
83809
|
-
message: `Lesson ${opts.lesson} not found`
|
|
83810
|
-
});
|
|
83811
|
-
}
|
|
83812
|
-
return lessons[foundLessonIndex];
|
|
83813
|
-
});
|
|
83814
83690
|
var selectSubfolderIndex = Effect_exports.fn("selectSubfolder")(
|
|
83815
83691
|
function* (opts) {
|
|
83816
83692
|
const subfolders = yield* opts.lesson.subfolders();
|
|
@@ -83864,36 +83740,10 @@ var getMainAndReadmeFiles = Effect_exports.fn("getMainAndReadmeFiles")(
|
|
|
83864
83740
|
return { mainFile, readmeFile };
|
|
83865
83741
|
}
|
|
83866
83742
|
);
|
|
83867
|
-
var
|
|
83868
|
-
|
|
83869
|
-
|
|
83870
|
-
|
|
83871
|
-
root
|
|
83872
|
-
});
|
|
83873
|
-
const { subfolder } = yield* selectSubfolderIndex({
|
|
83874
|
-
lesson: foundLesson
|
|
83875
|
-
});
|
|
83876
|
-
const { mainFile, readmeFile } = yield* getMainAndReadmeFiles({
|
|
83877
|
-
lesson: foundLesson,
|
|
83878
|
-
subfolder
|
|
83879
|
-
});
|
|
83880
|
-
if (readmeFile) {
|
|
83881
|
-
yield* logReadmeFile({ readmeFile });
|
|
83882
|
-
}
|
|
83883
|
-
yield* Console_exports.log(
|
|
83884
|
-
util.styleText("bold", `Running ${lesson} ${subfolder}...`)
|
|
83885
|
-
);
|
|
83886
|
-
ChildProcess.execSync(
|
|
83887
|
-
`pnpm tsx --env-file="${envFilePath}" "${mainFile}"`,
|
|
83888
|
-
{
|
|
83889
|
-
stdio: "inherit",
|
|
83890
|
-
cwd
|
|
83891
|
-
}
|
|
83892
|
-
);
|
|
83893
|
-
if ((yield* foundLesson.isExplainer()) && readmeFile) {
|
|
83894
|
-
yield* logReadmeFile({ readmeFile });
|
|
83895
|
-
}
|
|
83896
|
-
});
|
|
83743
|
+
var RunLessonSimpleError = class extends Data_exports.TaggedError(
|
|
83744
|
+
"RunLessonSimpleError"
|
|
83745
|
+
) {
|
|
83746
|
+
};
|
|
83897
83747
|
var notFound2 = Symbol("notFound");
|
|
83898
83748
|
var getNumberFromPathSegment = (path11) => {
|
|
83899
83749
|
const numberSegment = path11.split("-")[0];
|