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

feat: add devbox as an install tool #3191

Merged
merged 11 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
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
2 changes: 2 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"bundler",
"conan",
"corepack",
"devbox",
"docker",
"dotnet",
"git",
Expand Down Expand Up @@ -95,6 +96,7 @@
"bundler",
"corepack",
"conan",
"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,
burritobill marked this conversation as resolved.
Show resolved Hide resolved
});
}

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 @@ -113,6 +113,9 @@ RUN install-tool jb v0.6.0
# renovate: datasource=github-releases packageName=vmware-tanzu/carvel-vendir
RUN install-tool vendir v0.42.0

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

viceice marked this conversation as resolved.
Show resolved Hide resolved
#--------------------------------------
# Image: test-erlang
#--------------------------------------
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.22.0
# renovate: datasource=npm
RUN install-tool bun 1.1.29

# 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.5.1

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.29

#--------------------------------------
# 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