fix(FN-000): address startup review feedback
This commit is contained in:
@@ -20,17 +20,26 @@ export function buildDevNodeArgs({
|
||||
const VALID_PREBUILD_MODES = new Set(["auto", "none", "client", "full"]);
|
||||
|
||||
export function normalizePrebuildMode(value) {
|
||||
const mode = String(value || "auto").toLowerCase();
|
||||
if (!VALID_PREBUILD_MODES.has(mode)) {
|
||||
const mode = value === undefined || value === null ? "auto" : String(value).toLowerCase();
|
||||
if (mode === "" || !VALID_PREBUILD_MODES.has(mode)) {
|
||||
throw new Error(`Invalid prebuild mode "${value}". Expected one of: auto, none, client, full.`);
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
export function hasHostOverride(args) {
|
||||
return args.includes("--host") || args.some((arg) => arg.startsWith("--host="));
|
||||
}
|
||||
|
||||
export function buildForwardedDevArgs(args) {
|
||||
const needsDevHostInjection = args[0] === "dashboard" && !hasHostOverride(args);
|
||||
return needsDevHostInjection ? [...args, "--host", "0.0.0.0"] : args;
|
||||
}
|
||||
|
||||
export function parseDevWrapperArgs(rawArgs, env = process.env) {
|
||||
const inspectFlags = [];
|
||||
const args = [];
|
||||
let requestedPrebuild = env.FUSION_DEV_PREBUILD || "auto";
|
||||
let requestedPrebuild = env.FUSION_DEV_PREBUILD ?? "auto";
|
||||
|
||||
for (let i = 0; i < rawArgs.length; i += 1) {
|
||||
const arg = rawArgs[i];
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
* Cross-platform: Works on Windows, macOS, and Linux.
|
||||
*/
|
||||
import {
|
||||
buildForwardedDevArgs,
|
||||
buildDevNodeArgs,
|
||||
getPrebuildCommand,
|
||||
parseDevWrapperArgs,
|
||||
@@ -39,11 +40,7 @@ process.env.NODE_OPTIONS = nodeOptions;
|
||||
// mobile devices and other machines on the LAN for testing. Production
|
||||
// builds default to 127.0.0.1; this override only applies when starting
|
||||
// the dashboard via `pnpm dev dashboard` and only if no --host was passed.
|
||||
const needsDevHostInjection =
|
||||
args[0] === "dashboard" && !args.includes("--host");
|
||||
const forwardedArgs = needsDevHostInjection
|
||||
? [...args, "--host", "0.0.0.0"]
|
||||
: args;
|
||||
const forwardedArgs = buildForwardedDevArgs(args);
|
||||
const prebuildMode = resolvePrebuildMode(requestedPrebuild, forwardedArgs);
|
||||
const prebuildCommand = getPrebuildCommand(prebuildMode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user