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

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,44 @@ 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
+ if (source === "workspace") {
3163
+ appendFileSync(resolve6(logDirectory, "workspace.log"), line);
3164
+ }
3165
+ };
3166
+ return {
3167
+ logDirectory,
3168
+ appendLog: (source, message, level = "info") => {
3169
+ writeLog(source, message, level);
3170
+ appendLog(source, message, level);
3171
+ }
3172
+ };
3173
+ };
3131
3174
  var readPackageVersion2 = (candidate) => {
3132
3175
  try {
3133
3176
  const pkg = JSON.parse(readFileSync8(candidate, "utf-8"));
@@ -3532,6 +3575,9 @@ var workspace = async (subcommand, options) => {
3532
3575
  }),
3533
3576
  version: absoluteVersion
3534
3577
  });
3578
+ const workspaceLogs = createWorkspaceLogSink(tui.addLog);
3579
+ const addLog = workspaceLogs.appendLog;
3580
+ addLog("workspace", `Writing workspace logs to ${workspaceLogs.logDirectory}`, "info");
3535
3581
  const killProcesses = async () => {
3536
3582
  const snapshot = [...running];
3537
3583
  running.length = 0;
@@ -3543,10 +3589,10 @@ var workspace = async (subcommand, options) => {
3543
3589
  await Promise.all(snapshot.map((service) => service.process.exited));
3544
3590
  for (const service of snapshot.reverse()) {
3545
3591
  try {
3546
- await runShutdownHook(service.resolved, tui.addLog);
3592
+ await runShutdownHook(service.resolved, addLog);
3547
3593
  } catch (error) {
3548
3594
  const message = error instanceof Error ? error.message : String(error);
3549
- tui.addLog("workspace", `${service.name} shutdown hook failed: ${message}`, "warn");
3595
+ addLog("workspace", `${service.name} shutdown hook failed: ${message}`, "warn");
3550
3596
  }
3551
3597
  }
3552
3598
  };
@@ -3616,7 +3662,7 @@ var workspace = async (subcommand, options) => {
3616
3662
  const port = (resolved.service.port ?? Number(resolved.env.PORT ?? "")) || DEFAULT_PORT;
3617
3663
  if (port > 0) {
3618
3664
  killStaleProcesses(port, (message) => {
3619
- tui.addLog("workspace", message, "warn");
3665
+ addLog("workspace", message, "warn");
3620
3666
  });
3621
3667
  }
3622
3668
  if (isAbsoluteService(resolved.service) && resolved.configPath && !existsSync8(resolved.configPath)) {
@@ -3631,7 +3677,7 @@ var workspace = async (subcommand, options) => {
3631
3677
  stdin: "ignore",
3632
3678
  stdout: "pipe"
3633
3679
  });
3634
- pipeProcessLogs(name, processHandle, tui.addLog);
3680
+ pipeProcessLogs(name, processHandle, addLog);
3635
3681
  const runningService = {
3636
3682
  name,
3637
3683
  process: processHandle,
@@ -3646,7 +3692,7 @@ var workspace = async (subcommand, options) => {
3646
3692
  return;
3647
3693
  }
3648
3694
  tui.setServiceStatus(name, "error", `exit code ${exitCode || 1}`);
3649
- tui.addLog("workspace", `${name} exited with code ${exitCode || 1}. Shutting down workspace.`, "error");
3695
+ addLog("workspace", `${name} exited with code ${exitCode || 1}. Shutting down workspace.`, "error");
3650
3696
  shutdown(exitCode || 1);
3651
3697
  });
3652
3698
  await waitForReady(resolved);
@@ -3666,7 +3712,7 @@ var workspace = async (subcommand, options) => {
3666
3712
  }
3667
3713
  paused = false;
3668
3714
  }
3669
- tui.addLog("workspace", "Restarting workspace...", "info");
3715
+ addLog("workspace", "Restarting workspace...", "info");
3670
3716
  for (const name of orderedNames) {
3671
3717
  tui.setServiceStatus(name, "restarting");
3672
3718
  }
@@ -3675,7 +3721,7 @@ var workspace = async (subcommand, options) => {
3675
3721
  workspaceBootStartedAt = performance.now();
3676
3722
  await startServices();
3677
3723
  tui.setReadyDuration(performance.now() - workspaceBootStartedAt);
3678
- tui.addLog("workspace", "Workspace ready.", "success");
3724
+ addLog("workspace", "Workspace ready.", "success");
3679
3725
  };
3680
3726
  const togglePause = () => {
3681
3727
  if (paused) {
@@ -3684,14 +3730,14 @@ var workspace = async (subcommand, options) => {
3684
3730
  tui.setServiceStatus(service.name, "ready");
3685
3731
  }
3686
3732
  paused = false;
3687
- tui.addLog("workspace", "Workspace resumed.", "success");
3733
+ addLog("workspace", "Workspace resumed.", "success");
3688
3734
  } else {
3689
3735
  for (const service of running) {
3690
3736
  sendSignalToService(service.process, "SIGSTOP");
3691
3737
  tui.setServiceStatus(service.name, "paused");
3692
3738
  }
3693
3739
  paused = true;
3694
- tui.addLog("workspace", "Workspace paused.", "warn");
3740
+ addLog("workspace", "Workspace paused.", "warn");
3695
3741
  }
3696
3742
  };
3697
3743
  const runShellCommand2 = async (command) => {
@@ -3700,19 +3746,19 @@ var workspace = async (subcommand, options) => {
3700
3746
  stderr: "pipe",
3701
3747
  stdout: "pipe"
3702
3748
  });
3703
- pipeProcessLogs("shell", processHandle, tui.addLog);
3749
+ pipeProcessLogs("shell", processHandle, addLog);
3704
3750
  const exitCode = await processHandle.exited;
3705
3751
  if (exitCode === 0) {
3706
- tui.addLog("workspace", `Shell command finished: ${command}`, "success");
3752
+ addLog("workspace", `Shell command finished: ${command}`, "success");
3707
3753
  return;
3708
3754
  }
3709
- tui.addLog("workspace", `Shell command failed with exit code ${exitCode}: ${command}`, "error");
3755
+ addLog("workspace", `Shell command failed with exit code ${exitCode}: ${command}`, "error");
3710
3756
  };
3711
3757
  const openInBrowser = async () => {
3712
3758
  const publicService = orderedNames.map((name) => services[name]).find((service) => service && getVisibility(service) === "public");
3713
3759
  const url = publicService ? getServiceUrl(publicService) : null;
3714
3760
  if (!url) {
3715
- tui.addLog("workspace", "No public service to open.", "warn");
3761
+ addLog("workspace", "No public service to open.", "warn");
3716
3762
  return;
3717
3763
  }
3718
3764
  const { platform: platform4 } = process;
@@ -3733,9 +3779,9 @@ var workspace = async (subcommand, options) => {
3733
3779
  stderr: "ignore",
3734
3780
  stdout: "ignore"
3735
3781
  });
3736
- tui.addLog("workspace", `Opening ${url}`, "info");
3782
+ addLog("workspace", `Opening ${url}`, "info");
3737
3783
  } catch {
3738
- tui.addLog("workspace", `Could not open browser automatically. Visit ${url}`, "warn");
3784
+ addLog("workspace", `Could not open browser automatically. Visit ${url}`, "warn");
3739
3785
  }
3740
3786
  };
3741
3787
  process.on("SIGINT", () => {
@@ -3745,10 +3791,10 @@ var workspace = async (subcommand, options) => {
3745
3791
  shutdown(0);
3746
3792
  });
3747
3793
  tui.start();
3748
- tui.addLog("workspace", `Workspace booting ${orderedNames.length} services.`, "info");
3794
+ addLog("workspace", `Workspace booting ${orderedNames.length} services.`, "info");
3749
3795
  await startServices();
3750
3796
  tui.setReadyDuration(performance.now() - workspaceBootStartedAt);
3751
- tui.addLog("workspace", "Workspace ready.", "success");
3797
+ addLog("workspace", "Workspace ready.", "success");
3752
3798
  await new Promise(() => {});
3753
3799
  };
3754
3800
 
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