Skip to content

Commit 3753ca1

Browse files
committed
Fix linter mem issue
1 parent 3db4f3f commit 3753ca1

File tree

9 files changed

+53
-29
lines changed

9 files changed

+53
-29
lines changed

package-lock.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/adapter-docker/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export { DockerSequenceAdapter as SequenceAdapter } from "./docker-sequence-adap
77
export { DockerInstanceAdapter as InstanceAdapter } from "./docker-instance-adapter";
88

99
export const init = async (..._args: any[]) => {
10-
return await DockerodeDockerHelper.isDockerConfigured() ? {} : { error: "Docker initialization failed"};
10+
return await DockerodeDockerHelper.isDockerConfigured() ? {} : { error: "Docker initialization failed" };
1111
};
1212

1313
export const name = "docker";

packages/adapter-process/src/process-instance-adapter.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { STHConfiguration,
22
ExitCode,
3-
IComponent,
4-
ILifeCycleAdapterMain,
5-
ILifeCycleAdapterRun,
63
InstanceConfig,
74
InstanceLimits,
85
IObjectLogger,
96
MonitoringMessageData,
10-
SequenceConfig
7+
SequenceConfig,
8+
IInstanceAdapter
119
} from "@scramjet/types";
1210
import { ObjLogger } from "@scramjet/obj-logger";
1311
import { streamToString } from "@scramjet/utility";
@@ -22,10 +20,7 @@ const gotPython = "\n _ \n __ _____ _ __ ___
2220
/**
2321
* Adapter for running Instance by Runner executed in separate process.
2422
*/
25-
class ProcessInstanceAdapter implements
26-
ILifeCycleAdapterMain,
27-
ILifeCycleAdapterRun,
28-
IComponent {
23+
class ProcessInstanceAdapter implements IInstanceAdapter {
2924
logger: IObjectLogger;
3025
sthConfig: STHConfiguration;
3126

packages/adapter-process/src/process-sequence-adapter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
22
ProcessSequenceConfig,
33
ISequenceAdapter,
4-
STHConfiguration,
54
SequenceConfig,
65
IObjectLogger,
6+
ProcessAdapterConfiguration,
77
} from "@scramjet/types";
88
import { ObjLogger } from "@scramjet/obj-logger";
99
import { isDefined, readStreamedJSON } from "@scramjet/utility";
@@ -56,11 +56,11 @@ class ProcessSequenceAdapter implements ISequenceAdapter {
5656
logger: IObjectLogger;
5757

5858
name = "ProcessSequenceAdapter";
59-
config: NonNullable<STHConfiguration["adapters"]["@scramjet/adapter-process"]>;
59+
config: ProcessAdapterConfiguration;
6060

61-
constructor(config: STHConfiguration) {
61+
constructor(config: ProcessAdapterConfiguration) {
6262
this.logger = new ObjLogger(this);
63-
this.config = config.adapters["@scramjet/adapter-process"]!;
63+
this.config = config;
6464
}
6565

6666
/**

packages/host/src/lib/adapter-manager.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class AdapterManager {
1212
}
1313

1414
/**
15-
* Initializes configured adapters.
15+
* Initializes all configured adapters.
1616
*
1717
* @returns True if any adapter is available. False otherwise.
1818
*/
@@ -37,6 +37,7 @@ export class AdapterManager {
3737
}
3838

3939
if (this.adapters[adapter.pkgName]) throw new Error("Invalid adapters configuration, duplicated adapter name");
40+
4041
this.adapters[adapter.pkgName] = adapter;
4142
}
4243
)
@@ -48,23 +49,41 @@ export class AdapterManager {
4849
this.logger.info(`${adaptersCount} Adapters available:`, this.adapters);
4950

5051
return true;
51-
} else {
52-
this.logger.warn("No adapters defined. Sequences and Instances unsupported.");
53-
54-
return false;
5552
}
53+
54+
this.logger.warn("No adapters defined. Sequences and Instances unsupported.");
55+
56+
return false;
5657
}
5758

59+
/**
60+
* Validates adapter.
61+
*
62+
* @param {IRuntimeAdapter} adapter Checks if adapter provides required fields.
63+
* @returns {boolean} True if required fields are available.
64+
*/
5865
static validateAdapter(adapter: IRuntimeAdapter): boolean {
5966
return !!(adapter.name.trim() && ["SequenceAdapter", "InstanceAdapter", "init"].every((className: string) => className in adapter));
6067
}
6168

69+
/**
70+
* Initializes adapter with adapter config.
71+
*
72+
* @param {IRuntimeAdapter} adapter Adapter to initialize
73+
* @returns Object with error field if initialization failed, "ready" otherwise.
74+
*/
6275
async initAdapter(adapter: IRuntimeAdapter): Promise<{ error?: string } | "ready"> {
6376
const initResult = await adapter.init(adapter.config);
6477

6578
return initResult.error ? initResult : Promise.resolve("ready");
6679
}
6780

81+
/**
82+
* Returns Adapter by given package name.
83+
*
84+
* @param {string} pkgName Adapter package name.
85+
* @returns {IRuntimeAdapter} Adapter
86+
*/
6887
getAdapterByName(pkgName: string): IRuntimeAdapter | undefined {
6988
return Object.values(this.adapters).find(a => a.pkgName === pkgName);
7089
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { ILifeCycleAdapterMain, ILifeCycleAdapterRun } from "./lifecycle-adapters";
22
import { IComponent } from "./component";
33

4-
export interface IInstanceAdapter extends ILifeCycleAdapterMain, ILifeCycleAdapterRun, IComponent {}
4+
export interface IInstanceAdapter extends ILifeCycleAdapterMain, ILifeCycleAdapterRun, IComponent {
5+
}
6+
7+
export interface IInstanceAdapterContructor {
8+
new (config: any): IInstanceAdapter
9+
}

packages/types/src/runtime-adapter.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { IComponent } from "./component";
2-
import { IInstanceAdapter } from "./instance-adapter";
3-
import { ILifeCycleAdapterMain, ILifeCycleAdapterRun } from "./lifecycle-adapters";
4-
import { ISequenceAdapter } from "./sequence-adapter";
5-
import { STHConfiguration } from "./sth-configuration";
1+
import { IInstanceAdapterContructor } from "./instance-adapter";
2+
import { ISequenceAdapterContructor } from "./sequence-adapter";
63

74
export interface IRuntimeAdapter {
8-
SequenceAdapter: ISequenceAdapter & { new (config: STHConfiguration): ISequenceAdapter };
9-
InstanceAdapter: ILifeCycleAdapterMain & ILifeCycleAdapterRun & IComponent & { new (config: STHConfiguration): IInstanceAdapter };
5+
SequenceAdapter: ISequenceAdapterContructor;
6+
InstanceAdapter: IInstanceAdapterContructor;
107
name: string;
118
pkgName: string;
129
init(config: any): Promise<{ error?: string }>;

packages/types/src/sequence-adapter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ export interface ISequenceAdapter {
3232

3333
logger: IObjectLogger;
3434
}
35+
36+
export interface ISequenceAdapterContructor {
37+
new (config: any): ISequenceAdapter;
38+
}

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5047,9 +5047,9 @@ minimatch@^5.0.1, minimatch@^5.1.0, minimatch@^5.1.2:
50475047
brace-expansion "^2.0.1"
50485048

50495049
minimatch@^9.0.1:
5050-
version "9.0.2"
5051-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.2.tgz#397e387fff22f6795844d00badc903a3d5de7057"
5052-
integrity sha512-PZOT9g5v2ojiTL7r1xF6plNHLtOeTpSlDI007As2NlA2aYBMfVom17yqa6QzhmDP8QOhn7LjHTg7DFCVSSa6yg==
5050+
version "9.0.3"
5051+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825"
5052+
integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==
50535053
dependencies:
50545054
brace-expansion "^2.0.1"
50555055

0 commit comments

Comments
 (0)