@0x-jerry/x 2.7.2 → 2.7.4

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.2";
2
+ var version = "2.7.4";
3
3
 
4
4
  export {
5
5
  version
@@ -1,22 +1,21 @@
1
1
  // src/utils.ts
2
- import { existsSync } from "fs";
3
- import { run } from "@0x-jerry/utils/node";
2
+ import { existsSync } from "node:fs";
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(" ");
6
- await run(cmd, env);
6
+ await _exec(cmd, { env });
7
7
  }
8
8
  function exists(path) {
9
9
  return existsSync(path);
10
10
  }
11
11
  function flagOptionToStringArray(opt) {
12
- return Object.entries(opt).map(([_key, value]) => {
12
+ return Object.entries(opt).flatMap(([_key, value]) => {
13
13
  const key = (_key.length === 1 ? "-" : "--") + _key;
14
14
  if (typeof value === "string" || typeof value === "number") {
15
15
  return [key, String(value)];
16
- } else {
17
- return [key];
18
16
  }
19
- }).flat();
17
+ return [key];
18
+ });
20
19
  }
21
20
 
22
21
  export {
package/dist/x.js CHANGED
@@ -1,26 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  version
4
- } from "./chunk-5L45XIBY.js";
4
+ } from "./chunk-Q6TKVCKX.js";
5
5
 
6
6
  // src/x.ts
7
7
  import { sliver } from "@0x-jerry/silver";
8
+ import { bootstrap } from "global-agent";
8
9
 
9
10
  // src/commands/downloadGitRepo.ts
10
- import path from "node:path";
11
- import os from "node:os";
12
11
  import { createWriteStream } from "node:fs";
12
+ import os from "node:os";
13
+ import path from "node:path";
13
14
  import { pipeline } from "node:stream/promises";
14
- import prompts from "prompts";
15
- import pc from "picocolors";
16
- import got from "got";
15
+ import decompress from "decompress";
17
16
  import fs from "fs-extra";
17
+ import got from "got";
18
18
  import ora from "ora";
19
- import decompress from "decompress";
19
+ import pc from "picocolors";
20
+ import prompts from "prompts";
20
21
  async function downloadGitRepo(opt) {
21
22
  let { url, branch = "main", destDir } = opt;
22
23
  if (!url) {
23
- console.log(pc.red(`Please specify git url by using -u,--url`));
24
+ console.log(pc.red("Please specify git url by using -u,--url"));
24
25
  return;
25
26
  }
26
27
  destDir = await checkDest(destDir) || "";
@@ -100,7 +101,6 @@ async function downloadGitBranch(conf, branch) {
100
101
  }
101
102
 
102
103
  // src/x.ts
103
- import { bootstrap } from "global-agent";
104
104
  bootstrap({
105
105
  environmentVariableNamespace: ""
106
106
  });
@@ -115,8 +115,8 @@ t/template [dest], download git repo as a template. ${defaultAction}
115
115
  -b --branch, Git branch.
116
116
  `;
117
117
  async function defaultAction(_, args) {
118
- let [destDir] = _;
119
- let { url, branch = "main" } = args;
118
+ const [destDir] = _;
119
+ const { url, branch = "main" } = args;
120
120
  await downloadGitRepo({
121
121
  url,
122
122
  branch,
package/dist/xn.js CHANGED
@@ -3,17 +3,17 @@ import {
3
3
  exec,
4
4
  exists,
5
5
  flagOptionToStringArray
6
- } from "./chunk-WA6Z2RU3.js";
6
+ } from "./chunk-TTBHFDNB.js";
7
7
  import {
8
8
  version
9
- } from "./chunk-5L45XIBY.js";
9
+ } from "./chunk-Q6TKVCKX.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
16
  import { pathExists } from "fs-extra";
16
- import path from "path";
17
17
  var DenoDependencyManager = class {
18
18
  check() {
19
19
  const cwd = process.cwd();
@@ -34,10 +34,10 @@ var DenoDependencyManager = class {
34
34
  };
35
35
 
36
36
  // src/commands/dep/node.ts
37
- import path2, { join } from "path";
38
- import pc from "picocolors";
39
- import { readFile } from "fs/promises";
37
+ import { readFile } from "node:fs/promises";
38
+ import path2, { join } from "node:path";
40
39
  import { pathExists as pathExists2 } from "fs-extra";
40
+ import pc from "picocolors";
41
41
  var NodeDependencyManager = class {
42
42
  async check() {
43
43
  return pathExists2(path2.join(process.cwd(), "package.json"));
@@ -146,14 +146,13 @@ function getTypePackageName(pkg) {
146
146
  if (name.includes("@")) {
147
147
  const [scope, pkgName] = name.split("/");
148
148
  return `@types/${scope.slice(1)}__${pkgName}`;
149
- } else {
150
- return `@types/${name}`;
151
149
  }
150
+ return `@types/${name}`;
152
151
  }
153
152
 
154
153
  // src/commands/dep/rust.ts
154
+ import path3 from "node:path";
155
155
  import { pathExists as pathExists3 } from "fs-extra";
156
- import path3 from "path";
157
156
  var RustDependencyManager = class {
158
157
  check() {
159
158
  return pathExists3(path3.join(process.cwd(), "Cargo.toml"));
@@ -219,6 +218,8 @@ i/install [...modules], Install dependencies. ${installAction}
219
218
 
220
219
  up/upgrade [...modules], Upgrade dependencies. ${upgradeAction}
221
220
 
221
+ -L --latest @bool, upgrade to the latest version.
222
+
222
223
  rm/remove <...modules>, Remove dependencies. ${removeAction}
223
224
 
224
225
  -t --types @bool, remove package's type too, only take effect in node project.
@@ -246,8 +247,10 @@ async function removeAction(_, opt) {
246
247
  function getParameters(opt) {
247
248
  const params = opt._;
248
249
  const otherOpt = { ...opt };
249
- delete otherOpt._;
250
- delete otherOpt["--"];
250
+ const blockOptions = ["_", "--", "L"];
251
+ for (const opt2 of blockOptions) {
252
+ Reflect.deleteProperty(otherOpt, opt2);
253
+ }
251
254
  return {
252
255
  params,
253
256
  options: otherOpt
package/dist/xr.js CHANGED
@@ -1,93 +1,93 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  exec
4
- } from "./chunk-WA6Z2RU3.js";
4
+ } from "./chunk-TTBHFDNB.js";
5
5
  import {
6
6
  version
7
- } from "./chunk-5L45XIBY.js";
7
+ } from "./chunk-Q6TKVCKX.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 "path";
13
+ import path4 from "node:path";
14
14
  import pc from "picocolors";
15
15
 
16
- // src/commands/run/node.ts
16
+ // src/commands/run/deno.ts
17
+ import { readFile } from "node:fs/promises";
18
+ import path from "node:path";
17
19
  import { pathExists } from "fs-extra";
18
- import path from "path";
19
- import { readdir, readFile } from "fs/promises";
20
+ import { parse } from "jsonc-parser";
21
+ var DenoTaskDetecter = class {
22
+ check(cwd) {
23
+ return pathExists(path.join(cwd, "deno.json")) || pathExists(path.join(cwd, "deno.jsonc"));
24
+ }
25
+ async task(cwd, taskName) {
26
+ return (await this.tasks(cwd))[taskName];
27
+ }
28
+ async tasks(cwd) {
29
+ let tasks = {};
30
+ let denoConfigPath = path.join(cwd, "deno.json");
31
+ if (!await pathExists(denoConfigPath)) {
32
+ denoConfigPath = path.join(cwd, "deno.jsonc");
33
+ }
34
+ if (await pathExists(denoConfigPath)) {
35
+ const text = await readFile(denoConfigPath, "utf8");
36
+ const json = parse(text);
37
+ tasks = json.tasks || {};
38
+ }
39
+ return tasks;
40
+ }
41
+ };
42
+
43
+ // src/commands/run/node.ts
44
+ import { readFile as readFile2, readdir } from "node:fs/promises";
45
+ import path2 from "node:path";
46
+ import { pathExists as pathExists2 } from "fs-extra";
20
47
  var NodeTaskDetecter = class {
21
48
  async binaryPaths(cwd) {
22
49
  const envPaths = [];
23
50
  let dir = cwd;
24
51
  do {
25
- const binPath = path.join(dir, "node_modules", ".bin");
26
- if (await pathExists(binPath)) {
52
+ const binPath = path2.join(dir, "node_modules", ".bin");
53
+ if (await pathExists2(binPath)) {
27
54
  envPaths.push(binPath);
28
55
  }
29
- dir = path.resolve(dir, "..");
30
- } while (dir !== path.resolve(dir, ".."));
56
+ dir = path2.resolve(dir, "..");
57
+ } while (dir !== path2.resolve(dir, ".."));
31
58
  return envPaths;
32
59
  }
33
60
  check(cwd) {
34
- return pathExists(path.join(cwd, "package.json"));
61
+ return pathExists2(path2.join(cwd, "package.json"));
35
62
  }
36
63
  async task(cwd, taskName) {
37
64
  return (await this.tasks(cwd))[taskName];
38
65
  }
39
66
  async tasks(cwd) {
40
- const pkgPath = path.join(cwd, "package.json");
41
- const text = await readFile(pkgPath, "utf8");
67
+ const pkgPath = path2.join(cwd, "package.json");
68
+ const text = await readFile2(pkgPath, "utf8");
42
69
  const json = JSON.parse(text);
43
70
  const tasks = json.scripts || {};
44
71
  {
45
72
  let dir = cwd;
46
73
  do {
47
- const binPath = path.join(dir, "node_modules", ".bin");
48
- if (await pathExists(binPath)) {
74
+ const binPath = path2.join(dir, "node_modules", ".bin");
75
+ if (await pathExists2(binPath)) {
49
76
  const files = await readdir(binPath);
50
77
  for (const filename of files) {
51
78
  tasks[filename] ??= filename;
52
79
  }
53
80
  }
54
- dir = path.resolve(dir, "..");
55
- } while (dir !== path.resolve(dir, ".."));
56
- }
57
- return tasks;
58
- }
59
- };
60
-
61
- // src/commands/run/deno.ts
62
- import { parse } from "jsonc-parser";
63
- import { pathExists as pathExists2 } from "fs-extra";
64
- import path2 from "path";
65
- import { readFile as readFile2 } from "fs/promises";
66
- var DenoTaskDetecter = class {
67
- check(cwd) {
68
- return pathExists2(path2.join(cwd, "deno.json")) || pathExists2(path2.join(cwd, "deno.jsonc"));
69
- }
70
- async task(cwd, taskName) {
71
- return (await this.tasks(cwd))[taskName];
72
- }
73
- async tasks(cwd) {
74
- let tasks = {};
75
- let denoConfigPath = path2.join(cwd, "deno.json");
76
- if (!await pathExists2(denoConfigPath)) {
77
- denoConfigPath = path2.join(cwd, "deno.jsonc");
78
- }
79
- if (await pathExists2(denoConfigPath)) {
80
- const text = await readFile2(denoConfigPath, "utf8");
81
- const json = parse(text);
82
- tasks = json.tasks || {};
81
+ dir = path2.resolve(dir, "..");
82
+ } while (dir !== path2.resolve(dir, ".."));
83
83
  }
84
84
  return tasks;
85
85
  }
86
86
  };
87
87
 
88
88
  // src/commands/run/rust.ts
89
+ import path3 from "node:path";
89
90
  import { pathExists as pathExists3 } from "fs-extra";
90
- import path3 from "path";
91
91
  var RustTaskDetecter = class {
92
92
  check(cwd) {
93
93
  return pathExists3(path3.join(cwd, "Cargo.toml"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0x-jerry/x",
3
- "version": "2.7.2",
3
+ "version": "2.7.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/0x-jerry/x.git"
@@ -42,28 +42,29 @@
42
42
  "clean": true
43
43
  },
44
44
  "dependencies": {
45
- "@0x-jerry/silver": "^1.0.3",
46
- "@0x-jerry/utils": "^2.4.3",
45
+ "@0x-jerry/silver": "^1.1.1",
46
+ "@0x-jerry/utils": "^4.2.2",
47
47
  "decompress": "^4.2.1",
48
- "fs-extra": "^11.2.0",
48
+ "fs-extra": "^11.3.0",
49
49
  "global-agent": "^3.0.0",
50
- "got": "^14.4.1",
50
+ "got": "^14.4.5",
51
51
  "jsonc-parser": "^3.3.1",
52
- "ora": "^8.0.1",
53
- "picocolors": "^1.0.1",
52
+ "ora": "^8.1.1",
53
+ "picocolors": "^1.1.1",
54
54
  "prompts": "^2.4.2"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@0x-jerry/x-release": "^2.2.2",
58
+ "@biomejs/biome": "^1.9.4",
58
59
  "@types/decompress": "^4.2.7",
59
60
  "@types/fs-extra": "^11.0.4",
60
61
  "@types/global-agent": "^2.1.3",
61
- "@types/node": "^20.14.11",
62
+ "@types/node": "^22.10.10",
62
63
  "@types/prompts": "^2.4.9",
63
- "@vitest/coverage-v8": "^2.0.3",
64
- "tsup": "^8.2.0",
65
- "tsx": "^4.16.2",
66
- "typescript": "^5.5.3",
67
- "vitest": "^2.0.3"
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"
68
69
  }
69
70
  }