initx 0.0.4 → 0.0.6
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.mjs +5 -3
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +26 -7
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import cac from 'cac';
|
|
2
2
|
import { GitHandler } from '@initx-plugin/git';
|
|
3
|
+
import { CpHandler } from '@initx-plugin/cp';
|
|
3
4
|
|
|
4
|
-
const pkgJson = {name:"initx",type:"module",version:"0.0.
|
|
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:*"}};
|
|
5
6
|
|
|
6
7
|
function getDefaultExportFromCjs (x) {
|
|
7
8
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -96,11 +97,12 @@ const log = {
|
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
const handlers = [
|
|
99
|
-
new GitHandler()
|
|
100
|
+
new GitHandler(),
|
|
101
|
+
new CpHandler()
|
|
100
102
|
];
|
|
101
103
|
|
|
102
104
|
const cli = cac("initx");
|
|
103
|
-
cli.help().command("<something>", "
|
|
105
|
+
cli.help().command("<something>", "see https://github.com/imba97/initx").usage("").option("-v, --version", "Display version number");
|
|
104
106
|
const { args, options } = cli.parse();
|
|
105
107
|
if (options.h || options.help) {
|
|
106
108
|
process.exit(0);
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
export { GitHandler } from '@initx-plugin/git';
|
|
2
|
+
export { CpHandler } from '@initx-plugin/cp';
|
|
2
3
|
|
|
3
4
|
class InitxHandler {
|
|
4
|
-
async run(value, ...
|
|
5
|
-
|
|
6
|
-
|
|
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) => {
|
|
7
30
|
if (typeof test === "string") {
|
|
8
31
|
return test === value;
|
|
9
32
|
}
|
|
10
33
|
return test.test(value);
|
|
11
34
|
});
|
|
12
|
-
if (!passed) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
await this.handle(value, ...rest);
|
|
16
35
|
}
|
|
17
36
|
}
|
|
18
37
|
|
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.6",
|
|
5
5
|
"description": "More convenient initialization tool",
|
|
6
6
|
"author": "imba97",
|
|
7
7
|
"license": "MIT",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"cac": "^6.7.14",
|
|
28
|
-
"
|
|
29
|
-
"@initx-plugin/git": "0.0.
|
|
28
|
+
"@initx-plugin/cp": "0.0.6",
|
|
29
|
+
"@initx-plugin/git": "0.0.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@initx-plugin/
|
|
32
|
+
"@initx-plugin/core": "0.0.6"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"stub": "unbuild --stub",
|