diff --git a/docs/custom-registries.md b/docs/custom-registries.md index ba6dba1d8..37ad63536 100644 --- a/docs/custom-registries.md +++ b/docs/custom-registries.md @@ -25,6 +25,20 @@ RUN install-tool docker v24.0.2 RUN install-tool dart 2.18.0 ``` +## bun + +Bun releases are downloaded from: + +- `https://github.com/oven-sh/bun/releases/download` + +Samples: + +```txt +https://github.com/oven-sh/bun/releases/download/bun-v1.0.0/bun-linux-x64.zip +https://github.com/oven-sh/bun/releases/download/bun-v1.0.0/bun-linux-aarch64.zip +https://github.com/oven-sh/bun/releases/download/bun-v1.0.0/SHASUMS256.txt +``` + ## dart Dart releases are downloaded from: @@ -39,7 +53,6 @@ https://storage.googleapis.com/dart-archive/channels/stable/release/2.18.0/sdk/d https://storage.googleapis.com/dart-archive/channels/stable/release/2.19.4/sdk/dartsdk-linux-x64-release.zip.sha256sum https://storage.googleapis.com/dart-archive/channels/stable/release/2.19.4/sdk/dartsdk-linux-arm64-release.zip https://storage.googleapis.com/dart-archive/channels/stable/release/2.19.4/sdk/dartsdk-linux-arm64-release.zip.sha256sum - ``` ## docker @@ -53,7 +66,6 @@ Samples: ```txt https://download.docker.com/linux/static/stable/x86_64/docker-20.10.7.tgz https://download.docker.com/linux/static/stable/aarch64/docker-24.0.5.tgz - ``` ## dotnet diff --git a/docs/custom-root-ca.md b/docs/custom-root-ca.md index 42022388a..16e70c991 100644 --- a/docs/custom-root-ca.md +++ b/docs/custom-root-ca.md @@ -4,6 +4,12 @@ Most tools support two ways to extend the default Root CA certificates list. If you are using a custom base image, checkout [Custom base image](./custom-base-image.md) docs. +## Notes + +1. `Bun` doesn't support custom root ca certificates[^1]. + +[^1]: + ## Buildtime install This is the easiest method. diff --git a/src/cli/install-tool/index.ts b/src/cli/install-tool/index.ts index 68356bb74..2bdb3c894 100644 --- a/src/cli/install-tool/index.ts +++ b/src/cli/install-tool/index.ts @@ -1,5 +1,6 @@ import { Container, injectable } from 'inversify'; import { rootContainer } from '../services'; +import { InstallBunService } from '../tools/bun'; import { InstallDartService } from '../tools/dart'; import { InstallDockerService } from '../tools/docker'; import { InstallDotnetService } from '../tools/dotnet'; @@ -38,6 +39,7 @@ function prepareContainer(): Container { // tool services container.bind(INSTALL_TOOL_TOKEN).to(InstallBowerService); + container.bind(INSTALL_TOOL_TOKEN).to(InstallBunService); container.bind(INSTALL_TOOL_TOKEN).to(InstallBundlerService); container.bind(INSTALL_TOOL_TOKEN).to(InstallCocoapodsService); container.bind(INSTALL_TOOL_TOKEN).to(InstallCorepackService); diff --git a/src/cli/tools/bun.ts b/src/cli/tools/bun.ts new file mode 100644 index 000000000..96e709a6e --- /dev/null +++ b/src/cli/tools/bun.ts @@ -0,0 +1,79 @@ +import fs from 'node:fs/promises'; +import { join } from 'node:path'; +import { execa } from 'execa'; +import { inject, injectable } from 'inversify'; +import { InstallToolBaseService } from '../install-tool/install-tool-base.service'; +import { + CompressionService, + EnvService, + HttpService, + PathService, +} from '../services'; + +@injectable() +export class InstallBunService extends InstallToolBaseService { + readonly name = 'bun'; + + private get ghArch(): string { + switch (this.envSvc.arch) { + case 'arm64': + return 'aarch64'; + case 'amd64': + return 'x64'; + } + } + + constructor( + @inject(EnvService) envSvc: EnvService, + @inject(PathService) pathSvc: PathService, + @inject(HttpService) private http: HttpService, + @inject(CompressionService) private compress: CompressionService, + ) { + super(pathSvc, envSvc); + } + + override async install(version: string): Promise { + const baseUrl = `https://github.com/oven-sh/bun/releases/download/bun-v${version}/`; + const filename = `bun-linux-${this.ghArch}.zip`; + + const checksumFile = await this.http.download({ + url: `${baseUrl}SHASUMS256.txt`, + }); + const expectedChecksum = (await fs.readFile(checksumFile, 'utf-8')) + .split('\n') + .find((l) => l.includes(filename)) + ?.split(' ')[0]; + + const file = await this.http.download({ + url: `${baseUrl}${filename}`, + checksumType: 'sha256', + expectedChecksum, + }); + + // TODO: create recursive + if (!(await this.pathSvc.findToolPath(this.name))) { + await this.pathSvc.createToolPath(this.name); + } + + const path = join( + await this.pathSvc.createVersionedToolPath(this.name, version), + 'bin', + ); + await fs.mkdir(path); + await this.compress.extract({ + file, + cwd: path, + strip: 1, + }); + } + + override async link(version: string): Promise { + const src = join(this.pathSvc.versionedToolPath(this.name, version), 'bin'); + + await this.shellwrapper({ srcDir: src }); + } + + override async test(_version: string): Promise { + await execa(this.name, ['--version'], { stdio: ['inherit', 'inherit', 1] }); + } +} diff --git a/src/cli/tools/index.ts b/src/cli/tools/index.ts index bb4e269ce..9ee8b806e 100644 --- a/src/cli/tools/index.ts +++ b/src/cli/tools/index.ts @@ -1,5 +1,6 @@ export const NoPrepareTools = [ 'bower', + 'bun', 'bundler', 'cocoapods', 'corepack', diff --git a/test/Dockerfile.jammy b/test/Dockerfile.jammy index 9540f7f5f..9d92fa17f 100644 --- a/test/Dockerfile.jammy +++ b/test/Dockerfile.jammy @@ -29,6 +29,9 @@ RUN prepare-tool all #-------------------------------------- FROM build as test +# renovate: datasource=npm +RUN install-tool bun v1.0.0 + # renovate datasource=docker RUN install-tool dart 2.18.0 diff --git a/test/latest/Dockerfile b/test/latest/Dockerfile index d76a31e80..f795fda14 100644 --- a/test/latest/Dockerfile +++ b/test/latest/Dockerfile @@ -182,10 +182,13 @@ RUN prepare-tool all RUN set -ex; [ -d /usr/local/erlang ] && echo "works" || exit 1; #-------------------------------------- -# test: vendir, helmfile, kustomize +# test: bun, vendir, helmfile, kustomize #-------------------------------------- FROM base as teste +# renovate: datasource=npm +RUN install-tool bun v1.0.0 + # renovate: datasource=github-releases packageName=vmware-tanzu/carvel-vendir ARG VENDIR_VERSION=0.32.2 diff --git a/test/latest/Dockerfile.arm64 b/test/latest/Dockerfile.arm64 index f941a9c3d..a62086184 100644 --- a/test/latest/Dockerfile.arm64 +++ b/test/latest/Dockerfile.arm64 @@ -16,6 +16,14 @@ COPY src/ / RUN install-containerbase +#-------------------------------------- +# Image: bun +#-------------------------------------- +FROM base as test-bun + +# renovate: datasource=npm +RUN install-tool bun v1.0.0 + #-------------------------------------- # Image: docker #-------------------------------------- @@ -77,6 +85,7 @@ RUN install-tool vendir v0.34.4 #-------------------------------------- FROM base +COPY --from=test-bun /.dummy /.dummy COPY --from=test-docker /.dummy /.dummy COPY --from=test-git /.dummy /.dummy COPY --from=test-git-lfs /.dummy /.dummy