@flight-framework/cli 0.4.8 → 0.4.10

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/bin.js CHANGED
@@ -510,7 +510,7 @@ Happy flying!
510
510
  }
511
511
 
512
512
  // src/commands/dev.ts
513
- import { resolve as resolve3, join as join3, relative } from "path";
513
+ import { resolve as resolve3, join as join3 } from "path";
514
514
  import { readFileSync as readFileSync3, existsSync as existsSync3 } from "fs";
515
515
  import { consola as consola2 } from "consola";
516
516
  import { loadConfig } from "@flight-framework/core/config";
@@ -914,114 +914,6 @@ async function devCommand(options) {
914
914
  if (bundler && typeof bundler.createDevServer === "function") {
915
915
  consola2.info(`Using bundler: ${bundler.name || bundler.bundler || "custom"}`);
916
916
  const devServer = await bundler.createDevServer(config);
917
- const transformPort = devServer.port;
918
- const http = await import("http");
919
- const fs = await import("fs/promises");
920
- const path = await import("path");
921
- const { createRequire } = await import("module");
922
- const indexHtmlPath = path.join(root, "index.html");
923
- const publicIndexPath = path.join(root, "public", "index.html");
924
- const require2 = createRequire(root + "/");
925
- const server = http.createServer(async (req, res) => {
926
- const url = req.url || "/";
927
- const isSpaRoute = url === "/" || url === "/index.html" || !url.includes(".") && !url.startsWith("/@") && !url.startsWith("/__") && !url.startsWith("/src/") && !url.startsWith("/node_modules/");
928
- if (isSpaRoute) {
929
- try {
930
- let htmlContent;
931
- try {
932
- htmlContent = await fs.readFile(indexHtmlPath, "utf-8");
933
- } catch {
934
- htmlContent = await fs.readFile(publicIndexPath, "utf-8");
935
- }
936
- if (!htmlContent.includes("/__flightpack/hmr-runtime.js")) {
937
- htmlContent = htmlContent.replace(
938
- "</body>",
939
- `<script src="/__flightpack/hmr-runtime.js"></script>
940
- </body>`
941
- );
942
- }
943
- res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
944
- res.end(htmlContent);
945
- } catch (err) {
946
- res.writeHead(404, { "Content-Type": "text/plain" });
947
- res.end(`index.html not found in ${root}`);
948
- }
949
- return;
950
- }
951
- const proxyRequest = async (targetUrl, originalRes, retry = true) => {
952
- const proxyReq = http.request(
953
- {
954
- hostname: "localhost",
955
- port: transformPort,
956
- path: targetUrl,
957
- method: req.method,
958
- headers: req.headers
959
- },
960
- async (proxyRes) => {
961
- if (proxyRes.statusCode !== 404 || !retry) {
962
- res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);
963
- proxyRes.pipe(res);
964
- return;
965
- }
966
- proxyRes.resume();
967
- try {
968
- let resolvedUrl = null;
969
- if (targetUrl.startsWith("/node_modules/")) {
970
- const importPath = targetUrl.replace("/node_modules/", "");
971
- try {
972
- const resolvedPath = require2.resolve(importPath);
973
- if (resolvedPath.startsWith(root)) {
974
- let rel = relative(root, resolvedPath);
975
- resolvedUrl = "/" + rel.replace(/\\/g, "/");
976
- }
977
- } catch (e) {
978
- }
979
- }
980
- if (!resolvedUrl && !targetUrl.includes(".")) {
981
- const commonExtensions = [".mjs", ".js", ".ts", ".tsx", ".jsx", "/index.js"];
982
- const relPath = targetUrl.startsWith("/") ? targetUrl.slice(1) : targetUrl;
983
- const absBase = join3(root, relPath);
984
- for (const ext of commonExtensions) {
985
- if (existsSync3(absBase + ext)) {
986
- resolvedUrl = targetUrl + ext;
987
- break;
988
- }
989
- }
990
- }
991
- if (resolvedUrl && resolvedUrl !== targetUrl) {
992
- return proxyRequest(resolvedUrl, originalRes, false);
993
- }
994
- res.writeHead(404, proxyRes.headers);
995
- res.end("Not Found");
996
- } catch (resolveError) {
997
- res.writeHead(404, proxyRes.headers);
998
- res.end("Not Found");
999
- }
1000
- }
1001
- );
1002
- proxyReq.on("error", (err) => {
1003
- console.error("[CLI Proxy Error]", err.message);
1004
- if (!res.headersSent) {
1005
- res.writeHead(502, { "Content-Type": "text/plain" });
1006
- res.end("FlightPack transform server unavailable");
1007
- }
1008
- });
1009
- if (req.method !== "GET" && req.method !== "HEAD") {
1010
- req.pipe(proxyReq);
1011
- } else {
1012
- proxyReq.end();
1013
- }
1014
- };
1015
- proxyRequest(url, res);
1016
- });
1017
- const cliPort = port;
1018
- await new Promise((resolve10) => server.listen(cliPort, () => resolve10()));
1019
- console.log(`
1020
- \u26A1 Flight dev server running
1021
- `);
1022
- console.log(` Bundler: FlightPack`);
1023
- console.log(` Local: http://localhost:${cliPort}`);
1024
- console.log(``);
1025
917
  const elapsed = Date.now() - startTime;
1026
918
  consola2.success(`Flight dev server ready in ${elapsed}ms`);
1027
919
  devServer.printUrls?.();
@@ -1291,18 +1183,35 @@ async function buildCommand(options) {
1291
1183
  consola3.info("Building Flight project for production...\n");
1292
1184
  try {
1293
1185
  const root = resolve4(process.cwd());
1186
+ console.log("[DEBUG CLI] Root:", root);
1294
1187
  const config = await loadConfig2(root);
1188
+ console.log("[DEBUG CLI] Config loaded");
1189
+ console.log("[DEBUG CLI] config.build.outDir:", config.build.outDir);
1190
+ console.log("[DEBUG CLI] config.bundler exists:", !!config.bundler);
1191
+ console.log("[DEBUG CLI] config.bundler.name:", config.bundler?.name);
1295
1192
  const outDir = options.outDir ?? config.build.outDir;
1296
1193
  const sourcemap = options.sourcemap ?? config.build.sourcemap;
1297
1194
  const minify = options.minify ?? config.build.minify;
1195
+ console.log("[DEBUG CLI] Final outDir:", outDir);
1196
+ console.log("[DEBUG CLI] Final sourcemap:", sourcemap);
1197
+ console.log("[DEBUG CLI] Final minify:", minify);
1298
1198
  consola3.log(`Output directory: ${outDir}`);
1299
1199
  consola3.log(`Sourcemaps: ${sourcemap ? "enabled" : "disabled"}`);
1300
1200
  consola3.log(`Minification: ${minify ? "enabled" : "disabled"}
1301
1201
  `);
1302
1202
  const bundler = config.bundler;
1203
+ console.log("[DEBUG CLI] bundler:", bundler ? "exists" : "null");
1204
+ console.log("[DEBUG CLI] bundler.build type:", typeof bundler?.build);
1303
1205
  if (bundler && typeof bundler.build === "function") {
1304
1206
  consola3.info(`Using bundler: ${bundler.name || bundler.bundler || "custom"}`);
1207
+ console.log("[DEBUG CLI] Calling bundler.build(config)...");
1305
1208
  const result = await bundler.build(config);
1209
+ console.log("[DEBUG CLI] Build result received");
1210
+ console.log("[DEBUG CLI] result.success:", result.success);
1211
+ console.log("[DEBUG CLI] result.outDir:", result.outDir);
1212
+ console.log("[DEBUG CLI] result.files:", result.files?.length);
1213
+ console.log("[DEBUG CLI] result.files[0]:", JSON.stringify(result.files?.[0]));
1214
+ console.log("[DEBUG CLI] result.totalSize:", result.totalSize);
1306
1215
  if (!result.success) {
1307
1216
  for (const error of result.errors) {
1308
1217
  consola3.error(error.message);