@rune-cli/rune 0.0.3 → 0.0.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +15 -4
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -5,6 +5,9 @@ import { build } from "esbuild";
5
5
  import { cp, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import ts from "typescript";
8
+ //#region package.json
9
+ var version = "0.0.5";
10
+ //#endregion
8
11
  //#region src/manifest/generate-manifest.ts
9
12
  const COMMAND_ENTRY_FILE = "index.ts";
10
13
  function comparePathSegments(left, right) {
@@ -132,7 +135,7 @@ async function assertCommandsDirectoryExists(commandsDirectory) {
132
135
  if (!(await stat(commandsDirectory).catch((error) => {
133
136
  if (error.code === "ENOENT") return;
134
137
  throw error;
135
- }))?.isDirectory()) throw new Error(`Commands directory not found: ${commandsDirectory}`);
138
+ }))?.isDirectory()) throw new Error(`Commands directory not found at ${COMMANDS_DIRECTORY_NAME}. Create it or check the --project <path> option.`);
136
139
  }
137
140
  //#endregion
138
141
  //#region src/cli/build-command.ts
@@ -407,7 +410,7 @@ function tryParseProjectOption(argv, index) {
407
410
  };
408
411
  if (token === "--project") {
409
412
  const nextToken = argv[index + 1];
410
- if (!nextToken) return failureResult("Missing value for --project");
413
+ if (!nextToken) return failureResult("Missing value for --project. Usage: --project <path>");
411
414
  return {
412
415
  projectPath: nextToken,
413
416
  nextIndex: index + 2
@@ -417,6 +420,12 @@ function tryParseProjectOption(argv, index) {
417
420
  function isHelpFlag(token) {
418
421
  return token === "--help" || token === "-h";
419
422
  }
423
+ function isVersionFlag(token) {
424
+ return token === "--version" || token === "-V";
425
+ }
426
+ function getRuneVersion() {
427
+ return version;
428
+ }
420
429
  function parseDevArgs(argv) {
421
430
  const commandArgs = [];
422
431
  let projectPath;
@@ -473,12 +482,14 @@ Commands:
473
482
  dev Run a Rune project in development mode
474
483
 
475
484
  Options:
476
- -h, --help Show this help message
485
+ -h, --help Show this help message
486
+ -V, --version Show the version number
477
487
  `;
478
488
  }
479
489
  async function runRuneCli(options) {
480
490
  const [subcommand, ...restArgs] = options.argv;
481
491
  if (!subcommand || isHelpFlag(subcommand)) return successResult(renderRuneCliHelp());
492
+ if (isVersionFlag(subcommand)) return successResult(`rune v${getRuneVersion()}\n`);
482
493
  if (subcommand === "dev") {
483
494
  const parsedDevArgs = parseDevArgs(restArgs);
484
495
  if ("exitCode" in parsedDevArgs) return parsedDevArgs;
@@ -496,7 +507,7 @@ async function runRuneCli(options) {
496
507
  cwd: options.cwd
497
508
  });
498
509
  }
499
- return failureResult(`Unknown rune command: ${subcommand}`);
510
+ return failureResult(`Unknown command: ${subcommand}. Available commands: build, dev`);
500
511
  }
501
512
  //#endregion
502
513
  //#region src/cli.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rune-cli/rune",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Rune is a CLI framework built around the concept of file-based command routing.",
5
5
  "homepage": "https://github.com/morinokami/rune#readme",
6
6
  "bugs": {