From fc5e5b2c9e29859c54ba1e65128754cffae44bcf Mon Sep 17 00:00:00 2001 From: Wout Date: Wed, 25 Feb 2026 17:09:47 +0100 Subject: [PATCH 1/3] Add flag to remove orphaned containers in test script --- script/test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/test b/script/test index 443f26190..bb6030907 100755 --- a/script/test +++ b/script/test @@ -1,6 +1,6 @@ #!/bin/sh -eu -COMPOSE="docker compose run --rm app" +COMPOSE="docker compose run --remove-orphans --rm app" printf "\nrunning specs with 'crystal spec'\n\n" $COMPOSE crystal spec "$@" From 66f9bc57b8f6f0ec44a0a5f58d69cd85ff1d99bf Mon Sep 17 00:00:00 2001 From: Wout Date: Wed, 25 Feb 2026 17:11:28 +0100 Subject: [PATCH 2/3] Install bun instead of pulling it in This caused issues today where the bun tests failed because of the bun binary. This fix ensures we're getting the correct binary. --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9c1284db7..33404cf33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ FROM crystallang/crystal:latest WORKDIR /data -COPY --from=oven/bun:latest /usr/local/bin/bun /usr/local/bin/bun - RUN apt-get update && \ - apt-get install -y curl libreadline-dev && \ + apt-get install -y curl libreadline-dev unzip && \ + curl -fsSL https://bun.sh/install | bash && \ + ln -s /root/.bun/bin/bun /usr/local/bin/bun && \ # Cleanup leftovers apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From 156ecfeb15128a2bcabd161b497f69ec3154eb08 Mon Sep 17 00:00:00 2001 From: Wout Date: Wed, 25 Feb 2026 17:11:57 +0100 Subject: [PATCH 3/3] Fixes a bug in the asset manifest path --- spec/bun/lucky.test.js | 46 +++++++++++++++++++++--------------------- src/bun/lucky.js | 8 +++----- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/spec/bun/lucky.test.js b/spec/bun/lucky.test.js index 08a6a3835..8d059d200 100644 --- a/spec/bun/lucky.test.js +++ b/spec/bun/lucky.test.js @@ -229,43 +229,43 @@ describe('writeManifest', () => { await LuckyBun.writeManifest() const content = readFileSync( - join(TEST_DIR, 'public/assets/manifest.json'), + join(TEST_DIR, 'public/bun-manifest.json'), 'utf-8' ) expect(JSON.parse(content)).toEqual({'js/app.js': 'js/app-abc123.js'}) }) -}) - -describe('outDir', () => { - test('throws if config not loaded', () => { - LuckyBun.config = null - expect(() => LuckyBun.outDir).toThrow('Config is not loaded') - }) - test('returns full path when config loaded', () => { + test('writes manifest relative to project root, not outDir', async () => { LuckyBun.root = TEST_DIR LuckyBun.loadConfig() - expect(LuckyBun.outDir).toBe(join(TEST_DIR, 'public/assets')) + LuckyBun.manifest = {'js/app.js': 'js/app-abc123.js'} + + await LuckyBun.writeManifest() + + const correctPath = join(TEST_DIR, 'public/bun-manifest.json') + const buggyPath = join(TEST_DIR, 'public/assets/public/bun-manifest.json') + + expect(existsSync(correctPath)).toBe(true) + expect(existsSync(buggyPath)).toBe(false) }) -}) -describe('cssAliasPlugin', () => { - test('replaces $/ with src path', async () => { - mkdirSync(join(TEST_DIR, 'src/css'), {recursive: true}) - mkdirSync(join(TEST_DIR, 'src/images'), {recursive: true}) - writeFileSync(join(TEST_DIR, 'src/images/bg.png'), 'fake') + test('respects custom manifestPath from config', async () => { + mkdirSync(join(TEST_DIR, 'config'), {recursive: true}) writeFileSync( - join(TEST_DIR, 'src/css/app.css'), - "body { background: url('$/images/bg.png'); }" + join(TEST_DIR, 'config/bun.json'), + JSON.stringify({manifestPath: 'dist/manifest.json'}) ) LuckyBun.root = TEST_DIR LuckyBun.loadConfig() - await LuckyBun.buildCSS() + LuckyBun.manifest = {'css/app.css': 'css/app-def456.css'} + + await LuckyBun.writeManifest() + + const manifestPath = join(TEST_DIR, 'dist/manifest.json') + const content = JSON.parse(readFileSync(manifestPath, 'utf-8')) - const cssPath = join(TEST_DIR, 'public/assets/css/app.css') - const content = readFileSync(cssPath, 'utf-8') - expect(content).toContain('/src/') - expect(content).not.toContain('$/') + expect(existsSync(manifestPath)).toBe(true) + expect(content).toEqual({'css/app.css': 'css/app-def456.css'}) }) }) diff --git a/src/bun/lucky.js b/src/bun/lucky.js index 92485ddbd..5a000def7 100644 --- a/src/bun/lucky.js +++ b/src/bun/lucky.js @@ -181,11 +181,9 @@ export default { // Writes the asset manifest. async writeManifest() { - mkdirSync(this.outDir, {recursive: true}) - await Bun.write( - join(this.outDir, this.config.manifestPath), - JSON.stringify(this.manifest, null, 2) - ) + const manifestFullPath = join(this.root, this.config.manifestPath) + mkdirSync(dirname(manifestFullPath), {recursive: true}) + await Bun.write(manifestFullPath, JSON.stringify(this.manifest, null, 2)) }, // Performs a full new build based on the current environment.