Repository: geoffrich/svelte-adapter-azure-swa (js)

Issue:
Dynamically determine node version
https://github.com/geoffrich/svelte-adapter-azure-swa/pull/47 updated the adapter to target Node 16 instead of 12. This is good, but it would be better if we could allow the user to specify which node version to use. Otherwise, they'll be tied to the adapter Node version.

Here's how adapter-vercel does it:

https://github.com/sveltejs/kit/blob/3dae8e702641b5ee762b1892b7b7aa90e1c19a7c/packages/adapter-vercel/index.js#L388-L399

Pull request description:
feat: allow overriding `platform.apiRuntime`
Closes #48 

Instead of introducing a separate config option to set a custom node version, this PR allows setting `platform.apiRuntime` via `customStaticWebAppConfig`

e.g.

```js
// svelte.config.js
import adapter from 'svelte-adapter-azure-swa';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		adapter: adapter({
			customStaticWebAppConfig: {
				platform: {
					apiRuntime: 'node:18'
				}
			}
		})
	}
};

export default config;
```

Patch:
diff --git a/README.md b/README.md
index 306acdc..728aac6 100644
--- a/README.md
+++ b/README.md
@@ -165,6 +165,9 @@ export default {
 						'redirect': '/login',
 						'statusCode': 302
 					}
+				},
+				platform: {
+					apiRuntime: 'node:18'
 				}
 			}
 		})
diff --git a/index.js b/index.js
index 45c6969..c0ad9c0 100644
--- a/index.js
+++ b/index.js
@@ -210,7 +210,8 @@ export function generateConfig(customStaticWebAppConfig, appDir) {
 			rewrite: ssrFunctionRoute
 		},
 		platform: {
-			apiRuntime: 'node:16'
+			apiRuntime: 'node:16',
+			...customStaticWebAppConfig.platform
 		}
 	};
 


Test patch:
diff --git a/test/index.test.js b/test/index.test.js
index 8009c74..9711b1a 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -53,9 +53,13 @@ describe('generateConfig', () => {
 
 	test('accepts custom config', () => {
 		const result = generateConfig({
+			platform: {
+				apiRuntime: 'node:18'
+			},
 			globalHeaders: { 'X-Foo': 'bar' }
 		});
 		expect(result.globalHeaders).toStrictEqual({ 'X-Foo': 'bar' });
+		expect(result.platform.apiRuntime).toBe('node:18');
 	});
 });