@initx-plugin/core 0.0.20 → 0.0.22
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.d.mts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.mjs +3 -4
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -29,7 +29,7 @@ interface BaseMatchers {
|
|
|
29
29
|
}
|
|
30
30
|
type TypeMatchers = Record<string, BaseMatchers>;
|
|
31
31
|
type Matchers = MaybeArray<BaseMatchers> | TypeMatchers;
|
|
32
|
-
type
|
|
32
|
+
type PluginStore = Record<string, any>;
|
|
33
33
|
interface HandlerInfo {
|
|
34
34
|
handler: () => MaybePromise<void>;
|
|
35
35
|
description: string;
|
|
@@ -55,23 +55,25 @@ interface InitxBaseContext {
|
|
|
55
55
|
*/
|
|
56
56
|
optionsList: string[];
|
|
57
57
|
}
|
|
58
|
-
interface
|
|
58
|
+
interface InitxRunContext extends InitxBaseContext {
|
|
59
|
+
/**
|
|
60
|
+
* Package info
|
|
61
|
+
*/
|
|
62
|
+
packageInfo: PackageInfo;
|
|
63
|
+
}
|
|
64
|
+
interface InitxContext<TStore extends PluginStore = PluginStore> extends InitxRunContext {
|
|
59
65
|
/**
|
|
60
66
|
* Store
|
|
61
67
|
*
|
|
62
68
|
* Store data in memory, and write to disk when the program exits
|
|
63
69
|
*/
|
|
64
|
-
store:
|
|
65
|
-
/**
|
|
66
|
-
* Package info
|
|
67
|
-
*/
|
|
68
|
-
packageInfo: PackageInfo;
|
|
70
|
+
store: TStore;
|
|
69
71
|
}
|
|
70
|
-
declare abstract class InitxPlugin<
|
|
72
|
+
declare abstract class InitxPlugin<TStore extends PluginStore = PluginStore> {
|
|
71
73
|
abstract matchers: Matchers;
|
|
72
|
-
abstract handle(options: InitxContext<
|
|
73
|
-
|
|
74
|
-
run(context:
|
|
74
|
+
abstract handle(options: InitxContext<TStore>, ...others: string[]): MaybePromise<void>;
|
|
75
|
+
defaultStore?: TStore;
|
|
76
|
+
run(context: InitxRunContext, ...others: string[]): HandlerInfo[];
|
|
75
77
|
private matchBaseMatchers;
|
|
76
78
|
private matchArrayBaseMatchers;
|
|
77
79
|
private matchTypeMatchers;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ interface BaseMatchers {
|
|
|
29
29
|
}
|
|
30
30
|
type TypeMatchers = Record<string, BaseMatchers>;
|
|
31
31
|
type Matchers = MaybeArray<BaseMatchers> | TypeMatchers;
|
|
32
|
-
type
|
|
32
|
+
type PluginStore = Record<string, any>;
|
|
33
33
|
interface HandlerInfo {
|
|
34
34
|
handler: () => MaybePromise<void>;
|
|
35
35
|
description: string;
|
|
@@ -55,23 +55,25 @@ interface InitxBaseContext {
|
|
|
55
55
|
*/
|
|
56
56
|
optionsList: string[];
|
|
57
57
|
}
|
|
58
|
-
interface
|
|
58
|
+
interface InitxRunContext extends InitxBaseContext {
|
|
59
|
+
/**
|
|
60
|
+
* Package info
|
|
61
|
+
*/
|
|
62
|
+
packageInfo: PackageInfo;
|
|
63
|
+
}
|
|
64
|
+
interface InitxContext<TStore extends PluginStore = PluginStore> extends InitxRunContext {
|
|
59
65
|
/**
|
|
60
66
|
* Store
|
|
61
67
|
*
|
|
62
68
|
* Store data in memory, and write to disk when the program exits
|
|
63
69
|
*/
|
|
64
|
-
store:
|
|
65
|
-
/**
|
|
66
|
-
* Package info
|
|
67
|
-
*/
|
|
68
|
-
packageInfo: PackageInfo;
|
|
70
|
+
store: TStore;
|
|
69
71
|
}
|
|
70
|
-
declare abstract class InitxPlugin<
|
|
72
|
+
declare abstract class InitxPlugin<TStore extends PluginStore = PluginStore> {
|
|
71
73
|
abstract matchers: Matchers;
|
|
72
|
-
abstract handle(options: InitxContext<
|
|
73
|
-
|
|
74
|
-
run(context:
|
|
74
|
+
abstract handle(options: InitxContext<TStore>, ...others: string[]): MaybePromise<void>;
|
|
75
|
+
defaultStore?: TStore;
|
|
76
|
+
run(context: InitxRunContext, ...others: string[]): HandlerInfo[];
|
|
75
77
|
private matchBaseMatchers;
|
|
76
78
|
private matchArrayBaseMatchers;
|
|
77
79
|
private matchTypeMatchers;
|
package/dist/index.mjs
CHANGED
|
@@ -73,7 +73,7 @@ var __publicField = (obj, key, value) => {
|
|
|
73
73
|
};
|
|
74
74
|
class InitxPlugin {
|
|
75
75
|
constructor() {
|
|
76
|
-
__publicField(this, "
|
|
76
|
+
__publicField(this, "defaultStore");
|
|
77
77
|
}
|
|
78
78
|
run(context, ...others) {
|
|
79
79
|
if (this.isBaseMatchers(this.matchers)) {
|
|
@@ -148,7 +148,8 @@ class InitxPlugin {
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
async executeHandle(context, ...others) {
|
|
151
|
-
|
|
151
|
+
const store = createStore(context.packageInfo, this.defaultStore);
|
|
152
|
+
await this.handle({ ...context, store }, ...others);
|
|
152
153
|
writeStore(context.packageInfo);
|
|
153
154
|
}
|
|
154
155
|
}
|
|
@@ -192,10 +193,8 @@ function matchPlugins(plugins, { key, cliOptions }, ...others) {
|
|
|
192
193
|
const matchedHandlers = [];
|
|
193
194
|
for (const plugin of plugins) {
|
|
194
195
|
const { instance, packageInfo } = plugin;
|
|
195
|
-
const store = createStore(packageInfo, instance.defaultConfig);
|
|
196
196
|
const matched = instance.run({
|
|
197
197
|
key,
|
|
198
|
-
store,
|
|
199
198
|
cliOptions,
|
|
200
199
|
packageInfo,
|
|
201
200
|
optionsList: Object.keys(cliOptions).filter((key2) => cliOptions[key2] === true).map((key2) => `--${key2}`)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@initx-plugin/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.22",
|
|
5
5
|
"description": "core module for initx plugins",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/initx-collective/initx#readme",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"defu": "^6.1.4",
|
|
26
26
|
"fs-extra": "^11.2.0",
|
|
27
27
|
"importx": "^0.5.0",
|
|
28
|
-
"@initx-plugin/utils": "0.0.
|
|
28
|
+
"@initx-plugin/utils": "0.0.22"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/fs-extra": "^11.0.4"
|