@initx-plugin/core 0.0.8 → 0.0.9

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 CHANGED
@@ -44,4 +44,4 @@ declare abstract class InitxHandler {
44
44
  private isPassed;
45
45
  }
46
46
 
47
- export { InitxHandler, type InitxOptions };
47
+ export { type HandlerInfo, InitxHandler, type InitxOptions };
package/dist/index.d.ts CHANGED
@@ -44,4 +44,4 @@ declare abstract class InitxHandler {
44
44
  private isPassed;
45
45
  }
46
46
 
47
- export { InitxHandler, type InitxOptions };
47
+ export { type HandlerInfo, InitxHandler, type InitxOptions };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@initx-plugin/core",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.9",
5
5
  "description": "core module for initx plugins",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
@@ -16,7 +16,7 @@
16
16
  "keywords": [
17
17
  "initx"
18
18
  ],
19
- "main": "dist/index.cjs",
19
+ "main": "dist/index.mjs",
20
20
  "module": "dist/index.mjs",
21
21
  "types": "dist/index.d.ts",
22
22
  "files": [
package/dist/index.cjs DELETED
@@ -1,54 +0,0 @@
1
- 'use strict';
2
-
3
- class InitxHandler {
4
- run(options, ...others) {
5
- const handlers = [];
6
- if (!Array.isArray(this.matchers) && this.matchers.matching && this.matchers.description && this.isPassed(this.matchers.matching, options.key)) {
7
- handlers.push({
8
- handler: () => this.handle(options, ...others),
9
- description: this.matchers.description
10
- });
11
- return handlers;
12
- }
13
- if (this.isObject(this.matchers)) {
14
- const keys = Object.keys(this.matchers);
15
- for (let i = 0; i < keys.length; i++) {
16
- const matcher = this.matchers[keys[i]];
17
- const isPassed = this.isPassed(matcher.matching, options.key);
18
- if (isPassed) {
19
- handlers.push({
20
- handler: () => this.handle(options, keys[i], ...others),
21
- description: matcher.description
22
- });
23
- break;
24
- }
25
- }
26
- return handlers;
27
- }
28
- for (let i = 0; i < this.matchers.length; i++) {
29
- const matcher = this.matchers[i];
30
- const isPassed = this.isPassed(matcher.matching, options.key);
31
- if (isPassed) {
32
- handlers.push({
33
- handler: () => this.handle(options, ...others),
34
- description: matcher.description
35
- });
36
- }
37
- }
38
- return handlers;
39
- }
40
- isObject(value) {
41
- return typeof value === "object" && value !== null && !Array.isArray(value);
42
- }
43
- isPassed(matchers, key) {
44
- const tests = Array.isArray(matchers) ? matchers : [matchers];
45
- return tests.some((test) => {
46
- if (typeof test === "string") {
47
- return test === key;
48
- }
49
- return test.test(key);
50
- });
51
- }
52
- }
53
-
54
- exports.InitxHandler = InitxHandler;
package/dist/index.d.cts DELETED
@@ -1,47 +0,0 @@
1
- type MaybeArray<T> = T | T[];
2
- type MaybePromise<T> = T | Promise<T>;
3
- interface BaseMatchers {
4
- matching: MaybeArray<string | RegExp>;
5
- /**
6
- * Description of the handler
7
- *
8
- * If multiple handlers are matched, this description will be displayed
9
- */
10
- description: string;
11
- }
12
- type TypeMatchers = Record<string, BaseMatchers>;
13
- type Matchers = MaybeArray<BaseMatchers> | TypeMatchers;
14
- interface HandlerInfo {
15
- handler: () => MaybePromise<void>;
16
- description: string;
17
- }
18
- interface InitxOptions {
19
- /**
20
- * Matching string
21
- *
22
- * The key that was used to match the handler
23
- */
24
- key: string;
25
- /**
26
- * CLI options
27
- *
28
- * cac package parsed options
29
- */
30
- cliOptions: Record<string, any>;
31
- /**
32
- * Options list
33
- *
34
- * cli options list, like
35
- * @example ['--global']
36
- */
37
- optionsList: string[];
38
- }
39
- declare abstract class InitxHandler {
40
- abstract matchers: Matchers;
41
- abstract handle(options: InitxOptions, ...others: string[]): MaybePromise<void>;
42
- run(options: InitxOptions, ...others: string[]): HandlerInfo[];
43
- private isObject;
44
- private isPassed;
45
- }
46
-
47
- export { InitxHandler, type InitxOptions };