@wooksjs/event-cli 0.7.2 → 0.7.4
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 +5 -12
- package/dist/index.d.ts +4 -11
- package/dist/index.mjs +5 -12
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -38,15 +38,9 @@ const flagsKey = (0, __wooksjs_event_core.key)("cli.flags");
|
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region packages/event-cli/src/event-cli.ts
|
|
41
|
-
/** Creates a
|
|
42
|
-
function createCliContext(
|
|
43
|
-
return (
|
|
44
|
-
argv: data.argv,
|
|
45
|
-
pathParams: data.pathParams,
|
|
46
|
-
command: data.command,
|
|
47
|
-
opts: data.opts,
|
|
48
|
-
cliHelp: data.cliHelp
|
|
49
|
-
}, fn);
|
|
41
|
+
/** Creates a CLI event context and runs `fn` inside it. */
|
|
42
|
+
function createCliContext(options, seeds, fn) {
|
|
43
|
+
return (0, __wooksjs_event_core.createEventContext)(options, cliKind, seeds, fn);
|
|
50
44
|
}
|
|
51
45
|
|
|
52
46
|
//#endregion
|
|
@@ -158,14 +152,13 @@ var WooksCli = class extends wooks.WooksAdapterBase {
|
|
|
158
152
|
const parsedFlags = (0, minimist.default)(argv, _opts);
|
|
159
153
|
const pathParams = parsedFlags._;
|
|
160
154
|
const path = `/${pathParams.map((v) => encodeURI(v).replace(/\//gu, "%2F")).join("/")}`;
|
|
161
|
-
|
|
155
|
+
return createCliContext(this.getEventContextOptions(), {
|
|
162
156
|
opts: _opts,
|
|
163
157
|
argv,
|
|
164
158
|
pathParams,
|
|
165
159
|
cliHelp: this.cliHelp,
|
|
166
160
|
command: path.replace(/\//gu, " ").trim()
|
|
167
|
-
},
|
|
168
|
-
return runInContext(async () => {
|
|
161
|
+
}, async () => {
|
|
169
162
|
const ctx = (0, __wooksjs_event_core.current)();
|
|
170
163
|
ctx.set(flagsKey, parsedFlags);
|
|
171
164
|
this.computeAliases();
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _prostojs_cli_help from '@prostojs/cli-help';
|
|
|
4
4
|
import { CliHelpRenderer, TCliEntry, TCliHelpOptions } from '@prostojs/cli-help';
|
|
5
5
|
import { TConsoleBase } from '@prostojs/logger';
|
|
6
6
|
import * as _wooksjs_event_core from '@wooksjs/event-core';
|
|
7
|
-
import { EventContextOptions } from '@wooksjs/event-core';
|
|
7
|
+
import { EventContextOptions, EventKindSeeds } from '@wooksjs/event-core';
|
|
8
8
|
export { EventContext, EventContextOptions, useLogger, useRouteParams } from '@wooksjs/event-core';
|
|
9
9
|
import minimist from 'minimist';
|
|
10
10
|
import { TProstoRouterPathHandle } from '@prostojs/router';
|
|
@@ -229,15 +229,8 @@ declare function useCliOptions(): Record<string, string | boolean>;
|
|
|
229
229
|
*/
|
|
230
230
|
declare function useCliOption(name: string): string | boolean;
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
pathParams: string[];
|
|
235
|
-
command: string;
|
|
236
|
-
opts?: minimist.Opts;
|
|
237
|
-
cliHelp: TCliHelpRenderer;
|
|
238
|
-
}
|
|
239
|
-
/** Creates a new event context for a CLI command invocation. */
|
|
240
|
-
declare function createCliContext(data: TCliEventInput, options: EventContextOptions): <R>(fn: () => R) => R;
|
|
232
|
+
/** Creates a CLI event context and runs `fn` inside it. */
|
|
233
|
+
declare function createCliContext<R>(options: EventContextOptions, seeds: EventKindSeeds<typeof cliKind>, fn: () => R): R;
|
|
241
234
|
|
|
242
235
|
export { WooksCli, cliKind, cliShortcuts, createCliApp, createCliContext, flagsKey, useAutoHelp, useCliHelp, useCliOption, useCliOptions, useCommandLookupHelp };
|
|
243
|
-
export type {
|
|
236
|
+
export type { TCliHelpCustom, TCliHelpRenderer, TWooksCliEntry, TWooksCliOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -15,15 +15,9 @@ const flagsKey = key("cli.flags");
|
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region packages/event-cli/src/event-cli.ts
|
|
18
|
-
/** Creates a
|
|
19
|
-
function createCliContext(
|
|
20
|
-
return
|
|
21
|
-
argv: data.argv,
|
|
22
|
-
pathParams: data.pathParams,
|
|
23
|
-
command: data.command,
|
|
24
|
-
opts: data.opts,
|
|
25
|
-
cliHelp: data.cliHelp
|
|
26
|
-
}, fn);
|
|
18
|
+
/** Creates a CLI event context and runs `fn` inside it. */
|
|
19
|
+
function createCliContext(options, seeds, fn) {
|
|
20
|
+
return createEventContext(options, cliKind, seeds, fn);
|
|
27
21
|
}
|
|
28
22
|
|
|
29
23
|
//#endregion
|
|
@@ -135,14 +129,13 @@ var WooksCli = class extends WooksAdapterBase {
|
|
|
135
129
|
const parsedFlags = minimist(argv, _opts);
|
|
136
130
|
const pathParams = parsedFlags._;
|
|
137
131
|
const path = `/${pathParams.map((v) => encodeURI(v).replace(/\//gu, "%2F")).join("/")}`;
|
|
138
|
-
|
|
132
|
+
return createCliContext(this.getEventContextOptions(), {
|
|
139
133
|
opts: _opts,
|
|
140
134
|
argv,
|
|
141
135
|
pathParams,
|
|
142
136
|
cliHelp: this.cliHelp,
|
|
143
137
|
command: path.replace(/\//gu, " ").trim()
|
|
144
|
-
},
|
|
145
|
-
return runInContext(async () => {
|
|
138
|
+
}, async () => {
|
|
146
139
|
const ctx = current();
|
|
147
140
|
ctx.set(flagsKey, parsedFlags);
|
|
148
141
|
this.computeAliases();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wooksjs/event-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "@wooksjs/event-cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"@types/minimist": "^1.2.5",
|
|
53
53
|
"typescript": "^5.9.3",
|
|
54
54
|
"vitest": "^3.2.4",
|
|
55
|
-
"@wooksjs/event-core": "^0.7.
|
|
56
|
-
"wooks": "^0.7.
|
|
55
|
+
"@wooksjs/event-core": "^0.7.4",
|
|
56
|
+
"wooks": "^0.7.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@prostojs/logger": "^0.4.3",
|
|
60
|
-
"@prostojs/router": "^0.3.
|
|
61
|
-
"@wooksjs/event-core": "^0.7.
|
|
62
|
-
"wooks": "^0.7.
|
|
60
|
+
"@prostojs/router": "^0.3.3",
|
|
61
|
+
"@wooksjs/event-core": "^0.7.4",
|
|
62
|
+
"wooks": "^0.7.4"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "rolldown -c ../../rolldown.config.mjs",
|