@wrongstack/tools 0.306.2 → 0.306.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.
package/dist/install.js CHANGED
@@ -1048,6 +1048,7 @@ function utf8Prefix(text, maxBytes) {
1048
1048
  }
1049
1049
 
1050
1050
  // src/_util.ts
1051
+ import * as fsp2 from "node:fs/promises";
1051
1052
  import * as path3 from "node:path";
1052
1053
  import * as Core from "@wrongstack/core/utils";
1053
1054
  async function detectPackageManager(cwd, stopAt) {
@@ -1114,6 +1115,40 @@ function ensureInsideRoot(absPath, ctx) {
1114
1115
  function safeResolve(input, ctx) {
1115
1116
  return ensureInsideRoot(resolvePath(input, ctx), ctx);
1116
1117
  }
1118
+ async function resolveRealInsideRoot(absPath, ctx) {
1119
+ if (ctx.allowOutsideProjectRoot) return absPath;
1120
+ const realRoots = await Promise.all(
1121
+ allowedRoots(ctx).map((r) => fsp2.realpath(r).catch(() => path3.resolve(r)))
1122
+ );
1123
+ let probe = absPath;
1124
+ const pendingTail = [];
1125
+ for (; ; ) {
1126
+ let real;
1127
+ try {
1128
+ real = await fsp2.realpath(probe);
1129
+ } catch (err) {
1130
+ if (err.code === "ENOENT") {
1131
+ const parent = path3.dirname(probe);
1132
+ if (parent === probe) return absPath;
1133
+ pendingTail.unshift(path3.basename(probe));
1134
+ probe = parent;
1135
+ continue;
1136
+ }
1137
+ throw err;
1138
+ }
1139
+ const candidate = pendingTail.length > 0 ? path3.join(real, ...pendingTail) : real;
1140
+ if (isInsideAny(candidate, realRoots)) {
1141
+ return candidate;
1142
+ }
1143
+ throw new Error(
1144
+ `Path "${absPath}" resolves through a symlink outside project root "${realRoots[0]}"`
1145
+ );
1146
+ }
1147
+ }
1148
+ async function safeResolveReal(input, ctx) {
1149
+ const abs = safeResolve(input, ctx);
1150
+ return await resolveRealInsideRoot(abs, ctx);
1151
+ }
1117
1152
  var COMMAND_OUTPUT_MAX_BYTES = 32768;
1118
1153
  var REPEAT_RUN_THRESHOLD = 3;
1119
1154
  function collapseCarriageReturns(text) {
@@ -3905,7 +3940,7 @@ var installTool = {
3905
3940
  return final;
3906
3941
  },
3907
3942
  async *executeStream(input, ctx, opts) {
3908
- const cwd = input.cwd ? safeResolve(input.cwd, ctx) : ctx.cwd;
3943
+ const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
3909
3944
  if (!input.global) {
3910
3945
  const pkgList2 = input.packages ? Array.isArray(input.packages) ? input.packages : input.packages.split(",").map((p) => p.trim()) : [];
3911
3946
  const bridge = await tryLegacyPackageOperation(
package/dist/json.js CHANGED
@@ -174,8 +174,9 @@ async function resolveRealInsideRoot(absPath, ctx) {
174
174
  }
175
175
  throw err;
176
176
  }
177
- if (isInsideAny(real, realRoots)) {
178
- return pendingTail.length > 0 ? path.join(real, ...pendingTail) : real;
177
+ const candidate = pendingTail.length > 0 ? path.join(real, ...pendingTail) : real;
178
+ if (isInsideAny(candidate, realRoots)) {
179
+ return candidate;
179
180
  }
180
181
  throw new Error(
181
182
  `Path "${absPath}" resolves through a symlink outside project root "${realRoots[0]}"`
@@ -3214,8 +3214,9 @@ async function resolveRealInsideRoot(absPath, ctx) {
3214
3214
  }
3215
3215
  throw err;
3216
3216
  }
3217
- if (isInsideAny(real, realRoots)) {
3218
- return pendingTail.length > 0 ? path5.join(real, ...pendingTail) : real;
3217
+ const candidate = pendingTail.length > 0 ? path5.join(real, ...pendingTail) : real;
3218
+ if (isInsideAny(candidate, realRoots)) {
3219
+ return candidate;
3219
3220
  }
3220
3221
  throw new Error(
3221
3222
  `Path "${absPath}" resolves through a symlink outside project root "${realRoots[0]}"`
package/dist/lint.js CHANGED
@@ -1041,6 +1041,7 @@ function utf8Prefix(text, maxBytes) {
1041
1041
  }
1042
1042
 
1043
1043
  // src/_util.ts
1044
+ import * as fsp2 from "node:fs/promises";
1044
1045
  import * as path3 from "node:path";
1045
1046
  import * as Core from "@wrongstack/core/utils";
1046
1047
  function resolvePath(input, ctx) {
@@ -1064,6 +1065,40 @@ function ensureInsideRoot(absPath, ctx) {
1064
1065
  function safeResolve(input, ctx) {
1065
1066
  return ensureInsideRoot(resolvePath(input, ctx), ctx);
1066
1067
  }
1068
+ async function resolveRealInsideRoot(absPath, ctx) {
1069
+ if (ctx.allowOutsideProjectRoot) return absPath;
1070
+ const realRoots = await Promise.all(
1071
+ allowedRoots(ctx).map((r) => fsp2.realpath(r).catch(() => path3.resolve(r)))
1072
+ );
1073
+ let probe = absPath;
1074
+ const pendingTail = [];
1075
+ for (; ; ) {
1076
+ let real;
1077
+ try {
1078
+ real = await fsp2.realpath(probe);
1079
+ } catch (err) {
1080
+ if (err.code === "ENOENT") {
1081
+ const parent = path3.dirname(probe);
1082
+ if (parent === probe) return absPath;
1083
+ pendingTail.unshift(path3.basename(probe));
1084
+ probe = parent;
1085
+ continue;
1086
+ }
1087
+ throw err;
1088
+ }
1089
+ const candidate = pendingTail.length > 0 ? path3.join(real, ...pendingTail) : real;
1090
+ if (isInsideAny(candidate, realRoots)) {
1091
+ return candidate;
1092
+ }
1093
+ throw new Error(
1094
+ `Path "${absPath}" resolves through a symlink outside project root "${realRoots[0]}"`
1095
+ );
1096
+ }
1097
+ }
1098
+ async function safeResolveReal(input, ctx) {
1099
+ const abs = safeResolve(input, ctx);
1100
+ return await resolveRealInsideRoot(abs, ctx);
1101
+ }
1067
1102
  var COMMAND_OUTPUT_MAX_BYTES = 32768;
1068
1103
  var REPEAT_RUN_THRESHOLD = 3;
1069
1104
  function collapseCarriageReturns(text) {
@@ -3584,7 +3619,7 @@ var lintTool = {
3584
3619
  return final;
3585
3620
  },
3586
3621
  async *executeStream(input, ctx, opts) {
3587
- const cwd = input.cwd ? safeResolve(input.cwd, ctx) : ctx.cwd;
3622
+ const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
3588
3623
  const linter = input.linter ?? "auto";
3589
3624
  if (linter === "auto" && !input.files) {
3590
3625
  const bridge = await tryLegacyCodeOperation("lint", {
package/dist/logs.js CHANGED
@@ -171,8 +171,9 @@ async function resolveRealInsideRoot(absPath, ctx) {
171
171
  }
172
172
  throw err;
173
173
  }
174
- if (isInsideAny(real, realRoots)) {
175
- return pendingTail.length > 0 ? path.join(real, ...pendingTail) : real;
174
+ const candidate = pendingTail.length > 0 ? path.join(real, ...pendingTail) : real;
175
+ if (isInsideAny(candidate, realRoots)) {
176
+ return candidate;
176
177
  }
177
178
  throw new Error(
178
179
  `Path "${absPath}" resolves through a symlink outside project root "${realRoots[0]}"`
@@ -226,7 +227,7 @@ var logsTool = {
226
227
  }
227
228
  },
228
229
  async execute(input, ctx, opts) {
229
- const cwd = input.cwd ? safeResolve(input.cwd, ctx) : ctx.cwd;
230
+ const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
230
231
  const lines = input.lines ?? 100;
231
232
  let filterRe = null;
232
233
  if (input.filter) {
package/dist/outdated.js CHANGED
@@ -102,8 +102,9 @@ async function resolveRealInsideRoot(absPath, ctx) {
102
102
  }
103
103
  throw err;
104
104
  }
105
- if (isInsideAny(real, realRoots)) {
106
- return pendingTail.length > 0 ? path.join(real, ...pendingTail) : real;
105
+ const candidate = pendingTail.length > 0 ? path.join(real, ...pendingTail) : real;
106
+ if (isInsideAny(candidate, realRoots)) {
107
+ return candidate;
107
108
  }
108
109
  throw new Error(
109
110
  `Path "${absPath}" resolves through a symlink outside project root "${realRoots[0]}"`
@@ -5020,7 +5021,7 @@ var outdatedTool = {
5020
5021
  }
5021
5022
  },
5022
5023
  async execute(input, ctx, opts) {
5023
- const cwd = input.cwd ? safeResolve(input.cwd, ctx) : ctx.cwd;
5024
+ const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
5024
5025
  const manager = await detectPackageManager(cwd, ctx.projectRoot);
5025
5026
  if (manager === "npm") {
5026
5027
  try {