alex-c-line 2.2.4 → 2.2.5

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/index.cjs CHANGED
@@ -377,34 +377,62 @@ function gitPostMergeCleanup(program) {
377
377
  });
378
378
  }
379
379
  //#endregion
380
+ //#region src/utility/constants/warningPrefix.ts
381
+ const warningPrefix = "WARNING:";
382
+ //#endregion
383
+ //#region src/utility/fileSystem/readdirSafe.ts
384
+ async function readdirSafe(path) {
385
+ try {
386
+ return await (0, node_fs_promises.readdir)(path, { withFileTypes: true });
387
+ } catch (error) {
388
+ if (error instanceof Error && "code" in error && error.code === "ENOTDIR") return;
389
+ throw error;
390
+ }
391
+ }
392
+ //#endregion
380
393
  //#region src/cli/commands/internal/media/generate.ts
381
394
  function internalMediaGenerate(program) {
382
- program.command("generate").argument("[directory]", "The directory to generate from", process.cwd()).option("--ignore <ignore>", "Extra directories to ignore as comma-separated list").action(async (directory, { ignore }) => {
395
+ program.command("generate").argument("[target]", "The directory to generate from", process.cwd()).option("--ignore <ignore>", "Extra directories to ignore as comma-separated list").action(async (target, { ignore }) => {
396
+ const ignored = new Set([
397
+ ".git",
398
+ "node_modules",
399
+ "__pycache__",
400
+ ".venv",
401
+ "helpers",
402
+ ...ignore ? ignore.split(",") : []
403
+ ]);
404
+ async function renderFile(file) {
405
+ const relativePath = node_path.default.relative(process.cwd(), file);
406
+ console.info(`Rendering ${relativePath}...`);
407
+ try {
408
+ return await (0, execa.execa)({
409
+ stdio: "inherit",
410
+ env: {
411
+ ...process.env,
412
+ PYTHONPATH: node_path.default.resolve("src")
413
+ }
414
+ })`manim -qh ${file}`;
415
+ } catch (error) {
416
+ if (error instanceof execa.ExecaError) program.error(`${errorPrefix} An error has occurred with Manim while rendering ${relativePath}.`, {
417
+ exitCode: error.exitCode ?? 1,
418
+ code: "MANIM_ERROR"
419
+ });
420
+ else throw error;
421
+ }
422
+ }
383
423
  async function readDirectory(directory) {
384
- const directoryContents = await (0, node_fs_promises.readdir)(directory, { withFileTypes: true });
385
- for (const entry of directoryContents) {
424
+ const entries = await readdirSafe(directory);
425
+ if (entries === void 0) return;
426
+ for (const entry of entries) {
386
427
  const fullPath = node_path.default.join(directory, entry.name);
387
- if (entry.isDirectory() && ![
388
- ".git",
389
- "node_modules",
390
- "__pycache__",
391
- ".venv",
392
- "helpers",
393
- ...[ignore?.split(",") ?? ""]
394
- ].includes(entry.name)) await readDirectory(fullPath);
395
- if (entry.isFile() && entry.name.endsWith(".py")) {
396
- console.info(`Rendering ${node_path.default.relative(process.cwd(), fullPath)}...`);
397
- await (0, execa.execa)({
398
- stdio: "inherit",
399
- env: {
400
- ...process.env,
401
- PYTHONPATH: node_path.default.resolve("src")
402
- }
403
- })`manim -qh ${fullPath}`;
404
- }
428
+ if (entry.isDirectory() && !ignored.has(entry.name)) await readDirectory(fullPath);
429
+ else if (entry.isFile() && entry.name.endsWith(".py")) await renderFile(fullPath);
405
430
  }
406
431
  }
407
- await readDirectory(directory);
432
+ const statResult = await (0, node_fs_promises.stat)(target);
433
+ if (statResult.isFile()) await renderFile(target);
434
+ else if (statResult.isDirectory()) await readDirectory(target);
435
+ else console.warn(`${warningPrefix} Not a file or directory.`);
408
436
  });
409
437
  }
410
438
  //#endregion
@@ -1207,7 +1235,7 @@ function template(program) {
1207
1235
  //#endregion
1208
1236
  //#region package.json
1209
1237
  var name = "alex-c-line";
1210
- var version$1 = "2.2.4";
1238
+ var version$1 = "2.2.5";
1211
1239
  var description = "Command-line tool with commands to streamline the developer workflow.";
1212
1240
  //#endregion
1213
1241
  //#region src/utility/updates/checkUpdate.ts
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import boxen from "boxen";
7
7
  import figlet from "figlet";
8
8
  import path from "node:path";
9
9
  import { createCanvas } from "canvas";
10
- import { access, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
10
+ import { access, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
11
11
  import envPaths from "env-paths";
12
12
  import { confirm, input, password, select } from "@inquirer/prompts";
13
13
  import { parse } from "dotenv";
@@ -346,34 +346,62 @@ function gitPostMergeCleanup(program) {
346
346
  });
347
347
  }
348
348
  //#endregion
349
+ //#region src/utility/constants/warningPrefix.ts
350
+ const warningPrefix = "WARNING:";
351
+ //#endregion
352
+ //#region src/utility/fileSystem/readdirSafe.ts
353
+ async function readdirSafe(path) {
354
+ try {
355
+ return await readdir(path, { withFileTypes: true });
356
+ } catch (error) {
357
+ if (error instanceof Error && "code" in error && error.code === "ENOTDIR") return;
358
+ throw error;
359
+ }
360
+ }
361
+ //#endregion
349
362
  //#region src/cli/commands/internal/media/generate.ts
350
363
  function internalMediaGenerate(program) {
351
- program.command("generate").argument("[directory]", "The directory to generate from", process.cwd()).option("--ignore <ignore>", "Extra directories to ignore as comma-separated list").action(async (directory, { ignore }) => {
364
+ program.command("generate").argument("[target]", "The directory to generate from", process.cwd()).option("--ignore <ignore>", "Extra directories to ignore as comma-separated list").action(async (target, { ignore }) => {
365
+ const ignored = new Set([
366
+ ".git",
367
+ "node_modules",
368
+ "__pycache__",
369
+ ".venv",
370
+ "helpers",
371
+ ...ignore ? ignore.split(",") : []
372
+ ]);
373
+ async function renderFile(file) {
374
+ const relativePath = path.relative(process.cwd(), file);
375
+ console.info(`Rendering ${relativePath}...`);
376
+ try {
377
+ return await execa({
378
+ stdio: "inherit",
379
+ env: {
380
+ ...process.env,
381
+ PYTHONPATH: path.resolve("src")
382
+ }
383
+ })`manim -qh ${file}`;
384
+ } catch (error) {
385
+ if (error instanceof ExecaError) program.error(`${errorPrefix} An error has occurred with Manim while rendering ${relativePath}.`, {
386
+ exitCode: error.exitCode ?? 1,
387
+ code: "MANIM_ERROR"
388
+ });
389
+ else throw error;
390
+ }
391
+ }
352
392
  async function readDirectory(directory) {
353
- const directoryContents = await readdir(directory, { withFileTypes: true });
354
- for (const entry of directoryContents) {
393
+ const entries = await readdirSafe(directory);
394
+ if (entries === void 0) return;
395
+ for (const entry of entries) {
355
396
  const fullPath = path.join(directory, entry.name);
356
- if (entry.isDirectory() && ![
357
- ".git",
358
- "node_modules",
359
- "__pycache__",
360
- ".venv",
361
- "helpers",
362
- ...[ignore?.split(",") ?? ""]
363
- ].includes(entry.name)) await readDirectory(fullPath);
364
- if (entry.isFile() && entry.name.endsWith(".py")) {
365
- console.info(`Rendering ${path.relative(process.cwd(), fullPath)}...`);
366
- await execa({
367
- stdio: "inherit",
368
- env: {
369
- ...process.env,
370
- PYTHONPATH: path.resolve("src")
371
- }
372
- })`manim -qh ${fullPath}`;
373
- }
397
+ if (entry.isDirectory() && !ignored.has(entry.name)) await readDirectory(fullPath);
398
+ else if (entry.isFile() && entry.name.endsWith(".py")) await renderFile(fullPath);
374
399
  }
375
400
  }
376
- await readDirectory(directory);
401
+ const statResult = await stat(target);
402
+ if (statResult.isFile()) await renderFile(target);
403
+ else if (statResult.isDirectory()) await readDirectory(target);
404
+ else console.warn(`${warningPrefix} Not a file or directory.`);
377
405
  });
378
406
  }
379
407
  //#endregion
@@ -1176,7 +1204,7 @@ function template(program) {
1176
1204
  //#endregion
1177
1205
  //#region package.json
1178
1206
  var name = "alex-c-line";
1179
- var version$1 = "2.2.4";
1207
+ var version$1 = "2.2.5";
1180
1208
  var description = "Command-line tool with commands to streamline the developer workflow.";
1181
1209
  //#endregion
1182
1210
  //#region src/utility/updates/checkUpdate.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alex-c-line",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "Command-line tool with commands to streamline the developer workflow.",
5
5
  "repository": {
6
6
  "type": "git",