@base44-preview/cli 0.1.6-pr.580.9cdb7f2 → 0.1.6-pr.580.9ed07b2

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 CHANGED
@@ -259073,6 +259073,127 @@ function createFunctionRouter(manager, logger2) {
259073
259073
  return router;
259074
259074
  }
259075
259075
 
259076
+ // src/cli/dev/dev-server/serve-runner.ts
259077
+ import { spawn as spawn3 } from "node:child_process";
259078
+ import process23 from "node:process";
259079
+
259080
+ class ServeRunner {
259081
+ command;
259082
+ cwd;
259083
+ env;
259084
+ logger;
259085
+ child;
259086
+ stopping = false;
259087
+ stopPromise;
259088
+ exitListeners = [];
259089
+ constructor(options8) {
259090
+ this.command = options8.command;
259091
+ this.cwd = options8.cwd;
259092
+ this.env = options8.env;
259093
+ this.logger = options8.logger;
259094
+ }
259095
+ start() {
259096
+ if (this.child) {
259097
+ return;
259098
+ }
259099
+ const stdin2 = process23.platform === "win32" ? "ignore" : "inherit";
259100
+ const child = spawn3(this.command, {
259101
+ cwd: this.cwd,
259102
+ shell: true,
259103
+ detached: process23.platform !== "win32",
259104
+ env: { ...process23.env, ...this.env },
259105
+ stdio: [stdin2, "pipe", "pipe"],
259106
+ windowsHide: true
259107
+ });
259108
+ this.child = child;
259109
+ this.setupHandlers(child);
259110
+ }
259111
+ onExit(listener) {
259112
+ this.exitListeners.push(listener);
259113
+ }
259114
+ async stop() {
259115
+ if (this.stopPromise) {
259116
+ return this.stopPromise;
259117
+ }
259118
+ this.stopPromise = this.stopChild();
259119
+ return this.stopPromise;
259120
+ }
259121
+ async stopChild() {
259122
+ const child = this.child;
259123
+ if (!child || child.exitCode !== null) {
259124
+ return;
259125
+ }
259126
+ this.stopping = true;
259127
+ const exited = new Promise((resolve13) => child.once("exit", () => resolve13()));
259128
+ if (process23.platform === "win32" && child.pid) {
259129
+ const taskkill = spawn3("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
259130
+ stdio: "ignore",
259131
+ windowsHide: true
259132
+ });
259133
+ await new Promise((resolve13) => {
259134
+ taskkill.once("exit", () => resolve13());
259135
+ taskkill.once("error", () => resolve13());
259136
+ });
259137
+ } else if (child.pid) {
259138
+ try {
259139
+ process23.kill(-child.pid, "SIGTERM");
259140
+ } catch {
259141
+ child.kill();
259142
+ }
259143
+ }
259144
+ await exited;
259145
+ }
259146
+ setupHandlers(child) {
259147
+ child.stdout?.on("data", (data) => this.emitLines(data, "log"));
259148
+ child.stderr?.on("data", (data) => this.emitLines(data, "error"));
259149
+ child.on("error", (error48) => {
259150
+ this.logger.error("Frontend dev server failed to start:", error48);
259151
+ this.notifyExit(null);
259152
+ });
259153
+ child.on("exit", (code2) => {
259154
+ if (this.stopping) {
259155
+ return;
259156
+ }
259157
+ this.logger.error(`Frontend dev server exited with code ${code2}`);
259158
+ this.notifyExit(code2);
259159
+ });
259160
+ }
259161
+ notifyExit(code2) {
259162
+ for (const listener of this.exitListeners) {
259163
+ listener(code2);
259164
+ }
259165
+ }
259166
+ emitLines(data, type) {
259167
+ const lines = data.toString().trimEnd().split(`
259168
+ `);
259169
+ for (const line3 of lines) {
259170
+ if (type === "error") {
259171
+ this.logger.error(line3);
259172
+ } else {
259173
+ this.logger.log(line3);
259174
+ }
259175
+ }
259176
+ }
259177
+ }
259178
+
259179
+ // src/cli/dev/frontend-runner.ts
259180
+ function createFrontendRunner({
259181
+ serveCommand,
259182
+ projectRoot,
259183
+ appId,
259184
+ appBaseUrl
259185
+ }) {
259186
+ return new ServeRunner({
259187
+ command: serveCommand,
259188
+ cwd: projectRoot,
259189
+ env: {
259190
+ VITE_BASE44_APP_ID: appId,
259191
+ VITE_BASE44_APP_BASE_URL: appBaseUrl
259192
+ },
259193
+ logger: createDevLogger("frontend", theme.colors.base44Orange)
259194
+ });
259195
+ }
259196
+
259076
259197
  // src/cli/dev/dev-server/db/database.ts
259077
259198
  var import_nedb = __toESM(require_nedb(), 1);
259078
259199
 
@@ -260211,109 +260332,6 @@ function createCustomIntegrationRoutes(remoteProxy, logger2) {
260211
260332
  return router;
260212
260333
  }
260213
260334
 
260214
- // src/cli/dev/dev-server/serve-runner.ts
260215
- import { spawn as spawn3 } from "node:child_process";
260216
- import process23 from "node:process";
260217
-
260218
- class ServeRunner {
260219
- command;
260220
- cwd;
260221
- env;
260222
- logger;
260223
- child;
260224
- stopping = false;
260225
- stopPromise;
260226
- exitListeners = [];
260227
- constructor(options8) {
260228
- this.command = options8.command;
260229
- this.cwd = options8.cwd;
260230
- this.env = options8.env;
260231
- this.logger = options8.logger;
260232
- }
260233
- start() {
260234
- if (this.child) {
260235
- return;
260236
- }
260237
- const stdin2 = process23.platform === "win32" ? "ignore" : "inherit";
260238
- const child = spawn3(this.command, {
260239
- cwd: this.cwd,
260240
- shell: true,
260241
- detached: process23.platform !== "win32",
260242
- env: { ...process23.env, ...this.env },
260243
- stdio: [stdin2, "pipe", "pipe"],
260244
- windowsHide: true
260245
- });
260246
- this.child = child;
260247
- this.setupHandlers(child);
260248
- }
260249
- onExit(listener) {
260250
- this.exitListeners.push(listener);
260251
- }
260252
- async stop() {
260253
- if (this.stopPromise) {
260254
- return this.stopPromise;
260255
- }
260256
- this.stopPromise = this.stopChild();
260257
- return this.stopPromise;
260258
- }
260259
- async stopChild() {
260260
- const child = this.child;
260261
- if (!child || child.exitCode !== null) {
260262
- return;
260263
- }
260264
- this.stopping = true;
260265
- const exited = new Promise((resolve13) => child.once("exit", () => resolve13()));
260266
- if (process23.platform === "win32" && child.pid) {
260267
- const taskkill = spawn3("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
260268
- stdio: "ignore",
260269
- windowsHide: true
260270
- });
260271
- await new Promise((resolve13) => {
260272
- taskkill.once("exit", () => resolve13());
260273
- taskkill.once("error", () => resolve13());
260274
- });
260275
- } else if (child.pid) {
260276
- try {
260277
- process23.kill(-child.pid, "SIGTERM");
260278
- } catch {
260279
- child.kill();
260280
- }
260281
- }
260282
- await exited;
260283
- }
260284
- setupHandlers(child) {
260285
- child.stdout?.on("data", (data) => this.emitLines(data, "log"));
260286
- child.stderr?.on("data", (data) => this.emitLines(data, "error"));
260287
- child.on("error", (error48) => {
260288
- this.logger.error("Frontend dev server failed to start:", error48);
260289
- this.notifyExit(null);
260290
- });
260291
- child.on("exit", (code2) => {
260292
- if (this.stopping) {
260293
- return;
260294
- }
260295
- this.logger.error(`Frontend dev server exited with code ${code2}`);
260296
- this.notifyExit(code2);
260297
- });
260298
- }
260299
- notifyExit(code2) {
260300
- for (const listener of this.exitListeners) {
260301
- listener(code2);
260302
- }
260303
- }
260304
- emitLines(data, type) {
260305
- const lines = data.toString().trimEnd().split(`
260306
- `);
260307
- for (const line3 of lines) {
260308
- if (type === "error") {
260309
- this.logger.error(line3);
260310
- } else {
260311
- this.logger.log(line3);
260312
- }
260313
- }
260314
- }
260315
- }
260316
-
260317
260335
  // src/cli/dev/dev-server/watcher.ts
260318
260336
  import { EventEmitter as EventEmitter4 } from "node:events";
260319
260337
  import { relative as relative6 } from "node:path";
@@ -262144,14 +262162,11 @@ async function createDevServer(options8) {
262144
262162
  const serveCommand = project2.site?.serveCommand;
262145
262163
  let serveRunner;
262146
262164
  if (options8.appId && serveCommand) {
262147
- serveRunner = new ServeRunner({
262148
- command: serveCommand,
262149
- cwd: project2.root,
262150
- env: {
262151
- VITE_BASE44_APP_ID: options8.appId,
262152
- VITE_BASE44_APP_BASE_URL: baseUrl
262153
- },
262154
- logger: createDevLogger("frontend", theme.colors.base44Orange)
262165
+ serveRunner = createFrontendRunner({
262166
+ serveCommand,
262167
+ projectRoot: project2.root,
262168
+ appId: options8.appId,
262169
+ appBaseUrl: baseUrl
262155
262170
  });
262156
262171
  }
262157
262172
  const handleShutdownError = (error48) => {
@@ -262198,27 +262213,11 @@ async function createDevServer(options8) {
262198
262213
 
262199
262214
  // src/cli/dev/remote-serve.ts
262200
262215
  function startRemoteServe(options8) {
262201
- const runner = createRemoteServeRunner(options8);
262216
+ const runner = createFrontendRunner(options8);
262202
262217
  stopRunnerOnProcessSignals(runner);
262203
262218
  runner.onExit((code2) => process.exit(code2 ?? 1));
262204
262219
  runner.start();
262205
262220
  }
262206
- function createRemoteServeRunner({
262207
- appId,
262208
- appBaseUrl,
262209
- serveCommand,
262210
- projectRoot
262211
- }) {
262212
- return new ServeRunner({
262213
- command: serveCommand,
262214
- cwd: projectRoot,
262215
- env: {
262216
- VITE_BASE44_APP_ID: appId,
262217
- VITE_BASE44_APP_BASE_URL: appBaseUrl
262218
- },
262219
- logger: createDevLogger("frontend", theme.colors.base44Orange)
262220
- });
262221
- }
262222
262221
  function stopRunnerOnProcessSignals(runner) {
262223
262222
  const stop2 = () => void runner.stop();
262224
262223
  process.on("SIGINT", stop2);
@@ -266802,4 +266801,4 @@ export {
266802
266801
  CLIExitError
266803
266802
  };
266804
266803
 
266805
- //# debugId=92E6FA4E34506F4E64756E2164756E21
266804
+ //# debugId=DC5CC6FBD671465C64756E2164756E21