@netlify/dev 4.14.1 → 4.16.0

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/main.cjs CHANGED
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/main.ts
31
31
  var main_exports = {};
32
32
  __export(main_exports, {
33
- NetlifyDev: () => NetlifyDev
33
+ NetlifyDev: () => NetlifyDev,
34
+ applyMigrations: () => import_db_dev2.applyMigrations,
35
+ resetDatabase: () => import_db_dev2.resetDatabase
34
36
  });
35
37
  module.exports = __toCommonJS(main_exports);
36
38
  var import_node_fs2 = require("fs");
@@ -46,6 +48,7 @@ var import_images = require("@netlify/images");
46
48
  var import_redirects = require("@netlify/redirects");
47
49
  var import_static = require("@netlify/static");
48
50
  var import_db_dev = require("@netlify/db-dev");
51
+ var import_db_dev2 = require("@netlify/db-dev");
49
52
 
50
53
  // src/lib/env.ts
51
54
  var SUPPORTED_CONTEXTS = ["all", "production", "deploy-preview", "branch-deploy", "dev", "dev-server"];
@@ -534,6 +537,29 @@ var NetlifyDev = class {
534
537
  this.#siteID = siteID;
535
538
  const config = await this.getConfig();
536
539
  this.#config = config;
540
+ const reactiveConfig = new import_dev_utils.Reactive(config);
541
+ const fileWatcher = new import_dev_utils.FileWatcher();
542
+ this.#cleanupJobs.push(() => fileWatcher.close());
543
+ if (config.configPath) {
544
+ const reloadConfig = () => {
545
+ void (async () => {
546
+ try {
547
+ const newConfig = await this.getConfig();
548
+ this.#config = newConfig;
549
+ reactiveConfig.set(newConfig);
550
+ } catch (error) {
551
+ this.#logger.warn(`Failed to reload config: ${String(error)}`);
552
+ }
553
+ })();
554
+ };
555
+ fileWatcher.subscribe({
556
+ id: "netlify-config",
557
+ paths: config.configPath,
558
+ onChange: reloadConfig,
559
+ onAdd: reloadConfig,
560
+ onUnlink: reloadConfig
561
+ });
562
+ }
537
563
  const runtime = await getRuntime({
538
564
  blobs: this.#features.blobs,
539
565
  deployID: "0",
@@ -547,8 +573,12 @@ var NetlifyDev = class {
547
573
  const db = new import_db_dev.NetlifyDB({ directory: dbDirectory });
548
574
  const connectionString = await db.start();
549
575
  runtime.env.set("NETLIFY_DB_URL", connectionString);
576
+ state.set("dbConnectionString", connectionString);
550
577
  this.#db = db;
551
- this.#cleanupJobs.push(() => db.stop());
578
+ this.#cleanupJobs.push(async () => {
579
+ await db.stop();
580
+ state.delete("dbConnectionString");
581
+ });
552
582
  } catch (error) {
553
583
  this.#db = void 0;
554
584
  this.#logger.warn(`Failed to start Netlify DB locally: ${String(error)}`);
@@ -652,8 +682,9 @@ var NetlifyDev = class {
652
682
  state
653
683
  });
654
684
  this.#functionsHandler = new import_functions_dev.FunctionsHandler({
655
- config: this.#config,
685
+ config: reactiveConfig,
656
686
  destPath: this.#functionsServePath,
687
+ fileWatcher,
657
688
  geolocation,
658
689
  projectRoot: this.#projectRoot,
659
690
  settings: {},
@@ -713,5 +744,7 @@ var NetlifyDev = class {
713
744
  };
714
745
  // Annotate the CommonJS export names for ESM import in node:
715
746
  0 && (module.exports = {
716
- NetlifyDev
747
+ NetlifyDev,
748
+ applyMigrations,
749
+ resetDatabase
717
750
  });
package/dist/main.d.cts CHANGED
@@ -2,6 +2,7 @@ import { IncomingMessage } from 'node:http';
2
2
  import { Logger } from '@netlify/dev-utils';
3
3
  import { HeadersCollector } from '@netlify/headers';
4
4
  import { NetlifyDB } from '@netlify/db-dev';
5
+ export { SQLExecutor, applyMigrations, resetDatabase } from '@netlify/db-dev';
5
6
 
6
7
  interface Features {
7
8
  /**
package/dist/main.d.ts CHANGED
@@ -2,6 +2,7 @@ import { IncomingMessage } from 'node:http';
2
2
  import { Logger } from '@netlify/dev-utils';
3
3
  import { HeadersCollector } from '@netlify/headers';
4
4
  import { NetlifyDB } from '@netlify/db-dev';
5
+ export { SQLExecutor, applyMigrations, resetDatabase } from '@netlify/db-dev';
5
6
 
6
7
  interface Features {
7
8
  /**
package/dist/main.js CHANGED
@@ -6,10 +6,12 @@ import { parseAIGatewayContext, setupAIGateway } from "@netlify/ai/bootstrap";
6
6
  import { resolveConfig } from "@netlify/config";
7
7
  import {
8
8
  ensureNetlifyIgnore,
9
+ FileWatcher,
9
10
  getAPIToken,
10
11
  getGeoLocation,
11
12
  LocalState,
12
- HTTPServer
13
+ HTTPServer,
14
+ Reactive
13
15
  } from "@netlify/dev-utils";
14
16
  import { EdgeFunctionsHandler } from "@netlify/edge-functions-dev";
15
17
  import { FunctionsHandler } from "@netlify/functions-dev";
@@ -18,6 +20,7 @@ import { ImageHandler } from "@netlify/images";
18
20
  import { RedirectsHandler } from "@netlify/redirects";
19
21
  import { StaticHandler } from "@netlify/static";
20
22
  import { NetlifyDB } from "@netlify/db-dev";
23
+ import { applyMigrations, resetDatabase } from "@netlify/db-dev";
21
24
 
22
25
  // src/lib/env.ts
23
26
  var SUPPORTED_CONTEXTS = ["all", "production", "deploy-preview", "branch-deploy", "dev", "dev-server"];
@@ -506,6 +509,29 @@ var NetlifyDev = class {
506
509
  this.#siteID = siteID;
507
510
  const config = await this.getConfig();
508
511
  this.#config = config;
512
+ const reactiveConfig = new Reactive(config);
513
+ const fileWatcher = new FileWatcher();
514
+ this.#cleanupJobs.push(() => fileWatcher.close());
515
+ if (config.configPath) {
516
+ const reloadConfig = () => {
517
+ void (async () => {
518
+ try {
519
+ const newConfig = await this.getConfig();
520
+ this.#config = newConfig;
521
+ reactiveConfig.set(newConfig);
522
+ } catch (error) {
523
+ this.#logger.warn(`Failed to reload config: ${String(error)}`);
524
+ }
525
+ })();
526
+ };
527
+ fileWatcher.subscribe({
528
+ id: "netlify-config",
529
+ paths: config.configPath,
530
+ onChange: reloadConfig,
531
+ onAdd: reloadConfig,
532
+ onUnlink: reloadConfig
533
+ });
534
+ }
509
535
  const runtime = await getRuntime({
510
536
  blobs: this.#features.blobs,
511
537
  deployID: "0",
@@ -519,8 +545,12 @@ var NetlifyDev = class {
519
545
  const db = new NetlifyDB({ directory: dbDirectory });
520
546
  const connectionString = await db.start();
521
547
  runtime.env.set("NETLIFY_DB_URL", connectionString);
548
+ state.set("dbConnectionString", connectionString);
522
549
  this.#db = db;
523
- this.#cleanupJobs.push(() => db.stop());
550
+ this.#cleanupJobs.push(async () => {
551
+ await db.stop();
552
+ state.delete("dbConnectionString");
553
+ });
524
554
  } catch (error) {
525
555
  this.#db = void 0;
526
556
  this.#logger.warn(`Failed to start Netlify DB locally: ${String(error)}`);
@@ -624,8 +654,9 @@ var NetlifyDev = class {
624
654
  state
625
655
  });
626
656
  this.#functionsHandler = new FunctionsHandler({
627
- config: this.#config,
657
+ config: reactiveConfig,
628
658
  destPath: this.#functionsServePath,
659
+ fileWatcher,
629
660
  geolocation,
630
661
  projectRoot: this.#projectRoot,
631
662
  settings: {},
@@ -684,5 +715,7 @@ var NetlifyDev = class {
684
715
  }
685
716
  };
686
717
  export {
687
- NetlifyDev
718
+ NetlifyDev,
719
+ applyMigrations,
720
+ resetDatabase
688
721
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/dev",
3
- "version": "4.14.1",
3
+ "version": "4.16.0",
4
4
  "description": "Emulation of the Netlify environment for local development",
5
5
  "type": "module",
6
6
  "engines": {
@@ -57,17 +57,17 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@netlify/ai": "^0.4.0",
60
- "@netlify/blobs": "10.7.0",
60
+ "@netlify/blobs": "10.7.1",
61
61
  "@netlify/config": "^24.4.0",
62
- "@netlify/db-dev": "0.5.0",
63
- "@netlify/dev-utils": "4.3.3",
64
- "@netlify/edge-functions-dev": "1.0.11",
65
- "@netlify/functions-dev": "1.1.12",
66
- "@netlify/headers": "2.1.3",
67
- "@netlify/images": "1.3.3",
68
- "@netlify/redirects": "3.1.5",
69
- "@netlify/runtime": "4.1.16",
70
- "@netlify/static": "3.1.3",
62
+ "@netlify/db-dev": "0.7.0",
63
+ "@netlify/dev-utils": "4.4.0",
64
+ "@netlify/edge-functions-dev": "1.0.12",
65
+ "@netlify/functions-dev": "1.2.0",
66
+ "@netlify/headers": "2.1.4",
67
+ "@netlify/images": "1.3.4",
68
+ "@netlify/redirects": "3.1.6",
69
+ "@netlify/runtime": "4.1.17",
70
+ "@netlify/static": "3.1.4",
71
71
  "ulid": "^3.0.0"
72
72
  }
73
73
  }