@0x-jerry/x 2.12.2 → 2.12.3

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.
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "2.12.2";
2
+ var version = "2.12.3";
3
3
 
4
4
  export {
5
5
  version
package/dist/x.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  version
4
- } from "./chunk-OEKTPD6V.js";
4
+ } from "./chunk-BB5TC3CY.js";
5
5
 
6
6
  // src/x.ts
7
7
  import { sliver } from "@0x-jerry/silver";
package/dist/xn.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-ELIYGHQS.js";
7
7
  import {
8
8
  version
9
- } from "./chunk-OEKTPD6V.js";
9
+ } from "./chunk-BB5TC3CY.js";
10
10
 
11
11
  // src/xn.ts
12
12
  import { sliver } from "@0x-jerry/silver";
package/dist/xr.js CHANGED
@@ -4,10 +4,13 @@ import {
4
4
  } from "./chunk-ELIYGHQS.js";
5
5
  import {
6
6
  version
7
- } from "./chunk-OEKTPD6V.js";
7
+ } from "./chunk-BB5TC3CY.js";
8
8
 
9
9
  // src/xr.ts
10
10
  import { sliver } from "@0x-jerry/silver";
11
+ import { readdir } from "fs/promises";
12
+ import { pathExists as pathExists4 } from "fs-extra/esm";
13
+ import path5 from "path";
11
14
 
12
15
  // src/commands/run.ts
13
16
  import path4 from "path";
@@ -41,7 +44,7 @@ var DenoTaskDetecter = class {
41
44
  };
42
45
 
43
46
  // src/commands/run/node.ts
44
- import { readFile as readFile2, readdir } from "fs/promises";
47
+ import { readFile as readFile2 } from "fs/promises";
45
48
  import path2 from "path";
46
49
  import { pathExists as pathExists2 } from "fs-extra";
47
50
  var NodeTaskDetecter = class {
@@ -68,19 +71,6 @@ var NodeTaskDetecter = class {
68
71
  const text = await readFile2(pkgPath, "utf8");
69
72
  const json = JSON.parse(text);
70
73
  const tasks = json.scripts || {};
71
- {
72
- let dir = cwd;
73
- do {
74
- const binPath = path2.join(dir, "node_modules", ".bin");
75
- if (await pathExists2(binPath)) {
76
- const files = await readdir(binPath);
77
- for (const filename of files) {
78
- tasks[filename] ??= filename;
79
- }
80
- }
81
- dir = path2.resolve(dir, "..");
82
- } while (dir !== path2.resolve(dir, ".."));
83
- }
84
74
  return tasks;
85
75
  }
86
76
  };
@@ -147,12 +137,27 @@ async function getAvailableCommands() {
147
137
  var ins = sliver`
148
138
  v${version} @help @autocompletion
149
139
 
150
- xr <@command|_files:command-or-file> #stopEarly, run npm script or ts/js file quickly. ${defaultAction}
140
+ xr <@scripts|bin|_files:command-or-file> #stopEarly, run npm script or ts/js file quickly. ${defaultAction}
151
141
  `;
152
- ins.type("command", async () => {
142
+ ins.type("scripts", async () => {
153
143
  const allScripts = await getAvailableCommands();
154
144
  return allScripts;
155
145
  });
146
+ ins.type("bin", async () => {
147
+ let dir = process.cwd();
148
+ const binaries = [];
149
+ do {
150
+ const binPath = path5.join(dir, "node_modules", ".bin");
151
+ if (await pathExists4(binPath)) {
152
+ const files = await readdir(binPath);
153
+ for (const filename of files) {
154
+ binaries.push(filename);
155
+ }
156
+ }
157
+ dir = path5.resolve(dir, "..");
158
+ } while (dir !== path5.resolve(dir, ".."));
159
+ return binaries;
160
+ });
156
161
  async function defaultAction(_, arg) {
157
162
  const [commandOrFile, ...params] = arg._;
158
163
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0x-jerry/x",
3
- "version": "2.12.2",
3
+ "version": "2.12.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/0x-jerry/x.git"
@@ -47,7 +47,7 @@
47
47
  "clean": true
48
48
  },
49
49
  "dependencies": {
50
- "@0x-jerry/silver": "^1.2.3",
50
+ "@0x-jerry/silver": "^1.2.4",
51
51
  "@0x-jerry/utils": "^5.0.0",
52
52
  "decompress": "^4.2.1",
53
53
  "fs-extra": "^11.3.1",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "devDependencies": {
65
65
  "@0x-jerry/x-release": "^2.4.0",
66
- "@biomejs/biome": "^2.2.3",
66
+ "@biomejs/biome": "^2.2.4",
67
67
  "@types/decompress": "^4.2.7",
68
68
  "@types/fs-extra": "^11.0.4",
69
69
  "@types/global-agent": "^3.0.0",
package/readme.md CHANGED
@@ -1,94 +1,95 @@
1
- # X
2
-
3
- Some useful command for myself.
4
-
5
- ## Install
6
-
7
- ```sh
8
- pnpm i -g @0x-jerry/x
9
- ```
10
-
11
- ## Run task `xr`
12
-
13
- `xr` command can auto detect tasks in `package.json/scripts`, `deno.json/tasks`, and run it. you can also append any parameters.
14
-
15
- Example: In a node project with `pnpm-lock.yaml`. And `package.json` has a script `"test": "vitest run"`
16
-
17
- ```sh
18
- xr test test/*.ts
19
- # equals
20
- vitest run test/*.ts
21
-
22
- # you can also execute binary file in `node_modules/.bin` folder.
23
- xr vite --port 4004
24
- ```
25
-
26
- Example: In a deno project with `deno.json` or `deno.jsonc`. And have a task `"dev": "deno run -A main.ts"`
27
-
28
- ```sh
29
- xr dev
30
- # equals
31
- deno run -A main.ts
32
- ```
33
-
34
- ## Dependency Manager `xn`
35
-
36
- `xn` command can install modules by detect the correct tool, it detects lockfile to decide which dependency manager tools should be used.
37
-
38
- Example: install packages in a node project with `pnpm-lock.yaml`
39
-
40
- ```sh
41
- xn i lodash-es
42
- # equals
43
- pnpm i lodash-es
44
-
45
- xn i lodash-es -D
46
- # equals
47
- pnpm i lodash-es -D
48
-
49
- # -t/--types option support install @types/xx package in one command.
50
- xn i lodash-es --types
51
- # equals
52
- pnpm i lodash-es && pnpm i @types/lodash-es -D
53
- ```
54
-
55
- Example: remove packages in a node project with `pnpm-lock.yaml`
56
-
57
- ```sh
58
- xn rm lodash-es
59
- # equals
60
- pnpm uninstall lodash-es
61
-
62
- xn rm lodash-es -D
63
- # equals
64
- pnpm uninstall lodash-es -D
65
-
66
- # -t/--types option support remove @types/xx package in one command.
67
- xn rm lodash-es --types
68
- # equals
69
- pnpm uninstall lodash-es @types/lodash-es
70
- ```
71
-
72
- `xn` also support rust project.
73
-
74
- Example: in a rust project with `Cargo.toml`
75
-
76
- ```sh
77
- xn i log
78
- # equals
79
- cargo add log
80
-
81
- xn rm log
82
- # equals
83
- cargo remove log
84
- ```
85
-
86
- ## Command Completions
87
-
88
- Add this code to `~/.zshrc`
89
-
90
- ```zsh
91
- source <(x completions)
92
- source <(xr completions)
93
- source <(xn completions)
94
- ```
1
+ # X
2
+
3
+ Some useful command for myself.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ pnpm i -g @0x-jerry/x
9
+ ```
10
+
11
+ ## Run task `xr`
12
+
13
+ `xr` command can auto detect tasks in `package.json/scripts`, `deno.json/tasks`, and run it. you can also append any parameters.
14
+
15
+ Example: In a node project with `pnpm-lock.yaml`. And `package.json` has a script `"test": "vitest run"`
16
+
17
+ ```sh
18
+ xr test test/*.ts
19
+ # equals
20
+ vitest run test/*.ts
21
+
22
+ # you can also execute binary file in `node_modules/.bin` folder.
23
+ xr vite --port 4004
24
+ ```
25
+
26
+ Example: In a deno project with `deno.json` or `deno.jsonc`. And have a task `"dev": "deno run -A main.ts"`
27
+
28
+ ```sh
29
+ xr dev
30
+ # equals
31
+ deno run -A main.ts
32
+ ```
33
+
34
+ ## Dependency Manager `xn`
35
+
36
+ `xn` command can install modules by detect the correct tool, it detects lockfile to decide which dependency manager tools should be used.
37
+
38
+ Example: install packages in a node project with `pnpm-lock.yaml`
39
+
40
+ ```sh
41
+ xn i lodash-es
42
+ # equals
43
+ pnpm i lodash-es
44
+
45
+ xn i lodash-es -D
46
+ # equals
47
+ pnpm i lodash-es -D
48
+
49
+ # -t/--types option support install @types/xx package in one command.
50
+ xn i lodash-es --types
51
+ # equals
52
+ pnpm i lodash-es && pnpm i @types/lodash-es -D
53
+ ```
54
+
55
+ Example: remove packages in a node project with `pnpm-lock.yaml`
56
+
57
+ ```sh
58
+ xn rm lodash-es
59
+ # equals
60
+ pnpm uninstall lodash-es
61
+
62
+ xn rm lodash-es -D
63
+ # equals
64
+ pnpm uninstall lodash-es -D
65
+
66
+ # -t/--types option support remove @types/xx package in one command.
67
+ xn rm lodash-es --types
68
+ # equals
69
+ pnpm uninstall lodash-es @types/lodash-es
70
+ ```
71
+
72
+ `xn` also support rust project.
73
+
74
+ Example: in a rust project with `Cargo.toml`
75
+
76
+ ```sh
77
+ xn i log
78
+ # equals
79
+ cargo add log
80
+
81
+ xn rm log
82
+ # equals
83
+ cargo remove log
84
+ ```
85
+
86
+ ## Command Completions
87
+
88
+ Add this code to `~/.zshrc`
89
+
90
+ ```zsh
91
+ source <(x completion)
92
+ source <(xr completion)
93
+ source <(xn completion)
94
+ ```
95
+