@base44-preview/cli 0.1.16-pr.635.f70a612 → 0.1.16-pr.637.845faaa
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 +225 -285
- package/dist/cli/index.js.map +17 -21
- 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 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")) {
|
|
@@ -228470,6 +228470,17 @@ class DependencyNotFoundError extends UserError {
|
|
|
228470
228470
|
});
|
|
228471
228471
|
}
|
|
228472
228472
|
}
|
|
228473
|
+
var MAX_RESPONSE_TEXT_CHARS = 500;
|
|
228474
|
+
async function readResponseText(response) {
|
|
228475
|
+
try {
|
|
228476
|
+
const text = (await response.clone().text()).trim();
|
|
228477
|
+
if (!text)
|
|
228478
|
+
return;
|
|
228479
|
+
return text.length > MAX_RESPONSE_TEXT_CHARS ? `${text.slice(0, MAX_RESPONSE_TEXT_CHARS)}…` : text;
|
|
228480
|
+
} catch {
|
|
228481
|
+
return;
|
|
228482
|
+
}
|
|
228483
|
+
}
|
|
228473
228484
|
|
|
228474
228485
|
class ApiError extends SystemError {
|
|
228475
228486
|
code = "API_ERROR";
|
|
@@ -228505,7 +228516,9 @@ class ApiError extends SystemError {
|
|
|
228505
228516
|
details = parseErrorDetails(parsedData.extra_data);
|
|
228506
228517
|
}
|
|
228507
228518
|
} catch {
|
|
228508
|
-
|
|
228519
|
+
const body = await readResponseText(error.response);
|
|
228520
|
+
responseBody = body;
|
|
228521
|
+
message = body ? `${error.message} — ${body}` : `${error.message} — empty body, content-type ${error.response.headers.get("content-type") ?? "absent"}`;
|
|
228509
228522
|
}
|
|
228510
228523
|
const statusCode = ApiError.normalizeStatusCode(error.response.status, responseBody);
|
|
228511
228524
|
const requestBody = error.options.context?.__requestBody;
|
|
@@ -230705,11 +230718,10 @@ var TemplatesConfigSchema = object({
|
|
|
230705
230718
|
templates: array(TemplateSchema)
|
|
230706
230719
|
});
|
|
230707
230720
|
var SiteConfigSchema = object({
|
|
230708
|
-
buildCommand: string2().
|
|
230721
|
+
buildCommand: string2().default("npm run build"),
|
|
230709
230722
|
serveCommand: string2().optional(),
|
|
230710
|
-
outputDirectory: string2().optional()
|
|
230711
|
-
installCommand: string2().
|
|
230712
|
-
devHostFlag: string2().optional().default("--host")
|
|
230723
|
+
outputDirectory: string2().optional(),
|
|
230724
|
+
installCommand: string2().default("npm install")
|
|
230713
230725
|
});
|
|
230714
230726
|
var PluginMetadataSchema = object({
|
|
230715
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")
|
|
@@ -236546,10 +236558,12 @@ var CreateDeploymentResponseSchema = object({
|
|
|
236546
236558
|
url: string2()
|
|
236547
236559
|
}))
|
|
236548
236560
|
})
|
|
236549
|
-
]).nullable().optional()
|
|
236561
|
+
]).nullable().optional(),
|
|
236562
|
+
index_html_staged: boolean2().optional().default(false)
|
|
236550
236563
|
}).transform((data) => ({
|
|
236551
236564
|
deploymentId: data.deployment_id,
|
|
236552
236565
|
sessionId: data.session_id,
|
|
236566
|
+
indexHtmlStaged: data.index_html_staged,
|
|
236553
236567
|
assetUploads: data.asset_uploads == null ? null : data.asset_uploads.type === "cf" ? data.asset_uploads : {
|
|
236554
236568
|
type: "s3",
|
|
236555
236569
|
uploads: data.asset_uploads.uploads.map((upload) => ({
|
|
@@ -239512,9 +239526,9 @@ async function createDeployment(request) {
|
|
|
239512
239526
|
}
|
|
239513
239527
|
async function finalizeDeployment(deploymentId, sessionId, payload) {
|
|
239514
239528
|
const formData = new FormData;
|
|
239515
|
-
if ("
|
|
239529
|
+
if (payload.kind === "static-inline") {
|
|
239516
239530
|
formData.append("index.html", new File([payload.indexHtml], "index.html", { type: "text/html" }));
|
|
239517
|
-
} else {
|
|
239531
|
+
} else if (payload.kind === "worker") {
|
|
239518
239532
|
formData.append("payload", JSON.stringify({ completion_jwt: payload.completionJwt }));
|
|
239519
239533
|
for (const module of payload.modules) {
|
|
239520
239534
|
const content = await readFile(module.absolutePath);
|
|
@@ -240099,17 +240113,20 @@ async function deployToDeployments(options) {
|
|
|
240099
240113
|
const worker = await resolveWorkerBuild(projectRoot, progress);
|
|
240100
240114
|
const assetsDir = worker ? worker.assetsDir : outputDir;
|
|
240101
240115
|
const assets = assetsDir ? await buildAssetManifest(assetsDir, getAppContext().id) : NO_ASSETS;
|
|
240102
|
-
|
|
240116
|
+
if (!worker) {
|
|
240117
|
+
requireStaticEntryPoint(assetsDir, assets);
|
|
240118
|
+
}
|
|
240103
240119
|
const created = await createDeployment({
|
|
240104
240120
|
git_hash: gitHash,
|
|
240105
240121
|
config: worker?.config,
|
|
240106
240122
|
asset_manifest: assets.manifest
|
|
240107
240123
|
});
|
|
240108
240124
|
const completionJwt = await uploadDeploymentAssets(created.assetUploads, assets, { concurrency, progress });
|
|
240109
|
-
|
|
240125
|
+
const completion = worker ? { kind: "worker", modules: worker.modules, completionJwt } : await resolveStaticCompletion(assetsDir, assets, created.indexHtmlStaged);
|
|
240126
|
+
if (completion.kind === "worker") {
|
|
240110
240127
|
progress?.onWorker?.({ moduleCount: completion.modules.length });
|
|
240111
240128
|
}
|
|
240112
|
-
const finalized = await finalizeDeployment(created.deploymentId, created.sessionId,
|
|
240129
|
+
const finalized = await finalizeDeployment(created.deploymentId, created.sessionId, completion);
|
|
240113
240130
|
return { deploymentId: finalized.deploymentId, gitHash };
|
|
240114
240131
|
}
|
|
240115
240132
|
async function resolveWorkerBuild(projectRoot, progress) {
|
|
@@ -240130,11 +240147,20 @@ async function resolveWorkerBuild(projectRoot, progress) {
|
|
|
240130
240147
|
assetsDir
|
|
240131
240148
|
};
|
|
240132
240149
|
}
|
|
240133
|
-
|
|
240150
|
+
function requireStaticEntryPoint(assetsDir, assets) {
|
|
240134
240151
|
if (!assetsDir || !assets.manifest["/index.html"]) {
|
|
240135
240152
|
throw new InvalidInputError(`No index.html found in "${assetsDir ?? "the site output directory"}" — a static site needs one at the output directory root.`);
|
|
240136
240153
|
}
|
|
240137
|
-
return
|
|
240154
|
+
return assetsDir;
|
|
240155
|
+
}
|
|
240156
|
+
async function resolveStaticCompletion(assetsDir, assets, indexHtmlStaged) {
|
|
240157
|
+
if (indexHtmlStaged)
|
|
240158
|
+
return { kind: "static-staged" };
|
|
240159
|
+
const dir = requireStaticEntryPoint(assetsDir, assets);
|
|
240160
|
+
return {
|
|
240161
|
+
kind: "static-inline",
|
|
240162
|
+
indexHtml: new Uint8Array(await readFile3(join18(dir, "index.html")))
|
|
240163
|
+
};
|
|
240138
240164
|
}
|
|
240139
240165
|
function buildAssetsConfig(assetsConfig, progress) {
|
|
240140
240166
|
if (!assetsConfig)
|
|
@@ -246680,22 +246706,6 @@ async function gitHead(projectRoot) {
|
|
|
246680
246706
|
return null;
|
|
246681
246707
|
}
|
|
246682
246708
|
}
|
|
246683
|
-
// src/core/site/serve-command.ts
|
|
246684
|
-
var DEFAULT_SERVE_COMMAND = "npm run dev";
|
|
246685
|
-
var NPM_RUN_COMMAND = /^npm(\s+--prefix\s+\S+)?\s+run\s+\S+$/;
|
|
246686
|
-
function withServeAddress(serveCommand, { host, port, hostFlag }) {
|
|
246687
|
-
const args = [
|
|
246688
|
-
...host ? [hostFlag, host] : [],
|
|
246689
|
-
...port === undefined ? [] : ["--port", String(port)]
|
|
246690
|
-
];
|
|
246691
|
-
if (args.length === 0 || !NPM_RUN_COMMAND.test(serveCommand.trim())) {
|
|
246692
|
-
return serveCommand;
|
|
246693
|
-
}
|
|
246694
|
-
return `${serveCommand} -- ${args.join(" ")}`;
|
|
246695
|
-
}
|
|
246696
|
-
function forwardsServeAddress(serveCommand) {
|
|
246697
|
-
return NPM_RUN_COMMAND.test(serveCommand.trim());
|
|
246698
|
-
}
|
|
246699
246709
|
// src/core/project/deploy.ts
|
|
246700
246710
|
function hasResourcesToDeploy(projectData) {
|
|
246701
246711
|
const {
|
|
@@ -246708,7 +246718,7 @@ function hasResourcesToDeploy(projectData) {
|
|
|
246708
246718
|
connectors,
|
|
246709
246719
|
authConfig
|
|
246710
246720
|
} = projectData;
|
|
246711
|
-
const hasSite = project.site
|
|
246721
|
+
const hasSite = Boolean(project.site?.outputDirectory);
|
|
246712
246722
|
const hasEntities = entities.length > 0;
|
|
246713
246723
|
const hasFunctions = functions.length > 0;
|
|
246714
246724
|
const hasActors = actors.length > 0;
|
|
@@ -249995,36 +250005,6 @@ function printStripeResult(r, log) {
|
|
|
249995
250005
|
log.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
|
|
249996
250006
|
}
|
|
249997
250007
|
|
|
249998
|
-
// src/cli/commands/project/install.ts
|
|
249999
|
-
async function installAction({
|
|
250000
|
-
runTask
|
|
250001
|
-
}) {
|
|
250002
|
-
const { project } = await readProjectConfig();
|
|
250003
|
-
const installCommand = project.site?.installCommand;
|
|
250004
|
-
if (!installCommand) {
|
|
250005
|
-
throw new ConfigNotFoundError("No site install command found.", {
|
|
250006
|
-
hints: [
|
|
250007
|
-
{
|
|
250008
|
-
message: `Add a 'site' block to your config.jsonc (e.g., "site": { "installCommand": "npm ci" }). Inside one, installCommand defaults to "npm install".`
|
|
250009
|
-
}
|
|
250010
|
-
]
|
|
250011
|
-
});
|
|
250012
|
-
}
|
|
250013
|
-
await runTask("Installing site dependencies...", () => execa({ cwd: project.root, shell: true })`${installCommand}`, {
|
|
250014
|
-
successMessage: "Dependencies installed",
|
|
250015
|
-
errorMessage: "Install failed"
|
|
250016
|
-
});
|
|
250017
|
-
return {
|
|
250018
|
-
outroMessage: `Installed with ${theme.styles.bold(installCommand)}`
|
|
250019
|
-
};
|
|
250020
|
-
}
|
|
250021
|
-
function getInstallCommand() {
|
|
250022
|
-
return new Base44Command("install", {
|
|
250023
|
-
requireAuth: false,
|
|
250024
|
-
requireAppContext: false
|
|
250025
|
-
}).description("Install the site's dependencies with its configured command").action(installAction);
|
|
250026
|
-
}
|
|
250027
|
-
|
|
250028
250008
|
// src/cli/commands/project/app-id-options.ts
|
|
250029
250009
|
function readExplicitAppId(command) {
|
|
250030
250010
|
const { appId } = command.optsWithGlobals();
|
|
@@ -251067,7 +251047,7 @@ async function deployTarball({ runTask }, project) {
|
|
|
251067
251047
|
throw new ConfigNotFoundError("No site configuration found.", {
|
|
251068
251048
|
hints: [
|
|
251069
251049
|
{
|
|
251070
|
-
message: `Add
|
|
251050
|
+
message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
|
|
251071
251051
|
}
|
|
251072
251052
|
]
|
|
251073
251053
|
});
|
|
@@ -251104,213 +251084,6 @@ function parseConcurrency(value) {
|
|
|
251104
251084
|
return parsed;
|
|
251105
251085
|
}
|
|
251106
251086
|
|
|
251107
|
-
// src/cli/dev/createDevLogger.ts
|
|
251108
|
-
var colorByType = {
|
|
251109
|
-
error: theme.styles.error,
|
|
251110
|
-
warn: theme.styles.warn,
|
|
251111
|
-
log: (input) => input
|
|
251112
|
-
};
|
|
251113
|
-
var stringify = (item) => {
|
|
251114
|
-
if (typeof item === "string") {
|
|
251115
|
-
return item;
|
|
251116
|
-
}
|
|
251117
|
-
if (item instanceof Error) {
|
|
251118
|
-
return item.toString();
|
|
251119
|
-
}
|
|
251120
|
-
try {
|
|
251121
|
-
return JSON.stringify(item, null, 2) ?? String(item);
|
|
251122
|
-
} catch {
|
|
251123
|
-
return String(item);
|
|
251124
|
-
}
|
|
251125
|
-
};
|
|
251126
|
-
function createDevLogger(label, labelColor = theme.styles.dim) {
|
|
251127
|
-
const prefix = label ? `${labelColor(`[${label}]`)} ` : "";
|
|
251128
|
-
const print = (type, ...args) => {
|
|
251129
|
-
const colorize = colorByType[type];
|
|
251130
|
-
console[type](prefix + args.map((item) => colorize(stringify(item))).join(" "));
|
|
251131
|
-
};
|
|
251132
|
-
return {
|
|
251133
|
-
log: (...args) => print("log", ...args),
|
|
251134
|
-
error: (msg, err) => {
|
|
251135
|
-
print("error", msg);
|
|
251136
|
-
if (err) {
|
|
251137
|
-
print("error", err);
|
|
251138
|
-
}
|
|
251139
|
-
},
|
|
251140
|
-
warn: (...args) => print("warn", ...args)
|
|
251141
|
-
};
|
|
251142
|
-
}
|
|
251143
|
-
|
|
251144
|
-
// src/cli/dev/dev-server/serve-runner.ts
|
|
251145
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
251146
|
-
import process21 from "node:process";
|
|
251147
|
-
|
|
251148
|
-
class ServeRunner {
|
|
251149
|
-
command;
|
|
251150
|
-
cwd;
|
|
251151
|
-
env;
|
|
251152
|
-
logger;
|
|
251153
|
-
child;
|
|
251154
|
-
stopping = false;
|
|
251155
|
-
stopPromise;
|
|
251156
|
-
exitListeners = [];
|
|
251157
|
-
constructor(options) {
|
|
251158
|
-
this.command = options.command;
|
|
251159
|
-
this.cwd = options.cwd;
|
|
251160
|
-
this.env = options.env;
|
|
251161
|
-
this.logger = options.logger;
|
|
251162
|
-
}
|
|
251163
|
-
start() {
|
|
251164
|
-
if (this.child) {
|
|
251165
|
-
return;
|
|
251166
|
-
}
|
|
251167
|
-
const stdin = process21.platform === "win32" ? "ignore" : "inherit";
|
|
251168
|
-
const child = spawn2(this.command, {
|
|
251169
|
-
cwd: this.cwd,
|
|
251170
|
-
shell: true,
|
|
251171
|
-
detached: process21.platform !== "win32",
|
|
251172
|
-
env: { ...process21.env, ...this.env },
|
|
251173
|
-
stdio: [stdin, "pipe", "pipe"],
|
|
251174
|
-
windowsHide: true
|
|
251175
|
-
});
|
|
251176
|
-
this.child = child;
|
|
251177
|
-
this.setupHandlers(child);
|
|
251178
|
-
}
|
|
251179
|
-
onExit(listener) {
|
|
251180
|
-
this.exitListeners.push(listener);
|
|
251181
|
-
}
|
|
251182
|
-
async stop() {
|
|
251183
|
-
if (this.stopPromise) {
|
|
251184
|
-
return this.stopPromise;
|
|
251185
|
-
}
|
|
251186
|
-
this.stopPromise = this.stopChild();
|
|
251187
|
-
return this.stopPromise;
|
|
251188
|
-
}
|
|
251189
|
-
async stopChild() {
|
|
251190
|
-
const child = this.child;
|
|
251191
|
-
if (!child || child.exitCode !== null) {
|
|
251192
|
-
return;
|
|
251193
|
-
}
|
|
251194
|
-
this.stopping = true;
|
|
251195
|
-
const exited = new Promise((resolve) => child.once("exit", () => resolve()));
|
|
251196
|
-
if (process21.platform === "win32" && child.pid) {
|
|
251197
|
-
const taskkill = spawn2("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
251198
|
-
stdio: "ignore",
|
|
251199
|
-
windowsHide: true
|
|
251200
|
-
});
|
|
251201
|
-
await new Promise((resolve) => {
|
|
251202
|
-
taskkill.once("exit", () => resolve());
|
|
251203
|
-
taskkill.once("error", () => resolve());
|
|
251204
|
-
});
|
|
251205
|
-
} else if (child.pid) {
|
|
251206
|
-
try {
|
|
251207
|
-
process21.kill(-child.pid, "SIGTERM");
|
|
251208
|
-
} catch {
|
|
251209
|
-
child.kill();
|
|
251210
|
-
}
|
|
251211
|
-
}
|
|
251212
|
-
await exited;
|
|
251213
|
-
}
|
|
251214
|
-
setupHandlers(child) {
|
|
251215
|
-
child.stdout?.on("data", (data) => this.emitLines(data, "log"));
|
|
251216
|
-
child.stderr?.on("data", (data) => this.emitLines(data, "error"));
|
|
251217
|
-
child.on("error", (error) => {
|
|
251218
|
-
this.logger.error("Frontend dev server failed to start:", error);
|
|
251219
|
-
this.notifyExit(null);
|
|
251220
|
-
});
|
|
251221
|
-
child.on("exit", (code) => {
|
|
251222
|
-
if (this.stopping) {
|
|
251223
|
-
return;
|
|
251224
|
-
}
|
|
251225
|
-
this.logger.error(`Frontend dev server exited with code ${code}`);
|
|
251226
|
-
this.notifyExit(code);
|
|
251227
|
-
});
|
|
251228
|
-
}
|
|
251229
|
-
notifyExit(code) {
|
|
251230
|
-
for (const listener of this.exitListeners) {
|
|
251231
|
-
listener(code);
|
|
251232
|
-
}
|
|
251233
|
-
}
|
|
251234
|
-
emitLines(data, type) {
|
|
251235
|
-
const lines = data.toString().trimEnd().split(`
|
|
251236
|
-
`);
|
|
251237
|
-
for (const line of lines) {
|
|
251238
|
-
if (type === "error") {
|
|
251239
|
-
this.logger.error(line);
|
|
251240
|
-
} else {
|
|
251241
|
-
this.logger.log(line);
|
|
251242
|
-
}
|
|
251243
|
-
}
|
|
251244
|
-
}
|
|
251245
|
-
}
|
|
251246
|
-
|
|
251247
|
-
// src/cli/dev/serve-command-runner.ts
|
|
251248
|
-
function createServeCommandRunner({
|
|
251249
|
-
serveCommand,
|
|
251250
|
-
projectRoot,
|
|
251251
|
-
appId,
|
|
251252
|
-
appBaseUrl
|
|
251253
|
-
}) {
|
|
251254
|
-
return new ServeRunner({
|
|
251255
|
-
command: serveCommand,
|
|
251256
|
-
cwd: projectRoot,
|
|
251257
|
-
env: {
|
|
251258
|
-
VITE_BASE44_APP_ID: appId,
|
|
251259
|
-
VITE_BASE44_APP_BASE_URL: appBaseUrl
|
|
251260
|
-
},
|
|
251261
|
-
logger: createDevLogger("frontend", theme.colors.base44Orange)
|
|
251262
|
-
});
|
|
251263
|
-
}
|
|
251264
|
-
|
|
251265
|
-
// src/cli/dev/stop-runner-on-signals.ts
|
|
251266
|
-
import process22 from "node:process";
|
|
251267
|
-
function stopRunnerOnProcessSignals(runner) {
|
|
251268
|
-
const stop = () => void runner.stop();
|
|
251269
|
-
process22.on("SIGINT", stop);
|
|
251270
|
-
process22.on("SIGTERM", stop);
|
|
251271
|
-
}
|
|
251272
|
-
|
|
251273
|
-
// src/cli/commands/site/dev.ts
|
|
251274
|
-
async function siteDevAction(ctx, options) {
|
|
251275
|
-
const { app, log } = ctx;
|
|
251276
|
-
if (!app) {
|
|
251277
|
-
throw new InvalidInputError("No app id resolved for this project.");
|
|
251278
|
-
}
|
|
251279
|
-
const port = options.port === undefined ? undefined : Number(options.port);
|
|
251280
|
-
if (port !== undefined && !Number.isInteger(port)) {
|
|
251281
|
-
throw new InvalidInputError(`--port must be a whole number: ${options.port}`);
|
|
251282
|
-
}
|
|
251283
|
-
const { project } = await readProjectConfig(app.projectRoot);
|
|
251284
|
-
const site = project.site;
|
|
251285
|
-
if (!site) {
|
|
251286
|
-
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".`);
|
|
251287
|
-
}
|
|
251288
|
-
const serveCommand = site.serveCommand ?? DEFAULT_SERVE_COMMAND;
|
|
251289
|
-
const command = withServeAddress(serveCommand, {
|
|
251290
|
-
host: options.host,
|
|
251291
|
-
port,
|
|
251292
|
-
hostFlag: site.devHostFlag
|
|
251293
|
-
});
|
|
251294
|
-
if ((options.host || port !== undefined) && !forwardsServeAddress(serveCommand)) {
|
|
251295
|
-
log.warn(`serveCommand '${serveCommand}' is not an 'npm run' invocation, so --host/--port were not passed to it. Put the address in serveCommand itself.`);
|
|
251296
|
-
}
|
|
251297
|
-
const runner = createServeCommandRunner({
|
|
251298
|
-
serveCommand: command,
|
|
251299
|
-
projectRoot: project.root,
|
|
251300
|
-
appId: app.id,
|
|
251301
|
-
appBaseUrl: options.backendUrl
|
|
251302
|
-
});
|
|
251303
|
-
stopRunnerOnProcessSignals(runner);
|
|
251304
|
-
runner.onExit((code) => process.exit(code ?? 1));
|
|
251305
|
-
runner.start();
|
|
251306
|
-
return {
|
|
251307
|
-
outroMessage: `Frontend dev server running '${command}' against ${theme.styles.bold(options.backendUrl)}`
|
|
251308
|
-
};
|
|
251309
|
-
}
|
|
251310
|
-
function getSiteDevCommand() {
|
|
251311
|
-
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);
|
|
251312
|
-
}
|
|
251313
|
-
|
|
251314
251087
|
// src/cli/commands/site/open.ts
|
|
251315
251088
|
async function openAction({
|
|
251316
251089
|
isNonInteractive
|
|
@@ -251327,7 +251100,7 @@ function getSiteOpenCommand() {
|
|
|
251327
251100
|
|
|
251328
251101
|
// src/cli/commands/site/index.ts
|
|
251329
251102
|
function getSiteCommand() {
|
|
251330
|
-
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());
|
|
251331
251104
|
}
|
|
251332
251105
|
|
|
251333
251106
|
// src/core/types/generator.ts
|
|
@@ -251847,6 +251620,43 @@ function getWorkspaceCommand() {
|
|
|
251847
251620
|
return new Command2("workspace").description("List workspaces, inspect one, and move apps between them").addCommand(getWorkspaceListCommand()).addCommand(getWorkspaceGetCommand()).addCommand(getWorkspaceMoveCommand());
|
|
251848
251621
|
}
|
|
251849
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
|
+
|
|
251850
251660
|
// src/cli/dev/dev-server/main.ts
|
|
251851
251661
|
var import_cors = __toESM(require_lib4(), 1);
|
|
251852
251662
|
var import_express6 = __toESM(require_express(), 1);
|
|
@@ -251979,7 +251789,7 @@ var $dir = async (options) => dirWithOptions(options);
|
|
|
251979
251789
|
var $tmpName = promisify11(tmp.tmpName);
|
|
251980
251790
|
|
|
251981
251791
|
// src/cli/dev/dev-server/function-manager.ts
|
|
251982
|
-
import { spawn as
|
|
251792
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
251983
251793
|
import { dirname as dirname23, join as join31 } from "node:path";
|
|
251984
251794
|
import { pathToFileURL } from "node:url";
|
|
251985
251795
|
|
|
@@ -252077,7 +251887,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
252077
251887
|
async stopFunction(_name, { process: proc }) {
|
|
252078
251888
|
const exited = new Promise((r) => proc.once("exit", () => r()));
|
|
252079
251889
|
if (process.platform === "win32" && proc.pid) {
|
|
252080
|
-
|
|
251890
|
+
spawn2("taskkill", ["/pid", String(proc.pid), "/T", "/F"]);
|
|
252081
251891
|
} else {
|
|
252082
251892
|
proc.kill();
|
|
252083
251893
|
}
|
|
@@ -252086,7 +251896,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
252086
251896
|
spawnFunction(func, port) {
|
|
252087
251897
|
this.logger.log(`Spawning function "${func.name}" on port ${port}`);
|
|
252088
251898
|
const importMapPath = join31(dirname23(this.wrapperPath), "import-map.json");
|
|
252089
|
-
const process2 =
|
|
251899
|
+
const process2 = spawn2("deno", ["run", "--allow-all", "--import-map", importMapPath, this.wrapperPath], {
|
|
252090
251900
|
env: {
|
|
252091
251901
|
...globalThis.process.env,
|
|
252092
251902
|
FUNCTION_PATH: pathToFileURL(func.entryPath).href,
|
|
@@ -255616,6 +255426,127 @@ async function createDevServer(options) {
|
|
|
255616
255426
|
return { port, server, shutdown };
|
|
255617
255427
|
}
|
|
255618
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
|
+
|
|
255619
255550
|
// src/cli/commands/dev.ts
|
|
255620
255551
|
function localServerUrl(port) {
|
|
255621
255552
|
return `http://localhost:${port}`;
|
|
@@ -255641,6 +255572,11 @@ async function resolveConfiguredSite(app) {
|
|
|
255641
255572
|
const serveCommand = project.site?.serveCommand;
|
|
255642
255573
|
return serveCommand ? { serveCommand, projectRoot: project.root } : undefined;
|
|
255643
255574
|
}
|
|
255575
|
+
function stopRunnerOnProcessSignals(runner) {
|
|
255576
|
+
const stop = () => void runner.stop();
|
|
255577
|
+
process.on("SIGINT", stop);
|
|
255578
|
+
process.on("SIGTERM", stop);
|
|
255579
|
+
}
|
|
255644
255580
|
function startServeCommand(runner, backend) {
|
|
255645
255581
|
stopRunnerOnProcessSignals(runner);
|
|
255646
255582
|
runner.onExit(() => {
|
|
@@ -255903,17 +255839,22 @@ async function eject(ctx, options, command) {
|
|
|
255903
255839
|
errorMessage: "Failed to pull project"
|
|
255904
255840
|
});
|
|
255905
255841
|
const { project } = await readProjectConfig(resolvedPath);
|
|
255906
|
-
const
|
|
255907
|
-
|
|
255908
|
-
if (installCommand && buildCommand) {
|
|
255842
|
+
const site = project.site;
|
|
255843
|
+
if (site) {
|
|
255909
255844
|
const shouldDeploy = options.yes ? true : await Re({
|
|
255910
255845
|
message: "Would you like to deploy your project now?"
|
|
255911
255846
|
});
|
|
255912
255847
|
if (!Ct(shouldDeploy) && shouldDeploy) {
|
|
255913
255848
|
await runTask("Installing dependencies...", async (updateMessage) => {
|
|
255914
|
-
await execa({
|
|
255849
|
+
await execa({
|
|
255850
|
+
cwd: resolvedPath,
|
|
255851
|
+
shell: true
|
|
255852
|
+
})`${site.installCommand}`;
|
|
255915
255853
|
updateMessage("Building project...");
|
|
255916
|
-
await execa({
|
|
255854
|
+
await execa({
|
|
255855
|
+
cwd: resolvedPath,
|
|
255856
|
+
shell: true
|
|
255857
|
+
})`${site.buildCommand}`;
|
|
255917
255858
|
}, {
|
|
255918
255859
|
successMessage: theme.colors.base44Orange("Project built successfully"),
|
|
255919
255860
|
errorMessage: "Failed to build project"
|
|
@@ -255951,7 +255892,6 @@ function createProgram(context) {
|
|
|
255951
255892
|
program.addCommand(getCreateCommand());
|
|
255952
255893
|
program.addCommand(getScaffoldCommand());
|
|
255953
255894
|
program.addCommand(getDashboardCommand());
|
|
255954
|
-
program.addCommand(getInstallCommand());
|
|
255955
255895
|
program.addCommand(getBuildCommand());
|
|
255956
255896
|
program.addCommand(getDeployCommand3());
|
|
255957
255897
|
program.addCommand(getVisibilityCommand());
|
|
@@ -260021,4 +259961,4 @@ export {
|
|
|
260021
259961
|
runCLI
|
|
260022
259962
|
};
|
|
260023
259963
|
|
|
260024
|
-
//# debugId=
|
|
259964
|
+
//# debugId=63C1B06EC5E5944F64756E2164756E21
|