initx 0.0.10 → 0.0.12

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 CHANGED
@@ -1,11 +1,15 @@
1
1
  <h1 align="center">init 🛠</h1>
2
2
 
3
- <p align="center"><code>initx</code> More convenient initialization tool</p>
3
+ <p align="center"><code>initx</code> More convenient initialization engine</p>
4
4
 
5
5
  <pre align="center">npx <b>initx &lt;something&gt;</b></pre>
6
6
 
7
7
  ## Git
8
8
 
9
+ ```bash
10
+ npm install @initx-plugin/git -g
11
+ ```
12
+
9
13
  ### Git Repository
10
14
 
11
15
  Create a new repository or modify the remote repository address in the current directory
@@ -35,15 +39,17 @@ npx initx user mail@example.com your_name
35
39
  Select `Enable or disable GPG signing for git commits`, Set git commit signature
36
40
 
37
41
  ```bash
38
- # Enable
42
+ # npx initx gpg [true|false]
39
43
  npx initx gpg true
40
- # Disable
41
- npx initx gpg false
42
44
  ```
43
45
 
44
46
  ## GPG
45
47
 
46
- Select `Import or Export GPG key`
48
+ ```bash
49
+ npm install @initx-plugin/gpg -g
50
+ ```
51
+
52
+ Select `GPG key management`
47
53
 
48
54
  ### GPG import
49
55
 
@@ -58,14 +64,27 @@ npx initx gpg import
58
64
  Export the public key and private key to the current directory
59
65
 
60
66
  ```bash
61
- # npx initx gpg export key_id filename
62
- npx initx gpg export 92038B3E14C0D332542FB082B851A3E43D739400 home
67
+ # npx initx gpg export [filename]?
68
+ npx initx gpg export home
63
69
  ```
64
70
 
65
71
  `home_public.key` and `home_private.key` will be created in the current directory
66
72
 
73
+ ### GPG delete
74
+
75
+ Delete the public key and private key
76
+
77
+ ```bash
78
+ # npx initx gpg delete [public|private]?
79
+ npx initx gpg delete
80
+ ```
81
+
67
82
  ## Clipboard
68
83
 
84
+ ```bash
85
+ npm install @initx-plugin/cp -g
86
+ ```
87
+
69
88
  Copy some text to clipboard
70
89
 
71
90
  ### SSH Public Key
package/dist/cli.mjs CHANGED
@@ -1,108 +1,9 @@
1
1
  import cac from 'cac';
2
2
  import inquirer from 'inquirer';
3
- import GitHandler from '@initx-plugin/git';
4
- import CpHandler from '@initx-plugin/cp';
5
- import GpgHandler from '@initx-plugin/gpg';
3
+ import { log } from '@initx-plugin/utils';
4
+ import { loadPlugins } from '@initx-plugin/core';
6
5
 
7
- const pkgJson = {name:"initx",type:"module",version:"0.0.10",packageManager:"pnpm@9.12.2",description:"More convenient initialization tool",author:"imba97",license:"MIT",homepage:"https://github.com/imba97/initx#readme",repository:{type:"git",url:"git+ssh://git@github.com/imba97/initx"},bugs:{url:"https://github.com/imba97/initx/issues"},keywords:["initx"],main:"dist/index.mjs",module:"dist/index.mjs",types:"dist/index.d.ts",bin:"bin/initx.mjs",files:["dist"],scripts:{stub:"unbuild --stub",build:"unbuild"},dependencies:{"@initx-plugin/core":"workspace:*","@initx-plugin/cp":"workspace:*","@initx-plugin/git":"workspace:*","@initx-plugin/gpg":"workspace:*",cac:"^6.7.14",inquirer:"^12.0.0"}};
8
-
9
- function getDefaultExportFromCjs (x) {
10
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
- }
12
-
13
- var picocolors = {exports: {}};
14
-
15
- let p = process || {}, argv = p.argv || [], env = p.env || {};
16
- let isColorSupported =
17
- !(!!env.NO_COLOR || argv.includes("--no-color")) &&
18
- (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
19
-
20
- let formatter = (open, close, replace = open) =>
21
- input => {
22
- let string = "" + input, index = string.indexOf(close, open.length);
23
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
24
- };
25
-
26
- let replaceClose = (string, close, replace, index) => {
27
- let result = "", cursor = 0;
28
- do {
29
- result += string.substring(cursor, index) + replace;
30
- cursor = index + close.length;
31
- index = string.indexOf(close, cursor);
32
- } while (~index)
33
- return result + string.substring(cursor)
34
- };
35
-
36
- let createColors = (enabled = isColorSupported) => {
37
- let f = enabled ? formatter : () => String;
38
- return {
39
- isColorSupported: enabled,
40
- reset: f("\x1b[0m", "\x1b[0m"),
41
- bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
42
- dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
43
- italic: f("\x1b[3m", "\x1b[23m"),
44
- underline: f("\x1b[4m", "\x1b[24m"),
45
- inverse: f("\x1b[7m", "\x1b[27m"),
46
- hidden: f("\x1b[8m", "\x1b[28m"),
47
- strikethrough: f("\x1b[9m", "\x1b[29m"),
48
-
49
- black: f("\x1b[30m", "\x1b[39m"),
50
- red: f("\x1b[31m", "\x1b[39m"),
51
- green: f("\x1b[32m", "\x1b[39m"),
52
- yellow: f("\x1b[33m", "\x1b[39m"),
53
- blue: f("\x1b[34m", "\x1b[39m"),
54
- magenta: f("\x1b[35m", "\x1b[39m"),
55
- cyan: f("\x1b[36m", "\x1b[39m"),
56
- white: f("\x1b[37m", "\x1b[39m"),
57
- gray: f("\x1b[90m", "\x1b[39m"),
58
-
59
- bgBlack: f("\x1b[40m", "\x1b[49m"),
60
- bgRed: f("\x1b[41m", "\x1b[49m"),
61
- bgGreen: f("\x1b[42m", "\x1b[49m"),
62
- bgYellow: f("\x1b[43m", "\x1b[49m"),
63
- bgBlue: f("\x1b[44m", "\x1b[49m"),
64
- bgMagenta: f("\x1b[45m", "\x1b[49m"),
65
- bgCyan: f("\x1b[46m", "\x1b[49m"),
66
- bgWhite: f("\x1b[47m", "\x1b[49m"),
67
-
68
- blackBright: f("\x1b[90m", "\x1b[39m"),
69
- redBright: f("\x1b[91m", "\x1b[39m"),
70
- greenBright: f("\x1b[92m", "\x1b[39m"),
71
- yellowBright: f("\x1b[93m", "\x1b[39m"),
72
- blueBright: f("\x1b[94m", "\x1b[39m"),
73
- magentaBright: f("\x1b[95m", "\x1b[39m"),
74
- cyanBright: f("\x1b[96m", "\x1b[39m"),
75
- whiteBright: f("\x1b[97m", "\x1b[39m"),
76
-
77
- bgBlackBright: f("\x1b[100m", "\x1b[49m"),
78
- bgRedBright: f("\x1b[101m", "\x1b[49m"),
79
- bgGreenBright: f("\x1b[102m", "\x1b[49m"),
80
- bgYellowBright: f("\x1b[103m", "\x1b[49m"),
81
- bgBlueBright: f("\x1b[104m", "\x1b[49m"),
82
- bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
83
- bgCyanBright: f("\x1b[106m", "\x1b[49m"),
84
- bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
85
- }
86
- };
87
-
88
- picocolors.exports = createColors();
89
- picocolors.exports.createColors = createColors;
90
-
91
- var picocolorsExports = picocolors.exports;
92
- const c = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
93
-
94
- const log = {
95
- success: (msg) => console.log(`${c.bgGreen(c.black(" SUCCESS "))} ${msg}`),
96
- info: (msg) => console.log(`${c.bgBlue(c.white(" INFO "))} ${msg}`),
97
- warn: (msg) => console.log(`${c.bgYellow(c.black(" WARN "))} ${msg}`),
98
- error: (msg) => console.log(`${c.bgRed(c.white(" ERROR "))} ${msg}`)
99
- };
100
-
101
- const handlers = [
102
- new GitHandler(),
103
- new CpHandler(),
104
- new GpgHandler()
105
- ];
6
+ const pkgJson = {name:"initx",type:"module",version:"0.0.12",packageManager:"pnpm@9.12.2",description:"More convenient initialization engine",author:"imba97",license:"MIT",homepage:"https://github.com/imba97/initx#readme",repository:{type:"git",url:"git+ssh://git@github.com/imba97/initx"},bugs:{url:"https://github.com/imba97/initx/issues"},keywords:["initx"],main:"dist/index.mjs",module:"dist/index.mjs",types:"dist/index.d.ts",bin:"bin/initx.mjs",files:["dist"],scripts:{stub:"unbuild --stub",build:"unbuild"},dependencies:{"@initx-plugin/core":"workspace:*","@initx-plugin/utils":"workspace:*",cac:"^6.7.14",inquirer:"^12.0.0"}};
106
7
 
107
8
  const cli = cac("initx");
108
9
  cli.help().command("<something>", "see https://github.com/imba97/initx").usage("").option("-v, --version", "Display version number");
@@ -119,19 +20,29 @@ if (!key || typeof key !== "string") {
119
20
  log.error("Please enter something");
120
21
  process.exit(0);
121
22
  }
122
- const matchedHandlers = [];
123
- for (const handler of handlers) {
124
- const matched = handler.run({
125
- key,
126
- cliOptions,
127
- optionsList: Object.keys(cliOptions).filter((key2) => cliOptions[key2] === true).map((key2) => `--${key2}`)
128
- }, ...others);
129
- matchedHandlers.push(...matched);
130
- }
131
- if (matchedHandlers.length === 0) {
132
- process.exit(0);
133
- }
134
23
  (async function() {
24
+ const plugins = await loadPlugins();
25
+ if (plugins.length === 0) {
26
+ log.error("No plugin installed");
27
+ process.exit(0);
28
+ }
29
+ const matchedHandlers = [];
30
+ for (const plugin of plugins) {
31
+ const { handler, packageInfo } = plugin;
32
+ const matched = handler.run({
33
+ key,
34
+ cliOptions,
35
+ optionsList: Object.keys(cliOptions).filter((key2) => cliOptions[key2] === true).map((key2) => `--${key2}`)
36
+ }, ...others);
37
+ matchedHandlers.push(...matched.map((item) => ({
38
+ handler: item.handler,
39
+ description: item.description,
40
+ packageInfo
41
+ })));
42
+ }
43
+ if (matchedHandlers.length === 0) {
44
+ process.exit(0);
45
+ }
135
46
  if (matchedHandlers.length === 1) {
136
47
  const [{ handler }] = matchedHandlers;
137
48
  await handler();
@@ -142,11 +53,15 @@ if (matchedHandlers.length === 0) {
142
53
  type: "list",
143
54
  name: "index",
144
55
  message: "Which handler do you want to run?",
145
- choices: matchedHandlers.map(({ description }, index2) => ({
146
- name: description,
56
+ choices: matchedHandlers.map(({ description, packageInfo }, index2) => ({
57
+ name: `[${packageInfo.name.replace(/^@?initx-plugin[-/]/, "")}] ${description}`,
147
58
  value: index2
148
59
  }))
149
60
  }
150
61
  ]);
151
- await matchedHandlers[index]?.handler();
62
+ if (!matchedHandlers[index] || typeof matchedHandlers[index].handler !== "function") {
63
+ log.error("Handler not found");
64
+ process.exit(0);
65
+ }
66
+ await matchedHandlers[index].handler();
152
67
  })();
package/dist/index.d.mts CHANGED
@@ -1,4 +1 @@
1
- export { default as GitHandler } from '@initx-plugin/git';
2
- export { default as CpHandler } from '@initx-plugin/cp';
3
- export { default as GpgHandler } from '@initx-plugin/gpg';
4
1
  export * from '@initx-plugin/core';
package/dist/index.d.ts CHANGED
@@ -1,4 +1 @@
1
- export { default as GitHandler } from '@initx-plugin/git';
2
- export { default as CpHandler } from '@initx-plugin/cp';
3
- export { default as GpgHandler } from '@initx-plugin/gpg';
4
1
  export * from '@initx-plugin/core';
package/dist/index.mjs CHANGED
@@ -1,4 +1 @@
1
- export { default as GitHandler } from '@initx-plugin/git';
2
- export { default as CpHandler } from '@initx-plugin/cp';
3
- export { default as GpgHandler } from '@initx-plugin/gpg';
4
1
  export * from '@initx-plugin/core';
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "initx",
3
3
  "type": "module",
4
- "version": "0.0.10",
5
- "description": "More convenient initialization tool",
4
+ "version": "0.0.12",
5
+ "description": "More convenient initialization engine",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/imba97/initx#readme",
@@ -26,10 +26,8 @@
26
26
  "dependencies": {
27
27
  "cac": "^6.7.14",
28
28
  "inquirer": "^12.0.0",
29
- "@initx-plugin/core": "0.0.10",
30
- "@initx-plugin/cp": "0.0.10",
31
- "@initx-plugin/gpg": "0.0.10",
32
- "@initx-plugin/git": "0.0.10"
29
+ "@initx-plugin/core": "0.0.12",
30
+ "@initx-plugin/utils": "0.0.12"
33
31
  },
34
32
  "scripts": {
35
33
  "stub": "unbuild --stub",