@base44-preview/cli 0.0.36-pr.353.17ecffc → 0.0.36-pr.353.1c10216

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
@@ -243860,7 +243860,7 @@ function getTypesCommand(context) {
243860
243860
  }
243861
243861
 
243862
243862
  // src/cli/dev/dev-server/main.ts
243863
- import { dirname as dirname15, join as join18 } from "node:path";
243863
+ import { dirname as dirname14 } from "node:path";
243864
243864
  var import_cors = __toESM(require_lib4(), 1);
243865
243865
  var import_express4 = __toESM(require_express(), 1);
243866
243866
 
@@ -244068,6 +244068,10 @@ class FunctionManager {
244068
244068
  try {
244069
244069
  return await promise2;
244070
244070
  } finally {
244071
+ if (!this.starting.has(name2) && this.running.has(name2)) {
244072
+ this.running.get(name2)?.process.kill();
244073
+ this.running.delete(name2);
244074
+ }
244071
244075
  this.starting.delete(name2);
244072
244076
  }
244073
244077
  }
@@ -244128,7 +244132,9 @@ class FunctionManager {
244128
244132
  }
244129
244133
  });
244130
244134
  process21.on("exit", (code2) => {
244131
- this.logger.log(`[dev-server] Function "${name2}" exited with code ${code2}`);
244135
+ if (code2 !== null) {
244136
+ this.logger.log(`[dev-server] Function "${name2}" exited with code ${code2}`);
244137
+ }
244132
244138
  this.running.delete(name2);
244133
244139
  });
244134
244140
  process21.on("error", (error48) => {
@@ -244233,7 +244239,7 @@ class Database {
244233
244239
  }
244234
244240
 
244235
244241
  // src/cli/dev/dev-server/dir-watcher.ts
244236
- import { dirname as dirname14 } from "node:path";
244242
+ import { relative as relative4, sep } from "node:path";
244237
244243
 
244238
244244
  // node_modules/chokidar/index.js
244239
244245
  import { EventEmitter as EventEmitter3 } from "node:events";
@@ -245850,69 +245856,53 @@ function watch(paths, options8 = {}) {
245850
245856
  var import_debounce = __toESM(require_debounce(), 1);
245851
245857
  var WATCH_DEBOUNCE_MS = 300;
245852
245858
 
245853
- class DirWatcher {
245854
- targetDir;
245859
+ class WatchBase44Directory {
245860
+ configDir;
245855
245861
  onChange;
245856
245862
  logger;
245857
245863
  watcher = null;
245858
- closed = false;
245859
- constructor(targetDir, onChange, logger) {
245860
- this.targetDir = targetDir;
245864
+ constructor(configDir, onChange, logger) {
245865
+ this.configDir = configDir;
245861
245866
  this.onChange = onChange;
245862
245867
  this.logger = logger;
245863
245868
  }
245864
245869
  async start() {
245865
- if (await pathExists(this.targetDir)) {
245870
+ if (this.watcher) {
245871
+ return;
245872
+ }
245873
+ if (await pathExists(this.configDir)) {
245866
245874
  this.watchTarget();
245867
- } else {
245868
- this.watchParentForCreation();
245869
245875
  }
245870
245876
  }
245871
- close() {
245872
- this.closed = true;
245873
- this.watcher?.close();
245877
+ async close() {
245878
+ await this.watcher?.close();
245874
245879
  this.watcher = null;
245875
245880
  }
245876
- watchTarget() {
245877
- if (this.closed) {
245881
+ getSubfolder(path18) {
245882
+ const rel = relative4(this.configDir, path18);
245883
+ if (!rel || rel === ".")
245878
245884
  return;
245879
- }
245880
- const handler = import_debounce.default(async () => {
245881
- try {
245882
- await this.onChange();
245883
- } catch (error48) {
245884
- this.handleError(error48);
245885
- }
245886
- }, WATCH_DEBOUNCE_MS);
245887
- this.watcher = watch(this.targetDir, { ignoreInitial: true });
245888
- this.watcher.on("all", handler);
245885
+ return rel.split(sep)[0];
245889
245886
  }
245890
- watchParentForCreation() {
245891
- if (this.closed) {
245892
- return;
245893
- }
245894
- const parentDir = dirname14(this.targetDir);
245895
- const handler = import_debounce.default(async () => {
245896
- if (this.closed) {
245897
- return;
245898
- }
245899
- if (await pathExists(this.targetDir)) {
245900
- handler.cancel();
245901
- await this.watcher?.close();
245902
- this.watcher = null;
245903
- this.watchTarget();
245904
- try {
245905
- await this.onChange();
245906
- } catch (error48) {
245907
- this.handleError(error48);
245887
+ watchTarget() {
245888
+ const handler = import_debounce.default(async (_event, path18) => {
245889
+ const subfolder = this.getSubfolder(path18);
245890
+ await this.onChange(subfolder);
245891
+ }, WATCH_DEBOUNCE_MS);
245892
+ this.watcher = watch(this.configDir, {
245893
+ ignoreInitial: true,
245894
+ ignored: (filePath) => {
245895
+ if (this.configDir === filePath) {
245896
+ return false;
245908
245897
  }
245898
+ const subfolder = this.getSubfolder(filePath);
245899
+ return subfolder !== "functions";
245909
245900
  }
245910
- }, WATCH_DEBOUNCE_MS);
245911
- this.watcher = watch(parentDir, { ignoreInitial: true, depth: 0 });
245901
+ });
245912
245902
  this.watcher.on("all", handler);
245913
- }
245914
- handleError(error48) {
245915
- this.logger.error(`[dev-server] Watch handler failed for ${this.targetDir}`, error48 instanceof Error ? error48 : undefined);
245903
+ this.watcher.on("error", (err) => {
245904
+ this.logger.error(`[dev-server] Watch handler failed for ${this.configDir}`, err instanceof Error ? err : undefined);
245905
+ });
245916
245906
  }
245917
245907
  }
245918
245908
 
@@ -246333,22 +246323,23 @@ async function createDevServer(options8) {
246333
246323
  emitEntityEvent = (appId, entityName, event) => {
246334
246324
  broadcastEntityEvent(io6, appId, entityName, event);
246335
246325
  };
246336
- const configDir = dirname15(project2.configPath);
246337
- const functionsDir = join18(configDir, project2.functionsDir);
246338
- const functionsWatcher = new DirWatcher(functionsDir, async () => {
246339
- const { functions: functions2 } = await options8.loadResources();
246340
- const previousNamesLength = functionManager.getFunctionNames().length;
246341
- functionManager.reload(functions2);
246342
- const names = functionManager.getFunctionNames();
246343
- if (names.length > 0) {
246344
- devLogger.log(`Reloaded functions: ${names.sort().join(", ")}`);
246345
- } else if (previousNamesLength > 0) {
246346
- devLogger.log("All functions removed");
246326
+ const configDir = dirname14(project2.configPath);
246327
+ const base44ConfigWatcher = new WatchBase44Directory(configDir, async (subfolder) => {
246328
+ if (subfolder === "functions") {
246329
+ const { functions: functions2 } = await options8.loadResources();
246330
+ const previousFunctionCount = functionManager.getFunctionNames().length;
246331
+ functionManager.reload(functions2);
246332
+ const names = functionManager.getFunctionNames();
246333
+ if (names.length > 0) {
246334
+ devLogger.log(`Reloaded functions: ${names.sort().join(", ")}`);
246335
+ } else if (previousFunctionCount > 0) {
246336
+ devLogger.log("All functions removed");
246337
+ }
246347
246338
  }
246348
246339
  }, devLogger);
246349
- await functionsWatcher.start();
246340
+ await base44ConfigWatcher.start();
246350
246341
  const shutdown = () => {
246351
- functionsWatcher.close();
246342
+ base44ConfigWatcher.close();
246352
246343
  io6.close();
246353
246344
  functionManager.stopAll();
246354
246345
  server.close();
@@ -246504,7 +246495,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
246504
246495
  import { release, type } from "node:os";
246505
246496
 
246506
246497
  // node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
246507
- import { dirname as dirname16, posix, sep } from "path";
246498
+ import { dirname as dirname15, posix, sep as sep2 } from "path";
246508
246499
  function createModulerModifier() {
246509
246500
  const getModuleFromFileName = createGetModuleFromFilename();
246510
246501
  return async (frames) => {
@@ -246513,7 +246504,7 @@ function createModulerModifier() {
246513
246504
  return frames;
246514
246505
  };
246515
246506
  }
246516
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname16(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
246507
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname15(process.argv[1]) : process.cwd(), isWindows5 = sep2 === "\\") {
246517
246508
  const normalizedBase = isWindows5 ? normalizeWindowsPath2(basePath) : basePath;
246518
246509
  return (filename) => {
246519
246510
  if (!filename)
@@ -250731,4 +250722,4 @@ export {
250731
250722
  CLIExitError
250732
250723
  };
250733
250724
 
250734
- //# debugId=34515ECB16FFFDAF64756E2164756E21
250725
+ //# debugId=0FDE3E45A7228AE164756E2164756E21