@initx-plugin/cp 0.0.16 → 0.0.18
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/README.md +6 -0
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +25 -3
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { InitxPlugin, InitxContext } from '@initx-plugin/core';
|
|
2
2
|
|
|
3
3
|
declare enum CpType {
|
|
4
|
-
SSH = "ssh"
|
|
4
|
+
SSH = "ssh",
|
|
5
|
+
GPG = "gpg",
|
|
6
|
+
CWD = "cwd"
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
declare class
|
|
9
|
+
declare class CpPlugin extends InitxPlugin {
|
|
8
10
|
matchers: {
|
|
9
11
|
matching: string;
|
|
10
12
|
description: string;
|
|
11
13
|
}[];
|
|
12
14
|
handle(_ctx: InitxContext, cpType: CpType, ...others: string[]): Promise<void>;
|
|
13
15
|
[CpType.SSH](): Promise<void>;
|
|
16
|
+
[CpType.GPG](): Promise<void>;
|
|
17
|
+
[CpType.CWD](): Promise<void>;
|
|
14
18
|
private copy;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
export {
|
|
21
|
+
export { CpPlugin as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { InitxPlugin, InitxContext } from '@initx-plugin/core';
|
|
2
2
|
|
|
3
3
|
declare enum CpType {
|
|
4
|
-
SSH = "ssh"
|
|
4
|
+
SSH = "ssh",
|
|
5
|
+
GPG = "gpg",
|
|
6
|
+
CWD = "cwd"
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
declare class
|
|
9
|
+
declare class CpPlugin extends InitxPlugin {
|
|
8
10
|
matchers: {
|
|
9
11
|
matching: string;
|
|
10
12
|
description: string;
|
|
11
13
|
}[];
|
|
12
14
|
handle(_ctx: InitxContext, cpType: CpType, ...others: string[]): Promise<void>;
|
|
13
15
|
[CpType.SSH](): Promise<void>;
|
|
16
|
+
[CpType.GPG](): Promise<void>;
|
|
17
|
+
[CpType.CWD](): Promise<void>;
|
|
14
18
|
private copy;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
export {
|
|
21
|
+
export { CpPlugin as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
|
+
import { cwd } from 'node:process';
|
|
2
3
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
4
|
import { resolve } from 'node:path';
|
|
4
5
|
import clipboard from 'clipboardy';
|
|
5
6
|
import { InitxPlugin } from '@initx-plugin/core';
|
|
6
|
-
import { log, inquirer } from '@initx-plugin/utils';
|
|
7
|
+
import { log, inquirer, gpgList, c } from '@initx-plugin/utils';
|
|
7
8
|
|
|
8
9
|
var CpType = /* @__PURE__ */ ((CpType2) => {
|
|
9
10
|
CpType2["SSH"] = "ssh";
|
|
11
|
+
CpType2["GPG"] = "gpg";
|
|
12
|
+
CpType2["CWD"] = "cwd";
|
|
10
13
|
return CpType2;
|
|
11
14
|
})(CpType || {});
|
|
12
15
|
|
|
@@ -16,7 +19,7 @@ var __publicField = (obj, key, value) => {
|
|
|
16
19
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
17
20
|
return value;
|
|
18
21
|
};
|
|
19
|
-
class
|
|
22
|
+
class CpPlugin extends InitxPlugin {
|
|
20
23
|
constructor() {
|
|
21
24
|
super(...arguments);
|
|
22
25
|
__publicField(this, "matchers", [
|
|
@@ -58,9 +61,28 @@ class CpHandler extends InitxPlugin {
|
|
|
58
61
|
this.copy(publicKey);
|
|
59
62
|
log.success("Key copied to clipboard");
|
|
60
63
|
}
|
|
64
|
+
async [CpType.GPG]() {
|
|
65
|
+
const list = await gpgList();
|
|
66
|
+
if (list.length === 0) {
|
|
67
|
+
log.error("No GPG keys found");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let index = 0;
|
|
71
|
+
if (list.length > 1) {
|
|
72
|
+
index = await inquirer.select("Select GPG key", list.map(({ key: key2, name, email }) => `${key2} - ${name} <${email}>`));
|
|
73
|
+
}
|
|
74
|
+
const { key } = list[index];
|
|
75
|
+
const result = await c("gpg", ["--armor", "--export", key]);
|
|
76
|
+
this.copy(result.content);
|
|
77
|
+
log.success("GPG public key copied to clipboard");
|
|
78
|
+
}
|
|
79
|
+
async [CpType.CWD]() {
|
|
80
|
+
this.copy(cwd());
|
|
81
|
+
log.success("Current working directory copied to clipboard");
|
|
82
|
+
}
|
|
61
83
|
copy(content) {
|
|
62
84
|
clipboard.writeSync(content);
|
|
63
85
|
}
|
|
64
86
|
}
|
|
65
87
|
|
|
66
|
-
export {
|
|
88
|
+
export { CpPlugin as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@initx-plugin/cp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.18",
|
|
5
5
|
"description": "initx plugin, copy some text to clipboard",
|
|
6
6
|
"author": "imba97",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@initx-plugin/core": "
|
|
28
|
-
"@initx-plugin/utils": "
|
|
27
|
+
"@initx-plugin/core": "^0.0.23",
|
|
28
|
+
"@initx-plugin/utils": "^0.0.23",
|
|
29
29
|
"clipboardy": "^4.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@imba97/eslint-config": "^0.0.4",
|
|
33
33
|
"@types/node": "^22.9.0",
|
|
34
34
|
"bumpp": "^9.8.1",
|
|
35
|
-
"eslint": "^9.
|
|
35
|
+
"eslint": "^9.15.0",
|
|
36
36
|
"lint-staged": "^15.2.10",
|
|
37
37
|
"simple-git-hooks": "^2.11.1",
|
|
38
38
|
"typescript": "5.5.4",
|
|
39
39
|
"unbuild": "^2.0.0",
|
|
40
|
-
"vitest": "^2.1.
|
|
40
|
+
"vitest": "^2.1.5"
|
|
41
41
|
},
|
|
42
42
|
"simple-git-hooks": {
|
|
43
43
|
"pre-commit": "pnpm lint-staged"
|