@gapi/cli-builder 1.8.168 → 1.8.170

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/coverage/block-navigation.js +9 -1
  2. package/coverage/favicon.png +0 -0
  3. package/coverage/index.html +27 -22
  4. package/coverage/lcov-report/block-navigation.js +9 -1
  5. package/coverage/lcov-report/favicon.png +0 -0
  6. package/coverage/lcov-report/index.html +27 -22
  7. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  8. package/coverage/lcov-report/sorter.js +40 -0
  9. package/coverage/lcov-report/src/app.constants.ts.html +12 -7
  10. package/coverage/lcov-report/src/core/services/index.html +22 -17
  11. package/coverage/lcov-report/src/core/services/systemctl.ts.html +69 -37
  12. package/coverage/lcov-report/src/index.html +16 -11
  13. package/coverage/lcov.info +53 -36
  14. package/coverage/sort-arrow-sprite.png +0 -0
  15. package/coverage/sorter.js +40 -0
  16. package/coverage/src/app.constants.ts.html +12 -7
  17. package/coverage/src/core/services/index.html +22 -17
  18. package/coverage/src/core/services/systemctl.ts.html +69 -37
  19. package/coverage/src/index.html +16 -11
  20. package/dist/app.constants.d.ts +1 -1
  21. package/dist/app.constants.js +17 -15
  22. package/dist/app.controller.d.ts +0 -1
  23. package/dist/app.controller.js +7 -7
  24. package/dist/app.frame.js +3 -3
  25. package/dist/app.tokents.d.ts +2 -2
  26. package/dist/app.tokents.js +5 -5
  27. package/dist/app.types.d.ts +1 -3
  28. package/dist/cli-builder.js +5 -5
  29. package/dist/core/core.moduile.js +3 -3
  30. package/dist/core/executors/commands.d.ts +4 -4
  31. package/dist/core/executors/commands.js +4 -2
  32. package/dist/core/executors/helpers/execute.js +3 -2
  33. package/dist/core/executors/helpers/index.js +6 -2
  34. package/dist/core/executors/index.js +6 -2
  35. package/dist/core/services/get-ip-adresses.js +5 -3
  36. package/dist/core/services/subscription.service.d.ts +1 -1
  37. package/dist/core/services/subscription.service.js +12 -12
  38. package/dist/core/services/systemctl.js +32 -22
  39. package/dist/index.d.ts +3 -3
  40. package/dist/index.js +9 -4
  41. package/dist/scalar-object.d.ts +2 -2
  42. package/dist/scalar-object.js +0 -1
  43. package/eslint.config.mjs +38 -0
  44. package/package.json +5 -5
  45. package/src/app.constants.ts +1 -1
  46. package/src/app.controller.ts +4 -4
  47. package/src/app.frame.ts +5 -3
  48. package/src/app.tokents.ts +5 -3
  49. package/src/cli-builder.ts +8 -7
  50. package/src/core/executors/commands.ts +5 -5
  51. package/src/core/executors/helpers/execute.ts +1 -1
  52. package/src/core/services/get-ip-adresses.ts +1 -1
  53. package/src/core/services/subscription.service.ts +44 -34
  54. package/src/core/services/systemctl.spec.ts +4 -4
  55. package/src/core/services/systemctl.ts +26 -17
  56. package/src/index.ts +3 -4
  57. package/src/main.ts +6 -6
  58. package/src/scalar-object.ts +3 -4
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNetworkIP = exports.getIpAdresses = void 0;
4
4
  const net_1 = require("net");
5
- exports.getIpAdresses = (network) => Object.values(network).reduce((acc, interfaces) => {
5
+ const getIpAdresses = (network) => Object.values(network).reduce((acc, interfaces) => {
6
6
  let alias = 0;
7
7
  interfaces.forEach((iface) => {
8
8
  if ('IPv4' !== iface.family ||
@@ -22,8 +22,9 @@ exports.getIpAdresses = (network) => Object.values(network).reduce((acc, interfa
22
22
  });
23
23
  return acc;
24
24
  }, []);
25
- exports.getNetworkIP = () => new Promise((resolve, reject) => {
26
- const socket = net_1.createConnection(80, 'www.google.com');
25
+ exports.getIpAdresses = getIpAdresses;
26
+ const getNetworkIP = () => new Promise((resolve, reject) => {
27
+ const socket = (0, net_1.createConnection)(80, 'www.google.com');
27
28
  socket.on('connect', function () {
28
29
  let addressInfo = socket.address();
29
30
  if (typeof addressInfo === 'string') {
@@ -36,3 +37,4 @@ exports.getNetworkIP = () => new Promise((resolve, reject) => {
36
37
  reject(e);
37
38
  });
38
39
  });
40
+ exports.getNetworkIP = getNetworkIP;
@@ -22,6 +22,6 @@ export declare class SubscriptionService {
22
22
  unsubscribe(): void;
23
23
  closePubsub(): void;
24
24
  sendStatus(variables: MachineStatus): Promise<void>;
25
- sendMachineStatus(variables: MachineStatus): Promise<import("apollo-link").FetchResult<any, Record<string, any>, Record<string, any>>>;
25
+ sendMachineStatus(variables: MachineStatus): Promise<import("apollo-link").FetchResult<any>>;
26
26
  }
27
27
  export {};
@@ -22,7 +22,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.SubscriptionService = void 0;
25
- /* eslint-disable @typescript-eslint/no-var-requires */
26
25
  const core_1 = require("@gapi/core");
27
26
  const apollo_cache_inmemory_1 = require("apollo-cache-inmemory");
28
27
  const apollo_client_1 = require("apollo-client");
@@ -32,6 +31,7 @@ const app_constants_1 = require("../../app.constants");
32
31
  const app_tokents_1 = require("../../app.tokents");
33
32
  const commands_1 = require("../executors/commands");
34
33
  const get_ip_adresses_1 = require("./get-ip-adresses");
34
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
35
35
  const webSocketImpl = require('ws');
36
36
  let SubscriptionService = class SubscriptionService {
37
37
  constructor(subscriptionsQuery, machineStatusQuery) {
@@ -53,23 +53,23 @@ let SubscriptionService = class SubscriptionService {
53
53
  worker_type,
54
54
  label,
55
55
  ip: app_constants_1.Environment.GRAPHQL_RUNNER_NAT_IP ||
56
- (yield get_ip_adresses_1.getNetworkIP()),
57
- networkInterfaces: JSON.stringify(os_1.networkInterfaces()),
56
+ (yield (0, get_ip_adresses_1.getNetworkIP)()),
57
+ networkInterfaces: JSON.stringify((0, os_1.networkInterfaces)()),
58
58
  },
59
59
  reconnect: true,
60
60
  },
61
61
  webSocketImpl,
62
62
  });
63
- this.subscription = core_1.subscribeToTopic(this.subscriptionsQuery.query, this.subscriptionsQuery.variables, this.link)
64
- .pipe(operators_1.map(({ data }) => this.subscriptionsQuery.map(data)))
65
- .subscribe(({ args, command, cwd }) => __awaiter(this, void 0, void 0, function* () {
63
+ this.subscription = (0, core_1.subscribeToTopic)(this.subscriptionsQuery.query, this.subscriptionsQuery.variables, this.link)
64
+ .pipe((0, operators_1.map)(({ data }) => this.subscriptionsQuery.map(data)))
65
+ .subscribe((_a) => __awaiter(this, [_a], void 0, function* ({ args, command, cwd, }) {
66
66
  const cmd = core_1.Container.get(app_tokents_1.EnumToken)[command];
67
67
  if (!cmd) {
68
68
  console.log('Missing command');
69
69
  throw new Error('Missing command');
70
70
  }
71
71
  try {
72
- const data = yield commands_1.executeAction(command)(JSON.parse(args), cwd);
72
+ const data = yield (0, commands_1.executeAction)(command)(JSON.parse(args), cwd);
73
73
  yield this.sendStatus({
74
74
  label,
75
75
  machineHash: app_tokents_1.machineHash,
@@ -119,12 +119,12 @@ let SubscriptionService = class SubscriptionService {
119
119
  });
120
120
  }
121
121
  };
122
- SubscriptionService = __decorate([
123
- core_1.Injectable({
122
+ exports.SubscriptionService = SubscriptionService;
123
+ exports.SubscriptionService = SubscriptionService = __decorate([
124
+ (0, core_1.Injectable)({
124
125
  init: true,
125
126
  }),
126
- __param(0, core_1.Inject(app_tokents_1.SubscriptionQuery)),
127
- __param(1, core_1.Inject(app_tokents_1.MachineStatusQuery)),
127
+ __param(0, (0, core_1.Inject)(app_tokents_1.SubscriptionQuery)),
128
+ __param(1, (0, core_1.Inject)(app_tokents_1.MachineStatusQuery)),
128
129
  __metadata("design:paramtypes", [Object, Object])
129
130
  ], SubscriptionService);
130
- exports.SubscriptionService = SubscriptionService;
@@ -31,28 +31,38 @@ let SystemctlService = class SystemctlService {
31
31
  try {
32
32
  yield this.install(service_description, service, executableBinary);
33
33
  }
34
- catch (e) { }
34
+ catch (e) {
35
+ console.error(e);
36
+ }
35
37
  try {
36
38
  yield this.reload();
37
39
  }
38
- catch (e) { }
40
+ catch (e) {
41
+ console.error(e);
42
+ }
39
43
  try {
40
44
  yield this.enable(service);
41
45
  }
42
- catch (e) { }
46
+ catch (e) {
47
+ console.error(e);
48
+ }
43
49
  try {
44
50
  yield this.stop(service);
45
51
  }
46
- catch (e) { }
52
+ catch (e) {
53
+ console.error(e);
54
+ }
47
55
  try {
48
56
  yield this.start(service);
49
57
  }
50
- catch (e) { }
58
+ catch (e) {
59
+ console.error(e);
60
+ }
51
61
  });
52
62
  }
53
63
  enable(name) {
54
64
  return __awaiter(this, void 0, void 0, function* () {
55
- yield util_1.promisify(child_process_1.exec)(`systemctl enable ${name}`);
65
+ yield (0, util_1.promisify)(child_process_1.exec)(`systemctl enable ${name}`);
56
66
  });
57
67
  }
58
68
  generateConfig(description = 'Graphql Runner', executable = 'runner-linux') {
@@ -77,20 +87,20 @@ RestartSec=3
77
87
  WantedBy=multi-user.target
78
88
  `;
79
89
  }
80
- install(description = 'Graphql Runner', name = defaultRunnerName, executable = 'runner-linux') {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- yield util_1.promisify(fs_1.writeFile)(`/etc/systemd/system/${name}.service`, this.generateConfig(description, executable), { encoding: 'utf-8' });
90
+ install() {
91
+ return __awaiter(this, arguments, void 0, function* (description = 'Graphql Runner', name = defaultRunnerName, executable = 'runner-linux') {
92
+ yield (0, util_1.promisify)(fs_1.writeFile)(`/etc/systemd/system/${name}.service`, this.generateConfig(description, executable), { encoding: 'utf-8' });
83
93
  });
84
94
  }
85
95
  reload() {
86
96
  return __awaiter(this, void 0, void 0, function* () {
87
- const data = yield util_1.promisify(child_process_1.exec)(`systemctl daemon-reload`);
97
+ const data = yield (0, util_1.promisify)(child_process_1.exec)(`systemctl daemon-reload`);
88
98
  console.log(data);
89
99
  });
90
100
  }
91
- start(name = defaultRunnerName) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const data = yield util_1.promisify(child_process_1.exec)(`systemctl start ${name}`);
101
+ start() {
102
+ return __awaiter(this, arguments, void 0, function* (name = defaultRunnerName) {
103
+ const data = yield (0, util_1.promisify)(child_process_1.exec)(`systemctl start ${name}`);
94
104
  console.log(data);
95
105
  });
96
106
  }
@@ -101,20 +111,20 @@ WantedBy=multi-user.target
101
111
  yield this.start();
102
112
  });
103
113
  }
104
- stop(name = defaultRunnerName) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- const data = yield util_1.promisify(child_process_1.exec)(`systemctl stop ${name}`);
114
+ stop() {
115
+ return __awaiter(this, arguments, void 0, function* (name = defaultRunnerName) {
116
+ const data = yield (0, util_1.promisify)(child_process_1.exec)(`systemctl stop ${name}`);
107
117
  console.log(data);
108
118
  });
109
119
  }
110
- status(name = defaultRunnerName) {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- const data = yield util_1.promisify(child_process_1.exec)(`systemctl status ${name}`);
120
+ status() {
121
+ return __awaiter(this, arguments, void 0, function* (name = defaultRunnerName) {
122
+ const data = yield (0, util_1.promisify)(child_process_1.exec)(`systemctl status ${name}`);
113
123
  console.log(data);
114
124
  });
115
125
  }
116
126
  };
117
- SystemctlService = __decorate([
118
- core_1.Injectable()
119
- ], SystemctlService);
120
127
  exports.SystemctlService = SystemctlService;
128
+ exports.SystemctlService = SystemctlService = __decorate([
129
+ (0, core_1.Injectable)()
130
+ ], SystemctlService);
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from './cli-builder';
2
1
  export * from './app.constants';
3
- export { GenericEnum } from './core/executors/commands';
2
+ export * from './app.tokents';
3
+ export * from './cli-builder';
4
4
  export { executeCommand, ProcessReturn, } from './core/executors';
5
+ export { GenericEnum } from './core/executors/commands';
5
6
  export { Bootstrap } from '@gapi/core';
6
7
  export { SpawnOptionsWithoutStdio } from 'child_process';
7
- export * from './app.tokents';
package/dist/index.js CHANGED
@@ -1,19 +1,24 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
8
12
  }));
9
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./cli-builder"), exports);
17
+ exports.Bootstrap = exports.executeCommand = void 0;
14
18
  __exportStar(require("./app.constants"), exports);
19
+ __exportStar(require("./app.tokents"), exports);
20
+ __exportStar(require("./cli-builder"), exports);
15
21
  var executors_1 = require("./core/executors");
16
22
  Object.defineProperty(exports, "executeCommand", { enumerable: true, get: function () { return executors_1.executeCommand; } });
17
23
  var core_1 = require("@gapi/core");
18
24
  Object.defineProperty(exports, "Bootstrap", { enumerable: true, get: function () { return core_1.Bootstrap; } });
19
- __exportStar(require("./app.tokents"), exports);
@@ -1,4 +1,4 @@
1
1
  import { GraphQLScalarType } from 'graphql';
2
- export declare const GraphQLJSON: GraphQLScalarType;
2
+ export declare const GraphQLJSON: GraphQLScalarType<any, any>;
3
3
  export default GraphQLJSON;
4
- export declare const GraphQLJSONObject: GraphQLScalarType;
4
+ export declare const GraphQLJSONObject: GraphQLScalarType<any, any>;
@@ -17,7 +17,6 @@ function ensureObject(value) {
17
17
  function parseObject(ast, variables) {
18
18
  const value = Object.create(null);
19
19
  ast.fields.forEach((field) => {
20
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
21
20
  value[field.name.value] = parseLiteral(field.value, variables);
22
21
  });
23
22
  return value;
@@ -0,0 +1,38 @@
1
+ import { defineConfig, globalIgnores } from 'eslint/config';
2
+ import tsParser from '@typescript-eslint/parser';
3
+ import tsPlugin from '@typescript-eslint/eslint-plugin';
4
+ import prettierPlugin from 'eslint-plugin-prettier';
5
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
6
+ import prettierConfig from 'eslint-config-prettier';
7
+
8
+ export default defineConfig([
9
+ globalIgnores(["dist/*"]),
10
+ {
11
+ files: ['./src/**/*.ts', './src/**/*.tsx'],
12
+ languageOptions: {
13
+ parser: tsParser,
14
+ ecmaVersion: 2018,
15
+ sourceType: 'module',
16
+ },
17
+ plugins: {
18
+ '@typescript-eslint': tsPlugin,
19
+ prettier: prettierPlugin,
20
+ 'simple-import-sort': simpleImportSort, // ✅ MUST MATCH RULE PREFIX
21
+ },
22
+ rules: {
23
+ ...tsPlugin.configs.recommended.rules,
24
+ ...prettierConfig.rules,
25
+
26
+ '@typescript-eslint/explicit-function-return-type': 'off',
27
+ '@typescript-eslint/camelcase': 'off',
28
+ '@typescript-eslint/interface-name-prefix': 'off',
29
+
30
+ 'simple-import-sort/imports': 'error',
31
+ 'simple-import-sort/exports': 'error',
32
+ 'sort-imports': 'off',
33
+ 'import/order': 'off',
34
+
35
+ 'prettier/prettier': 'error',
36
+ },
37
+ },
38
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gapi/cli-builder",
3
- "version": "1.8.168",
3
+ "version": "1.8.170",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/gapi.git"
@@ -33,18 +33,18 @@
33
33
  "module": "./dist/index.js",
34
34
  "typings": "./dist/index.d.ts",
35
35
  "dependencies": {
36
- "@gapi/core": "^1.8.167",
36
+ "@gapi/core": "^1.8.169",
37
37
  "bufferutil": "^4.0.1",
38
38
  "apollo-cache-inmemory": "^1.6.5",
39
39
  "apollo-client": "^2.6.8",
40
40
  "ws": "^7.2.3"
41
41
  },
42
42
  "devDependencies": {
43
- "jest": "^25.5.4",
43
+ "jest": "^30.2.0",
44
44
  "@types/jest": "^25.2.1",
45
- "ts-jest": "^25.4.0",
45
+ "ts-jest": "^29.4.6",
46
46
  "@types/hapi": "^18.0.2",
47
- "@types/node": "^13.11.1"
47
+ "@types/node": "^25.0.3"
48
48
  },
49
49
  "jest": {
50
50
  "testEnvironment": "node",
@@ -18,7 +18,7 @@ export const includes = (i: Commands) =>
18
18
  export const nextOrDefault = (
19
19
  i: Commands,
20
20
  fb: unknown = true,
21
- type = (p) => p
21
+ type = (p) => p,
22
22
  ) => {
23
23
  if (process.argv.toString().includes(i)) {
24
24
  const isNextArgumentPresent =
@@ -16,12 +16,12 @@ export class AppController {
16
16
  stoppedListener: NodeJS.Timeout;
17
17
 
18
18
  constructor(
19
- private subscriptionService: SubscriptionService
19
+ private subscriptionService: SubscriptionService,
20
20
  ) {}
21
21
 
22
22
  @Mutation({
23
23
  uri: {
24
- type: GraphQLNonNull(GraphQLString),
24
+ type: new GraphQLNonNull(GraphQLString),
25
25
  },
26
26
  authorization: {
27
27
  type: GraphQLString,
@@ -35,14 +35,14 @@ export class AppController {
35
35
  })
36
36
  subscribeToGraphqlPubsub(
37
37
  root,
38
- { uri, worker_type, authorization, label }
38
+ { uri, worker_type, authorization, label },
39
39
  ) {
40
40
  this.subscriptionService.unsubscribe();
41
41
  this.subscriptionService.subscribe(
42
42
  uri,
43
43
  authorization,
44
44
  worker_type || 'runner',
45
- label
45
+ label,
46
46
  );
47
47
  return {
48
48
  data: `Success subscribed to pubsub ${uri}`,
package/src/app.frame.ts CHANGED
@@ -19,7 +19,7 @@ export class AppFrameModule {
19
19
  useFactory: () => async (next, request) => {
20
20
  if (
21
21
  request.payload.query.includes(
22
- 'query { status { status } }'
22
+ 'query { status { status } }',
23
23
  )
24
24
  ) {
25
25
  return next();
@@ -38,13 +38,15 @@ export class AppFrameModule {
38
38
  frameworkImports: [
39
39
  CoreModule.forRoot({
40
40
  server: {
41
- randomPort: !!Environment.GRAPHQL_RUNNER_RANDOM_PORT,
41
+ randomPort:
42
+ !!Environment.GRAPHQL_RUNNER_RANDOM_PORT,
42
43
  hapi: {
43
44
  port: Environment.GRAPHQL_RUNNER_API_PORT,
44
45
  },
45
46
  },
46
47
  graphql: {
47
- graphiQlPlayground: !!Environment.GRAPHQL_RUNNER_GRAPHIQL,
48
+ graphiQlPlayground:
49
+ !!Environment.GRAPHQL_RUNNER_GRAPHIQL,
48
50
  openBrowser: false,
49
51
  },
50
52
  }),
@@ -7,10 +7,12 @@ import { Environment } from './app.constants';
7
7
 
8
8
  export const CommandsToken = new InjectionToken();
9
9
  export const EnumToken = new InjectionToken();
10
- export const SubscriptionQuery = new InjectionToken<NetworkItem>();
10
+ export const SubscriptionQuery =
11
+ new InjectionToken<NetworkItem>();
11
12
 
12
13
  export type SubscriptionQuery = NetworkItem;
13
- export const MachineStatusQuery = new InjectionToken<NetworkItem>();
14
+ export const MachineStatusQuery =
15
+ new InjectionToken<NetworkItem>();
14
16
 
15
17
  export type MachineStatusQuery = NetworkItem;
16
18
 
@@ -27,7 +29,7 @@ export const machineHash = createHash('md5')
27
29
  export class Network {
28
30
  subscription: NetworkItem = {
29
31
  query: gql`
30
- subscription($machineHash: String, $label: String) {
32
+ subscription ($machineHash: String, $label: String) {
31
33
  registerWorker(
32
34
  machineHash: $machineHash
33
35
  label: $label
@@ -47,7 +47,7 @@ export class CLIBuilder {
47
47
  public static forRoot<C, T = unknown, K = unknown>(
48
48
  commands: GenericEnum<C, T, K>,
49
49
  enumerables,
50
- network: Network = new Network()
50
+ network: Network = new Network(),
51
51
  ): ModuleWithProviders {
52
52
  return {
53
53
  module: CLIBuilder,
@@ -99,7 +99,7 @@ export class CLIBuilder {
99
99
  new GraphqlEnumType({
100
100
  name: 'Commands',
101
101
  values: enumerables,
102
- })
102
+ }),
103
103
  ),
104
104
  },
105
105
  args: {
@@ -119,10 +119,10 @@ export class CLIBuilder {
119
119
  cmd: string;
120
120
  args: string[];
121
121
  cwd: string;
122
- }
122
+ },
123
123
  ) =>
124
124
  executeAction<number, string[]>(
125
- cmd
125
+ cmd,
126
126
  )(args, cwd),
127
127
  },
128
128
  }),
@@ -132,9 +132,10 @@ export class CLIBuilder {
132
132
  }),
133
133
  },
134
134
  ],
135
- controllers: Environment.GRAPHQL_RUNNER_SUBSCRIPTION_URI
136
- ? []
137
- : [AppController],
135
+ controllers:
136
+ Environment.GRAPHQL_RUNNER_SUBSCRIPTION_URI
137
+ ? []
138
+ : [AppController],
138
139
  };
139
140
  }
140
141
  }
@@ -14,16 +14,16 @@ type GenericEnumType<T, K, A> = {
14
14
  export type GenericEnum<
15
15
  C,
16
16
  T = any,
17
- K = any
17
+ K = any,
18
18
  > = GenericEnumType<C, T, K>;
19
19
 
20
- export const getAction = <T = {}, K = {}>(
21
- cmd: string | number
20
+ export const getAction = <T = object, K = object>(
21
+ cmd: string | number,
22
22
  ): ((args: K, cwd?: string) => Promise<T>) =>
23
23
  Container.get(CommandsToken)[
24
24
  Container.get(EnumToken)[cmd]
25
25
  ];
26
26
 
27
- export const executeAction = <T = {}, K = {}>(
28
- action: string | number
27
+ export const executeAction = <T = object, K = object>(
28
+ action: string | number,
29
29
  ) => getAction<T, K>(action);
@@ -12,7 +12,7 @@ export interface ProcessReturn {
12
12
  export const executeCommand = (
13
13
  command: string,
14
14
  args: string[] = [],
15
- options?: SpawnOptionsWithoutStdio
15
+ options?: SpawnOptionsWithoutStdio,
16
16
  ) => {
17
17
  return new Promise<ProcessReturn>((resolve, reject) => {
18
18
  const child = spawn(command, args, options);
@@ -4,7 +4,7 @@ export const getIpAdresses = (
4
4
  network: Record<
5
5
  string,
6
6
  { family: string; internal: boolean; address: string }[]
7
- >
7
+ >,
8
8
  ) =>
9
9
  Object.values(network).reduce((acc, interfaces) => {
10
10
  let alias = 0;
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
1
  import {
3
2
  Container,
4
3
  Inject,
@@ -23,7 +22,9 @@ import {
23
22
  import { executeAction } from '../executors/commands';
24
23
  import { getNetworkIP } from './get-ip-adresses';
25
24
 
25
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
26
26
  const webSocketImpl = require('ws');
27
+
27
28
  interface MachineStatus {
28
29
  machineHash: string;
29
30
  label: string;
@@ -47,14 +48,14 @@ export class SubscriptionService {
47
48
  @Inject(SubscriptionQuery)
48
49
  private subscriptionsQuery: SubscriptionQuery,
49
50
  @Inject(MachineStatusQuery)
50
- private machineStatusQuery: MachineStatusQuery
51
+ private machineStatusQuery: MachineStatusQuery,
51
52
  ) {
52
53
  if (Environment.GRAPHQL_RUNNER_SUBSCRIPTION_URI) {
53
54
  this.subscribe(
54
55
  Environment.GRAPHQL_RUNNER_SUBSCRIPTION_URI,
55
56
  Environment.GRAPHQL_RUNNER_SECRET,
56
57
  Environment.GRAPHQL_RUNNER_TYPE,
57
- Environment.GRAPHQL_RUNNER_LABEL
58
+ Environment.GRAPHQL_RUNNER_LABEL,
58
59
  );
59
60
  }
60
61
  }
@@ -62,7 +63,7 @@ export class SubscriptionService {
62
63
  uri: string,
63
64
  authorization?: string,
64
65
  worker_type?: string,
65
- label?: string
66
+ label?: string,
66
67
  ) {
67
68
  this.currentSubscriptionUri = uri;
68
69
  this.link = new WebSocketLink({
@@ -77,7 +78,7 @@ export class SubscriptionService {
77
78
  Environment.GRAPHQL_RUNNER_NAT_IP ||
78
79
  (await getNetworkIP()),
79
80
  networkInterfaces: JSON.stringify(
80
- networkInterfaces()
81
+ networkInterfaces(),
81
82
  ),
82
83
  },
83
84
  reconnect: true,
@@ -90,37 +91,46 @@ export class SubscriptionService {
90
91
  }>(
91
92
  this.subscriptionsQuery.query,
92
93
  this.subscriptionsQuery.variables,
93
- this.link
94
+ this.link,
94
95
  )
95
96
  .pipe(
96
- map(({ data }) => this.subscriptionsQuery.map(data))
97
+ map(({ data }) =>
98
+ this.subscriptionsQuery.map(data),
99
+ ),
97
100
  )
98
- .subscribe(async ({ args, command, cwd }) => {
99
- const cmd = Container.get(EnumToken)[command];
100
- if (!cmd) {
101
- console.log('Missing command');
102
- throw new Error('Missing command');
103
- }
104
- try {
105
- const data = await executeAction(command)(
106
- JSON.parse(args),
107
- cwd
108
- );
109
- await this.sendStatus({
110
- label,
111
- machineHash,
112
- data: JSON.stringify(data),
113
- });
114
- } catch (error) {
115
- console.log(error);
116
- await this.sendStatus({
117
- label,
118
- machineHash,
119
- data: '',
120
- error: JSON.stringify(error),
121
- });
122
- }
123
- }, console.error);
101
+ .subscribe(
102
+ async ({
103
+ args,
104
+ command,
105
+ cwd,
106
+ }: IInstanceConnectionType) => {
107
+ const cmd = Container.get(EnumToken)[command];
108
+ if (!cmd) {
109
+ console.log('Missing command');
110
+ throw new Error('Missing command');
111
+ }
112
+ try {
113
+ const data = await executeAction(command)(
114
+ JSON.parse(args),
115
+ cwd,
116
+ );
117
+ await this.sendStatus({
118
+ label,
119
+ machineHash,
120
+ data: JSON.stringify(data),
121
+ });
122
+ } catch (error) {
123
+ console.log(error);
124
+ await this.sendStatus({
125
+ label,
126
+ machineHash,
127
+ data: '',
128
+ error: JSON.stringify(error),
129
+ });
130
+ }
131
+ },
132
+ console.error,
133
+ );
124
134
  return this.subscription;
125
135
  }
126
136
 
@@ -148,7 +158,7 @@ export class SubscriptionService {
148
158
 
149
159
  sendMachineStatus(variables: MachineStatus) {
150
160
  const client = new ApolloClient({
151
- link: this.link,
161
+ link: this.link as never,
152
162
  cache: new InMemoryCache(),
153
163
  });
154
164
  return client.mutate({