@base44-preview/cli 0.1.17-pr.635.e302685 → 0.1.17-pr.638.76ba6a7
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.
|
@@ -8,7 +8,7 @@ A simple todo list app built with React and Base44 backend.
|
|
|
8
8
|
base44/ # Backend configuration
|
|
9
9
|
├── config.jsonc # Project settings
|
|
10
10
|
└── entities/ # Data schemas
|
|
11
|
-
└──
|
|
11
|
+
└── Task.jsonc # Task entity
|
|
12
12
|
|
|
13
13
|
src/ # Frontend code
|
|
14
14
|
├── App.jsx # Main todo app
|
package/dist/cli/index.js
CHANGED
|
@@ -119090,7 +119090,7 @@ import path52 from "path";
|
|
|
119090
119090
|
import * as path42 from "path";
|
|
119091
119091
|
import * as fs26 from "fs/promises";
|
|
119092
119092
|
import * as path22 from "path";
|
|
119093
|
-
import
|
|
119093
|
+
import process22 from "process";
|
|
119094
119094
|
import * as path32 from "path";
|
|
119095
119095
|
import process32 from "process";
|
|
119096
119096
|
import path92 from "path";
|
|
@@ -119622,7 +119622,7 @@ function partition2(array2, predicate) {
|
|
|
119622
119622
|
return result;
|
|
119623
119623
|
}
|
|
119624
119624
|
async function findInDirectory(nameOrNames, { typeCheck, cwd, allowSymlinks = true, filter: filter2 }) {
|
|
119625
|
-
const directory = toAbsolutePath(cwd) ??
|
|
119625
|
+
const directory = toAbsolutePath(cwd) ?? process22.cwd();
|
|
119626
119626
|
const names = Array.isArray(nameOrNames) ? nameOrNames : [nameOrNames];
|
|
119627
119627
|
for (const name of names) {
|
|
119628
119628
|
const fileOrDirectory = path22.join(directory, name);
|
|
@@ -146002,10 +146002,10 @@ __export(exports_supports_color, {
|
|
|
146002
146002
|
createSupportsColor: () => createSupportsColor2,
|
|
146003
146003
|
default: () => supports_color_default2
|
|
146004
146004
|
});
|
|
146005
|
-
import
|
|
146005
|
+
import process21 from "node:process";
|
|
146006
146006
|
import os9 from "node:os";
|
|
146007
146007
|
import tty4 from "node:tty";
|
|
146008
|
-
function hasFlag2(flag, argv = globalThis.Deno ? globalThis.Deno.args :
|
|
146008
|
+
function hasFlag2(flag, argv = globalThis.Deno ? globalThis.Deno.args : process21.argv) {
|
|
146009
146009
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
146010
146010
|
const position = argv.indexOf(prefix + flag);
|
|
146011
146011
|
const terminatorPosition = argv.indexOf("--");
|
|
@@ -146068,7 +146068,7 @@ function _supportsColor2(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
146068
146068
|
if (env3.TERM === "dumb") {
|
|
146069
146069
|
return min;
|
|
146070
146070
|
}
|
|
146071
|
-
if (
|
|
146071
|
+
if (process21.platform === "win32") {
|
|
146072
146072
|
const osRelease = os9.release().split(".");
|
|
146073
146073
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
146074
146074
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
@@ -146130,7 +146130,7 @@ function createSupportsColor2(stream, options = {}) {
|
|
|
146130
146130
|
}
|
|
146131
146131
|
var env3, flagForceColor2, supportsColor2, supports_color_default2;
|
|
146132
146132
|
var init_supports_color = __esm(() => {
|
|
146133
|
-
({ env: env3 } =
|
|
146133
|
+
({ env: env3 } = process21);
|
|
146134
146134
|
if (hasFlag2("no-color") || hasFlag2("no-colors") || hasFlag2("color=false") || hasFlag2("color=never")) {
|
|
146135
146135
|
flagForceColor2 = 0;
|
|
146136
146136
|
} else if (hasFlag2("color") || hasFlag2("colors") || hasFlag2("color=true") || hasFlag2("color=always")) {
|
|
@@ -230721,10 +230721,7 @@ var SiteConfigSchema = object({
|
|
|
230721
230721
|
buildCommand: string2().default("npm run build"),
|
|
230722
230722
|
serveCommand: string2().optional(),
|
|
230723
230723
|
outputDirectory: string2().optional(),
|
|
230724
|
-
installCommand: string2().default("npm install")
|
|
230725
|
-
devHostFlag: string2().optional(),
|
|
230726
|
-
devHost: string2().optional(),
|
|
230727
|
-
devPort: number2().int().min(1).max(65535).optional()
|
|
230724
|
+
installCommand: string2().default("npm install")
|
|
230728
230725
|
});
|
|
230729
230726
|
var PluginMetadataSchema = object({
|
|
230730
230727
|
namespace: string2().min(1, "Plugin namespace cannot be empty").regex(/^[a-zA-Z0-9_-]+$/, "Plugin namespace can only contain letters, numbers, underscores, and dashes")
|
|
@@ -246709,44 +246706,6 @@ async function gitHead(projectRoot) {
|
|
|
246709
246706
|
return null;
|
|
246710
246707
|
}
|
|
246711
246708
|
}
|
|
246712
|
-
// src/core/site/serve-command.ts
|
|
246713
|
-
var DEFAULT_SERVE_COMMAND = "npm run dev";
|
|
246714
|
-
var DEFAULT_HOST_FLAG = "--host";
|
|
246715
|
-
var DEFAULT_DEV_HOST = "0.0.0.0";
|
|
246716
|
-
var DEFAULT_DEV_PORT = 5173;
|
|
246717
|
-
var SCRIPT = "[A-Za-z0-9:_.-]+";
|
|
246718
|
-
var PREFIX2 = "[A-Za-z0-9._/-]+";
|
|
246719
|
-
var SCRIPT_RUNNERS = [
|
|
246720
|
-
{
|
|
246721
|
-
pattern: new RegExp(String.raw`^npm(\s+--prefix\s+${PREFIX2})?\s+run\s+${SCRIPT}$`),
|
|
246722
|
-
separator: " -- "
|
|
246723
|
-
},
|
|
246724
|
-
{
|
|
246725
|
-
pattern: new RegExp(String.raw`^(?:pnpm|yarn|bun)(\s+run)?\s+${SCRIPT}$`),
|
|
246726
|
-
separator: " "
|
|
246727
|
-
}
|
|
246728
|
-
];
|
|
246729
|
-
function runnerFor(serveCommand) {
|
|
246730
|
-
return SCRIPT_RUNNERS.find((runner) => runner.pattern.test(serveCommand));
|
|
246731
|
-
}
|
|
246732
|
-
function withServeAddress(serveCommand, { host, port, hostFlag }) {
|
|
246733
|
-
const command = serveCommand.trim();
|
|
246734
|
-
const args = [
|
|
246735
|
-
...host ? [hostFlag ?? DEFAULT_HOST_FLAG, host] : [],
|
|
246736
|
-
...port === undefined ? [] : ["--port", String(port)]
|
|
246737
|
-
];
|
|
246738
|
-
if (args.length === 0) {
|
|
246739
|
-
return { command, droppedAddress: false };
|
|
246740
|
-
}
|
|
246741
|
-
const runner = runnerFor(command);
|
|
246742
|
-
if (!runner) {
|
|
246743
|
-
return { command, droppedAddress: true };
|
|
246744
|
-
}
|
|
246745
|
-
return {
|
|
246746
|
-
command: `${command}${runner.separator}${args.join(" ")}`,
|
|
246747
|
-
droppedAddress: false
|
|
246748
|
-
};
|
|
246749
|
-
}
|
|
246750
246709
|
// src/core/project/deploy.ts
|
|
246751
246710
|
function hasResourcesToDeploy(projectData) {
|
|
246752
246711
|
const {
|
|
@@ -249649,7 +249608,7 @@ async function buildAction(ctx) {
|
|
|
249649
249608
|
};
|
|
249650
249609
|
}
|
|
249651
249610
|
function getBuildCommand() {
|
|
249652
|
-
return new Base44Command("build"
|
|
249611
|
+
return new Base44Command("build").description("Build the site with the Base44 app id injected").action(buildAction);
|
|
249653
249612
|
}
|
|
249654
249613
|
|
|
249655
249614
|
// src/cli/commands/project/create.ts
|
|
@@ -250046,36 +250005,6 @@ function printStripeResult(r, log) {
|
|
|
250046
250005
|
log.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
|
|
250047
250006
|
}
|
|
250048
250007
|
|
|
250049
|
-
// src/cli/commands/project/install.ts
|
|
250050
|
-
async function installAction({
|
|
250051
|
-
runTask
|
|
250052
|
-
}) {
|
|
250053
|
-
const { project } = await readProjectConfig();
|
|
250054
|
-
const installCommand = project.site?.installCommand;
|
|
250055
|
-
if (!installCommand) {
|
|
250056
|
-
throw new ConfigNotFoundError("No site install command found.", {
|
|
250057
|
-
hints: [
|
|
250058
|
-
{
|
|
250059
|
-
message: `Add a 'site' block to your config.jsonc (e.g., "site": { "installCommand": "npm ci" }). Inside one, installCommand defaults to "npm install".`
|
|
250060
|
-
}
|
|
250061
|
-
]
|
|
250062
|
-
});
|
|
250063
|
-
}
|
|
250064
|
-
await runTask("Installing site dependencies...", () => execa({ cwd: project.root, shell: true })`${installCommand}`, {
|
|
250065
|
-
successMessage: "Dependencies installed",
|
|
250066
|
-
errorMessage: "Install failed"
|
|
250067
|
-
});
|
|
250068
|
-
return {
|
|
250069
|
-
outroMessage: `Installed with ${theme.styles.bold(installCommand)}`
|
|
250070
|
-
};
|
|
250071
|
-
}
|
|
250072
|
-
function getInstallCommand() {
|
|
250073
|
-
return new Base44Command("install", {
|
|
250074
|
-
requireAuth: false,
|
|
250075
|
-
requireAppContext: false
|
|
250076
|
-
}).description("Install the site's dependencies with its configured command").action(installAction);
|
|
250077
|
-
}
|
|
250078
|
-
|
|
250079
250008
|
// src/cli/commands/project/app-id-options.ts
|
|
250080
250009
|
function readExplicitAppId(command) {
|
|
250081
250010
|
const { appId } = command.optsWithGlobals();
|
|
@@ -251155,219 +251084,6 @@ function parseConcurrency(value) {
|
|
|
251155
251084
|
return parsed;
|
|
251156
251085
|
}
|
|
251157
251086
|
|
|
251158
|
-
// src/cli/dev/createDevLogger.ts
|
|
251159
|
-
var colorByType = {
|
|
251160
|
-
error: theme.styles.error,
|
|
251161
|
-
warn: theme.styles.warn,
|
|
251162
|
-
log: (input) => input
|
|
251163
|
-
};
|
|
251164
|
-
var stringify = (item) => {
|
|
251165
|
-
if (typeof item === "string") {
|
|
251166
|
-
return item;
|
|
251167
|
-
}
|
|
251168
|
-
if (item instanceof Error) {
|
|
251169
|
-
return item.toString();
|
|
251170
|
-
}
|
|
251171
|
-
try {
|
|
251172
|
-
return JSON.stringify(item, null, 2) ?? String(item);
|
|
251173
|
-
} catch {
|
|
251174
|
-
return String(item);
|
|
251175
|
-
}
|
|
251176
|
-
};
|
|
251177
|
-
function createDevLogger(label, labelColor = theme.styles.dim) {
|
|
251178
|
-
const prefix = label ? `${labelColor(`[${label}]`)} ` : "";
|
|
251179
|
-
const print = (type, ...args) => {
|
|
251180
|
-
const colorize = colorByType[type];
|
|
251181
|
-
console[type](prefix + args.map((item) => colorize(stringify(item))).join(" "));
|
|
251182
|
-
};
|
|
251183
|
-
return {
|
|
251184
|
-
log: (...args) => print("log", ...args),
|
|
251185
|
-
error: (msg, err) => {
|
|
251186
|
-
print("error", msg);
|
|
251187
|
-
if (err) {
|
|
251188
|
-
print("error", err);
|
|
251189
|
-
}
|
|
251190
|
-
},
|
|
251191
|
-
warn: (...args) => print("warn", ...args)
|
|
251192
|
-
};
|
|
251193
|
-
}
|
|
251194
|
-
|
|
251195
|
-
// src/cli/dev/dev-server/serve-runner.ts
|
|
251196
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
251197
|
-
import process21 from "node:process";
|
|
251198
|
-
|
|
251199
|
-
class ServeRunner {
|
|
251200
|
-
command;
|
|
251201
|
-
cwd;
|
|
251202
|
-
env;
|
|
251203
|
-
logger;
|
|
251204
|
-
child;
|
|
251205
|
-
stopping = false;
|
|
251206
|
-
stopPromise;
|
|
251207
|
-
exitListeners = [];
|
|
251208
|
-
constructor(options) {
|
|
251209
|
-
this.command = options.command;
|
|
251210
|
-
this.cwd = options.cwd;
|
|
251211
|
-
this.env = options.env;
|
|
251212
|
-
this.logger = options.logger;
|
|
251213
|
-
}
|
|
251214
|
-
start() {
|
|
251215
|
-
if (this.child) {
|
|
251216
|
-
return;
|
|
251217
|
-
}
|
|
251218
|
-
const stdin = process21.platform === "win32" ? "ignore" : "inherit";
|
|
251219
|
-
const child = spawn2(this.command, {
|
|
251220
|
-
cwd: this.cwd,
|
|
251221
|
-
shell: true,
|
|
251222
|
-
detached: process21.platform !== "win32",
|
|
251223
|
-
env: { ...process21.env, ...this.env },
|
|
251224
|
-
stdio: [stdin, "pipe", "pipe"],
|
|
251225
|
-
windowsHide: true
|
|
251226
|
-
});
|
|
251227
|
-
this.child = child;
|
|
251228
|
-
this.setupHandlers(child);
|
|
251229
|
-
}
|
|
251230
|
-
onExit(listener) {
|
|
251231
|
-
this.exitListeners.push(listener);
|
|
251232
|
-
}
|
|
251233
|
-
async stop() {
|
|
251234
|
-
if (this.stopPromise) {
|
|
251235
|
-
return this.stopPromise;
|
|
251236
|
-
}
|
|
251237
|
-
this.stopPromise = this.stopChild();
|
|
251238
|
-
return this.stopPromise;
|
|
251239
|
-
}
|
|
251240
|
-
async stopChild() {
|
|
251241
|
-
const child = this.child;
|
|
251242
|
-
if (!child || child.exitCode !== null) {
|
|
251243
|
-
return;
|
|
251244
|
-
}
|
|
251245
|
-
this.stopping = true;
|
|
251246
|
-
const exited = new Promise((resolve) => child.once("exit", () => resolve()));
|
|
251247
|
-
if (process21.platform === "win32" && child.pid) {
|
|
251248
|
-
const taskkill = spawn2("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
251249
|
-
stdio: "ignore",
|
|
251250
|
-
windowsHide: true
|
|
251251
|
-
});
|
|
251252
|
-
await new Promise((resolve) => {
|
|
251253
|
-
taskkill.once("exit", () => resolve());
|
|
251254
|
-
taskkill.once("error", () => resolve());
|
|
251255
|
-
});
|
|
251256
|
-
} else if (child.pid) {
|
|
251257
|
-
try {
|
|
251258
|
-
process21.kill(-child.pid, "SIGTERM");
|
|
251259
|
-
} catch {
|
|
251260
|
-
child.kill();
|
|
251261
|
-
}
|
|
251262
|
-
}
|
|
251263
|
-
await exited;
|
|
251264
|
-
}
|
|
251265
|
-
setupHandlers(child) {
|
|
251266
|
-
child.stdout?.on("data", (data) => this.emitLines(data, "log"));
|
|
251267
|
-
child.stderr?.on("data", (data) => this.emitLines(data, "error"));
|
|
251268
|
-
child.on("error", (error) => {
|
|
251269
|
-
this.logger.error("Frontend dev server failed to start:", error);
|
|
251270
|
-
this.notifyExit(null);
|
|
251271
|
-
});
|
|
251272
|
-
child.on("exit", (code) => {
|
|
251273
|
-
if (this.stopping) {
|
|
251274
|
-
return;
|
|
251275
|
-
}
|
|
251276
|
-
this.logger.error(`Frontend dev server exited with code ${code}`);
|
|
251277
|
-
this.notifyExit(code);
|
|
251278
|
-
});
|
|
251279
|
-
}
|
|
251280
|
-
notifyExit(code) {
|
|
251281
|
-
for (const listener of this.exitListeners) {
|
|
251282
|
-
listener(code);
|
|
251283
|
-
}
|
|
251284
|
-
}
|
|
251285
|
-
emitLines(data, type) {
|
|
251286
|
-
const lines = data.toString().trimEnd().split(`
|
|
251287
|
-
`);
|
|
251288
|
-
for (const line of lines) {
|
|
251289
|
-
if (type === "error") {
|
|
251290
|
-
this.logger.error(line);
|
|
251291
|
-
} else {
|
|
251292
|
-
this.logger.log(line);
|
|
251293
|
-
}
|
|
251294
|
-
}
|
|
251295
|
-
}
|
|
251296
|
-
}
|
|
251297
|
-
|
|
251298
|
-
// src/cli/dev/serve-command-runner.ts
|
|
251299
|
-
function createServeCommandRunner({
|
|
251300
|
-
serveCommand,
|
|
251301
|
-
projectRoot,
|
|
251302
|
-
appId,
|
|
251303
|
-
appBaseUrl
|
|
251304
|
-
}) {
|
|
251305
|
-
return new ServeRunner({
|
|
251306
|
-
command: serveCommand,
|
|
251307
|
-
cwd: projectRoot,
|
|
251308
|
-
env: {
|
|
251309
|
-
VITE_BASE44_APP_ID: appId,
|
|
251310
|
-
...appBaseUrl ? { VITE_BASE44_APP_BASE_URL: appBaseUrl } : {}
|
|
251311
|
-
},
|
|
251312
|
-
logger: createDevLogger("frontend", theme.colors.base44Orange)
|
|
251313
|
-
});
|
|
251314
|
-
}
|
|
251315
|
-
|
|
251316
|
-
// src/cli/dev/stop-runner-on-signals.ts
|
|
251317
|
-
import process22 from "node:process";
|
|
251318
|
-
function stopRunnerOnProcessSignals(runner) {
|
|
251319
|
-
const stop = () => void runner.stop();
|
|
251320
|
-
process22.on("SIGINT", stop);
|
|
251321
|
-
process22.on("SIGTERM", stop);
|
|
251322
|
-
}
|
|
251323
|
-
|
|
251324
|
-
// src/cli/commands/site/dev.ts
|
|
251325
|
-
function parsePort(value) {
|
|
251326
|
-
if (!/^\d+$/.test(value)) {
|
|
251327
|
-
throw new InvalidArgumentError2("must be a whole number");
|
|
251328
|
-
}
|
|
251329
|
-
const port = Number(value);
|
|
251330
|
-
if (port < 1 || port > 65535) {
|
|
251331
|
-
throw new InvalidArgumentError2("must be between 1 and 65535");
|
|
251332
|
-
}
|
|
251333
|
-
return port;
|
|
251334
|
-
}
|
|
251335
|
-
async function siteDevAction(ctx, options) {
|
|
251336
|
-
const { app } = ctx;
|
|
251337
|
-
if (!app?.projectRoot) {
|
|
251338
|
-
throw new ConfigInvalidError("base44 site dev requires a linked local project. Run it from a project with base44/.app.jsonc.");
|
|
251339
|
-
}
|
|
251340
|
-
const { project } = await readProjectConfig(app.projectRoot);
|
|
251341
|
-
const site = project.site;
|
|
251342
|
-
if (!site) {
|
|
251343
|
-
throw new InvalidInputError(`This project has no 'site' block in base44/config.jsonc, so there is no frontend to serve. Add one naming its serveCommand; site dev falls back to "npm run dev".`);
|
|
251344
|
-
}
|
|
251345
|
-
const serveCommand = site.serveCommand ?? DEFAULT_SERVE_COMMAND;
|
|
251346
|
-
const { command, droppedAddress } = withServeAddress(serveCommand, {
|
|
251347
|
-
host: options.host ?? site.devHost ?? DEFAULT_DEV_HOST,
|
|
251348
|
-
port: options.port ?? site.devPort ?? DEFAULT_DEV_PORT,
|
|
251349
|
-
hostFlag: site.devHostFlag
|
|
251350
|
-
});
|
|
251351
|
-
if (droppedAddress) {
|
|
251352
|
-
throw new InvalidInputError(`serveCommand '${serveCommand}' takes no forwarded arguments, so the bind address cannot be passed to it. Bind it inside serveCommand itself, or use an 'npm run', 'pnpm', 'yarn' or 'bun run' script.`);
|
|
251353
|
-
}
|
|
251354
|
-
const runner = createServeCommandRunner({
|
|
251355
|
-
serveCommand: command,
|
|
251356
|
-
projectRoot: project.root,
|
|
251357
|
-
appId: app.id,
|
|
251358
|
-
appBaseUrl: options.backendUrl
|
|
251359
|
-
});
|
|
251360
|
-
stopRunnerOnProcessSignals(runner);
|
|
251361
|
-
runner.onExit((code) => process.exit(code ?? 1));
|
|
251362
|
-
runner.start();
|
|
251363
|
-
return {
|
|
251364
|
-
outroMessage: options.backendUrl ? `Frontend dev server running '${command}' against ${theme.styles.bold(options.backendUrl)}` : `Frontend dev server running '${command}'`
|
|
251365
|
-
};
|
|
251366
|
-
}
|
|
251367
|
-
function getSiteDevCommand() {
|
|
251368
|
-
return new Base44Command("dev", { requireAuth: false }).description("Run the site's dev server against a given backend (no local backend)").option("--backend-url <url>", "Backend the frontend should call, injected as VITE_BASE44_APP_BASE_URL. Omit for a frontend that reaches its backend same-origin.").option("--host <address>", `Address to bind (default: site.devHost, else ${DEFAULT_DEV_HOST})`).option("--port <number>", `Port to bind (default: site.devPort, else ${DEFAULT_DEV_PORT})`, parsePort).action(siteDevAction);
|
|
251369
|
-
}
|
|
251370
|
-
|
|
251371
251087
|
// src/cli/commands/site/open.ts
|
|
251372
251088
|
async function openAction({
|
|
251373
251089
|
isNonInteractive
|
|
@@ -251384,7 +251100,7 @@ function getSiteOpenCommand() {
|
|
|
251384
251100
|
|
|
251385
251101
|
// src/cli/commands/site/index.ts
|
|
251386
251102
|
function getSiteCommand() {
|
|
251387
|
-
return new Command2("site").description("Manage app site (frontend app)").addCommand(getSiteDeployCommand()).addCommand(
|
|
251103
|
+
return new Command2("site").description("Manage app site (frontend app)").addCommand(getSiteDeployCommand()).addCommand(getSiteOpenCommand());
|
|
251388
251104
|
}
|
|
251389
251105
|
|
|
251390
251106
|
// src/core/types/generator.ts
|
|
@@ -251904,6 +251620,43 @@ function getWorkspaceCommand() {
|
|
|
251904
251620
|
return new Command2("workspace").description("List workspaces, inspect one, and move apps between them").addCommand(getWorkspaceListCommand()).addCommand(getWorkspaceGetCommand()).addCommand(getWorkspaceMoveCommand());
|
|
251905
251621
|
}
|
|
251906
251622
|
|
|
251623
|
+
// src/cli/dev/createDevLogger.ts
|
|
251624
|
+
var colorByType = {
|
|
251625
|
+
error: theme.styles.error,
|
|
251626
|
+
warn: theme.styles.warn,
|
|
251627
|
+
log: (input) => input
|
|
251628
|
+
};
|
|
251629
|
+
var stringify = (item) => {
|
|
251630
|
+
if (typeof item === "string") {
|
|
251631
|
+
return item;
|
|
251632
|
+
}
|
|
251633
|
+
if (item instanceof Error) {
|
|
251634
|
+
return item.toString();
|
|
251635
|
+
}
|
|
251636
|
+
try {
|
|
251637
|
+
return JSON.stringify(item, null, 2) ?? String(item);
|
|
251638
|
+
} catch {
|
|
251639
|
+
return String(item);
|
|
251640
|
+
}
|
|
251641
|
+
};
|
|
251642
|
+
function createDevLogger(label, labelColor = theme.styles.dim) {
|
|
251643
|
+
const prefix = label ? `${labelColor(`[${label}]`)} ` : "";
|
|
251644
|
+
const print = (type, ...args) => {
|
|
251645
|
+
const colorize = colorByType[type];
|
|
251646
|
+
console[type](prefix + args.map((item) => colorize(stringify(item))).join(" "));
|
|
251647
|
+
};
|
|
251648
|
+
return {
|
|
251649
|
+
log: (...args) => print("log", ...args),
|
|
251650
|
+
error: (msg, err) => {
|
|
251651
|
+
print("error", msg);
|
|
251652
|
+
if (err) {
|
|
251653
|
+
print("error", err);
|
|
251654
|
+
}
|
|
251655
|
+
},
|
|
251656
|
+
warn: (...args) => print("warn", ...args)
|
|
251657
|
+
};
|
|
251658
|
+
}
|
|
251659
|
+
|
|
251907
251660
|
// src/cli/dev/dev-server/main.ts
|
|
251908
251661
|
var import_cors = __toESM(require_lib4(), 1);
|
|
251909
251662
|
var import_express6 = __toESM(require_express(), 1);
|
|
@@ -252036,7 +251789,7 @@ var $dir = async (options) => dirWithOptions(options);
|
|
|
252036
251789
|
var $tmpName = promisify11(tmp.tmpName);
|
|
252037
251790
|
|
|
252038
251791
|
// src/cli/dev/dev-server/function-manager.ts
|
|
252039
|
-
import { spawn as
|
|
251792
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
252040
251793
|
import { dirname as dirname23, join as join31 } from "node:path";
|
|
252041
251794
|
import { pathToFileURL } from "node:url";
|
|
252042
251795
|
|
|
@@ -252134,7 +251887,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
252134
251887
|
async stopFunction(_name, { process: proc }) {
|
|
252135
251888
|
const exited = new Promise((r) => proc.once("exit", () => r()));
|
|
252136
251889
|
if (process.platform === "win32" && proc.pid) {
|
|
252137
|
-
|
|
251890
|
+
spawn2("taskkill", ["/pid", String(proc.pid), "/T", "/F"]);
|
|
252138
251891
|
} else {
|
|
252139
251892
|
proc.kill();
|
|
252140
251893
|
}
|
|
@@ -252143,7 +251896,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
252143
251896
|
spawnFunction(func, port) {
|
|
252144
251897
|
this.logger.log(`Spawning function "${func.name}" on port ${port}`);
|
|
252145
251898
|
const importMapPath = join31(dirname23(this.wrapperPath), "import-map.json");
|
|
252146
|
-
const process2 =
|
|
251899
|
+
const process2 = spawn2("deno", ["run", "--allow-all", "--import-map", importMapPath, this.wrapperPath], {
|
|
252147
251900
|
env: {
|
|
252148
251901
|
...globalThis.process.env,
|
|
252149
251902
|
FUNCTION_PATH: pathToFileURL(func.entryPath).href,
|
|
@@ -255673,6 +255426,127 @@ async function createDevServer(options) {
|
|
|
255673
255426
|
return { port, server, shutdown };
|
|
255674
255427
|
}
|
|
255675
255428
|
|
|
255429
|
+
// src/cli/dev/dev-server/serve-runner.ts
|
|
255430
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
255431
|
+
import process23 from "node:process";
|
|
255432
|
+
|
|
255433
|
+
class ServeRunner {
|
|
255434
|
+
command;
|
|
255435
|
+
cwd;
|
|
255436
|
+
env;
|
|
255437
|
+
logger;
|
|
255438
|
+
child;
|
|
255439
|
+
stopping = false;
|
|
255440
|
+
stopPromise;
|
|
255441
|
+
exitListeners = [];
|
|
255442
|
+
constructor(options) {
|
|
255443
|
+
this.command = options.command;
|
|
255444
|
+
this.cwd = options.cwd;
|
|
255445
|
+
this.env = options.env;
|
|
255446
|
+
this.logger = options.logger;
|
|
255447
|
+
}
|
|
255448
|
+
start() {
|
|
255449
|
+
if (this.child) {
|
|
255450
|
+
return;
|
|
255451
|
+
}
|
|
255452
|
+
const stdin = process23.platform === "win32" ? "ignore" : "inherit";
|
|
255453
|
+
const child = spawn3(this.command, {
|
|
255454
|
+
cwd: this.cwd,
|
|
255455
|
+
shell: true,
|
|
255456
|
+
detached: process23.platform !== "win32",
|
|
255457
|
+
env: { ...process23.env, ...this.env },
|
|
255458
|
+
stdio: [stdin, "pipe", "pipe"],
|
|
255459
|
+
windowsHide: true
|
|
255460
|
+
});
|
|
255461
|
+
this.child = child;
|
|
255462
|
+
this.setupHandlers(child);
|
|
255463
|
+
}
|
|
255464
|
+
onExit(listener) {
|
|
255465
|
+
this.exitListeners.push(listener);
|
|
255466
|
+
}
|
|
255467
|
+
async stop() {
|
|
255468
|
+
if (this.stopPromise) {
|
|
255469
|
+
return this.stopPromise;
|
|
255470
|
+
}
|
|
255471
|
+
this.stopPromise = this.stopChild();
|
|
255472
|
+
return this.stopPromise;
|
|
255473
|
+
}
|
|
255474
|
+
async stopChild() {
|
|
255475
|
+
const child = this.child;
|
|
255476
|
+
if (!child || child.exitCode !== null) {
|
|
255477
|
+
return;
|
|
255478
|
+
}
|
|
255479
|
+
this.stopping = true;
|
|
255480
|
+
const exited = new Promise((resolve) => child.once("exit", () => resolve()));
|
|
255481
|
+
if (process23.platform === "win32" && child.pid) {
|
|
255482
|
+
const taskkill = spawn3("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
255483
|
+
stdio: "ignore",
|
|
255484
|
+
windowsHide: true
|
|
255485
|
+
});
|
|
255486
|
+
await new Promise((resolve) => {
|
|
255487
|
+
taskkill.once("exit", () => resolve());
|
|
255488
|
+
taskkill.once("error", () => resolve());
|
|
255489
|
+
});
|
|
255490
|
+
} else if (child.pid) {
|
|
255491
|
+
try {
|
|
255492
|
+
process23.kill(-child.pid, "SIGTERM");
|
|
255493
|
+
} catch {
|
|
255494
|
+
child.kill();
|
|
255495
|
+
}
|
|
255496
|
+
}
|
|
255497
|
+
await exited;
|
|
255498
|
+
}
|
|
255499
|
+
setupHandlers(child) {
|
|
255500
|
+
child.stdout?.on("data", (data) => this.emitLines(data, "log"));
|
|
255501
|
+
child.stderr?.on("data", (data) => this.emitLines(data, "error"));
|
|
255502
|
+
child.on("error", (error) => {
|
|
255503
|
+
this.logger.error("Frontend dev server failed to start:", error);
|
|
255504
|
+
this.notifyExit(null);
|
|
255505
|
+
});
|
|
255506
|
+
child.on("exit", (code) => {
|
|
255507
|
+
if (this.stopping) {
|
|
255508
|
+
return;
|
|
255509
|
+
}
|
|
255510
|
+
this.logger.error(`Frontend dev server exited with code ${code}`);
|
|
255511
|
+
this.notifyExit(code);
|
|
255512
|
+
});
|
|
255513
|
+
}
|
|
255514
|
+
notifyExit(code) {
|
|
255515
|
+
for (const listener of this.exitListeners) {
|
|
255516
|
+
listener(code);
|
|
255517
|
+
}
|
|
255518
|
+
}
|
|
255519
|
+
emitLines(data, type) {
|
|
255520
|
+
const lines = data.toString().trimEnd().split(`
|
|
255521
|
+
`);
|
|
255522
|
+
for (const line of lines) {
|
|
255523
|
+
if (type === "error") {
|
|
255524
|
+
this.logger.error(line);
|
|
255525
|
+
} else {
|
|
255526
|
+
this.logger.log(line);
|
|
255527
|
+
}
|
|
255528
|
+
}
|
|
255529
|
+
}
|
|
255530
|
+
}
|
|
255531
|
+
|
|
255532
|
+
// src/cli/dev/serve-command-runner.ts
|
|
255533
|
+
function createServeCommandRunner({
|
|
255534
|
+
serveCommand,
|
|
255535
|
+
projectRoot,
|
|
255536
|
+
appId,
|
|
255537
|
+
appBaseUrl
|
|
255538
|
+
}) {
|
|
255539
|
+
return new ServeRunner({
|
|
255540
|
+
command: serveCommand,
|
|
255541
|
+
cwd: projectRoot,
|
|
255542
|
+
env: {
|
|
255543
|
+
VITE_BASE44_APP_ID: appId,
|
|
255544
|
+
VITE_BASE44_APP_BASE_URL: appBaseUrl
|
|
255545
|
+
},
|
|
255546
|
+
logger: createDevLogger("frontend", theme.colors.base44Orange)
|
|
255547
|
+
});
|
|
255548
|
+
}
|
|
255549
|
+
|
|
255676
255550
|
// src/cli/commands/dev.ts
|
|
255677
255551
|
function localServerUrl(port) {
|
|
255678
255552
|
return `http://localhost:${port}`;
|
|
@@ -255698,6 +255572,11 @@ async function resolveConfiguredSite(app) {
|
|
|
255698
255572
|
const serveCommand = project.site?.serveCommand;
|
|
255699
255573
|
return serveCommand ? { serveCommand, projectRoot: project.root } : undefined;
|
|
255700
255574
|
}
|
|
255575
|
+
function stopRunnerOnProcessSignals(runner) {
|
|
255576
|
+
const stop = () => void runner.stop();
|
|
255577
|
+
process.on("SIGINT", stop);
|
|
255578
|
+
process.on("SIGTERM", stop);
|
|
255579
|
+
}
|
|
255701
255580
|
function startServeCommand(runner, backend) {
|
|
255702
255581
|
stopRunnerOnProcessSignals(runner);
|
|
255703
255582
|
runner.onExit(() => {
|
|
@@ -255811,7 +255690,7 @@ function readStdin2() {
|
|
|
255811
255690
|
process.stdin.on("error", reject);
|
|
255812
255691
|
});
|
|
255813
255692
|
}
|
|
255814
|
-
function
|
|
255693
|
+
function parsePort(value) {
|
|
255815
255694
|
const port = Number(value);
|
|
255816
255695
|
if (!Number.isInteger(port) || port <= 0 || port > 65535) {
|
|
255817
255696
|
throw new InvalidInputError(`Invalid --port value: "${value}".`, {
|
|
@@ -255848,7 +255727,7 @@ async function execAction({ app, isNonInteractive }, options) {
|
|
|
255848
255727
|
if (!code.trim()) {
|
|
255849
255728
|
throw noInputError;
|
|
255850
255729
|
}
|
|
255851
|
-
const local = options.local ? await resolveLocalTarget(options.port !== undefined ?
|
|
255730
|
+
const local = options.local ? await resolveLocalTarget(options.port !== undefined ? parsePort(options.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
|
|
255852
255731
|
const { exitCode } = await runScript({
|
|
255853
255732
|
appId: app.id,
|
|
255854
255733
|
code,
|
|
@@ -256013,7 +255892,6 @@ function createProgram(context) {
|
|
|
256013
255892
|
program.addCommand(getCreateCommand());
|
|
256014
255893
|
program.addCommand(getScaffoldCommand());
|
|
256015
255894
|
program.addCommand(getDashboardCommand());
|
|
256016
|
-
program.addCommand(getInstallCommand());
|
|
256017
255895
|
program.addCommand(getBuildCommand());
|
|
256018
255896
|
program.addCommand(getDeployCommand3());
|
|
256019
255897
|
program.addCommand(getVisibilityCommand());
|
|
@@ -260083,4 +259961,4 @@ export {
|
|
|
260083
259961
|
runCLI
|
|
260084
259962
|
};
|
|
260085
259963
|
|
|
260086
|
-
//# debugId=
|
|
259964
|
+
//# debugId=815732FBC7D9653064756E2164756E21
|