@initx-plugin/cp 0.0.17 → 0.0.19
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 +12 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +26 -19
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -16,12 +16,24 @@ npm install @initx-plugin/cp -g
|
|
|
16
16
|
|
|
17
17
|
Copy some text to clipboard
|
|
18
18
|
|
|
19
|
+
### Current Working Directory
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx initx cp cwd
|
|
23
|
+
```
|
|
24
|
+
|
|
19
25
|
### SSH Public Key
|
|
20
26
|
|
|
21
27
|
```bash
|
|
22
28
|
npx initx cp ssh
|
|
23
29
|
```
|
|
24
30
|
|
|
31
|
+
### GPG Public Key
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx initx cp gpg
|
|
35
|
+
```
|
|
36
|
+
|
|
25
37
|
## Documentation
|
|
26
38
|
|
|
27
39
|
[initx](https://github.com/initx-collective/initx)
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { InitxPlugin, InitxContext } from '@initx-plugin/core';
|
|
|
2
2
|
|
|
3
3
|
declare enum CpType {
|
|
4
4
|
SSH = "ssh",
|
|
5
|
+
GPG = "gpg",
|
|
5
6
|
CWD = "cwd"
|
|
6
7
|
}
|
|
7
8
|
|
|
@@ -12,6 +13,7 @@ declare class CpPlugin extends InitxPlugin {
|
|
|
12
13
|
}[];
|
|
13
14
|
handle(_ctx: InitxContext, cpType: CpType, ...others: string[]): Promise<void>;
|
|
14
15
|
[CpType.SSH](): Promise<void>;
|
|
16
|
+
[CpType.GPG](): Promise<void>;
|
|
15
17
|
[CpType.CWD](): Promise<void>;
|
|
16
18
|
private copy;
|
|
17
19
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { InitxPlugin, InitxContext } from '@initx-plugin/core';
|
|
|
2
2
|
|
|
3
3
|
declare enum CpType {
|
|
4
4
|
SSH = "ssh",
|
|
5
|
+
GPG = "gpg",
|
|
5
6
|
CWD = "cwd"
|
|
6
7
|
}
|
|
7
8
|
|
|
@@ -12,6 +13,7 @@ declare class CpPlugin extends InitxPlugin {
|
|
|
12
13
|
}[];
|
|
13
14
|
handle(_ctx: InitxContext, cpType: CpType, ...others: string[]): Promise<void>;
|
|
14
15
|
[CpType.SSH](): Promise<void>;
|
|
16
|
+
[CpType.GPG](): Promise<void>;
|
|
15
17
|
[CpType.CWD](): Promise<void>;
|
|
16
18
|
private copy;
|
|
17
19
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
import os from 'node:os';
|
|
2
|
-
import { cwd } from 'node:process';
|
|
3
1
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
4
3
|
import { resolve } from 'node:path';
|
|
5
|
-
import
|
|
4
|
+
import { cwd } from 'node:process';
|
|
6
5
|
import { InitxPlugin } from '@initx-plugin/core';
|
|
7
|
-
import { log, inquirer } from '@initx-plugin/utils';
|
|
6
|
+
import { log, inquirer, gpgList, c } from '@initx-plugin/utils';
|
|
7
|
+
import clipboard from 'clipboardy';
|
|
8
8
|
|
|
9
9
|
var CpType = /* @__PURE__ */ ((CpType2) => {
|
|
10
10
|
CpType2["SSH"] = "ssh";
|
|
11
|
+
CpType2["GPG"] = "gpg";
|
|
11
12
|
CpType2["CWD"] = "cwd";
|
|
12
13
|
return CpType2;
|
|
13
14
|
})(CpType || {});
|
|
14
15
|
|
|
15
|
-
var __defProp = Object.defineProperty;
|
|
16
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
-
var __publicField = (obj, key, value) => {
|
|
18
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
|
-
return value;
|
|
20
|
-
};
|
|
21
16
|
class CpPlugin extends InitxPlugin {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
17
|
+
matchers = [
|
|
18
|
+
{
|
|
19
|
+
matching: "cp",
|
|
20
|
+
description: "Copy SSH public key"
|
|
21
|
+
}
|
|
22
|
+
];
|
|
31
23
|
async handle(_ctx, cpType, ...others) {
|
|
32
24
|
if (!cpType || typeof this[cpType] !== "function") {
|
|
33
25
|
const typeList = CpType;
|
|
@@ -60,6 +52,21 @@ class CpPlugin extends InitxPlugin {
|
|
|
60
52
|
this.copy(publicKey);
|
|
61
53
|
log.success("Key copied to clipboard");
|
|
62
54
|
}
|
|
55
|
+
async [CpType.GPG]() {
|
|
56
|
+
const list = await gpgList();
|
|
57
|
+
if (list.length === 0) {
|
|
58
|
+
log.error("No GPG keys found");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let index = 0;
|
|
62
|
+
if (list.length > 1) {
|
|
63
|
+
index = await inquirer.select("Select GPG key", list.map(({ key: key2, name, email }) => `${key2} - ${name} <${email}>`));
|
|
64
|
+
}
|
|
65
|
+
const { key } = list[index];
|
|
66
|
+
const result = await c("gpg", ["--armor", "--export", key]);
|
|
67
|
+
this.copy(result.content);
|
|
68
|
+
log.success("GPG public key copied to clipboard");
|
|
69
|
+
}
|
|
63
70
|
async [CpType.CWD]() {
|
|
64
71
|
this.copy(cwd());
|
|
65
72
|
log.success("Current working directory copied to clipboard");
|
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.19",
|
|
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": "^0.0.
|
|
28
|
-
"@initx-plugin/utils": "^0.0.
|
|
27
|
+
"@initx-plugin/core": "^0.0.27",
|
|
28
|
+
"@initx-plugin/utils": "^0.0.27",
|
|
29
29
|
"clipboardy": "^4.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@imba97/eslint-config": "^0.0.
|
|
33
|
-
"@types/node": "^22.
|
|
34
|
-
"bumpp": "^9.
|
|
35
|
-
"eslint": "^9.
|
|
36
|
-
"lint-staged": "^15.
|
|
32
|
+
"@imba97/eslint-config": "^0.0.5",
|
|
33
|
+
"@types/node": "^22.10.2",
|
|
34
|
+
"bumpp": "^9.9.2",
|
|
35
|
+
"eslint": "^9.17.0",
|
|
36
|
+
"lint-staged": "^15.3.0",
|
|
37
37
|
"simple-git-hooks": "^2.11.1",
|
|
38
|
-
"typescript": "5.
|
|
39
|
-
"unbuild": "^
|
|
40
|
-
"vitest": "^2.1.
|
|
38
|
+
"typescript": "^5.7.2",
|
|
39
|
+
"unbuild": "^3.1.0",
|
|
40
|
+
"vitest": "^2.1.8"
|
|
41
41
|
},
|
|
42
42
|
"simple-git-hooks": {
|
|
43
43
|
"pre-commit": "pnpm lint-staged"
|