-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add devbox as an install tool (#3191)
* 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
1 parent
8dc62a6
commit c2ef8e6
Showing
8 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters