Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/cli/install-tool/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
RubyBaseInstallService,
RubyGemVersionResolver,
} from '../tools/ruby/utils';
import { logger } from '../utils';
import { isDockerBuild, logger } from '../utils';
import { MissingParent } from '../utils/codes';
import { installTool, linkTool, resolveVersion } from '.';
import { ensurePaths, rootPath } from '~test/path';
Expand All @@ -18,6 +18,10 @@ vi.mock('del');
vi.mock('nano-spawn');
vi.mock('../tools/bun');
vi.mock('../tools/php/composer');
vi.mock('../utils', async (importActual) => ({
...(await importActual<typeof import('../utils')>()),
isDockerBuild: vi.fn(),
}));

describe('cli/install-tool/index', () => {
beforeAll(async () => {
Expand Down Expand Up @@ -53,6 +57,7 @@ describe('cli/install-tool/index', () => {

describe('installTool', () => {
test('fails if parent is missing', async () => {
vi.mocked(isDockerBuild).mockResolvedValueOnce(true);
expect(await installTool('gradle', '1.0.0')).toBe(MissingParent);
expect(logger.fatal).toHaveBeenCalledExactlyOnceWith(
{ tool: 'gradle', parent: 'java' },
Expand Down
34 changes: 33 additions & 1 deletion src/cli/install-tool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import { DenoInstallService } from '../tools/deno';
import { DevboxInstallService } from '../tools/devbox';
import { DockerInstallService } from '../tools/docker';
import { DotnetInstallService } from '../tools/dotnet';
import { ErlangInstallService } from '../tools/erlang';
import { ElixirInstallService } from '../tools/erlang/elixir';
import { FlutterInstallService } from '../tools/flutter';
import { FluxInstallService } from '../tools/flux';
import { GitLfsInstallService } from '../tools/git/lfs';
import { GleamInstallService } from '../tools/gleam';
import { GolangInstallService } from '../tools/golang';
import { HelmInstallService } from '../tools/helm';
import { HelmfileInstallService } from '../tools/helmfile';
import {
Expand All @@ -28,8 +32,12 @@ import {
JavaJreVersionResolver,
JavaVersionResolver,
} from '../tools/java/resolver';
import { SbtInstallService } from '../tools/java/sbt';
import { ScalaInstallService } from '../tools/java/scala';
import { JsonnetBundlerInstallService } from '../tools/jb';
import { KubectlInstallService } from '../tools/kubectl';
import { KustomizeInstallService } from '../tools/kustomize';
import { NixInstallService } from '../tools/nix';
import { NodeInstallService } from '../tools/node';
import {
RenovateInstallService,
Expand All @@ -48,14 +56,17 @@ import {
ComposerVersionResolver,
} from '../tools/php/composer';
import { PixiInstallService } from '../tools/pixi';
import { PowershellInstallService } from '../tools/powershell';
import { ProtocInstallService } from '../tools/protoc';
import { PythonInstallService } from '../tools/python';
import {
ConanInstallService,
ConanVersionResolver,
} from '../tools/python/conan';
import { PipVersionResolver } from '../tools/python/pip';
import { PoetryVersionResolver } from '../tools/python/poetry';
import { PipBaseInstallService } from '../tools/python/utils';
import { RubyInstallService } from '../tools/ruby';
import {
CocoapodsInstallService,
CocoapodsVersionResolver,
Expand All @@ -64,10 +75,15 @@ import {
RubyBaseInstallService,
RubyGemVersionResolver,
} from '../tools/ruby/utils';
import { RustInstallService } from '../tools/rust';
import { SkopeoInstallService } from '../tools/skopeo';
import { SopsInstallService } from '../tools/sops';
import { SwiftInstallService } from '../tools/swift';
import { TerraformInstallService } from '../tools/terraform';
import { VendirInstallService } from '../tools/vendir';
import { WallyInstallService } from '../tools/wally';
import { logger } from '../utils';
import { isNotKnownV2Tool } from '../utils/v2-tool';
import {
V1ToolInstallService,
V2ToolInstallService,
Expand Down Expand Up @@ -99,32 +115,48 @@ async function prepareInstallContainer(): Promise<Container> {
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(ElixirInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(ErlangInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(FlutterInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(FluxInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(GitLfsInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(GleamInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(GolangInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(GradleInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(HelmInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(HelmfileInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(JavaInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(JavaJreInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(JavaJdkInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(JsonnetBundlerInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(KubectlInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(KustomizeInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(MavenInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(NixInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(NodeInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(PhpInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(PixiInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(PowershellInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(ProtocInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(PythonInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(RenovateInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(RubyInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(RustInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(SbtInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(ScalaInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(SkopeoInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(SopsInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(SwiftInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(TerraformInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(VendirInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(WallyInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(YarnInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(YarnSlimInstallService);

// v2 tool services
const pathSvc = await container.getAsync(PathService);
for (const tool of await pathSvc.findLegacyTools()) {
const legacyTools = await pathSvc.findLegacyTools();
for (const tool of legacyTools.filter(isNotKnownV2Tool)) {
@injectable()
@injectFromHierarchy()
class GenericInstallService extends V2ToolInstallService {
Expand Down
22 changes: 21 additions & 1 deletion src/cli/prepare-tool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@ import { PathService, createContainer } from '../services';
import { DartPrepareService } from '../tools/dart';
import { DockerPrepareService } from '../tools/docker';
import { DotnetPrepareService } from '../tools/dotnet';
import { ErlangPrepareService } from '../tools/erlang';
import { ElixirPrepareService } from '../tools/erlang/elixir';
import { FlutterPrepareService } from '../tools/flutter';
import { GolangPrepareService } from '../tools/golang';
import {
JavaJdkPrepareService,
JavaJrePrepareService,
JavaPrepareService,
} from '../tools/java';
import { SbtPrepareService } from '../tools/java/sbt';
import { NodePrepareService } from '../tools/node';
import { PhpPrepareService } from '../tools/php';
import { PowershellPrepareService } from '../tools/powershell';
import { PythonPrepareService } from '../tools/python';
import { ConanPrepareService } from '../tools/python/conan';
import { RubyPrepareService } from '../tools/ruby';
import { RustPrepareService } from '../tools/rust';
import { SwiftPrepareService } from '../tools/swift';
import { logger } from '../utils';
import { isNotKnownV2Tool } from '../utils/v2-tool';
import { V2ToolPrepareService } from './prepare-legacy-tools.service';
import { PREPARE_TOOL_TOKEN, PrepareToolService } from './prepare-tool.service';

Expand All @@ -25,7 +35,8 @@ async function prepareContainer(): Promise<Container> {

// v2 tool services
const pathSvc = await container.getAsync(PathService);
for (const tool of await pathSvc.findLegacyTools()) {
const v2Tools = await pathSvc.findLegacyTools();
for (const tool of v2Tools.filter(isNotKnownV2Tool)) {
@injectable()
@injectFromHierarchy()
class GenericV2ToolPrepareService extends V2ToolPrepareService {
Expand All @@ -39,12 +50,21 @@ async function prepareContainer(): Promise<Container> {
container.bind(PREPARE_TOOL_TOKEN).to(DartPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(DotnetPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(DockerPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(ElixirPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(ErlangPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(FlutterPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(GolangPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(JavaPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(JavaJrePrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(JavaJdkPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(NodePrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(PhpPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(PowershellPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(PythonPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(RubyPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(RustPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(SbtPrepareService);
container.bind(PREPARE_TOOL_TOKEN).to(SwiftPrepareService);

logger.trace('preparing container done');
return container;
Expand Down
4 changes: 3 additions & 1 deletion src/cli/services/v2-tool.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
postConstruct,
} from 'inversify';
import { logger } from '../utils';
import { isNotKnownV2Tool } from '../utils/v2-tool';
import { PathService } from './path.service';

@injectable(bindingScopeValues.Singleton)
Expand All @@ -19,7 +20,8 @@ export class V2ToolService {

@postConstruct()
protected async [Symbol('_construct')](): Promise<void> {
for (const tool of await this.pathSvc.findLegacyTools()) {
const tools = await this.pathSvc.findLegacyTools();
for (const tool of tools.filter(isNotKnownV2Tool)) {
const content = await readFile(
join(this.pathSvc.usrPath, 'tools/v2', `${tool}.sh`),
{ encoding: 'utf8' },
Expand Down
33 changes: 33 additions & 0 deletions src/cli/tools/erlang/elixir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { injectFromHierarchy, injectable } from 'inversify';
import { V2ToolInstallService } from '../../install-tool/install-legacy-tool.service';
import { V2ToolPrepareService } from '../../prepare-tool/prepare-legacy-tools.service';
import { v2Tool } from '../../utils/v2-tool';

@injectable()
@injectFromHierarchy()
@v2Tool('elixir')
export class ElixirPrepareService extends V2ToolPrepareService {
override readonly name = 'elixir';

override needsPrepare(): boolean {
return true;
}
override needsInitialize(): boolean {
return true;
}
}

@injectable()
@injectFromHierarchy()
@v2Tool('elixir')
export class ElixirInstallService extends V2ToolInstallService {
override readonly name = 'elixir';
override readonly parent = 'erlang';

override needsPrepare(): boolean {
return true;
}
override needsInitialize(): boolean {
return true;
}
}
32 changes: 32 additions & 0 deletions src/cli/tools/erlang/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { injectFromHierarchy, injectable } from 'inversify';
import { V2ToolInstallService } from '../../install-tool/install-legacy-tool.service';
import { V2ToolPrepareService } from '../../prepare-tool/prepare-legacy-tools.service';
import { v2Tool } from '../../utils/v2-tool';

@injectable()
@injectFromHierarchy()
@v2Tool('elixir')
export class ErlangPrepareService extends V2ToolPrepareService {
override readonly name = 'erlang';

override needsPrepare(): boolean {
return true;
}
override needsInitialize(): boolean {
return false;
}
}

@injectable()
@injectFromHierarchy()
@v2Tool('erlang')
export class ErlangInstallService extends V2ToolInstallService {
override readonly name = 'erlang';

override needsPrepare(): boolean {
return true;
}
override needsInitialize(): boolean {
return false;
}
}
18 changes: 18 additions & 0 deletions src/cli/tools/git/lfs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { injectFromHierarchy, injectable } from 'inversify';
import { V2ToolInstallService } from '../../install-tool/install-legacy-tool.service';
import { v2Tool } from '../../utils/v2-tool';

@injectable()
@injectFromHierarchy()
@v2Tool('git-lfs')
export class GitLfsInstallService extends V2ToolInstallService {
override readonly name = 'git-lfs';
override readonly parent = 'git';

override needsPrepare(): boolean {
return false;
}
override needsInitialize(): boolean {
return false;
}
}
32 changes: 32 additions & 0 deletions src/cli/tools/golang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { injectFromHierarchy, injectable } from 'inversify';
import { V2ToolInstallService } from '../install-tool/install-legacy-tool.service';
import { V2ToolPrepareService } from '../prepare-tool/prepare-legacy-tools.service';
import { v2Tool } from '../utils/v2-tool';

@injectable()
@injectFromHierarchy()
@v2Tool('golang')
export class GolangPrepareService extends V2ToolPrepareService {
override readonly name = 'golang';

override needsPrepare(): boolean {
return true;
}
override needsInitialize(): boolean {
return true;
}
}

@injectable()
@injectFromHierarchy()
@v2Tool('golang')
export class GolangInstallService extends V2ToolInstallService {
override readonly name = 'golang';

override needsPrepare(): boolean {
return true;
}
override needsInitialize(): boolean {
return true;
}
}
13 changes: 12 additions & 1 deletion src/cli/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ export const NoPrepareTools = [
'deno',
'devbox',
'flux',
'git-lfs',
'gleam',
'gradle',
'hashin',
'helm',
'helmfile',
'jb',
'kubectl',
'kustomize',
'lerna',
'maven',
'nix',
'npm',
'pdm',
'pip-tools',
Expand All @@ -31,15 +34,23 @@ export const NoPrepareTools = [
'poetry',
'protoc',
'renovate',
'scala',
'skopeo',
'sops',
'terraform',
'uv',
'vendir',
'wally',
'yarn',
'yarn-slim',
];

export const NoInitTools = [...NoPrepareTools];
export const NoInitTools = [
...NoPrepareTools,
'erlang',
'powershell',
'python',
];

/**
* Tools in this map are implicit mapped from `install-tool` to `install-<type>`.
Expand Down
Loading
Loading