@initx-plugin/cp 0.0.8 → 0.0.9

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@initx-plugin/cp",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.9",
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.cjs",
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.8",
28
- "@initx-plugin/utils": "0.0.8"
27
+ "@initx-plugin/core": "0.0.9",
28
+ "@initx-plugin/utils": "0.0.9"
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 };