@netlify/build 29.20.15 → 29.21.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/lib/core/build.js CHANGED
@@ -271,6 +271,7 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configO
271
271
  testOpts,
272
272
  featureFlags,
273
273
  integrations,
274
+ context,
274
275
  });
275
276
  errorParams.pluginsOptions = pluginsOptionsA;
276
277
  const { childProcesses, timers: timersB } = await startPlugins({
@@ -4,9 +4,11 @@ export function installMissingPlugins({ missingPlugins, autoPluginsDir, mode, lo
4
4
  mode: any;
5
5
  logs: any;
6
6
  }): Promise<void>;
7
- export function installIntegrationPlugins({ integrations, autoPluginsDir, mode, logs }: {
7
+ export function installIntegrationPlugins({ integrations, autoPluginsDir, mode, logs, context, testOpts, }: {
8
8
  integrations: any;
9
9
  autoPluginsDir: any;
10
10
  mode: any;
11
11
  logs: any;
12
+ context: any;
13
+ testOpts: any;
12
14
  }): Promise<void>;
@@ -1,7 +1,9 @@
1
1
  import { promises as fs } from 'fs';
2
- import { normalize } from 'path';
2
+ import { normalize, resolve } from 'path';
3
+ import { execa } from 'execa';
3
4
  import { pathExists } from 'path-exists';
4
5
  import { isFile } from 'path-type';
6
+ import { logArray, logSubHeader } from '../log/logger.js';
5
7
  import { logInstallMissingPlugins, logInstallIntegrations } from '../log/messages/install.js';
6
8
  import { addExactDependencies } from './main.js';
7
9
  // Automatically install plugins if not already installed.
@@ -18,17 +20,41 @@ export const installMissingPlugins = async function ({ missingPlugins, autoPlugi
18
20
  await createAutoPluginsDir(logs, autoPluginsDir);
19
21
  await addExactDependencies({ packageRoot: autoPluginsDir, isLocal: mode !== 'buildbot', packages });
20
22
  };
21
- export const installIntegrationPlugins = async function ({ integrations, autoPluginsDir, mode, logs }) {
22
- const packages = integrations.map(getIntegrationPackage);
23
- logInstallIntegrations(logs, integrations);
23
+ export const installIntegrationPlugins = async function ({ integrations, autoPluginsDir, mode, logs, context, testOpts, }) {
24
+ const integrationsToBuild = integrations.filter((integration) => typeof integration.dev !== 'undefined' && context === 'dev');
25
+ if (integrationsToBuild.length) {
26
+ logSubHeader(logs, 'Building integrations');
27
+ logArray(logs, integrationsToBuild.map(({ slug, dev: { path } }) => `${slug} from ${path}`));
28
+ }
29
+ const packages = (await Promise.all(integrations.map((integration) => getIntegrationPackage({ integration, context, testOpts })))).filter(Boolean);
30
+ logInstallIntegrations(logs, integrations.filter((integration) => integrationsToBuild.every((compiledIntegration) => integration.slug !== compiledIntegration.slug)));
24
31
  if (packages.length === 0) {
25
32
  return;
26
33
  }
27
34
  await createAutoPluginsDir(logs, autoPluginsDir);
28
35
  await addExactDependencies({ packageRoot: autoPluginsDir, isLocal: mode !== 'buildbot', packages });
29
36
  };
30
- const getIntegrationPackage = function ({ version }) {
31
- return `${version}/packages/buildhooks.tgz`;
37
+ const getIntegrationPackage = async function ({ integration: { version, dev }, context, testOpts }) {
38
+ if (typeof version !== 'undefined') {
39
+ return `${version}/packages/buildhooks.tgz`;
40
+ }
41
+ if (typeof dev !== 'undefined' && context === 'dev') {
42
+ const { path } = dev;
43
+ const integrationDir = testOpts ? resolve(testOpts.cwd, path) : resolve(path);
44
+ try {
45
+ const res = await execa('npm', ['run', 'build'], { cwd: integrationDir });
46
+ // This is horrible and hacky, but `npm run build` will
47
+ // return status code 0 even if it fails
48
+ if (!res.stdout.includes('Build complete!')) {
49
+ throw new Error(res.stdout);
50
+ }
51
+ }
52
+ catch (e) {
53
+ throw new Error(`Failed to build integration`);
54
+ }
55
+ return undefined;
56
+ }
57
+ return undefined;
32
58
  };
33
59
  // We pin the version without using semver ranges ^ nor ~
34
60
  const getPackage = function ({ packageName, expectedVersion }) {
@@ -8,7 +8,7 @@ import { getPackageJson } from '../utils/package.js';
8
8
  import { useManifest } from './manifest/main.js';
9
9
  import { resolvePluginsPath } from './resolve.js';
10
10
  // Load core plugins and user plugins
11
- const tGetPluginsOptions = async function ({ pluginsOptions, netlifyConfig: { plugins }, siteInfo, buildDir, packagePath, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, }) {
11
+ const tGetPluginsOptions = async function ({ pluginsOptions, netlifyConfig: { plugins }, siteInfo, buildDir, packagePath, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, context, }) {
12
12
  const pluginsOptionsA = await resolvePluginsPath({
13
13
  pluginsOptions,
14
14
  siteInfo,
@@ -25,6 +25,7 @@ const tGetPluginsOptions = async function ({ pluginsOptions, netlifyConfig: { pl
25
25
  testOpts,
26
26
  featureFlags,
27
27
  integrations,
28
+ context,
28
29
  });
29
30
  const pluginsOptionsB = await Promise.all(pluginsOptionsA.map((pluginOptions) => loadPluginFiles({ pluginOptions, debug })));
30
31
  const pluginsOptionsC = pluginsOptionsB.filter(isNotRedundantCorePlugin);
@@ -1,4 +1,4 @@
1
- export function resolvePluginsPath({ pluginsOptions, siteInfo, buildDir, packagePath, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, }: {
1
+ export function resolvePluginsPath({ pluginsOptions, siteInfo, buildDir, packagePath, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, context, }: {
2
2
  pluginsOptions: any;
3
3
  siteInfo: any;
4
4
  buildDir: any;
@@ -14,4 +14,5 @@ export function resolvePluginsPath({ pluginsOptions, siteInfo, buildDir, package
14
14
  testOpts: any;
15
15
  featureFlags: any;
16
16
  integrations: any;
17
+ context: any;
17
18
  }): Promise<any[]>;
@@ -11,7 +11,7 @@ const AUTO_PLUGINS_DIR = '.netlify/plugins/';
11
11
  // - local plugin
12
12
  // - external plugin already installed in `node_modules`, most likely through `package.json`
13
13
  // - automatically installed by us, to `.netlify/plugins/`
14
- export const resolvePluginsPath = async function ({ pluginsOptions, siteInfo, buildDir, packagePath, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, }) {
14
+ export const resolvePluginsPath = async function ({ pluginsOptions, siteInfo, buildDir, packagePath, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, context, }) {
15
15
  const autoPluginsDir = getAutoPluginsDir(buildDir, packagePath);
16
16
  const pluginsOptionsA = await Promise.all(pluginsOptions.map((pluginOptions) => resolvePluginPath({ pluginOptions, buildDir, autoPluginsDir })));
17
17
  const pluginsOptionsB = addPluginsNodeVersion({
@@ -38,8 +38,16 @@ export const resolvePluginsPath = async function ({ pluginsOptions, siteInfo, bu
38
38
  logs,
39
39
  });
40
40
  let integrationPluginOptions = [];
41
- if (featureFlags.buildbot_fetch_integrations) {
42
- integrationPluginOptions = await handleIntegrations({ integrations, autoPluginsDir, mode, logs });
41
+ if (featureFlags.buildbot_fetch_integrations || featureFlags.cli_fetch_integrations) {
42
+ integrationPluginOptions = await handleIntegrations({
43
+ integrations,
44
+ autoPluginsDir,
45
+ mode,
46
+ logs,
47
+ buildDir,
48
+ context,
49
+ testOpts,
50
+ });
43
51
  }
44
52
  return [...pluginsOptionsE, ...integrationPluginOptions];
45
53
  };
@@ -107,18 +115,25 @@ const handleMissingPlugins = async function ({ pluginsOptions, autoPluginsDir, m
107
115
  await installMissingPlugins({ missingPlugins, autoPluginsDir, mode, logs });
108
116
  return Promise.all(pluginsOptions.map((pluginOptions) => resolveMissingPluginPath({ pluginOptions, autoPluginsDir })));
109
117
  };
110
- const handleIntegrations = async function ({ integrations, autoPluginsDir, mode, logs }) {
118
+ const handleIntegrations = async function ({ integrations, autoPluginsDir, mode, logs, buildDir, context, testOpts }) {
111
119
  const toInstall = integrations.filter((integration) => integration.has_build);
112
- await installIntegrationPlugins({ integrations: toInstall, autoPluginsDir, mode, logs });
120
+ await installIntegrationPlugins({ integrations: toInstall, autoPluginsDir, mode, logs, context, testOpts });
113
121
  if (toInstall.length === 0) {
114
122
  return [];
115
123
  }
116
124
  return Promise.all(toInstall.map((integration) => resolveIntegration({
117
125
  integration,
118
126
  autoPluginsDir,
127
+ buildDir,
128
+ context,
119
129
  })));
120
130
  };
121
- const resolveIntegration = async function ({ integration, autoPluginsDir }) {
131
+ const resolveIntegration = async function ({ integration, autoPluginsDir, buildDir, context }) {
132
+ if (typeof integration.dev !== 'undefined' && context === 'dev') {
133
+ const { path } = integration.dev;
134
+ const pluginPath = await resolvePath(`${path}/.ntli/build`, buildDir);
135
+ return { pluginPath, packageName: `${integration.slug}`, isIntegration: true, integration, loadedFrom: 'local' };
136
+ }
122
137
  const pluginPath = await resolvePath(`${integration.slug}-buildhooks`, autoPluginsDir);
123
138
  return { pluginPath, packageName: `${integration.slug}-buildhooks`, isIntegration: true, integration };
124
139
  };
@@ -21,7 +21,7 @@ export const resolvePath = async function (path, basedir) {
21
21
  // `resolve` sometimes gives unhelpful error messages.
22
22
  // https://github.com/browserify/resolve/issues/223
23
23
  }
24
- catch {
24
+ catch (e) {
25
25
  return require.resolve(path, { paths: [basedir] });
26
26
  }
27
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "29.20.15",
3
+ "version": "29.21.0",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -67,14 +67,14 @@
67
67
  "@bugsnag/js": "^7.0.0",
68
68
  "@honeycombio/opentelemetry-node": "^0.5.0",
69
69
  "@netlify/cache-utils": "^5.1.5",
70
- "@netlify/config": "^20.8.1",
70
+ "@netlify/config": "^20.9.0",
71
71
  "@netlify/edge-bundler": "8.20.0",
72
72
  "@netlify/framework-info": "^9.8.10",
73
- "@netlify/functions-utils": "^5.2.28",
73
+ "@netlify/functions-utils": "^5.2.29",
74
74
  "@netlify/git-utils": "^5.1.1",
75
75
  "@netlify/plugins-list": "^6.71.0",
76
76
  "@netlify/run-utils": "^5.1.1",
77
- "@netlify/zip-it-and-ship-it": "9.18.0",
77
+ "@netlify/zip-it-and-ship-it": "9.18.1",
78
78
  "@opentelemetry/api": "^1.4.1",
79
79
  "@sindresorhus/slugify": "^2.0.0",
80
80
  "ansi-escapes": "^6.0.0",
@@ -145,5 +145,5 @@
145
145
  "engines": {
146
146
  "node": "^14.16.0 || >=16.0.0"
147
147
  },
148
- "gitHead": "e3d86a42f6211965e2eea2f3fc41a3eb57ece4e8"
148
+ "gitHead": "5521b954cc7944141d095434e39cce2af3d3ccaf"
149
149
  }