@initx-plugin/cp 0.0.8 → 0.0.10
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -1
- package/package.json +4 -4
- package/dist/index.cjs +0 -58
- package/dist/index.d.cts +0 -17
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,8 @@ class CpHandler extends InitxHandler {
|
|
|
28
28
|
}
|
|
29
29
|
async handle(_options, cpType, ...others) {
|
|
30
30
|
if (!cpType || typeof this[cpType] !== "function") {
|
|
31
|
+
const typeList = CpType;
|
|
32
|
+
log.error(`Please enter the copy type, Available types: ${Object.keys(typeList).map((key) => typeList[key])}`);
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
35
|
this[cpType](...others);
|
|
@@ -48,4 +50,4 @@ class CpHandler extends InitxHandler {
|
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
export { CpHandler };
|
|
53
|
+
export { CpHandler 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.10",
|
|
5
5
|
"description": "initx plugin, copy some text to clipboard",
|
|
6
6
|
"author": "imba97",
|
|
7
7
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"keywords": [
|
|
17
17
|
"initx"
|
|
18
18
|
],
|
|
19
|
-
"main": "dist/index.
|
|
19
|
+
"main": "dist/index.mjs",
|
|
20
20
|
"module": "dist/index.mjs",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
22
|
"files": [
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"clipboardy": "^4.0.0",
|
|
27
|
-
"@initx-plugin/core": "0.0.
|
|
28
|
-
"@initx-plugin/utils": "0.0.
|
|
27
|
+
"@initx-plugin/core": "0.0.10",
|
|
28
|
+
"@initx-plugin/utils": "0.0.10"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"stub": "unbuild --stub",
|
package/dist/index.cjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const os = require('node:os');
|
|
4
|
-
const node_fs = require('node:fs');
|
|
5
|
-
const node_path = require('node:path');
|
|
6
|
-
const clipboard = require('clipboardy');
|
|
7
|
-
const core = require('@initx-plugin/core');
|
|
8
|
-
const utils = require('@initx-plugin/utils');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
|
-
|
|
12
|
-
const os__default = /*#__PURE__*/_interopDefaultCompat(os);
|
|
13
|
-
const clipboard__default = /*#__PURE__*/_interopDefaultCompat(clipboard);
|
|
14
|
-
|
|
15
|
-
var CpType = /* @__PURE__ */ ((CpType2) => {
|
|
16
|
-
CpType2["SSH"] = "ssh";
|
|
17
|
-
return CpType2;
|
|
18
|
-
})(CpType || {});
|
|
19
|
-
|
|
20
|
-
var __defProp = Object.defineProperty;
|
|
21
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
22
|
-
var __publicField = (obj, key, value) => {
|
|
23
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
-
return value;
|
|
25
|
-
};
|
|
26
|
-
class CpHandler extends core.InitxHandler {
|
|
27
|
-
constructor() {
|
|
28
|
-
super(...arguments);
|
|
29
|
-
__publicField(this, "matchers", [
|
|
30
|
-
{
|
|
31
|
-
matching: "cp",
|
|
32
|
-
description: "Copy SSH public key"
|
|
33
|
-
}
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
async handle(_options, cpType, ...others) {
|
|
37
|
-
if (!cpType || typeof this[cpType] !== "function") {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
this[cpType](...others);
|
|
41
|
-
}
|
|
42
|
-
async [CpType.SSH]() {
|
|
43
|
-
const sshDir = node_path.resolve(os__default.homedir(), ".ssh");
|
|
44
|
-
const publicKeyPath = node_path.resolve(sshDir, "id_rsa.pub");
|
|
45
|
-
if (!node_fs.existsSync(publicKeyPath)) {
|
|
46
|
-
utils.log.error(`SSH key not found, path: ${publicKeyPath}`);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const publicKey = node_fs.readFileSync(publicKeyPath, "utf8");
|
|
50
|
-
this.copy(publicKey);
|
|
51
|
-
utils.log.success("Public key copied to clipboard");
|
|
52
|
-
}
|
|
53
|
-
copy(content) {
|
|
54
|
-
clipboard__default.writeSync(content);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
exports.CpHandler = CpHandler;
|
package/dist/index.d.cts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { InitxHandler, InitxOptions } from '@initx-plugin/core';
|
|
2
|
-
|
|
3
|
-
declare enum CpType {
|
|
4
|
-
SSH = "ssh"
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare class CpHandler extends InitxHandler {
|
|
8
|
-
matchers: {
|
|
9
|
-
matching: string;
|
|
10
|
-
description: string;
|
|
11
|
-
}[];
|
|
12
|
-
handle(_options: InitxOptions, cpType: CpType, ...others: string[]): Promise<void>;
|
|
13
|
-
[CpType.SSH](): Promise<void>;
|
|
14
|
-
private copy;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { CpHandler };
|