@initx-plugin/cp 0.0.13 → 0.0.14
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 +1 -1
- package/dist/index.mjs +19 -6
- package/package.json +29 -9
package/README.md
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import clipboard from 'clipboardy';
|
|
5
5
|
import { InitxHandler } from '@initx-plugin/core';
|
|
6
|
-
import { log } from '@initx-plugin/utils';
|
|
6
|
+
import { log, inquirer } from '@initx-plugin/utils';
|
|
7
7
|
|
|
8
8
|
var CpType = /* @__PURE__ */ ((CpType2) => {
|
|
9
9
|
CpType2["SSH"] = "ssh";
|
|
@@ -36,14 +36,27 @@ class CpHandler extends InitxHandler {
|
|
|
36
36
|
}
|
|
37
37
|
async [CpType.SSH]() {
|
|
38
38
|
const sshDir = resolve(os.homedir(), ".ssh");
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
log.error(`SSH key not found, path: ${publicKeyPath}`);
|
|
39
|
+
if (!existsSync(sshDir)) {
|
|
40
|
+
log.error(`SSH directory not found, path: ${sshDir}`);
|
|
42
41
|
return;
|
|
43
42
|
}
|
|
43
|
+
const publicKeysName = readdirSync(sshDir).filter((file) => file.endsWith(".pub"));
|
|
44
|
+
if (publicKeysName.length === 0) {
|
|
45
|
+
log.error("SSH key not found");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let publicKeyName;
|
|
49
|
+
if (publicKeysName.length === 1) {
|
|
50
|
+
const [firstKey] = publicKeysName;
|
|
51
|
+
publicKeyName = firstKey;
|
|
52
|
+
} else {
|
|
53
|
+
const index = await inquirer.select("Select SSH key", publicKeysName);
|
|
54
|
+
publicKeyName = publicKeysName[index];
|
|
55
|
+
}
|
|
56
|
+
const publicKeyPath = resolve(sshDir, publicKeyName);
|
|
44
57
|
const publicKey = readFileSync(publicKeyPath, "utf8");
|
|
45
58
|
this.copy(publicKey);
|
|
46
|
-
log.success("
|
|
59
|
+
log.success("Key copied to clipboard");
|
|
47
60
|
}
|
|
48
61
|
copy(content) {
|
|
49
62
|
clipboard.writeSync(content);
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@initx-plugin/cp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"description": "initx plugin, copy some text to clipboard",
|
|
6
6
|
"author": "imba97",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://github.com/
|
|
8
|
+
"homepage": "https://github.com/initx-collective/initx-plugin-cp#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git
|
|
11
|
+
"url": "git@github.com:initx-collective/initx-plugin-cp.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/initx-collective/initx-plugin-cp/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
|
-
"initx"
|
|
17
|
+
"initx-plugin",
|
|
18
|
+
"copy"
|
|
18
19
|
],
|
|
19
20
|
"main": "dist/index.mjs",
|
|
20
21
|
"module": "dist/index.mjs",
|
|
@@ -23,12 +24,31 @@
|
|
|
23
24
|
"dist"
|
|
24
25
|
],
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"
|
|
27
|
-
"@initx-plugin/
|
|
28
|
-
"
|
|
27
|
+
"@initx-plugin/core": "latest",
|
|
28
|
+
"@initx-plugin/utils": "latest",
|
|
29
|
+
"clipboardy": "^4.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@imba97/eslint-config": "^0.0.4",
|
|
33
|
+
"@types/node": "^22.8.2",
|
|
34
|
+
"bumpp": "^9.8.0",
|
|
35
|
+
"eslint": "^9.13.0",
|
|
36
|
+
"lint-staged": "^15.2.10",
|
|
37
|
+
"simple-git-hooks": "^2.11.1",
|
|
38
|
+
"typescript": "5.5.4",
|
|
39
|
+
"unbuild": "^2.0.0",
|
|
40
|
+
"vitest": "^2.1.4"
|
|
41
|
+
},
|
|
42
|
+
"simple-git-hooks": {
|
|
43
|
+
"pre-commit": "pnpm lint-staged"
|
|
44
|
+
},
|
|
45
|
+
"lint-staged": {
|
|
46
|
+
"*": "eslint --cache --flag unstable_ts_config --fix"
|
|
29
47
|
},
|
|
30
48
|
"scripts": {
|
|
31
49
|
"stub": "unbuild --stub",
|
|
32
|
-
"build": "unbuild"
|
|
50
|
+
"build": "unbuild",
|
|
51
|
+
"lint": "eslint --cache --flag unstable_ts_config",
|
|
52
|
+
"release": "bumpp"
|
|
33
53
|
}
|
|
34
54
|
}
|