@simon_he/pi 0.1.13 → 0.1.15

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
@@ -46,7 +46,7 @@ var import_node_process = __toESM(require("process"), 1);
46
46
  var import_node = require("lazy-js-utils/node");
47
47
 
48
48
  // package.json
49
- var version = "0.1.13";
49
+ var version = "0.1.15";
50
50
 
51
51
  // src/help.ts
52
52
  var isZh = import_node_process.default.env.PI_Lang === "zh";
@@ -298,14 +298,13 @@ async function pi(params, pkg, executor = "ni") {
298
298
  successMsg = pkg ? isZh3 ? `${pkg} \u5B89\u88C5\u6210\u529F! \u{1F60A}` : `Installed ${pkg} successfully! \u{1F60A}` : isZh3 ? "\u4F9D\u8D56\u66F4\u65B0\u6210\u529F! \u{1F60A}" : "Updated dependency successfully! \u{1F60A}";
299
299
  }
300
300
  const failMsg = pkg ? isZh3 ? `${params} \u5B89\u88C5\u5931\u8D25 \u{1F62D}` : `Failed to install ${params} \u{1F62D}` : isZh3 ? "\u4F9D\u8D56\u66F4\u65B0\u5931\u8D25 \u{1F62D}" : "Failed to update dependency \u{1F62D}";
301
- const newParams = isLatest ? params : await getParams(params);
302
301
  const isSilent = import_node_process5.default.env.PI_SILENT === "true";
303
302
  let stdio = isSilent ? "inherit" : ["inherit", "pipe", "inherit"];
304
303
  let loading_status;
305
304
  const { PI_DEFAULT, PI_MaxSockets: sockets } = import_node_process5.default.env;
306
305
  const pkgTool = await (0, import_node6.getPkgTool)();
307
306
  const maxSockets = sockets || 4;
308
- const install = PI_DEFAULT === "yarn" || pkgTool === "yarn" ? newParams ? "add" : "" : "install";
307
+ const install = !params ? "install" : "add";
309
308
  if (pkgTool === "npm") {
310
309
  if (PI_DEFAULT) {
311
310
  executor = `${PI_DEFAULT} ${install}`;
@@ -318,10 +317,11 @@ async function pi(params, pkg, executor = "ni") {
318
317
  executor = `${pkgTool} ${install}`;
319
318
  loading_status = await loading(text, isSilent);
320
319
  }
320
+ const newParams = isLatest ? "" : await getParams(params);
321
321
  const runSockets = executor.split(" ")[0] === "npm" ? ` --max-sockets=${maxSockets}` : "";
322
- console.log(import_picocolors4.default.green(`${executor}${newParams ? ` ${newParams}` : runSockets}`));
322
+ console.log(import_picocolors4.default.green(isLatest ? params.map((p) => `${executor} ${p}`).join(" & ") : `${executor}${newParams ? ` ${newParams}` : runSockets}`));
323
323
  let { status, result } = await (0, import_node6.useNodeWorker)({
324
- params: `${executor}${newParams ? ` ${newParams}` : runSockets}`,
324
+ params: isLatest ? params.map((p) => `${executor} ${p}`).join(" & ") : `${executor}${newParams ? ` ${newParams}` : runSockets}`,
325
325
  stdio,
326
326
  errorExit: false
327
327
  });
@@ -387,9 +387,9 @@ async function pil(params) {
387
387
  const { dependencies = {}, devDependencies = {} } = await (0, import_node7.getPkg)();
388
388
  if (!params) {
389
389
  const deps = [
390
- ...Object.keys(dependencies).map((key) => `${key}: ${dependencies[key]}`),
390
+ ...Object.keys(dependencies).map((key) => `${key}: ${dependencies[key].replace(/([><~])/g, "\\$1")}`),
391
391
  ...Object.keys(devDependencies).map(
392
- (key) => `${key}: ${devDependencies[key]}`
392
+ (key) => `${key}: ${devDependencies[key].replace(/([><~])/g, "\\$1")}`
393
393
  )
394
394
  ];
395
395
  const { result: choose, status } = await (0, import_node7.jsShell)(
@@ -410,14 +410,14 @@ async function pil(params) {
410
410
  const name = i.split(": ")[0];
411
411
  if (name in devDependencies)
412
412
  return `${name}@latest -D`;
413
- return `${name}@latest`;
413
+ return `${name}@latest -S`;
414
414
  });
415
415
  params = names.join(" ");
416
416
  }
417
417
  let latestPkgname = params;
418
- const reg = /\s(-[dw]+)/gi;
418
+ const reg = /\s(-[dws]+)/gi;
419
419
  const suffix = [];
420
- let command = latestPkgname = (await getParams(params)).replace(
420
+ const command = latestPkgname = (await getParams(params)).replace(
421
421
  reg,
422
422
  (_, k) => {
423
423
  suffix.push(k);
@@ -428,8 +428,15 @@ async function pil(params) {
428
428
  const v = dependencies[i] || devDependencies[i];
429
429
  return `${i}$${v}`;
430
430
  }).join(" ");
431
- command = command.replace(/\s+/, " ").split(" ").map((i, index) => `${i} ${suffix[index] || "-s"}`).join(" ");
432
- return await pi(command, latestPkgname.replace(/@latest/g, ""), "pil");
431
+ const group = {};
432
+ const items = command.replace(/\s+/, " ").trim().split(" ").map((i, idx) => [i, suffix[idx] || "-s"]);
433
+ for (const [pkg, flag] of items) {
434
+ if (!group[flag])
435
+ group[flag] = [];
436
+ group[flag].push(pkg);
437
+ }
438
+ const cmds = Object.entries(group).map(([flag, pkgs]) => `${pkgs.join(" ")} ${flag}`);
439
+ return await pi(cmds, latestPkgname.replace(/@latest/g, ""), "pil");
433
440
  }
434
441
 
435
442
  // src/pinit.ts
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ import process from "node:process";
25
25
  import { jsShell } from "lazy-js-utils/node";
26
26
 
27
27
  // package.json
28
- var version = "0.1.13";
28
+ var version = "0.1.15";
29
29
 
30
30
  // src/help.ts
31
31
  var isZh = process.env.PI_Lang === "zh";
@@ -277,14 +277,13 @@ async function pi(params, pkg, executor = "ni") {
277
277
  successMsg = pkg ? isZh3 ? `${pkg} \u5B89\u88C5\u6210\u529F! \u{1F60A}` : `Installed ${pkg} successfully! \u{1F60A}` : isZh3 ? "\u4F9D\u8D56\u66F4\u65B0\u6210\u529F! \u{1F60A}" : "Updated dependency successfully! \u{1F60A}";
278
278
  }
279
279
  const failMsg = pkg ? isZh3 ? `${params} \u5B89\u88C5\u5931\u8D25 \u{1F62D}` : `Failed to install ${params} \u{1F62D}` : isZh3 ? "\u4F9D\u8D56\u66F4\u65B0\u5931\u8D25 \u{1F62D}" : "Failed to update dependency \u{1F62D}";
280
- const newParams = isLatest ? params : await getParams(params);
281
280
  const isSilent = process5.env.PI_SILENT === "true";
282
281
  let stdio = isSilent ? "inherit" : ["inherit", "pipe", "inherit"];
283
282
  let loading_status;
284
283
  const { PI_DEFAULT, PI_MaxSockets: sockets } = process5.env;
285
284
  const pkgTool = await getPkgTool2();
286
285
  const maxSockets = sockets || 4;
287
- const install = PI_DEFAULT === "yarn" || pkgTool === "yarn" ? newParams ? "add" : "" : "install";
286
+ const install = !params ? "install" : "add";
288
287
  if (pkgTool === "npm") {
289
288
  if (PI_DEFAULT) {
290
289
  executor = `${PI_DEFAULT} ${install}`;
@@ -297,10 +296,11 @@ async function pi(params, pkg, executor = "ni") {
297
296
  executor = `${pkgTool} ${install}`;
298
297
  loading_status = await loading(text, isSilent);
299
298
  }
299
+ const newParams = isLatest ? "" : await getParams(params);
300
300
  const runSockets = executor.split(" ")[0] === "npm" ? ` --max-sockets=${maxSockets}` : "";
301
- console.log(colors3.green(`${executor}${newParams ? ` ${newParams}` : runSockets}`));
301
+ console.log(colors3.green(isLatest ? params.map((p) => `${executor} ${p}`).join(" & ") : `${executor}${newParams ? ` ${newParams}` : runSockets}`));
302
302
  let { status, result } = await useNodeWorker({
303
- params: `${executor}${newParams ? ` ${newParams}` : runSockets}`,
303
+ params: isLatest ? params.map((p) => `${executor} ${p}`).join(" & ") : `${executor}${newParams ? ` ${newParams}` : runSockets}`,
304
304
  stdio,
305
305
  errorExit: false
306
306
  });
@@ -366,9 +366,9 @@ async function pil(params) {
366
366
  const { dependencies = {}, devDependencies = {} } = await getPkg3();
367
367
  if (!params) {
368
368
  const deps = [
369
- ...Object.keys(dependencies).map((key) => `${key}: ${dependencies[key]}`),
369
+ ...Object.keys(dependencies).map((key) => `${key}: ${dependencies[key].replace(/([><~])/g, "\\$1")}`),
370
370
  ...Object.keys(devDependencies).map(
371
- (key) => `${key}: ${devDependencies[key]}`
371
+ (key) => `${key}: ${devDependencies[key].replace(/([><~])/g, "\\$1")}`
372
372
  )
373
373
  ];
374
374
  const { result: choose, status } = await jsShell7(
@@ -389,14 +389,14 @@ async function pil(params) {
389
389
  const name = i.split(": ")[0];
390
390
  if (name in devDependencies)
391
391
  return `${name}@latest -D`;
392
- return `${name}@latest`;
392
+ return `${name}@latest -S`;
393
393
  });
394
394
  params = names.join(" ");
395
395
  }
396
396
  let latestPkgname = params;
397
- const reg = /\s(-[dw]+)/gi;
397
+ const reg = /\s(-[dws]+)/gi;
398
398
  const suffix = [];
399
- let command = latestPkgname = (await getParams(params)).replace(
399
+ const command = latestPkgname = (await getParams(params)).replace(
400
400
  reg,
401
401
  (_, k) => {
402
402
  suffix.push(k);
@@ -407,8 +407,15 @@ async function pil(params) {
407
407
  const v = dependencies[i] || devDependencies[i];
408
408
  return `${i}$${v}`;
409
409
  }).join(" ");
410
- command = command.replace(/\s+/, " ").split(" ").map((i, index) => `${i} ${suffix[index] || "-s"}`).join(" ");
411
- return await pi(command, latestPkgname.replace(/@latest/g, ""), "pil");
410
+ const group = {};
411
+ const items = command.replace(/\s+/, " ").trim().split(" ").map((i, idx) => [i, suffix[idx] || "-s"]);
412
+ for (const [pkg, flag] of items) {
413
+ if (!group[flag])
414
+ group[flag] = [];
415
+ group[flag].push(pkg);
416
+ }
417
+ const cmds = Object.entries(group).map(([flag, pkgs]) => `${pkgs.join(" ")} ${flag}`);
418
+ return await pi(cmds, latestPkgname.replace(/@latest/g, ""), "pil");
412
419
  }
413
420
 
414
421
  // src/pinit.ts
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@simon_he/pi",
3
3
  "type": "module",
4
- "version": "0.1.13",
5
- "packageManager": "pnpm@10.8.0",
4
+ "version": "0.1.15",
5
+ "packageManager": "pnpm@10.10.0",
6
6
  "description": "An intelligent cross-platform package manager and CLI tool that autodetects project environments (Node.mjs, Go, Rust, Python) with beautiful loading animations and smart command execution.",
7
7
  "author": {
8
8
  "name": "Simon He",
@@ -92,22 +92,22 @@
92
92
  "dependencies": {
93
93
  "ccommand": "^1.0.84",
94
94
  "fast-glob": "^3.3.3",
95
- "lazy-js-utils": "^0.1.39",
95
+ "lazy-js-utils": "^0.1.43",
96
96
  "ora": "^8.2.0",
97
97
  "picocolors": "^1.1.1",
98
98
  "semver": "^7.7.1"
99
99
  },
100
100
  "devDependencies": {
101
- "@antfu/eslint-config": "^4.11.0",
102
- "@types/node": "^22.14.0",
101
+ "@antfu/eslint-config": "^4.12.0",
102
+ "@types/node": "^22.15.3",
103
103
  "bumpp": "^10.1.0",
104
- "eslint": "^9.24.0",
104
+ "eslint": "^9.25.1",
105
105
  "lint-staged": "^13.3.0",
106
106
  "prettier": "^2.8.8",
107
107
  "tsup": "^8.4.0",
108
- "tsx": "^4.19.3",
108
+ "tsx": "^4.19.4",
109
109
  "typescript": "^5.8.3",
110
- "vitest": "^3.1.1"
110
+ "vitest": "^3.1.2"
111
111
  },
112
112
  "lint-staged": {
113
113
  "*.{vue,js,ts,jsx,tsx,md,json}": "eslint . --fix"