Skip to content

Commit 3e3234c

Browse files
committed
fix: resolve integration dev path relative to buildDir
Currently, programmatic executions of `buildSite` resolve a development integration's path (specified via `netlify.toml#integrations[].dev.path`) relative to the current working directory. I don't think this makes any sense, honestly. I find this undocumented behavior unintuitive; if I specify a relative path in a `netlify.toml` I would expect it to be resolved relative to the `netlify.toml`. This is _technically_ a breaking change, but in practice I really doubt any users are testing extension build hooks, it's unlikely to break anything for the platform team (_maybe_ a few tests, but we can update the paths in those tests if it does). I'm tempted to remove `testOpts.cwd` here because I can't find anywhere that we use it internally and it's unintuitive, too, but I'm leaving it in for now as an easy escape hatch in case this change breaks any tests Composable Platform has.
1 parent 254f154 commit 3e3234c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/build/src/install/missing.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const installIntegrationPlugins = async function ({
3535
context,
3636
testOpts,
3737
pluginsEnv,
38+
buildDir,
3839
}) {
3940
const integrationsToBuild = integrations.filter(
4041
(integration) => typeof integration.dev !== 'undefined' && context === 'dev',
@@ -47,7 +48,7 @@ export const installIntegrationPlugins = async function ({
4748
)
4849
}
4950
const packages = (
50-
await Promise.all(integrations.map((integration) => getIntegrationPackage({ integration, context, testOpts, pluginsEnv })))
51+
await Promise.all(integrations.map((integration) => getIntegrationPackage({ integration, context, testOpts, buildDir, pluginsEnv })))
5152
).filter(Boolean)
5253
logInstallIntegrations(
5354
logs,
@@ -65,15 +66,16 @@ export const installIntegrationPlugins = async function ({
6566
await addExactDependencies({ packageRoot: autoPluginsDir, isLocal: mode !== 'buildbot', packages })
6667
}
6768

68-
const getIntegrationPackage = async function ({ integration: { version, dev }, context, testOpts = {}, pluginsEnv }) {
69+
const getIntegrationPackage = async function ({ integration: { version, dev }, context, testOpts = {}, buildDir, pluginsEnv }) {
6970
if (typeof version !== 'undefined') {
7071
return `${version}/packages/buildhooks.tgz`
7172
}
7273

7374
if (typeof dev !== 'undefined' && context === 'dev') {
7475
const { path } = dev
7576

76-
const integrationDir = testOpts.cwd ? resolve(testOpts.cwd, path) : resolve(path)
77+
const integrationDir = testOpts.cwd ? resolve(testOpts.cwd, path) : resolve(buildDir, path)
78+
7779
try {
7880
const res = await execa('npm', ['run', 'build'], { cwd: integrationDir, env: pluginsEnv })
7981

packages/build/src/plugins/resolve.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const handleMissingPlugins = async function ({ pluginsOptions, autoPluginsDir, m
168168

169169
const handleIntegrations = async function ({ integrations, autoPluginsDir, mode, logs, buildDir, context, testOpts, pluginsEnv }) {
170170
const toInstall = integrations.filter((integration) => integration.has_build)
171-
await installIntegrationPlugins({ integrations: toInstall, autoPluginsDir, mode, logs, context, testOpts, pluginsEnv })
171+
await installIntegrationPlugins({ integrations: toInstall, autoPluginsDir, mode, logs, context, testOpts, buildDir, pluginsEnv })
172172

173173
if (toInstall.length === 0) {
174174
return []
@@ -190,7 +190,7 @@ const handleIntegrations = async function ({ integrations, autoPluginsDir, mode,
190190
const resolveIntegration = async function ({ integration, autoPluginsDir, buildDir, context, testOpts }) {
191191
if (typeof integration.dev !== 'undefined' && context === 'dev') {
192192
const { path } = integration.dev
193-
const integrationDir = testOpts.cwd ? resolve(testOpts.cwd, path) : resolve(path)
193+
const integrationDir = testOpts.cwd ? resolve(testOpts.cwd, path) : resolve(buildDir, path)
194194
const pluginPath = await resolvePath(`${integrationDir}/.ntli/build`, buildDir)
195195

196196
return { pluginPath, packageName: `${integration.slug}`, isIntegration: true, integration, loadedFrom: 'local' }

0 commit comments

Comments
 (0)