Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions src/cli/install-tool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
createContainer,
} from '../services/index.ts';
import { ApkoInstallService } from '../tools/apko.ts';
import { ApmInstallService } from '../tools/apm.ts';
import { BazeliskInstallService } from '../tools/bazelisk.ts';
import { BufInstallService } from '../tools/buf.ts';
import { BunInstallService } from '../tools/bun.ts';
Expand Down Expand Up @@ -134,6 +135,7 @@ async function prepareInstallContainer(): Promise<Container> {
// modern tool services
container.bind(INSTALL_TOOL_TOKEN).to(AndroidSdkCmdlineToolsInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(ApkoInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(ApmInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(ComposerInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(BazeliskInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(BuildxInstallService);
Expand Down
59 changes: 59 additions & 0 deletions src/cli/tools/apm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import fs from 'node:fs/promises';
import { injectFromHierarchy, injectable } from 'inversify';
import { BaseInstallService } from '../install-tool/base-install.service.ts';

@injectable()
@injectFromHierarchy()
export class ApmInstallService extends BaseInstallService {
readonly name = 'apm';

private get ghArch(): string {
switch (this.envSvc.arch) {
case 'arm64':
return 'arm64';
case 'amd64':
return 'x86_64';
}
}

override async install(version: string): Promise<void> {
/**
* APM (Agent Package Manager) ships self-contained PyInstaller `onedir`
* bundles (an `apm` binary next to an `_internal` directory) as
* `apm-<os>-<arch>.tar.gz` release assets, each accompanied by a
* `.sha256` sidecar.
* @see {@link https://github.com/microsoft/apm/releases}
*/
const baseUrl = `https://github.com/microsoft/apm/releases/download/v${version}/`;
const filename = `apm-linux-${this.ghArch}.tar.gz`;
const url = `${baseUrl}${filename}`;

const checksumFile = await this.http.download({ url: `${url}.sha256` });
const expectedChecksum = (await fs.readFile(checksumFile, 'utf-8'))
.split('\n')
.find((l) => l.includes(filename))
?.split(/\s+/)[0];

const file = await this.http.download({
url,
checksumType: 'sha256',
expectedChecksum,
});

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

const path = await this.pathSvc.createVersionedToolPath(this.name, version);
// strip the top-level `apm-linux-<arch>` directory so the `apm` binary and
// its sibling `_internal` bundle end up directly in the versioned path.
await this.compress.extract({ file, cwd: path, strip: 1 });
}

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

override async test(_version: string): Promise<void> {
await this._spawn(this.name, ['--version']);
}
}
1 change: 1 addition & 0 deletions src/cli/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { InstallToolType } from '../utils';
export const NoPrepareTools = [
'android-sdk-cmdline-tools',
'apko',
'apm',
'bazelisk',
'bower',
'buf',
Expand Down
5 changes: 4 additions & 1 deletion test/latest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ RUN prepare-tool all
RUN set -ex; [ -d /usr/local/erlang ] && echo "works" || exit 1;

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

Expand All @@ -231,6 +231,9 @@ RUN install-tool deno 2.9.1
# renovate: datasource=github-releases packageName=chainguard-dev/apko
RUN install-tool apko 1.2.22

# renovate: datasource=github-releases packageName=microsoft/apm
RUN install-tool apm 0.24.0

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

Expand Down