diff --git a/changelog.md b/changelog.md index 36e8d5c..6e51269 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,14 @@ # Architect Inventory changelog +--- + +## [4.0.6] 2024-06-29 + +### Changed + +- Added bun support + + --- ## [4.0.5] 2024-04-29 diff --git a/src/config/pragmas/populate-lambda/get-handler.js b/src/config/pragmas/populate-lambda/get-handler.js index fc8c7c6..8fc7477 100644 --- a/src/config/pragmas/populate-lambda/get-handler.js +++ b/src/config/pragmas/populate-lambda/get-handler.js @@ -85,6 +85,10 @@ function getExt ({ runtime, src, errors }) { let { file = 'mod', ext = 'ts' } = findHandler(denoHandlers, src) return { file, ext } } + if (runtime.startsWith('bun')) { + let { file = 'mod', ext = 'ts' } = findHandler(denoHandlers, src) + return { file, ext } + } return { ext: '' } } catch (err) { diff --git a/src/config/project/plugins/runtimes.js b/src/config/project/plugins/runtimes.js index 89e5cca..a4d9e3a 100644 --- a/src/config/project/plugins/runtimes.js +++ b/src/config/project/plugins/runtimes.js @@ -2,7 +2,7 @@ let { aliases, runtimeList } = require('lambda-runtimes') let { deepFrozenCopy } = require('@architect/utils') let { is, validationPatterns } = require('../../../lib') let { looserName } = validationPatterns -let allRuntimes = runtimeList.concat([ 'deno', ...Object.keys(aliases) ]) +let allRuntimes = runtimeList.concat([ 'bun', 'deno', ...Object.keys(aliases) ]) let validTypes = [ 'transpiled', 'compiled', 'interpreted' ] let builtTypes = validTypes.filter(t => t !== 'interpreted') diff --git a/src/validate/config.js b/src/validate/config.js index 175780b..927a318 100644 --- a/src/validate/config.js +++ b/src/validate/config.js @@ -14,7 +14,7 @@ module.exports = function configValidator (params, inventory, errors) { } = inventory.aws let customRuntimes = inventory._project?.customRuntimes?.runtimes || [] - let allRuntimes = runtimeList.concat([ 'deno', ...customRuntimes ]) + let allRuntimes = runtimeList.concat([ 'bun', 'deno', ...customRuntimes ]) /** * Global config diff --git a/test/unit/src/config/pragmas/populate-lambda/get-handler-test.js b/test/unit/src/config/pragmas/populate-lambda/get-handler-test.js index 21ed63a..dfd9acb 100644 --- a/test/unit/src/config/pragmas/populate-lambda/get-handler-test.js +++ b/test/unit/src/config/pragmas/populate-lambda/get-handler-test.js @@ -25,7 +25,7 @@ test('Set up env', t => { }) test('Handler properties (built-in runtimes)', t => { - t.plan(38) + t.plan(41) let config, cwd, errors, pythonHandler, rubyHandler, result // Defaults to Node.js @@ -150,6 +150,16 @@ test('Handler properties (built-in runtimes)', t => { t.equal(result.handlerFile, srcPath(`mod.ts`), `Got correct handlerFile: ${result.handlerFile}`) t.equal(result.handlerMethod, handler, `Got correct handlerMethod: ${result.handlerMethod}`) + // Bun + config = defaultFunctionConfig() + errors = [] + config.runtime = 'bun' + result = getHandler({ config, src, errors }) + t.notOk(errors.length, 'Did not get handler errors') + t.equal(result.handlerFile, srcPath(`mod.ts`), `Got correct handlerFile: ${result.handlerFile}`) + t.equal(result.handlerMethod, handler, `Got correct handlerMethod: ${result.handlerMethod}`) + + // Other / unknown config = defaultFunctionConfig() errors = [] diff --git a/test/unit/src/config/pragmas/populate-lambda/get-runtimes-test.js b/test/unit/src/config/pragmas/populate-lambda/get-runtimes-test.js index b2b3514..0760f25 100644 --- a/test/unit/src/config/pragmas/populate-lambda/get-runtimes-test.js +++ b/test/unit/src/config/pragmas/populate-lambda/get-runtimes-test.js @@ -40,7 +40,7 @@ test('Friendly runtime names (aka aliases)', t => { }) test('Exact runtime names', t => { - t.plan(14) + t.plan(16) let name let config @@ -78,6 +78,11 @@ test('Exact runtime names', t => { config = getRuntimes({ config: c(name), inventory }) t.equal(config.runtime, name, `Returned correct runtime string: ${name}`) t.notOk(config.runtimeAlias, 'Did not get runtimeAlias') + + name = 'bun' + config = getRuntimes({ config: c(name), inventory }) + t.equal(config.runtime, name, `Returned correct runtime string: ${name}`) + t.notOk(config.runtimeAlias, 'Did not get runtimeAlias') }) test('Custom runtime via plugin', t => {