@0x-jerry/x 2.3.6 → 2.4.1

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/xn.d.ts CHANGED
@@ -1 +1,12 @@
1
1
  #!/usr/bin/env node
2
+ /**
3
+ *
4
+ * @param pkg
5
+ *
6
+ * getPackageName('lodash@latest') => @types/lodash
7
+ * getPackageName('@babel/core') => @types/babel__core
8
+ *
9
+ */
10
+ declare function getTypePackageName(pkg: string): string;
11
+
12
+ export { getTypePackageName };
package/dist/xn.js CHANGED
@@ -82,18 +82,35 @@ xn, install npm package quickly. ${defaultAction}
82
82
 
83
83
  i/install [module] #stopEarly, install npm package quickly. ${installAction}
84
84
 
85
+ -t --types @bool, install package's types too.
86
+
85
87
  up/upgrade #stopEarly, upgrade npm packages. ${upgradeAction}
86
88
  `;
87
89
  async function defaultAction() {
88
90
  await runNpm("install");
89
91
  }
90
92
  async function installAction(_, opt) {
91
- const installOnly = !opt._.length;
93
+ const packages = opt._;
94
+ const installOnly = !packages.length;
92
95
  if (installOnly) {
93
96
  await runNpm("install");
94
97
  return;
95
98
  }
96
- await runNpm("add", ...opt._);
99
+ await runNpm("add", ...packages);
100
+ if (opt.types) {
101
+ const typesPackages = packages.map((pkg) => getTypePackageName(pkg));
102
+ await runNpm("add", ...typesPackages, "-D");
103
+ }
104
+ }
105
+ function getTypePackageName(pkg) {
106
+ const idx = pkg.lastIndexOf("@");
107
+ const name = idx > 0 ? pkg.slice(0, idx) : pkg;
108
+ if (name.includes("@")) {
109
+ const [scope, pkgName] = name.split("/");
110
+ return `@types/${scope.slice(1)}__${pkgName}`;
111
+ } else {
112
+ return `@types/${name}`;
113
+ }
97
114
  }
98
115
  async function upgradeAction(_, opt) {
99
116
  const params = opt._;
@@ -102,3 +119,6 @@ async function upgradeAction(_, opt) {
102
119
  }
103
120
  await runNpm("upgrade", ...params);
104
121
  }
122
+ export {
123
+ getTypePackageName
124
+ };
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@0x-jerry/x",
3
- "version": "2.3.6",
4
- "main": "index.js",
3
+ "version": "2.4.1",
5
4
  "repository": {
6
5
  "type": "git",
7
6
  "url": "git+https://github.com/0x-jerry/x.git"
@@ -11,9 +10,7 @@
11
10
  "type": "module",
12
11
  "publishConfig": {
13
12
  "access": "public",
14
- "registry": "https://registry.npmjs.org",
15
- "main": "dist/index.js",
16
- "typings": "dist/index.d.ts"
13
+ "registry": "https://registry.npmjs.org"
17
14
  },
18
15
  "files": [
19
16
  "dist"
@@ -23,16 +20,6 @@
23
20
  "xn": "dist/xn.js",
24
21
  "x": "dist/x.js"
25
22
  },
26
- "scripts": {
27
- "build": "tsup",
28
- "dev:xr": "tsx src/xr.ts",
29
- "dev:xn": "tsx src/xn.ts",
30
- "dev:x": "tsx src/x.ts",
31
- "test": "vitest",
32
- "ci:test": "vitest run",
33
- "prepublishOnly": "npm run build",
34
- "release": "x-release"
35
- },
36
23
  "tsup": {
37
24
  "entry": [
38
25
  "src/xr.ts",
@@ -46,28 +33,37 @@
46
33
  "clean": true
47
34
  },
48
35
  "dependencies": {
49
- "@0x-jerry/silver": "^0.1.5",
50
- "@0x-jerry/utils": "^2.2.5",
36
+ "@0x-jerry/silver": "^0.1.7",
37
+ "@0x-jerry/utils": "^2.2.7",
51
38
  "decompress": "^4.2.1",
52
39
  "fs-extra": "^11.2.0",
53
40
  "global-agent": "^3.0.0",
54
41
  "got": "^14.2.1",
55
42
  "jsonc-parser": "^3.2.1",
56
43
  "ora": "^8.0.1",
57
- "picocolors": "^1.0.0",
44
+ "picocolors": "^1.0.1",
58
45
  "prompts": "^2.4.2"
59
46
  },
60
47
  "devDependencies": {
61
- "@0x-jerry/x-release": "^2.0.1",
48
+ "@0x-jerry/x-release": "^2.2.2",
62
49
  "@types/decompress": "^4.2.7",
63
50
  "@types/fs-extra": "^11.0.4",
64
51
  "@types/global-agent": "^2.1.3",
65
- "@types/node": "^20.12.11",
52
+ "@types/node": "^20.12.12",
66
53
  "@types/prompts": "^2.4.9",
67
54
  "@vitest/coverage-v8": "^1.6.0",
68
55
  "tsup": "^8.0.2",
69
- "tsx": "^4.9.3",
56
+ "tsx": "^4.10.4",
70
57
  "typescript": "^5.4.5",
71
58
  "vitest": "^1.6.0"
59
+ },
60
+ "scripts": {
61
+ "build": "tsup",
62
+ "dev:xr": "tsx src/xr.ts",
63
+ "dev:xn": "tsx src/xn.ts",
64
+ "dev:x": "tsx src/x.ts",
65
+ "test": "vitest",
66
+ "ci:test": "vitest run",
67
+ "release": "x-release"
72
68
  }
73
69
  }
package/readme.md CHANGED
@@ -1,19 +1,19 @@
1
- # X
2
-
3
- Some useful command for myself.
4
-
5
- ## Install
6
-
7
- ```sh
8
- npm i -g @0x-jerry/x
9
- ```
10
-
11
- ## Command Completions
12
-
13
- Add this code to `~/.zshrc`
14
-
15
- ```zsh
16
- source <(x completions)
17
- source <(xr completions)
18
- source <(xn completions)
19
- ```
1
+ # X
2
+
3
+ Some useful command for myself.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i -g @0x-jerry/x
9
+ ```
10
+
11
+ ## Command Completions
12
+
13
+ Add this code to `~/.zshrc`
14
+
15
+ ```zsh
16
+ source <(x completions)
17
+ source <(xr completions)
18
+ source <(xn completions)
19
+ ```