@absolutejs/absolute 0.17.2 → 0.17.3

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
@@ -948,6 +948,82 @@ var prettier = async (args) => {
948
948
  await runTool(prettierAdapter, args);
949
949
  };
950
950
 
951
+ // src/cli/scripts/start.ts
952
+ var {env: env2 } = globalThis.Bun;
953
+ import { existsSync as existsSync5 } from "fs";
954
+ import { basename, resolve as resolve5 } from "path";
955
+ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
956
+ var start = async (serverEntry) => {
957
+ const port = Number(env2.PORT) || DEFAULT_PORT;
958
+ killStaleProcesses(port);
959
+ const entryName = basename(serverEntry).replace(/\.[^.]+$/, "");
960
+ const outdir = resolve5("dist/server");
961
+ console.log(cliTag2("\x1B[36m", `Building ${serverEntry}...`));
962
+ const buildProc = Bun.spawn(["bun", "build", serverEntry, "--target=bun", `--outdir=${outdir}`], {
963
+ cwd: process.cwd(),
964
+ stdout: "inherit",
965
+ stderr: "inherit"
966
+ });
967
+ const buildExit = await buildProc.exited;
968
+ if (buildExit !== 0) {
969
+ console.error(cliTag2("\x1B[31m", "Build failed."));
970
+ process.exit(buildExit);
971
+ }
972
+ const outputPath = resolve5(outdir, `${entryName}.js`);
973
+ if (!existsSync5(outputPath)) {
974
+ console.error(cliTag2("\x1B[31m", `Expected output not found: ${outputPath}`));
975
+ process.exit(1);
976
+ }
977
+ const usesDocker = existsSync5(resolve5(COMPOSE_PATH));
978
+ const scripts = usesDocker ? await readDbScripts() : null;
979
+ if (scripts)
980
+ await startDatabase(scripts);
981
+ let cleaning = false;
982
+ const sessionStart = Date.now();
983
+ sendTelemetryEvent("start:start", { entry: serverEntry });
984
+ console.log(cliTag2("\x1B[32m", `Starting production server...`));
985
+ const serverProcess = Bun.spawn(["bun", "run", outputPath], {
986
+ cwd: process.cwd(),
987
+ env: {
988
+ ...process.env,
989
+ FORCE_COLOR: "1",
990
+ NODE_ENV: "production"
991
+ },
992
+ stdin: "inherit",
993
+ stdout: "inherit",
994
+ stderr: "inherit"
995
+ });
996
+ const cleanup = async (exitCode2 = 0) => {
997
+ if (cleaning)
998
+ return;
999
+ cleaning = true;
1000
+ sendTelemetryEvent("start:session-duration", {
1001
+ duration: Math.round((Date.now() - sessionStart) / 1000),
1002
+ entry: serverEntry
1003
+ });
1004
+ try {
1005
+ serverProcess.kill();
1006
+ } catch {}
1007
+ await serverProcess.exited;
1008
+ if (scripts)
1009
+ await stopDatabase(scripts);
1010
+ process.exit(exitCode2);
1011
+ };
1012
+ process.on("SIGINT", () => cleanup(0));
1013
+ process.on("SIGTERM", () => cleanup(0));
1014
+ const exitCode = await serverProcess.exited;
1015
+ if (!cleaning) {
1016
+ console.error(cliTag2("\x1B[31m", `Server exited with code ${exitCode}.`));
1017
+ sendTelemetryEvent("start:server-exit", {
1018
+ exitCode,
1019
+ entry: serverEntry
1020
+ });
1021
+ if (scripts)
1022
+ await stopDatabase(scripts);
1023
+ process.exit(exitCode);
1024
+ }
1025
+ };
1026
+
951
1027
  // src/cli/index.ts
952
1028
  var command = process.argv[2];
953
1029
  var args = process.argv.slice(3);
@@ -955,6 +1031,10 @@ if (command === "dev") {
955
1031
  sendTelemetryEvent("cli:command", { command });
956
1032
  const serverEntry = args[0] ?? DEFAULT_SERVER_ENTRY;
957
1033
  await dev(serverEntry);
1034
+ } else if (command === "start") {
1035
+ sendTelemetryEvent("cli:command", { command });
1036
+ const serverEntry = args[0] ?? DEFAULT_SERVER_ENTRY;
1037
+ await start(serverEntry);
958
1038
  } else if (command === "eslint") {
959
1039
  sendTelemetryEvent("cli:command", { command });
960
1040
  await eslint(args);
@@ -973,6 +1053,7 @@ if (command === "dev") {
973
1053
  console.error("Usage: absolute <command>");
974
1054
  console.error("Commands:");
975
1055
  console.error(" dev [entry] Start development server");
1056
+ console.error(" start [entry] Start production server");
976
1057
  console.error(" eslint Run ESLint (cached)");
977
1058
  console.error(" info Print system info for bug reports");
978
1059
  console.error(" prettier Run Prettier check (cached)");
package/dist/index.js CHANGED
@@ -200162,6 +200162,19 @@ var build2 = async ({
200162
200162
  }) => {
200163
200163
  const buildStart = performance.now();
200164
200164
  const projectRoot = cwd();
200165
+ const versionCandidates = [
200166
+ resolve8(import.meta.dir, "..", "..", "package.json"),
200167
+ resolve8(import.meta.dir, "..", "package.json")
200168
+ ];
200169
+ for (const candidate of versionCandidates) {
200170
+ try {
200171
+ const pkg = await Bun.file(candidate).json();
200172
+ if (pkg.name === "@absolutejs/absolute") {
200173
+ globalThis.__absoluteVersion = pkg.version;
200174
+ break;
200175
+ }
200176
+ } catch {}
200177
+ }
200165
200178
  const isIncremental = incrementalFiles && incrementalFiles.length > 0;
200166
200179
  const normalizedIncrementalFiles = incrementalFiles?.map(normalizePath);
200167
200180
  const throwOnError = options?.throwOnError === true;
@@ -200595,8 +200608,8 @@ var build2 = async ({
200595
200608
  svelteDir,
200596
200609
  vueDir
200597
200610
  });
200598
- if (!isIncremental && !options?.injectHMR) {
200599
- console.log(`Build completed in ${getDurationString(performance.now() - buildStart)}`);
200611
+ if (!isIncremental) {
200612
+ globalThis.__hmrBuildDuration = performance.now() - buildStart;
200600
200613
  }
200601
200614
  sendTelemetryEvent("build:complete", {
200602
200615
  frameworks: frameworkNames,
@@ -202446,5 +202459,5 @@ export {
202446
202459
  BUN_BUILD_WARNING_SUPPRESSION
202447
202460
  };
202448
202461
 
202449
- //# debugId=C7A98673D8CCBF2964756E2164756E21
202462
+ //# debugId=31BD2065A6F0A47664756E2164756E21
202450
202463
  //# sourceMappingURL=index.js.map