@simon_he/pi 0.0.87 → 0.0.89

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/index.cjs CHANGED
@@ -61,50 +61,58 @@ var __privateWrapper = (obj, member, setter, getter) => ({
61
61
  }
62
62
  });
63
63
 
64
- // node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js
64
+ // node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
65
65
  var require_picocolors = __commonJS({
66
- "node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports, module2) {
67
- var tty2 = require("tty");
68
- var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
66
+ "node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports, module2) {
67
+ var argv = process.argv || [];
68
+ var env2 = process.env;
69
+ var isColorSupported = !("NO_COLOR" in env2 || argv.includes("--no-color")) && ("FORCE_COLOR" in env2 || argv.includes("--color") || process.platform === "win32" || require != null && require("tty").isatty(1) && env2.TERM !== "dumb" || "CI" in env2);
69
70
  var formatter = (open, close, replace = open) => (input) => {
70
71
  let string = "" + input;
71
72
  let index = string.indexOf(close, open.length);
72
73
  return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
73
74
  };
74
75
  var replaceClose = (string, close, replace, index) => {
75
- let start = string.substring(0, index) + replace;
76
- let end = string.substring(index + close.length);
77
- let nextIndex = end.indexOf(close);
78
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
76
+ let result = "";
77
+ let cursor = 0;
78
+ do {
79
+ result += string.substring(cursor, index) + replace;
80
+ cursor = index + close.length;
81
+ index = string.indexOf(close, cursor);
82
+ } while (~index);
83
+ return result + string.substring(cursor);
84
+ };
85
+ var createColors = (enabled = isColorSupported) => {
86
+ let init = enabled ? formatter : () => String;
87
+ return {
88
+ isColorSupported: enabled,
89
+ reset: init("\x1B[0m", "\x1B[0m"),
90
+ bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
91
+ dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
92
+ italic: init("\x1B[3m", "\x1B[23m"),
93
+ underline: init("\x1B[4m", "\x1B[24m"),
94
+ inverse: init("\x1B[7m", "\x1B[27m"),
95
+ hidden: init("\x1B[8m", "\x1B[28m"),
96
+ strikethrough: init("\x1B[9m", "\x1B[29m"),
97
+ black: init("\x1B[30m", "\x1B[39m"),
98
+ red: init("\x1B[31m", "\x1B[39m"),
99
+ green: init("\x1B[32m", "\x1B[39m"),
100
+ yellow: init("\x1B[33m", "\x1B[39m"),
101
+ blue: init("\x1B[34m", "\x1B[39m"),
102
+ magenta: init("\x1B[35m", "\x1B[39m"),
103
+ cyan: init("\x1B[36m", "\x1B[39m"),
104
+ white: init("\x1B[37m", "\x1B[39m"),
105
+ gray: init("\x1B[90m", "\x1B[39m"),
106
+ bgBlack: init("\x1B[40m", "\x1B[49m"),
107
+ bgRed: init("\x1B[41m", "\x1B[49m"),
108
+ bgGreen: init("\x1B[42m", "\x1B[49m"),
109
+ bgYellow: init("\x1B[43m", "\x1B[49m"),
110
+ bgBlue: init("\x1B[44m", "\x1B[49m"),
111
+ bgMagenta: init("\x1B[45m", "\x1B[49m"),
112
+ bgCyan: init("\x1B[46m", "\x1B[49m"),
113
+ bgWhite: init("\x1B[47m", "\x1B[49m")
114
+ };
79
115
  };
80
- var createColors = (enabled = isColorSupported) => ({
81
- isColorSupported: enabled,
82
- reset: enabled ? (s) => `\x1B[0m${s}\x1B[0m` : String,
83
- bold: enabled ? formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
84
- dim: enabled ? formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
85
- italic: enabled ? formatter("\x1B[3m", "\x1B[23m") : String,
86
- underline: enabled ? formatter("\x1B[4m", "\x1B[24m") : String,
87
- inverse: enabled ? formatter("\x1B[7m", "\x1B[27m") : String,
88
- hidden: enabled ? formatter("\x1B[8m", "\x1B[28m") : String,
89
- strikethrough: enabled ? formatter("\x1B[9m", "\x1B[29m") : String,
90
- black: enabled ? formatter("\x1B[30m", "\x1B[39m") : String,
91
- red: enabled ? formatter("\x1B[31m", "\x1B[39m") : String,
92
- green: enabled ? formatter("\x1B[32m", "\x1B[39m") : String,
93
- yellow: enabled ? formatter("\x1B[33m", "\x1B[39m") : String,
94
- blue: enabled ? formatter("\x1B[34m", "\x1B[39m") : String,
95
- magenta: enabled ? formatter("\x1B[35m", "\x1B[39m") : String,
96
- cyan: enabled ? formatter("\x1B[36m", "\x1B[39m") : String,
97
- white: enabled ? formatter("\x1B[37m", "\x1B[39m") : String,
98
- gray: enabled ? formatter("\x1B[90m", "\x1B[39m") : String,
99
- bgBlack: enabled ? formatter("\x1B[40m", "\x1B[49m") : String,
100
- bgRed: enabled ? formatter("\x1B[41m", "\x1B[49m") : String,
101
- bgGreen: enabled ? formatter("\x1B[42m", "\x1B[49m") : String,
102
- bgYellow: enabled ? formatter("\x1B[43m", "\x1B[49m") : String,
103
- bgBlue: enabled ? formatter("\x1B[44m", "\x1B[49m") : String,
104
- bgMagenta: enabled ? formatter("\x1B[45m", "\x1B[49m") : String,
105
- bgCyan: enabled ? formatter("\x1B[46m", "\x1B[49m") : String,
106
- bgWhite: enabled ? formatter("\x1B[47m", "\x1B[49m") : String
107
- });
108
116
  module2.exports = createColors();
109
117
  module2.exports.createColors = createColors;
110
118
  }
@@ -6751,7 +6759,7 @@ function getLatestVersion(pkg, isZh6 = true) {
6751
6759
  var import_lazy_js_utils2 = require("lazy-js-utils");
6752
6760
 
6753
6761
  // package.json
6754
- var version = "0.0.87";
6762
+ var version = "0.0.89";
6755
6763
 
6756
6764
  // src/help.ts
6757
6765
  var isZh2 = process.env.PI_Lang === "zh";
@@ -6807,6 +6815,7 @@ async function installDeps() {
6807
6815
 
6808
6816
  // src/pi.ts
6809
6817
  var import_process2 = __toESM(require("process"), 1);
6818
+ var import_console = require("console");
6810
6819
  var import_lazy_js_utils5 = require("lazy-js-utils");
6811
6820
  var import_picocolors4 = __toESM(require_picocolors(), 1);
6812
6821
 
@@ -6887,10 +6896,27 @@ async function pi(params, pkg, executor = "ni") {
6887
6896
  loading_status = await loading(text);
6888
6897
  }
6889
6898
  const runSockets = executor.split(" ")[0] === "npm" ? ` --max-sockets=${maxSockets}` : "";
6890
- const { status, result } = await (0, import_lazy_js_utils5.useNodeWorker)({
6899
+ let { status, result } = await (0, import_lazy_js_utils5.useNodeWorker)({
6891
6900
  params: `${executor}${newParams ? ` ${newParams}` : runSockets}`,
6892
- stdio
6901
+ stdio,
6902
+ errorExit: false
6893
6903
  });
6904
+ if (result.includes("pnpm versions with respective Node.js version support")) {
6905
+ (0, import_console.log)(result);
6906
+ (0, import_console.log)(
6907
+ import_picocolors4.default.yellow(
6908
+ isZh3 ? "\u6B63\u5728\u5C1D\u8BD5\u4F7F\u7528 npm \u518D\u6B21\u6267\u884C..." : "Trying to use npm to run again..."
6909
+ )
6910
+ );
6911
+ const { status: newStatus, result: newResult } = (0, import_lazy_js_utils5.jsShell)(
6912
+ `npm install${newParams ? ` ${newParams}` : runSockets}`,
6913
+ {
6914
+ stdio
6915
+ }
6916
+ );
6917
+ status = newStatus;
6918
+ result = newResult;
6919
+ }
6894
6920
  if (stdio === "inherit")
6895
6921
  loading_status = await loading("");
6896
6922
  const end = Date.now();
package/dist/index.js CHANGED
@@ -62,50 +62,58 @@ var __privateWrapper = (obj, member, setter, getter) => ({
62
62
  }
63
63
  });
64
64
 
65
- // node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js
65
+ // node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
66
66
  var require_picocolors = __commonJS({
67
- "node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports, module) {
68
- var tty2 = __require("tty");
69
- var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
67
+ "node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports, module) {
68
+ var argv = process.argv || [];
69
+ var env2 = process.env;
70
+ var isColorSupported = !("NO_COLOR" in env2 || argv.includes("--no-color")) && ("FORCE_COLOR" in env2 || argv.includes("--color") || process.platform === "win32" || __require != null && __require("tty").isatty(1) && env2.TERM !== "dumb" || "CI" in env2);
70
71
  var formatter = (open, close, replace = open) => (input) => {
71
72
  let string = "" + input;
72
73
  let index = string.indexOf(close, open.length);
73
74
  return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
74
75
  };
75
76
  var replaceClose = (string, close, replace, index) => {
76
- let start = string.substring(0, index) + replace;
77
- let end = string.substring(index + close.length);
78
- let nextIndex = end.indexOf(close);
79
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
77
+ let result = "";
78
+ let cursor = 0;
79
+ do {
80
+ result += string.substring(cursor, index) + replace;
81
+ cursor = index + close.length;
82
+ index = string.indexOf(close, cursor);
83
+ } while (~index);
84
+ return result + string.substring(cursor);
85
+ };
86
+ var createColors = (enabled = isColorSupported) => {
87
+ let init = enabled ? formatter : () => String;
88
+ return {
89
+ isColorSupported: enabled,
90
+ reset: init("\x1B[0m", "\x1B[0m"),
91
+ bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
92
+ dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
93
+ italic: init("\x1B[3m", "\x1B[23m"),
94
+ underline: init("\x1B[4m", "\x1B[24m"),
95
+ inverse: init("\x1B[7m", "\x1B[27m"),
96
+ hidden: init("\x1B[8m", "\x1B[28m"),
97
+ strikethrough: init("\x1B[9m", "\x1B[29m"),
98
+ black: init("\x1B[30m", "\x1B[39m"),
99
+ red: init("\x1B[31m", "\x1B[39m"),
100
+ green: init("\x1B[32m", "\x1B[39m"),
101
+ yellow: init("\x1B[33m", "\x1B[39m"),
102
+ blue: init("\x1B[34m", "\x1B[39m"),
103
+ magenta: init("\x1B[35m", "\x1B[39m"),
104
+ cyan: init("\x1B[36m", "\x1B[39m"),
105
+ white: init("\x1B[37m", "\x1B[39m"),
106
+ gray: init("\x1B[90m", "\x1B[39m"),
107
+ bgBlack: init("\x1B[40m", "\x1B[49m"),
108
+ bgRed: init("\x1B[41m", "\x1B[49m"),
109
+ bgGreen: init("\x1B[42m", "\x1B[49m"),
110
+ bgYellow: init("\x1B[43m", "\x1B[49m"),
111
+ bgBlue: init("\x1B[44m", "\x1B[49m"),
112
+ bgMagenta: init("\x1B[45m", "\x1B[49m"),
113
+ bgCyan: init("\x1B[46m", "\x1B[49m"),
114
+ bgWhite: init("\x1B[47m", "\x1B[49m")
115
+ };
80
116
  };
81
- var createColors = (enabled = isColorSupported) => ({
82
- isColorSupported: enabled,
83
- reset: enabled ? (s) => `\x1B[0m${s}\x1B[0m` : String,
84
- bold: enabled ? formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
85
- dim: enabled ? formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
86
- italic: enabled ? formatter("\x1B[3m", "\x1B[23m") : String,
87
- underline: enabled ? formatter("\x1B[4m", "\x1B[24m") : String,
88
- inverse: enabled ? formatter("\x1B[7m", "\x1B[27m") : String,
89
- hidden: enabled ? formatter("\x1B[8m", "\x1B[28m") : String,
90
- strikethrough: enabled ? formatter("\x1B[9m", "\x1B[29m") : String,
91
- black: enabled ? formatter("\x1B[30m", "\x1B[39m") : String,
92
- red: enabled ? formatter("\x1B[31m", "\x1B[39m") : String,
93
- green: enabled ? formatter("\x1B[32m", "\x1B[39m") : String,
94
- yellow: enabled ? formatter("\x1B[33m", "\x1B[39m") : String,
95
- blue: enabled ? formatter("\x1B[34m", "\x1B[39m") : String,
96
- magenta: enabled ? formatter("\x1B[35m", "\x1B[39m") : String,
97
- cyan: enabled ? formatter("\x1B[36m", "\x1B[39m") : String,
98
- white: enabled ? formatter("\x1B[37m", "\x1B[39m") : String,
99
- gray: enabled ? formatter("\x1B[90m", "\x1B[39m") : String,
100
- bgBlack: enabled ? formatter("\x1B[40m", "\x1B[49m") : String,
101
- bgRed: enabled ? formatter("\x1B[41m", "\x1B[49m") : String,
102
- bgGreen: enabled ? formatter("\x1B[42m", "\x1B[49m") : String,
103
- bgYellow: enabled ? formatter("\x1B[43m", "\x1B[49m") : String,
104
- bgBlue: enabled ? formatter("\x1B[44m", "\x1B[49m") : String,
105
- bgMagenta: enabled ? formatter("\x1B[45m", "\x1B[49m") : String,
106
- bgCyan: enabled ? formatter("\x1B[46m", "\x1B[49m") : String,
107
- bgWhite: enabled ? formatter("\x1B[47m", "\x1B[49m") : String
108
- });
109
117
  module.exports = createColors();
110
118
  module.exports.createColors = createColors;
111
119
  }
@@ -6755,7 +6763,7 @@ function getLatestVersion(pkg, isZh6 = true) {
6755
6763
  import { jsShell as jsShell2 } from "lazy-js-utils";
6756
6764
 
6757
6765
  // package.json
6758
- var version = "0.0.87";
6766
+ var version = "0.0.89";
6759
6767
 
6760
6768
  // src/help.ts
6761
6769
  var isZh2 = process.env.PI_Lang === "zh";
@@ -6812,6 +6820,7 @@ async function installDeps() {
6812
6820
  // src/pi.ts
6813
6821
  var import_picocolors4 = __toESM(require_picocolors(), 1);
6814
6822
  import process9 from "process";
6823
+ import { log } from "console";
6815
6824
  import { getPkgTool as getPkgTool2, jsShell as jsShell5, useNodeWorker } from "lazy-js-utils";
6816
6825
 
6817
6826
  // src/detectNode.ts
@@ -6891,10 +6900,27 @@ async function pi(params, pkg, executor = "ni") {
6891
6900
  loading_status = await loading(text);
6892
6901
  }
6893
6902
  const runSockets = executor.split(" ")[0] === "npm" ? ` --max-sockets=${maxSockets}` : "";
6894
- const { status, result } = await useNodeWorker({
6903
+ let { status, result } = await useNodeWorker({
6895
6904
  params: `${executor}${newParams ? ` ${newParams}` : runSockets}`,
6896
- stdio
6905
+ stdio,
6906
+ errorExit: false
6897
6907
  });
6908
+ if (result.includes("pnpm versions with respective Node.js version support")) {
6909
+ log(result);
6910
+ log(
6911
+ import_picocolors4.default.yellow(
6912
+ isZh3 ? "\u6B63\u5728\u5C1D\u8BD5\u4F7F\u7528 npm \u518D\u6B21\u6267\u884C..." : "Trying to use npm to run again..."
6913
+ )
6914
+ );
6915
+ const { status: newStatus, result: newResult } = jsShell5(
6916
+ `npm install${newParams ? ` ${newParams}` : runSockets}`,
6917
+ {
6918
+ stdio
6919
+ }
6920
+ );
6921
+ status = newStatus;
6922
+ result = newResult;
6923
+ }
6898
6924
  if (stdio === "inherit")
6899
6925
  loading_status = await loading("");
6900
6926
  const end = Date.now();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simon_he/pi",
3
3
  "type": "module",
4
- "version": "0.0.87",
4
+ "version": "0.0.89",
5
5
  "description": "",
6
6
  "author": "Simon He",
7
7
  "license": "MIT",
@@ -65,19 +65,19 @@
65
65
  "typecheck": "tsc --noEmit"
66
66
  },
67
67
  "dependencies": {
68
- "ccommand": "^1.0.57",
68
+ "ccommand": "^1.0.62",
69
69
  "fast-glob": "latest",
70
- "lazy-js-utils": "^0.0.92",
71
- "semver": "^7.6.0"
70
+ "lazy-js-utils": "^0.0.94",
71
+ "semver": "^7.6.2"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@antfu/eslint-config": "^0.34.2",
75
- "@types/node": "^18.19.31",
75
+ "@types/node": "^18.19.39",
76
76
  "bumpp": "^8.2.1",
77
77
  "eslint": "^8.57.0",
78
78
  "lint-staged": "^13.3.0",
79
79
  "ora": "^6.3.1",
80
- "picocolors": "^1.0.0",
80
+ "picocolors": "^1.0.1",
81
81
  "pnpm": "^7.33.7",
82
82
  "prettier": "^2.8.8",
83
83
  "rimraf": "^3.0.2",