@simon_he/pi 0.0.81 → 0.0.83

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.
Files changed (3) hide show
  1. package/dist/index.cjs +152 -109
  2. package/dist/index.js +137 -94
  3. package/package.json +6 -2
package/dist/index.cjs CHANGED
@@ -203,11 +203,11 @@ var require_signals = __commonJS({
203
203
  // node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js
204
204
  var require_signal_exit = __commonJS({
205
205
  "node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports, module2) {
206
- var process11 = global.process;
207
- var processOk = function(process12) {
208
- return process12 && typeof process12 === "object" && typeof process12.removeListener === "function" && typeof process12.emit === "function" && typeof process12.reallyExit === "function" && typeof process12.listeners === "function" && typeof process12.kill === "function" && typeof process12.pid === "number" && typeof process12.on === "function";
206
+ var process12 = global.process;
207
+ var processOk = function(process13) {
208
+ return process13 && typeof process13 === "object" && typeof process13.removeListener === "function" && typeof process13.emit === "function" && typeof process13.reallyExit === "function" && typeof process13.listeners === "function" && typeof process13.kill === "function" && typeof process13.pid === "number" && typeof process13.on === "function";
209
209
  };
210
- if (!processOk(process11)) {
210
+ if (!processOk(process12)) {
211
211
  module2.exports = function() {
212
212
  return function() {
213
213
  };
@@ -215,15 +215,15 @@ var require_signal_exit = __commonJS({
215
215
  } else {
216
216
  assert = require("assert");
217
217
  signals = require_signals();
218
- isWin2 = /^win/i.test(process11.platform);
218
+ isWin2 = /^win/i.test(process12.platform);
219
219
  EE = require("events");
220
220
  if (typeof EE !== "function") {
221
221
  EE = EE.EventEmitter;
222
222
  }
223
- if (process11.__signal_exit_emitter__) {
224
- emitter = process11.__signal_exit_emitter__;
223
+ if (process12.__signal_exit_emitter__) {
224
+ emitter = process12.__signal_exit_emitter__;
225
225
  } else {
226
- emitter = process11.__signal_exit_emitter__ = new EE();
226
+ emitter = process12.__signal_exit_emitter__ = new EE();
227
227
  emitter.count = 0;
228
228
  emitter.emitted = {};
229
229
  }
@@ -260,12 +260,12 @@ var require_signal_exit = __commonJS({
260
260
  loaded = false;
261
261
  signals.forEach(function(sig) {
262
262
  try {
263
- process11.removeListener(sig, sigListeners[sig]);
263
+ process12.removeListener(sig, sigListeners[sig]);
264
264
  } catch (er) {
265
265
  }
266
266
  });
267
- process11.emit = originalProcessEmit;
268
- process11.reallyExit = originalProcessReallyExit;
267
+ process12.emit = originalProcessEmit;
268
+ process12.reallyExit = originalProcessReallyExit;
269
269
  emitter.count -= 1;
270
270
  };
271
271
  module2.exports.unload = unload;
@@ -282,7 +282,7 @@ var require_signal_exit = __commonJS({
282
282
  if (!processOk(global.process)) {
283
283
  return;
284
284
  }
285
- var listeners = process11.listeners(sig);
285
+ var listeners = process12.listeners(sig);
286
286
  if (listeners.length === emitter.count) {
287
287
  unload();
288
288
  emit("exit", null, sig);
@@ -290,7 +290,7 @@ var require_signal_exit = __commonJS({
290
290
  if (isWin2 && sig === "SIGHUP") {
291
291
  sig = "SIGINT";
292
292
  }
293
- process11.kill(process11.pid, sig);
293
+ process12.kill(process12.pid, sig);
294
294
  }
295
295
  };
296
296
  });
@@ -306,36 +306,36 @@ var require_signal_exit = __commonJS({
306
306
  emitter.count += 1;
307
307
  signals = signals.filter(function(sig) {
308
308
  try {
309
- process11.on(sig, sigListeners[sig]);
309
+ process12.on(sig, sigListeners[sig]);
310
310
  return true;
311
311
  } catch (er) {
312
312
  return false;
313
313
  }
314
314
  });
315
- process11.emit = processEmit;
316
- process11.reallyExit = processReallyExit;
315
+ process12.emit = processEmit;
316
+ process12.reallyExit = processReallyExit;
317
317
  };
318
318
  module2.exports.load = load;
319
- originalProcessReallyExit = process11.reallyExit;
319
+ originalProcessReallyExit = process12.reallyExit;
320
320
  processReallyExit = function processReallyExit2(code) {
321
321
  if (!processOk(global.process)) {
322
322
  return;
323
323
  }
324
- process11.exitCode = code || /* istanbul ignore next */
324
+ process12.exitCode = code || /* istanbul ignore next */
325
325
  0;
326
- emit("exit", process11.exitCode, null);
327
- emit("afterexit", process11.exitCode, null);
328
- originalProcessReallyExit.call(process11, process11.exitCode);
326
+ emit("exit", process12.exitCode, null);
327
+ emit("afterexit", process12.exitCode, null);
328
+ originalProcessReallyExit.call(process12, process12.exitCode);
329
329
  };
330
- originalProcessEmit = process11.emit;
330
+ originalProcessEmit = process12.emit;
331
331
  processEmit = function processEmit2(ev, arg) {
332
332
  if (ev === "exit" && processOk(global.process)) {
333
333
  if (arg !== void 0) {
334
- process11.exitCode = arg;
334
+ process12.exitCode = arg;
335
335
  }
336
336
  var ret = originalProcessEmit.apply(this, arguments);
337
- emit("exit", process11.exitCode, null);
338
- emit("afterexit", process11.exitCode, null);
337
+ emit("exit", process12.exitCode, null);
338
+ emit("afterexit", process12.exitCode, null);
339
339
  return ret;
340
340
  } else {
341
341
  return originalProcessEmit.apply(this, arguments);
@@ -5656,9 +5656,9 @@ __export(src_exports, {
5656
5656
  setup: () => setup
5657
5657
  });
5658
5658
  module.exports = __toCommonJS(src_exports);
5659
- var import_process3 = __toESM(require("process"), 1);
5660
- var import_lazy_js_utils13 = require("lazy-js-utils");
5661
- var import_picocolors7 = __toESM(require_picocolors(), 1);
5659
+ var import_process4 = __toESM(require("process"), 1);
5660
+ var import_lazy_js_utils14 = require("lazy-js-utils");
5661
+ var import_picocolors8 = __toESM(require_picocolors(), 1);
5662
5662
  var import_fast_glob = __toESM(require("fast-glob"), 1);
5663
5663
  var import_ccommand2 = require("ccommand");
5664
5664
 
@@ -6751,7 +6751,7 @@ function getLatestVersion(pkg, isZh6 = true) {
6751
6751
  var import_lazy_js_utils2 = require("lazy-js-utils");
6752
6752
 
6753
6753
  // package.json
6754
- var version = "0.0.81";
6754
+ var version = "0.0.83";
6755
6755
 
6756
6756
  // src/help.ts
6757
6757
  var isZh2 = process.env.PI_Lang === "zh";
@@ -6806,11 +6806,54 @@ async function installDeps() {
6806
6806
  }
6807
6807
 
6808
6808
  // src/pi.ts
6809
+ var import_process2 = __toESM(require("process"), 1);
6810
+ var import_lazy_js_utils5 = require("lazy-js-utils");
6811
+ var import_picocolors4 = __toESM(require_picocolors(), 1);
6812
+
6813
+ // src/detectNode.ts
6809
6814
  var import_process = __toESM(require("process"), 1);
6810
6815
  var import_lazy_js_utils4 = require("lazy-js-utils");
6811
6816
  var import_picocolors3 = __toESM(require_picocolors(), 1);
6812
- var isZh3 = import_process.default.env.PI_Lang === "zh";
6817
+ var semver = require("semver");
6818
+ async function detectNode() {
6819
+ var _a;
6820
+ let pkg;
6821
+ try {
6822
+ pkg = await (0, import_lazy_js_utils4.getPkg)();
6823
+ } catch (e) {
6824
+ const cwd = import_process.default.cwd();
6825
+ console.log(import_picocolors3.default.red(`\u5F53\u524D\u76EE\u5F55: ${cwd} \u6CA1\u6709package.json\u6587\u4EF6`));
6826
+ import_process.default.exit(1);
6827
+ }
6828
+ if ((_a = pkg.engines) == null ? void 0 : _a.node) {
6829
+ const isSafe = semver.satisfies(import_process.default.version, pkg.engines.node);
6830
+ if (!isSafe) {
6831
+ const { result, status } = await (0, import_lazy_js_utils4.jsShell)(
6832
+ `echo "yes
6833
+ no" | gum filter --placeholder=" \u5F53\u524Dnode\u7248\u672C\u4E0D\u6EE1\u8DB3 ${pkg.engines.node}\uFF0C\u662F\u5426\u5207\u6362node\u7248\u672C"`,
6834
+ "pipe"
6835
+ );
6836
+ if (status === 0 && result === "yes") {
6837
+ await (0, import_lazy_js_utils4.jsShell)(
6838
+ `
6839
+ current=$(echo $(fnm current))
6840
+ registery=$(echo "$(fnm ls)" | sed 's/system//g' | sed 's/default//g' | sed 's/* //g' | sed "s/$current/* $current/g" | gum filter --placeholder=" \u8BF7\u9009\u62E9\u4E00\u4E2Anode\u7248\u672C")
6841
+ registery=$(echo \${registery// /} | sed 's/*//g')
6842
+ if [ $registery ]; then
6843
+ fnm use \${registery% -*}
6844
+ fi
6845
+ `,
6846
+ "pipe"
6847
+ );
6848
+ }
6849
+ }
6850
+ }
6851
+ }
6852
+
6853
+ // src/pi.ts
6854
+ var isZh3 = import_process2.default.env.PI_Lang === "zh";
6813
6855
  async function pi(params, pkg, executor = "ni") {
6856
+ await detectNode();
6814
6857
  const text = pkg ? `Installing ${params} ...` : "Updating dependency ...";
6815
6858
  const isLatest = executor === "pil";
6816
6859
  const start = Date.now();
@@ -6824,8 +6867,8 @@ async function pi(params, pkg, executor = "ni") {
6824
6867
  const newParams = isLatest ? params : await getParams(params);
6825
6868
  let stdio = "pipe";
6826
6869
  let loading_status;
6827
- const { PI_DEFAULT, PI_MaxSockets: sockets } = import_process.default.env;
6828
- const pkgTool = await (0, import_lazy_js_utils4.getPkgTool)();
6870
+ const { PI_DEFAULT, PI_MaxSockets: sockets } = import_process2.default.env;
6871
+ const pkgTool = await (0, import_lazy_js_utils5.getPkgTool)();
6829
6872
  const maxSockets = sockets || 4;
6830
6873
  const install = PI_DEFAULT === "yarn" || pkgTool === "yarn" ? newParams ? "add" : "" : "install";
6831
6874
  if (pkgTool === "npm") {
@@ -6841,7 +6884,7 @@ async function pi(params, pkg, executor = "ni") {
6841
6884
  loading_status = await loading(text);
6842
6885
  }
6843
6886
  const runSockets = executor.split(" ")[0] === "npm" ? ` --max-sockets=${maxSockets}` : "";
6844
- const { status, result } = await (0, import_lazy_js_utils4.useNodeWorker)({
6887
+ const { status, result } = await (0, import_lazy_js_utils5.useNodeWorker)({
6845
6888
  params: `${executor}${newParams ? ` ${newParams}` : runSockets}`,
6846
6889
  stdio
6847
6890
  });
@@ -6849,15 +6892,15 @@ async function pi(params, pkg, executor = "ni") {
6849
6892
  loading_status = await loading("");
6850
6893
  const end = Date.now();
6851
6894
  const costTime = (end - start) / 1e3;
6852
- successMsg += import_picocolors3.default.blue(` ---- \u23F0\uFF1A${costTime}s`);
6895
+ successMsg += import_picocolors4.default.blue(` ---- \u23F0\uFF1A${costTime}s`);
6853
6896
  if (status === 0) {
6854
- loading_status.succeed(import_picocolors3.default.green(successMsg));
6897
+ loading_status.succeed(import_picocolors4.default.green(successMsg));
6855
6898
  } else if (result && result.includes("Not Found - 404")) {
6856
6899
  const _result = isZh3 ? `${pkg} \u5305\u540D\u53EF\u80FD\u6709\u8BEF\uFF0C\u5E76\u4E0D\u80FD\u5728npm\u4E2D\u641C\u7D22\u5230\uFF0C\u8BF7\u68C0\u67E5` : `${pkg} the package name may be wrong, and cannot be found in npm, please check`;
6857
- loading_status.fail(import_picocolors3.default.red(result ? `${failMsg}
6900
+ loading_status.fail(import_picocolors4.default.red(result ? `${failMsg}
6858
6901
  ${_result}` : failMsg));
6859
6902
  } else {
6860
- loading_status.fail(import_picocolors3.default.red(result ? `${failMsg}
6903
+ loading_status.fail(import_picocolors4.default.red(result ? `${failMsg}
6861
6904
  ${result}` : failMsg));
6862
6905
  }
6863
6906
  if (result) {
@@ -6865,16 +6908,16 @@ ${result}` : failMsg));
6865
6908
  const match = result.match(reg);
6866
6909
  if (match) {
6867
6910
  const dep = match[1];
6868
- (0, import_lazy_js_utils4.jsShell)(`pi ${dep}@latest`);
6911
+ (0, import_lazy_js_utils5.jsShell)(`pi ${dep}@latest`);
6869
6912
  }
6870
6913
  }
6871
- import_process.default.exit();
6914
+ import_process2.default.exit();
6872
6915
  }
6873
6916
 
6874
6917
  // src/pa.ts
6875
- var import_lazy_js_utils5 = require("lazy-js-utils");
6918
+ var import_lazy_js_utils6 = require("lazy-js-utils");
6876
6919
  function pa() {
6877
- return (0, import_lazy_js_utils5.jsShell)("na");
6920
+ return (0, import_lazy_js_utils6.jsShell)("na");
6878
6921
  }
6879
6922
 
6880
6923
  // src/pci.ts
@@ -6883,16 +6926,16 @@ function pci(params, pkg) {
6883
6926
  }
6884
6927
 
6885
6928
  // src/pfind.ts
6886
- var import_lazy_js_utils6 = require("lazy-js-utils");
6929
+ var import_lazy_js_utils7 = require("lazy-js-utils");
6887
6930
  function pfind(params) {
6888
- return (0, import_lazy_js_utils6.jsShell)(`ccommand find ${params}`);
6931
+ return (0, import_lazy_js_utils7.jsShell)(`ccommand find ${params}`);
6889
6932
  }
6890
6933
 
6891
6934
  // src/pil.ts
6892
- var import_lazy_js_utils7 = require("lazy-js-utils");
6893
- var import_picocolors4 = __toESM(require_picocolors(), 1);
6935
+ var import_lazy_js_utils8 = require("lazy-js-utils");
6936
+ var import_picocolors5 = __toESM(require_picocolors(), 1);
6894
6937
  async function pil(params) {
6895
- const { dependencies = {}, devDependencies = {} } = await (0, import_lazy_js_utils7.getPkg)();
6938
+ const { dependencies = {}, devDependencies = {} } = await (0, import_lazy_js_utils8.getPkg)();
6896
6939
  if (!params) {
6897
6940
  const deps = [
6898
6941
  ...Object.keys(dependencies).map((key) => `${key}: ${dependencies[key]}`),
@@ -6900,14 +6943,14 @@ async function pil(params) {
6900
6943
  (key) => `${key}: ${devDependencies[key]}`
6901
6944
  )
6902
6945
  ];
6903
- const { result: choose, status } = (0, import_lazy_js_utils7.jsShell)(
6946
+ const { result: choose, status } = (0, import_lazy_js_utils8.jsShell)(
6904
6947
  `echo ${deps.join(
6905
6948
  ","
6906
6949
  )} | sed "s/,/\\n/g" | gum filter --no-limit --placeholder=" \u{1F914}${process.env.PI_Lang === "zh" ? "\u8BF7\u9009\u62E9\u4E00\u4E2A\u9700\u8981\u83B7\u53D6\u6700\u65B0\u7248\u672C\u7684\u4F9D\u8D56" : "Please select a dependency that needs to obtain the latest version."}"`,
6907
6950
  "pipe"
6908
6951
  );
6909
6952
  if (status === 130) {
6910
- console.log(import_picocolors4.default.dim("\u5DF2\u53D6\u6D88"));
6953
+ console.log(import_picocolors5.default.dim("\u5DF2\u53D6\u6D88"));
6911
6954
  process.exit(0);
6912
6955
  } else if (status !== 0) {
6913
6956
  throw new Error(choose);
@@ -6939,32 +6982,32 @@ async function pil(params) {
6939
6982
  }
6940
6983
 
6941
6984
  // src/pinit.ts
6942
- var import_lazy_js_utils8 = require("lazy-js-utils");
6985
+ var import_lazy_js_utils9 = require("lazy-js-utils");
6943
6986
  async function pinit() {
6944
6987
  console.log("Initializing project...");
6945
- switch (await (0, import_lazy_js_utils8.getPkgTool)()) {
6988
+ switch (await (0, import_lazy_js_utils9.getPkgTool)()) {
6946
6989
  case "npm":
6947
- (0, import_lazy_js_utils8.jsShell)("npm init -y");
6990
+ (0, import_lazy_js_utils9.jsShell)("npm init -y");
6948
6991
  return;
6949
6992
  case "yarn":
6950
- (0, import_lazy_js_utils8.jsShell)("yarn init -y");
6993
+ (0, import_lazy_js_utils9.jsShell)("yarn init -y");
6951
6994
  return;
6952
6995
  case "pnpm":
6953
- (0, import_lazy_js_utils8.jsShell)("pnpm init -y");
6996
+ (0, import_lazy_js_utils9.jsShell)("pnpm init -y");
6954
6997
  return;
6955
6998
  default:
6956
- (0, import_lazy_js_utils8.jsShell)("npm init -y");
6999
+ (0, import_lazy_js_utils9.jsShell)("npm init -y");
6957
7000
  }
6958
7001
  }
6959
7002
 
6960
7003
  // src/pix.ts
6961
- var import_lazy_js_utils9 = require("lazy-js-utils");
7004
+ var import_lazy_js_utils10 = require("lazy-js-utils");
6962
7005
  async function pix(params) {
6963
- switch (await (0, import_lazy_js_utils9.getPkgTool)()) {
7006
+ switch (await (0, import_lazy_js_utils10.getPkgTool)()) {
6964
7007
  case "bun":
6965
- return (0, import_lazy_js_utils9.jsShell)(`bunx ${params}`);
7008
+ return (0, import_lazy_js_utils10.jsShell)(`bunx ${params}`);
6966
7009
  default:
6967
- return (0, import_lazy_js_utils9.jsShell)(`npx ${params}`);
7010
+ return (0, import_lazy_js_utils10.jsShell)(`npx ${params}`);
6968
7011
  }
6969
7012
  }
6970
7013
 
@@ -6975,33 +7018,33 @@ function prun(params) {
6975
7018
  }
6976
7019
 
6977
7020
  // src/pu.ts
6978
- var import_lazy_js_utils10 = require("lazy-js-utils");
7021
+ var import_lazy_js_utils11 = require("lazy-js-utils");
6979
7022
  function pu() {
6980
- return (0, import_lazy_js_utils10.jsShell)("nu");
7023
+ return (0, import_lazy_js_utils11.jsShell)("nu");
6981
7024
  }
6982
7025
 
6983
7026
  // src/pui.ts
6984
- var import_lazy_js_utils11 = require("lazy-js-utils");
6985
- var import_picocolors5 = __toESM(require_picocolors(), 1);
7027
+ var import_lazy_js_utils12 = require("lazy-js-utils");
7028
+ var import_picocolors6 = __toESM(require_picocolors(), 1);
6986
7029
  var isZh4 = process.env.PI_Lang === "zh";
6987
7030
  async function pui(params, pkg) {
6988
7031
  const text = `${isZh4 ? "\u6B63\u5728\u4E3A\u60A8\u5378\u8F7D" : "Uninstalling"} ${pkg} ...`;
6989
7032
  if (!params) {
6990
- const { dependencies = {}, devDependencies = {} } = await (0, import_lazy_js_utils11.getPkg)();
7033
+ const { dependencies = {}, devDependencies = {} } = await (0, import_lazy_js_utils12.getPkg)();
6991
7034
  const deps = [
6992
7035
  ...Object.keys(dependencies).map((key) => `${key}: ${dependencies[key]}`),
6993
7036
  ...Object.keys(devDependencies).map(
6994
7037
  (key) => `${key}: ${devDependencies[key]}`
6995
7038
  )
6996
7039
  ];
6997
- const { result: choose, status: status2 } = (0, import_lazy_js_utils11.jsShell)(
7040
+ const { result: choose, status: status2 } = (0, import_lazy_js_utils12.jsShell)(
6998
7041
  `echo ${deps.join(
6999
7042
  ","
7000
7043
  )} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${process.env.PI_Lang === "zh" ? "\u8BF7\u9009\u62E9\u4E00\u4E2A\u9700\u8981\u5220\u9664\u4F9D\u8D56" : "Please select a dependency to get the latest version."}"`,
7001
7044
  "pipe"
7002
7045
  );
7003
7046
  if (status2 === 130) {
7004
- console.log(import_picocolors5.default.dim("\u5DF2\u53D6\u6D88"));
7047
+ console.log(import_picocolors6.default.dim("\u5DF2\u53D6\u6D88"));
7005
7048
  process.exit(0);
7006
7049
  } else if (status2 !== 0) {
7007
7050
  throw new Error(choose);
@@ -7013,50 +7056,50 @@ async function pui(params, pkg) {
7013
7056
  const failMsg = isZh4 ? `${pkg}\u5378\u8F7D\u5931\u8D25 \u{1F62D}` : `Failed to uninstall ${pkg} \u{1F62D}`;
7014
7057
  if (!pkg) {
7015
7058
  console.log(
7016
- import_picocolors5.default.yellow(
7059
+ import_picocolors6.default.yellow(
7017
7060
  isZh4 ? "\u9700\u8981\u6307\u5B9A\u8981\u5378\u8F7D\u7684\u5305\u540D\uFF01" : "Need to specify an uninstall package name!"
7018
7061
  )
7019
7062
  );
7020
7063
  process.exit(1);
7021
7064
  }
7022
7065
  const loading_status = await loading(text);
7023
- const { status, result } = await (0, import_lazy_js_utils11.useNodeWorker)(`nun ${params}`);
7066
+ const { status, result } = await (0, import_lazy_js_utils12.useNodeWorker)(`nun ${params}`);
7024
7067
  const end = Date.now();
7025
7068
  const costTime = (end - start) / 1e3;
7026
- successMsg += import_picocolors5.default.blue(` ---- \u23F0\uFF1A${costTime}s`);
7069
+ successMsg += import_picocolors6.default.blue(` ---- \u23F0\uFF1A${costTime}s`);
7027
7070
  if (status === 0)
7028
- loading_status.succeed(import_picocolors5.default.green(successMsg));
7071
+ loading_status.succeed(import_picocolors6.default.green(successMsg));
7029
7072
  else
7030
- loading_status.fail(import_picocolors5.default.red(result ? `${failMsg}
7073
+ loading_status.fail(import_picocolors6.default.red(result ? `${failMsg}
7031
7074
  ${result}` : failMsg));
7032
7075
  process.exit();
7033
7076
  }
7034
7077
 
7035
7078
  // src/pio.ts
7036
- var import_process2 = __toESM(require("process"), 1);
7037
- var import_lazy_js_utils12 = require("lazy-js-utils");
7038
- var import_picocolors6 = __toESM(require_picocolors(), 1);
7079
+ var import_process3 = __toESM(require("process"), 1);
7080
+ var import_lazy_js_utils13 = require("lazy-js-utils");
7081
+ var import_picocolors7 = __toESM(require_picocolors(), 1);
7039
7082
  async function pio(params, pkg, executor = "ni") {
7040
7083
  const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
7041
7084
  const failMsg = pkg ? `Failed to install ${pkg} \u{1F62D}` : "Failed to update dependency! \u{1F62D}";
7042
7085
  const offline = "--prefer-offline";
7043
7086
  const newParams = await getParams(params);
7044
- const { status, result } = await (0, import_lazy_js_utils12.useNodeWorker)({
7087
+ const { status, result } = await (0, import_lazy_js_utils13.useNodeWorker)({
7045
7088
  params: `${executor} ${newParams} ${offline}`,
7046
7089
  stdio: "inherit"
7047
7090
  });
7048
7091
  const loading_status = await loading("");
7049
7092
  if (status === 0)
7050
- loading_status.succeed(import_picocolors6.default.green(successMsg));
7093
+ loading_status.succeed(import_picocolors7.default.green(successMsg));
7051
7094
  else
7052
- loading_status.fail(import_picocolors6.default.red(result ? `${result}
7095
+ loading_status.fail(import_picocolors7.default.red(result ? `${result}
7053
7096
 
7054
7097
  ${failMsg}` : failMsg));
7055
- import_process2.default.exit();
7098
+ import_process3.default.exit();
7056
7099
  }
7057
7100
 
7058
7101
  // src/index.ts
7059
- var rootPath = import_process3.default.cwd();
7102
+ var rootPath = import_process4.default.cwd();
7060
7103
  var runMap = {
7061
7104
  pi,
7062
7105
  pix,
@@ -7070,35 +7113,35 @@ var runMap = {
7070
7113
  pfind,
7071
7114
  pio
7072
7115
  };
7073
- var isZh5 = import_process3.default.env.PI_Lang === "zh";
7116
+ var isZh5 = import_process4.default.env.PI_Lang === "zh";
7074
7117
  async function setup() {
7075
- const cmd = import_process3.default.argv[1];
7118
+ const cmd = import_process4.default.argv[1];
7076
7119
  let exec = "";
7077
- if ((0, import_lazy_js_utils13.isWin)()) {
7120
+ if ((0, import_lazy_js_utils14.isWin)()) {
7078
7121
  const last = cmd.lastIndexOf("\\") + 1;
7079
7122
  exec = cmd.slice(last, cmd.length).split(".").slice(0, -1).join(".");
7080
7123
  } else {
7081
7124
  const last = cmd.lastIndexOf("/") + 1;
7082
7125
  exec = cmd.slice(last, cmd.length);
7083
7126
  }
7084
- const argv = import_process3.default.argv.slice(2);
7127
+ const argv = import_process4.default.argv.slice(2);
7085
7128
  help(argv);
7086
- const params = (0, import_lazy_js_utils13.spaceFormat)(argv.join(" ")).trim();
7087
- if (!(0, import_lazy_js_utils13.hasPkg)(rootPath)) {
7088
- if ((0, import_lazy_js_utils13.isGo)()) {
7129
+ const params = (0, import_lazy_js_utils14.spaceFormat)(argv.join(" ")).trim();
7130
+ if (!(0, import_lazy_js_utils14.hasPkg)(rootPath)) {
7131
+ if ((0, import_lazy_js_utils14.isGo)()) {
7089
7132
  if (exec === "pi") {
7090
7133
  const loading_status = await loading(
7091
7134
  `${isZh5 ? "\u6B63\u5728\u4E3A\u60A8\u5B89\u88C5" : "Installing"} ${params} ...
7092
7135
  `
7093
7136
  );
7094
- const { status } = params ? await (0, import_lazy_js_utils13.useNodeWorker)(`go get ${params}`) : await (0, import_lazy_js_utils13.useNodeWorker)("go mod tidy");
7137
+ const { status } = params ? await (0, import_lazy_js_utils14.useNodeWorker)(`go get ${params}`) : await (0, import_lazy_js_utils14.useNodeWorker)("go mod tidy");
7095
7138
  if (status === 0) {
7096
7139
  loading_status.succeed(
7097
- import_picocolors7.default.green(isZh5 ? "\u5B89\u88C5\u6210\u529F! \u{1F60A}" : "Installed successfully! \u{1F60A}")
7140
+ import_picocolors8.default.green(isZh5 ? "\u5B89\u88C5\u6210\u529F! \u{1F60A}" : "Installed successfully! \u{1F60A}")
7098
7141
  );
7099
7142
  } else {
7100
7143
  loading_status.fail(
7101
- import_picocolors7.default.red(isZh5 ? "\u5B89\u88C5\u5931\u8D25 \u{1F62D}" : "Failed to install \u{1F62D}")
7144
+ import_picocolors8.default.red(isZh5 ? "\u5B89\u88C5\u5931\u8D25 \u{1F62D}" : "Failed to install \u{1F62D}")
7102
7145
  );
7103
7146
  }
7104
7147
  } else if (exec === "pui") {
@@ -7106,47 +7149,47 @@ async function setup() {
7106
7149
  `${isZh5 ? "\u6B63\u5728\u4E3A\u60A8\u5378\u8F7D" : "Uninstalling"} ${params} ...
7107
7150
  `
7108
7151
  );
7109
- const { status } = await (0, import_lazy_js_utils13.useNodeWorker)(`go clean ${params}`);
7152
+ const { status } = await (0, import_lazy_js_utils14.useNodeWorker)(`go clean ${params}`);
7110
7153
  if (status === 0) {
7111
7154
  loading_status.succeed(
7112
- import_picocolors7.default.green(isZh5 ? "\u5378\u8F7D\u6210\u529F! \u{1F60A}" : "Uninstalled successfully! \u{1F60A}")
7155
+ import_picocolors8.default.green(isZh5 ? "\u5378\u8F7D\u6210\u529F! \u{1F60A}" : "Uninstalled successfully! \u{1F60A}")
7113
7156
  );
7114
7157
  } else {
7115
7158
  loading_status.fail(
7116
- import_picocolors7.default.red(isZh5 ? "\u5378\u8F7D\u5931\u8D25 \u{1F62D}" : "Failed to uninstall \u{1F62D}")
7159
+ import_picocolors8.default.red(isZh5 ? "\u5378\u8F7D\u5931\u8D25 \u{1F62D}" : "Failed to uninstall \u{1F62D}")
7117
7160
  );
7118
7161
  }
7119
7162
  } else if (exec === "prun") {
7120
7163
  const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
7121
7164
  const target = (await (0, import_fast_glob.default)(match))[0];
7122
- return target ? (0, import_lazy_js_utils13.jsShell)(`go run ${target}`) : (0, import_ccommand2.ccommand)(params);
7165
+ return target ? (0, import_lazy_js_utils14.jsShell)(`go run ${target}`) : (0, import_ccommand2.ccommand)(params);
7123
7166
  } else if (exec === "pinit") {
7124
- (0, import_lazy_js_utils13.jsShell)(`go mod init ${params}`);
7167
+ (0, import_lazy_js_utils14.jsShell)(`go mod init ${params}`);
7125
7168
  } else if (exec === "pbuild") {
7126
- (0, import_lazy_js_utils13.jsShell)(`go build ${params}`);
7169
+ (0, import_lazy_js_utils14.jsShell)(`go build ${params}`);
7127
7170
  } else {
7128
7171
  console.log(
7129
- import_picocolors7.default.red(
7172
+ import_picocolors8.default.red(
7130
7173
  isZh5 ? "\u5F53\u524D\u6307\u4EE4\u8FD8\u4E0D\u652F\u6301" : "The commands is not supported"
7131
7174
  )
7132
7175
  );
7133
7176
  }
7134
- import_process3.default.exit();
7177
+ import_process4.default.exit();
7135
7178
  }
7136
- if ((0, import_lazy_js_utils13.isRust)()) {
7179
+ if ((0, import_lazy_js_utils14.isRust)()) {
7137
7180
  if (exec === "pi") {
7138
7181
  const loading_status = await loading(
7139
7182
  `${isZh5 ? "\u6B63\u5728\u4E3A\u60A8\u5B89\u88C5" : "Installing"} ${params} ...
7140
7183
  `
7141
7184
  );
7142
- const { status } = await (0, import_lazy_js_utils13.useNodeWorker)(`cargo install ${params}`);
7185
+ const { status } = await (0, import_lazy_js_utils14.useNodeWorker)(`cargo install ${params}`);
7143
7186
  if (status === 0) {
7144
7187
  loading_status.succeed(
7145
- import_picocolors7.default.green(isZh5 ? "\u5B89\u88C5\u6210\u529F! \u{1F60A}" : "Installed successfully! \u{1F60A}")
7188
+ import_picocolors8.default.green(isZh5 ? "\u5B89\u88C5\u6210\u529F! \u{1F60A}" : "Installed successfully! \u{1F60A}")
7146
7189
  );
7147
7190
  } else {
7148
7191
  loading_status.fail(
7149
- import_picocolors7.default.red(isZh5 ? "\u5B89\u88C5\u5931\u8D25 \u{1F62D}" : "Failed to install \u{1F62D}")
7192
+ import_picocolors8.default.red(isZh5 ? "\u5B89\u88C5\u5931\u8D25 \u{1F62D}" : "Failed to install \u{1F62D}")
7150
7193
  );
7151
7194
  }
7152
7195
  } else if (exec === "pui") {
@@ -7154,34 +7197,34 @@ async function setup() {
7154
7197
  `${isZh5 ? "\u6B63\u5728\u4E3A\u60A8\u5378\u8F7D" : "Uninstalling"} ${params} ...
7155
7198
  `
7156
7199
  );
7157
- const { status } = await (0, import_lazy_js_utils13.useNodeWorker)(`cargo uninstall ${params}`);
7200
+ const { status } = await (0, import_lazy_js_utils14.useNodeWorker)(`cargo uninstall ${params}`);
7158
7201
  if (status === 0) {
7159
7202
  loading_status.succeed(
7160
- import_picocolors7.default.green(isZh5 ? "\u5378\u8F7D\u6210\u529F! \u{1F60A}" : "Uninstalled successfully! \u{1F60A}")
7203
+ import_picocolors8.default.green(isZh5 ? "\u5378\u8F7D\u6210\u529F! \u{1F60A}" : "Uninstalled successfully! \u{1F60A}")
7161
7204
  );
7162
7205
  } else {
7163
7206
  loading_status.fail(
7164
- import_picocolors7.default.red(isZh5 ? "\u5378\u8F7D\u5931\u8D25 \u{1F62D}" : "Failed to uninstall \u{1F62D}")
7207
+ import_picocolors8.default.red(isZh5 ? "\u5378\u8F7D\u5931\u8D25 \u{1F62D}" : "Failed to uninstall \u{1F62D}")
7165
7208
  );
7166
7209
  }
7167
7210
  } else if (exec === "prun") {
7168
- (0, import_lazy_js_utils13.jsShell)(`cargo run ${params}`);
7211
+ (0, import_lazy_js_utils14.jsShell)(`cargo run ${params}`);
7169
7212
  } else if (exec === "pinit") {
7170
- (0, import_lazy_js_utils13.jsShell)(`cargo init ${params}`);
7213
+ (0, import_lazy_js_utils14.jsShell)(`cargo init ${params}`);
7171
7214
  } else if (exec === "pbuild") {
7172
- (0, import_lazy_js_utils13.jsShell)(`cargo build ${params}`);
7215
+ (0, import_lazy_js_utils14.jsShell)(`cargo build ${params}`);
7173
7216
  } else {
7174
7217
  console.log(
7175
- import_picocolors7.default.red(
7218
+ import_picocolors8.default.red(
7176
7219
  isZh5 ? "\u5F53\u524D\u6307\u4EE4\u8FD8\u4E0D\u652F\u6301" : "The commands is not supported"
7177
7220
  )
7178
7221
  );
7179
7222
  }
7180
- import_process3.default.exit();
7223
+ import_process4.default.exit();
7181
7224
  }
7182
7225
  if (!runMap[exec]) {
7183
7226
  console.log(
7184
- import_picocolors7.default.yellow(
7227
+ import_picocolors8.default.yellow(
7185
7228
  isZh5 ? "\u547D\u4EE4\u4E0D\u5B58\u5728\uFF0C\u8BF7\u6267\u884Cpi -h\u67E5\u770B\u5E2E\u52A9" : "The command does not exist, please execute pi -h to view the help"
7186
7229
  )
7187
7230
  );
package/dist/index.js CHANGED
@@ -204,11 +204,11 @@ var require_signals = __commonJS({
204
204
  // node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js
205
205
  var require_signal_exit = __commonJS({
206
206
  "node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports, module) {
207
- var process11 = global.process;
208
- var processOk = function(process12) {
209
- return process12 && typeof process12 === "object" && typeof process12.removeListener === "function" && typeof process12.emit === "function" && typeof process12.reallyExit === "function" && typeof process12.listeners === "function" && typeof process12.kill === "function" && typeof process12.pid === "number" && typeof process12.on === "function";
207
+ var process12 = global.process;
208
+ var processOk = function(process13) {
209
+ return process13 && typeof process13 === "object" && typeof process13.removeListener === "function" && typeof process13.emit === "function" && typeof process13.reallyExit === "function" && typeof process13.listeners === "function" && typeof process13.kill === "function" && typeof process13.pid === "number" && typeof process13.on === "function";
210
210
  };
211
- if (!processOk(process11)) {
211
+ if (!processOk(process12)) {
212
212
  module.exports = function() {
213
213
  return function() {
214
214
  };
@@ -216,15 +216,15 @@ var require_signal_exit = __commonJS({
216
216
  } else {
217
217
  assert = __require("assert");
218
218
  signals = require_signals();
219
- isWin2 = /^win/i.test(process11.platform);
219
+ isWin2 = /^win/i.test(process12.platform);
220
220
  EE = __require("events");
221
221
  if (typeof EE !== "function") {
222
222
  EE = EE.EventEmitter;
223
223
  }
224
- if (process11.__signal_exit_emitter__) {
225
- emitter = process11.__signal_exit_emitter__;
224
+ if (process12.__signal_exit_emitter__) {
225
+ emitter = process12.__signal_exit_emitter__;
226
226
  } else {
227
- emitter = process11.__signal_exit_emitter__ = new EE();
227
+ emitter = process12.__signal_exit_emitter__ = new EE();
228
228
  emitter.count = 0;
229
229
  emitter.emitted = {};
230
230
  }
@@ -261,12 +261,12 @@ var require_signal_exit = __commonJS({
261
261
  loaded = false;
262
262
  signals.forEach(function(sig) {
263
263
  try {
264
- process11.removeListener(sig, sigListeners[sig]);
264
+ process12.removeListener(sig, sigListeners[sig]);
265
265
  } catch (er) {
266
266
  }
267
267
  });
268
- process11.emit = originalProcessEmit;
269
- process11.reallyExit = originalProcessReallyExit;
268
+ process12.emit = originalProcessEmit;
269
+ process12.reallyExit = originalProcessReallyExit;
270
270
  emitter.count -= 1;
271
271
  };
272
272
  module.exports.unload = unload;
@@ -283,7 +283,7 @@ var require_signal_exit = __commonJS({
283
283
  if (!processOk(global.process)) {
284
284
  return;
285
285
  }
286
- var listeners = process11.listeners(sig);
286
+ var listeners = process12.listeners(sig);
287
287
  if (listeners.length === emitter.count) {
288
288
  unload();
289
289
  emit("exit", null, sig);
@@ -291,7 +291,7 @@ var require_signal_exit = __commonJS({
291
291
  if (isWin2 && sig === "SIGHUP") {
292
292
  sig = "SIGINT";
293
293
  }
294
- process11.kill(process11.pid, sig);
294
+ process12.kill(process12.pid, sig);
295
295
  }
296
296
  };
297
297
  });
@@ -307,36 +307,36 @@ var require_signal_exit = __commonJS({
307
307
  emitter.count += 1;
308
308
  signals = signals.filter(function(sig) {
309
309
  try {
310
- process11.on(sig, sigListeners[sig]);
310
+ process12.on(sig, sigListeners[sig]);
311
311
  return true;
312
312
  } catch (er) {
313
313
  return false;
314
314
  }
315
315
  });
316
- process11.emit = processEmit;
317
- process11.reallyExit = processReallyExit;
316
+ process12.emit = processEmit;
317
+ process12.reallyExit = processReallyExit;
318
318
  };
319
319
  module.exports.load = load;
320
- originalProcessReallyExit = process11.reallyExit;
320
+ originalProcessReallyExit = process12.reallyExit;
321
321
  processReallyExit = function processReallyExit2(code) {
322
322
  if (!processOk(global.process)) {
323
323
  return;
324
324
  }
325
- process11.exitCode = code || /* istanbul ignore next */
325
+ process12.exitCode = code || /* istanbul ignore next */
326
326
  0;
327
- emit("exit", process11.exitCode, null);
328
- emit("afterexit", process11.exitCode, null);
329
- originalProcessReallyExit.call(process11, process11.exitCode);
327
+ emit("exit", process12.exitCode, null);
328
+ emit("afterexit", process12.exitCode, null);
329
+ originalProcessReallyExit.call(process12, process12.exitCode);
330
330
  };
331
- originalProcessEmit = process11.emit;
331
+ originalProcessEmit = process12.emit;
332
332
  processEmit = function processEmit2(ev, arg) {
333
333
  if (ev === "exit" && processOk(global.process)) {
334
334
  if (arg !== void 0) {
335
- process11.exitCode = arg;
335
+ process12.exitCode = arg;
336
336
  }
337
337
  var ret = originalProcessEmit.apply(this, arguments);
338
- emit("exit", process11.exitCode, null);
339
- emit("afterexit", process11.exitCode, null);
338
+ emit("exit", process12.exitCode, null);
339
+ emit("afterexit", process12.exitCode, null);
340
340
  return ret;
341
341
  } else {
342
342
  return originalProcessEmit.apply(this, arguments);
@@ -5652,14 +5652,14 @@ var require_bl = __commonJS({
5652
5652
  });
5653
5653
 
5654
5654
  // src/index.ts
5655
- var import_picocolors7 = __toESM(require_picocolors(), 1);
5656
- import process10 from "process";
5655
+ var import_picocolors8 = __toESM(require_picocolors(), 1);
5656
+ import process11 from "process";
5657
5657
  import {
5658
5658
  hasPkg,
5659
5659
  isGo,
5660
5660
  isRust,
5661
5661
  isWin,
5662
- jsShell as jsShell12,
5662
+ jsShell as jsShell13,
5663
5663
  spaceFormat,
5664
5664
  useNodeWorker as useNodeWorker4
5665
5665
  } from "lazy-js-utils";
@@ -6755,7 +6755,7 @@ function getLatestVersion(pkg, isZh6 = true) {
6755
6755
  import { jsShell as jsShell2 } from "lazy-js-utils";
6756
6756
 
6757
6757
  // package.json
6758
- var version = "0.0.81";
6758
+ var version = "0.0.83";
6759
6759
 
6760
6760
  // src/help.ts
6761
6761
  var isZh2 = process.env.PI_Lang === "zh";
@@ -6810,11 +6810,54 @@ async function installDeps() {
6810
6810
  }
6811
6811
 
6812
6812
  // src/pi.ts
6813
+ var import_picocolors4 = __toESM(require_picocolors(), 1);
6814
+ import process9 from "process";
6815
+ import { getPkgTool as getPkgTool2, jsShell as jsShell5, useNodeWorker } from "lazy-js-utils";
6816
+
6817
+ // src/detectNode.ts
6813
6818
  var import_picocolors3 = __toESM(require_picocolors(), 1);
6814
6819
  import process8 from "process";
6815
- import { getPkgTool as getPkgTool2, jsShell as jsShell4, useNodeWorker } from "lazy-js-utils";
6816
- var isZh3 = process8.env.PI_Lang === "zh";
6820
+ import { getPkg as getPkg2, jsShell as jsShell4 } from "lazy-js-utils";
6821
+ var semver = __require("semver");
6822
+ async function detectNode() {
6823
+ var _a;
6824
+ let pkg;
6825
+ try {
6826
+ pkg = await getPkg2();
6827
+ } catch (e) {
6828
+ const cwd = process8.cwd();
6829
+ console.log(import_picocolors3.default.red(`\u5F53\u524D\u76EE\u5F55: ${cwd} \u6CA1\u6709package.json\u6587\u4EF6`));
6830
+ process8.exit(1);
6831
+ }
6832
+ if ((_a = pkg.engines) == null ? void 0 : _a.node) {
6833
+ const isSafe = semver.satisfies(process8.version, pkg.engines.node);
6834
+ if (!isSafe) {
6835
+ const { result, status } = await jsShell4(
6836
+ `echo "yes
6837
+ no" | gum filter --placeholder=" \u5F53\u524Dnode\u7248\u672C\u4E0D\u6EE1\u8DB3 ${pkg.engines.node}\uFF0C\u662F\u5426\u5207\u6362node\u7248\u672C"`,
6838
+ "pipe"
6839
+ );
6840
+ if (status === 0 && result === "yes") {
6841
+ await jsShell4(
6842
+ `
6843
+ current=$(echo $(fnm current))
6844
+ registery=$(echo "$(fnm ls)" | sed 's/system//g' | sed 's/default//g' | sed 's/* //g' | sed "s/$current/* $current/g" | gum filter --placeholder=" \u8BF7\u9009\u62E9\u4E00\u4E2Anode\u7248\u672C")
6845
+ registery=$(echo \${registery// /} | sed 's/*//g')
6846
+ if [ $registery ]; then
6847
+ fnm use \${registery% -*}
6848
+ fi
6849
+ `,
6850
+ "pipe"
6851
+ );
6852
+ }
6853
+ }
6854
+ }
6855
+ }
6856
+
6857
+ // src/pi.ts
6858
+ var isZh3 = process9.env.PI_Lang === "zh";
6817
6859
  async function pi(params, pkg, executor = "ni") {
6860
+ await detectNode();
6818
6861
  const text = pkg ? `Installing ${params} ...` : "Updating dependency ...";
6819
6862
  const isLatest = executor === "pil";
6820
6863
  const start = Date.now();
@@ -6828,7 +6871,7 @@ async function pi(params, pkg, executor = "ni") {
6828
6871
  const newParams = isLatest ? params : await getParams(params);
6829
6872
  let stdio = "pipe";
6830
6873
  let loading_status;
6831
- const { PI_DEFAULT, PI_MaxSockets: sockets } = process8.env;
6874
+ const { PI_DEFAULT, PI_MaxSockets: sockets } = process9.env;
6832
6875
  const pkgTool = await getPkgTool2();
6833
6876
  const maxSockets = sockets || 4;
6834
6877
  const install = PI_DEFAULT === "yarn" || pkgTool === "yarn" ? newParams ? "add" : "" : "install";
@@ -6853,15 +6896,15 @@ async function pi(params, pkg, executor = "ni") {
6853
6896
  loading_status = await loading("");
6854
6897
  const end = Date.now();
6855
6898
  const costTime = (end - start) / 1e3;
6856
- successMsg += import_picocolors3.default.blue(` ---- \u23F0\uFF1A${costTime}s`);
6899
+ successMsg += import_picocolors4.default.blue(` ---- \u23F0\uFF1A${costTime}s`);
6857
6900
  if (status === 0) {
6858
- loading_status.succeed(import_picocolors3.default.green(successMsg));
6901
+ loading_status.succeed(import_picocolors4.default.green(successMsg));
6859
6902
  } else if (result && result.includes("Not Found - 404")) {
6860
6903
  const _result = isZh3 ? `${pkg} \u5305\u540D\u53EF\u80FD\u6709\u8BEF\uFF0C\u5E76\u4E0D\u80FD\u5728npm\u4E2D\u641C\u7D22\u5230\uFF0C\u8BF7\u68C0\u67E5` : `${pkg} the package name may be wrong, and cannot be found in npm, please check`;
6861
- loading_status.fail(import_picocolors3.default.red(result ? `${failMsg}
6904
+ loading_status.fail(import_picocolors4.default.red(result ? `${failMsg}
6862
6905
  ${_result}` : failMsg));
6863
6906
  } else {
6864
- loading_status.fail(import_picocolors3.default.red(result ? `${failMsg}
6907
+ loading_status.fail(import_picocolors4.default.red(result ? `${failMsg}
6865
6908
  ${result}` : failMsg));
6866
6909
  }
6867
6910
  if (result) {
@@ -6869,16 +6912,16 @@ ${result}` : failMsg));
6869
6912
  const match = result.match(reg);
6870
6913
  if (match) {
6871
6914
  const dep = match[1];
6872
- jsShell4(`pi ${dep}@latest`);
6915
+ jsShell5(`pi ${dep}@latest`);
6873
6916
  }
6874
6917
  }
6875
- process8.exit();
6918
+ process9.exit();
6876
6919
  }
6877
6920
 
6878
6921
  // src/pa.ts
6879
- import { jsShell as jsShell5 } from "lazy-js-utils";
6922
+ import { jsShell as jsShell6 } from "lazy-js-utils";
6880
6923
  function pa() {
6881
- return jsShell5("na");
6924
+ return jsShell6("na");
6882
6925
  }
6883
6926
 
6884
6927
  // src/pci.ts
@@ -6887,16 +6930,16 @@ function pci(params, pkg) {
6887
6930
  }
6888
6931
 
6889
6932
  // src/pfind.ts
6890
- import { jsShell as jsShell6 } from "lazy-js-utils";
6933
+ import { jsShell as jsShell7 } from "lazy-js-utils";
6891
6934
  function pfind(params) {
6892
- return jsShell6(`ccommand find ${params}`);
6935
+ return jsShell7(`ccommand find ${params}`);
6893
6936
  }
6894
6937
 
6895
6938
  // src/pil.ts
6896
- var import_picocolors4 = __toESM(require_picocolors(), 1);
6897
- import { getPkg as getPkg2, jsShell as jsShell7 } from "lazy-js-utils";
6939
+ var import_picocolors5 = __toESM(require_picocolors(), 1);
6940
+ import { getPkg as getPkg3, jsShell as jsShell8 } from "lazy-js-utils";
6898
6941
  async function pil(params) {
6899
- const { dependencies = {}, devDependencies = {} } = await getPkg2();
6942
+ const { dependencies = {}, devDependencies = {} } = await getPkg3();
6900
6943
  if (!params) {
6901
6944
  const deps = [
6902
6945
  ...Object.keys(dependencies).map((key) => `${key}: ${dependencies[key]}`),
@@ -6904,14 +6947,14 @@ async function pil(params) {
6904
6947
  (key) => `${key}: ${devDependencies[key]}`
6905
6948
  )
6906
6949
  ];
6907
- const { result: choose, status } = jsShell7(
6950
+ const { result: choose, status } = jsShell8(
6908
6951
  `echo ${deps.join(
6909
6952
  ","
6910
6953
  )} | sed "s/,/\\n/g" | gum filter --no-limit --placeholder=" \u{1F914}${process.env.PI_Lang === "zh" ? "\u8BF7\u9009\u62E9\u4E00\u4E2A\u9700\u8981\u83B7\u53D6\u6700\u65B0\u7248\u672C\u7684\u4F9D\u8D56" : "Please select a dependency that needs to obtain the latest version."}"`,
6911
6954
  "pipe"
6912
6955
  );
6913
6956
  if (status === 130) {
6914
- console.log(import_picocolors4.default.dim("\u5DF2\u53D6\u6D88"));
6957
+ console.log(import_picocolors5.default.dim("\u5DF2\u53D6\u6D88"));
6915
6958
  process.exit(0);
6916
6959
  } else if (status !== 0) {
6917
6960
  throw new Error(choose);
@@ -6943,32 +6986,32 @@ async function pil(params) {
6943
6986
  }
6944
6987
 
6945
6988
  // src/pinit.ts
6946
- import { getPkgTool as getPkgTool3, jsShell as jsShell8 } from "lazy-js-utils";
6989
+ import { getPkgTool as getPkgTool3, jsShell as jsShell9 } from "lazy-js-utils";
6947
6990
  async function pinit() {
6948
6991
  console.log("Initializing project...");
6949
6992
  switch (await getPkgTool3()) {
6950
6993
  case "npm":
6951
- jsShell8("npm init -y");
6994
+ jsShell9("npm init -y");
6952
6995
  return;
6953
6996
  case "yarn":
6954
- jsShell8("yarn init -y");
6997
+ jsShell9("yarn init -y");
6955
6998
  return;
6956
6999
  case "pnpm":
6957
- jsShell8("pnpm init -y");
7000
+ jsShell9("pnpm init -y");
6958
7001
  return;
6959
7002
  default:
6960
- jsShell8("npm init -y");
7003
+ jsShell9("npm init -y");
6961
7004
  }
6962
7005
  }
6963
7006
 
6964
7007
  // src/pix.ts
6965
- import { getPkgTool as getPkgTool4, jsShell as jsShell9 } from "lazy-js-utils";
7008
+ import { getPkgTool as getPkgTool4, jsShell as jsShell10 } from "lazy-js-utils";
6966
7009
  async function pix(params) {
6967
7010
  switch (await getPkgTool4()) {
6968
7011
  case "bun":
6969
- return jsShell9(`bunx ${params}`);
7012
+ return jsShell10(`bunx ${params}`);
6970
7013
  default:
6971
- return jsShell9(`npx ${params}`);
7014
+ return jsShell10(`npx ${params}`);
6972
7015
  }
6973
7016
  }
6974
7017
 
@@ -6979,33 +7022,33 @@ function prun(params) {
6979
7022
  }
6980
7023
 
6981
7024
  // src/pu.ts
6982
- import { jsShell as jsShell10 } from "lazy-js-utils";
7025
+ import { jsShell as jsShell11 } from "lazy-js-utils";
6983
7026
  function pu() {
6984
- return jsShell10("nu");
7027
+ return jsShell11("nu");
6985
7028
  }
6986
7029
 
6987
7030
  // src/pui.ts
6988
- var import_picocolors5 = __toESM(require_picocolors(), 1);
6989
- import { getPkg as getPkg3, jsShell as jsShell11, useNodeWorker as useNodeWorker2 } from "lazy-js-utils";
7031
+ var import_picocolors6 = __toESM(require_picocolors(), 1);
7032
+ import { getPkg as getPkg4, jsShell as jsShell12, useNodeWorker as useNodeWorker2 } from "lazy-js-utils";
6990
7033
  var isZh4 = process.env.PI_Lang === "zh";
6991
7034
  async function pui(params, pkg) {
6992
7035
  const text = `${isZh4 ? "\u6B63\u5728\u4E3A\u60A8\u5378\u8F7D" : "Uninstalling"} ${pkg} ...`;
6993
7036
  if (!params) {
6994
- const { dependencies = {}, devDependencies = {} } = await getPkg3();
7037
+ const { dependencies = {}, devDependencies = {} } = await getPkg4();
6995
7038
  const deps = [
6996
7039
  ...Object.keys(dependencies).map((key) => `${key}: ${dependencies[key]}`),
6997
7040
  ...Object.keys(devDependencies).map(
6998
7041
  (key) => `${key}: ${devDependencies[key]}`
6999
7042
  )
7000
7043
  ];
7001
- const { result: choose, status: status2 } = jsShell11(
7044
+ const { result: choose, status: status2 } = jsShell12(
7002
7045
  `echo ${deps.join(
7003
7046
  ","
7004
7047
  )} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${process.env.PI_Lang === "zh" ? "\u8BF7\u9009\u62E9\u4E00\u4E2A\u9700\u8981\u5220\u9664\u4F9D\u8D56" : "Please select a dependency to get the latest version."}"`,
7005
7048
  "pipe"
7006
7049
  );
7007
7050
  if (status2 === 130) {
7008
- console.log(import_picocolors5.default.dim("\u5DF2\u53D6\u6D88"));
7051
+ console.log(import_picocolors6.default.dim("\u5DF2\u53D6\u6D88"));
7009
7052
  process.exit(0);
7010
7053
  } else if (status2 !== 0) {
7011
7054
  throw new Error(choose);
@@ -7017,7 +7060,7 @@ async function pui(params, pkg) {
7017
7060
  const failMsg = isZh4 ? `${pkg}\u5378\u8F7D\u5931\u8D25 \u{1F62D}` : `Failed to uninstall ${pkg} \u{1F62D}`;
7018
7061
  if (!pkg) {
7019
7062
  console.log(
7020
- import_picocolors5.default.yellow(
7063
+ import_picocolors6.default.yellow(
7021
7064
  isZh4 ? "\u9700\u8981\u6307\u5B9A\u8981\u5378\u8F7D\u7684\u5305\u540D\uFF01" : "Need to specify an uninstall package name!"
7022
7065
  )
7023
7066
  );
@@ -7027,18 +7070,18 @@ async function pui(params, pkg) {
7027
7070
  const { status, result } = await useNodeWorker2(`nun ${params}`);
7028
7071
  const end = Date.now();
7029
7072
  const costTime = (end - start) / 1e3;
7030
- successMsg += import_picocolors5.default.blue(` ---- \u23F0\uFF1A${costTime}s`);
7073
+ successMsg += import_picocolors6.default.blue(` ---- \u23F0\uFF1A${costTime}s`);
7031
7074
  if (status === 0)
7032
- loading_status.succeed(import_picocolors5.default.green(successMsg));
7075
+ loading_status.succeed(import_picocolors6.default.green(successMsg));
7033
7076
  else
7034
- loading_status.fail(import_picocolors5.default.red(result ? `${failMsg}
7077
+ loading_status.fail(import_picocolors6.default.red(result ? `${failMsg}
7035
7078
  ${result}` : failMsg));
7036
7079
  process.exit();
7037
7080
  }
7038
7081
 
7039
7082
  // src/pio.ts
7040
- var import_picocolors6 = __toESM(require_picocolors(), 1);
7041
- import process9 from "process";
7083
+ var import_picocolors7 = __toESM(require_picocolors(), 1);
7084
+ import process10 from "process";
7042
7085
  import { useNodeWorker as useNodeWorker3 } from "lazy-js-utils";
7043
7086
  async function pio(params, pkg, executor = "ni") {
7044
7087
  const successMsg = pkg ? `Installed ${pkg} successfully! \u{1F60A}` : "Updated dependency successfully! \u{1F60A}";
@@ -7051,16 +7094,16 @@ async function pio(params, pkg, executor = "ni") {
7051
7094
  });
7052
7095
  const loading_status = await loading("");
7053
7096
  if (status === 0)
7054
- loading_status.succeed(import_picocolors6.default.green(successMsg));
7097
+ loading_status.succeed(import_picocolors7.default.green(successMsg));
7055
7098
  else
7056
- loading_status.fail(import_picocolors6.default.red(result ? `${result}
7099
+ loading_status.fail(import_picocolors7.default.red(result ? `${result}
7057
7100
 
7058
7101
  ${failMsg}` : failMsg));
7059
- process9.exit();
7102
+ process10.exit();
7060
7103
  }
7061
7104
 
7062
7105
  // src/index.ts
7063
- var rootPath = process10.cwd();
7106
+ var rootPath = process11.cwd();
7064
7107
  var runMap = {
7065
7108
  pi,
7066
7109
  pix,
@@ -7074,9 +7117,9 @@ var runMap = {
7074
7117
  pfind,
7075
7118
  pio
7076
7119
  };
7077
- var isZh5 = process10.env.PI_Lang === "zh";
7120
+ var isZh5 = process11.env.PI_Lang === "zh";
7078
7121
  async function setup() {
7079
- const cmd = process10.argv[1];
7122
+ const cmd = process11.argv[1];
7080
7123
  let exec = "";
7081
7124
  if (isWin()) {
7082
7125
  const last = cmd.lastIndexOf("\\") + 1;
@@ -7085,7 +7128,7 @@ async function setup() {
7085
7128
  const last = cmd.lastIndexOf("/") + 1;
7086
7129
  exec = cmd.slice(last, cmd.length);
7087
7130
  }
7088
- const argv = process10.argv.slice(2);
7131
+ const argv = process11.argv.slice(2);
7089
7132
  help(argv);
7090
7133
  const params = spaceFormat(argv.join(" ")).trim();
7091
7134
  if (!hasPkg(rootPath)) {
@@ -7098,11 +7141,11 @@ async function setup() {
7098
7141
  const { status } = params ? await useNodeWorker4(`go get ${params}`) : await useNodeWorker4("go mod tidy");
7099
7142
  if (status === 0) {
7100
7143
  loading_status.succeed(
7101
- import_picocolors7.default.green(isZh5 ? "\u5B89\u88C5\u6210\u529F! \u{1F60A}" : "Installed successfully! \u{1F60A}")
7144
+ import_picocolors8.default.green(isZh5 ? "\u5B89\u88C5\u6210\u529F! \u{1F60A}" : "Installed successfully! \u{1F60A}")
7102
7145
  );
7103
7146
  } else {
7104
7147
  loading_status.fail(
7105
- import_picocolors7.default.red(isZh5 ? "\u5B89\u88C5\u5931\u8D25 \u{1F62D}" : "Failed to install \u{1F62D}")
7148
+ import_picocolors8.default.red(isZh5 ? "\u5B89\u88C5\u5931\u8D25 \u{1F62D}" : "Failed to install \u{1F62D}")
7106
7149
  );
7107
7150
  }
7108
7151
  } else if (exec === "pui") {
@@ -7113,29 +7156,29 @@ async function setup() {
7113
7156
  const { status } = await useNodeWorker4(`go clean ${params}`);
7114
7157
  if (status === 0) {
7115
7158
  loading_status.succeed(
7116
- import_picocolors7.default.green(isZh5 ? "\u5378\u8F7D\u6210\u529F! \u{1F60A}" : "Uninstalled successfully! \u{1F60A}")
7159
+ import_picocolors8.default.green(isZh5 ? "\u5378\u8F7D\u6210\u529F! \u{1F60A}" : "Uninstalled successfully! \u{1F60A}")
7117
7160
  );
7118
7161
  } else {
7119
7162
  loading_status.fail(
7120
- import_picocolors7.default.red(isZh5 ? "\u5378\u8F7D\u5931\u8D25 \u{1F62D}" : "Failed to uninstall \u{1F62D}")
7163
+ import_picocolors8.default.red(isZh5 ? "\u5378\u8F7D\u5931\u8D25 \u{1F62D}" : "Failed to uninstall \u{1F62D}")
7121
7164
  );
7122
7165
  }
7123
7166
  } else if (exec === "prun") {
7124
7167
  const match = params ? params.endsWith(".go") ? [`**/${params}`] : [`**/${params}.go`, `**/${params}/main.go`] : "main.go";
7125
7168
  const target = (await fg(match))[0];
7126
- return target ? jsShell12(`go run ${target}`) : ccommand2(params);
7169
+ return target ? jsShell13(`go run ${target}`) : ccommand2(params);
7127
7170
  } else if (exec === "pinit") {
7128
- jsShell12(`go mod init ${params}`);
7171
+ jsShell13(`go mod init ${params}`);
7129
7172
  } else if (exec === "pbuild") {
7130
- jsShell12(`go build ${params}`);
7173
+ jsShell13(`go build ${params}`);
7131
7174
  } else {
7132
7175
  console.log(
7133
- import_picocolors7.default.red(
7176
+ import_picocolors8.default.red(
7134
7177
  isZh5 ? "\u5F53\u524D\u6307\u4EE4\u8FD8\u4E0D\u652F\u6301" : "The commands is not supported"
7135
7178
  )
7136
7179
  );
7137
7180
  }
7138
- process10.exit();
7181
+ process11.exit();
7139
7182
  }
7140
7183
  if (isRust()) {
7141
7184
  if (exec === "pi") {
@@ -7146,11 +7189,11 @@ async function setup() {
7146
7189
  const { status } = await useNodeWorker4(`cargo install ${params}`);
7147
7190
  if (status === 0) {
7148
7191
  loading_status.succeed(
7149
- import_picocolors7.default.green(isZh5 ? "\u5B89\u88C5\u6210\u529F! \u{1F60A}" : "Installed successfully! \u{1F60A}")
7192
+ import_picocolors8.default.green(isZh5 ? "\u5B89\u88C5\u6210\u529F! \u{1F60A}" : "Installed successfully! \u{1F60A}")
7150
7193
  );
7151
7194
  } else {
7152
7195
  loading_status.fail(
7153
- import_picocolors7.default.red(isZh5 ? "\u5B89\u88C5\u5931\u8D25 \u{1F62D}" : "Failed to install \u{1F62D}")
7196
+ import_picocolors8.default.red(isZh5 ? "\u5B89\u88C5\u5931\u8D25 \u{1F62D}" : "Failed to install \u{1F62D}")
7154
7197
  );
7155
7198
  }
7156
7199
  } else if (exec === "pui") {
@@ -7161,31 +7204,31 @@ async function setup() {
7161
7204
  const { status } = await useNodeWorker4(`cargo uninstall ${params}`);
7162
7205
  if (status === 0) {
7163
7206
  loading_status.succeed(
7164
- import_picocolors7.default.green(isZh5 ? "\u5378\u8F7D\u6210\u529F! \u{1F60A}" : "Uninstalled successfully! \u{1F60A}")
7207
+ import_picocolors8.default.green(isZh5 ? "\u5378\u8F7D\u6210\u529F! \u{1F60A}" : "Uninstalled successfully! \u{1F60A}")
7165
7208
  );
7166
7209
  } else {
7167
7210
  loading_status.fail(
7168
- import_picocolors7.default.red(isZh5 ? "\u5378\u8F7D\u5931\u8D25 \u{1F62D}" : "Failed to uninstall \u{1F62D}")
7211
+ import_picocolors8.default.red(isZh5 ? "\u5378\u8F7D\u5931\u8D25 \u{1F62D}" : "Failed to uninstall \u{1F62D}")
7169
7212
  );
7170
7213
  }
7171
7214
  } else if (exec === "prun") {
7172
- jsShell12(`cargo run ${params}`);
7215
+ jsShell13(`cargo run ${params}`);
7173
7216
  } else if (exec === "pinit") {
7174
- jsShell12(`cargo init ${params}`);
7217
+ jsShell13(`cargo init ${params}`);
7175
7218
  } else if (exec === "pbuild") {
7176
- jsShell12(`cargo build ${params}`);
7219
+ jsShell13(`cargo build ${params}`);
7177
7220
  } else {
7178
7221
  console.log(
7179
- import_picocolors7.default.red(
7222
+ import_picocolors8.default.red(
7180
7223
  isZh5 ? "\u5F53\u524D\u6307\u4EE4\u8FD8\u4E0D\u652F\u6301" : "The commands is not supported"
7181
7224
  )
7182
7225
  );
7183
7226
  }
7184
- process10.exit();
7227
+ process11.exit();
7185
7228
  }
7186
7229
  if (!runMap[exec]) {
7187
7230
  console.log(
7188
- import_picocolors7.default.yellow(
7231
+ import_picocolors8.default.yellow(
7189
7232
  isZh5 ? "\u547D\u4EE4\u4E0D\u5B58\u5728\uFF0C\u8BF7\u6267\u884Cpi -h\u67E5\u770B\u5E2E\u52A9" : "The command does not exist, please execute pi -h to view the help"
7190
7233
  )
7191
7234
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simon_he/pi",
3
3
  "type": "module",
4
- "version": "0.0.81",
4
+ "version": "0.0.83",
5
5
  "description": "",
6
6
  "author": "Simon He",
7
7
  "license": "MIT",
@@ -49,6 +49,9 @@
49
49
  "files": [
50
50
  "dist"
51
51
  ],
52
+ "engines": {
53
+ "node": ">=16.0.0"
54
+ },
52
55
  "scripts": {
53
56
  "build": "tsup ./src/index.ts --format cjs,esm --dts --clean ",
54
57
  "dev": "bun build -- --watch src",
@@ -64,7 +67,8 @@
64
67
  "dependencies": {
65
68
  "ccommand": "^1.0.55",
66
69
  "fast-glob": "latest",
67
- "lazy-js-utils": "latest"
70
+ "lazy-js-utils": "latest",
71
+ "semver": "^7.5.4"
68
72
  },
69
73
  "devDependencies": {
70
74
  "@antfu/eslint-config": "^0.34.0",