-
Notifications
You must be signed in to change notification settings - Fork 82
fix: resolve site dependency version from packagePath if defined #6650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
579c160
5a01fdc
a45722f
596e0b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [[plugins]] | ||
| package = "netlify-plugin-contextual-env" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "name": "module_plugin", | ||
| "version": "0.0.1", | ||
| "type": "module", | ||
| "description": "test", | ||
| "license": "MIT", | ||
| "repository": "test", | ||
| "dependencies": { | ||
| "@netlify/dependency-with-range": "^9.5.4" | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "workspaces": [ | ||
| "apps/*" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [[plugins]] | ||
| package = "netlify-plugin-contextual-env" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "name": "module_plugin", | ||
| "version": "0.0.1", | ||
| "type": "module", | ||
| "description": "test", | ||
| "license": "MIT", | ||
| "repository": "test", | ||
| "dependencies": { | ||
| "@netlify/dependency-with-range": "^9.5.4" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "workspaces": [ | ||
| "apps/*" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,7 @@ import cpy from 'cpy' | |
|
|
||
| const FIXTURES_DIR = fileURLToPath(new URL('fixtures', import.meta.url)) | ||
|
|
||
| const runWithApiMock = async function ( | ||
| t, | ||
| const runWithApiMockAndGetNormalizedOutput = async function ( | ||
| fixtureName, | ||
| { testPlugin, response = getPluginsList(testPlugin), ...flags } = {}, | ||
| status = 200, | ||
|
|
@@ -26,12 +25,21 @@ const runWithApiMock = async function ( | |
| ...flags, | ||
| }) | ||
| .runWithBuild() | ||
| await t.snapshot(normalizeOutput(output)) | ||
| return normalizeOutput(output) | ||
| } finally { | ||
| await stopServer() | ||
| } | ||
| } | ||
|
|
||
| const runWithApiMock = async function ( | ||
| t, | ||
| fixtureName, | ||
| { testPlugin, response = getPluginsList(testPlugin), ...flags } = {}, | ||
| status = 200, | ||
| ) { | ||
| await t.snapshot(await runWithApiMockAndGetNormalizedOutput(fixtureName, { testPlugin, response, ...flags }, status)) | ||
| } | ||
|
|
||
|
Comment on lines
+34
to
+42
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All existing tests in this suite use snapshots which is not something I wanted to continue and wanted something a bit more concrete, so I moved most of this to another helper that just returns normalized output instead of snapshotting it. Would be nice to convert existing tests to explicit assertions, but I don't have bandwidth for that right now |
||
| // We use a specific plugin in tests. We hardcode its version to keep the tests | ||
| // stable even when new versions of that plugin are published. | ||
| const getPluginsList = function (testPlugin = DEFAULT_TEST_PLUGIN) { | ||
|
|
@@ -289,6 +297,66 @@ test.serial('Plugins can specify non-matching compatibility.siteDependencies ran | |
| }) | ||
| }) | ||
|
|
||
| test.serial( | ||
| 'Plugins can specify matching compatibility.siteDependencies range in monorepo with hoisted node_modules', | ||
| async (t) => { | ||
| await removeDir(`${FIXTURES_DIR}/plugins_compat_site_dependencies_range_monorepo_hoisted/apps/web/.netlify`) | ||
| const normalizedOutput = await runWithApiMockAndGetNormalizedOutput( | ||
| 'plugins_compat_site_dependencies_range_monorepo_hoisted', | ||
| { | ||
| testPlugin: { | ||
| compatibility: [ | ||
| { version: '0.3.0' }, | ||
| { | ||
| version: '0.2.0', | ||
| siteDependencies: { | ||
| // this is satisfied, so this version should be selected | ||
| '@netlify/dependency-with-range': '<10', | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| packagePath: 'apps/web', | ||
| }, | ||
| ) | ||
| t.true( | ||
| normalizedOutput.includes( | ||
| 'netlify-plugin-contextual-env 0-2-0 from netlify.toml (latest 0-3-0, expected 0-2-0, compatible 0-2-0)', | ||
| ), | ||
| ) | ||
| }, | ||
| ) | ||
|
|
||
| test.serial( | ||
| 'Plugins can specify matching compatibility.siteDependencies range in monorepo without hoisted node_modules', | ||
| async (t) => { | ||
| await removeDir(`${FIXTURES_DIR}/plugins_compat_site_dependencies_range_monorepo_not_hoisted/apps/web/.netlify`) | ||
| const normalizedOutput = await runWithApiMockAndGetNormalizedOutput( | ||
| 'plugins_compat_site_dependencies_range_monorepo_not_hoisted', | ||
| { | ||
| testPlugin: { | ||
| compatibility: [ | ||
| { version: '0.3.0' }, | ||
| { | ||
| version: '0.2.0', | ||
| siteDependencies: { | ||
| // this is satisfied, so this version should be selected | ||
| '@netlify/dependency-with-range': '<10', | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| packagePath: 'apps/web', | ||
| }, | ||
| ) | ||
| t.true( | ||
| normalizedOutput.includes( | ||
| 'netlify-plugin-contextual-env 0-2-0 from netlify.toml (latest 0-3-0, expected 0-2-0, compatible 0-2-0)', | ||
| ), | ||
| ) | ||
| }, | ||
| ) | ||
|
|
||
| test.serial('Plugin versions can be feature flagged', async (t) => { | ||
| await removeDir(`${FIXTURES_DIR}/plugins_compat_node_version/.netlify`) | ||
| await runWithApiMock(t, 'plugins_compat_node_version', { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - we seem to mostly be using
join(buildDir, packagePath || '')orpackagePath ?? ''