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

refactor: move constructor injections #2133

Merged
merged 1 commit into from
Feb 5, 2024
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
8 changes: 7 additions & 1 deletion src/cli/prepare-tool/prepare-tool-base.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { injectable } from 'inversify';
import { inject, injectable } from 'inversify';
import { EnvService, PathService } from '../services';

Check warning on line 2 in src/cli/prepare-tool/prepare-tool-base.service.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/prepare-tool/prepare-tool-base.service.ts#L1-L2

Added lines #L1 - L2 were not covered by tests

@injectable()
export abstract class PrepareToolBaseService {
abstract readonly name: string;

constructor(
@inject(PathService) protected readonly pathSvc: PathService,
@inject(EnvService) protected readonly envSvc: EnvService,
) {}

Check warning on line 12 in src/cli/prepare-tool/prepare-tool-base.service.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/prepare-tool/prepare-tool-base.service.ts#L8-L12

Added lines #L8 - L12 were not covered by tests
abstract execute(): Promise<void> | void;

toString(): string {
Expand Down
4 changes: 0 additions & 4 deletions src/cli/tools/dart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import {
export class PrepareDartService extends PrepareToolBaseService {
readonly name = 'dart';

constructor(@inject(EnvService) private envSvc: EnvService) {
super();
}

async execute(): Promise<void> {
await fs.mkdir(`${this.envSvc.home}/.dart`);
await fs.writeFile(
Expand Down
4 changes: 0 additions & 4 deletions src/cli/tools/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import {
export class PrepareDockerService extends PrepareToolBaseService {
readonly name = 'docker';

constructor(@inject(EnvService) private envSvc: EnvService) {
super();
}

async execute(): Promise<void> {
await execa('groupadd', ['-g', '999', 'docker']);
await execa('usermod', ['-aG', 'docker', this.envSvc.userName]);
Expand Down
6 changes: 3 additions & 3 deletions src/cli/tools/dotnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
readonly name = 'dotnet';

constructor(
@inject(EnvService) private readonly envSvc: EnvService,
@inject(EnvService) envSvc: EnvService,

Check warning on line 21 in src/cli/tools/dotnet/index.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/dotnet/index.ts#L21

Added line #L21 was not covered by tests
@inject(AptService) private readonly aptSvc: AptService,
@inject(PathService) private readonly pathSvc: PathService,
@inject(PathService) pathSvc: PathService,

Check warning on line 23 in src/cli/tools/dotnet/index.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/dotnet/index.ts#L23

Added line #L23 was not covered by tests
) {
super();
super(pathSvc, envSvc);

Check warning on line 25 in src/cli/tools/dotnet/index.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/dotnet/index.ts#L25

Added line #L25 was not covered by tests
}

async execute(): Promise<void> {
Expand Down
4 changes: 0 additions & 4 deletions src/cli/tools/flutter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import { logger } from '../utils';
export class PrepareFlutterService extends PrepareToolBaseService {
readonly name = 'flutter';

constructor(@inject(EnvService) private readonly envSvc: EnvService) {
super();
}

override async execute(): Promise<void> {
const flutter = join(this.envSvc.userHome, '.flutter');
await fs.writeFile(flutter, '{ "firstRun": false, "enabled": false }');
Expand Down
Loading