@absolutejs/absolute 0.19.0-beta.1126 → 0.19.0-beta.1127

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
@@ -181163,7 +181163,108 @@ var prerenderStaticPages = async (outputPath, prerenderPort, resolvedOutdir, sta
181163
181163
  console.error(err);
181164
181164
  }
181165
181165
  };
181166
- var start = async (serverEntry, outdir, configPath2) => {
181166
+ var runPreparedServer = async ({
181167
+ absoluteVersion,
181168
+ bundleDurationMs,
181169
+ configPath: configPath2,
181170
+ frameworks: frameworks2,
181171
+ outdir,
181172
+ outputPath,
181173
+ port,
181174
+ prebuilt,
181175
+ resolvedOutdir,
181176
+ serverEntry,
181177
+ totalDuration
181178
+ }) => {
181179
+ const usesDocker = existsSync8(resolve8(COMPOSE_PATH));
181180
+ const scripts = usesDocker ? await readDbScripts() : null;
181181
+ if (scripts)
181182
+ await startDatabase(scripts);
181183
+ let cleaning = false;
181184
+ const sessionStart = Date.now();
181185
+ sendTelemetryEvent("start:start", {
181186
+ buildDurationMs: Math.max(0, Math.round(totalDuration) - bundleDurationMs),
181187
+ bundleDurationMs,
181188
+ entry: serverEntry,
181189
+ frameworks: frameworks2,
181190
+ totalDurationMs: Math.round(totalDuration)
181191
+ });
181192
+ const serverProcess = Bun.spawn(["bun", "run", outputPath], {
181193
+ cwd: process.cwd(),
181194
+ env: {
181195
+ ...process.env,
181196
+ ABSOLUTE_BUILD_DIR: resolvedOutdir,
181197
+ ABSOLUTE_BUILD_DURATION: String(Math.round(totalDuration)),
181198
+ ABSOLUTE_INSTANCE_MANAGED: "1",
181199
+ ABSOLUTE_VERSION: absoluteVersion,
181200
+ FORCE_COLOR: "1",
181201
+ NODE_ENV: "production",
181202
+ ...configPath2 ? { ABSOLUTE_CONFIG: configPath2 } : {}
181203
+ },
181204
+ stderr: "inherit",
181205
+ stdin: "inherit",
181206
+ stdout: "inherit"
181207
+ });
181208
+ const relaunchCommand = [
181209
+ process.execPath,
181210
+ process.argv[1] ?? "",
181211
+ "start",
181212
+ serverEntry,
181213
+ ...outdir ? ["--outdir", outdir] : [],
181214
+ ...configPath2 ? ["--config", configPath2] : [],
181215
+ ...prebuilt ? ["--prebuilt"] : []
181216
+ ].filter((part) => part.length > 0);
181217
+ registerInstance({
181218
+ command: relaunchCommand,
181219
+ configPath: configPath2 ?? null,
181220
+ controllerPid: process.pid,
181221
+ cwd: process.cwd(),
181222
+ frameworks: frameworks2,
181223
+ host: env2.ABSOLUTE_HOST ?? env2.HOST ?? "localhost",
181224
+ https: env2.ABSOLUTE_HTTPS === "true",
181225
+ logFile: null,
181226
+ name: resolveProjectName(process.cwd()),
181227
+ pid: process.pid,
181228
+ port,
181229
+ ppid: process.ppid,
181230
+ source: "start",
181231
+ startedAt: new Date().toISOString()
181232
+ });
181233
+ const cleanup = async (exitCode2 = 0) => {
181234
+ if (cleaning)
181235
+ return;
181236
+ cleaning = true;
181237
+ deregisterInstance(process.pid);
181238
+ sendTelemetryEvent("start:session-duration", {
181239
+ duration: Math.round((Date.now() - sessionStart) / MILLISECONDS_IN_A_SECOND),
181240
+ entry: serverEntry
181241
+ });
181242
+ try {
181243
+ serverProcess.kill();
181244
+ } catch {}
181245
+ await serverProcess.exited;
181246
+ if (scripts)
181247
+ await stopDatabase(scripts);
181248
+ process.exit(exitCode2);
181249
+ };
181250
+ process.on("SIGINT", () => cleanup(0));
181251
+ process.on("SIGTERM", () => cleanup(0));
181252
+ const exitCode = await serverProcess.exited;
181253
+ if (cleaning)
181254
+ return;
181255
+ console.error(cliTag2("\x1B[31m", `Server exited with code ${exitCode}.`));
181256
+ sendTelemetryEvent("start:server-exit", {
181257
+ entry: serverEntry,
181258
+ exitCode
181259
+ });
181260
+ if (scripts)
181261
+ await stopDatabase(scripts);
181262
+ process.exit(exitCode);
181263
+ };
181264
+ var start = async (serverEntry, outdir, configPath2, options = {}) => {
181265
+ if (options.prebuilt && options.prepareOnly) {
181266
+ throw new Error("A production start cannot be prebuilt and prepare-only.");
181267
+ }
181167
181268
  const port = Number(env2.PORT) || DEFAULT_PORT;
181168
181269
  killStaleProcesses(port);
181169
181270
  const entryName = basename3(serverEntry).replace(/\.[^.]+$/, "");
@@ -181172,8 +181273,6 @@ var start = async (serverEntry, outdir, configPath2) => {
181172
181273
  resolve8(import.meta.dir, "..", "..", "..", "package.json"),
181173
181274
  resolve8(import.meta.dir, "..", "..", "package.json")
181174
181275
  ]);
181175
- const buildStepStart = performance.now();
181176
- process.stdout.write(cliTag2("\x1B[36m", `Building assets`));
181177
181276
  const buildConfig = await loadConfig(configPath2);
181178
181277
  buildConfig.buildDirectory = resolvedOutdir;
181179
181278
  buildConfig.mode = "production";
@@ -181185,6 +181284,27 @@ var start = async (serverEntry, outdir, configPath2) => {
181185
181284
  buildConfig.vueDirectory && "vue",
181186
181285
  buildConfig.angularDirectory && "angular"
181187
181286
  ].filter((val) => Boolean(val));
181287
+ const outputPath = resolve8(resolvedOutdir, `${entryName}.js`);
181288
+ if (options.prebuilt) {
181289
+ if (!existsSync8(outputPath)) {
181290
+ throw new Error(`Prepared production server not found: ${outputPath}`);
181291
+ }
181292
+ return runPreparedServer({
181293
+ absoluteVersion,
181294
+ bundleDurationMs: 0,
181295
+ configPath: configPath2,
181296
+ frameworks: frameworks2,
181297
+ outdir,
181298
+ outputPath,
181299
+ port,
181300
+ prebuilt: true,
181301
+ resolvedOutdir,
181302
+ serverEntry,
181303
+ totalDuration: 0
181304
+ });
181305
+ }
181306
+ const buildStepStart = performance.now();
181307
+ process.stdout.write(cliTag2("\x1B[36m", `Building assets`));
181188
181308
  try {
181189
181309
  const build = await resolveBuildModule([
181190
181310
  resolve8(import.meta.dir, "..", "..", "core", "build"),
@@ -181287,7 +181407,6 @@ var start = async (serverEntry, outdir, configPath2) => {
181287
181407
  if (!serverBundle.success) {
181288
181408
  handleBundleFailure(serverBundle, bundleStart, serverEntry);
181289
181409
  }
181290
- const outputPath = resolve8(resolvedOutdir, `${entryName}.js`);
181291
181410
  if (!existsSync8(outputPath)) {
181292
181411
  console.error(cliTag2("\x1B[31m", `Expected output not found: ${outputPath}`));
181293
181412
  process.exit(1);
@@ -181322,91 +181441,27 @@ var start = async (serverEntry, outdir, configPath2) => {
181322
181441
  if (buildConfig.static) {
181323
181442
  await prerenderStaticPages(outputPath, port + 1, resolvedOutdir, buildConfig.static, absoluteVersion, configPath2);
181324
181443
  }
181325
- const usesDocker = existsSync8(resolve8(COMPOSE_PATH));
181326
- const scripts = usesDocker ? await readDbScripts() : null;
181327
- if (scripts)
181328
- await startDatabase(scripts);
181329
- let cleaning = false;
181330
- const sessionStart = Date.now();
181331
181444
  const totalDuration = performance.now() - buildStepStart;
181332
- sendTelemetryEvent("start:start", {
181333
- buildDurationMs: Math.round(performance.now() - buildStepStart) - bundleDurationMs,
181334
- bundleDurationMs,
181335
- entry: serverEntry,
181336
- frameworks: frameworks2,
181337
- totalDurationMs: Math.round(totalDuration)
181338
- });
181339
- const serverProcess = Bun.spawn(["bun", "run", outputPath], {
181340
- cwd: process.cwd(),
181341
- env: {
181342
- ...process.env,
181343
- ABSOLUTE_BUILD_DIR: resolvedOutdir,
181344
- ABSOLUTE_BUILD_DURATION: String(Math.round(totalDuration)),
181345
- ABSOLUTE_INSTANCE_MANAGED: "1",
181346
- ABSOLUTE_VERSION: absoluteVersion,
181347
- FORCE_COLOR: "1",
181348
- NODE_ENV: "production",
181349
- ...configPath2 ? { ABSOLUTE_CONFIG: configPath2 } : {}
181350
- },
181351
- stderr: "inherit",
181352
- stdin: "inherit",
181353
- stdout: "inherit"
181354
- });
181355
- const relaunchCommand = [
181356
- process.execPath,
181357
- process.argv[1] ?? "",
181358
- "start",
181359
- serverEntry,
181360
- ...outdir ? ["--outdir", outdir] : [],
181361
- ...configPath2 ? ["--config", configPath2] : []
181362
- ].filter((part) => part.length > 0);
181363
- registerInstance({
181364
- command: relaunchCommand,
181365
- configPath: configPath2 ?? null,
181366
- controllerPid: process.pid,
181367
- cwd: process.cwd(),
181368
- frameworks: frameworks2,
181369
- host: env2.ABSOLUTE_HOST ?? env2.HOST ?? "localhost",
181370
- https: env2.ABSOLUTE_HTTPS === "true",
181371
- logFile: null,
181372
- name: resolveProjectName(process.cwd()),
181373
- pid: process.pid,
181374
- port,
181375
- ppid: process.ppid,
181376
- source: "start",
181377
- startedAt: new Date().toISOString()
181378
- });
181379
- const cleanup = async (exitCode2 = 0) => {
181380
- if (cleaning)
181381
- return;
181382
- cleaning = true;
181383
- deregisterInstance(process.pid);
181384
- sendTelemetryEvent("start:session-duration", {
181385
- duration: Math.round((Date.now() - sessionStart) / MILLISECONDS_IN_A_SECOND),
181445
+ if (options.prepareOnly) {
181446
+ sendTelemetryEvent("prepare:complete", {
181447
+ durationMs: Math.round(totalDuration),
181386
181448
  entry: serverEntry
181387
181449
  });
181388
- try {
181389
- serverProcess.kill();
181390
- } catch {}
181391
- await serverProcess.exited;
181392
- if (scripts)
181393
- await stopDatabase(scripts);
181394
- process.exit(exitCode2);
181395
- };
181396
- process.on("SIGINT", () => cleanup(0));
181397
- process.on("SIGTERM", () => cleanup(0));
181398
- const exitCode = await serverProcess.exited;
181399
- if (cleaning) {
181400
181450
  return;
181401
181451
  }
181402
- console.error(cliTag2("\x1B[31m", `Server exited with code ${exitCode}.`));
181403
- sendTelemetryEvent("start:server-exit", {
181404
- entry: serverEntry,
181405
- exitCode
181452
+ return runPreparedServer({
181453
+ absoluteVersion,
181454
+ bundleDurationMs,
181455
+ configPath: configPath2,
181456
+ frameworks: frameworks2,
181457
+ outdir,
181458
+ outputPath,
181459
+ port,
181460
+ prebuilt: false,
181461
+ resolvedOutdir,
181462
+ serverEntry,
181463
+ totalDuration
181406
181464
  });
181407
- if (scripts)
181408
- await stopDatabase(scripts);
181409
- process.exit(exitCode);
181410
181465
  };
181411
181466
 
181412
181467
  // src/cli/scripts/workspace.ts
@@ -182794,12 +182849,21 @@ if (command === "dev") {
182794
182849
  const serverEntry = positionalArgs2[0] ?? DEFAULT_SERVER_ENTRY;
182795
182850
  await dev(serverEntry, configPath2);
182796
182851
  } else if (command === "start") {
182852
+ sendTelemetryEvent("cli:command", { command });
182853
+ const outdir = parseNamedArg("--outdir");
182854
+ const configPath2 = parseNamedArg("--config");
182855
+ const positionalArgs2 = stripNamedArgs("--outdir", "--config").filter((arg) => arg !== "--prebuilt");
182856
+ const serverEntry = positionalArgs2[0] ?? DEFAULT_SERVER_ENTRY;
182857
+ await start(serverEntry, outdir, configPath2, {
182858
+ prebuilt: args.includes("--prebuilt")
182859
+ });
182860
+ } else if (command === "prepare") {
182797
182861
  sendTelemetryEvent("cli:command", { command });
182798
182862
  const outdir = parseNamedArg("--outdir");
182799
182863
  const configPath2 = parseNamedArg("--config");
182800
182864
  const positionalArgs2 = stripNamedArgs("--outdir", "--config");
182801
182865
  const serverEntry = positionalArgs2[0] ?? DEFAULT_SERVER_ENTRY;
182802
- await start(serverEntry, outdir, configPath2);
182866
+ await start(serverEntry, outdir, configPath2, { prepareOnly: true });
182803
182867
  } else if (command === "build") {
182804
182868
  sendTelemetryEvent("cli:command", { command });
182805
182869
  const outdir = parseNamedArg("--outdir");
@@ -182932,7 +182996,8 @@ if (command === "dev") {
182932
182996
  console.error(" dev [entry] Start development server");
182933
182997
  console.error(" workspace dev [--no-tui] Start multi-service workspace dev");
182934
182998
  console.error(" build [--outdir dir] [--profile] Build production assets");
182935
- console.error(" start [entry] [--outdir dir] Start production server");
182999
+ console.error(" prepare [entry] [--outdir dir] Build production assets and server without launching");
183000
+ console.error(" start [entry] [--outdir dir] [--prebuilt] Start production server");
182936
183001
  console.error(" compile [entry] [--outdir dir] [--outfile path] Compile standalone executable");
182937
183002
  console.error(" config [--port n] Open the unified config UI (ESLint, tsconfig, Prettier)");
182938
183003
  console.error(" db <backup|restore|seed> Backup/restore any Postgres DB (ORM-agnostic, upsert by PK) or run the seed script");
package/dist/index.js CHANGED
@@ -21582,8 +21582,8 @@ var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY, OPTIMIZATION_END
21582
21582
  const device = config2?.deviceSizes ?? DEFAULT_DEVICE_SIZES;
21583
21583
  const image2 = config2?.imageSizes ?? DEFAULT_IMAGE_SIZES;
21584
21584
  return [...device, ...image2].sort((left, right) => left - right);
21585
- }, getCacheDir = (buildDir) => {
21586
- const dir = join20(buildDir, ".cache", "images");
21585
+ }, getCacheDir = (buildDir, cacheDirectory) => {
21586
+ const dir = cacheDirectory ? resolve16(cacheDirectory) : join20(buildDir, ".cache", "images");
21587
21587
  if (!existsSync17(dir))
21588
21588
  mkdirSync3(dir, { recursive: true });
21589
21589
  return dir;
@@ -39399,7 +39399,7 @@ var DEFAULT_CACHE_TTL_SECONDS = 60, MS_PER_SECOND = 1000, MAX_QUALITY = 100, avi
39399
39399
  const cacheControlHeader = `public, max-age=${Math.ceil(minimumCacheTTL / MS_PER_SECOND)}, must-revalidate`;
39400
39400
  const configuredFormats = config2?.formats ?? ["webp"];
39401
39401
  const remotePatterns = config2?.remotePatterns ?? [];
39402
- const cacheDir = getCacheDir(buildDir);
39402
+ const cacheDir = getCacheDir(buildDir, config2?.cacheDirectory);
39403
39403
  return plugin.get(endpointPath, async ({ query, request }) => {
39404
39404
  const parsed = parseQueryParams(query, allowedSizes, defaultQuality);
39405
39405
  if ("error" in parsed)
@@ -48043,5 +48043,5 @@ export {
48043
48043
  ANGULAR_INIT_TIMEOUT_MS
48044
48044
  };
48045
48045
 
48046
- //# debugId=84966EED2C28538064756E2164756E21
48046
+ //# debugId=C88B0B763C496EAA64756E2164756E21
48047
48047
  //# sourceMappingURL=index.js.map