From 5eb8e35b003976f13eb13a15956de3fe8ed4aff2 Mon Sep 17 00:00:00 2001 From: Ryan Block Date: Thu, 4 Nov 2021 10:13:27 -0700 Subject: [PATCH] Add runtime version metadata --- cjs/changelog.md => changelog.md | 0 cjs/index.js | 76 ++++++++++++++++++++++++++++++++ test/unit/esm/index-test.js | 17 ++++++- 3 files changed, 91 insertions(+), 2 deletions(-) rename cjs/changelog.md => changelog.md (100%) diff --git a/cjs/changelog.md b/changelog.md similarity index 100% rename from cjs/changelog.md rename to changelog.md diff --git a/cjs/index.js b/cjs/index.js index 07a1c12..8db944b 100644 --- a/cjs/index.js +++ b/cjs/index.js @@ -32,6 +32,81 @@ let runtimes = { ], } +let runtimeVersions = { + 'nodejs14.x': { + major: '14', + minor: null, + patch: null, + wildcard: '14.*.*' + }, + 'nodejs12.x': { + major: '12', + minor: null, + patch: null, + wildcard: '12.*.*', + }, + 'python3.9': { + major: '3', + minor: '9', + patch: null, + wildcard: '3.9.*', + }, + 'python3.8': { + major: '3', + minor: '8', + patch: null, + wildcard: '3.8.*', + }, + 'python3.7': { + major: '3', + minor: '7', + patch: null, + wildcard: '3.7.*', + }, + 'python3.6': { + major: '3', + minor: '6', + patch: null, + wildcard: '3.6.*', + }, + 'ruby2.7': { + major: '2', + minor: '7', + patch: null, + wildcard: '2.7.*', + }, + 'java11': { + major: '11', + minor: null, + patch: null, + wildcard: '11.*.*', + }, + 'java8.al2': { + major: '8', + minor: null, + patch: null, + wildcard: '8.*.*', + }, + 'java8': { + major: '8', + minor: null, + patch: null, + wildcard: '8.*.*', + }, + 'go1.x': { + major: '1', + minor: null, + patch: null, + wildcard: '1.*.*', + }, + 'dotnetcore3.1': { + major: '3', + minor: '1', + patch: null, + wildcard: '3.1.*', + }, +} + let runtimeList = Object.values(runtimes).reduce((a, b) => a.concat(b), []) let runtimesByArchitecture = { @@ -110,6 +185,7 @@ let retiredRuntimes = { module.exports = { runtimes, + runtimeVersions, runtimeList, runtimesByArchitecture, architecturesByRuntime, diff --git a/test/unit/esm/index-test.js b/test/unit/esm/index-test.js index 61699b1..7400915 100644 --- a/test/unit/esm/index-test.js +++ b/test/unit/esm/index-test.js @@ -7,9 +7,10 @@ test('Set up env', t => { }) test('Exports', t => { - t.plan(7) + t.plan(8) let { runtimes, + runtimeVersions, runtimeList, runtimesByArchitecture, architecturesByRuntime, @@ -17,12 +18,13 @@ test('Exports', t => { retiredRuntimes, } = lambdaRuntimes t.ok(runtimes, 'Got runtimes') + t.ok(runtimeVersions, 'Got runtimeVersions') t.ok(runtimeList, 'Got runtimeList') t.ok(runtimesByArchitecture, 'Got runtimesByArchitecture') t.ok(architecturesByRuntime, 'Got architecturesByRuntime') t.ok(aliases, 'Got aliases') t.ok(retiredRuntimes, 'Got retiredRuntimes') - t.equal(Object.keys(lambdaRuntimes).length, 6, 'Got all properties') + t.equal(Object.keys(lambdaRuntimes).length, 7, 'Got all properties') console.dir(lambdaRuntimes, { depth: null }) }) @@ -35,6 +37,17 @@ test('runtimes semantics', t => { t.pass('All runtimes values are arrays') }) +test('runtimeVersions semantics', t => { + t.plan(2) + let { runtimeList, runtimeVersions } = lambdaRuntimes + let list = runtimeList.filter(r => !r.startsWith('provided')) + list.forEach(runtime => { + if (!runtimeVersions[runtime]) t.fail(`${runtime} not found in runtimeVersions`) + }) + t.pass('Found all runtimeVersions') + t.equal(list.length, Object.keys(runtimeVersions).length, 'Correct number of runtimeVersions found') +}) + test('runtimeList semantics', t => { t.plan(1) let { runtimeList } = lambdaRuntimes