Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes to enable bun support in sandbox #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Architect Inventory changelog

---

## [4.0.6] 2024-06-29

### Changed

- Added bun support


---

## [4.0.5] 2024-04-29
Expand Down
4 changes: 4 additions & 0 deletions src/config/pragmas/populate-lambda/get-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/config/project/plugins/runtimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion src/validate/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion test/unit/src/config/pragmas/populate-lambda/get-handler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 => {
Expand Down