@0x-jerry/x 2.7.4 → 2.8.0

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.7.4";
2
+ var version = "2.8.0";
3
3
 
4
4
  export {
5
5
  version
@@ -1,5 +1,5 @@
1
1
  // src/utils.ts
2
- import { existsSync } from "node:fs";
2
+ import { existsSync } from "fs";
3
3
  import { exec as _exec } from "@0x-jerry/utils/node";
4
4
  async function exec(script, params, env) {
5
5
  const cmd = [script, ...params].join(" ");
@@ -0,0 +1,8 @@
1
+ // src/preload.js
2
+ import { register } from "module";
3
+ register("@nodejs-loaders/alias", import.meta.url);
4
+ register("@nodejs-loaders/tsx", import.meta.url);
5
+ register("@nodejs-loaders/text", import.meta.url);
6
+ register("@nodejs-loaders/jsonc", import.meta.url);
7
+ register("@nodejs-loaders/json5", import.meta.url);
8
+ register("@nodejs-loaders/yaml", import.meta.url);
package/dist/x.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  version
4
- } from "./chunk-Q6TKVCKX.js";
4
+ } from "./chunk-EY2UY7SH.js";
5
5
 
6
6
  // src/x.ts
7
7
  import { sliver } from "@0x-jerry/silver";
8
8
  import { bootstrap } from "global-agent";
9
9
 
10
10
  // src/commands/downloadGitRepo.ts
11
- import { createWriteStream } from "node:fs";
12
- import os from "node:os";
13
- import path from "node:path";
14
- import { pipeline } from "node:stream/promises";
11
+ import { createWriteStream } from "fs";
12
+ import os from "os";
13
+ import path from "path";
14
+ import { pipeline } from "stream/promises";
15
15
  import decompress from "decompress";
16
16
  import fs from "fs-extra";
17
17
  import got from "got";
package/dist/xn.js CHANGED
@@ -3,16 +3,16 @@ import {
3
3
  exec,
4
4
  exists,
5
5
  flagOptionToStringArray
6
- } from "./chunk-TTBHFDNB.js";
6
+ } from "./chunk-UW6XLRG7.js";
7
7
  import {
8
8
  version
9
- } from "./chunk-Q6TKVCKX.js";
9
+ } from "./chunk-EY2UY7SH.js";
10
10
 
11
11
  // src/xn.ts
12
12
  import { sliver } from "@0x-jerry/silver";
13
13
 
14
14
  // src/commands/dep/deno.ts
15
- import path from "node:path";
15
+ import path from "path";
16
16
  import { pathExists } from "fs-extra";
17
17
  var DenoDependencyManager = class {
18
18
  check() {
@@ -34,8 +34,8 @@ var DenoDependencyManager = class {
34
34
  };
35
35
 
36
36
  // src/commands/dep/node.ts
37
- import { readFile } from "node:fs/promises";
38
- import path2, { join } from "node:path";
37
+ import { readFile } from "fs/promises";
38
+ import path2, { join } from "path";
39
39
  import { pathExists as pathExists2 } from "fs-extra";
40
40
  import pc from "picocolors";
41
41
  var NodeDependencyManager = class {
@@ -151,7 +151,7 @@ function getTypePackageName(pkg) {
151
151
  }
152
152
 
153
153
  // src/commands/dep/rust.ts
154
- import path3 from "node:path";
154
+ import path3 from "path";
155
155
  import { pathExists as pathExists3 } from "fs-extra";
156
156
  var RustDependencyManager = class {
157
157
  check() {
package/dist/xr.js CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  exec
4
- } from "./chunk-TTBHFDNB.js";
4
+ } from "./chunk-UW6XLRG7.js";
5
5
  import {
6
6
  version
7
- } from "./chunk-Q6TKVCKX.js";
7
+ } from "./chunk-EY2UY7SH.js";
8
8
 
9
9
  // src/xr.ts
10
10
  import { sliver } from "@0x-jerry/silver";
11
11
 
12
12
  // src/commands/run.ts
13
- import path4 from "node:path";
13
+ import path4 from "path";
14
14
  import pc from "picocolors";
15
15
 
16
16
  // src/commands/run/deno.ts
17
- import { readFile } from "node:fs/promises";
18
- import path from "node:path";
17
+ import { readFile } from "fs/promises";
18
+ import path from "path";
19
19
  import { pathExists } from "fs-extra";
20
20
  import { parse } from "jsonc-parser";
21
21
  var DenoTaskDetecter = class {
@@ -41,8 +41,8 @@ var DenoTaskDetecter = class {
41
41
  };
42
42
 
43
43
  // src/commands/run/node.ts
44
- import { readFile as readFile2, readdir } from "node:fs/promises";
45
- import path2 from "node:path";
44
+ import { readFile as readFile2, readdir } from "fs/promises";
45
+ import path2 from "path";
46
46
  import { pathExists as pathExists2 } from "fs-extra";
47
47
  var NodeTaskDetecter = class {
48
48
  async binaryPaths(cwd) {
@@ -86,7 +86,7 @@ var NodeTaskDetecter = class {
86
86
  };
87
87
 
88
88
  // src/commands/run/rust.ts
89
- import path3 from "node:path";
89
+ import path3 from "path";
90
90
  import { pathExists as pathExists3 } from "fs-extra";
91
91
  var RustTaskDetecter = class {
92
92
  check(cwd) {
@@ -144,20 +144,30 @@ async function getAvailableCommands() {
144
144
  }
145
145
 
146
146
  // src/xr.ts
147
+ import path5 from "path";
147
148
  var ins = sliver`
148
149
  v${version} @help @autocompletion
149
150
 
150
- xr [@command:command] #stopEarly, run command quickly. ${defaultAction}
151
+ xr <@command:command-or-file> #stopEarly, run npm script or ts/js file quickly. ${defaultAction}
151
152
  `;
152
153
  ins.type("command", async () => {
153
154
  const allScripts = await getAvailableCommands();
154
155
  return allScripts;
155
156
  });
156
157
  async function defaultAction(_, arg) {
157
- const [command, ...params] = arg._;
158
+ const [commandOrFile, ...params] = arg._;
159
+ if (isJsFile(commandOrFile)) {
160
+ const registerFilePath = path5.join(import.meta.dirname, "./preload.js");
161
+ await exec("node", ["--import", registerFilePath, commandOrFile]);
162
+ return;
163
+ }
158
164
  try {
159
- await runScript(command, params);
165
+ await runScript(commandOrFile, params);
160
166
  } catch (error) {
161
167
  process.exit(1);
162
168
  }
163
169
  }
170
+ var RE_TJS_FILE = /.(t|j)sx?$/;
171
+ function isJsFile(file) {
172
+ return RE_TJS_FILE.test(file);
173
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0x-jerry/x",
3
- "version": "2.7.4",
3
+ "version": "2.8.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/0x-jerry/x.git"
@@ -34,7 +34,8 @@
34
34
  "entry": [
35
35
  "src/xr.ts",
36
36
  "src/xn.ts",
37
- "src/x.ts"
37
+ "src/x.ts",
38
+ "src/preload.js"
38
39
  ],
39
40
  "format": [
40
41
  "esm"
@@ -43,28 +44,34 @@
43
44
  },
44
45
  "dependencies": {
45
46
  "@0x-jerry/silver": "^1.1.1",
46
- "@0x-jerry/utils": "^4.2.2",
47
+ "@0x-jerry/utils": "^5.0.0",
48
+ "@nodejs-loaders/alias": "^2.1.2",
49
+ "@nodejs-loaders/json5": "^1.1.0",
50
+ "@nodejs-loaders/jsonc": "^1.1.0",
51
+ "@nodejs-loaders/text": "^1.1.0",
52
+ "@nodejs-loaders/tsx": "^1.1.2",
53
+ "@nodejs-loaders/yaml": "^1.1.0",
47
54
  "decompress": "^4.2.1",
48
- "fs-extra": "^11.3.0",
55
+ "fs-extra": "^11.3.1",
49
56
  "global-agent": "^3.0.0",
50
- "got": "^14.4.5",
57
+ "got": "^14.4.8",
51
58
  "jsonc-parser": "^3.3.1",
52
- "ora": "^8.1.1",
59
+ "ora": "^8.2.0",
53
60
  "picocolors": "^1.1.1",
54
61
  "prompts": "^2.4.2"
55
62
  },
56
63
  "devDependencies": {
57
- "@0x-jerry/x-release": "^2.2.2",
58
- "@biomejs/biome": "^1.9.4",
64
+ "@0x-jerry/x-release": "^2.4.0",
65
+ "@biomejs/biome": "^2.2.2",
59
66
  "@types/decompress": "^4.2.7",
60
67
  "@types/fs-extra": "^11.0.4",
61
- "@types/global-agent": "^2.1.3",
62
- "@types/node": "^22.10.10",
68
+ "@types/global-agent": "^3.0.0",
69
+ "@types/node": "^24.3.0",
63
70
  "@types/prompts": "^2.4.9",
64
- "@vitest/coverage-v8": "^3.0.4",
65
- "tsup": "^8.3.6",
66
- "tsx": "^4.19.2",
67
- "typescript": "^5.7.3",
68
- "vitest": "^3.0.4"
71
+ "@vitest/coverage-v8": "^3.2.4",
72
+ "tsup": "^8.5.0",
73
+ "tsx": "^4.20.5",
74
+ "typescript": "^5.9.2",
75
+ "vitest": "^3.2.4"
69
76
  }
70
77
  }