initx 0.0.6 → 0.0.8

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/dist/cli.cjs ADDED
@@ -0,0 +1,159 @@
1
+ 'use strict';
2
+
3
+ const cac = require('cac');
4
+ const inquirer = require('inquirer');
5
+ const git = require('@initx-plugin/git');
6
+ const cp = require('@initx-plugin/cp');
7
+ const gpg = require('@initx-plugin/gpg');
8
+
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
+
11
+ const cac__default = /*#__PURE__*/_interopDefaultCompat(cac);
12
+ const inquirer__default = /*#__PURE__*/_interopDefaultCompat(inquirer);
13
+
14
+ const pkgJson = {name:"initx",type:"module",version:"0.0.8",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.cjs",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"}};
15
+
16
+ function getDefaultExportFromCjs (x) {
17
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
18
+ }
19
+
20
+ var picocolors = {exports: {}};
21
+
22
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
23
+ let isColorSupported =
24
+ !(!!env.NO_COLOR || argv.includes("--no-color")) &&
25
+ (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
26
+
27
+ let formatter = (open, close, replace = open) =>
28
+ input => {
29
+ let string = "" + input, index = string.indexOf(close, open.length);
30
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
31
+ };
32
+
33
+ let replaceClose = (string, close, replace, index) => {
34
+ let result = "", cursor = 0;
35
+ do {
36
+ result += string.substring(cursor, index) + replace;
37
+ cursor = index + close.length;
38
+ index = string.indexOf(close, cursor);
39
+ } while (~index)
40
+ return result + string.substring(cursor)
41
+ };
42
+
43
+ let createColors = (enabled = isColorSupported) => {
44
+ let f = enabled ? formatter : () => String;
45
+ return {
46
+ isColorSupported: enabled,
47
+ reset: f("\x1b[0m", "\x1b[0m"),
48
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
49
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
50
+ italic: f("\x1b[3m", "\x1b[23m"),
51
+ underline: f("\x1b[4m", "\x1b[24m"),
52
+ inverse: f("\x1b[7m", "\x1b[27m"),
53
+ hidden: f("\x1b[8m", "\x1b[28m"),
54
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
55
+
56
+ black: f("\x1b[30m", "\x1b[39m"),
57
+ red: f("\x1b[31m", "\x1b[39m"),
58
+ green: f("\x1b[32m", "\x1b[39m"),
59
+ yellow: f("\x1b[33m", "\x1b[39m"),
60
+ blue: f("\x1b[34m", "\x1b[39m"),
61
+ magenta: f("\x1b[35m", "\x1b[39m"),
62
+ cyan: f("\x1b[36m", "\x1b[39m"),
63
+ white: f("\x1b[37m", "\x1b[39m"),
64
+ gray: f("\x1b[90m", "\x1b[39m"),
65
+
66
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
67
+ bgRed: f("\x1b[41m", "\x1b[49m"),
68
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
69
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
70
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
71
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
72
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
73
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
74
+
75
+ blackBright: f("\x1b[90m", "\x1b[39m"),
76
+ redBright: f("\x1b[91m", "\x1b[39m"),
77
+ greenBright: f("\x1b[92m", "\x1b[39m"),
78
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
79
+ blueBright: f("\x1b[94m", "\x1b[39m"),
80
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
81
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
82
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
83
+
84
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
85
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
86
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
87
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
88
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
89
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
90
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
91
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
92
+ }
93
+ };
94
+
95
+ picocolors.exports = createColors();
96
+ picocolors.exports.createColors = createColors;
97
+
98
+ var picocolorsExports = picocolors.exports;
99
+ const c = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
100
+
101
+ const log = {
102
+ success: (msg) => console.log(`${c.bgGreen(c.black(" SUCCESS "))} ${msg}`),
103
+ info: (msg) => console.log(`${c.bgBlue(c.white(" INFO "))} ${msg}`),
104
+ warn: (msg) => console.log(`${c.bgYellow(c.black(" WARN "))} ${msg}`),
105
+ error: (msg) => console.log(`${c.bgRed(c.white(" ERROR "))} ${msg}`)
106
+ };
107
+
108
+ const handlers = [
109
+ new git.GitHandler(),
110
+ new cp.CpHandler(),
111
+ new gpg.GpgHandler()
112
+ ];
113
+
114
+ const cli = cac__default("initx");
115
+ cli.help().command("<something>", "see https://github.com/imba97/initx").usage("").option("-v, --version", "Display version number");
116
+ const { args, options: cliOptions } = cli.parse();
117
+ if (cliOptions.h || cliOptions.help) {
118
+ process.exit(0);
119
+ }
120
+ if (cliOptions.v || cliOptions.version) {
121
+ console.log(pkgJson.version);
122
+ process.exit(0);
123
+ }
124
+ const [key, ...others] = args;
125
+ if (!key || typeof key !== "string") {
126
+ log.error("Please enter something");
127
+ process.exit(0);
128
+ }
129
+ const matchedHandlers = [];
130
+ for (const handler of handlers) {
131
+ const matched = handler.run({
132
+ key,
133
+ cliOptions,
134
+ optionsList: Object.keys(cliOptions).filter((key2) => cliOptions[key2] === true).map((key2) => `--${key2}`)
135
+ }, ...others);
136
+ matchedHandlers.push(...matched);
137
+ }
138
+ if (matchedHandlers.length === 0) {
139
+ process.exit(0);
140
+ }
141
+ (async function() {
142
+ if (matchedHandlers.length === 1) {
143
+ const [{ handler }] = matchedHandlers;
144
+ await handler();
145
+ return;
146
+ }
147
+ const { index } = await inquirer__default.prompt([
148
+ {
149
+ type: "list",
150
+ name: "index",
151
+ message: "Which handler do you want to run?",
152
+ choices: matchedHandlers.map(({ description }, index2) => ({
153
+ name: description,
154
+ value: index2
155
+ }))
156
+ }
157
+ ]);
158
+ await matchedHandlers[index]?.handler();
159
+ })();
package/dist/cli.d.cts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
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.6",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/cp":"workspace:*","@initx-plugin/git":"workspace:*",cac:"^6.7.14"},devDependencies:{"@initx-plugin/core":"workspace:*"}};
7
+ const pkgJson = {name:"initx",type:"module",version:"0.0.8",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.cjs",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,26 +100,53 @@ 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");
105
108
  cli.help().command("<something>", "see https://github.com/imba97/initx").usage("").option("-v, --version", "Display version number");
106
- const { args, options } = cli.parse();
107
- if (options.h || options.help) {
109
+ const { args, options: cliOptions } = cli.parse();
110
+ if (cliOptions.h || cliOptions.help) {
108
111
  process.exit(0);
109
112
  }
110
- if (options.v || options.version) {
113
+ if (cliOptions.v || cliOptions.version) {
111
114
  console.log(pkgJson.version);
112
115
  process.exit(0);
113
116
  }
114
- const [something, ...rest] = args;
115
- if (!something || typeof something !== "string") {
117
+ const [key, ...others] = args;
118
+ 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(something, ...rest);
135
+ if (matchedHandlers.length === 1) {
136
+ const [{ handler }] = matchedHandlers;
137
+ await handler();
138
+ return;
122
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();
123
152
  })();
package/dist/index.cjs ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ const git = require('@initx-plugin/git');
4
+ const cp = require('@initx-plugin/cp');
5
+ const core = require('@initx-plugin/core');
6
+
7
+
8
+
9
+ exports.GitHandler = git.GitHandler;
10
+ exports.CpHandler = cp.CpHandler;
11
+ Object.keys(core).forEach(function (k) {
12
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = core[k];
13
+ });
@@ -0,0 +1,3 @@
1
+ export { GitHandler } from '@initx-plugin/git';
2
+ export { CpHandler } from '@initx-plugin/cp';
3
+ export * from '@initx-plugin/core';
package/dist/index.mjs CHANGED
@@ -1,38 +1,3 @@
1
1
  export { GitHandler } from '@initx-plugin/git';
2
2
  export { CpHandler } from '@initx-plugin/cp';
3
-
4
- class InitxHandler {
5
- async run(value, ...others) {
6
- if (this.isObject(this.matchers)) {
7
- const keys = Object.keys(this.matchers);
8
- for (let i = 0; i < keys.length; i++) {
9
- const matcher = this.matchers[keys[i]];
10
- const isPassed2 = this.isPassed(matcher, value);
11
- if (isPassed2) {
12
- this.handle(value, keys[i], ...others);
13
- break;
14
- }
15
- }
16
- return;
17
- }
18
- const isPassed = this.isPassed(this.matchers, value);
19
- if (!isPassed) {
20
- return;
21
- }
22
- await this.handle(value, ...others);
23
- }
24
- isObject(value) {
25
- return typeof value === "object" && value !== null && !Array.isArray(value);
26
- }
27
- isPassed(matchers, value) {
28
- const tests = Array.isArray(matchers) ? matchers : [matchers];
29
- return tests.some((test) => {
30
- if (typeof test === "string") {
31
- return test === value;
32
- }
33
- return test.test(value);
34
- });
35
- }
36
- }
37
-
38
- export { InitxHandler };
3
+ export * from '@initx-plugin/core';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "initx",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "description": "More convenient initialization tool",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
@@ -16,7 +16,7 @@
16
16
  "keywords": [
17
17
  "initx"
18
18
  ],
19
- "main": "dist/index.mjs",
19
+ "main": "dist/index.cjs",
20
20
  "module": "dist/index.mjs",
21
21
  "types": "dist/index.d.ts",
22
22
  "bin": "bin/initx.mjs",
@@ -25,11 +25,11 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "cac": "^6.7.14",
28
- "@initx-plugin/cp": "0.0.6",
29
- "@initx-plugin/git": "0.0.6"
30
- },
31
- "devDependencies": {
32
- "@initx-plugin/core": "0.0.6"
28
+ "inquirer": "^12.0.0",
29
+ "@initx-plugin/core": "0.0.8",
30
+ "@initx-plugin/cp": "0.0.8",
31
+ "@initx-plugin/git": "0.0.8",
32
+ "@initx-plugin/gpg": "0.0.8"
33
33
  },
34
34
  "scripts": {
35
35
  "stub": "unbuild --stub",