@base44-preview/cli 0.0.36-pr.353.e4eb961 → 0.0.36-pr.353.f5250a0

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
  }
@@ -244235,7 +244239,7 @@ class Database {
244235
244239
  }
244236
244240
 
244237
244241
  // src/cli/dev/dev-server/dir-watcher.ts
244238
- import { dirname as dirname14 } from "node:path";
244242
+ import { relative as relative4, sep } from "node:path";
244239
244243
 
244240
244244
  // node_modules/chokidar/index.js
244241
244245
  import { EventEmitter as EventEmitter3 } from "node:events";
@@ -245852,69 +245856,53 @@ function watch(paths, options8 = {}) {
245852
245856
  var import_debounce = __toESM(require_debounce(), 1);
245853
245857
  var WATCH_DEBOUNCE_MS = 300;
245854
245858
 
245855
- class DirWatcher {
245856
- targetDir;
245859
+ class WatchBase44Directory {
245860
+ configDir;
245857
245861
  onChange;
245858
245862
  logger;
245859
245863
  watcher = null;
245860
- closed = false;
245861
- constructor(targetDir, onChange, logger) {
245862
- this.targetDir = targetDir;
245864
+ constructor(configDir, onChange, logger) {
245865
+ this.configDir = configDir;
245863
245866
  this.onChange = onChange;
245864
245867
  this.logger = logger;
245865
245868
  }
245866
245869
  async start() {
245867
- if (await pathExists(this.targetDir)) {
245870
+ if (this.watcher) {
245871
+ return;
245872
+ }
245873
+ if (await pathExists(this.configDir)) {
245868
245874
  this.watchTarget();
245869
- } else {
245870
- this.watchParentForCreation();
245871
245875
  }
245872
245876
  }
245873
- close() {
245874
- this.closed = true;
245875
- this.watcher?.close();
245877
+ async close() {
245878
+ await this.watcher?.close();
245876
245879
  this.watcher = null;
245877
245880
  }
245878
- watchTarget() {
245879
- if (this.closed) {
245881
+ getSubfolder(path18) {
245882
+ const rel = relative4(this.configDir, path18);
245883
+ if (!rel || rel === ".")
245880
245884
  return;
245881
- }
245882
- const handler = import_debounce.default(async () => {
245883
- try {
245884
- await this.onChange();
245885
- } catch (error48) {
245886
- this.handleError(error48);
245887
- }
245888
- }, WATCH_DEBOUNCE_MS);
245889
- this.watcher = watch(this.targetDir, { ignoreInitial: true });
245890
- this.watcher.on("all", handler);
245885
+ return rel.split(sep)[0];
245891
245886
  }
245892
- watchParentForCreation() {
245893
- if (this.closed) {
245894
- return;
245895
- }
245896
- const parentDir = dirname14(this.targetDir);
245897
- const handler = import_debounce.default(async () => {
245898
- if (this.closed) {
245899
- return;
245900
- }
245901
- if (await pathExists(this.targetDir)) {
245902
- handler.cancel();
245903
- await this.watcher?.close();
245904
- this.watcher = null;
245905
- this.watchTarget();
245906
- try {
245907
- await this.onChange();
245908
- } catch (error48) {
245909
- 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;
245910
245897
  }
245898
+ const subfolder = this.getSubfolder(filePath);
245899
+ return subfolder !== "functions";
245911
245900
  }
245912
- }, WATCH_DEBOUNCE_MS);
245913
- this.watcher = watch(parentDir, { ignoreInitial: true, depth: 0 });
245901
+ });
245914
245902
  this.watcher.on("all", handler);
245915
- }
245916
- handleError(error48) {
245917
- 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
+ });
245918
245906
  }
245919
245907
  }
245920
245908
 
@@ -246335,22 +246323,23 @@ async function createDevServer(options8) {
246335
246323
  emitEntityEvent = (appId, entityName, event) => {
246336
246324
  broadcastEntityEvent(io6, appId, entityName, event);
246337
246325
  };
246338
- const configDir = dirname15(project2.configPath);
246339
- const functionsDir = join18(configDir, project2.functionsDir);
246340
- const functionsWatcher = new DirWatcher(functionsDir, async () => {
246341
- const { functions: functions2 } = await options8.loadResources();
246342
- const previousNamesLength = functionManager.getFunctionNames().length;
246343
- functionManager.reload(functions2);
246344
- const names = functionManager.getFunctionNames();
246345
- if (names.length > 0) {
246346
- devLogger.log(`Reloaded functions: ${names.sort().join(", ")}`);
246347
- } else if (previousNamesLength > 0) {
246348
- 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
+ }
246349
246338
  }
246350
246339
  }, devLogger);
246351
- await functionsWatcher.start();
246340
+ await base44ConfigWatcher.start();
246352
246341
  const shutdown = () => {
246353
- functionsWatcher.close();
246342
+ base44ConfigWatcher.close();
246354
246343
  io6.close();
246355
246344
  functionManager.stopAll();
246356
246345
  server.close();
@@ -246506,7 +246495,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
246506
246495
  import { release, type } from "node:os";
246507
246496
 
246508
246497
  // node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
246509
- import { dirname as dirname16, posix, sep } from "path";
246498
+ import { dirname as dirname15, posix, sep as sep2 } from "path";
246510
246499
  function createModulerModifier() {
246511
246500
  const getModuleFromFileName = createGetModuleFromFilename();
246512
246501
  return async (frames) => {
@@ -246515,7 +246504,7 @@ function createModulerModifier() {
246515
246504
  return frames;
246516
246505
  };
246517
246506
  }
246518
- 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 === "\\") {
246519
246508
  const normalizedBase = isWindows5 ? normalizeWindowsPath2(basePath) : basePath;
246520
246509
  return (filename) => {
246521
246510
  if (!filename)
@@ -250733,4 +250722,4 @@ export {
250733
250722
  CLIExitError
250734
250723
  };
250735
250724
 
250736
- //# debugId=EFF117A5EF450AB064756E2164756E21
250725
+ //# debugId=0FDE3E45A7228AE164756E2164756E21