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

fix: pin adapter versions in adapter-auto #8874

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cyan-ladybugs-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-auto': patch
---

fix: pin adapter versions
14 changes: 10 additions & 4 deletions packages/adapter-auto/adapters.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
// List of adapters to check for. `version` is used to pin the installed adapter version and should point
// to the latest version of the adapter that is compatible with adapter-auto's current peerDependency version of SvelteKit.
export const adapters = [
{
name: 'Vercel',
test: () => !!process.env.VERCEL,
module: '@sveltejs/adapter-vercel'
module: '@sveltejs/adapter-vercel',
version: '1'
Copy link
Member

Choose a reason for hiding this comment

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

is there some way to get these automatically populated from the workspace? it seems like it's going to be really easy to overlook bumping these, which might cause more trouble that it solves

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't automatically bump them because the mechanism can't know if the bump warrants a major release of adapter-auto or not.
Example:

  • adapter-vercel releases new major but peerDep on SvelteKit stays the same -> should be a minor release in adapter-auto
  • adapter-vercel releases a new major and bumps peerDep on SvelteKit -> should be a major release in adapter-auto

Copy link
Member

Choose a reason for hiding this comment

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

Do we have the ability to specify semver ranges here of the other adapters? It might not be what's happening here, but I can imagine a situation where an adapter has a breaking change because of what options it accepts, but that change is irrelevant for people consuming it through the auto adapter because it doesn't let you specify any options anyway. Are we prepared for that sort of situation?

Copy link
Member

Choose a reason for hiding this comment

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

I think we could just bump the adapter version here and it would be harmless, no? It's just a matter of remembering to do it

Copy link
Member

Choose a reason for hiding this comment

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

Probably, yeah. I'm not sure what I was thinking about with the range. I think I had forgotten that the auto adapter doesn't itself have peer dependencies on the other adapters.

},
{
name: 'Cloudflare Pages',
test: () => !!process.env.CF_PAGES,
module: '@sveltejs/adapter-cloudflare'
module: '@sveltejs/adapter-cloudflare',
version: '2'
},
{
name: 'Netlify',
test: () => !!process.env.NETLIFY,
module: '@sveltejs/adapter-netlify'
module: '@sveltejs/adapter-netlify',
version: '1'
},
{
name: 'Azure Static Web Apps',
test: () => process.env.GITHUB_ACTION_REPOSITORY === 'Azure/static-web-apps-deploy',
module: 'svelte-adapter-azure-swa'
module: 'svelte-adapter-azure-swa',
version: '0.13'
Copy link
Member Author

Choose a reason for hiding this comment

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

@geoffrich FYI you need to bump this when you create a new major of the azure adapter

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the heads up 👍

}
];
10 changes: 5 additions & 5 deletions packages/adapter-auto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { adapters } from './adapters.js';
import { dirname, join } from 'path';
import { existsSync } from 'fs';

/** @type {Record<string, (name: string) => string>} */
/** @type {Record<string, (name: string, version: string) => string>} */
const commands = {
npm: (name) => `npm install -D ${name}`,
pnpm: (name) => `pnpm add -D ${name}`,
yarn: (name) => `yarn add -D ${name}`
npm: (name, version) => `npm install -D ${name}@${version}`,
pnpm: (name, version) => `pnpm add -D ${name}@${version}`,
yarn: (name, version) => `yarn add -D ${name}@${version}`
};

function detect_lockfile() {
Expand Down Expand Up @@ -64,7 +64,7 @@ async function get_adapter() {
error.message.startsWith(`Cannot find package '${match.module}'`)
) {
const package_manager = detect_package_manager();
const command = commands[package_manager](match.module);
const command = commands[package_manager](match.module, match.version);

try {
console.log(`Installing ${match.module}...`);
Expand Down