diff --git a/.changeset/cyan-ladybugs-divide.md b/.changeset/cyan-ladybugs-divide.md new file mode 100644 index 000000000000..2cd5d409b0f1 --- /dev/null +++ b/.changeset/cyan-ladybugs-divide.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-auto': patch +--- + +fix: pin adapter versions diff --git a/packages/adapter-auto/adapters.js b/packages/adapter-auto/adapters.js index 12b77910e69b..bbd36575c55a 100644 --- a/packages/adapter-auto/adapters.js +++ b/packages/adapter-auto/adapters.js @@ -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' }, { 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' } ]; diff --git a/packages/adapter-auto/index.js b/packages/adapter-auto/index.js index 6caacb8b7db9..9e73f5092c85 100644 --- a/packages/adapter-auto/index.js +++ b/packages/adapter-auto/index.js @@ -5,11 +5,11 @@ import { adapters } from './adapters.js'; import { dirname, join } from 'path'; import { existsSync } from 'fs'; -/** @type {Record string>} */ +/** @type {Record 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() { @@ -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}...`);