ai-hero-cli 0.0.24 → 0.0.25

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 +92 -74
  2. package/package.json +1 -1
package/bin.cjs CHANGED
@@ -5595,8 +5595,8 @@ ${ctx.indent}`;
5595
5595
  const vs0 = valueStr[0];
5596
5596
  const nl0 = valueStr.indexOf("\n");
5597
5597
  const hasNewline = nl0 !== -1;
5598
- const flow2 = ctx.inFlow ?? value5.flow ?? value5.items.length === 0;
5599
- if (hasNewline || !flow2) {
5598
+ const flow3 = ctx.inFlow ?? value5.flow ?? value5.items.length === 0;
5599
+ if (hasNewline || !flow3) {
5600
5600
  let hasPropsLine = false;
5601
5601
  if (hasNewline && (vs0 === "&" || vs0 === "!")) {
5602
5602
  let sp0 = valueStr.indexOf(" ");
@@ -5814,8 +5814,8 @@ var require_stringifyCollection = __commonJS({
5814
5814
  var stringify2 = require_stringify();
5815
5815
  var stringifyComment = require_stringifyComment();
5816
5816
  function stringifyCollection(collection, ctx, options3) {
5817
- const flow2 = ctx.inFlow ?? collection.flow;
5818
- const stringify3 = flow2 ? stringifyFlowCollection : stringifyBlockCollection;
5817
+ const flow3 = ctx.inFlow ?? collection.flow;
5818
+ const stringify3 = flow3 ? stringifyFlowCollection : stringifyBlockCollection;
5819
5819
  return stringify3(collection, ctx, options3);
5820
5820
  }
5821
5821
  function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
@@ -7426,7 +7426,7 @@ var require_Document = __commonJS({
7426
7426
  options3 = replacer;
7427
7427
  replacer = void 0;
7428
7428
  }
7429
- const { aliasDuplicateObjects, anchorPrefix, flow: flow2, keepUndefined, onTagObj, tag: tag4 } = options3 ?? {};
7429
+ const { aliasDuplicateObjects, anchorPrefix, flow: flow3, keepUndefined, onTagObj, tag: tag4 } = options3 ?? {};
7430
7430
  const { onAnchor, setAnchors, sourceObjects } = anchors.createNodeAnchors(
7431
7431
  this,
7432
7432
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
@@ -7442,7 +7442,7 @@ var require_Document = __commonJS({
7442
7442
  sourceObjects
7443
7443
  };
7444
7444
  const node = createNode.createNode(value5, tag4, ctx);
7445
- if (flow2 && identity3.isCollection(node))
7445
+ if (flow3 && identity3.isCollection(node))
7446
7446
  node.flow = true;
7447
7447
  setAnchors();
7448
7448
  return node;
@@ -7688,7 +7688,7 @@ ${pointer}
7688
7688
  // node_modules/.pnpm/yaml@2.8.1/node_modules/yaml/dist/compose/resolve-props.js
7689
7689
  var require_resolve_props = __commonJS({
7690
7690
  "node_modules/.pnpm/yaml@2.8.1/node_modules/yaml/dist/compose/resolve-props.js"(exports) {
7691
- function resolveProps(tokens, { flow: flow2, indicator, next, offset, onError: onError4, parentIndent, startOnNewline }) {
7691
+ function resolveProps(tokens, { flow: flow3, indicator, next, offset, onError: onError4, parentIndent, startOnNewline }) {
7692
7692
  let spaceBefore = false;
7693
7693
  let atNewline = startOnNewline;
7694
7694
  let hasSpace = startOnNewline;
@@ -7717,7 +7717,7 @@ var require_resolve_props = __commonJS({
7717
7717
  }
7718
7718
  switch (token.type) {
7719
7719
  case "space":
7720
- if (!flow2 && (indicator !== "doc-start" || next?.type !== "flow-collection") && token.source.includes(" ")) {
7720
+ if (!flow3 && (indicator !== "doc-start" || next?.type !== "flow-collection") && token.source.includes(" ")) {
7721
7721
  tab = token;
7722
7722
  }
7723
7723
  hasSpace = true;
@@ -7773,15 +7773,15 @@ var require_resolve_props = __commonJS({
7773
7773
  if (anchor || tag4)
7774
7774
  onError4(token, "BAD_PROP_ORDER", `Anchors and tags must be after the ${token.source} indicator`);
7775
7775
  if (found)
7776
- onError4(token, "UNEXPECTED_TOKEN", `Unexpected ${token.source} in ${flow2 ?? "collection"}`);
7776
+ onError4(token, "UNEXPECTED_TOKEN", `Unexpected ${token.source} in ${flow3 ?? "collection"}`);
7777
7777
  found = token;
7778
7778
  atNewline = indicator === "seq-item-ind" || indicator === "explicit-key-ind";
7779
7779
  hasSpace = false;
7780
7780
  break;
7781
7781
  case "comma":
7782
- if (flow2) {
7782
+ if (flow3) {
7783
7783
  if (comma3)
7784
- onError4(token, "UNEXPECTED_TOKEN", `Unexpected , in ${flow2}`);
7784
+ onError4(token, "UNEXPECTED_TOKEN", `Unexpected , in ${flow3}`);
7785
7785
  comma3 = token;
7786
7786
  atNewline = false;
7787
7787
  hasSpace = false;
@@ -42031,7 +42031,7 @@ var require_lodash = __commonJS({
42031
42031
  function defaultTo(value5, defaultValue) {
42032
42032
  return value5 == null || value5 !== value5 ? defaultValue : value5;
42033
42033
  }
42034
- var flow2 = createFlow();
42034
+ var flow3 = createFlow();
42035
42035
  var flowRight = createFlow(true);
42036
42036
  function identity3(value5) {
42037
42037
  return value5;
@@ -42231,7 +42231,7 @@ var require_lodash = __commonJS({
42231
42231
  lodash.flattenDeep = flattenDeep;
42232
42232
  lodash.flattenDepth = flattenDepth;
42233
42233
  lodash.flip = flip3;
42234
- lodash.flow = flow2;
42234
+ lodash.flow = flow3;
42235
42235
  lodash.flowRight = flowRight;
42236
42236
  lodash.fromPairs = fromPairs;
42237
42237
  lodash.functions = functions;
@@ -84350,11 +84350,7 @@ var ImageUploadError = class extends Data_exports.TaggedError(
84350
84350
  var uploadToCloudinary = Command_exports2.make(
84351
84351
  "upload-to-cloudinary",
84352
84352
  {
84353
- filePath: Options_exports.text("file-path").pipe(
84354
- Options_exports.withDescription(
84355
- "The markdown file to extract images from"
84356
- )
84357
- ),
84353
+ root: rootOption,
84358
84354
  cwd: Options_exports.text("cwd").pipe(
84359
84355
  Options_exports.withDescription("The working directory"),
84360
84356
  Options_exports.withDefault(process.cwd())
@@ -84364,7 +84360,7 @@ var uploadToCloudinary = Command_exports2.make(
84364
84360
  Effect_exports.fn("upload-to-cloudinary")(function* ({
84365
84361
  cwd,
84366
84362
  envFilePath,
84367
- filePath
84363
+ root
84368
84364
  }) {
84369
84365
  const fs = yield* FileSystem_exports.FileSystem;
84370
84366
  const envConfig = dotenv.config({
@@ -84394,66 +84390,87 @@ var uploadToCloudinary = Command_exports2.make(
84394
84390
  api_secret: apiSecret,
84395
84391
  cloud_name: cloudName
84396
84392
  });
84397
- const fileContent5 = yield* fs.readFileString(filePath);
84398
- const imageRegex = /!\[([^\]]*)\]\(([^)]+)\)/g;
84399
- const imageMatches = Array.from(
84400
- fileContent5.matchAll(imageRegex)
84401
- );
84402
- if (imageMatches.length === 0) {
84403
- return yield* new NoImagesFoundError({
84404
- message: "No images found in the markdown file"
84405
- });
84393
+ const lessonParserService = yield* LessonParserService;
84394
+ const lessons = yield* lessonParserService.getLessonsFromRepo(root);
84395
+ const readmeFiles = [];
84396
+ for (const lesson of lessons) {
84397
+ const allFiles = yield* lesson.allFiles();
84398
+ const foundReadmes = allFiles.filter(
84399
+ (file6) => file6.includes("readme.md")
84400
+ );
84401
+ for (const readmeFile of foundReadmes) {
84402
+ readmeFiles.push(readmeFile);
84403
+ }
84406
84404
  }
84407
- let updatedContent = fileContent5;
84408
- const markdownDir = path4__namespace.dirname(filePath);
84409
- for (const [fullMatch, altText, imagePath] of imageMatches) {
84410
- let resolvedImagePath;
84411
- if (imagePath.startsWith("/")) {
84412
- resolvedImagePath = path4__namespace.resolve(
84413
- cwd,
84414
- // Remove the leading slash
84415
- imagePath.slice(1)
84416
- );
84417
- } else if (imagePath.startsWith("http")) {
84418
- continue;
84419
- } else {
84420
- resolvedImagePath = path4__namespace.resolve(markdownDir, imagePath);
84405
+ for (const readmeFile of readmeFiles) {
84406
+ const fileContent5 = yield* fs.readFileString(readmeFile);
84407
+ const imageRegex = /!\[([^\]]*)\]\(([^)]+)\)/g;
84408
+ const imageMatches = Array.from(
84409
+ fileContent5.matchAll(imageRegex)
84410
+ );
84411
+ if (imageMatches.length === 0) {
84412
+ return yield* new NoImagesFoundError({
84413
+ message: "No images found in the markdown file"
84414
+ });
84421
84415
  }
84422
- const imageExists = yield* fs.exists(resolvedImagePath);
84423
- if (!imageExists) {
84416
+ let updatedContent = fileContent5;
84417
+ const markdownDir = path4__namespace.dirname(readmeFile);
84418
+ for (const [
84419
+ fullMatch,
84420
+ altText,
84421
+ imagePath
84422
+ ] of imageMatches) {
84423
+ let resolvedImagePath;
84424
+ if (imagePath.startsWith("/")) {
84425
+ resolvedImagePath = path4__namespace.resolve(
84426
+ cwd,
84427
+ // Remove the leading slash
84428
+ imagePath.slice(1)
84429
+ );
84430
+ } else if (imagePath.startsWith("http")) {
84431
+ continue;
84432
+ } else {
84433
+ resolvedImagePath = path4__namespace.resolve(
84434
+ markdownDir,
84435
+ imagePath
84436
+ );
84437
+ }
84438
+ const imageExists = yield* fs.exists(resolvedImagePath);
84439
+ if (!imageExists) {
84440
+ yield* Console_exports.log(
84441
+ `Warning: Image file not found: ${resolvedImagePath}`
84442
+ );
84443
+ continue;
84444
+ }
84445
+ yield* Console_exports.log(`Uploading: ${resolvedImagePath}`);
84446
+ const uploadResult = yield* Effect_exports.tryPromise({
84447
+ try: () => {
84448
+ return import_cloudinary.v2.uploader.upload(
84449
+ resolvedImagePath,
84450
+ {
84451
+ resource_type: "auto",
84452
+ folder: "ai-hero-images"
84453
+ // Optional: organize uploads in a folder
84454
+ }
84455
+ );
84456
+ },
84457
+ catch: (error4) => {
84458
+ return new ImageUploadError({
84459
+ message: `Error uploading ${imagePath}`,
84460
+ cause: error4
84461
+ });
84462
+ }
84463
+ });
84464
+ updatedContent = updatedContent.replace(
84465
+ fullMatch,
84466
+ `![${altText}](${uploadResult.secure_url})`
84467
+ );
84424
84468
  yield* Console_exports.log(
84425
- `Warning: Image file not found: ${resolvedImagePath}`
84469
+ `\u2713 Uploaded: ${uploadResult.secure_url}`
84426
84470
  );
84427
- continue;
84428
84471
  }
84429
- yield* Console_exports.log(`Uploading: ${resolvedImagePath}`);
84430
- const uploadResult = yield* Effect_exports.tryPromise({
84431
- try: () => {
84432
- return import_cloudinary.v2.uploader.upload(resolvedImagePath, {
84433
- resource_type: "auto",
84434
- folder: "ai-hero-images"
84435
- // Optional: organize uploads in a folder
84436
- });
84437
- },
84438
- catch: (error4) => {
84439
- return new ImageUploadError({
84440
- message: `Error uploading ${imagePath}`,
84441
- cause: error4
84442
- });
84443
- }
84444
- });
84445
- updatedContent = updatedContent.replace(
84446
- fullMatch,
84447
- `![${altText}](${uploadResult.secure_url})`
84448
- );
84449
- yield* Console_exports.log(
84450
- `\u2713 Uploaded: ${uploadResult.secure_url}`
84451
- );
84472
+ yield* fs.writeFileString(readmeFile, updatedContent);
84452
84473
  }
84453
- yield* fs.writeFileString(filePath, updatedContent);
84454
- yield* Console_exports.log(
84455
- "\u2713 Markdown file updated with Cloudinary URLs"
84456
- );
84457
84474
  })
84458
84475
  ).pipe(
84459
84476
  Command_exports2.withDescription(
@@ -84501,7 +84518,8 @@ var upgradePackages = Command_exports2.make(
84501
84518
  "upgrade",
84502
84519
  "ai@latest",
84503
84520
  "@ai-sdk/*@latest",
84504
- "ai-hero-cli@latest"
84521
+ "ai-hero-cli@latest",
84522
+ "evalite@latest"
84505
84523
  ).pipe(
84506
84524
  verbose ? Command_exports.stdout("inherit") : Command_exports.stdout("pipe"),
84507
84525
  verbose ? Command_exports.stderr("inherit") : Command_exports.stderr("pipe"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hero-cli",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "description": "The CLI used to run exercises for the AI Hero course",
6
6
  "bin": "bin.cjs",