@h3ravel/musket 0.5.0 → 0.5.2
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 +71 -8
- package/dist/index.d.ts +54 -5
- package/dist/index.js +71 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ let glob = require("glob");
|
|
|
28
28
|
let node_path = require("node:path");
|
|
29
29
|
node_path = __toESM(node_path);
|
|
30
30
|
let __h3ravel_support = require("@h3ravel/support");
|
|
31
|
+
let node_module = require("node:module");
|
|
31
32
|
let node_fs_promises = require("node:fs/promises");
|
|
32
33
|
|
|
33
34
|
//#region src/Core/Command.ts
|
|
@@ -843,11 +844,23 @@ var Musket = class Musket {
|
|
|
843
844
|
//#endregion
|
|
844
845
|
//#region src/Core/Kernel.ts
|
|
845
846
|
var Kernel = class Kernel {
|
|
847
|
+
/**
|
|
848
|
+
* The current working directory
|
|
849
|
+
*/
|
|
846
850
|
cwd;
|
|
847
851
|
output = typeof __h3ravel_shared.Logger;
|
|
848
852
|
modules = [];
|
|
853
|
+
/**
|
|
854
|
+
* The base path for the CLI app
|
|
855
|
+
*/
|
|
849
856
|
basePath = "";
|
|
857
|
+
/**
|
|
858
|
+
* Packages that should show up up when the -V flag is passed
|
|
859
|
+
*/
|
|
850
860
|
packages = [];
|
|
861
|
+
/**
|
|
862
|
+
* The CLI configuration options
|
|
863
|
+
*/
|
|
851
864
|
config = {};
|
|
852
865
|
constructor(app) {
|
|
853
866
|
this.app = app;
|
|
@@ -855,19 +868,69 @@ var Kernel = class Kernel {
|
|
|
855
868
|
async ensureDirectoryExists(dir) {
|
|
856
869
|
await (0, node_fs_promises.mkdir)(dir, { recursive: true });
|
|
857
870
|
}
|
|
871
|
+
/**
|
|
872
|
+
* Initialize Musket CLI
|
|
873
|
+
*
|
|
874
|
+
* @param app
|
|
875
|
+
* @param config
|
|
876
|
+
* @returns
|
|
877
|
+
*/
|
|
858
878
|
static async init(app, config = {}) {
|
|
859
|
-
|
|
860
|
-
instance.config = config;
|
|
861
|
-
instance.packages = config.packages ?? [];
|
|
862
|
-
return (await instance.loadRequirements()).run();
|
|
879
|
+
return await new Kernel(app).setConfig(config).setPackages(config.packages ?? []).bootstrap().run();
|
|
863
880
|
}
|
|
881
|
+
/**
|
|
882
|
+
* Run the CLI IO
|
|
883
|
+
*/
|
|
864
884
|
async run() {
|
|
865
885
|
return await Musket.parse(this, this.config);
|
|
866
886
|
}
|
|
867
|
-
|
|
868
|
-
|
|
887
|
+
/**
|
|
888
|
+
* Set the configuration for the CLI
|
|
889
|
+
*/
|
|
890
|
+
setConfig(config) {
|
|
891
|
+
this.config = config;
|
|
892
|
+
return this;
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Get the configuration for the CLI
|
|
896
|
+
*/
|
|
897
|
+
getConfig() {
|
|
898
|
+
return this.config;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Set the current working directory
|
|
902
|
+
*/
|
|
903
|
+
setCwd(cwd) {
|
|
904
|
+
this.cwd = cwd;
|
|
905
|
+
return this;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Get the current working directory
|
|
909
|
+
*/
|
|
910
|
+
getCwd() {
|
|
911
|
+
return this.cwd;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Set the packages that should show up up when the -V flag is passed
|
|
915
|
+
*/
|
|
916
|
+
setPackages(packages) {
|
|
917
|
+
this.packages = packages;
|
|
918
|
+
return this;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Get the packages that should show up up when the -V flag is passed
|
|
922
|
+
*/
|
|
923
|
+
getPackages() {
|
|
924
|
+
return this.packages;
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Bootstrap the CLI
|
|
928
|
+
*/
|
|
929
|
+
bootstrap() {
|
|
930
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
931
|
+
this.cwd ??= node_path.default.join(process.cwd(), this.basePath);
|
|
869
932
|
if (!this.config.hideMusketInfo) try {
|
|
870
|
-
const pkg = (
|
|
933
|
+
const pkg = require$1(node_path.default.join(process.cwd(), "package.json"));
|
|
871
934
|
pkg.name = this.config.cliName ?? pkg.name;
|
|
872
935
|
this.modules.push(pkg);
|
|
873
936
|
} catch {}
|
|
@@ -876,7 +939,7 @@ var Kernel = class Kernel {
|
|
|
876
939
|
const name = typeof item === "string" ? item : item.name;
|
|
877
940
|
const alias = typeof item === "string" ? item : item.alias;
|
|
878
941
|
const modulePath = __h3ravel_shared.FileSystem.findModulePkg(name, this.cwd) ?? "";
|
|
879
|
-
const pkg = (
|
|
942
|
+
const pkg = require$1(node_path.default.join(modulePath, "package.json"));
|
|
880
943
|
pkg.alias = alias;
|
|
881
944
|
this.modules.push(pkg);
|
|
882
945
|
} catch (e) {
|
package/dist/index.d.ts
CHANGED
|
@@ -118,20 +118,69 @@ interface InitConfig {
|
|
|
118
118
|
//#region src/Core/Kernel.d.ts
|
|
119
119
|
declare class Kernel<A extends Application = Application> {
|
|
120
120
|
app: A;
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* The current working directory
|
|
123
|
+
*/
|
|
124
|
+
private cwd;
|
|
122
125
|
output: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
123
126
|
modules: XGeneric<{
|
|
124
127
|
version: string;
|
|
125
128
|
name: string;
|
|
126
129
|
}>[];
|
|
130
|
+
/**
|
|
131
|
+
* The base path for the CLI app
|
|
132
|
+
*/
|
|
127
133
|
basePath: string;
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Packages that should show up up when the -V flag is passed
|
|
136
|
+
*/
|
|
137
|
+
private packages;
|
|
138
|
+
/**
|
|
139
|
+
* The CLI configuration options
|
|
140
|
+
*/
|
|
141
|
+
private config;
|
|
130
142
|
constructor(app: A);
|
|
131
143
|
ensureDirectoryExists(dir: string): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Initialize Musket CLI
|
|
146
|
+
*
|
|
147
|
+
* @param app
|
|
148
|
+
* @param config
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
132
151
|
static init<A extends Application>(app: A, config?: InitConfig): Promise<commander0.Command>;
|
|
133
|
-
|
|
134
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Run the CLI IO
|
|
154
|
+
*/
|
|
155
|
+
run(): Promise<commander0.Command>;
|
|
156
|
+
/**
|
|
157
|
+
* Set the configuration for the CLI
|
|
158
|
+
*/
|
|
159
|
+
setConfig(config: InitConfig): this;
|
|
160
|
+
/**
|
|
161
|
+
* Get the configuration for the CLI
|
|
162
|
+
*/
|
|
163
|
+
getConfig(): InitConfig;
|
|
164
|
+
/**
|
|
165
|
+
* Set the current working directory
|
|
166
|
+
*/
|
|
167
|
+
setCwd(cwd: string): this;
|
|
168
|
+
/**
|
|
169
|
+
* Get the current working directory
|
|
170
|
+
*/
|
|
171
|
+
getCwd(): string;
|
|
172
|
+
/**
|
|
173
|
+
* Set the packages that should show up up when the -V flag is passed
|
|
174
|
+
*/
|
|
175
|
+
setPackages(packages: NonNullable<InitConfig['packages']>): this;
|
|
176
|
+
/**
|
|
177
|
+
* Get the packages that should show up up when the -V flag is passed
|
|
178
|
+
*/
|
|
179
|
+
getPackages(): NonNullable<InitConfig['packages']>;
|
|
180
|
+
/**
|
|
181
|
+
* Bootstrap the CLI
|
|
182
|
+
*/
|
|
183
|
+
bootstrap(): this;
|
|
135
184
|
}
|
|
136
185
|
//#endregion
|
|
137
186
|
//#region src/Core/Command.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { FileSystem, Logger, Prompts } from "@h3ravel/shared";
|
|
2
3
|
import { Argument, Option, program } from "commander";
|
|
3
4
|
import { build } from "tsdown";
|
|
@@ -819,11 +820,23 @@ var Musket = class Musket {
|
|
|
819
820
|
//#endregion
|
|
820
821
|
//#region src/Core/Kernel.ts
|
|
821
822
|
var Kernel = class Kernel {
|
|
823
|
+
/**
|
|
824
|
+
* The current working directory
|
|
825
|
+
*/
|
|
822
826
|
cwd;
|
|
823
827
|
output = typeof Logger;
|
|
824
828
|
modules = [];
|
|
829
|
+
/**
|
|
830
|
+
* The base path for the CLI app
|
|
831
|
+
*/
|
|
825
832
|
basePath = "";
|
|
833
|
+
/**
|
|
834
|
+
* Packages that should show up up when the -V flag is passed
|
|
835
|
+
*/
|
|
826
836
|
packages = [];
|
|
837
|
+
/**
|
|
838
|
+
* The CLI configuration options
|
|
839
|
+
*/
|
|
827
840
|
config = {};
|
|
828
841
|
constructor(app) {
|
|
829
842
|
this.app = app;
|
|
@@ -831,19 +844,69 @@ var Kernel = class Kernel {
|
|
|
831
844
|
async ensureDirectoryExists(dir) {
|
|
832
845
|
await mkdir(dir, { recursive: true });
|
|
833
846
|
}
|
|
847
|
+
/**
|
|
848
|
+
* Initialize Musket CLI
|
|
849
|
+
*
|
|
850
|
+
* @param app
|
|
851
|
+
* @param config
|
|
852
|
+
* @returns
|
|
853
|
+
*/
|
|
834
854
|
static async init(app, config = {}) {
|
|
835
|
-
|
|
836
|
-
instance.config = config;
|
|
837
|
-
instance.packages = config.packages ?? [];
|
|
838
|
-
return (await instance.loadRequirements()).run();
|
|
855
|
+
return await new Kernel(app).setConfig(config).setPackages(config.packages ?? []).bootstrap().run();
|
|
839
856
|
}
|
|
857
|
+
/**
|
|
858
|
+
* Run the CLI IO
|
|
859
|
+
*/
|
|
840
860
|
async run() {
|
|
841
861
|
return await Musket.parse(this, this.config);
|
|
842
862
|
}
|
|
843
|
-
|
|
844
|
-
|
|
863
|
+
/**
|
|
864
|
+
* Set the configuration for the CLI
|
|
865
|
+
*/
|
|
866
|
+
setConfig(config) {
|
|
867
|
+
this.config = config;
|
|
868
|
+
return this;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Get the configuration for the CLI
|
|
872
|
+
*/
|
|
873
|
+
getConfig() {
|
|
874
|
+
return this.config;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Set the current working directory
|
|
878
|
+
*/
|
|
879
|
+
setCwd(cwd) {
|
|
880
|
+
this.cwd = cwd;
|
|
881
|
+
return this;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Get the current working directory
|
|
885
|
+
*/
|
|
886
|
+
getCwd() {
|
|
887
|
+
return this.cwd;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Set the packages that should show up up when the -V flag is passed
|
|
891
|
+
*/
|
|
892
|
+
setPackages(packages) {
|
|
893
|
+
this.packages = packages;
|
|
894
|
+
return this;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Get the packages that should show up up when the -V flag is passed
|
|
898
|
+
*/
|
|
899
|
+
getPackages() {
|
|
900
|
+
return this.packages;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Bootstrap the CLI
|
|
904
|
+
*/
|
|
905
|
+
bootstrap() {
|
|
906
|
+
const require = createRequire(import.meta.url);
|
|
907
|
+
this.cwd ??= path.join(process.cwd(), this.basePath);
|
|
845
908
|
if (!this.config.hideMusketInfo) try {
|
|
846
|
-
const pkg = (
|
|
909
|
+
const pkg = require(path.join(process.cwd(), "package.json"));
|
|
847
910
|
pkg.name = this.config.cliName ?? pkg.name;
|
|
848
911
|
this.modules.push(pkg);
|
|
849
912
|
} catch {}
|
|
@@ -852,7 +915,7 @@ var Kernel = class Kernel {
|
|
|
852
915
|
const name = typeof item === "string" ? item : item.name;
|
|
853
916
|
const alias = typeof item === "string" ? item : item.alias;
|
|
854
917
|
const modulePath = FileSystem.findModulePkg(name, this.cwd) ?? "";
|
|
855
|
-
const pkg = (
|
|
918
|
+
const pkg = require(path.join(modulePath, "package.json"));
|
|
856
919
|
pkg.alias = alias;
|
|
857
920
|
this.modules.push(pkg);
|
|
858
921
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/musket",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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",
|