From 14c6c9784f05a8cd9feb380f2265a8f078d8f04a Mon Sep 17 00:00:00 2001 From: Jikun Date: Tue, 12 May 2026 11:40:36 +0800 Subject: [PATCH 1/2] bug fix --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 79bf7c42e..006d7812f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -68,7 +68,7 @@ export const DEFAULT_CONFIG: SWACLIConfig = { appName: SWA_CLI_APP_NAME || undefined, dryRun: useEnvVarOrUseDefault(SWA_CLI_DEPLOY_DRY_RUN, false), apiLanguage: SWA_CLI_API_LANGUAGE || "node", - apiVersion: SWA_CLI_API_VERSION || "16", + apiVersion: SWA_CLI_API_VERSION || "22", dataApiDevserverUrl: SWA_CLI_DATA_API_DEVSERVER_URL || undefined, // swa login options From 1a85bb98063e489c990c13402a214fbec749967c Mon Sep 17 00:00:00 2001 From: Jikun Date: Mon, 18 May 2026 10:54:35 +0800 Subject: [PATCH 2/2] added UT --- src/cli/commands/deploy/deploy.spec.ts | 38 ++++++++++++++++++++++++++ src/core/constants.spec.ts | 19 +++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/core/constants.spec.ts diff --git a/src/cli/commands/deploy/deploy.spec.ts b/src/cli/commands/deploy/deploy.spec.ts index f67dbadc4..313de36b5 100644 --- a/src/cli/commands/deploy/deploy.spec.ts +++ b/src/cli/commands/deploy/deploy.spec.ts @@ -9,6 +9,8 @@ import * as deployClientModule from "../../../core/deploy-client.js"; import { deploy } from "./deploy.js"; import * as loginModule from "../login/login.js"; import { loadPackageJson } from "../../../core/utils/json.js"; +import { DEFAULT_VERSION, SUPPORTED_VERSIONS } from "../../../core/constants.js"; +import * as optionsModule from "../../../core/utils/options.js"; const pkg = loadPackageJson(); @@ -269,5 +271,41 @@ describe("deploy", () => { expect(logger.error).toHaveBeenCalledWith("The deployment binary exited with code 1."); expect(exitSpy).not.toHaveBeenCalled(); }); + + it("should pass correct FUNCTION_LANGUAGE_VERSION for python when only apiLanguage is specified", async () => { + vi.spyOn(optionsModule, "isUserOrConfigOption").mockImplementation((option) => option === "apiLanguage"); + + await deploy({ outputLocation: "/test-output", dryRun: false, apiLanguage: "python" }); + + const spawnCall = vi.mocked(spawn).mock.calls[0]; + const env = spawnCall[2]?.env as Record; + expect(env.FUNCTION_LANGUAGE).toBe("python"); + expect(env.FUNCTION_LANGUAGE_VERSION).toBe(DEFAULT_VERSION.Python); + expect(SUPPORTED_VERSIONS.Python).toContain(env.FUNCTION_LANGUAGE_VERSION); + }); + + it("should pass correct FUNCTION_LANGUAGE_VERSION for dotnet when only apiLanguage is specified", async () => { + vi.spyOn(optionsModule, "isUserOrConfigOption").mockImplementation((option) => option === "apiLanguage"); + + await deploy({ outputLocation: "/test-output", dryRun: false, apiLanguage: "dotnet" }); + + const spawnCall = vi.mocked(spawn).mock.calls[0]; + const env = spawnCall[2]?.env as Record; + expect(env.FUNCTION_LANGUAGE).toBe("dotnet"); + expect(env.FUNCTION_LANGUAGE_VERSION).toBe(DEFAULT_VERSION.Dotnet); + expect(SUPPORTED_VERSIONS.Dotnet).toContain(env.FUNCTION_LANGUAGE_VERSION); + }); + + it("should pass correct FUNCTION_LANGUAGE_VERSION for dotnetisolated when only apiLanguage is specified", async () => { + vi.spyOn(optionsModule, "isUserOrConfigOption").mockImplementation((option) => option === "apiLanguage"); + + await deploy({ outputLocation: "/test-output", dryRun: false, apiLanguage: "dotnetisolated" }); + + const spawnCall = vi.mocked(spawn).mock.calls[0]; + const env = spawnCall[2]?.env as Record; + expect(env.FUNCTION_LANGUAGE).toBe("dotnetisolated"); + expect(env.FUNCTION_LANGUAGE_VERSION).toBe(DEFAULT_VERSION.DotnetIsolated); + expect(SUPPORTED_VERSIONS.DotnetIsolated).toContain(env.FUNCTION_LANGUAGE_VERSION); + }); }); }); diff --git a/src/core/constants.spec.ts b/src/core/constants.spec.ts new file mode 100644 index 000000000..0218be68f --- /dev/null +++ b/src/core/constants.spec.ts @@ -0,0 +1,19 @@ +import { DEFAULT_CONFIG } from "../config.js"; +import { DEFAULT_VERSION, SUPPORTED_VERSIONS } from "./constants.js"; + +describe("DEFAULT_CONFIG and DEFAULT_VERSION/SUPPORTED_VERSIONS consistency", () => { + it("DEFAULT_CONFIG.apiVersion should match DEFAULT_VERSION.Node", () => { + expect(DEFAULT_CONFIG.apiVersion).toBe(DEFAULT_VERSION.Node); + }); + + it("DEFAULT_CONFIG.apiLanguage should be 'node'", () => { + expect(DEFAULT_CONFIG.apiLanguage).toBe("node"); + }); + + it("every DEFAULT_VERSION should be in its corresponding SUPPORTED_VERSIONS", () => { + expect(SUPPORTED_VERSIONS.Node).toContain(DEFAULT_VERSION.Node); + expect(SUPPORTED_VERSIONS.Dotnet).toContain(DEFAULT_VERSION.Dotnet); + expect(SUPPORTED_VERSIONS.DotnetIsolated).toContain(DEFAULT_VERSION.DotnetIsolated); + expect(SUPPORTED_VERSIONS.Python).toContain(DEFAULT_VERSION.Python); + }); +});