@optique/discover 1.2.0-dev.2255 → 1.2.0-dev.2261

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/cli.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  const require_chunk = require('./chunk-CUT6urMc.cjs');
3
- require('./command-C9u5sJZS.cjs');
4
- require('./src-CzbbFDmi.cjs');
5
- const require_generator = require('./generator-DW4rrPD2.cjs');
3
+ require('./command-C-NgG0KJ.cjs');
4
+ require('./src-C3_a7SFM.cjs');
5
+ const require_generator = require('./generator-CkGpilfc.cjs');
6
6
  const require_main_check = require('./main-check-CwunSNpK.cjs');
7
7
  const __optique_core_constructs = require_chunk.__toESM(require("@optique/core/constructs"));
8
8
  const __optique_core_message = require_chunk.__toESM(require("@optique/core/message"));
@@ -15,7 +15,7 @@ const node_process = require_chunk.__toESM(require("node:process"));
15
15
 
16
16
  //#region deno.json
17
17
  var name = "@optique/discover";
18
- var version = "1.2.0-dev.2255+a902c666";
18
+ var version = "1.2.0-dev.2261+cc03d22d";
19
19
  var license = "MIT";
20
20
  var exports$1 = {
21
21
  ".": "./src/index.ts",
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import "./command-DSHIV50v.js";
3
- import "./src-CVATvqru.js";
4
- import { watchCommandsModule, writeCommandsModule } from "./generator-HNXr5Vz2.js";
2
+ import "./command-9sgrJtwh.js";
3
+ import "./src-wHLRsXWK.js";
4
+ import { watchCommandsModule, writeCommandsModule } from "./generator-B8UY7n7b.js";
5
5
  import { isMainModuleUrl } from "./main-check-mMnKfUZs.js";
6
6
  import { object } from "@optique/core/constructs";
7
7
  import { message } from "@optique/core/message";
@@ -14,7 +14,7 @@ import process from "node:process";
14
14
 
15
15
  //#region deno.json
16
16
  var name = "@optique/discover";
17
- var version = "1.2.0-dev.2255+a902c666";
17
+ var version = "1.2.0-dev.2261+cc03d22d";
18
18
  var license = "MIT";
19
19
  var exports = {
20
20
  ".": "./src/index.ts",
@@ -32,6 +32,7 @@ function isCommand(value) {
32
32
  * @internal
33
33
  */
34
34
  function validateHooks(hooks, scope) {
35
+ if (Array.isArray(hooks)) throw new TypeError(`${scope} hooks must be an object, not an array.`);
35
36
  if (typeof hooks !== "object" || hooks == null) throw new TypeError(`${scope} hooks must be an object.`);
36
37
  for (const name of [
37
38
  "beforeEach",
@@ -33,6 +33,7 @@ function isCommand(value) {
33
33
  * @internal
34
34
  */
35
35
  function validateHooks(hooks, scope) {
36
+ if (Array.isArray(hooks)) throw new TypeError(`${scope} hooks must be an object, not an array.`);
36
37
  if (typeof hooks !== "object" || hooks == null) throw new TypeError(`${scope} hooks must be an object.`);
37
38
  for (const name of [
38
39
  "beforeEach",
@@ -104,13 +104,15 @@ interface ProgramHooks {
104
104
  *
105
105
  * The returned {@link ProgramHookContext} is threaded forward as the second
106
106
  * argument to the command handler (when this is the most specific hook scope)
107
- * and to {@link afterEach} and {@link onError}.
107
+ * and to {@link afterEach} and {@link onError}. Returning a context is
108
+ * optional: omit the return or return `null`, and an empty context is
109
+ * threaded forward instead.
108
110
  *
109
111
  * Returning a promise is supported; the dispatcher awaits it. A rejected
110
112
  * promise (or a thrown error) aborts the command before the handler runs and
111
113
  * invokes {@link onError}.
112
114
  */
113
- readonly beforeEach?: (invocation: ProgramInvocation) => ProgramHookContext | Promise<ProgramHookContext>;
115
+ readonly beforeEach?: (invocation: ProgramInvocation) => ProgramHookContext | null | void | Promise<ProgramHookContext | null | void>;
114
116
  /**
115
117
  * Called after the handler returns successfully, receiving the context from
116
118
  * {@link beforeEach} (or an empty object when no `beforeEach` ran) and the
@@ -104,13 +104,15 @@ interface ProgramHooks {
104
104
  *
105
105
  * The returned {@link ProgramHookContext} is threaded forward as the second
106
106
  * argument to the command handler (when this is the most specific hook scope)
107
- * and to {@link afterEach} and {@link onError}.
107
+ * and to {@link afterEach} and {@link onError}. Returning a context is
108
+ * optional: omit the return or return `null`, and an empty context is
109
+ * threaded forward instead.
108
110
  *
109
111
  * Returning a promise is supported; the dispatcher awaits it. A rejected
110
112
  * promise (or a thrown error) aborts the command before the handler runs and
111
113
  * invokes {@link onError}.
112
114
  */
113
- readonly beforeEach?: (invocation: ProgramInvocation) => ProgramHookContext | Promise<ProgramHookContext>;
115
+ readonly beforeEach?: (invocation: ProgramInvocation) => ProgramHookContext | null | void | Promise<ProgramHookContext | null | void>;
114
116
  /**
115
117
  * Called after the handler returns successfully, receiving the context from
116
118
  * {@link beforeEach} (or an empty object when no `beforeEach` ran) and the
package/dist/command.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_command = require('./command-C9u5sJZS.cjs');
1
+ const require_command = require('./command-C-NgG0KJ.cjs');
2
2
 
3
3
  exports.defineCommand = require_command.defineCommand;
4
4
  exports.isCommand = require_command.isCommand;
@@ -1,2 +1,2 @@
1
- import { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand, validateHooks } from "./command-DIfnalpt.cjs";
1
+ import { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand, validateHooks } from "./command-Dvg452tU.cjs";
2
2
  export { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand, validateHooks };
package/dist/command.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand, validateHooks } from "./command-s80EaEXl.js";
1
+ import { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand, validateHooks } from "./command-egqHCvDL.js";
2
2
  export { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand, validateHooks };
package/dist/command.js CHANGED
@@ -1,3 +1,3 @@
1
- import { defineCommand, isCommand, validateHooks } from "./command-DSHIV50v.js";
1
+ import { defineCommand, isCommand, validateHooks } from "./command-9sgrJtwh.js";
2
2
 
3
3
  export { defineCommand, isCommand, validateHooks };
@@ -1,4 +1,4 @@
1
- import { getDefaultExtensions } from "./src-CVATvqru.js";
1
+ import { getDefaultExtensions } from "./src-wHLRsXWK.js";
2
2
  import { mkdir, readdir, realpath, stat, writeFile } from "node:fs/promises";
3
3
  import { dirname, posix, relative, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_src = require('./src-CzbbFDmi.cjs');
2
+ const require_src = require('./src-C3_a7SFM.cjs');
3
3
  const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
4
4
  const node_path = require_chunk.__toESM(require("node:path"));
5
5
  const node_url = require_chunk.__toESM(require("node:url"));
@@ -1,6 +1,6 @@
1
- require('./command-C9u5sJZS.cjs');
2
- require('./src-CzbbFDmi.cjs');
3
- const require_generator = require('./generator-DW4rrPD2.cjs');
1
+ require('./command-C-NgG0KJ.cjs');
2
+ require('./src-C3_a7SFM.cjs');
3
+ const require_generator = require('./generator-CkGpilfc.cjs');
4
4
 
5
5
  exports.generateCommandsModule = require_generator.generateCommandsModule;
6
6
  exports.watchCommandsModule = require_generator.watchCommandsModule;
package/dist/generator.js CHANGED
@@ -1,5 +1,5 @@
1
- import "./command-DSHIV50v.js";
2
- import "./src-CVATvqru.js";
3
- import { generateCommandsModule, watchCommandsModule, writeCommandsModule } from "./generator-HNXr5Vz2.js";
1
+ import "./command-9sgrJtwh.js";
2
+ import "./src-wHLRsXWK.js";
3
+ import { generateCommandsModule, watchCommandsModule, writeCommandsModule } from "./generator-B8UY7n7b.js";
4
4
 
5
5
  export { generateCommandsModule, watchCommandsModule, writeCommandsModule };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- const require_command = require('./command-C9u5sJZS.cjs');
2
- const require_src = require('./src-CzbbFDmi.cjs');
1
+ const require_command = require('./command-C-NgG0KJ.cjs');
2
+ const require_src = require('./src-C3_a7SFM.cjs');
3
3
 
4
4
  exports.commandsFromModules = require_src.commandsFromModules;
5
5
  exports.createProgramParser = require_src.createProgramParser;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand } from "./command-DIfnalpt.cjs";
1
+ import { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand } from "./command-Dvg452tU.cjs";
2
2
  import { Mode } from "@optique/core/parser";
3
3
  import { FluentParser } from "@optique/core/fluent";
4
4
  import { Message } from "@optique/core/message";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand } from "./command-s80EaEXl.js";
1
+ import { AnyCommand, AnyStaticCommand, Command, CommandDefinition, CommandMetadata, CommandPath, ProgramHookContext, ProgramHooks, ProgramInvocation, StaticCommand, defineCommand, isCommand } from "./command-egqHCvDL.js";
2
2
  import { Message } from "@optique/core/message";
3
3
  import { ProgramMetadata } from "@optique/core/program";
4
4
  import { RunOptions } from "@optique/run";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineCommand, isCommand } from "./command-DSHIV50v.js";
2
- import { commandsFromModules, createProgramParser, discoverCommands, getDefaultExtensions, runProgram } from "./src-CVATvqru.js";
1
+ import { defineCommand, isCommand } from "./command-9sgrJtwh.js";
2
+ import { commandsFromModules, createProgramParser, discoverCommands, getDefaultExtensions, runProgram } from "./src-wHLRsXWK.js";
3
3
 
4
4
  export { commandsFromModules, createProgramParser, defineCommand, discoverCommands, getDefaultExtensions, isCommand, runProgram };
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_command = require('./command-C9u5sJZS.cjs');
2
+ const require_command = require('./command-C-NgG0KJ.cjs');
3
3
  const __optique_core_constructs = require_chunk.__toESM(require("@optique/core/constructs"));
4
4
  const __optique_core_modifiers = require_chunk.__toESM(require("@optique/core/modifiers"));
5
5
  const __optique_core_primitives = require_chunk.__toESM(require("@optique/core/primitives"));
@@ -200,7 +200,7 @@ async function dispatchInvocation(invocation, programHooks) {
200
200
  async function runHookScope(hooks, invocation, inner) {
201
201
  let context = {};
202
202
  try {
203
- if (hooks?.beforeEach != null) context = await hooks.beforeEach(invocation);
203
+ if (hooks?.beforeEach != null) context = await hooks.beforeEach(invocation) ?? {};
204
204
  const result = await inner(context);
205
205
  if (hooks?.afterEach != null) await hooks.afterEach(context, result);
206
206
  return result;
@@ -1,4 +1,4 @@
1
- import { isCommand, validateHooks } from "./command-DSHIV50v.js";
1
+ import { isCommand, validateHooks } from "./command-9sgrJtwh.js";
2
2
  import { longestMatch, or } from "@optique/core/constructs";
3
3
  import { map } from "@optique/core/modifiers";
4
4
  import { command } from "@optique/core/primitives";
@@ -199,7 +199,7 @@ async function dispatchInvocation(invocation, programHooks) {
199
199
  async function runHookScope(hooks, invocation, inner) {
200
200
  let context = {};
201
201
  try {
202
- if (hooks?.beforeEach != null) context = await hooks.beforeEach(invocation);
202
+ if (hooks?.beforeEach != null) context = await hooks.beforeEach(invocation) ?? {};
203
203
  const result = await inner(context);
204
204
  if (hooks?.afterEach != null) await hooks.afterEach(context, result);
205
205
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/discover",
3
- "version": "1.2.0-dev.2255",
3
+ "version": "1.2.0-dev.2261",
4
4
  "description": "Runtime-aware command discovery for Optique CLI programs",
5
5
  "keywords": [
6
6
  "CLI",
@@ -83,8 +83,8 @@
83
83
  "optique-discover": "./dist/cli.js"
84
84
  },
85
85
  "dependencies": {
86
- "@optique/core": "1.2.0-dev.2255+a902c666",
87
- "@optique/run": "1.2.0-dev.2255+a902c666"
86
+ "@optique/core": "1.2.0-dev.2261+cc03d22d",
87
+ "@optique/run": "1.2.0-dev.2261+cc03d22d"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@types/node": "^24.0.0",