@reddoorla/maintenance 0.54.2 → 0.54.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/cli/bin.js CHANGED
@@ -3621,11 +3621,15 @@ async function browserAudit(ctx) {
3621
3621
  await runner.close?.();
3622
3622
  }
3623
3623
  }
3624
+ var FETCH_TIMEOUT_MS = 1e4;
3624
3625
  function defaultDiscoverDeps() {
3625
3626
  return {
3626
3627
  fetchText: async (url) => {
3627
3628
  try {
3628
- const res = await fetch(url, { redirect: "follow" });
3629
+ const res = await fetch(url, {
3630
+ redirect: "follow",
3631
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
3632
+ });
3629
3633
  if (!res.ok) return null;
3630
3634
  return await res.text();
3631
3635
  } catch {
@@ -3726,9 +3730,17 @@ async function defaultBrowserRunner() {
3726
3730
  for (const url of urls) {
3727
3731
  let status;
3728
3732
  try {
3729
- let res = await fetch(url, { method: "HEAD", redirect: "follow" });
3733
+ let res = await fetch(url, {
3734
+ method: "HEAD",
3735
+ redirect: "follow",
3736
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
3737
+ });
3730
3738
  if (res.status === 405 || res.status === 501) {
3731
- res = await fetch(url, { method: "GET", redirect: "follow" });
3739
+ res = await fetch(url, {
3740
+ method: "GET",
3741
+ redirect: "follow",
3742
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
3743
+ });
3732
3744
  }
3733
3745
  status = res.status;
3734
3746
  } catch {
@@ -3846,6 +3858,20 @@ function fromJsonFile(path) {
3846
3858
  }
3847
3859
 
3848
3860
  // src/cli/fleet/resolve-sites.ts
3861
+ init_url();
3862
+ function sanitizeDynamicSites(sites) {
3863
+ return sites.map((s) => {
3864
+ if (s.deployedUrl !== void 0 && !isHttpUrl(s.deployedUrl)) {
3865
+ console.warn(
3866
+ `[inventory] dynamic inventory: ignoring deployedUrl that is not http(s) for ${s.name ?? s.path}: ${JSON.stringify(s.deployedUrl)}`
3867
+ );
3868
+ const copy = { ...s };
3869
+ delete copy.deployedUrl;
3870
+ return copy;
3871
+ }
3872
+ return s;
3873
+ });
3874
+ }
3849
3875
  async function resolveSites(input) {
3850
3876
  if (input.site && input.fleet) {
3851
3877
  throw Object.assign(new Error("cannot combine a positional [site] with --fleet"), {
@@ -3862,24 +3888,22 @@ async function resolveSites(input) {
3862
3888
  if (input.fleet) {
3863
3889
  const fleetPath = resolve(input.cwd, input.fleet);
3864
3890
  const ext = extname(fleetPath).toLowerCase();
3865
- let provider;
3866
3891
  if (ext === ".json") {
3867
- provider = fromJsonFile(fleetPath);
3868
- } else if (ext === ".js" || ext === ".mjs" || ext === ".cjs") {
3892
+ return fromJsonFile(fleetPath)();
3893
+ }
3894
+ if (ext === ".js" || ext === ".mjs" || ext === ".cjs") {
3869
3895
  const mod = await import(pathToFileURL(fleetPath).href);
3870
3896
  if (!mod.default || typeof mod.default !== "function") {
3871
3897
  throw Object.assign(new Error(`--fleet ${input.fleet}: default export is not a function`), {
3872
3898
  exitCode: 2
3873
3899
  });
3874
3900
  }
3875
- provider = mod.default;
3876
- } else {
3877
- throw Object.assign(
3878
- new Error(`--fleet ${input.fleet}: unsupported extension ${ext || "(none)"}`),
3879
- { exitCode: 2 }
3880
- );
3901
+ return sanitizeDynamicSites(await mod.default());
3881
3902
  }
3882
- return provider();
3903
+ throw Object.assign(
3904
+ new Error(`--fleet ${input.fleet}: unsupported extension ${ext || "(none)"}`),
3905
+ { exitCode: 2 }
3906
+ );
3883
3907
  }
3884
3908
  return localPath(resolve(input.cwd, input.site ?? input.cwd))();
3885
3909
  }