initx 0.0.3 → 0.0.4
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.d.mts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.mjs +121 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +19 -0
- package/package.json +3 -3
package/dist/cli.d.mts
ADDED
package/dist/cli.d.ts
ADDED
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import cac from 'cac';
|
|
2
|
+
import { GitHandler } from '@initx-plugin/git';
|
|
3
|
+
|
|
4
|
+
const pkgJson = {name:"initx",type:"module",version:"0.0.4",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/git":"workspace:*",cac:"^6.7.14",execa:"^9.4.1"},devDependencies:{"@initx-plugin/types":"workspace:*"}};
|
|
5
|
+
|
|
6
|
+
function getDefaultExportFromCjs (x) {
|
|
7
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var picocolors = {exports: {}};
|
|
11
|
+
|
|
12
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
13
|
+
let isColorSupported =
|
|
14
|
+
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
15
|
+
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
16
|
+
|
|
17
|
+
let formatter = (open, close, replace = open) =>
|
|
18
|
+
input => {
|
|
19
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
20
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let replaceClose = (string, close, replace, index) => {
|
|
24
|
+
let result = "", cursor = 0;
|
|
25
|
+
do {
|
|
26
|
+
result += string.substring(cursor, index) + replace;
|
|
27
|
+
cursor = index + close.length;
|
|
28
|
+
index = string.indexOf(close, cursor);
|
|
29
|
+
} while (~index)
|
|
30
|
+
return result + string.substring(cursor)
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let createColors = (enabled = isColorSupported) => {
|
|
34
|
+
let f = enabled ? formatter : () => String;
|
|
35
|
+
return {
|
|
36
|
+
isColorSupported: enabled,
|
|
37
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
38
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
39
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
40
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
41
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
42
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
43
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
44
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
45
|
+
|
|
46
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
47
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
48
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
49
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
50
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
51
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
52
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
53
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
54
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
55
|
+
|
|
56
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
57
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
58
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
59
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
60
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
61
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
62
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
63
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
64
|
+
|
|
65
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
66
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
67
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
68
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
69
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
70
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
71
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
72
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
73
|
+
|
|
74
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
75
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
76
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
77
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
78
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
79
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
80
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
81
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
picocolors.exports = createColors();
|
|
86
|
+
picocolors.exports.createColors = createColors;
|
|
87
|
+
|
|
88
|
+
var picocolorsExports = picocolors.exports;
|
|
89
|
+
const c = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
90
|
+
|
|
91
|
+
const log = {
|
|
92
|
+
success: (msg) => console.log(`${c.bgGreen(c.black(" SUCCESS "))} ${msg}`),
|
|
93
|
+
info: (msg) => console.log(`${c.bgBlue(c.white(" INFO "))} ${msg}`),
|
|
94
|
+
warn: (msg) => console.log(`${c.bgYellow(c.black(" WARN "))} ${msg}`),
|
|
95
|
+
error: (msg) => console.log(`${c.bgRed(c.white(" ERROR "))} ${msg}`)
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const handlers = [
|
|
99
|
+
new GitHandler()
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
const cli = cac("initx");
|
|
103
|
+
cli.help().command("<something>", "Enter something").usage("").option("-v, --version", "Display version number");
|
|
104
|
+
const { args, options } = cli.parse();
|
|
105
|
+
if (options.h || options.help) {
|
|
106
|
+
process.exit(0);
|
|
107
|
+
}
|
|
108
|
+
if (options.v || options.version) {
|
|
109
|
+
console.log(pkgJson.version);
|
|
110
|
+
process.exit(0);
|
|
111
|
+
}
|
|
112
|
+
const [something, ...rest] = args;
|
|
113
|
+
if (!something || typeof something !== "string") {
|
|
114
|
+
log.error("Please enter something");
|
|
115
|
+
process.exit(0);
|
|
116
|
+
}
|
|
117
|
+
(async function() {
|
|
118
|
+
for (const handler of handlers) {
|
|
119
|
+
await handler.run(something, ...rest);
|
|
120
|
+
}
|
|
121
|
+
})();
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { GitHandler } from '@initx-plugin/git';
|
|
2
|
+
|
|
3
|
+
class InitxHandler {
|
|
4
|
+
async run(value, ...rest) {
|
|
5
|
+
const tests = Array.isArray(this.matchers) ? this.matchers : [this.matchers];
|
|
6
|
+
const passed = tests.some((test) => {
|
|
7
|
+
if (typeof test === "string") {
|
|
8
|
+
return test === value;
|
|
9
|
+
}
|
|
10
|
+
return test.test(value);
|
|
11
|
+
});
|
|
12
|
+
if (!passed) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
await this.handle(value, ...rest);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { InitxHandler };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "initx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "More convenient initialization tool",
|
|
6
6
|
"author": "imba97",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"cac": "^6.7.14",
|
|
28
28
|
"execa": "^9.4.1",
|
|
29
|
-
"@initx-plugin/git": "0.0.
|
|
29
|
+
"@initx-plugin/git": "0.0.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@initx-plugin/types": "0.0.
|
|
32
|
+
"@initx-plugin/types": "0.0.4"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"stub": "unbuild --stub",
|