@moostjs/event-cli 0.2.32 → 0.2.34
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 +39 -22
- package/dist/index.cjs +7 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +7 -5
- package/package.json +14 -5
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# @moostjs/event-cli
|
|
2
2
|
|
|
3
|
-
**!!! This is work-in-progress library, breaking changes are expected !!!**
|
|
4
|
-
|
|
5
3
|
<p align="center">
|
|
6
4
|
<img src="../../moost-logo.png" width="450px"><br>
|
|
7
5
|
<a href="https://github.com/moostjs/moostjs/blob/main/LICENSE">
|
|
@@ -9,32 +7,51 @@
|
|
|
9
7
|
</a>
|
|
10
8
|
</p>
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
Welcome to `@moostjs/event-cli`, a Moostjs library designed to handle CLI events within your Moost application. This package provides decorators that simplify the creation of command line interface handlers in a structured and declarative manner.
|
|
11
|
+
|
|
12
|
+
**Note:** As `@moostjs/event-cli` is under active development, breaking changes can be expected.
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Overview
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
import { MoostCli, Flag, Cli } from '@moostjs/event-cli'
|
|
18
|
-
import { Moost } from 'moost'
|
|
16
|
+
The `@moostjs/event-cli` module is crucial for making Moost applications responsive to CLI events. By leveraging this module, you can create handlers for these events in a structured, and clear manner.
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
@Cli('command')
|
|
22
|
-
command(@Flag('test') test: string | boolean) {
|
|
23
|
-
return `command run with flag test=${ test }`
|
|
24
|
-
}
|
|
25
|
-
}
|
|
18
|
+
## Getting Started
|
|
26
19
|
|
|
27
|
-
|
|
20
|
+
To start a new Moost CLI project, you can run the following command:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm create moost -- --cli
|
|
24
|
+
```
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
app.adapter(cli)
|
|
31
|
-
app.init()
|
|
26
|
+
You can also provide a name for your project:
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// "command run with flag test=true"
|
|
28
|
+
```bash
|
|
29
|
+
npm create moost my-cli-app -- --cli
|
|
36
30
|
```
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
This command will initiate a setup tool that will guide you through the project initialization process. It will prompt you to make certain choices such as:
|
|
33
|
+
|
|
34
|
+
- Whether you want to integrate eslint and prettier.
|
|
35
|
+
- Which bundler you prefer to use: esbuild or rollup.
|
|
36
|
+
|
|
37
|
+
## [Official Documentation](https://moost.org/cliapp/)
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
We are excited to welcome contributors who are passionate about improving Moostjs. No matter your level of experience, your unique perspective and skills can make valuable contributions to our growing community.
|
|
42
|
+
|
|
43
|
+
Here are some basic steps to get you started:
|
|
44
|
+
|
|
45
|
+
1. **Fork the Repo:** Navigate to [moostjs](https://github.com/moostjs/moostjs) and fork the repository to your own GitHub account.
|
|
46
|
+
|
|
47
|
+
2. **Clone the Repo:** Clone the forked repository to your local machine.
|
|
48
|
+
|
|
49
|
+
3. **Create a Branch:** Make a new branch for your feature or bug fix.
|
|
50
|
+
|
|
51
|
+
4. **Make your Changes:** Implement your feature or fix the bug and commit the changes to your branch.
|
|
52
|
+
|
|
53
|
+
5. **Make a Pull Request:** Navigate back to your forked repo and press the "New pull request" button.
|
|
54
|
+
|
|
55
|
+
Don't hesitate to ask for help if you need it. We believe in fostering a friendly and respectful environment for all contributors.
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
Thank you for your interest in Moostjs. We look forward to building something amazing together!
|
package/dist/index.cjs
CHANGED
|
@@ -107,7 +107,7 @@ class MoostCli {
|
|
|
107
107
|
void this.cliApp.run();
|
|
108
108
|
}
|
|
109
109
|
bindHandler(opts) {
|
|
110
|
-
var _a, _b, _c, _d
|
|
110
|
+
var _a, _b, _c, _d;
|
|
111
111
|
let fn;
|
|
112
112
|
for (const handler of opts.handlers) {
|
|
113
113
|
if (handler.type !== 'CLI')
|
|
@@ -141,11 +141,11 @@ class MoostCli {
|
|
|
141
141
|
[
|
|
142
142
|
...(((_c = (_b = this.opts) === null || _b === void 0 ? void 0 : _b.globalCliOptions) === null || _c === void 0 ? void 0 : _c.length) ? this.opts.globalCliOptions : []),
|
|
143
143
|
...((classMeta === null || classMeta === void 0 ? void 0 : classMeta.cliOptions) || []),
|
|
144
|
-
...((
|
|
144
|
+
...((meta === null || meta === void 0 ? void 0 : meta.params) ? meta.params.filter((param) => { var _a; return ((_a = param.cliOptionsKeys) === null || _a === void 0 ? void 0 : _a.length) > 0; }).map((param) => ({
|
|
145
145
|
keys: param.cliOptionsKeys,
|
|
146
146
|
value: typeof param.value === 'string' ? param.value : '',
|
|
147
147
|
description: param.description || '',
|
|
148
|
-
}))
|
|
148
|
+
})) : []),
|
|
149
149
|
].forEach(o => cliOptions.set(o.keys[0], o));
|
|
150
150
|
const aliases = [];
|
|
151
151
|
if (meta === null || meta === void 0 ? void 0 : meta.cliAliases) {
|
|
@@ -155,8 +155,8 @@ class MoostCli {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
const args = {};
|
|
158
|
-
(
|
|
159
|
-
this.cliApp.cli(targetPath, {
|
|
158
|
+
(_d = meta === null || meta === void 0 ? void 0 : meta.params) === null || _d === void 0 ? void 0 : _d.filter(p => p.paramSource === 'ROUTE' && p.description).forEach(p => args[p.paramName] = p.description);
|
|
159
|
+
const routerBinding = this.cliApp.cli(targetPath, {
|
|
160
160
|
description: (meta === null || meta === void 0 ? void 0 : meta.description) || '',
|
|
161
161
|
options: Array.from(cliOptions.values()),
|
|
162
162
|
args,
|
|
@@ -165,11 +165,13 @@ class MoostCli {
|
|
|
165
165
|
handler: fn,
|
|
166
166
|
onRegister: (path, aliasType) => {
|
|
167
167
|
var _a;
|
|
168
|
+
opts.register(handler, path, routerBinding.getArgs());
|
|
168
169
|
if ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.debug) {
|
|
169
170
|
opts.logHandler(`${'[36m'}(${aliasTypes[aliasType]})${'[32m'}${path}`);
|
|
170
171
|
}
|
|
171
172
|
},
|
|
172
173
|
});
|
|
174
|
+
opts.register(handler, targetPath, routerBinding.getArgs());
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
177
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -185,7 +185,7 @@ export declare class MoostCli implements TMoostAdapter<TCliHandlerMeta> {
|
|
|
185
185
|
onNotFound(): Promise<unknown>;
|
|
186
186
|
protected moost?: Moost;
|
|
187
187
|
onInit(moost: Moost): void;
|
|
188
|
-
bindHandler<T extends object = object>(opts: TMoostAdapterOptions<TCliHandlerMeta, T>): void
|
|
188
|
+
bindHandler<T extends object = object>(opts: TMoostAdapterOptions<TCliHandlerMeta, T>): void;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
export declare interface TCliHandlerMeta {
|
package/dist/index.mjs
CHANGED
|
@@ -106,7 +106,7 @@ class MoostCli {
|
|
|
106
106
|
void this.cliApp.run();
|
|
107
107
|
}
|
|
108
108
|
bindHandler(opts) {
|
|
109
|
-
var _a, _b, _c, _d
|
|
109
|
+
var _a, _b, _c, _d;
|
|
110
110
|
let fn;
|
|
111
111
|
for (const handler of opts.handlers) {
|
|
112
112
|
if (handler.type !== 'CLI')
|
|
@@ -140,11 +140,11 @@ class MoostCli {
|
|
|
140
140
|
[
|
|
141
141
|
...(((_c = (_b = this.opts) === null || _b === void 0 ? void 0 : _b.globalCliOptions) === null || _c === void 0 ? void 0 : _c.length) ? this.opts.globalCliOptions : []),
|
|
142
142
|
...((classMeta === null || classMeta === void 0 ? void 0 : classMeta.cliOptions) || []),
|
|
143
|
-
...((
|
|
143
|
+
...((meta === null || meta === void 0 ? void 0 : meta.params) ? meta.params.filter((param) => { var _a; return ((_a = param.cliOptionsKeys) === null || _a === void 0 ? void 0 : _a.length) > 0; }).map((param) => ({
|
|
144
144
|
keys: param.cliOptionsKeys,
|
|
145
145
|
value: typeof param.value === 'string' ? param.value : '',
|
|
146
146
|
description: param.description || '',
|
|
147
|
-
}))
|
|
147
|
+
})) : []),
|
|
148
148
|
].forEach(o => cliOptions.set(o.keys[0], o));
|
|
149
149
|
const aliases = [];
|
|
150
150
|
if (meta === null || meta === void 0 ? void 0 : meta.cliAliases) {
|
|
@@ -154,8 +154,8 @@ class MoostCli {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
const args = {};
|
|
157
|
-
(
|
|
158
|
-
this.cliApp.cli(targetPath, {
|
|
157
|
+
(_d = meta === null || meta === void 0 ? void 0 : meta.params) === null || _d === void 0 ? void 0 : _d.filter(p => p.paramSource === 'ROUTE' && p.description).forEach(p => args[p.paramName] = p.description);
|
|
158
|
+
const routerBinding = this.cliApp.cli(targetPath, {
|
|
159
159
|
description: (meta === null || meta === void 0 ? void 0 : meta.description) || '',
|
|
160
160
|
options: Array.from(cliOptions.values()),
|
|
161
161
|
args,
|
|
@@ -164,11 +164,13 @@ class MoostCli {
|
|
|
164
164
|
handler: fn,
|
|
165
165
|
onRegister: (path, aliasType) => {
|
|
166
166
|
var _a;
|
|
167
|
+
opts.register(handler, path, routerBinding.getArgs());
|
|
167
168
|
if ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.debug) {
|
|
168
169
|
opts.logHandler(`${'[36m'}(${aliasTypes[aliasType]})${'[32m'}${path}`);
|
|
169
170
|
}
|
|
170
171
|
},
|
|
171
172
|
});
|
|
173
|
+
opts.register(handler, targetPath, routerBinding.getArgs());
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.34",
|
|
4
4
|
"description": "@moostjs/event-cli",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
8
16
|
"files": [
|
|
9
17
|
"dist"
|
|
10
18
|
],
|
|
@@ -28,11 +36,12 @@
|
|
|
28
36
|
},
|
|
29
37
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-cli#readme",
|
|
30
38
|
"peerDependencies": {
|
|
31
|
-
"moost": "0.2.
|
|
32
|
-
"wooks": "^0.3.
|
|
33
|
-
"@wooksjs/event-core": "^0.3.
|
|
39
|
+
"moost": "0.2.34",
|
|
40
|
+
"wooks": "^0.3.11",
|
|
41
|
+
"@wooksjs/event-core": "^0.3.11"
|
|
34
42
|
},
|
|
35
43
|
"dependencies": {
|
|
36
|
-
"@wooksjs/event-cli": "^0.3.
|
|
44
|
+
"@wooksjs/event-cli": "^0.3.11",
|
|
45
|
+
"@prostojs/wf": "^0.0.3"
|
|
37
46
|
}
|
|
38
47
|
}
|