initx 0.0.5 → 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 CHANGED
@@ -2,7 +2,7 @@ import cac from 'cac';
2
2
  import { GitHandler } from '@initx-plugin/git';
3
3
  import { CpHandler } from '@initx-plugin/cp';
4
4
 
5
- const pkgJson = {name:"initx",type:"module",version:"0.0.5",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/types":"workspace:*"}};
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:*"}};
6
6
 
7
7
  function getDefaultExportFromCjs (x) {
8
8
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -102,7 +102,7 @@ const handlers = [
102
102
  ];
103
103
 
104
104
  const cli = cac("initx");
105
- cli.help().command("<something>", "Enter something").usage("").option("-v, --version", "Display version number");
105
+ cli.help().command("<something>", "see https://github.com/imba97/initx").usage("").option("-v, --version", "Display version number");
106
106
  const { args, options } = cli.parse();
107
107
  if (options.h || options.help) {
108
108
  process.exit(0);
package/dist/index.d.mts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { GitHandler } from '@initx-plugin/git';
2
- export * from '@initx-plugin/types';
2
+ export { CpHandler } from '@initx-plugin/cp';
3
+ export * from '@initx-plugin/core';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { GitHandler } from '@initx-plugin/git';
2
- export * from '@initx-plugin/types';
2
+ export { CpHandler } from '@initx-plugin/cp';
3
+ export * from '@initx-plugin/core';
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, ...rest) {
5
- const tests = Array.isArray(this.matchers) ? this.matchers : [this.matchers];
6
- const passed = tests.some((test) => {
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.5",
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
- "@initx-plugin/cp": "0.0.5",
29
- "@initx-plugin/git": "0.0.5"
28
+ "@initx-plugin/cp": "0.0.6",
29
+ "@initx-plugin/git": "0.0.6"
30
30
  },
31
31
  "devDependencies": {
32
- "@initx-plugin/types": "0.0.5"
32
+ "@initx-plugin/core": "0.0.6"
33
33
  },
34
34
  "scripts": {
35
35
  "stub": "unbuild --stub",