@moostjs/event-cli 0.2.6 → 0.2.8
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 +2 -33
- package/dist/index.mjs +1 -32
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var eventCli = require('@wooksjs/event-cli');
|
|
4
|
-
var
|
|
4
|
+
var eventCore = require('@wooksjs/event-core');
|
|
5
5
|
var moost = require('moost');
|
|
6
6
|
|
|
7
7
|
/******************************************************************************
|
|
@@ -29,37 +29,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const banner = () => `[${"@wooksjs/event-core"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
33
|
-
|
|
34
|
-
/* istanbul ignore file */
|
|
35
|
-
function logError(error) {
|
|
36
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function panic(error) {
|
|
40
|
-
logError(error);
|
|
41
|
-
return new Error(error);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Use existing event context
|
|
45
|
-
*
|
|
46
|
-
* !Must be called syncronously while context is reachable
|
|
47
|
-
*
|
|
48
|
-
* @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
|
|
49
|
-
*/
|
|
50
|
-
function useEventContext(expectedTypes) {
|
|
51
|
-
{
|
|
52
|
-
throw panic('Event context does not exist. Use event context synchronously within the runtime of the event.');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function useEventId() {
|
|
57
|
-
const { store } = useEventContext();
|
|
58
|
-
const { init } = store('event');
|
|
59
|
-
const getId = () => init('id', () => crypto.randomUUID());
|
|
60
|
-
return { getId };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
32
|
class MoostCli {
|
|
64
33
|
constructor(cliApp) {
|
|
65
34
|
if (cliApp && cliApp instanceof eventCli.WooksCli) {
|
|
@@ -85,7 +54,7 @@ class MoostCli {
|
|
|
85
54
|
if (!fn) {
|
|
86
55
|
fn = () => __awaiter(this, void 0, void 0, function* () {
|
|
87
56
|
const { restoreCtx } = eventCli.useCliContext();
|
|
88
|
-
const scopeId = useEventId().getId();
|
|
57
|
+
const scopeId = eventCore.useEventId().getId();
|
|
89
58
|
const unscope = opts.registerEventScope(scopeId);
|
|
90
59
|
const instance = yield opts.getInstance();
|
|
91
60
|
restoreCtx();
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WooksCli, createCliApp, useCliContext, useFlags } from '@wooksjs/event-cli';
|
|
2
|
-
import {
|
|
2
|
+
import { useEventId } from '@wooksjs/event-core';
|
|
3
3
|
import { Resolve, getMoostMate } from 'moost';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
@@ -27,37 +27,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const banner = () => `[${"@wooksjs/event-core"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
31
|
-
|
|
32
|
-
/* istanbul ignore file */
|
|
33
|
-
function logError(error) {
|
|
34
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function panic(error) {
|
|
38
|
-
logError(error);
|
|
39
|
-
return new Error(error);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Use existing event context
|
|
43
|
-
*
|
|
44
|
-
* !Must be called syncronously while context is reachable
|
|
45
|
-
*
|
|
46
|
-
* @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
|
|
47
|
-
*/
|
|
48
|
-
function useEventContext(expectedTypes) {
|
|
49
|
-
{
|
|
50
|
-
throw panic('Event context does not exist. Use event context synchronously within the runtime of the event.');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function useEventId() {
|
|
55
|
-
const { store } = useEventContext();
|
|
56
|
-
const { init } = store('event');
|
|
57
|
-
const getId = () => init('id', () => randomUUID());
|
|
58
|
-
return { getId };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
30
|
class MoostCli {
|
|
62
31
|
constructor(cliApp) {
|
|
63
32
|
if (cliApp && cliApp instanceof WooksCli) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "@moostjs/event-cli",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-cli#readme",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"moost": "0.2.
|
|
32
|
-
"wooks": "^0.2.5"
|
|
31
|
+
"moost": "0.2.8",
|
|
32
|
+
"wooks": "^0.2.5",
|
|
33
|
+
"@wooksjs/event-core": "^0.2.5"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@wooksjs/event-cli": "^0.2.5"
|