Skip to content
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

feat: allow frameworks to detect version of CLI that's being used #6226

Merged
merged 14 commits into from
Jan 8, 2024

Conversation

Skn0tt
Copy link
Contributor

@Skn0tt Skn0tt commented Nov 29, 2023

Addresses https://linear.app/netlify/issue/COM-189/give-frameworks-a-way-to-detect-version-of-netlify-build-cli-thats.

This PR gives frameworks + framework adapters a way to detect the version of the Netlify CLI that it's called through. The Astro adapter, for example, can use this to detect if the CLI is at least on 17.8.x - else it can choose to fail the local dev, because not all features that it depends on are present on that version. It can then prompt the user to update their CLI.

@Skn0tt Skn0tt self-assigned this Nov 29, 2023
@Skn0tt Skn0tt requested a review from a team as a code owner November 29, 2023 11:03
@Skn0tt Skn0tt changed the title feat: Inject dev version feat: allow frameworks to detect version of CLI that's being used Nov 29, 2023
Copy link

github-actions bot commented Nov 29, 2023

📊 Benchmark results

Comparing with 10d470d

  • Dependency count: 1,410 (no change)
  • Package size: 422 MB (no change)
  • Number of ts-expect-error directives: 1,189 (no change)

@@ -606,7 +609,8 @@ export default class BaseCommand extends Command {
token,
...apiUrlOpts,
})
const { buildDir, config, configPath, repositoryRoot, siteInfo } = cachedConfig
const { buildDir, config, configPath, env, repositoryRoot, siteInfo } = cachedConfig
env.NETLIFY_CLI_VERSION = { sources: ['internal'], value: netlifyCliVersion }
Copy link
Contributor Author

@Skn0tt Skn0tt Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main functional change in this PR.

I don't have strong feelings around the name of the var - maybe NETLIFY_CLI would be better? We already inject NETLIFY_LOCAL=true. We could reuse that, but I imagine some consumers are depending on its value being "true".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this var name is just fine - clear is best imo (even if it's wordy :D )

sarahetter
sarahetter previously approved these changes Dec 5, 2023
@Skn0tt Skn0tt enabled auto-merge (squash) December 5, 2023 14:00
@Skn0tt
Copy link
Contributor Author

Skn0tt commented Dec 12, 2023

Oops, looks like this didn't auto-merge yet! Resolved the conflicts, would love another stamp :)

sarahetter
sarahetter previously approved these changes Dec 12, 2023
@Skn0tt
Copy link
Contributor Author

Skn0tt commented Dec 13, 2023

And now the tests are failing :/ I swear they worked locally!

@Skn0tt
Copy link
Contributor Author

Skn0tt commented Dec 22, 2023

Whoohoo, tests are passing! Would appreciate another approval in the new year :D

@@ -26,6 +26,7 @@ import {
exit,
getToken,
log,
netlifyCliVersion,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This name feels a bit redundant and overly verbose to me, since everything here pertains to the Netlify CLI and there's no need to make that explicit with a prefix. Could we use something like version?

// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
Object.entries(environment).filter(([, variable]) => variable.sources[0] !== 'general'),
Object.entries(environment).filter(
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would it take to get rid of this?

@Skn0tt Skn0tt merged commit 1066ff3 into main Jan 8, 2024
35 checks passed
@Skn0tt Skn0tt deleted the inject-dev-version branch January 8, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants