Repository navigation
Expand file tree
/
Copy pathsops.ts
More file actions
52 lines (43 loc) · 1.69 KB
/
Copy pathsops.ts
File metadata and controls
52 lines (43 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import fs from 'node:fs/promises';
import { join } from 'node:path';
import { injectFromHierarchy, injectable } from 'inversify';
import { BaseInstallService } from '../install-tool/base-install.service.ts';
@injectable()
@injectFromHierarchy()
export class SopsInstallService extends BaseInstallService {
readonly name = 'sops';
/** The `checksums.txt` file exists from 3.8.0. */
override readonly minVersion = '3.8.0';
/**
* Downloads the sops binary from GitHub into the versioned `bin` folder. The
* file and its checksum come from the tool-versions data, without data it
* is verified against the release's checksums file.
*/
override async install(version: string): Promise<void> {
const baseUrl = `https://github.com/getsops/${this.name}/releases/download/v${version}/`;
const filename = `${this.name}-v${version}.linux.${this.envSvc.arch}`;
const file = await this.downloadChecksumListed(
version,
baseUrl,
filename,
`${this.name}-v${version}.checksums.txt`,
);
await this.pathSvc.ensureToolPath(this.name);
const path = await this.pathSvc.createVersionedToolPath(
this.name,
version,
'bin',
);
await fs.copyFile(file, join(path, this.name));
await fs.chmod(join(path, this.name), this.envSvc.umask);
}
/** Links the `sops` binary into the global bin folder. */
override async link(version: string): Promise<void> {
const src = join(this.pathSvc.versionedToolPath(this.name, version), 'bin');
await this.shellwrapper({ srcDir: src });
}
/** Checks that `sops --version` runs. */
override async test(_version: string): Promise<void> {
await this._spawn(this.name, ['--version']);
}
}