@netlify/build 35.5.14 → 35.6.1

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.
@@ -15,4 +15,5 @@ export const DEFAULT_FEATURE_FLAGS = {
15
15
  netlify_build_updated_plugin_compatibility: false,
16
16
  netlify_build_plugin_system_log: false,
17
17
  edge_bundler_generate_tarball: false,
18
+ netlify_build_db_setup: false,
18
19
  };
@@ -0,0 +1,2 @@
1
+ import { CoreStep } from '../types.js';
2
+ export declare const dbSetup: CoreStep;
@@ -0,0 +1,49 @@
1
+ import { join } from 'node:path';
2
+ import { getPackageJson } from '../../utils/package.js';
3
+ const NPM_PACKAGE_NAME = '@netlify/db';
4
+ const condition = async ({ buildDir, packagePath, featureFlags }) => {
5
+ if (!featureFlags?.netlify_build_db_setup) {
6
+ return false;
7
+ }
8
+ const { packageJson } = await getPackageJson(buildDir);
9
+ if (hasDBPackage(packageJson)) {
10
+ return true;
11
+ }
12
+ if (packagePath) {
13
+ const { packageJson: workspacePackageJson } = await getPackageJson(join(buildDir, packagePath));
14
+ if (hasDBPackage(workspacePackageJson)) {
15
+ return true;
16
+ }
17
+ }
18
+ return false;
19
+ };
20
+ const coreStep = async ({ api, constants, context, deployId }) => {
21
+ const siteId = constants.SITE_ID;
22
+ // @ts-expect-error This is an internal method for now so it isn't typed yet.
23
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
24
+ const database = (await api.createSiteDatabase({ site_id: siteId }));
25
+ let connectionString = database.connection_string;
26
+ if (context !== 'production') {
27
+ // @ts-expect-error This is an internal method for now so it isn't typed yet.
28
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
29
+ const databaseBranch = (await api.createSiteDatabaseBranch({
30
+ site_id: siteId,
31
+ body: { deploy_id: deployId },
32
+ }));
33
+ connectionString = databaseBranch.connection_string;
34
+ }
35
+ process.env.NETLIFY_DB_URL = connectionString;
36
+ return { newEnvChanges: { NETLIFY_DB_URL: connectionString } };
37
+ };
38
+ const hasDBPackage = (packageJSON) => {
39
+ const { dependencies = {}, devDependencies = {} } = packageJSON;
40
+ return NPM_PACKAGE_NAME in dependencies || NPM_PACKAGE_NAME in devDependencies;
41
+ };
42
+ export const dbSetup = {
43
+ event: 'onPreBuild',
44
+ coreStep,
45
+ coreStepId: 'db_provision',
46
+ coreStepName: 'Netlify DB setup',
47
+ coreStepDescription: () => 'Setup Netlify DB database',
48
+ condition,
49
+ };
@@ -15,6 +15,10 @@ export type CoreStepFunctionArgs = {
15
15
  */
16
16
  packagePath?: string;
17
17
  deployId: string;
18
+ /**
19
+ * The deploy context (e.g. 'production', 'deploy-preview', 'branch-deploy')
20
+ */
21
+ context: string;
18
22
  saveConfig: boolean;
19
23
  constants: NetlifyPluginConstants;
20
24
  quiet?: boolean;
package/lib/steps/get.js CHANGED
@@ -7,6 +7,7 @@ import { devUploadBlobs } from '../plugins_core/dev_blobs_upload/index.js';
7
7
  import { bundleEdgeFunctions } from '../plugins_core/edge_functions/index.js';
8
8
  import { applyDeployConfig } from '../plugins_core/frameworks_api/index.js';
9
9
  import { bundleFunctions } from '../plugins_core/functions/index.js';
10
+ import { dbSetup } from '../plugins_core/db_setup/index.js';
10
11
  import { preCleanup } from '../plugins_core/pre_cleanup/index.js';
11
12
  import { preDevCleanup } from '../plugins_core/pre_dev_cleanup/index.js';
12
13
  import { saveArtifacts } from '../plugins_core/save_artifacts/index.js';
@@ -64,6 +65,7 @@ const getEventSteps = function (eventHandlers) {
64
65
  const addCoreSteps = function (steps) {
65
66
  return [
66
67
  preCleanup,
68
+ dbSetup,
67
69
  buildCommandCore,
68
70
  applyDeployConfig,
69
71
  ...steps,
@@ -7,4 +7,4 @@ type PackageResult = {
7
7
  * Retrieve `package.json` from a specific directory
8
8
  */
9
9
  export declare const getPackageJson: (cwd: string, options?: Omit<Options, "cwd">) => Promise<PackageResult>;
10
- export {};
10
+ export type { PackageJson };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "35.5.14",
3
+ "version": "35.6.1",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -69,12 +69,12 @@
69
69
  "@bugsnag/js": "^8.0.0",
70
70
  "@netlify/blobs": "^10.4.4",
71
71
  "@netlify/cache-utils": "^6.0.4",
72
- "@netlify/config": "^24.3.0",
73
- "@netlify/edge-bundler": "14.9.5",
72
+ "@netlify/config": "^24.3.1",
73
+ "@netlify/edge-bundler": "14.9.7",
74
74
  "@netlify/functions-utils": "^6.2.21",
75
75
  "@netlify/git-utils": "^6.0.3",
76
76
  "@netlify/opentelemetry-utils": "^2.0.1",
77
- "@netlify/plugins-list": "^6.81.1",
77
+ "@netlify/plugins-list": "^6.81.2",
78
78
  "@netlify/run-utils": "^6.0.2",
79
79
  "@netlify/zip-it-and-ship-it": "14.3.1",
80
80
  "@sindresorhus/slugify": "^2.0.0",
@@ -152,5 +152,5 @@
152
152
  "engines": {
153
153
  "node": ">=18.14.0"
154
154
  },
155
- "gitHead": "76b0a932036a205140d5f2110f3ef7e90583fbb0"
155
+ "gitHead": "55f6d3568bcea071e679b4152c3273eb48223159"
156
156
  }