@absolutejs/absolute 0.19.0-beta.682 → 0.19.0-beta.684

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
@@ -1145,17 +1145,17 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
1145
1145
  }, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
1146
1146
  const local = resolve8("node_modules", ".bin", name);
1147
1147
  return existsSync10(local) ? local : null;
1148
- }, stripAnsi2 = (str) => str.replace(/\x1b\[[0-9;]*m/g, ""), formatSvelteOutput = (output) => {
1148
+ }, stripAnsi3 = (str) => str.replace(/\x1b\[[0-9;]*m/g, ""), formatSvelteOutput = (output) => {
1149
1149
  const cwd = `${process.cwd()}/`;
1150
- const summaryMatch = stripAnsi2(output).match(/svelte-check found (\d+) error/);
1150
+ const summaryMatch = stripAnsi3(output).match(/svelte-check found (\d+) error/);
1151
1151
  const errorCount = summaryMatch ? parseInt(summaryMatch[1] ?? "0", 10) : 0;
1152
1152
  const formatted = output.split(`
1153
1153
  `).filter((line) => {
1154
- const plain = stripAnsi2(line);
1154
+ const plain = stripAnsi3(line);
1155
1155
  return !plain.startsWith("Loading svelte-check") && !plain.startsWith("Getting Svelte") && !plain.startsWith("====") && !plain.startsWith("svelte-check found") && !/^\d+ (START|COMPLETED)/.test(plain) && plain.trim() !== "";
1156
1156
  }).flatMap((line) => {
1157
1157
  const result = line.replaceAll(cwd, "");
1158
- const plain = stripAnsi2(result);
1158
+ const plain = stripAnsi3(result);
1159
1159
  const pathMatch = plain.match(/^(\S+\.svelte):(\d+:\d+)$/);
1160
1160
  if (pathMatch) {
1161
1161
  return [
@@ -1163,9 +1163,9 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
1163
1163
  ];
1164
1164
  }
1165
1165
  if (result.includes("\x1B[35m")) {
1166
- const plainLine = stripAnsi2(result);
1167
- const before = stripAnsi2(result.split("\x1B[35m")[0] ?? "");
1168
- const token = stripAnsi2((result.split("\x1B[35m")[1] ?? "").split(/\x1b\[3[69]m/)[0] ?? "");
1166
+ const plainLine = stripAnsi3(result);
1167
+ const before = stripAnsi3(result.split("\x1B[35m")[0] ?? "");
1168
+ const token = stripAnsi3((result.split("\x1B[35m")[1] ?? "").split(/\x1b\[3[69]m/)[0] ?? "");
1169
1169
  if (!token)
1170
1170
  return [result];
1171
1171
  const expanded = before.replace(/\t/g, " ");
@@ -2485,7 +2485,13 @@ var start = async (serverEntry, outdir, configPath2) => {
2485
2485
  init_constants();
2486
2486
  init_loadConfig();
2487
2487
  init_getDurationString();
2488
- import { existsSync as existsSync8, readFileSync as readFileSync8 } from "fs";
2488
+ import {
2489
+ appendFileSync,
2490
+ existsSync as existsSync8,
2491
+ mkdirSync as mkdirSync4,
2492
+ readFileSync as readFileSync8,
2493
+ writeFileSync as writeFileSync2
2494
+ } from "fs";
2489
2495
  import { createConnection } from "net";
2490
2496
  import { resolve as resolve6 } from "path";
2491
2497
 
@@ -3127,7 +3133,41 @@ var createWorkspaceTui = ({
3127
3133
 
3128
3134
  // src/cli/scripts/workspace.ts
3129
3135
  init_utils();
3136
+ var ANSI_REGEX2 = /\x1B\[[0-?]*[ -/]*[@-~]/g;
3130
3137
  var sleep = (ms) => new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
3138
+ var stripAnsi2 = (value) => value.replace(ANSI_REGEX2, "");
3139
+ var sanitizeLogFileName = (value) => value.replace(/[^a-zA-Z0-9._-]/g, "_") || "unknown";
3140
+ var createWorkspaceLogSink = (appendLog) => {
3141
+ const logDirectory = resolve6(".absolutejs", "workspace", "logs");
3142
+ mkdirSync4(logDirectory, { recursive: true });
3143
+ for (const file of ["all.log", "workspace.log"]) {
3144
+ writeFileSync2(resolve6(logDirectory, file), "");
3145
+ }
3146
+ const initializedSources = new Set(["workspace"]);
3147
+ const writeLog = (source, message, level) => {
3148
+ const cleanMessage = stripAnsi2(message).trimEnd();
3149
+ if (!cleanMessage) {
3150
+ return;
3151
+ }
3152
+ const timestamp = new Date().toISOString();
3153
+ const line = `[${timestamp}] [${level}] [${source}] ${cleanMessage}
3154
+ `;
3155
+ const sourceFile = resolve6(logDirectory, `${sanitizeLogFileName(source)}.log`);
3156
+ if (!initializedSources.has(source)) {
3157
+ writeFileSync2(sourceFile, "");
3158
+ initializedSources.add(source);
3159
+ }
3160
+ appendFileSync(sourceFile, line);
3161
+ appendFileSync(resolve6(logDirectory, "all.log"), line);
3162
+ };
3163
+ return {
3164
+ logDirectory,
3165
+ appendLog: (source, message, level = "info") => {
3166
+ writeLog(source, message, level);
3167
+ appendLog(source, message, level);
3168
+ }
3169
+ };
3170
+ };
3131
3171
  var readPackageVersion2 = (candidate) => {
3132
3172
  try {
3133
3173
  const pkg = JSON.parse(readFileSync8(candidate, "utf-8"));
@@ -3532,6 +3572,9 @@ var workspace = async (subcommand, options) => {
3532
3572
  }),
3533
3573
  version: absoluteVersion
3534
3574
  });
3575
+ const workspaceLogs = createWorkspaceLogSink(tui.addLog);
3576
+ const addLog = workspaceLogs.appendLog;
3577
+ addLog("workspace", `Writing workspace logs to ${workspaceLogs.logDirectory}`, "info");
3535
3578
  const killProcesses = async () => {
3536
3579
  const snapshot = [...running];
3537
3580
  running.length = 0;
@@ -3543,10 +3586,10 @@ var workspace = async (subcommand, options) => {
3543
3586
  await Promise.all(snapshot.map((service) => service.process.exited));
3544
3587
  for (const service of snapshot.reverse()) {
3545
3588
  try {
3546
- await runShutdownHook(service.resolved, tui.addLog);
3589
+ await runShutdownHook(service.resolved, addLog);
3547
3590
  } catch (error) {
3548
3591
  const message = error instanceof Error ? error.message : String(error);
3549
- tui.addLog("workspace", `${service.name} shutdown hook failed: ${message}`, "warn");
3592
+ addLog("workspace", `${service.name} shutdown hook failed: ${message}`, "warn");
3550
3593
  }
3551
3594
  }
3552
3595
  };
@@ -3616,7 +3659,7 @@ var workspace = async (subcommand, options) => {
3616
3659
  const port = (resolved.service.port ?? Number(resolved.env.PORT ?? "")) || DEFAULT_PORT;
3617
3660
  if (port > 0) {
3618
3661
  killStaleProcesses(port, (message) => {
3619
- tui.addLog("workspace", message, "warn");
3662
+ addLog("workspace", message, "warn");
3620
3663
  });
3621
3664
  }
3622
3665
  if (isAbsoluteService(resolved.service) && resolved.configPath && !existsSync8(resolved.configPath)) {
@@ -3631,7 +3674,7 @@ var workspace = async (subcommand, options) => {
3631
3674
  stdin: "ignore",
3632
3675
  stdout: "pipe"
3633
3676
  });
3634
- pipeProcessLogs(name, processHandle, tui.addLog);
3677
+ pipeProcessLogs(name, processHandle, addLog);
3635
3678
  const runningService = {
3636
3679
  name,
3637
3680
  process: processHandle,
@@ -3646,7 +3689,7 @@ var workspace = async (subcommand, options) => {
3646
3689
  return;
3647
3690
  }
3648
3691
  tui.setServiceStatus(name, "error", `exit code ${exitCode || 1}`);
3649
- tui.addLog("workspace", `${name} exited with code ${exitCode || 1}. Shutting down workspace.`, "error");
3692
+ addLog("workspace", `${name} exited with code ${exitCode || 1}. Shutting down workspace.`, "error");
3650
3693
  shutdown(exitCode || 1);
3651
3694
  });
3652
3695
  await waitForReady(resolved);
@@ -3666,7 +3709,7 @@ var workspace = async (subcommand, options) => {
3666
3709
  }
3667
3710
  paused = false;
3668
3711
  }
3669
- tui.addLog("workspace", "Restarting workspace...", "info");
3712
+ addLog("workspace", "Restarting workspace...", "info");
3670
3713
  for (const name of orderedNames) {
3671
3714
  tui.setServiceStatus(name, "restarting");
3672
3715
  }
@@ -3675,7 +3718,7 @@ var workspace = async (subcommand, options) => {
3675
3718
  workspaceBootStartedAt = performance.now();
3676
3719
  await startServices();
3677
3720
  tui.setReadyDuration(performance.now() - workspaceBootStartedAt);
3678
- tui.addLog("workspace", "Workspace ready.", "success");
3721
+ addLog("workspace", "Workspace ready.", "success");
3679
3722
  };
3680
3723
  const togglePause = () => {
3681
3724
  if (paused) {
@@ -3684,14 +3727,14 @@ var workspace = async (subcommand, options) => {
3684
3727
  tui.setServiceStatus(service.name, "ready");
3685
3728
  }
3686
3729
  paused = false;
3687
- tui.addLog("workspace", "Workspace resumed.", "success");
3730
+ addLog("workspace", "Workspace resumed.", "success");
3688
3731
  } else {
3689
3732
  for (const service of running) {
3690
3733
  sendSignalToService(service.process, "SIGSTOP");
3691
3734
  tui.setServiceStatus(service.name, "paused");
3692
3735
  }
3693
3736
  paused = true;
3694
- tui.addLog("workspace", "Workspace paused.", "warn");
3737
+ addLog("workspace", "Workspace paused.", "warn");
3695
3738
  }
3696
3739
  };
3697
3740
  const runShellCommand2 = async (command) => {
@@ -3700,19 +3743,19 @@ var workspace = async (subcommand, options) => {
3700
3743
  stderr: "pipe",
3701
3744
  stdout: "pipe"
3702
3745
  });
3703
- pipeProcessLogs("shell", processHandle, tui.addLog);
3746
+ pipeProcessLogs("shell", processHandle, addLog);
3704
3747
  const exitCode = await processHandle.exited;
3705
3748
  if (exitCode === 0) {
3706
- tui.addLog("workspace", `Shell command finished: ${command}`, "success");
3749
+ addLog("workspace", `Shell command finished: ${command}`, "success");
3707
3750
  return;
3708
3751
  }
3709
- tui.addLog("workspace", `Shell command failed with exit code ${exitCode}: ${command}`, "error");
3752
+ addLog("workspace", `Shell command failed with exit code ${exitCode}: ${command}`, "error");
3710
3753
  };
3711
3754
  const openInBrowser = async () => {
3712
3755
  const publicService = orderedNames.map((name) => services[name]).find((service) => service && getVisibility(service) === "public");
3713
3756
  const url = publicService ? getServiceUrl(publicService) : null;
3714
3757
  if (!url) {
3715
- tui.addLog("workspace", "No public service to open.", "warn");
3758
+ addLog("workspace", "No public service to open.", "warn");
3716
3759
  return;
3717
3760
  }
3718
3761
  const { platform: platform4 } = process;
@@ -3733,9 +3776,9 @@ var workspace = async (subcommand, options) => {
3733
3776
  stderr: "ignore",
3734
3777
  stdout: "ignore"
3735
3778
  });
3736
- tui.addLog("workspace", `Opening ${url}`, "info");
3779
+ addLog("workspace", `Opening ${url}`, "info");
3737
3780
  } catch {
3738
- tui.addLog("workspace", `Could not open browser automatically. Visit ${url}`, "warn");
3781
+ addLog("workspace", `Could not open browser automatically. Visit ${url}`, "warn");
3739
3782
  }
3740
3783
  };
3741
3784
  process.on("SIGINT", () => {
@@ -3745,10 +3788,10 @@ var workspace = async (subcommand, options) => {
3745
3788
  shutdown(0);
3746
3789
  });
3747
3790
  tui.start();
3748
- tui.addLog("workspace", `Workspace booting ${orderedNames.length} services.`, "info");
3791
+ addLog("workspace", `Workspace booting ${orderedNames.length} services.`, "info");
3749
3792
  await startServices();
3750
3793
  tui.setReadyDuration(performance.now() - workspaceBootStartedAt);
3751
- tui.addLog("workspace", "Workspace ready.", "success");
3794
+ addLog("workspace", "Workspace ready.", "success");
3752
3795
  await new Promise(() => {});
3753
3796
  };
3754
3797
 
package/dist/index.js CHANGED
@@ -174823,7 +174823,7 @@ ${registrations}
174823
174823
  ({ tsLibDir } = cached);
174824
174824
  cached.lastUsed = Date.now();
174825
174825
  } else {
174826
- const tsPath = __require.resolve("typescript");
174826
+ const tsPath = __require.resolve("/home/alexkahn/abs/absolutejs/node_modules/typescript/lib/typescript.js");
174827
174827
  const tsRootDir = dirname9(tsPath);
174828
174828
  tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve18(tsRootDir, "lib");
174829
174829
  const config = readConfiguration("./tsconfig.json");
@@ -188997,5 +188997,5 @@ export {
188997
188997
  ANGULAR_INIT_TIMEOUT_MS
188998
188998
  };
188999
188999
 
189000
- //# debugId=34F91B1BAA5BDB1464756E2164756E21
189000
+ //# debugId=A7EC3AF25BF78DB864756E2164756E21
189001
189001
  //# sourceMappingURL=index.js.map