@absolutejs/absolute 0.19.0-beta.1036 → 0.19.0-beta.1038

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/index.js CHANGED
@@ -170805,8 +170805,35 @@ var exports_build = {};
170805
170805
  __export(exports_build, {
170806
170806
  build: () => build
170807
170807
  });
170808
- import { resolve as resolve10 } from "path";
170809
- var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, tryImportBuild2 = async (candidate) => {
170808
+ import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync13 } from "fs";
170809
+ import { join as join12, resolve as resolve10 } from "path";
170810
+ var PROFILE_TOP = 15, PROFILE_COL = 8, FRAMEWORK_KEYS, cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, printProfile = (buildDir) => {
170811
+ const traceDir = join12(buildDir, ".absolute-trace");
170812
+ if (!existsSync10(traceDir))
170813
+ return;
170814
+ const files = readdirSync3(traceDir).filter((file) => file.endsWith(".json")).sort();
170815
+ const latest = files[files.length - 1];
170816
+ if (latest === undefined)
170817
+ return;
170818
+ const trace = JSON.parse(readFileSync13(join12(traceDir, latest), "utf-8"));
170819
+ const events = Array.isArray(trace.events) ? trace.events : [];
170820
+ if (events.length === 0)
170821
+ return;
170822
+ const slowest = [...events].sort((left, right) => right.durationMs - left.durationMs).slice(0, PROFILE_TOP);
170823
+ const byFramework = FRAMEWORK_KEYS.map((key) => ({
170824
+ ms: events.filter((event) => event.name.includes(key)).reduce((total, event) => total + event.durationMs, 0),
170825
+ name: key
170826
+ })).filter((entry) => entry.ms > 0);
170827
+ const lines = [
170828
+ `
170829
+ \x1B[1mbuild profile\x1B[0m \x1B[2m\xB7 slowest phases\x1B[0m`,
170830
+ ...slowest.map((event) => ` \x1B[2m${getDurationString(event.durationMs).padStart(PROFILE_COL)}\x1B[0m ${event.name}`),
170831
+ `
170832
+ \x1B[2mby framework: ${byFramework.map((entry) => `${entry.name} ${getDurationString(entry.ms)}`).join(" \xB7 ")}\x1B[0m`
170833
+ ];
170834
+ console.log(lines.join(`
170835
+ `));
170836
+ }, tryImportBuild2 = async (candidate) => {
170810
170837
  try {
170811
170838
  const mod = await import(candidate);
170812
170839
  const buildFn = mod.build;
@@ -170824,9 +170851,11 @@ var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
170824
170851
  return mod;
170825
170852
  }
170826
170853
  return resolveBuildModule2(remaining);
170827
- }, build = async (outdir, configPath2) => {
170854
+ }, build = async (outdir, configPath2, profile = false) => {
170828
170855
  const resolvedOutdir = resolve10(outdir ?? "build");
170829
170856
  const buildStart = performance.now();
170857
+ if (profile)
170858
+ process.env.ABSOLUTE_BUILD_TRACE = "1";
170830
170859
  process.stdout.write(cliTag3("\x1B[36m", "Building assets"));
170831
170860
  const buildConfig = await loadConfig(configPath2);
170832
170861
  buildConfig.buildDirectory = resolvedOutdir;
@@ -170851,18 +170880,21 @@ var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
170851
170880
  durationMs: Math.round(performance.now() - buildStart)
170852
170881
  });
170853
170882
  console.log(` \x1B[2m(${getDurationString(performance.now() - buildStart)})\x1B[0m`);
170883
+ if (profile)
170884
+ printProfile(resolvedOutdir);
170854
170885
  };
170855
170886
  var init_build = __esm(() => {
170856
170887
  init_getDurationString();
170857
170888
  init_loadConfig();
170858
170889
  init_startupBanner();
170859
170890
  init_telemetryEvent();
170891
+ FRAMEWORK_KEYS = ["react", "vue", "svelte", "angular", "html", "htmx"];
170860
170892
  });
170861
170893
 
170862
170894
  // src/build/scanConventions.ts
170863
170895
  import { basename as basename4 } from "path";
170864
170896
  var {Glob: Glob2 } = globalThis.Bun;
170865
- import { existsSync as existsSync10 } from "fs";
170897
+ import { existsSync as existsSync11 } from "fs";
170866
170898
  var CONVENTION_RE, classifyFile = (file, pageFiles, defaults, pages) => {
170867
170899
  const fileName = basename4(file);
170868
170900
  const match = CONVENTION_RE.exec(fileName);
@@ -170887,7 +170919,7 @@ var CONVENTION_RE, classifyFile = (file, pageFiles, defaults, pages) => {
170887
170919
  else if (kind === "loading")
170888
170920
  pages[pageName].loading = file;
170889
170921
  }, scanConventions = async (pagesDir, pattern) => {
170890
- if (!existsSync10(pagesDir)) {
170922
+ if (!existsSync11(pagesDir)) {
170891
170923
  const pageFiles2 = [];
170892
170924
  return { conventions: undefined, pageFiles: pageFiles2 };
170893
170925
  }
@@ -170922,8 +170954,8 @@ var exports_ls = {};
170922
170954
  __export(exports_ls, {
170923
170955
  runLs: () => runLs
170924
170956
  });
170925
- import { existsSync as existsSync11, readFileSync as readFileSync13, statSync } from "fs";
170926
- import { basename as basename5, extname as extname2, join as join12, relative as relative2 } from "path";
170957
+ import { existsSync as existsSync12, readFileSync as readFileSync14, statSync } from "fs";
170958
+ import { basename as basename5, extname as extname2, join as join13, relative as relative2 } from "path";
170927
170959
  var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELDS, readStringField = (source, key) => {
170928
170960
  const value = Reflect.get(source, key);
170929
170961
  return typeof value === "string" ? value : undefined;
@@ -170945,13 +170977,13 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
170945
170977
  const dir = readStringField(source, framework.field);
170946
170978
  return dir === undefined ? [] : [
170947
170979
  {
170948
- dir: join12(baseDir, dir),
170980
+ dir: join13(baseDir, dir),
170949
170981
  label: framework.label,
170950
170982
  pattern: framework.pattern
170951
170983
  }
170952
170984
  ];
170953
170985
  }), scanFramework = async (spec) => {
170954
- const { pageFiles } = await scanConventions(join12(spec.dir, "pages"), spec.pattern);
170986
+ const { pageFiles } = await scanConventions(join13(spec.dir, "pages"), spec.pattern);
170955
170987
  if (pageFiles.length === 0)
170956
170988
  return null;
170957
170989
  const pages = pageFiles.map((file) => ({
@@ -170973,12 +171005,12 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
170973
171005
  return pages ? [{ label, pages: sortPages(pages) }] : [];
170974
171006
  });
170975
171007
  }, resolveDiskPath = (buildDir, value) => {
170976
- if (existsSync11(value))
171008
+ if (existsSync12(value))
170977
171009
  return value;
170978
- const underBuild = join12(buildDir, value);
170979
- if (existsSync11(underBuild))
171010
+ const underBuild = join13(buildDir, value);
171011
+ if (existsSync12(underBuild))
170980
171012
  return underBuild;
170981
- return join12(process.cwd(), value);
171013
+ return join13(process.cwd(), value);
170982
171014
  }, fileSize = (diskPath) => {
170983
171015
  try {
170984
171016
  return statSync(diskPath).size;
@@ -170986,7 +171018,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
170986
171018
  return 0;
170987
171019
  }
170988
171020
  }, readManifestSizes = (manifestDir) => {
170989
- const manifest = JSON.parse(readFileSync13(join12(manifestDir, "manifest.json"), "utf-8"));
171021
+ const manifest = JSON.parse(readFileSync14(join13(manifestDir, "manifest.json"), "utf-8"));
170990
171022
  const sizes = new Map;
170991
171023
  Object.entries(manifest).forEach(([key, value]) => {
170992
171024
  sizes.set(key, fileSize(resolveDiskPath(manifestDir, value)));
@@ -171005,7 +171037,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
171005
171037
  }))
171006
171038
  })), manifestAge = (manifestPath) => getDurationString(Date.now() - statSync(manifestPath).mtimeMs), firstBuildDir = (candidates) => candidates.map((candidate) => {
171007
171039
  const dir = readStringField(candidate.source, "buildDirectory");
171008
- return dir === undefined ? undefined : join12(candidate.baseDir, dir);
171040
+ return dir === undefined ? undefined : join13(candidate.baseDir, dir);
171009
171041
  }).find((dir) => dir !== undefined), resolveSizesDir = (args, candidates) => parseFlagValue(args, "--outdir") ?? firstBuildDir(candidates) ?? DEFAULT_BUILD_DIR, formatSize = (bytes) => {
171010
171042
  if (bytes === null || bytes === 0)
171011
171043
  return "-";
@@ -171057,6 +171089,25 @@ ${colors.dim}${frameworkCount} ${frameworkCount === 1 ? "framework" : "framework
171057
171089
  }, printDim = (message) => {
171058
171090
  process.stdout.write(`${colors.dim}${message}${colors.reset}
171059
171091
  `);
171092
+ }, SIZE_UNITS, parseBudget = (args) => {
171093
+ const value = parseFlagValue(args, "--budget");
171094
+ if (value === undefined)
171095
+ return null;
171096
+ const match = value.toLowerCase().match(/^([\d.]+)\s*(gb|mb|kb|b)?$/);
171097
+ const amount = match ? Number(match[1]) : NaN;
171098
+ if (!Number.isFinite(amount))
171099
+ return null;
171100
+ return amount * (SIZE_UNITS[match?.[2] ?? "b"] ?? 1);
171101
+ }, reportBudget = (groups, budget) => {
171102
+ const over = groups.flatMap((group) => group.pages).filter((page) => (page.sizeBytes ?? 0) > budget);
171103
+ if (over.length === 0) {
171104
+ printDim(`\u2713 all pages within ${formatSize(budget)} budget`);
171105
+ return;
171106
+ }
171107
+ over.forEach((page) => process.stdout.write(` ${colors.red}\u2717 ${page.name} ${formatSize(page.sizeBytes)} > ${formatSize(budget)}${colors.reset}
171108
+ `));
171109
+ printDim(`${over.length} page${over.length === 1 ? "" : "s"} over budget`);
171110
+ process.exitCode = 1;
171060
171111
  }, guardBrokenPipe = () => {
171061
171112
  process.stdout.on("error", (error) => {
171062
171113
  if (error instanceof Error && "code" in error && error.code === "EPIPE") {
@@ -171084,14 +171135,17 @@ ${colors.dim}${frameworkCount} ${frameworkCount === 1 ? "framework" : "framework
171084
171135
  return;
171085
171136
  }
171086
171137
  const sizesDir = resolveSizesDir(args, candidates);
171087
- const manifestPath = join12(sizesDir, "manifest.json");
171088
- if (!existsSync11(manifestPath)) {
171138
+ const manifestPath = join13(sizesDir, "manifest.json");
171139
+ if (!existsSync12(manifestPath)) {
171089
171140
  printDim(`No build at ${relativeOrSelf(manifestPath)}. Run \`absolute build\` first, or pass \`--outdir <dir>\`.`);
171090
171141
  return;
171091
171142
  }
171092
171143
  const sized = withSizes(groups, pageSizer(readManifestSizes(sizesDir)));
171093
171144
  const note = `${relativeOrSelf(manifestPath)} \xB7 built ${manifestAge(manifestPath)} ago`;
171094
171145
  emit(sized, true, note, wantsJson);
171146
+ const budget = parseBudget(args);
171147
+ if (budget !== null && !wantsJson)
171148
+ reportBudget(sized, budget);
171095
171149
  };
171096
171150
  var init_ls = __esm(() => {
171097
171151
  init_scanConventions();
@@ -171117,6 +171171,12 @@ var init_ls = __esm(() => {
171117
171171
  { field: "htmlDirectory", label: "HTML", pattern: "*.html" },
171118
171172
  { field: "htmxDirectory", label: "HTMX", pattern: "*.html" }
171119
171173
  ];
171174
+ SIZE_UNITS = {
171175
+ b: 1,
171176
+ gb: BYTES_PER_KILOBYTE * BYTES_PER_KILOBYTE * BYTES_PER_KILOBYTE,
171177
+ kb: BYTES_PER_KILOBYTE,
171178
+ mb: BYTES_PER_KILOBYTE * BYTES_PER_KILOBYTE
171179
+ };
171120
171180
  });
171121
171181
 
171122
171182
  // src/utils/formatBytes.ts
@@ -171986,9 +172046,360 @@ var init_mem = __esm(() => {
171986
172046
  HEADERS = ["NAME", "SOURCE", "PORT", "RSS", "% SYS"];
171987
172047
  });
171988
172048
 
172049
+ // src/cli/scripts/env.ts
172050
+ var exports_env = {};
172051
+ __export(exports_env, {
172052
+ scanEnvUsage: () => scanEnvUsage,
172053
+ runEnv: () => runEnv,
172054
+ collectEnvVars: () => collectEnvVars
172055
+ });
172056
+ import { existsSync as existsSync13, readFileSync as readFileSync15 } from "fs";
172057
+ import { join as join14 } from "path";
172058
+ var {env: env3, Glob: Glob3 } = globalThis.Bun;
172059
+ var EXTENSIONS = "ts,tsx,js,jsx,mjs,cjs,svelte,vue", STATUS_WIDTH, keysInFile = (text) => [...text.matchAll(/getEnv\(\s*['"]([^'"]+)['"]\s*\)/g)].map((match) => match[1]).filter((key) => key !== undefined), scanPatterns = () => existsSync13(join14(process.cwd(), "src")) ? [`src/**/*.{${EXTENSIONS}}`] : [`*.{${EXTENSIONS}}`], scanEnvUsage = async () => {
172060
+ const scans = scanPatterns().map((pattern) => Array.fromAsync(new Glob3(pattern).scan({ cwd: process.cwd() })));
172061
+ const files = (await Promise.all(scans)).flat();
172062
+ const usage = new Map;
172063
+ files.forEach((file) => {
172064
+ keysInFile(readFileSync15(file, "utf-8")).forEach((key) => {
172065
+ usage.set(key, [...usage.get(key) ?? [], file]);
172066
+ });
172067
+ });
172068
+ return usage;
172069
+ }, isSet = (key) => typeof env3[key] === "string" && env3[key] !== "", collectEnvVars = async () => {
172070
+ const usage = await scanEnvUsage();
172071
+ return [...usage.keys()].sort().map((key) => ({
172072
+ files: usage.get(key) ?? [],
172073
+ key,
172074
+ set: isSet(key)
172075
+ }));
172076
+ }, printTable = (vars) => {
172077
+ const keyWidth = Math.max(...vars.map((entry) => entry.key.length));
172078
+ const lines = vars.map((entry) => {
172079
+ const mark = entry.set ? `${colors.green}\u2713${colors.reset}` : `${colors.red}\u2717${colors.reset}`;
172080
+ const status2 = entry.set ? "set" : `${colors.red}missing${colors.reset}`;
172081
+ const count = `${colors.dim}${entry.files.length} file${entry.files.length === 1 ? "" : "s"}${colors.reset}`;
172082
+ return ` ${mark} ${padLine(entry.key, keyWidth)}${" ".repeat(LIST_TUI_COLUMN_GAP)}${padLine(status2, STATUS_WIDTH)}${" ".repeat(LIST_TUI_COLUMN_GAP)}${count}`;
172083
+ });
172084
+ process.stdout.write(`${lines.join(`
172085
+ `)}
172086
+ `);
172087
+ }, runEnv = async (args) => {
172088
+ const vars = await collectEnvVars();
172089
+ if (vars.length === 0) {
172090
+ process.stdout.write(`${colors.dim}No getEnv() usage found under src/.${colors.reset}
172091
+ `);
172092
+ return;
172093
+ }
172094
+ const missing = vars.filter((entry) => !entry.set);
172095
+ if (args.includes("--json")) {
172096
+ process.stdout.write(`${JSON.stringify({ missing, vars }, null, 2)}
172097
+ `);
172098
+ return;
172099
+ }
172100
+ printTable(vars);
172101
+ const summary = missing.length === 0 ? `${colors.green}all ${vars.length} set${colors.reset}` : `${colors.red}${missing.length} missing${colors.reset}`;
172102
+ process.stdout.write(`
172103
+ ${colors.dim}${vars.length} referenced \xB7 ${colors.reset}${summary}
172104
+ `);
172105
+ if (args.includes("--check") && missing.length > 0) {
172106
+ process.exitCode = 1;
172107
+ }
172108
+ };
172109
+ var init_env = __esm(() => {
172110
+ init_constants();
172111
+ init_tuiPrimitives();
172112
+ STATUS_WIDTH = "missing".length;
172113
+ });
172114
+
172115
+ // src/cli/scripts/logs.ts
172116
+ var exports_logs = {};
172117
+ __export(exports_logs, {
172118
+ runLogs: () => runLogs
172119
+ });
172120
+ import {
172121
+ closeSync as closeSync2,
172122
+ existsSync as existsSync14,
172123
+ openSync as openSync4,
172124
+ readSync as readSync2,
172125
+ statSync as statSync2,
172126
+ watchFile
172127
+ } from "fs";
172128
+ var DEFAULT_LINES = 40, POLL_MS = 250, LINES_FLAG_SPAN = 2, readFrom = (path, start2, length) => {
172129
+ if (length <= 0)
172130
+ return "";
172131
+ const descriptor = openSync4(path, "r");
172132
+ try {
172133
+ const buffer = Buffer.alloc(length);
172134
+ readSync2(descriptor, buffer, 0, length, start2);
172135
+ return buffer.toString("utf-8");
172136
+ } finally {
172137
+ closeSync2(descriptor);
172138
+ }
172139
+ }, tailLines = (path, maxLines) => {
172140
+ const { size } = statSync2(path);
172141
+ const start2 = Math.max(0, size - LIST_LOG_TAIL_MAX_BYTES);
172142
+ const lines = readFrom(path, start2, size - start2).split(`
172143
+ `);
172144
+ return lines.slice(Math.max(0, lines.length - maxLines)).join(`
172145
+ `);
172146
+ }, parseLines = (args) => {
172147
+ const index = args.findIndex((arg) => arg === "-n" || arg === "--lines");
172148
+ if (index === UNFOUND_INDEX)
172149
+ return DEFAULT_LINES;
172150
+ const value = Number(args[index + 1]);
172151
+ return Number.isInteger(value) && value > 0 ? value : DEFAULT_LINES;
172152
+ }, targetName = (args) => {
172153
+ const index = args.findIndex((arg) => arg === "-n" || arg === "--lines");
172154
+ const cleaned = index === UNFOUND_INDEX ? args : [...args.slice(0, index), ...args.slice(index + LINES_FLAG_SPAN)];
172155
+ return cleaned.find((arg) => !arg.startsWith("-"));
172156
+ }, followFile = (path) => {
172157
+ let offset = statSync2(path).size;
172158
+ watchFile(path, { interval: POLL_MS }, (current) => {
172159
+ if (current.size > offset) {
172160
+ process.stdout.write(readFrom(path, offset, current.size - offset));
172161
+ }
172162
+ offset = current.size;
172163
+ });
172164
+ }, printDim2 = (message) => {
172165
+ process.stdout.write(`${colors.dim}${message}${colors.reset}
172166
+ `);
172167
+ }, printAvailable = (instances) => {
172168
+ const named = instances.filter((instance) => instance.logFile !== null);
172169
+ if (named.length === 0) {
172170
+ printDim2("No running servers have a captured log.");
172171
+ return;
172172
+ }
172173
+ printDim2("Servers with logs:");
172174
+ named.forEach((instance) => printDim2(` ${instance.name}`));
172175
+ }, runLogs = async (args) => {
172176
+ const instances = await enrichInstances(await discoverInstances());
172177
+ const name = targetName(args);
172178
+ if (name === undefined) {
172179
+ printDim2("Usage: absolute logs <name> [-f] [-n <lines>]");
172180
+ printAvailable(instances);
172181
+ return;
172182
+ }
172183
+ const match = instances.find((instance) => instance.name === name);
172184
+ if (!match) {
172185
+ printDim2(`No running server named "${name}".`);
172186
+ printAvailable(instances);
172187
+ return;
172188
+ }
172189
+ if (match.logFile === null || !existsSync14(match.logFile)) {
172190
+ printDim2(`"${name}" has no captured log (untracked, or started outside the CLI).`);
172191
+ return;
172192
+ }
172193
+ process.stdout.write(`${tailLines(match.logFile, parseLines(args))}
172194
+ `);
172195
+ if (args.includes("-f") || args.includes("--follow")) {
172196
+ printDim2(`\u2014 following ${match.name} \xB7 ctrl+c to stop \u2014`);
172197
+ followFile(match.logFile);
172198
+ }
172199
+ };
172200
+ var init_logs = __esm(() => {
172201
+ init_constants();
172202
+ init_discoverInstances();
172203
+ init_instanceStatus();
172204
+ init_tuiPrimitives();
172205
+ });
172206
+
172207
+ // src/cli/scripts/doctor.ts
172208
+ var exports_doctor = {};
172209
+ __export(exports_doctor, {
172210
+ runDoctor: () => runDoctor
172211
+ });
172212
+ import { existsSync as existsSync15 } from "fs";
172213
+ import { createRequire } from "module";
172214
+ import { arch as arch4, platform as platform5 } from "os";
172215
+ import { join as join15 } from "path";
172216
+ var FRAMEWORK_FIELDS2, projectRequire, check = (status2, label, detail) => ({
172217
+ detail,
172218
+ label,
172219
+ status: status2
172220
+ }), readString = (source, key) => {
172221
+ const value = Reflect.get(source, key);
172222
+ return typeof value === "string" ? value : undefined;
172223
+ }, resolveVersion = (specifier) => {
172224
+ try {
172225
+ const pkg = projectRequire(`${specifier}/package.json`);
172226
+ const version2 = pkg && typeof pkg === "object" ? Reflect.get(pkg, "version") : null;
172227
+ return typeof version2 === "string" ? version2 : null;
172228
+ } catch {
172229
+ return null;
172230
+ }
172231
+ }, checkBun = () => check("ok", "Bun runtime", `v${Bun.version}`), checkAbsolute = () => {
172232
+ const version2 = resolveVersion("@absolutejs/absolute");
172233
+ return version2 === null ? check("fail", "@absolutejs/absolute", "not resolvable here") : check("ok", "@absolutejs/absolute", `v${version2}`);
172234
+ }, checkNative = () => {
172235
+ const target = `@absolutejs/native-${platform5()}-${arch4()}`;
172236
+ const version2 = resolveVersion(target);
172237
+ return version2 === null ? check("warn", "Native binary", `${target} not installed`) : check("ok", "Native binary", `v${version2}`);
172238
+ }, loadConfigOrNull = async () => {
172239
+ try {
172240
+ return await loadRawConfig();
172241
+ } catch {
172242
+ return null;
172243
+ }
172244
+ }, frameworkChecks = (config) => FRAMEWORK_FIELDS2.flatMap((field) => {
172245
+ const dir = readString(config, field);
172246
+ if (dir === undefined)
172247
+ return [];
172248
+ const label = `${field.replace("Directory", "")} pages`;
172249
+ return [
172250
+ existsSync15(join15(process.cwd(), dir)) ? check("ok", label, dir) : check("fail", label, `${dir} (missing)`)
172251
+ ];
172252
+ }), envCheck = async () => {
172253
+ const vars = await collectEnvVars();
172254
+ const missing = vars.filter((entry) => !entry.set);
172255
+ if (vars.length === 0)
172256
+ return check("ok", "Env vars", "no getEnv() usage");
172257
+ if (missing.length === 0) {
172258
+ return check("ok", "Env vars", `all ${vars.length} set`);
172259
+ }
172260
+ return check("fail", "Env vars", `missing ${missing.map((entry) => entry.key).join(", ")}`);
172261
+ }, devPort = (config) => {
172262
+ const dev2 = Reflect.get(config, "dev");
172263
+ const port = dev2 && typeof dev2 === "object" ? Reflect.get(dev2, "port") : undefined;
172264
+ return typeof port === "number" ? port : DEFAULT_PORT;
172265
+ }, portCheck = async (config) => {
172266
+ const port = devPort(config);
172267
+ const holder = (await scanListeners()).find((listener) => listener.port === port);
172268
+ return holder ? check("warn", "Dev port", `${port} in use by pid ${holder.pid}`) : check("ok", "Dev port", `${port} free`);
172269
+ }, STATUS_MARK, renderCheck = (entry, labelWidth) => ` ${STATUS_MARK[entry.status]} ${entry.label.padEnd(labelWidth)} ${colors.dim}${entry.detail}${colors.reset}`, printReport2 = (checks) => {
172270
+ const labelWidth = Math.max(...checks.map((entry) => entry.label.length));
172271
+ const failed = checks.filter((entry) => entry.status === "fail").length;
172272
+ const warned = checks.filter((entry) => entry.status === "warn").length;
172273
+ const summary = failed > 0 ? `${colors.red}${failed} failed${colors.reset}` : `${colors.green}all good${colors.reset}`;
172274
+ const lines = checks.map((entry) => renderCheck(entry, labelWidth));
172275
+ process.stdout.write(`${lines.join(`
172276
+ `)}
172277
+
172278
+ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim} \xB7 ${warned} warning${warned === 1 ? "" : "s"}${colors.reset}
172279
+ `);
172280
+ }, runDoctor = async (args) => {
172281
+ const config = await loadConfigOrNull();
172282
+ const configCheck = config === null ? check("fail", "Config", "absolute.config.ts not found or invalid") : check("ok", "Config", "absolute.config.ts loaded");
172283
+ const [env4, port] = await Promise.all([
172284
+ envCheck(),
172285
+ config === null ? check("warn", "Dev port", "skipped (no config)") : portCheck(config)
172286
+ ]);
172287
+ const checks = [
172288
+ checkBun(),
172289
+ checkAbsolute(),
172290
+ checkNative(),
172291
+ configCheck,
172292
+ ...config === null ? [] : frameworkChecks(config),
172293
+ env4,
172294
+ port
172295
+ ];
172296
+ if (args.includes("--json")) {
172297
+ process.stdout.write(`${JSON.stringify(checks, null, 2)}
172298
+ `);
172299
+ } else {
172300
+ printReport2(checks);
172301
+ }
172302
+ if (checks.some((entry) => entry.status === "fail")) {
172303
+ process.exitCode = 1;
172304
+ }
172305
+ };
172306
+ var init_doctor = __esm(() => {
172307
+ init_constants();
172308
+ init_loadConfig();
172309
+ init_portScan();
172310
+ init_tuiPrimitives();
172311
+ init_env();
172312
+ FRAMEWORK_FIELDS2 = [
172313
+ "reactDirectory",
172314
+ "vueDirectory",
172315
+ "svelteDirectory",
172316
+ "angularDirectory",
172317
+ "htmlDirectory",
172318
+ "htmxDirectory"
172319
+ ];
172320
+ projectRequire = createRequire(join15(process.cwd(), "package.json"));
172321
+ STATUS_MARK = {
172322
+ fail: `${colors.red}\u2717${colors.reset}`,
172323
+ ok: `${colors.green}\u2713${colors.reset}`,
172324
+ warn: `${colors.yellow}\u26A0${colors.reset}`
172325
+ };
172326
+ });
172327
+
172328
+ // src/cli/scripts/routes.ts
172329
+ var exports_routes = {};
172330
+ __export(exports_routes, {
172331
+ runRoutes: () => runRoutes
172332
+ });
172333
+ var METHOD_COLOR, printDim3 = (message) => {
172334
+ process.stdout.write(`${colors.dim}${message}${colors.reset}
172335
+ `);
172336
+ }, pickServer = (instances) => {
172337
+ const withUrl = instances.filter((instance) => instance.url !== null);
172338
+ return withUrl.find((instance) => instance.source === "dev") ?? withUrl.find((instance) => instance.source !== "untracked") ?? withUrl[0];
172339
+ }, fetchRoutes = async (url) => {
172340
+ try {
172341
+ const response = await fetch(`${url}__absolute/routes`);
172342
+ if (!response.ok)
172343
+ return null;
172344
+ const data = await response.json();
172345
+ if (!Array.isArray(data))
172346
+ return null;
172347
+ return data.map((entry) => ({
172348
+ method: String(entry.method ?? "").toUpperCase(),
172349
+ path: String(entry.path ?? "")
172350
+ }));
172351
+ } catch {
172352
+ return null;
172353
+ }
172354
+ }, runRoutes = async (args) => {
172355
+ const instances = await enrichInstances(await discoverInstances());
172356
+ const server2 = pickServer(instances);
172357
+ if (!server2 || server2.url === null) {
172358
+ printDim3("No running server found. Start one with `absolute dev`, then run `absolute routes`.");
172359
+ return;
172360
+ }
172361
+ const routes = await fetchRoutes(server2.url);
172362
+ if (!routes) {
172363
+ printDim3(`Could not read routes from ${server2.name} \u2014 route introspection needs a dev server.`);
172364
+ return;
172365
+ }
172366
+ const sorted = routes.filter((route) => route.path !== "/__absolute/routes").sort((left, right) => left.path.localeCompare(right.path) || left.method.localeCompare(right.method));
172367
+ if (args.includes("--json")) {
172368
+ process.stdout.write(`${JSON.stringify(sorted, null, 2)}
172369
+ `);
172370
+ return;
172371
+ }
172372
+ if (sorted.length === 0) {
172373
+ printDim3("No routes registered.");
172374
+ return;
172375
+ }
172376
+ const methodWidth = Math.max(...sorted.map((route) => route.method.length));
172377
+ const lines = sorted.map((route) => {
172378
+ const color = METHOD_COLOR[route.method] ?? colors.dim;
172379
+ return ` ${color}${padLine(route.method, methodWidth)}${colors.reset} ${route.path}`;
172380
+ });
172381
+ process.stdout.write(`${lines.join(`
172382
+ `)}
172383
+
172384
+ ${colors.dim}${sorted.length} routes \xB7 ${server2.name}${colors.reset}
172385
+ `);
172386
+ };
172387
+ var init_routes = __esm(() => {
172388
+ init_discoverInstances();
172389
+ init_instanceStatus();
172390
+ init_tuiPrimitives();
172391
+ METHOD_COLOR = {
172392
+ DELETE: colors.red,
172393
+ GET: colors.green,
172394
+ PATCH: colors.yellow,
172395
+ POST: colors.cyan,
172396
+ PUT: colors.yellow
172397
+ };
172398
+ });
172399
+
171989
172400
  // src/build/externalAssetPlugin.ts
171990
- import { copyFileSync as copyFileSync2, existsSync as existsSync12, mkdirSync as mkdirSync7, statSync as statSync2 } from "fs";
171991
- import { basename as basename6, dirname as dirname4, join as join13, resolve as resolve11 } from "path";
172401
+ import { copyFileSync as copyFileSync2, existsSync as existsSync16, mkdirSync as mkdirSync7, statSync as statSync3 } from "fs";
172402
+ import { basename as basename6, dirname as dirname4, join as join16, resolve as resolve11 } from "path";
171992
172403
  var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
171993
172404
  name: "absolute-external-asset",
171994
172405
  setup(bld) {
@@ -172009,12 +172420,12 @@ var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
172009
172420
  if (!relPath)
172010
172421
  continue;
172011
172422
  const assetPath = resolve11(sourceDir, relPath);
172012
- if (!existsSync12(assetPath))
172423
+ if (!existsSync16(assetPath))
172013
172424
  continue;
172014
- if (!statSync2(assetPath).isFile())
172425
+ if (!statSync3(assetPath).isFile())
172015
172426
  continue;
172016
- const targetPath = join13(outDir, basename6(assetPath));
172017
- if (existsSync12(targetPath))
172427
+ const targetPath = join16(outDir, basename6(assetPath));
172428
+ if (existsSync16(targetPath))
172018
172429
  continue;
172019
172430
  mkdirSync7(dirname4(targetPath), { recursive: true });
172020
172431
  copyFileSync2(assetPath, targetPath);
@@ -172031,19 +172442,19 @@ __export(exports_compile, {
172031
172442
  shouldEmbedCompiledAsset: () => shouldEmbedCompiledAsset,
172032
172443
  compile: () => compile
172033
172444
  });
172034
- var {env: env3 } = globalThis.Bun;
172445
+ var {env: env4 } = globalThis.Bun;
172035
172446
  import {
172036
172447
  cpSync,
172037
- existsSync as existsSync13,
172448
+ existsSync as existsSync17,
172038
172449
  mkdirSync as mkdirSync8,
172039
- readdirSync as readdirSync3,
172040
- readFileSync as readFileSync14,
172450
+ readdirSync as readdirSync4,
172451
+ readFileSync as readFileSync16,
172041
172452
  rmSync as rmSync5,
172042
- statSync as statSync3,
172453
+ statSync as statSync4,
172043
172454
  unlinkSync as unlinkSync4,
172044
172455
  writeFileSync as writeFileSync6
172045
172456
  } from "fs";
172046
- import { basename as basename7, dirname as dirname5, join as join14, relative as relative3, resolve as resolve12 } from "path";
172457
+ import { basename as basename7, dirname as dirname5, join as join17, relative as relative3, resolve as resolve12 } from "path";
172047
172458
  var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
172048
172459
  const resolvedVersion = version2 || "unknown";
172049
172460
  console.log("");
@@ -172051,14 +172462,14 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172051
172462
  console.log("");
172052
172463
  }, collectFiles2 = (dir) => {
172053
172464
  const result = [];
172054
- let pending = readdirSync3(dir, { withFileTypes: true });
172465
+ let pending = readdirSync4(dir, { withFileTypes: true });
172055
172466
  while (pending.length > 0) {
172056
172467
  const entry = pending.pop();
172057
172468
  if (!entry)
172058
172469
  continue;
172059
- const fullPath = join14(entry.parentPath, entry.name);
172470
+ const fullPath = join17(entry.parentPath, entry.name);
172060
172471
  if (entry.isDirectory())
172061
- pending = pending.concat(readdirSync3(fullPath, { withFileTypes: true }));
172472
+ pending = pending.concat(readdirSync4(fullPath, { withFileTypes: true }));
172062
172473
  else
172063
172474
  result.push(fullPath);
172064
172475
  }
@@ -172071,16 +172482,16 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172071
172482
  return `./${parts.join("/")}`;
172072
172483
  }, collectProjectSourceFiles = (dir) => {
172073
172484
  const result = [];
172074
- let pending = readdirSync3(dir, { withFileTypes: true });
172485
+ let pending = readdirSync4(dir, { withFileTypes: true });
172075
172486
  while (pending.length > 0) {
172076
172487
  const entry = pending.pop();
172077
172488
  if (!entry)
172078
172489
  continue;
172079
- const fullPath = join14(entry.parentPath, entry.name);
172490
+ const fullPath = join17(entry.parentPath, entry.name);
172080
172491
  if (entry.isDirectory()) {
172081
172492
  if (SERVER_RUNTIME_SCAN_SKIP_DIRS.has(entry.name))
172082
172493
  continue;
172083
- pending = pending.concat(readdirSync3(fullPath, { withFileTypes: true }));
172494
+ pending = pending.concat(readdirSync4(fullPath, { withFileTypes: true }));
172084
172495
  } else if (hasSourceExtension(fullPath)) {
172085
172496
  result.push(fullPath);
172086
172497
  }
@@ -172091,7 +172502,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172091
172502
  const normalizedOutdir = resolve12(outdir);
172092
172503
  const copyReference = (filePath, relPath) => {
172093
172504
  const assetSource = resolve12(dirname5(filePath), relPath);
172094
- if (!existsSync13(assetSource) || !statSync3(assetSource).isFile())
172505
+ if (!existsSync17(assetSource) || !statSync4(assetSource).isFile())
172095
172506
  return;
172096
172507
  const assetTarget = resolve12(normalizedOutdir, relPath.replace(/^\.\//, ""));
172097
172508
  if (assetTarget !== normalizedOutdir && !assetTarget.startsWith(`${normalizedOutdir}/`))
@@ -172103,7 +172514,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172103
172514
  cpSync(assetSource, assetTarget, { force: true });
172104
172515
  };
172105
172516
  for (const filePath of collectProjectSourceFiles(process.cwd())) {
172106
- const source = readFileSync14(filePath, "utf-8");
172517
+ const source = readFileSync16(filePath, "utf-8");
172107
172518
  SERVER_RUNTIME_ASSET_RE.lastIndex = 0;
172108
172519
  let match;
172109
172520
  while ((match = SERVER_RUNTIME_ASSET_RE.exec(source)) !== null) {
@@ -172132,7 +172543,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172132
172543
  }
172133
172544
  }, readPackageVersion4 = (candidate) => {
172134
172545
  try {
172135
- const pkg = JSON.parse(readFileSync14(candidate, "utf-8"));
172546
+ const pkg = JSON.parse(readFileSync16(candidate, "utf-8"));
172136
172547
  if (pkg.name !== "@absolutejs/absolute")
172137
172548
  return null;
172138
172549
  const ver = pkg.version;
@@ -172175,7 +172586,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172175
172586
  resolve12(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
172176
172587
  ];
172177
172588
  for (const candidate of candidates) {
172178
- if (existsSync13(candidate))
172589
+ if (existsSync17(candidate))
172179
172590
  return candidate;
172180
172591
  }
172181
172592
  return resolve12(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
@@ -172191,7 +172602,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172191
172602
  return true;
172192
172603
  }, tryReadNodePackageJson = (packageDir) => {
172193
172604
  try {
172194
- return JSON.parse(readFileSync14(join14(packageDir, "package.json"), "utf-8"));
172605
+ return JSON.parse(readFileSync16(join17(packageDir, "package.json"), "utf-8"));
172195
172606
  } catch {
172196
172607
  return null;
172197
172608
  }
@@ -172203,7 +172614,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172203
172614
  if (!pkg)
172204
172615
  return;
172205
172616
  seen.add(specifier);
172206
- const destDir = join14(outdir, "node_modules", ...specifier.split("/"));
172617
+ const destDir = join17(outdir, "node_modules", ...specifier.split("/"));
172207
172618
  rmSync5(destDir, { force: true, recursive: true });
172208
172619
  cpSync(srcDir, destDir, {
172209
172620
  force: true,
@@ -172226,7 +172637,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172226
172637
  if (!buildConfig.angularDirectory)
172227
172638
  return;
172228
172639
  const angularScopeDir = resolve12(process.cwd(), "node_modules", "@angular");
172229
- const angularPackages = existsSync13(angularScopeDir) ? readdirSync3(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
172640
+ const angularPackages = existsSync17(angularScopeDir) ? readdirSync4(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
172230
172641
  const roots = new Set([...angularPackages, "rxjs", "tslib", "typescript"]);
172231
172642
  const seen = new Set;
172232
172643
  for (const specifier of roots) {
@@ -172243,16 +172654,16 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172243
172654
  }
172244
172655
  copyAngularRuntimePackages(buildConfig, outdir);
172245
172656
  }, collectRuntimePackageSpecifiers = (distDir) => {
172246
- const nodeModulesDir = join14(distDir, "node_modules");
172247
- if (!existsSync13(nodeModulesDir))
172657
+ const nodeModulesDir = join17(distDir, "node_modules");
172658
+ if (!existsSync17(nodeModulesDir))
172248
172659
  return [];
172249
172660
  const specifiers = [];
172250
- for (const entry of readdirSync3(nodeModulesDir, { withFileTypes: true })) {
172661
+ for (const entry of readdirSync4(nodeModulesDir, { withFileTypes: true })) {
172251
172662
  if (!entry.isDirectory())
172252
172663
  continue;
172253
172664
  if (entry.name.startsWith("@")) {
172254
- const scopeDir = join14(nodeModulesDir, entry.name);
172255
- for (const scopedEntry of readdirSync3(scopeDir, {
172665
+ const scopeDir = join17(nodeModulesDir, entry.name);
172666
+ for (const scopedEntry of readdirSync4(scopeDir, {
172256
172667
  withFileTypes: true
172257
172668
  })) {
172258
172669
  if (scopedEntry.isDirectory()) {
@@ -172283,21 +172694,21 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172283
172694
  const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
172284
172695
  if (!packageSpecifier)
172285
172696
  return null;
172286
- const packageDir = join14(distDir, "node_modules", ...packageSpecifier.split("/"));
172697
+ const packageDir = join17(distDir, "node_modules", ...packageSpecifier.split("/"));
172287
172698
  const subpath = specifier.slice(packageSpecifier.length);
172288
- const subPackageDir = subpath ? join14(packageDir, ...subpath.slice(1).split("/")) : null;
172289
- const resolvedPackageDir = subPackageDir && existsSync13(join14(subPackageDir, "package.json")) ? subPackageDir : packageDir;
172290
- const packageJsonPath = join14(resolvedPackageDir, "package.json");
172291
- if (!existsSync13(packageJsonPath))
172699
+ const subPackageDir = subpath ? join17(packageDir, ...subpath.slice(1).split("/")) : null;
172700
+ const resolvedPackageDir = subPackageDir && existsSync17(join17(subPackageDir, "package.json")) ? subPackageDir : packageDir;
172701
+ const packageJsonPath = join17(resolvedPackageDir, "package.json");
172702
+ if (!existsSync17(packageJsonPath))
172292
172703
  return null;
172293
- const pkg = JSON.parse(readFileSync14(packageJsonPath, "utf-8"));
172704
+ const pkg = JSON.parse(readFileSync16(packageJsonPath, "utf-8"));
172294
172705
  const exportKey = resolvedPackageDir !== subPackageDir && subpath ? `.${subpath}` : ".";
172295
172706
  const rootExport = pkg.exports?.[exportKey];
172296
172707
  const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
172297
- return join14(resolvedPackageDir, entry);
172708
+ return join17(resolvedPackageDir, entry);
172298
172709
  }, RUNTIME_JS_EXTENSIONS, MODULE_SPECIFIER_RE, isRuntimeJsFile = (filePath) => RUNTIME_JS_EXTENSIONS.some((extension) => filePath.endsWith(extension)), isNodeModulesPath = (filePath) => filePath.split(/[\\/]/).includes("node_modules"), isFile = (filePath) => {
172299
172710
  try {
172300
- return statSync3(filePath).isFile();
172711
+ return statSync4(filePath).isFile();
172301
172712
  } catch {
172302
172713
  return false;
172303
172714
  }
@@ -172307,13 +172718,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172307
172718
  const candidates = [
172308
172719
  candidate,
172309
172720
  ...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
172310
- ...RUNTIME_JS_EXTENSIONS.map((extension) => join14(candidate, `index${extension}`))
172721
+ ...RUNTIME_JS_EXTENSIONS.map((extension) => join17(candidate, `index${extension}`))
172311
172722
  ];
172312
172723
  return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
172313
172724
  }, findContainingRuntimePackageDir = (filePath) => {
172314
172725
  let dir = dirname5(filePath);
172315
172726
  while (dir !== dirname5(dir)) {
172316
- if (isNodeModulesPath(dir) && existsSync13(join14(dir, "package.json"))) {
172727
+ if (isNodeModulesPath(dir) && existsSync17(join17(dir, "package.json"))) {
172317
172728
  return dir;
172318
172729
  }
172319
172730
  dir = dirname5(dir);
@@ -172329,7 +172740,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172329
172740
  const entry = pickExportEntry(pkg?.imports?.[specifier]);
172330
172741
  if (!entry)
172331
172742
  return null;
172332
- return join14(packageDir, entry);
172743
+ return join17(packageDir, entry);
172333
172744
  }, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), rewriteRuntimeModuleSpecifiers = (distDir) => {
172334
172745
  const packageSpecifiers = collectRuntimePackageSpecifiers(distDir);
172335
172746
  if (packageSpecifiers.length === 0)
@@ -172348,7 +172759,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
172348
172759
  if (!filePath || seen.has(filePath))
172349
172760
  continue;
172350
172761
  seen.add(filePath);
172351
- const source = readFileSync14(filePath, "utf-8");
172762
+ const source = readFileSync16(filePath, "utf-8");
172352
172763
  const rewritten = source.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
172353
172764
  if (typeof specifier === "string" && specifier.startsWith(".")) {
172354
172765
  enqueue(resolveRuntimeJsFile(resolve12(dirname5(filePath), specifier)));
@@ -172821,7 +173232,7 @@ console.log(\`
172821
173232
  const resolvedOutdir = resolve12(outdir ?? "dist");
172822
173233
  await withBuildDirectoryLock(resolvedOutdir, () => compileUnlocked(serverEntry, resolvedOutdir, outfile, configPath2));
172823
173234
  }, compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath2) => {
172824
- const prerenderPort = Number(env3.COMPILE_PORT) || Number(env3.PORT) || DEFAULT_PORT + 1;
173235
+ const prerenderPort = Number(env4.COMPILE_PORT) || Number(env4.PORT) || DEFAULT_PORT + 1;
172825
173236
  killStaleProcesses(prerenderPort);
172826
173237
  const entryName = basename7(serverEntry).replace(/\.[^.]+$/, "");
172827
173238
  const resolvedOutfile = resolve12(outfile ?? "compiled-server");
@@ -172886,13 +173297,13 @@ console.log(\`
172886
173297
  process.exit(1);
172887
173298
  }
172888
173299
  const outputPath = resolve12(resolvedOutdir, `${entryName}.js`);
172889
- if (!existsSync13(outputPath)) {
173300
+ if (!existsSync17(outputPath)) {
172890
173301
  console.error(cliTag4("\x1B[31m", `Expected output not found: ${outputPath}`));
172891
173302
  process.exit(1);
172892
173303
  }
172893
- if (existsSync13(resolve12(resolvedOutdir, "angular", "vendor", "server"))) {
173304
+ if (existsSync17(resolve12(resolvedOutdir, "angular", "vendor", "server"))) {
172894
173305
  const vendorDir = resolve12(resolvedOutdir, "angular", "vendor", "server");
172895
- const vendorEntries = readdirSync3(vendorDir).filter((f) => f.endsWith(".js"));
173306
+ const vendorEntries = readdirSync4(vendorDir).filter((f) => f.endsWith(".js"));
172896
173307
  const angularServerVendorPaths = {};
172897
173308
  for (const file of vendorEntries) {
172898
173309
  const stem = file.replace(/\.js$/, "");
@@ -172912,7 +173323,7 @@ console.log(\`
172912
173323
  copyServerRuntimeAssetReferences(resolvedOutdir);
172913
173324
  const prerenderStart = performance.now();
172914
173325
  process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
172915
- rmSync5(join14(resolvedOutdir, "_prerendered"), {
173326
+ rmSync5(join17(resolvedOutdir, "_prerendered"), {
172916
173327
  force: true,
172917
173328
  recursive: true
172918
173329
  });
@@ -172931,7 +173342,7 @@ console.log(\`
172931
173342
  const compileStart = performance.now();
172932
173343
  process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
172933
173344
  const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
172934
- const entrypointPath = join14(resolvedOutdir, "_compile_entrypoint.ts");
173345
+ const entrypointPath = join17(resolvedOutdir, "_compile_entrypoint.ts");
172935
173346
  await Bun.write(entrypointPath, entrypointCode);
172936
173347
  mkdirSync8(dirname5(resolvedOutfile), { recursive: true });
172937
173348
  const result = await Bun.build({
@@ -173027,11 +173438,11 @@ var exports_typecheck = {};
173027
173438
  __export(exports_typecheck, {
173028
173439
  typecheck: () => typecheck
173029
173440
  });
173030
- import { resolve as resolve13, join as join15 } from "path";
173031
- import { existsSync as existsSync14, readFileSync as readFileSync15 } from "fs";
173441
+ import { resolve as resolve13, join as join18 } from "path";
173442
+ import { existsSync as existsSync18, readFileSync as readFileSync17 } from "fs";
173032
173443
  import { mkdir as mkdir2, writeFile } from "fs/promises";
173033
173444
  var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), resolveConfigPath = (configPath2) => resolve13(configPath2 ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts"), getTypecheckTargets = async (configPath2) => {
173034
- if (!existsSync14(resolveConfigPath(configPath2))) {
173445
+ if (!existsSync18(resolveConfigPath(configPath2))) {
173035
173446
  return [{}];
173036
173447
  }
173037
173448
  const rawConfig = await loadRawConfig(configPath2);
@@ -173052,7 +173463,7 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
173052
173463
  return { exitCode, name, output: (stdout + stderr).trim() };
173053
173464
  }, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
173054
173465
  const local = resolve13("node_modules", ".bin", name);
173055
- return existsSync14(local) ? local : null;
173466
+ return existsSync18(local) ? local : null;
173056
173467
  }, ANSI_COLOR_REGEX, ANSI_PURPLE_REGEX, ANSI_CYAN_REGEX, ANSI_TOKEN_END_REGEX, stripAnsi3 = (str) => str.replace(ANSI_COLOR_REGEX, ""), formatSvelteOutput = (output) => {
173057
173468
  const cwd = `${process.cwd()}/`;
173058
173469
  const summaryMatch = stripAnsi3(output).match(/svelte-check found (\d+) error/);
@@ -173104,10 +173515,10 @@ Found ${errorCount} error${suffix}.`;
173104
173515
  resolve13(import.meta.dir, "../../types", fileName),
173105
173516
  resolve13(import.meta.dir, "../../../types", fileName)
173106
173517
  ];
173107
- return candidates.find((candidate) => existsSync14(candidate)) ?? candidates[0];
173518
+ return candidates.find((candidate) => existsSync18(candidate)) ?? candidates[0];
173108
173519
  }, ABSOLUTE_TYPECHECK_FILES, readProjectTsconfig = () => {
173109
173520
  try {
173110
- return JSON.parse(readFileSync15(resolve13("tsconfig.json"), "utf-8"));
173521
+ return JSON.parse(readFileSync17(resolve13("tsconfig.json"), "utf-8"));
173111
173522
  } catch {
173112
173523
  return {};
173113
173524
  }
@@ -173135,7 +173546,7 @@ Found ${errorCount} error${suffix}.`;
173135
173546
  console.error("\x1B[31m\u2717\x1B[0m vue-tsc is required for Vue type checking. Install it: bun add -d vue-tsc");
173136
173547
  process.exit(1);
173137
173548
  }
173138
- const vueTsconfigPath = join15(cacheDir, "tsconfig.vue-check.json");
173549
+ const vueTsconfigPath = join18(cacheDir, "tsconfig.vue-check.json");
173139
173550
  return writeFile(vueTsconfigPath, JSON.stringify({
173140
173551
  compilerOptions: {
173141
173552
  rootDir: ".."
@@ -173150,7 +173561,7 @@ Found ${errorCount} error${suffix}.`;
173150
173561
  resolve13(vueTsconfigPath),
173151
173562
  "--incremental",
173152
173563
  "--tsBuildInfoFile",
173153
- join15(cacheDir, "vue-tsc.tsbuildinfo"),
173564
+ join18(cacheDir, "vue-tsc.tsbuildinfo"),
173154
173565
  "--pretty"
173155
173566
  ]));
173156
173567
  }, buildAngularCheck = async (cacheDir, angularDir) => {
@@ -173159,7 +173570,7 @@ Found ${errorCount} error${suffix}.`;
173159
173570
  console.error("\x1B[31m\u2717\x1B[0m @angular/compiler-cli is required for Angular type checking. Install it: bun add -d @angular/compiler-cli");
173160
173571
  process.exit(1);
173161
173572
  }
173162
- const angularTsconfigPath = join15(cacheDir, "tsconfig.angular-check.json");
173573
+ const angularTsconfigPath = join18(cacheDir, "tsconfig.angular-check.json");
173163
173574
  await writeFile(angularTsconfigPath, JSON.stringify({
173164
173575
  angularCompilerOptions: {
173165
173576
  strictTemplates: true
@@ -173179,7 +173590,7 @@ Found ${errorCount} error${suffix}.`;
173179
173590
  console.error("\x1B[31m\u2717\x1B[0m typescript is required for type checking. Install it: bun add -d typescript");
173180
173591
  process.exit(1);
173181
173592
  }
173182
- const tscConfigPath = join15(cacheDir, "tsconfig.typecheck.json");
173593
+ const tscConfigPath = join18(cacheDir, "tsconfig.typecheck.json");
173183
173594
  return writeFile(tscConfigPath, JSON.stringify({
173184
173595
  compilerOptions: {
173185
173596
  rootDir: ".."
@@ -173194,7 +173605,7 @@ Found ${errorCount} error${suffix}.`;
173194
173605
  resolve13(tscConfigPath),
173195
173606
  "--incremental",
173196
173607
  "--tsBuildInfoFile",
173197
- join15(cacheDir, "tsc.tsbuildinfo"),
173608
+ join18(cacheDir, "tsc.tsbuildinfo"),
173198
173609
  "--pretty"
173199
173610
  ]));
173200
173611
  }, buildSvelteCheck = async (cacheDir, svelteDir) => {
@@ -173203,7 +173614,7 @@ Found ${errorCount} error${suffix}.`;
173203
173614
  console.error("\x1B[31m\u2717\x1B[0m svelte-check is required for Svelte type checking. Install it: bun add -d svelte-check");
173204
173615
  process.exit(1);
173205
173616
  }
173206
- const svelteTsconfigPath = join15(cacheDir, "tsconfig.svelte-check.json");
173617
+ const svelteTsconfigPath = join18(cacheDir, "tsconfig.svelte-check.json");
173207
173618
  await writeFile(svelteTsconfigPath, JSON.stringify({
173208
173619
  extends: resolve13("tsconfig.json"),
173209
173620
  files: ABSOLUTE_TYPECHECK_FILES,
@@ -176877,7 +177288,7 @@ if (command === "dev") {
176877
177288
  const outdir = parseNamedArg("--outdir");
176878
177289
  const configPath2 = parseNamedArg("--config");
176879
177290
  const { build: build2 } = await Promise.resolve().then(() => (init_build(), exports_build));
176880
- await build2(outdir, configPath2);
177291
+ await build2(outdir, configPath2, args.includes("--profile"));
176881
177292
  } else if (command === "workspace") {
176882
177293
  sendTelemetryEvent("cli:command", {
176883
177294
  command: `workspace:${workspaceCommand ?? "unknown"}`
@@ -176910,6 +177321,22 @@ if (command === "dev") {
176910
177321
  sendTelemetryEvent("cli:command", { command: "mem" });
176911
177322
  const { runMem: runMem2 } = await Promise.resolve().then(() => (init_mem(), exports_mem));
176912
177323
  await runMem2(args);
177324
+ } else if (command === "env") {
177325
+ sendTelemetryEvent("cli:command", { command: "env" });
177326
+ const { runEnv: runEnv2 } = await Promise.resolve().then(() => (init_env(), exports_env));
177327
+ await runEnv2(args);
177328
+ } else if (command === "logs") {
177329
+ sendTelemetryEvent("cli:command", { command: "logs" });
177330
+ const { runLogs: runLogs2 } = await Promise.resolve().then(() => (init_logs(), exports_logs));
177331
+ await runLogs2(args);
177332
+ } else if (command === "doctor") {
177333
+ sendTelemetryEvent("cli:command", { command: "doctor" });
177334
+ const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), exports_doctor));
177335
+ await runDoctor2(args);
177336
+ } else if (command === "routes") {
177337
+ sendTelemetryEvent("cli:command", { command: "routes" });
177338
+ const { runRoutes: runRoutes2 } = await Promise.resolve().then(() => (init_routes(), exports_routes));
177339
+ await runRoutes2(args);
176913
177340
  } else if (command === "info") {
176914
177341
  sendTelemetryEvent("cli:command", { command });
176915
177342
  info();
@@ -176945,16 +177372,20 @@ if (command === "dev") {
176945
177372
  console.error("Commands:");
176946
177373
  console.error(" dev [entry] Start development server");
176947
177374
  console.error(" workspace dev [--no-tui] Start multi-service workspace dev");
176948
- console.error(" build [--outdir dir] Build production assets");
177375
+ console.error(" build [--outdir dir] [--profile] Build production assets");
176949
177376
  console.error(" start [entry] [--outdir dir] Start production server");
176950
177377
  console.error(" compile [entry] [--outdir dir] [--outfile path] Compile standalone executable");
176951
177378
  console.error(" config [--port n] Open the unified config UI (ESLint, tsconfig, Prettier)");
177379
+ console.error(" doctor [--json] Diagnose the project (bun, config, framework dirs, env, port)");
177380
+ console.error(" env [--check] [--json] Report env vars the app reads (getEnv) and which are missing");
176952
177381
  console.error(" eslint Run ESLint (cached)");
176953
177382
  console.error(" info Print system info for bug reports");
176954
- console.error(" ls [--sizes] [--json] List the project's pages by framework (from source)");
177383
+ console.error(" logs <name> [-f] [-n <lines>] Tail a running server's log by name");
177384
+ console.error(" ls [--sizes] [--budget <size>] [--json] List the project's pages by framework");
176955
177385
  console.error(" mem [--json] Memory report (RSS) for running servers, plus system usage");
176956
177386
  console.error(" ps [--watch] [--json] [--kill <pid|port>] [--kill-all] List/manage running servers");
176957
177387
  console.error(" prettier Run Prettier check (cached)");
177388
+ console.error(" routes [--json] List every route (pages + API) of a running dev server");
176958
177389
  console.error(" typecheck Run type checkers for all frameworks");
176959
177390
  console.error(" telemetry Manage anonymous telemetry");
176960
177391
  console.error(" tunnel-relay Run the public reverse-tunnel relay (for webhook dev)");