@initx-plugin/cp 0.0.6 → 0.0.7

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
@@ -1,12 +1,12 @@
1
- import { InitxHandler } from '@initx-plugin/core';
1
+ import { InitxHandler, InitxOptions } from '@initx-plugin/core';
2
2
 
3
3
  declare enum CpType {
4
4
  SSH = "ssh"
5
5
  }
6
6
 
7
7
  declare class CpHandler extends InitxHandler {
8
- matchers: string[];
9
- handle(_command: string, cpType: CpType, ...rest: string[]): Promise<void>;
8
+ matchers: string;
9
+ handle(_options: InitxOptions, cpType: CpType, ...others: string[]): Promise<void>;
10
10
  [CpType.SSH](): Promise<void>;
11
11
  private copy;
12
12
  }
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { InitxHandler } from '@initx-plugin/core';
1
+ import { InitxHandler, InitxOptions } from '@initx-plugin/core';
2
2
 
3
3
  declare enum CpType {
4
4
  SSH = "ssh"
5
5
  }
6
6
 
7
7
  declare class CpHandler extends InitxHandler {
8
- matchers: string[];
9
- handle(_command: string, cpType: CpType, ...rest: string[]): Promise<void>;
8
+ matchers: string;
9
+ handle(_options: InitxOptions, cpType: CpType, ...others: string[]): Promise<void>;
10
10
  [CpType.SSH](): Promise<void>;
11
11
  private copy;
12
12
  }
package/dist/index.mjs CHANGED
@@ -2,42 +2,9 @@ import os from 'node:os';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
4
  import clipboard from 'clipboardy';
5
+ import { InitxHandler } from '@initx-plugin/core';
5
6
  import { log } from '@initx-plugin/utils';
6
7
 
7
- class InitxHandler {
8
- async run(value, ...others) {
9
- if (this.isObject(this.matchers)) {
10
- const keys = Object.keys(this.matchers);
11
- for (let i = 0; i < keys.length; i++) {
12
- const matcher = this.matchers[keys[i]];
13
- const isPassed2 = this.isPassed(matcher, value);
14
- if (isPassed2) {
15
- this.handle(value, keys[i], ...others);
16
- break;
17
- }
18
- }
19
- return;
20
- }
21
- const isPassed = this.isPassed(this.matchers, value);
22
- if (!isPassed) {
23
- return;
24
- }
25
- await this.handle(value, ...others);
26
- }
27
- isObject(value) {
28
- return typeof value === "object" && value !== null && !Array.isArray(value);
29
- }
30
- isPassed(matchers, value) {
31
- const tests = Array.isArray(matchers) ? matchers : [matchers];
32
- return tests.some((test) => {
33
- if (typeof test === "string") {
34
- return test === value;
35
- }
36
- return test.test(value);
37
- });
38
- }
39
- }
40
-
41
8
  var CpType = /* @__PURE__ */ ((CpType2) => {
42
9
  CpType2["SSH"] = "ssh";
43
10
  return CpType2;
@@ -52,16 +19,13 @@ var __publicField = (obj, key, value) => {
52
19
  class CpHandler extends InitxHandler {
53
20
  constructor() {
54
21
  super(...arguments);
55
- __publicField(this, "matchers", ["cp"]);
22
+ __publicField(this, "matchers", "cp");
56
23
  }
57
- async handle(_command, cpType, ...rest) {
24
+ async handle(_options, cpType, ...others) {
58
25
  if (!cpType || typeof this[cpType] !== "function") {
59
26
  return;
60
27
  }
61
- if (!Array.isArray(rest)) {
62
- rest = [];
63
- }
64
- this[cpType](...rest);
28
+ this[cpType](...others);
65
29
  }
66
30
  async [CpType.SSH]() {
67
31
  const sshDir = resolve(os.homedir(), ".ssh");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@initx-plugin/cp",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "description": "initx plugin, copy some text to clipboard",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
@@ -24,11 +24,8 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "clipboardy": "^4.0.0",
27
- "@initx-plugin/utils": "0.0.6"
28
- },
29
- "devDependencies": {
30
- "@types/copy-paste": "^1.1.33",
31
- "@initx-plugin/core": "0.0.6"
27
+ "@initx-plugin/utils": "0.0.7",
28
+ "@initx-plugin/core": "0.0.7"
32
29
  },
33
30
  "scripts": {
34
31
  "stub": "unbuild --stub",