@h3ravel/musket 0.3.12 → 0.5.0
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/README.md +26 -0
- package/dist/index.d.ts +10 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,6 +73,32 @@ Kernel.init(app, {
|
|
|
73
73
|
});
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
### Advanced Initialization
|
|
77
|
+
|
|
78
|
+
You can also initialize **Musket CLI** with precise controls
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { Kernel } from 'h3ravel/musket';
|
|
82
|
+
|
|
83
|
+
const app = new Application();
|
|
84
|
+
|
|
85
|
+
const instance = new Kernel(app)
|
|
86
|
+
.setCwd(process.cwd())
|
|
87
|
+
.setConfig({
|
|
88
|
+
cliName: 'musket-cli',
|
|
89
|
+
discoveryPaths: [path.join(process.cwd(), 'tests/Commands/*.ts')],
|
|
90
|
+
})
|
|
91
|
+
.setPackages([
|
|
92
|
+
{ name: '@h3ravel/shared', alias: 'Shared PKG' },
|
|
93
|
+
'@h3ravel/support',
|
|
94
|
+
])
|
|
95
|
+
.bootstrap();
|
|
96
|
+
|
|
97
|
+
return await instance.run();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
> NB: Packages in the config will be ignored when initializing in this way, as a work around, chain the `setPackages` method to the Kernel intance and pass your options
|
|
101
|
+
|
|
76
102
|
## Creating Commands
|
|
77
103
|
|
|
78
104
|
Commands in Musket extend the base `Command` class and define a **signature** and **handle()** method.
|
package/dist/index.d.ts
CHANGED
|
@@ -116,8 +116,8 @@ interface InitConfig {
|
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/Core/Kernel.d.ts
|
|
119
|
-
declare class Kernel {
|
|
120
|
-
app:
|
|
119
|
+
declare class Kernel<A extends Application = Application> {
|
|
120
|
+
app: A;
|
|
121
121
|
cwd: string;
|
|
122
122
|
output: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
123
123
|
modules: XGeneric<{
|
|
@@ -127,18 +127,18 @@ declare class Kernel {
|
|
|
127
127
|
basePath: string;
|
|
128
128
|
packages: NonNullable<InitConfig['packages']>;
|
|
129
129
|
config: InitConfig;
|
|
130
|
-
constructor(app:
|
|
130
|
+
constructor(app: A);
|
|
131
131
|
ensureDirectoryExists(dir: string): Promise<void>;
|
|
132
|
-
static init(app:
|
|
132
|
+
static init<A extends Application>(app: A, config?: InitConfig): Promise<commander0.Command>;
|
|
133
133
|
private run;
|
|
134
134
|
private loadRequirements;
|
|
135
135
|
}
|
|
136
136
|
//#endregion
|
|
137
137
|
//#region src/Core/Command.d.ts
|
|
138
|
-
declare class Command {
|
|
139
|
-
protected app:
|
|
140
|
-
protected kernel: Kernel
|
|
141
|
-
constructor(app:
|
|
138
|
+
declare class Command<A extends Application = Application> {
|
|
139
|
+
protected app: A;
|
|
140
|
+
protected kernel: Kernel<A>;
|
|
141
|
+
constructor(app: A, kernel: Kernel<A>);
|
|
142
142
|
/**
|
|
143
143
|
* The underlying commander instance.
|
|
144
144
|
*
|
|
@@ -173,7 +173,7 @@ declare class Command {
|
|
|
173
173
|
* Execute the console command.
|
|
174
174
|
*/
|
|
175
175
|
handle(..._args: any[]): Promise<void>;
|
|
176
|
-
setApplication(app:
|
|
176
|
+
setApplication(app: A): void;
|
|
177
177
|
setInput(options: XGeneric, args: string[], regArgs: readonly Argument[], dictionary: Record<string, any>, program: Command$1): this;
|
|
178
178
|
setOption(key: string, value: unknown): this;
|
|
179
179
|
setProgram(program: Command$1): this;
|
|
@@ -366,6 +366,7 @@ declare class Musket {
|
|
|
366
366
|
//#endregion
|
|
367
367
|
//#region src/Contracts/Application.d.ts
|
|
368
368
|
declare class Application {
|
|
369
|
+
[key: string]: any;
|
|
369
370
|
/**
|
|
370
371
|
* The current musket CLI Instance
|
|
371
372
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/musket",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|