Skip to content

Commit

Permalink
feat: add devbox as an install tool (#3191)
Browse files Browse the repository at this point in the history
* feat: add devbox as an install tool

* Add distro test

* Add docs and more tests

Revert formatting

Revert vendir version downgrade

* Fix rebase issue

* alphabetical renovate dep names

* fix version command for devbox cli

* PR recommendations

* Add link to bin

* Update devbox version and mkdir to match bun installer

* test: sort

---------

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent 8dc62a6 commit c2ef8e6
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 2 deletions.
14 changes: 14 additions & 0 deletions docs/custom-registries.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ https://storage.googleapis.com/dart-archive/channels/stable/release/2.19.4/sdk/d
https://storage.googleapis.com/dart-archive/channels/stable/release/2.19.4/sdk/dartsdk-linux-arm64-release.zip.sha256sum
```

## `devbox`

Devbox releases are downloaded from:

- `https://github.com/jetify-com/devbox/releases`

Samples:

```txt
https://github.com/jetify-com/devbox/releases/download/0.12.0/devbox_0.12.0_linux_amd64.tar.gz
https://github.com/jetify-com/devbox/releases/download/0.12.0/devbox_0.12.0_linux_arm64.tar.gz
https://github.com/jetify-com/devbox/releases/download/0.12.0/checksums.txt
```

## `docker`

Docker releases are downloaded from:
Expand Down
4 changes: 3 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"conan",
"copier",
"corepack",
"devbox",
"docker",
"dotnet",
"git",
Expand Down Expand Up @@ -100,9 +101,10 @@
"bazelisk",
"bun",
"bundler",
"corepack",
"conan",
"copier",
"corepack",
"devbox",
"docker",
"dotnet",
"git",
Expand Down
2 changes: 2 additions & 0 deletions src/cli/install-tool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ResolverMap } from '../tools';
import { BazeliskInstallService } from '../tools/bazelisk';
import { BunInstallService } from '../tools/bun';
import { DartInstallService } from '../tools/dart';
import { DevboxInstallService } from '../tools/devbox';
import { DockerInstallService } from '../tools/docker';
import { DotnetInstallService } from '../tools/dotnet';
import { FlutterInstallService } from '../tools/flutter';
Expand Down Expand Up @@ -85,6 +86,7 @@ function prepareInstallContainer(): Container {
container.bind(INSTALL_TOOL_TOKEN).to(CocoapodsInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(ConanInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(DartInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(DevboxInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(DockerInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(DotnetInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(FlutterInstallService);
Expand Down
65 changes: 65 additions & 0 deletions src/cli/tools/devbox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import fs from 'node:fs/promises';
import { join } from 'node:path';
import { execa } from 'execa';
import { inject, injectable } from 'inversify';
import { BaseInstallService } from '../install-tool/base-install.service';
import {
CompressionService,
EnvService,
HttpService,
PathService,
} from '../services';

@injectable()
export class DevboxInstallService extends BaseInstallService {
readonly name = 'devbox';

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<void> {
const baseUrl = `https://github.com/jetify-com/devbox/releases/download/${version}/`;
const filename = `devbox_${version}_linux_${this.envSvc.arch}.tar.gz`;

const checksumFile = await this.http.download({
url: `${baseUrl}checksums.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,
});

await this.pathSvc.ensureToolPath(this.name);

const path = join(
await this.pathSvc.createVersionedToolPath(this.name, version),
'bin',
);
await fs.mkdir(path);
await this.compress.extract({
file,
cwd: path,
});
}

override async link(version: string): Promise<void> {
const src = join(this.pathSvc.versionedToolPath(this.name, version), 'bin');
await this.shellwrapper({ srcDir: src });
}

override async test(_version: string): Promise<void> {
await execa(this.name, ['version'], { stdio: ['inherit', 'inherit', 1] });
}
}
1 change: 1 addition & 0 deletions src/cli/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const NoPrepareTools = [
'composer',
'copier',
'corepack',
'devbox',
'flux',
'gleam',
'gradle',
Expand Down
3 changes: 3 additions & 0 deletions test/Dockerfile.distro
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ RUN install-tool bun 1.1.38
# renovate: datasource=docker
RUN install-tool dart 3.5.4

# renovate: datasource=github-releases packageName=jetify-com/devbox
RUN install-tool devbox 0.13.4

# renovate: datasource=github-releases packageName=moby/moby
RUN install-tool docker v27.3.1

Expand Down
5 changes: 4 additions & 1 deletion test/latest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ RUN prepare-tool all
RUN set -ex; [ -d /usr/local/erlang ] && echo "works" || exit 1;

#--------------------------------------
# test: bazelisk, bun, vendir, helmfile, kustomize, skopeo
# test: bazelisk, bun, devbox, vendir, helmfile, kustomize, skopeo
#--------------------------------------
FROM base AS teste

Expand All @@ -215,6 +215,9 @@ RUN install-tool bazelisk v1.24.1
# renovate: datasource=npm
RUN install-tool bun 1.1.38

# renovate: datasource=github-releases packageName=jetify-com/devbox
RUN install-tool devbox 0.13.4

# renovate: datasource=github-releases packageName=gleam-lang/gleam
RUN install-tool gleam 1.6.3

Expand Down
9 changes: 9 additions & 0 deletions test/latest/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ FROM base AS test-bun
# renovate: datasource=npm
RUN install-tool bun 1.1.38

#--------------------------------------
# Image: devbox
#--------------------------------------
FROM base AS test-devbox

# renovate: datasource=github-releases packageName=jetify-com/devbox
RUN install-tool devbox 0.13.4

#--------------------------------------
# Image: gleam
#--------------------------------------
Expand Down Expand Up @@ -133,6 +141,7 @@ FROM base

COPY --from=test-bazelisk /.dummy /.dummy
COPY --from=test-bun /.dummy /.dummy
COPY --from=test-devbox /.dummy /.dummy
COPY --from=test-docker /.dummy /.dummy
COPY --from=test-git /.dummy /.dummy
COPY --from=test-git-lfs /.dummy /.dummy
Expand Down

0 comments on commit c2ef8e6

Please sign in to comment.