initx 0.0.7 → 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.
Files changed (2) hide show
  1. package/dist/cli.mjs +33 -8
  2. package/package.json +6 -4
package/dist/cli.mjs CHANGED
@@ -1,8 +1,10 @@
1
1
  import cac from 'cac';
2
+ import inquirer from 'inquirer';
2
3
  import { GitHandler } from '@initx-plugin/git';
3
4
  import { CpHandler } from '@initx-plugin/cp';
5
+ import { GpgHandler } from '@initx-plugin/gpg';
4
6
 
5
- const pkgJson = {name:"initx",type:"module",version:"0.0.7",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:*",cac:"^6.7.14"}};
7
+ const pkgJson = {name:"initx",type:"module",version:"0.0.9",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"}};
6
8
 
7
9
  function getDefaultExportFromCjs (x) {
8
10
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -98,7 +100,8 @@ const log = {
98
100
 
99
101
  const handlers = [
100
102
  new GitHandler(),
101
- new CpHandler()
103
+ new CpHandler(),
104
+ new GpgHandler()
102
105
  ];
103
106
 
104
107
  const cli = cac("initx");
@@ -116,12 +119,34 @@ if (!key || typeof key !== "string") {
116
119
  log.error("Please enter something");
117
120
  process.exit(0);
118
121
  }
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
+ }
119
134
  (async function() {
120
- for (const handler of handlers) {
121
- await handler.run({
122
- key,
123
- cliOptions,
124
- optionsList: Object.keys(cliOptions).filter((key2) => cliOptions[key2] === true).map((key2) => `--${key2}`)
125
- }, ...others);
135
+ if (matchedHandlers.length === 1) {
136
+ const [{ handler }] = matchedHandlers;
137
+ await handler();
138
+ return;
126
139
  }
140
+ const { index } = await inquirer.prompt([
141
+ {
142
+ type: "list",
143
+ name: "index",
144
+ message: "Which handler do you want to run?",
145
+ choices: matchedHandlers.map(({ description }, index2) => ({
146
+ name: description,
147
+ value: index2
148
+ }))
149
+ }
150
+ ]);
151
+ await matchedHandlers[index]?.handler();
127
152
  })();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "initx",
3
3
  "type": "module",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "description": "More convenient initialization tool",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
@@ -25,9 +25,11 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "cac": "^6.7.14",
28
- "@initx-plugin/core": "0.0.7",
29
- "@initx-plugin/git": "0.0.7",
30
- "@initx-plugin/cp": "0.0.7"
28
+ "inquirer": "^12.0.0",
29
+ "@initx-plugin/cp": "0.0.9",
30
+ "@initx-plugin/core": "0.0.9",
31
+ "@initx-plugin/git": "0.0.9",
32
+ "@initx-plugin/gpg": "0.0.9"
31
33
  },
32
34
  "scripts": {
33
35
  "stub": "unbuild --stub",