@simon_he/pi 0.1.18 → 0.1.19

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.18";
49
+ var version = "0.1.19";
50
50
 
51
51
  // src/help.ts
52
52
  var isZh = import_node_process.default.env.PI_Lang === "zh";
@@ -218,6 +218,8 @@ async function getParams(params) {
218
218
  return params.replace(W, "");
219
219
  if (w.test(params))
220
220
  return params.replace(w, "");
221
+ if (d.test(params))
222
+ return params.replace(d, " -D");
221
223
  }
222
224
  if ((await (0, import_node5.getPkg)())?.workspaces) {
223
225
  if (D.test(params))
@@ -231,10 +233,10 @@ async function getParams(params) {
231
233
  if (Dw.test(params))
232
234
  return params.replace(Dw, " -DW");
233
235
  if (W.test(params))
234
- return params.replace(w, " -W");
236
+ return params.replace(W, " -W");
235
237
  return params;
236
238
  default:
237
- return params;
239
+ return d.test(params) ? params.replace(d, " -D") : params;
238
240
  }
239
241
  } catch {
240
242
  console.log(
@@ -434,16 +436,45 @@ async function pil(params) {
434
436
  const v = dependencies[i] || devDependencies[i];
435
437
  return `${i}$${v}`;
436
438
  }).join(" ");
437
- const group = {};
438
- const items = command.replace(/\s+/, " ").trim().split(" ").map((i, idx) => [i, suffix[idx] || "-s"]);
439
- for (const [pkg, flag] of items) {
440
- if (!group[flag])
441
- group[flag] = [];
442
- group[flag].push(pkg);
439
+ const tokens = command.replace(/\s+/, " ").trim().split(" ").filter(Boolean);
440
+ const pkgs = tokens.filter((t) => !t.startsWith("-"));
441
+ let globalWorkspaceFlag = null;
442
+ const perFlags = [];
443
+ let assignIdx = 0;
444
+ for (const f of suffix) {
445
+ if (/^-(?:w|W)$/.test(f)) {
446
+ globalWorkspaceFlag = f;
447
+ continue;
448
+ }
449
+ perFlags[assignIdx++] = f;
443
450
  }
444
- const cmds = Object.entries(group).map(
445
- ([flag, pkgs]) => `${pkgs.join(" ")} ${flag}`
446
- );
451
+ const normalizeFlag = (f) => {
452
+ if (!f)
453
+ return "";
454
+ if (/^-s$/i.test(f) || /^-S$/.test(f))
455
+ return "";
456
+ return f;
457
+ };
458
+ const combineWorkspace = (f, w2) => {
459
+ if (!w2)
460
+ return f;
461
+ if (/w/i.test(f))
462
+ return f;
463
+ if (!f)
464
+ return w2;
465
+ if (/d/i.test(f))
466
+ return `-D${w2.slice(1)}`;
467
+ return w2;
468
+ };
469
+ const finalFlags = pkgs.map((_, i) => combineWorkspace(normalizeFlag(perFlags[i]), globalWorkspaceFlag));
470
+ const group = {};
471
+ pkgs.forEach((p, i) => {
472
+ const key = finalFlags[i] || "";
473
+ if (!group[key])
474
+ group[key] = [];
475
+ group[key].push(p);
476
+ });
477
+ const cmds = Object.entries(group).map(([flag, list]) => `${list.join(" ")}${flag ? ` ${flag}` : ""}`);
447
478
  return await pi(cmds, latestPkgname.replace(/@latest/g, ""), "pil");
448
479
  }
449
480
 
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ import process from "process";
25
25
  import { jsShell } from "lazy-js-utils/node";
26
26
 
27
27
  // package.json
28
- var version = "0.1.18";
28
+ var version = "0.1.19";
29
29
 
30
30
  // src/help.ts
31
31
  var isZh = process.env.PI_Lang === "zh";
@@ -197,6 +197,8 @@ async function getParams(params) {
197
197
  return params.replace(W, "");
198
198
  if (w.test(params))
199
199
  return params.replace(w, "");
200
+ if (d.test(params))
201
+ return params.replace(d, " -D");
200
202
  }
201
203
  if ((await getPkg2())?.workspaces) {
202
204
  if (D.test(params))
@@ -210,10 +212,10 @@ async function getParams(params) {
210
212
  if (Dw.test(params))
211
213
  return params.replace(Dw, " -DW");
212
214
  if (W.test(params))
213
- return params.replace(w, " -W");
215
+ return params.replace(W, " -W");
214
216
  return params;
215
217
  default:
216
- return params;
218
+ return d.test(params) ? params.replace(d, " -D") : params;
217
219
  }
218
220
  } catch {
219
221
  console.log(
@@ -413,16 +415,45 @@ async function pil(params) {
413
415
  const v = dependencies[i] || devDependencies[i];
414
416
  return `${i}$${v}`;
415
417
  }).join(" ");
416
- const group = {};
417
- const items = command.replace(/\s+/, " ").trim().split(" ").map((i, idx) => [i, suffix[idx] || "-s"]);
418
- for (const [pkg, flag] of items) {
419
- if (!group[flag])
420
- group[flag] = [];
421
- group[flag].push(pkg);
418
+ const tokens = command.replace(/\s+/, " ").trim().split(" ").filter(Boolean);
419
+ const pkgs = tokens.filter((t) => !t.startsWith("-"));
420
+ let globalWorkspaceFlag = null;
421
+ const perFlags = [];
422
+ let assignIdx = 0;
423
+ for (const f of suffix) {
424
+ if (/^-(?:w|W)$/.test(f)) {
425
+ globalWorkspaceFlag = f;
426
+ continue;
427
+ }
428
+ perFlags[assignIdx++] = f;
422
429
  }
423
- const cmds = Object.entries(group).map(
424
- ([flag, pkgs]) => `${pkgs.join(" ")} ${flag}`
425
- );
430
+ const normalizeFlag = (f) => {
431
+ if (!f)
432
+ return "";
433
+ if (/^-s$/i.test(f) || /^-S$/.test(f))
434
+ return "";
435
+ return f;
436
+ };
437
+ const combineWorkspace = (f, w2) => {
438
+ if (!w2)
439
+ return f;
440
+ if (/w/i.test(f))
441
+ return f;
442
+ if (!f)
443
+ return w2;
444
+ if (/d/i.test(f))
445
+ return `-D${w2.slice(1)}`;
446
+ return w2;
447
+ };
448
+ const finalFlags = pkgs.map((_, i) => combineWorkspace(normalizeFlag(perFlags[i]), globalWorkspaceFlag));
449
+ const group = {};
450
+ pkgs.forEach((p, i) => {
451
+ const key = finalFlags[i] || "";
452
+ if (!group[key])
453
+ group[key] = [];
454
+ group[key].push(p);
455
+ });
456
+ const cmds = Object.entries(group).map(([flag, list]) => `${list.join(" ")}${flag ? ` ${flag}` : ""}`);
426
457
  return await pi(cmds, latestPkgname.replace(/@latest/g, ""), "pil");
427
458
  }
428
459
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@simon_he/pi",
3
3
  "type": "module",
4
- "version": "0.1.18",
5
- "packageManager": "pnpm@10.15.1",
4
+ "version": "0.1.19",
5
+ "packageManager": "pnpm@10.18.1",
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",