ecopages 0.2.0-beta.6 → 0.2.0-beta.8

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.
Files changed (2) hide show
  1. package/bin/launch-plan.js +26 -2
  2. package/package.json +2 -2
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { parseEnv } from "node:util";
4
4
  import { SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from "@ecopages/core/utils/resolve-entry-file";
5
+ const SERVER_BUNDLE_MANIFEST_FILENAME = "manifest.json";
5
6
  const nodeRequirePreload = import.meta.resolve("./node-require-preload.js");
6
7
  const tsxLoader = import.meta.resolve("tsx/esm");
7
8
  function getEnvFilePaths(nodeEnv) {
@@ -76,15 +77,38 @@ function inferLaunchMode(args, launchMode) {
76
77
  }
77
78
  return "start";
78
79
  }
80
+ function resolveProductionServerEntry(cwd = process.cwd()) {
81
+ const manifestPath = path.join(cwd, "dist", SERVER_BUNDLE_DIR, SERVER_BUNDLE_MANIFEST_FILENAME);
82
+ if (existsSync(manifestPath)) {
83
+ try {
84
+ const parsed = JSON.parse(readFileSync(manifestPath, "utf8"));
85
+ if (parsed?.serverEntry) {
86
+ const fromManifest = path.isAbsolute(parsed.serverEntry) ? parsed.serverEntry : path.join(path.dirname(manifestPath), parsed.serverEntry);
87
+ if (existsSync(fromManifest)) {
88
+ return fromManifest;
89
+ }
90
+ }
91
+ if (parsed?.distDir) {
92
+ const fromDistDir = path.join(parsed.distDir, SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME);
93
+ if (existsSync(fromDistDir)) {
94
+ return fromDistDir;
95
+ }
96
+ }
97
+ } catch {
98
+ }
99
+ }
100
+ const legacyPath = path.join(cwd, "dist", SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME);
101
+ return existsSync(legacyPath) ? legacyPath : void 0;
102
+ }
79
103
  function createLaunchPlan(args, options, entryFile, launchMode) {
80
104
  const resolvedOptions = options ?? {};
81
105
  const resolvedEntryFile = entryFile ?? "app.ts";
82
106
  const { envOverrides, env } = buildLaunchEnv(resolvedOptions);
83
107
  const runtime = detectRuntime(resolvedOptions);
84
108
  const resolvedLaunchMode = inferLaunchMode(args, launchMode);
85
- const distServerApp = path.join(process.cwd(), "dist", SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME);
109
+ const distServerApp = resolveProductionServerEntry(process.cwd());
86
110
  const shouldUseBundle = usesProductionBundle(resolvedLaunchMode);
87
- const useBundle = shouldUseBundle && existsSync(distServerApp);
111
+ const useBundle = shouldUseBundle && Boolean(distServerApp);
88
112
  if (shouldUseBundle && !useBundle) {
89
113
  throw new Error("No production bundle found. Run `ecopages build` before starting in production mode.");
90
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecopages",
3
- "version": "0.2.0-beta.6",
3
+ "version": "0.2.0-beta.8",
4
4
  "description": "CLI utilities for Ecopages",
5
5
  "type": "module",
6
6
  "engines": {
@@ -32,7 +32,7 @@
32
32
  "ecopages": "bin/cli.js"
33
33
  },
34
34
  "dependencies": {
35
- "@ecopages/core": "0.2.0-beta.6",
35
+ "@ecopages/core": "0.2.0-beta.8",
36
36
  "@ecopages/logger": "^0.2.3",
37
37
  "giget": "^2.0.0",
38
38
  "tsx": "^4.22.3"