@h3ravel/musket 2.2.7 → 2.2.8

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
@@ -23,7 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  let _h3ravel_shared = require("@h3ravel/shared");
25
25
  let commander = require("commander");
26
- let tsdown = require("tsdown");
27
26
  let glob = require("glob");
28
27
  let node_path = require("node:path");
29
28
  node_path = __toESM(node_path, 1);
@@ -1420,13 +1419,22 @@ var Musket = class Musket {
1420
1419
  return this.program;
1421
1420
  }
1422
1421
  async rebuild(name) {
1423
- if (name !== "fire" && name !== "build" && this.config.allowRebuilds) await (0, tsdown.build)({
1422
+ if (name !== "fire" && name !== "build" && this.config.allowRebuilds) await (await this.resolveTsdownBuild())({
1424
1423
  ...this.tsDownConfig,
1425
1424
  logLevel: "silent",
1426
1425
  watch: false,
1427
1426
  plugins: []
1428
1427
  });
1429
1428
  }
1429
+ async resolveTsdownBuild() {
1430
+ try {
1431
+ const module = await import("tsdown");
1432
+ if (typeof module.build === "function") return module.build;
1433
+ } catch (cause) {
1434
+ throw new Error("Musket rebuilds require the optional \"tsdown\" package. Install it in your application to use allowRebuilds.", { cause });
1435
+ }
1436
+ throw new Error("The installed \"tsdown\" package does not export a build function.");
1437
+ }
1430
1438
  makeOption(opt, cmd, parse, parent) {
1431
1439
  const description = opt.description?.replace(/\[(\w+)\]/g, (_, k) => parent?.[k] ?? `[${k}]`) ?? "";
1432
1440
  const type = opt.name.replaceAll("-", "");
package/dist/index.d.ts CHANGED
@@ -1,8 +1,13 @@
1
1
  import { ChoiceOrSeparatorArray, Choices, Logger, LoggerChalk, Prompts, Spinner } from "@h3ravel/shared";
2
2
  import { Argument, Command as Command$1 } from "commander";
3
- import { UserConfig } from "tsdown";
4
3
 
5
4
  //#region src/Contracts/ICommand.d.ts
5
+ /**
6
+ * Configuration forwarded to the optional tsdown integration when rebuilds
7
+ * are enabled. Musket deliberately keeps this structural so importing its
8
+ * public types does not require tsdown to be installed.
9
+ */
10
+ type MusketBuildConfig = object;
6
11
  type CommandOption = {
7
12
  name: string;
8
13
  shared?: boolean;
@@ -161,7 +166,7 @@ interface KernelConfig<A extends Application = Application> {
161
166
  /**
162
167
  * If we need to programmatically run the tsdown build command, we will use this config.
163
168
  */
164
- tsDownConfig?: UserConfig;
169
+ tsDownConfig?: MusketBuildConfig;
165
170
  /**
166
171
  * Packages that should show up up when the `-V` flag is passed
167
172
  */
@@ -872,7 +877,7 @@ declare class Musket<A extends Application = Application> {
872
877
  */
873
878
  private registeredKeys;
874
879
  private program;
875
- constructor(app: A, kernel: Kernel<A>, baseCommands?: Command<A>[], resolver?: CommandMethodResolver | undefined, tsDownConfig?: UserConfig);
880
+ constructor(app: A, kernel: Kernel<A>, baseCommands?: Command<A>[], resolver?: CommandMethodResolver | undefined, tsDownConfig?: MusketBuildConfig);
876
881
  build(): Promise<Command$1>;
877
882
  private loadBaseCommands;
878
883
  /**
@@ -970,6 +975,7 @@ declare class Musket<A extends Application = Application> {
970
975
  getRegisteredCommands(): ParsedCommand[];
971
976
  private initialize;
972
977
  rebuild(name: string): Promise<void>;
978
+ private resolveTsdownBuild;
973
979
  private makeOption;
974
980
  private handle;
975
981
  static parse<E extends boolean = false, A extends Application = Application>(kernel: Kernel<A>, config: KernelConfig<A>, returnExit?: E): Promise<E extends true ? number : Command$1>;
@@ -1008,4 +1014,4 @@ declare class Signature {
1008
1014
  static parseSignature<A extends Application = Application>(signature: string, commandClass: Command<A>): ParsedCommand<A>;
1009
1015
  }
1010
1016
  //#endregion
1011
- export { Application, ArgumentDefinition, Command, CommandMethodResolver, CommandOption, Kernel, KernelConfig, ModuleMeta, Musket, OptionDefinition, PackageMeta, ParsedCommand, Signature, SignatureBuilder, SignatureValue, TGeneric, VersionRenderHelpers, XGeneric };
1017
+ export { Application, ArgumentDefinition, Command, CommandMethodResolver, CommandOption, Kernel, KernelConfig, ModuleMeta, Musket, MusketBuildConfig, OptionDefinition, PackageMeta, ParsedCommand, Signature, SignatureBuilder, SignatureValue, TGeneric, VersionRenderHelpers, XGeneric };
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { FileSystem, Logger, Prompts, importFile } from "@h3ravel/shared";
2
2
  import { Argument, Command as Command$1, Option } from "commander";
3
- import { build } from "tsdown";
4
3
  import { glob } from "glob";
5
4
  import path from "node:path";
6
5
  import { createRequire } from "module";
@@ -1396,13 +1395,22 @@ var Musket = class Musket {
1396
1395
  return this.program;
1397
1396
  }
1398
1397
  async rebuild(name) {
1399
- if (name !== "fire" && name !== "build" && this.config.allowRebuilds) await build({
1398
+ if (name !== "fire" && name !== "build" && this.config.allowRebuilds) await (await this.resolveTsdownBuild())({
1400
1399
  ...this.tsDownConfig,
1401
1400
  logLevel: "silent",
1402
1401
  watch: false,
1403
1402
  plugins: []
1404
1403
  });
1405
1404
  }
1405
+ async resolveTsdownBuild() {
1406
+ try {
1407
+ const module = await import("tsdown");
1408
+ if (typeof module.build === "function") return module.build;
1409
+ } catch (cause) {
1410
+ throw new Error("Musket rebuilds require the optional \"tsdown\" package. Install it in your application to use allowRebuilds.", { cause });
1411
+ }
1412
+ throw new Error("The installed \"tsdown\" package does not export a build function.");
1413
+ }
1406
1414
  makeOption(opt, cmd, parse, parent) {
1407
1415
  const description = opt.description?.replace(/\[(\w+)\]/g, (_, k) => parent?.[k] ?? `[${k}]`) ?? "";
1408
1416
  const type = opt.name.replaceAll("-", "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/musket",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "description": "Musket CLI is a framework-agnostic CLI framework designed to allow you build artisan-like CLI apps and for use in the H3ravel framework.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -76,6 +76,14 @@
76
76
  "resolve-from": "^5.0.0",
77
77
  "tsx": "^4.20.5"
78
78
  },
79
+ "peerDependencies": {
80
+ "tsdown": "^0.22.2"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "tsdown": {
84
+ "optional": true
85
+ }
86
+ },
79
87
  "engines": {
80
88
  "node": "^20.19.0 || >=22.12.0"
81
89
  },