@absolutejs/absolute 0.19.0-beta.660 → 0.19.0-beta.661

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
@@ -669,8 +669,8 @@ __export(exports_compile, {
669
669
  compile: () => compile
670
670
  });
671
671
  var {env: env3 } = globalThis.Bun;
672
- import { existsSync as existsSync8, readdirSync, readFileSync as readFileSync8, unlinkSync } from "fs";
673
- import { basename as basename2, join as join6, relative, resolve as resolve6 } from "path";
672
+ import { existsSync as existsSync9, readdirSync, readFileSync as readFileSync8, unlinkSync } from "fs";
673
+ import { basename as basename2, join as join6, relative, resolve as resolve7 } from "path";
674
674
  var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, collectFiles2 = (dir) => {
675
675
  const result = [];
676
676
  let pending = readdirSync(dir, { withFileTypes: true });
@@ -719,18 +719,18 @@ var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
719
719
  return;
720
720
  }, resolveJsxDevRuntimeCompatPath2 = () => {
721
721
  const candidates = [
722
- resolve6(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
723
- resolve6(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
724
- resolve6(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
725
- resolve6(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
726
- resolve6(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
727
- resolve6(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
722
+ resolve7(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
723
+ resolve7(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
724
+ resolve7(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
725
+ resolve7(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
726
+ resolve7(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
727
+ resolve7(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
728
728
  ];
729
729
  for (const candidate of candidates) {
730
- if (existsSync8(candidate))
730
+ if (existsSync9(candidate))
731
731
  return candidate;
732
732
  }
733
- return resolve6(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
733
+ return resolve7(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
734
734
  }, jsxDevRuntimeCompatPath2, generateEntrypoint = (distDir, serverEntry, prerenderMap, version2) => {
735
735
  const allFiles = collectFiles2(distDir);
736
736
  const serverBundleName = `${basename2(serverEntry).replace(/\.[^.]+$/, "")}.js`;
@@ -850,11 +850,11 @@ console.log(\`
850
850
  const prerenderPort = Number(env3.COMPILE_PORT) || Number(env3.PORT) || DEFAULT_PORT + 1;
851
851
  killStaleProcesses(prerenderPort);
852
852
  const entryName = basename2(serverEntry).replace(/\.[^.]+$/, "");
853
- const resolvedOutdir = resolve6(outdir ?? "dist");
854
- const resolvedOutfile = resolve6(outfile ?? "compiled-server");
853
+ const resolvedOutdir = resolve7(outdir ?? "dist");
854
+ const resolvedOutfile = resolve7(outfile ?? "compiled-server");
855
855
  const absoluteVersion = resolvePackageVersion2([
856
- resolve6(import.meta.dir, "..", "..", "..", "package.json"),
857
- resolve6(import.meta.dir, "..", "..", "package.json")
856
+ resolve7(import.meta.dir, "..", "..", "..", "package.json"),
857
+ resolve7(import.meta.dir, "..", "..", "package.json")
858
858
  ]);
859
859
  const totalStart = performance.now();
860
860
  const buildStart = performance.now();
@@ -864,8 +864,8 @@ console.log(\`
864
864
  buildConfig.mode = "production";
865
865
  try {
866
866
  const build = await resolveBuildModule2([
867
- resolve6(import.meta.dir, "..", "..", "core", "build"),
868
- resolve6(import.meta.dir, "..", "build")
867
+ resolve7(import.meta.dir, "..", "..", "core", "build"),
868
+ resolve7(import.meta.dir, "..", "build")
869
869
  ]);
870
870
  if (!build)
871
871
  throw new Error("Could not locate build module");
@@ -880,7 +880,7 @@ console.log(\`
880
880
  process.stdout.write(cliTag3("\x1B[36m", "Bundling production server"));
881
881
  const serverBundle = await Bun.build({
882
882
  define: { "process.env.NODE_ENV": '"production"' },
883
- entrypoints: [resolve6(serverEntry)],
883
+ entrypoints: [resolve7(serverEntry)],
884
884
  external: FRAMEWORK_EXTERNALS,
885
885
  outdir: resolvedOutdir,
886
886
  plugins: [stubPlugin],
@@ -891,8 +891,8 @@ console.log(\`
891
891
  console.error(cliTag3("\x1B[31m", "Server bundle failed."));
892
892
  process.exit(1);
893
893
  }
894
- const outputPath = resolve6(resolvedOutdir, `${entryName}.js`);
895
- if (!existsSync8(outputPath)) {
894
+ const outputPath = resolve7(resolvedOutdir, `${entryName}.js`);
895
+ if (!existsSync9(outputPath)) {
896
896
  console.error(cliTag3("\x1B[31m", `Expected output not found: ${outputPath}`));
897
897
  process.exit(1);
898
898
  }
@@ -1032,8 +1032,8 @@ var exports_typecheck = {};
1032
1032
  __export(exports_typecheck, {
1033
1033
  typecheck: () => typecheck
1034
1034
  });
1035
- import { resolve as resolve7, join as join7 } from "path";
1036
- import { existsSync as existsSync9 } from "fs";
1035
+ import { resolve as resolve8, join as join7 } from "path";
1036
+ import { existsSync as existsSync10 } from "fs";
1037
1037
  import { mkdir as mkdir2, writeFile } from "fs/promises";
1038
1038
  var run = async (name, command) => {
1039
1039
  const proc = Bun.spawn(command, {
@@ -1047,8 +1047,8 @@ var run = async (name, command) => {
1047
1047
  const exitCode = await proc.exited;
1048
1048
  return { exitCode, name, output: (stdout + stderr).trim() };
1049
1049
  }, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
1050
- const local = resolve7("node_modules", ".bin", name);
1051
- return existsSync9(local) ? local : null;
1050
+ const local = resolve8("node_modules", ".bin", name);
1051
+ return existsSync10(local) ? local : null;
1052
1052
  }, stripAnsi = (str) => str.replace(/\x1b\[[0-9;]*m/g, ""), formatSvelteOutput = (output) => {
1053
1053
  const cwd = `${process.cwd()}/`;
1054
1054
  const summaryMatch = stripAnsi(output).match(/svelte-check found (\d+) error/);
@@ -1105,13 +1105,13 @@ Found ${errorCount} error${suffix}.`;
1105
1105
  rootDir: ".."
1106
1106
  },
1107
1107
  exclude: TYPECHECK_EXCLUDE,
1108
- extends: resolve7("tsconfig.json"),
1108
+ extends: resolve8("tsconfig.json"),
1109
1109
  include: TYPECHECK_INCLUDE
1110
1110
  }, null, "\t")).then(() => run("vue-tsc", [
1111
1111
  vueTscBin,
1112
1112
  "--noEmit",
1113
1113
  "--project",
1114
- resolve7(vueTsconfigPath),
1114
+ resolve8(vueTsconfigPath),
1115
1115
  "--incremental",
1116
1116
  "--tsBuildInfoFile",
1117
1117
  join7(cacheDir, "vue-tsc.tsbuildinfo"),
@@ -1133,10 +1133,10 @@ Found ${errorCount} error${suffix}.`;
1133
1133
  rootDir: ".."
1134
1134
  },
1135
1135
  exclude: TYPECHECK_EXCLUDE,
1136
- extends: resolve7("tsconfig.json"),
1136
+ extends: resolve8("tsconfig.json"),
1137
1137
  include: [`../${angularDir}/**/*`]
1138
1138
  }, null, "\t"));
1139
- return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve7(angularTsconfigPath))}`);
1139
+ return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve8(angularTsconfigPath))}`);
1140
1140
  }, buildTscCheck = (cacheDir) => {
1141
1141
  const tscBin = findBin("tsc");
1142
1142
  if (!tscBin) {
@@ -1149,13 +1149,13 @@ Found ${errorCount} error${suffix}.`;
1149
1149
  rootDir: ".."
1150
1150
  },
1151
1151
  exclude: TYPECHECK_EXCLUDE,
1152
- extends: resolve7("tsconfig.json"),
1152
+ extends: resolve8("tsconfig.json"),
1153
1153
  include: TYPECHECK_INCLUDE
1154
1154
  }, null, "\t")).then(() => run("tsc", [
1155
1155
  tscBin,
1156
1156
  "--noEmit",
1157
1157
  "--project",
1158
- resolve7(tscConfigPath),
1158
+ resolve8(tscConfigPath),
1159
1159
  "--incremental",
1160
1160
  "--tsBuildInfoFile",
1161
1161
  join7(cacheDir, "tsc.tsbuildinfo"),
@@ -1169,13 +1169,13 @@ Found ${errorCount} error${suffix}.`;
1169
1169
  }
1170
1170
  const svelteTsconfigPath = join7(cacheDir, "tsconfig.svelte-check.json");
1171
1171
  await writeFile(svelteTsconfigPath, JSON.stringify({
1172
- extends: resolve7("tsconfig.json"),
1172
+ extends: resolve8("tsconfig.json"),
1173
1173
  include: [`../${svelteDir}/**/*`]
1174
1174
  }, null, "\t"));
1175
1175
  return run("svelte-check", [
1176
1176
  svelteBin,
1177
1177
  "--tsconfig",
1178
- resolve7(svelteTsconfigPath),
1178
+ resolve8(svelteTsconfigPath),
1179
1179
  "--threshold",
1180
1180
  "error",
1181
1181
  "--compiler-warnings",
@@ -2375,12 +2375,245 @@ var start = async (serverEntry, outdir, configPath2) => {
2375
2375
  process.exit(exitCode);
2376
2376
  };
2377
2377
 
2378
+ // src/cli/scripts/workspace.ts
2379
+ init_constants();
2380
+ init_loadConfig();
2381
+ init_startupBanner();
2382
+ init_utils();
2383
+ import { existsSync as existsSync8 } from "fs";
2384
+ import { resolve as resolve6 } from "path";
2385
+ var serviceTag = (name, color) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[${name}]\x1B[0m`;
2386
+ var workspaceTag = (color, message) => `${serviceTag("workspace", color)} ${color}${message}\x1B[0m`;
2387
+ var sleep = (ms) => new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
2388
+ var ensureWorkspaceConfig = (config) => {
2389
+ if (!config.workspace?.services || Object.keys(config.workspace.services).length === 0) {
2390
+ throw new Error("absolute.config.ts is missing workspace.services. Add a workspace section before using `absolute workspace dev`.");
2391
+ }
2392
+ return config.workspace;
2393
+ };
2394
+ var resolveHealthcheck = (healthcheck) => {
2395
+ if (!healthcheck) {
2396
+ return null;
2397
+ }
2398
+ if (typeof healthcheck === "string") {
2399
+ return {
2400
+ intervalMs: 250,
2401
+ timeoutMs: 30000,
2402
+ url: healthcheck
2403
+ };
2404
+ }
2405
+ return {
2406
+ intervalMs: healthcheck.intervalMs ?? 250,
2407
+ timeoutMs: healthcheck.timeoutMs ?? 30000,
2408
+ url: healthcheck.url
2409
+ };
2410
+ };
2411
+ var waitForHealthcheck = async (name, healthcheck) => {
2412
+ const resolved = resolveHealthcheck(healthcheck);
2413
+ if (!resolved) {
2414
+ return;
2415
+ }
2416
+ const startedAt = Date.now();
2417
+ while (Date.now() - startedAt < resolved.timeoutMs) {
2418
+ try {
2419
+ const response = await fetch(resolved.url);
2420
+ if (response.ok) {
2421
+ console.log(workspaceTag("\x1B[32m", `${name} passed healthcheck ${resolved.url}`));
2422
+ return;
2423
+ }
2424
+ } catch {}
2425
+ await sleep(resolved.intervalMs);
2426
+ }
2427
+ throw new Error(`${name} did not become healthy within ${resolved.timeoutMs}ms (${resolved.url})`);
2428
+ };
2429
+ var topologicallySortServices = (services) => {
2430
+ const ordered = [];
2431
+ const visiting = new Set;
2432
+ const visited = new Set;
2433
+ const visit = (name) => {
2434
+ if (visited.has(name)) {
2435
+ return;
2436
+ }
2437
+ if (visiting.has(name)) {
2438
+ throw new Error(`workspace.services has a dependency cycle involving "${name}"`);
2439
+ }
2440
+ const service = services[name];
2441
+ if (!service) {
2442
+ throw new Error(`workspace.services references unknown service "${name}"`);
2443
+ }
2444
+ visiting.add(name);
2445
+ for (const dependency of service.dependsOn ?? []) {
2446
+ if (!services[dependency]) {
2447
+ throw new Error(`workspace.services.${name} depends on missing service "${dependency}"`);
2448
+ }
2449
+ visit(dependency);
2450
+ }
2451
+ visiting.delete(name);
2452
+ visited.add(name);
2453
+ ordered.push(name);
2454
+ };
2455
+ for (const name of Object.keys(services)) {
2456
+ visit(name);
2457
+ }
2458
+ return ordered;
2459
+ };
2460
+ var createLineForwarder = (name, color, dest) => {
2461
+ let buffer = "";
2462
+ return {
2463
+ push: (chunk) => {
2464
+ buffer += Buffer.from(chunk).toString();
2465
+ const lines = buffer.split(`
2466
+ `);
2467
+ buffer = lines.pop() ?? "";
2468
+ for (const line of lines) {
2469
+ dest.write(`${serviceTag(name, color)} ${line}
2470
+ `);
2471
+ }
2472
+ },
2473
+ flush: () => {
2474
+ if (!buffer) {
2475
+ return;
2476
+ }
2477
+ dest.write(`${serviceTag(name, color)} ${buffer}
2478
+ `);
2479
+ buffer = "";
2480
+ }
2481
+ };
2482
+ };
2483
+ var pipeProcessLogs = (name, processHandle) => {
2484
+ const stdoutForwarder = createLineForwarder(name, "\x1B[36m", process.stdout);
2485
+ const stderrForwarder = createLineForwarder(name, "\x1B[31m", process.stderr);
2486
+ const forward = async (stream, forwarder) => {
2487
+ const reader = stream.getReader();
2488
+ try {
2489
+ while (true) {
2490
+ const { done, value } = await reader.read();
2491
+ if (done) {
2492
+ break;
2493
+ }
2494
+ if (value) {
2495
+ forwarder.push(value);
2496
+ }
2497
+ }
2498
+ } finally {
2499
+ forwarder.flush();
2500
+ reader.releaseLock();
2501
+ }
2502
+ };
2503
+ forward(processHandle.stdout, stdoutForwarder);
2504
+ forward(processHandle.stderr, stderrForwarder);
2505
+ };
2506
+ var resolveService = (name, service, options) => {
2507
+ const cwd = resolve6(service.cwd ?? ".");
2508
+ const env3 = {
2509
+ ...process.env,
2510
+ ...service.env,
2511
+ FORCE_COLOR: "1",
2512
+ NODE_ENV: "development"
2513
+ };
2514
+ if (service.port && !env3.PORT) {
2515
+ env3.PORT = String(service.port);
2516
+ }
2517
+ if (service.kind === "absolute") {
2518
+ const configPath2 = service.config ? resolve6(cwd, service.config) : options.configPath ? resolve6(options.configPath) : process.env.ABSOLUTE_CONFIG ? resolve6(process.env.ABSOLUTE_CONFIG) : undefined;
2519
+ if (configPath2) {
2520
+ env3.ABSOLUTE_CONFIG = configPath2;
2521
+ }
2522
+ const command = [
2523
+ process.execPath,
2524
+ "--hot",
2525
+ "--no-clear-screen",
2526
+ service.entry ?? DEFAULT_SERVER_ENTRY
2527
+ ];
2528
+ return {
2529
+ command,
2530
+ configPath: configPath2,
2531
+ cwd,
2532
+ env: env3,
2533
+ name,
2534
+ service
2535
+ };
2536
+ }
2537
+ return {
2538
+ command: service.command,
2539
+ cwd,
2540
+ env: env3,
2541
+ name,
2542
+ service
2543
+ };
2544
+ };
2545
+ var workspace = async (subcommand, options) => {
2546
+ if (subcommand !== "dev") {
2547
+ throw new Error(subcommand ? `Unknown workspace command: ${subcommand}` : "No workspace subcommand specified. Use `absolute workspace dev`.");
2548
+ }
2549
+ const config = await loadConfig(options.configPath);
2550
+ const workspaceConfig = ensureWorkspaceConfig(config);
2551
+ const orderedNames = topologicallySortServices(workspaceConfig.services);
2552
+ const running = [];
2553
+ let shuttingDown = false;
2554
+ const shutdown = async (exitCode = 0) => {
2555
+ if (shuttingDown) {
2556
+ return;
2557
+ }
2558
+ shuttingDown = true;
2559
+ for (const service of running) {
2560
+ try {
2561
+ service.process.kill();
2562
+ } catch {}
2563
+ }
2564
+ await Promise.all(running.map((service) => service.process.exited));
2565
+ process.exit(exitCode);
2566
+ };
2567
+ process.on("SIGINT", () => {
2568
+ shutdown(0);
2569
+ });
2570
+ process.on("SIGTERM", () => {
2571
+ shutdown(0);
2572
+ });
2573
+ console.log(workspaceTag("\x1B[36m", `Starting workspace services: ${orderedNames.join(", ")}`));
2574
+ for (const name of orderedNames) {
2575
+ const service = workspaceConfig.services[name];
2576
+ if (!service) {
2577
+ throw new Error(`workspace.services is missing "${name}"`);
2578
+ }
2579
+ const resolved = resolveService(name, service, options);
2580
+ const port = (resolved.service.port ?? Number(resolved.env.PORT ?? "")) || DEFAULT_PORT;
2581
+ if (port > 0) {
2582
+ killStaleProcesses(port);
2583
+ }
2584
+ if (resolved.service.kind === "absolute" && resolved.configPath && !existsSync8(resolved.configPath)) {
2585
+ throw new Error(`${name} references missing config "${resolved.configPath}"`);
2586
+ }
2587
+ console.log(workspaceTag("\x1B[36m", `Starting ${name}: ${resolved.command.join(" ")}`));
2588
+ const processHandle = Bun.spawn(resolved.command, {
2589
+ cwd: resolved.cwd,
2590
+ env: resolved.env,
2591
+ stderr: "pipe",
2592
+ stdin: "ignore",
2593
+ stdout: "pipe"
2594
+ });
2595
+ running.push({ name, process: processHandle });
2596
+ pipeProcessLogs(name, processHandle);
2597
+ processHandle.exited.then((exitCode) => {
2598
+ if (shuttingDown) {
2599
+ return;
2600
+ }
2601
+ console.error(workspaceTag("\x1B[31m", `${name} exited with code ${exitCode}. Shutting down workspace.`));
2602
+ shutdown(exitCode || 1);
2603
+ });
2604
+ await waitForHealthcheck(name, resolved.service.healthcheck);
2605
+ }
2606
+ console.log(workspaceTag("\x1B[32m", `Workspace ready with ${running.length} services.`));
2607
+ await Promise.all(running.map((service) => service.process.exited));
2608
+ };
2609
+
2378
2610
  // src/cli/index.ts
2379
2611
  init_telemetry();
2380
2612
  init_telemetryEvent();
2381
2613
  init_constants();
2382
2614
  init_utils();
2383
2615
  var [command] = process.argv.slice(2);
2616
+ var [workspaceCommand] = process.argv.slice(3);
2384
2617
  var args = process.argv.slice(CLI_ARGS_OFFSET);
2385
2618
  var parseNamedArg = (flag) => {
2386
2619
  const idx = args.indexOf(flag);
@@ -2407,6 +2640,12 @@ if (command === "dev") {
2407
2640
  const positionalArgs = stripNamedArgs("--outdir", "--config");
2408
2641
  const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
2409
2642
  await start(serverEntry, outdir, configPath2);
2643
+ } else if (command === "workspace") {
2644
+ sendTelemetryEvent("cli:command", {
2645
+ command: `workspace:${workspaceCommand ?? "unknown"}`
2646
+ });
2647
+ const configPath2 = parseNamedArg("--config");
2648
+ await workspace(workspaceCommand, { configPath: configPath2 });
2410
2649
  } else if (command === "eslint") {
2411
2650
  sendTelemetryEvent("cli:command", { command });
2412
2651
  await eslint(args);
@@ -2443,6 +2682,7 @@ if (command === "dev") {
2443
2682
  console.error("Usage: absolute <command>");
2444
2683
  console.error("Commands:");
2445
2684
  console.error(" dev [entry] Start development server");
2685
+ console.error(" workspace dev Start multi-service workspace dev");
2446
2686
  console.error(" start [entry] [--outdir dir] Start production server");
2447
2687
  console.error(" compile [entry] [--outdir dir] [--outfile path] Compile standalone executable");
2448
2688
  console.error(" eslint Run ESLint (cached)");
package/dist/index.js CHANGED
@@ -174803,7 +174803,7 @@ ${registrations}
174803
174803
  ({ tsLibDir } = cached);
174804
174804
  cached.lastUsed = Date.now();
174805
174805
  } else {
174806
- const tsPath = __require.resolve("typescript");
174806
+ const tsPath = __require.resolve("/home/alexkahn/abs/absolutejs/node_modules/typescript/lib/typescript.js");
174807
174807
  const tsRootDir = dirname9(tsPath);
174808
174808
  tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve18(tsRootDir, "lib");
174809
174809
  const config = readConfiguration("./tsconfig.json");
@@ -188795,5 +188795,5 @@ export {
188795
188795
  ANGULAR_INIT_TIMEOUT_MS
188796
188796
  };
188797
188797
 
188798
- //# debugId=3CA14FD87FDA4FFC64756E2164756E21
188798
+ //# debugId=3C96D67450CFBA3764756E2164756E21
188799
188799
  //# sourceMappingURL=index.js.map