@base44-preview/cli 0.1.16-pr.634.fb8f8af → 0.1.16-pr.635.2ec10a1
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 +276 -185
- package/dist/cli/index.js.map +17 -13
- package/package.json +1 -1
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 process23 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) ?? process23.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 process24 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 : process24.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 (process24.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 } = process24);
|
|
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")) {
|
|
@@ -230705,10 +230705,11 @@ var TemplatesConfigSchema = object({
|
|
|
230705
230705
|
templates: array(TemplateSchema)
|
|
230706
230706
|
});
|
|
230707
230707
|
var SiteConfigSchema = object({
|
|
230708
|
-
buildCommand: string2().default("npm run build"),
|
|
230709
|
-
serveCommand: string2().optional(),
|
|
230710
|
-
outputDirectory: string2().optional(),
|
|
230711
|
-
installCommand: string2().default("npm install")
|
|
230708
|
+
buildCommand: string2().optional().default("npm run build"),
|
|
230709
|
+
serveCommand: string2().optional().default("npm run dev"),
|
|
230710
|
+
outputDirectory: string2().optional().default("./dist"),
|
|
230711
|
+
installCommand: string2().optional().default("npm install"),
|
|
230712
|
+
devHostFlag: string2().optional().default("--host")
|
|
230712
230713
|
});
|
|
230713
230714
|
var PluginMetadataSchema = object({
|
|
230714
230715
|
namespace: string2().min(1, "Plugin namespace cannot be empty").regex(/^[a-zA-Z0-9_-]+$/, "Plugin namespace can only contain letters, numbers, underscores, and dashes")
|
|
@@ -246679,6 +246680,21 @@ async function gitHead(projectRoot) {
|
|
|
246679
246680
|
return null;
|
|
246680
246681
|
}
|
|
246681
246682
|
}
|
|
246683
|
+
// src/core/site/serve-command.ts
|
|
246684
|
+
var NPM_RUN_COMMAND = /^npm(\s+--prefix\s+\S+)?\s+run\s+\S+$/;
|
|
246685
|
+
function withServeAddress(serveCommand, { host, port, hostFlag }) {
|
|
246686
|
+
const args = [
|
|
246687
|
+
...host ? [hostFlag, host] : [],
|
|
246688
|
+
...port === undefined ? [] : ["--port", String(port)]
|
|
246689
|
+
];
|
|
246690
|
+
if (args.length === 0 || !NPM_RUN_COMMAND.test(serveCommand.trim())) {
|
|
246691
|
+
return serveCommand;
|
|
246692
|
+
}
|
|
246693
|
+
return `${serveCommand} -- ${args.join(" ")}`;
|
|
246694
|
+
}
|
|
246695
|
+
function forwardsServeAddress(serveCommand) {
|
|
246696
|
+
return NPM_RUN_COMMAND.test(serveCommand.trim());
|
|
246697
|
+
}
|
|
246682
246698
|
// src/core/project/deploy.ts
|
|
246683
246699
|
function hasResourcesToDeploy(projectData) {
|
|
246684
246700
|
const {
|
|
@@ -246691,7 +246707,7 @@ function hasResourcesToDeploy(projectData) {
|
|
|
246691
246707
|
connectors,
|
|
246692
246708
|
authConfig
|
|
246693
246709
|
} = projectData;
|
|
246694
|
-
const hasSite =
|
|
246710
|
+
const hasSite = project.site !== undefined;
|
|
246695
246711
|
const hasEntities = entities.length > 0;
|
|
246696
246712
|
const hasFunctions = functions.length > 0;
|
|
246697
246713
|
const hasActors = actors.length > 0;
|
|
@@ -249978,6 +249994,36 @@ function printStripeResult(r, log) {
|
|
|
249978
249994
|
log.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
|
|
249979
249995
|
}
|
|
249980
249996
|
|
|
249997
|
+
// src/cli/commands/project/install.ts
|
|
249998
|
+
async function installAction({
|
|
249999
|
+
runTask
|
|
250000
|
+
}) {
|
|
250001
|
+
const { project } = await readProjectConfig();
|
|
250002
|
+
const installCommand = project.site?.installCommand;
|
|
250003
|
+
if (!installCommand) {
|
|
250004
|
+
throw new ConfigNotFoundError("No site install command found.", {
|
|
250005
|
+
hints: [
|
|
250006
|
+
{
|
|
250007
|
+
message: `Add a 'site' block to your config.jsonc (e.g., "site": { "installCommand": "npm ci" }). Inside one, installCommand defaults to "npm install".`
|
|
250008
|
+
}
|
|
250009
|
+
]
|
|
250010
|
+
});
|
|
250011
|
+
}
|
|
250012
|
+
await runTask("Installing site dependencies...", () => execa({ cwd: project.root, shell: true })`${installCommand}`, {
|
|
250013
|
+
successMessage: "Dependencies installed",
|
|
250014
|
+
errorMessage: "Install failed"
|
|
250015
|
+
});
|
|
250016
|
+
return {
|
|
250017
|
+
outroMessage: `Installed with ${theme.styles.bold(installCommand)}`
|
|
250018
|
+
};
|
|
250019
|
+
}
|
|
250020
|
+
function getInstallCommand() {
|
|
250021
|
+
return new Base44Command("install", {
|
|
250022
|
+
requireAuth: false,
|
|
250023
|
+
requireAppContext: false
|
|
250024
|
+
}).description("Install the site's dependencies with its configured command").action(installAction);
|
|
250025
|
+
}
|
|
250026
|
+
|
|
249981
250027
|
// src/cli/commands/project/app-id-options.ts
|
|
249982
250028
|
function readExplicitAppId(command) {
|
|
249983
250029
|
const { appId } = command.optsWithGlobals();
|
|
@@ -251020,7 +251066,7 @@ async function deployTarball({ runTask }, project) {
|
|
|
251020
251066
|
throw new ConfigNotFoundError("No site configuration found.", {
|
|
251021
251067
|
hints: [
|
|
251022
251068
|
{
|
|
251023
|
-
message: `Add 'site
|
|
251069
|
+
message: `Add a 'site' block to your config.jsonc (e.g., "site": { "outputDirectory": "dist" }). Inside one, outputDirectory defaults to "./dist".`
|
|
251024
251070
|
}
|
|
251025
251071
|
]
|
|
251026
251072
|
});
|
|
@@ -251057,6 +251103,212 @@ function parseConcurrency(value) {
|
|
|
251057
251103
|
return parsed;
|
|
251058
251104
|
}
|
|
251059
251105
|
|
|
251106
|
+
// src/cli/dev/createDevLogger.ts
|
|
251107
|
+
var colorByType = {
|
|
251108
|
+
error: theme.styles.error,
|
|
251109
|
+
warn: theme.styles.warn,
|
|
251110
|
+
log: (input) => input
|
|
251111
|
+
};
|
|
251112
|
+
var stringify = (item) => {
|
|
251113
|
+
if (typeof item === "string") {
|
|
251114
|
+
return item;
|
|
251115
|
+
}
|
|
251116
|
+
if (item instanceof Error) {
|
|
251117
|
+
return item.toString();
|
|
251118
|
+
}
|
|
251119
|
+
try {
|
|
251120
|
+
return JSON.stringify(item, null, 2) ?? String(item);
|
|
251121
|
+
} catch {
|
|
251122
|
+
return String(item);
|
|
251123
|
+
}
|
|
251124
|
+
};
|
|
251125
|
+
function createDevLogger(label, labelColor = theme.styles.dim) {
|
|
251126
|
+
const prefix = label ? `${labelColor(`[${label}]`)} ` : "";
|
|
251127
|
+
const print = (type, ...args) => {
|
|
251128
|
+
const colorize = colorByType[type];
|
|
251129
|
+
console[type](prefix + args.map((item) => colorize(stringify(item))).join(" "));
|
|
251130
|
+
};
|
|
251131
|
+
return {
|
|
251132
|
+
log: (...args) => print("log", ...args),
|
|
251133
|
+
error: (msg, err) => {
|
|
251134
|
+
print("error", msg);
|
|
251135
|
+
if (err) {
|
|
251136
|
+
print("error", err);
|
|
251137
|
+
}
|
|
251138
|
+
},
|
|
251139
|
+
warn: (...args) => print("warn", ...args)
|
|
251140
|
+
};
|
|
251141
|
+
}
|
|
251142
|
+
|
|
251143
|
+
// src/cli/dev/dev-server/serve-runner.ts
|
|
251144
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
251145
|
+
import process21 from "node:process";
|
|
251146
|
+
|
|
251147
|
+
class ServeRunner {
|
|
251148
|
+
command;
|
|
251149
|
+
cwd;
|
|
251150
|
+
env;
|
|
251151
|
+
logger;
|
|
251152
|
+
child;
|
|
251153
|
+
stopping = false;
|
|
251154
|
+
stopPromise;
|
|
251155
|
+
exitListeners = [];
|
|
251156
|
+
constructor(options) {
|
|
251157
|
+
this.command = options.command;
|
|
251158
|
+
this.cwd = options.cwd;
|
|
251159
|
+
this.env = options.env;
|
|
251160
|
+
this.logger = options.logger;
|
|
251161
|
+
}
|
|
251162
|
+
start() {
|
|
251163
|
+
if (this.child) {
|
|
251164
|
+
return;
|
|
251165
|
+
}
|
|
251166
|
+
const stdin = process21.platform === "win32" ? "ignore" : "inherit";
|
|
251167
|
+
const child = spawn2(this.command, {
|
|
251168
|
+
cwd: this.cwd,
|
|
251169
|
+
shell: true,
|
|
251170
|
+
detached: process21.platform !== "win32",
|
|
251171
|
+
env: { ...process21.env, ...this.env },
|
|
251172
|
+
stdio: [stdin, "pipe", "pipe"],
|
|
251173
|
+
windowsHide: true
|
|
251174
|
+
});
|
|
251175
|
+
this.child = child;
|
|
251176
|
+
this.setupHandlers(child);
|
|
251177
|
+
}
|
|
251178
|
+
onExit(listener) {
|
|
251179
|
+
this.exitListeners.push(listener);
|
|
251180
|
+
}
|
|
251181
|
+
async stop() {
|
|
251182
|
+
if (this.stopPromise) {
|
|
251183
|
+
return this.stopPromise;
|
|
251184
|
+
}
|
|
251185
|
+
this.stopPromise = this.stopChild();
|
|
251186
|
+
return this.stopPromise;
|
|
251187
|
+
}
|
|
251188
|
+
async stopChild() {
|
|
251189
|
+
const child = this.child;
|
|
251190
|
+
if (!child || child.exitCode !== null) {
|
|
251191
|
+
return;
|
|
251192
|
+
}
|
|
251193
|
+
this.stopping = true;
|
|
251194
|
+
const exited = new Promise((resolve) => child.once("exit", () => resolve()));
|
|
251195
|
+
if (process21.platform === "win32" && child.pid) {
|
|
251196
|
+
const taskkill = spawn2("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
251197
|
+
stdio: "ignore",
|
|
251198
|
+
windowsHide: true
|
|
251199
|
+
});
|
|
251200
|
+
await new Promise((resolve) => {
|
|
251201
|
+
taskkill.once("exit", () => resolve());
|
|
251202
|
+
taskkill.once("error", () => resolve());
|
|
251203
|
+
});
|
|
251204
|
+
} else if (child.pid) {
|
|
251205
|
+
try {
|
|
251206
|
+
process21.kill(-child.pid, "SIGTERM");
|
|
251207
|
+
} catch {
|
|
251208
|
+
child.kill();
|
|
251209
|
+
}
|
|
251210
|
+
}
|
|
251211
|
+
await exited;
|
|
251212
|
+
}
|
|
251213
|
+
setupHandlers(child) {
|
|
251214
|
+
child.stdout?.on("data", (data) => this.emitLines(data, "log"));
|
|
251215
|
+
child.stderr?.on("data", (data) => this.emitLines(data, "error"));
|
|
251216
|
+
child.on("error", (error) => {
|
|
251217
|
+
this.logger.error("Frontend dev server failed to start:", error);
|
|
251218
|
+
this.notifyExit(null);
|
|
251219
|
+
});
|
|
251220
|
+
child.on("exit", (code) => {
|
|
251221
|
+
if (this.stopping) {
|
|
251222
|
+
return;
|
|
251223
|
+
}
|
|
251224
|
+
this.logger.error(`Frontend dev server exited with code ${code}`);
|
|
251225
|
+
this.notifyExit(code);
|
|
251226
|
+
});
|
|
251227
|
+
}
|
|
251228
|
+
notifyExit(code) {
|
|
251229
|
+
for (const listener of this.exitListeners) {
|
|
251230
|
+
listener(code);
|
|
251231
|
+
}
|
|
251232
|
+
}
|
|
251233
|
+
emitLines(data, type) {
|
|
251234
|
+
const lines = data.toString().trimEnd().split(`
|
|
251235
|
+
`);
|
|
251236
|
+
for (const line of lines) {
|
|
251237
|
+
if (type === "error") {
|
|
251238
|
+
this.logger.error(line);
|
|
251239
|
+
} else {
|
|
251240
|
+
this.logger.log(line);
|
|
251241
|
+
}
|
|
251242
|
+
}
|
|
251243
|
+
}
|
|
251244
|
+
}
|
|
251245
|
+
|
|
251246
|
+
// src/cli/dev/serve-command-runner.ts
|
|
251247
|
+
function createServeCommandRunner({
|
|
251248
|
+
serveCommand,
|
|
251249
|
+
projectRoot,
|
|
251250
|
+
appId,
|
|
251251
|
+
appBaseUrl
|
|
251252
|
+
}) {
|
|
251253
|
+
return new ServeRunner({
|
|
251254
|
+
command: serveCommand,
|
|
251255
|
+
cwd: projectRoot,
|
|
251256
|
+
env: {
|
|
251257
|
+
VITE_BASE44_APP_ID: appId,
|
|
251258
|
+
VITE_BASE44_APP_BASE_URL: appBaseUrl
|
|
251259
|
+
},
|
|
251260
|
+
logger: createDevLogger("frontend", theme.colors.base44Orange)
|
|
251261
|
+
});
|
|
251262
|
+
}
|
|
251263
|
+
|
|
251264
|
+
// src/cli/dev/stop-runner-on-signals.ts
|
|
251265
|
+
import process22 from "node:process";
|
|
251266
|
+
function stopRunnerOnProcessSignals(runner) {
|
|
251267
|
+
const stop = () => void runner.stop();
|
|
251268
|
+
process22.on("SIGINT", stop);
|
|
251269
|
+
process22.on("SIGTERM", stop);
|
|
251270
|
+
}
|
|
251271
|
+
|
|
251272
|
+
// src/cli/commands/site/dev.ts
|
|
251273
|
+
async function siteDevAction(ctx, options) {
|
|
251274
|
+
const { app, log } = ctx;
|
|
251275
|
+
if (!app) {
|
|
251276
|
+
throw new InvalidInputError("No app id resolved for this project.");
|
|
251277
|
+
}
|
|
251278
|
+
const port = options.port === undefined ? undefined : Number(options.port);
|
|
251279
|
+
if (port !== undefined && !Number.isInteger(port)) {
|
|
251280
|
+
throw new InvalidInputError(`--port must be a whole number: ${options.port}`);
|
|
251281
|
+
}
|
|
251282
|
+
const { project } = await readProjectConfig(app.projectRoot);
|
|
251283
|
+
const site = project.site;
|
|
251284
|
+
if (!site) {
|
|
251285
|
+
throw new InvalidInputError(`This project has no 'site' block in base44/config.jsonc, so there is no frontend to serve. Add one; inside it serveCommand defaults to "npm run dev".`);
|
|
251286
|
+
}
|
|
251287
|
+
const command = withServeAddress(site.serveCommand, {
|
|
251288
|
+
host: options.host,
|
|
251289
|
+
port,
|
|
251290
|
+
hostFlag: site.devHostFlag
|
|
251291
|
+
});
|
|
251292
|
+
if ((options.host || port !== undefined) && !forwardsServeAddress(site.serveCommand)) {
|
|
251293
|
+
log.warn(`serveCommand '${site.serveCommand}' is not an 'npm run' invocation, so --host/--port were not passed to it. Put the address in serveCommand itself.`);
|
|
251294
|
+
}
|
|
251295
|
+
const runner = createServeCommandRunner({
|
|
251296
|
+
serveCommand: command,
|
|
251297
|
+
projectRoot: project.root,
|
|
251298
|
+
appId: app.id,
|
|
251299
|
+
appBaseUrl: options.backendUrl
|
|
251300
|
+
});
|
|
251301
|
+
stopRunnerOnProcessSignals(runner);
|
|
251302
|
+
runner.onExit((code) => process.exit(code ?? 1));
|
|
251303
|
+
runner.start();
|
|
251304
|
+
return {
|
|
251305
|
+
outroMessage: `Frontend dev server running '${command}' against ${theme.styles.bold(options.backendUrl)}`
|
|
251306
|
+
};
|
|
251307
|
+
}
|
|
251308
|
+
function getSiteDevCommand() {
|
|
251309
|
+
return new Base44Command("dev", { requireAuth: false }).description("Run the site's dev server against a given backend (no local backend)").requiredOption("--backend-url <url>", "Backend the frontend should call, injected as VITE_BASE44_APP_BASE_URL").option("--host <address>", "Address to bind, e.g. 0.0.0.0").option("--port <number>", "Port to bind").action(siteDevAction);
|
|
251310
|
+
}
|
|
251311
|
+
|
|
251060
251312
|
// src/cli/commands/site/open.ts
|
|
251061
251313
|
async function openAction({
|
|
251062
251314
|
isNonInteractive
|
|
@@ -251073,7 +251325,7 @@ function getSiteOpenCommand() {
|
|
|
251073
251325
|
|
|
251074
251326
|
// src/cli/commands/site/index.ts
|
|
251075
251327
|
function getSiteCommand() {
|
|
251076
|
-
return new Command2("site").description("Manage app site (frontend app)").addCommand(getSiteDeployCommand()).addCommand(getSiteOpenCommand());
|
|
251328
|
+
return new Command2("site").description("Manage app site (frontend app)").addCommand(getSiteDeployCommand()).addCommand(getSiteDevCommand()).addCommand(getSiteOpenCommand());
|
|
251077
251329
|
}
|
|
251078
251330
|
|
|
251079
251331
|
// src/core/types/generator.ts
|
|
@@ -251593,43 +251845,6 @@ function getWorkspaceCommand() {
|
|
|
251593
251845
|
return new Command2("workspace").description("List workspaces, inspect one, and move apps between them").addCommand(getWorkspaceListCommand()).addCommand(getWorkspaceGetCommand()).addCommand(getWorkspaceMoveCommand());
|
|
251594
251846
|
}
|
|
251595
251847
|
|
|
251596
|
-
// src/cli/dev/createDevLogger.ts
|
|
251597
|
-
var colorByType = {
|
|
251598
|
-
error: theme.styles.error,
|
|
251599
|
-
warn: theme.styles.warn,
|
|
251600
|
-
log: (input) => input
|
|
251601
|
-
};
|
|
251602
|
-
var stringify = (item) => {
|
|
251603
|
-
if (typeof item === "string") {
|
|
251604
|
-
return item;
|
|
251605
|
-
}
|
|
251606
|
-
if (item instanceof Error) {
|
|
251607
|
-
return item.toString();
|
|
251608
|
-
}
|
|
251609
|
-
try {
|
|
251610
|
-
return JSON.stringify(item, null, 2) ?? String(item);
|
|
251611
|
-
} catch {
|
|
251612
|
-
return String(item);
|
|
251613
|
-
}
|
|
251614
|
-
};
|
|
251615
|
-
function createDevLogger(label, labelColor = theme.styles.dim) {
|
|
251616
|
-
const prefix = label ? `${labelColor(`[${label}]`)} ` : "";
|
|
251617
|
-
const print = (type, ...args) => {
|
|
251618
|
-
const colorize = colorByType[type];
|
|
251619
|
-
console[type](prefix + args.map((item) => colorize(stringify(item))).join(" "));
|
|
251620
|
-
};
|
|
251621
|
-
return {
|
|
251622
|
-
log: (...args) => print("log", ...args),
|
|
251623
|
-
error: (msg, err) => {
|
|
251624
|
-
print("error", msg);
|
|
251625
|
-
if (err) {
|
|
251626
|
-
print("error", err);
|
|
251627
|
-
}
|
|
251628
|
-
},
|
|
251629
|
-
warn: (...args) => print("warn", ...args)
|
|
251630
|
-
};
|
|
251631
|
-
}
|
|
251632
|
-
|
|
251633
251848
|
// src/cli/dev/dev-server/main.ts
|
|
251634
251849
|
var import_cors = __toESM(require_lib4(), 1);
|
|
251635
251850
|
var import_express6 = __toESM(require_express(), 1);
|
|
@@ -251762,7 +251977,7 @@ var $dir = async (options) => dirWithOptions(options);
|
|
|
251762
251977
|
var $tmpName = promisify11(tmp.tmpName);
|
|
251763
251978
|
|
|
251764
251979
|
// src/cli/dev/dev-server/function-manager.ts
|
|
251765
|
-
import { spawn as
|
|
251980
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
251766
251981
|
import { dirname as dirname23, join as join31 } from "node:path";
|
|
251767
251982
|
import { pathToFileURL } from "node:url";
|
|
251768
251983
|
|
|
@@ -251860,7 +252075,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
251860
252075
|
async stopFunction(_name, { process: proc }) {
|
|
251861
252076
|
const exited = new Promise((r) => proc.once("exit", () => r()));
|
|
251862
252077
|
if (process.platform === "win32" && proc.pid) {
|
|
251863
|
-
|
|
252078
|
+
spawn3("taskkill", ["/pid", String(proc.pid), "/T", "/F"]);
|
|
251864
252079
|
} else {
|
|
251865
252080
|
proc.kill();
|
|
251866
252081
|
}
|
|
@@ -251869,7 +252084,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
251869
252084
|
spawnFunction(func, port) {
|
|
251870
252085
|
this.logger.log(`Spawning function "${func.name}" on port ${port}`);
|
|
251871
252086
|
const importMapPath = join31(dirname23(this.wrapperPath), "import-map.json");
|
|
251872
|
-
const process2 =
|
|
252087
|
+
const process2 = spawn3("deno", ["run", "--allow-all", "--import-map", importMapPath, this.wrapperPath], {
|
|
251873
252088
|
env: {
|
|
251874
252089
|
...globalThis.process.env,
|
|
251875
252090
|
FUNCTION_PATH: pathToFileURL(func.entryPath).href,
|
|
@@ -255399,127 +255614,6 @@ async function createDevServer(options) {
|
|
|
255399
255614
|
return { port, server, shutdown };
|
|
255400
255615
|
}
|
|
255401
255616
|
|
|
255402
|
-
// src/cli/dev/dev-server/serve-runner.ts
|
|
255403
|
-
import { spawn as spawn3 } from "node:child_process";
|
|
255404
|
-
import process23 from "node:process";
|
|
255405
|
-
|
|
255406
|
-
class ServeRunner {
|
|
255407
|
-
command;
|
|
255408
|
-
cwd;
|
|
255409
|
-
env;
|
|
255410
|
-
logger;
|
|
255411
|
-
child;
|
|
255412
|
-
stopping = false;
|
|
255413
|
-
stopPromise;
|
|
255414
|
-
exitListeners = [];
|
|
255415
|
-
constructor(options) {
|
|
255416
|
-
this.command = options.command;
|
|
255417
|
-
this.cwd = options.cwd;
|
|
255418
|
-
this.env = options.env;
|
|
255419
|
-
this.logger = options.logger;
|
|
255420
|
-
}
|
|
255421
|
-
start() {
|
|
255422
|
-
if (this.child) {
|
|
255423
|
-
return;
|
|
255424
|
-
}
|
|
255425
|
-
const stdin = process23.platform === "win32" ? "ignore" : "inherit";
|
|
255426
|
-
const child = spawn3(this.command, {
|
|
255427
|
-
cwd: this.cwd,
|
|
255428
|
-
shell: true,
|
|
255429
|
-
detached: process23.platform !== "win32",
|
|
255430
|
-
env: { ...process23.env, ...this.env },
|
|
255431
|
-
stdio: [stdin, "pipe", "pipe"],
|
|
255432
|
-
windowsHide: true
|
|
255433
|
-
});
|
|
255434
|
-
this.child = child;
|
|
255435
|
-
this.setupHandlers(child);
|
|
255436
|
-
}
|
|
255437
|
-
onExit(listener) {
|
|
255438
|
-
this.exitListeners.push(listener);
|
|
255439
|
-
}
|
|
255440
|
-
async stop() {
|
|
255441
|
-
if (this.stopPromise) {
|
|
255442
|
-
return this.stopPromise;
|
|
255443
|
-
}
|
|
255444
|
-
this.stopPromise = this.stopChild();
|
|
255445
|
-
return this.stopPromise;
|
|
255446
|
-
}
|
|
255447
|
-
async stopChild() {
|
|
255448
|
-
const child = this.child;
|
|
255449
|
-
if (!child || child.exitCode !== null) {
|
|
255450
|
-
return;
|
|
255451
|
-
}
|
|
255452
|
-
this.stopping = true;
|
|
255453
|
-
const exited = new Promise((resolve) => child.once("exit", () => resolve()));
|
|
255454
|
-
if (process23.platform === "win32" && child.pid) {
|
|
255455
|
-
const taskkill = spawn3("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
255456
|
-
stdio: "ignore",
|
|
255457
|
-
windowsHide: true
|
|
255458
|
-
});
|
|
255459
|
-
await new Promise((resolve) => {
|
|
255460
|
-
taskkill.once("exit", () => resolve());
|
|
255461
|
-
taskkill.once("error", () => resolve());
|
|
255462
|
-
});
|
|
255463
|
-
} else if (child.pid) {
|
|
255464
|
-
try {
|
|
255465
|
-
process23.kill(-child.pid, "SIGTERM");
|
|
255466
|
-
} catch {
|
|
255467
|
-
child.kill();
|
|
255468
|
-
}
|
|
255469
|
-
}
|
|
255470
|
-
await exited;
|
|
255471
|
-
}
|
|
255472
|
-
setupHandlers(child) {
|
|
255473
|
-
child.stdout?.on("data", (data) => this.emitLines(data, "log"));
|
|
255474
|
-
child.stderr?.on("data", (data) => this.emitLines(data, "error"));
|
|
255475
|
-
child.on("error", (error) => {
|
|
255476
|
-
this.logger.error("Frontend dev server failed to start:", error);
|
|
255477
|
-
this.notifyExit(null);
|
|
255478
|
-
});
|
|
255479
|
-
child.on("exit", (code) => {
|
|
255480
|
-
if (this.stopping) {
|
|
255481
|
-
return;
|
|
255482
|
-
}
|
|
255483
|
-
this.logger.error(`Frontend dev server exited with code ${code}`);
|
|
255484
|
-
this.notifyExit(code);
|
|
255485
|
-
});
|
|
255486
|
-
}
|
|
255487
|
-
notifyExit(code) {
|
|
255488
|
-
for (const listener of this.exitListeners) {
|
|
255489
|
-
listener(code);
|
|
255490
|
-
}
|
|
255491
|
-
}
|
|
255492
|
-
emitLines(data, type) {
|
|
255493
|
-
const lines = data.toString().trimEnd().split(`
|
|
255494
|
-
`);
|
|
255495
|
-
for (const line of lines) {
|
|
255496
|
-
if (type === "error") {
|
|
255497
|
-
this.logger.error(line);
|
|
255498
|
-
} else {
|
|
255499
|
-
this.logger.log(line);
|
|
255500
|
-
}
|
|
255501
|
-
}
|
|
255502
|
-
}
|
|
255503
|
-
}
|
|
255504
|
-
|
|
255505
|
-
// src/cli/dev/serve-command-runner.ts
|
|
255506
|
-
function createServeCommandRunner({
|
|
255507
|
-
serveCommand,
|
|
255508
|
-
projectRoot,
|
|
255509
|
-
appId,
|
|
255510
|
-
appBaseUrl
|
|
255511
|
-
}) {
|
|
255512
|
-
return new ServeRunner({
|
|
255513
|
-
command: serveCommand,
|
|
255514
|
-
cwd: projectRoot,
|
|
255515
|
-
env: {
|
|
255516
|
-
VITE_BASE44_APP_ID: appId,
|
|
255517
|
-
VITE_BASE44_APP_BASE_URL: appBaseUrl
|
|
255518
|
-
},
|
|
255519
|
-
logger: createDevLogger("frontend", theme.colors.base44Orange)
|
|
255520
|
-
});
|
|
255521
|
-
}
|
|
255522
|
-
|
|
255523
255617
|
// src/cli/commands/dev.ts
|
|
255524
255618
|
function localServerUrl(port) {
|
|
255525
255619
|
return `http://localhost:${port}`;
|
|
@@ -255545,11 +255639,6 @@ async function resolveConfiguredSite(app) {
|
|
|
255545
255639
|
const serveCommand = project.site?.serveCommand;
|
|
255546
255640
|
return serveCommand ? { serveCommand, projectRoot: project.root } : undefined;
|
|
255547
255641
|
}
|
|
255548
|
-
function stopRunnerOnProcessSignals(runner) {
|
|
255549
|
-
const stop = () => void runner.stop();
|
|
255550
|
-
process.on("SIGINT", stop);
|
|
255551
|
-
process.on("SIGTERM", stop);
|
|
255552
|
-
}
|
|
255553
255642
|
function startServeCommand(runner, backend) {
|
|
255554
255643
|
stopRunnerOnProcessSignals(runner);
|
|
255555
255644
|
runner.onExit(() => {
|
|
@@ -255561,7 +255650,7 @@ function startServeCommand(runner, backend) {
|
|
|
255561
255650
|
async function remoteDevAction(app) {
|
|
255562
255651
|
const site = await resolveConfiguredSite(app);
|
|
255563
255652
|
if (!site) {
|
|
255564
|
-
throw new ConfigInvalidError(
|
|
255653
|
+
throw new ConfigInvalidError(`base44 dev --remote serves the frontend against the production backend, but this project has no 'site' block in base44/config.jsonc. Add one; inside it serveCommand defaults to "npm run dev".`);
|
|
255565
255654
|
}
|
|
255566
255655
|
const appBaseUrl = await getSiteUrl();
|
|
255567
255656
|
const runner = createServeCommandRunner({
|
|
@@ -255812,16 +255901,17 @@ async function eject(ctx, options, command) {
|
|
|
255812
255901
|
errorMessage: "Failed to pull project"
|
|
255813
255902
|
});
|
|
255814
255903
|
const { project } = await readProjectConfig(resolvedPath);
|
|
255815
|
-
const
|
|
255816
|
-
|
|
255904
|
+
const installCommand = project.site?.installCommand;
|
|
255905
|
+
const buildCommand = project.site?.buildCommand;
|
|
255906
|
+
if (installCommand && buildCommand) {
|
|
255817
255907
|
const shouldDeploy = options.yes ? true : await Re({
|
|
255818
255908
|
message: "Would you like to deploy your project now?"
|
|
255819
255909
|
});
|
|
255820
255910
|
if (!Ct(shouldDeploy) && shouldDeploy) {
|
|
255821
255911
|
await runTask("Installing dependencies...", async (updateMessage) => {
|
|
255822
|
-
await execa({ cwd: resolvedPath, shell: true })`${
|
|
255912
|
+
await execa({ cwd: resolvedPath, shell: true })`${installCommand}`;
|
|
255823
255913
|
updateMessage("Building project...");
|
|
255824
|
-
await execa({ cwd: resolvedPath, shell: true })`${
|
|
255914
|
+
await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
|
|
255825
255915
|
}, {
|
|
255826
255916
|
successMessage: theme.colors.base44Orange("Project built successfully"),
|
|
255827
255917
|
errorMessage: "Failed to build project"
|
|
@@ -255859,6 +255949,7 @@ function createProgram(context) {
|
|
|
255859
255949
|
program.addCommand(getCreateCommand());
|
|
255860
255950
|
program.addCommand(getScaffoldCommand());
|
|
255861
255951
|
program.addCommand(getDashboardCommand());
|
|
255952
|
+
program.addCommand(getInstallCommand());
|
|
255862
255953
|
program.addCommand(getBuildCommand());
|
|
255863
255954
|
program.addCommand(getDeployCommand3());
|
|
255864
255955
|
program.addCommand(getVisibilityCommand());
|
|
@@ -259928,4 +260019,4 @@ export {
|
|
|
259928
260019
|
runCLI
|
|
259929
260020
|
};
|
|
259930
260021
|
|
|
259931
|
-
//# debugId=
|
|
260022
|
+
//# debugId=26F032DEEC9B5A8664756E2164756E21
|