@initx-plugin/cp 0.0.5 → 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/types';
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/types';
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
@@ -1,25 +1,10 @@
1
1
  import os from 'node:os';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
- import { copy } from 'copy-paste';
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, ...rest) {
9
- const tests = Array.isArray(this.matchers) ? this.matchers : [this.matchers];
10
- const passed = tests.some((test) => {
11
- if (typeof test === "string") {
12
- return test === value;
13
- }
14
- return test.test(value);
15
- });
16
- if (!passed) {
17
- return;
18
- }
19
- await this.handle(value, ...rest);
20
- }
21
- }
22
-
23
8
  var CpType = /* @__PURE__ */ ((CpType2) => {
24
9
  CpType2["SSH"] = "ssh";
25
10
  return CpType2;
@@ -34,16 +19,13 @@ var __publicField = (obj, key, value) => {
34
19
  class CpHandler extends InitxHandler {
35
20
  constructor() {
36
21
  super(...arguments);
37
- __publicField(this, "matchers", ["cp"]);
22
+ __publicField(this, "matchers", "cp");
38
23
  }
39
- async handle(_command, cpType, ...rest) {
24
+ async handle(_options, cpType, ...others) {
40
25
  if (!cpType || typeof this[cpType] !== "function") {
41
26
  return;
42
27
  }
43
- if (!Array.isArray(rest)) {
44
- rest = [];
45
- }
46
- this[cpType](...rest);
28
+ this[cpType](...others);
47
29
  }
48
30
  async [CpType.SSH]() {
49
31
  const sshDir = resolve(os.homedir(), ".ssh");
@@ -53,19 +35,11 @@ class CpHandler extends InitxHandler {
53
35
  return;
54
36
  }
55
37
  const publicKey = readFileSync(publicKeyPath, "utf8");
56
- await this.copy(publicKey);
38
+ this.copy(publicKey);
57
39
  log.success("Public key copied to clipboard");
58
40
  }
59
41
  copy(content) {
60
- return new Promise((resolve, reject) => {
61
- copy(content, (err) => {
62
- if (err) {
63
- reject(err);
64
- return;
65
- }
66
- resolve(true);
67
- });
68
- });
42
+ clipboard.writeSync(content);
69
43
  }
70
44
  }
71
45
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@initx-plugin/cp",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.0.7",
5
5
  "description": "initx plugin, copy some text to clipboard",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
@@ -23,12 +23,9 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "copy-paste": "^1.5.3",
27
- "@initx-plugin/utils": "0.0.5"
28
- },
29
- "devDependencies": {
30
- "@types/copy-paste": "^1.1.33",
31
- "@initx-plugin/types": "0.0.5"
26
+ "clipboardy": "^4.0.0",
27
+ "@initx-plugin/utils": "0.0.7",
28
+ "@initx-plugin/core": "0.0.7"
32
29
  },
33
30
  "scripts": {
34
31
  "stub": "unbuild --stub",