You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This extra text will be used by other plugins and middlewares. Originally, use case is for showing extra info about the command in help or pilot command
185
+
This extra text will be used by other plugins and middlewares. Originally, use case is for showing info about the command in help or pilot command
179
186
180
187
```typescript
181
188
{
182
189
name:"delete",
183
-
extra:"this command will delete all files. run with caution.",
190
+
additionalInfo:"this command will delete all files. run with caution.",
This is a command description used by help and other plugins.
207
-
208
211
#### usage
209
212
210
213
Sample usage code shown in the help command
@@ -246,6 +249,10 @@ The `run` method provides various data about the command and app.
246
249
}
247
250
```
248
251
252
+
#### data.utils
253
+
254
+
todo
255
+
249
256
### Sub commands
250
257
251
258
Commands can be nested multiple levels. If you want to make a sub-command, just add the parent name in `main` property. Other features of the command remains same for sub commands.
@@ -298,7 +305,7 @@ Please dont use parent name aliases
298
305
299
306
### Default command
300
307
301
-
By default **lesy**look for command named `default` if no args supplied in the input. If you would like to run different command as a default command, set it in the config.
308
+
By default **lesy**looks for command named `default` if no args supplied in the input. If you would like to run different command as a default command, set it in the config.
Copy file name to clipboardExpand all lines: docs/src/markdown/docs/main/core/middlewares.md
+41-41Lines changed: 41 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ path: /docs/core/middlewares
4
4
icon: fire-fill
5
5
---
6
6
7
-
Middlewares are special type of hooks, to inject new functionality or change tge behaviour of the command flow. For instance, if you want to redirect the command, or validate the middleware can be hooked in to specific points in the flow. Basically, they are simple functions which will be execute at the runtime.
7
+
Middlewares are special type of hooks, to inject new functionality or change the behaviour of the command flow. For instance, if you want to redirect the command or validate, the middleware can be hooked in to specific points in the flow. Basically, they are simple functions which will be execute at specific point during runtime.
8
8
9
9
### Hook points
10
10
@@ -34,11 +34,10 @@ export default {
34
34
Add the middleware file in the **index.ts** file.
35
35
36
36
```typescript
37
-
let argv =process.argv.slice(2);
38
37
let commands = [...];
39
38
let middlewares = [`${__dirname}/middlewares/start.ts`];
40
39
41
-
export { argv, commands, middlewares };
40
+
export { commands, middlewares };
42
41
```
43
42
44
43
Middleware should return the input data to continue the flow.
@@ -76,9 +75,9 @@ This will run after loading all commands and plugins. The run context will have
76
75
```typescript
77
76
exportdefault {
78
77
on: "START",
79
-
run: (data) => {
80
-
console.log(data.cmds);
81
-
returndata;
78
+
run: (ctx) => {
79
+
console.log(ctx.cmds);
80
+
returnctx;
82
81
},
83
82
};
84
83
```
@@ -90,14 +89,14 @@ This will run before parsing raw argv input. At this point you can change **argv
90
89
```typescript
91
90
exportdefault {
92
91
on: "PRE_PARSE",
93
-
run: (data) => {
94
-
//data.argv - raw input argv values
95
-
//data.root - root path
96
-
//data.config - config object
97
-
//data.utils - colors() and spinner() object
98
-
//data.feature - all features
99
-
//data.request - oject of dynamic actions
100
-
returndata;
92
+
run: (ctx) => {
93
+
//ctx.argv - raw input argv values
94
+
//ctx.root - root path
95
+
//ctx.config - config object
96
+
//ctx.utils - colors() and spinner() object
97
+
//ctx.feature - all features
98
+
//ctx.request - oject of dynamic actions
99
+
returnctx;
101
100
},
102
101
};
103
102
```
@@ -109,17 +108,17 @@ Run after parsing raw argv values.
109
108
```typescript
110
109
exportdefault {
111
110
on: "PRE_PARSE",
112
-
run: (data) => {
113
-
//data.argv - raw input argv values
114
-
//data.root - root path
115
-
//data.config - config object
116
-
//data.utils - colors() and spinner() object
117
-
//data.feature - all features
118
-
//data.request - oject of dynamic actions
119
-
120
-
//data.args - resolved args
121
-
//data.flags - resolved flags
122
-
returndata;
111
+
run: (ctx) => {
112
+
//ctx.argv - raw input argv values
113
+
//ctx.root - root path
114
+
//ctx.config - config object
115
+
//ctx.utils - colors() and spinner() object
116
+
//ctx.feature - all features
117
+
//ctx.request - oject of dynamic actions
118
+
119
+
//ctx.args - resolved args
120
+
//ctx.flags - resolved flags
121
+
returnctx;
123
122
},
124
123
};
125
124
```
@@ -131,9 +130,9 @@ Once lesy found the right command to execute, it will pass the command object to
131
130
```typescript
132
131
exportdefault {
133
132
on: "PRE_VALIDATE",
134
-
run: (data) => {
135
-
console.log(data);
136
-
returndata;
133
+
run: (ctx) => {
134
+
console.log(ctx);
135
+
returnctx;
137
136
},
138
137
};
139
138
```
@@ -171,30 +170,31 @@ After validation passes, **pre_run** will be executed will all the necessary inf
171
170
```typescript
172
171
exportdefault {
173
172
on: "PRE_RUN",
174
-
run: (data) => {
175
-
//data.argv - raw input argv values
176
-
//data.root - root path
177
-
//data.config - config object
178
-
//data.utils - colors() and spinner() object
179
-
//data.feature - all features
180
-
//data.request - oject of dynamic actions
181
-
//data.args - resolved args
182
-
//data.flags - resolved flags
183
-
//data.rest - unknown args
184
-
returndata;
173
+
run: (ctx) => {
174
+
//ctx.argv - raw input argv values
175
+
//ctx.root - root path
176
+
//ctx.config - config object
177
+
//ctx.utils - colors() and spinner() object
178
+
//ctx.feature - all features
179
+
//ctx.request - oject of dynamic actions
180
+
//ctx.args - resolved args
181
+
//ctx.flags - resolved flags
182
+
//ctx.rest - unknown args
183
+
returnctx;
185
184
},
186
185
};
187
186
```
188
187
189
188
### END - Hook
190
189
191
-
This hook will run at the end of the command flow. There is no run context. Thus no need of return statement.
190
+
This hook will run at the end of the command flow.
Copy file name to clipboardExpand all lines: docs/src/markdown/docs/main/get-started/concepts.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,7 @@ title: Concepts
3
3
path: /docs/get-started/concepts
4
4
icon: honour-fill
5
5
---
6
+
7
+
Lesy is build based on frictionless sleek middleware architecture, thus maintaining the each core components work independently as well as play together.
0 commit comments