Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Adding support for nodejs16 and nodejs18 #642

Merged
merged 13 commits into from
Feb 27, 2023
17 changes: 17 additions & 0 deletions src/armTemplates/resources/functionApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,23 @@ describe("Function App Resource", () => {
expect(functionAppNodeVersion.value).toEqual("~16");
});

it("gets correct parameters - node 18", () => {
const config = getConfig(FunctionAppOS.LINUX, Runtime.NODE18);

const resource = new FunctionAppResource();

const params = resource.getParameters(config);
const {
linuxFxVersion,
functionAppNodeVersion,
} = params;

assertLinuxParams(params);

expect(linuxFxVersion.value).toEqual("NODE|18");
expect(functionAppNodeVersion.value).toEqual("~18");
});

it("gets correct parameters - python 3.6", () => {
const config = getConfig(FunctionAppOS.LINUX, Runtime.PYTHON36);

Expand Down
5 changes: 5 additions & 0 deletions src/config/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe("Runtime", () => {
expect(isNodeRuntime(Runtime.NODE12)).toBe(true);
expect(isNodeRuntime(Runtime.NODE14)).toBe(true);
expect(isNodeRuntime(Runtime.NODE16)).toBe(true);
expect(isNodeRuntime(Runtime.NODE18)).toBe(true);
expect(isNodeRuntime(Runtime.PYTHON36)).toBe(false);
expect(isNodeRuntime(Runtime.PYTHON37)).toBe(false);
expect(isNodeRuntime(Runtime.PYTHON38)).toBe(false);
Expand All @@ -17,6 +18,7 @@ describe("Runtime", () => {
expect(isPythonRuntime(Runtime.NODE12)).toBe(false);
expect(isPythonRuntime(Runtime.NODE14)).toBe(false);
expect(isPythonRuntime(Runtime.NODE16)).toBe(false);
expect(isPythonRuntime(Runtime.NODE18)).toBe(false);
expect(isPythonRuntime(Runtime.PYTHON36)).toBe(true);
expect(isPythonRuntime(Runtime.PYTHON37)).toBe(true);
expect(isPythonRuntime(Runtime.PYTHON38)).toBe(true);
Expand All @@ -27,6 +29,7 @@ describe("Runtime", () => {
expect(getRuntimeVersion(Runtime.NODE12)).toBe("12");
expect(getRuntimeVersion(Runtime.NODE14)).toBe("14");
expect(getRuntimeVersion(Runtime.NODE16)).toBe("16");
expect(getRuntimeVersion(Runtime.NODE18)).toBe("18");
expect(getRuntimeVersion(Runtime.PYTHON36)).toBe("3.6");
expect(getRuntimeVersion(Runtime.PYTHON37)).toBe("3.7");
expect(getRuntimeVersion(Runtime.PYTHON38)).toBe("3.8");
Expand All @@ -43,6 +46,7 @@ describe("Runtime", () => {
expect(getRuntimeLanguage(Runtime.NODE12)).toBe("nodejs");
expect(getRuntimeLanguage(Runtime.NODE14)).toBe("nodejs");
expect(getRuntimeLanguage(Runtime.NODE16)).toBe("nodejs");
expect(getRuntimeLanguage(Runtime.NODE18)).toBe("nodejs");
expect(getRuntimeLanguage(Runtime.PYTHON36)).toBe("python");
expect(getRuntimeLanguage(Runtime.PYTHON37)).toBe("python");
expect(getRuntimeLanguage(Runtime.PYTHON38)).toBe("python");
Expand All @@ -59,6 +63,7 @@ describe("Runtime", () => {
expect(getFunctionWorkerRuntime(Runtime.NODE12)).toBe("node");
expect(getFunctionWorkerRuntime(Runtime.NODE14)).toBe("node");
expect(getFunctionWorkerRuntime(Runtime.NODE16)).toBe("node");
expect(getFunctionWorkerRuntime(Runtime.NODE18)).toBe("node");
expect(getFunctionWorkerRuntime(Runtime.PYTHON36)).toBe("python");
expect(getFunctionWorkerRuntime(Runtime.PYTHON37)).toBe("python");
expect(getFunctionWorkerRuntime(Runtime.PYTHON38)).toBe("python");
Expand Down
3 changes: 3 additions & 0 deletions src/config/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum Runtime {
NODE12 = "nodejs12",
NODE14 = "nodejs14",
NODE16 = "nodejs16",
NODE18 = "nodejs18",
PYTHON36 = "python3.6",
PYTHON37 = "python3.7",
PYTHON38 = "python3.8",
Expand All @@ -16,6 +17,7 @@ export const supportedRuntimes = [
Runtime.NODE12,
Runtime.NODE14,
Runtime.NODE16,
Runtime.NODE18,
Runtime.PYTHON36,
Runtime.PYTHON37,
Runtime.PYTHON38,
Expand Down Expand Up @@ -95,6 +97,7 @@ export const dockerImages = {
nodejs12: "NODE|12",
nodejs14: "NODE|14",
nodejs16: "NODE|16",
nodejs18: "NODE|18",
"python3.6": "PYTHON|3.6",
"python3.7": "PYTHON|3.7",
"python3.8": "PYTHON|3.8",
Expand Down
8 changes: 4 additions & 4 deletions src/services/configService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,23 @@ describe("Config Service", () => {
sls.service.provider.runtime = "python2.7" as any;
expect(() => new ConfigService(sls, {} as any))
.toThrowError("Runtime python2.7 is not supported. " +
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,nodejs18,python3.6,python3.7,python3.8");
});

it("throws error when incomplete nodejs version in defined", () => {
const sls = MockFactory.createTestServerless();
sls.service.provider.runtime = "nodejs" as any;
expect(() => new ConfigService(sls, {} as any))
.toThrowError("Runtime nodejs is not supported. " +
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,nodejs18,python3.6,python3.7,python3.8");
});

it("throws error when unsupported nodejs version in defined", () => {
const sls = MockFactory.createTestServerless();
sls.service.provider.runtime = "nodejs5.x" as any;
expect(() => new ConfigService(sls, {} as any))
.toThrowError("Runtime nodejs5.x is not supported. " +
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,nodejs18,python3.6,python3.7,python3.8");
});

it("Does not throw an error when valid nodejs version is defined", () => {
Expand All @@ -258,7 +258,7 @@ describe("Config Service", () => {
sls.service.provider.runtime = undefined;
expect(() => new ConfigService(sls, {} as any))
.toThrowError("Runtime undefined. " +
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,python3.6,python3.7,python3.8");
"Runtimes supported: nodejs10,nodejs12,nodejs14,nodejs16,nodejs18,python3.6,python3.7,python3.8");
});

it("does not throw an error with python3.6", () => {
Expand Down