@netlify/build 35.5.14 → 35.6.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.
|
@@ -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,
|
package/lib/utils/package.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "35.
|
|
3
|
+
"version": "35.6.0",
|
|
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.
|
|
73
|
-
"@netlify/edge-bundler": "14.9.
|
|
72
|
+
"@netlify/config": "^24.3.1",
|
|
73
|
+
"@netlify/edge-bundler": "14.9.6",
|
|
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.
|
|
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": "
|
|
155
|
+
"gitHead": "3b7249e4fd7ea006bf473b4953c17312369d1973"
|
|
156
156
|
}
|