From a517d70ee8e452d9f60ad6a9d1e1a1dd3e0c918e Mon Sep 17 00:00:00 2001 From: Yshay Yaacobi Date: Mon, 2 Oct 2023 11:07:36 +0300 Subject: [PATCH] formatting and removed dead code --- packages/cli/src/commands/proxy/connect.ts | 2 +- .../src/docker/events-client.ts | 19 +------------------ .../core/src/compose/script-injection.test.ts | 2 +- packages/core/src/compose/script-injection.ts | 2 +- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/packages/cli/src/commands/proxy/connect.ts b/packages/cli/src/commands/proxy/connect.ts index 59e84021..41cac82a 100644 --- a/packages/cli/src/commands/proxy/connect.ts +++ b/packages/cli/src/commands/proxy/connect.ts @@ -29,7 +29,7 @@ export default class Connect extends ProfileCommand { required: true, hidden: true, env: 'LIVECYCLE_WIDGET_URL', - default: 'https://app.livecycle.run/widget/widget-bootstrap.js' + default: 'https://app.livecycle.run/widget/widget-bootstrap.js', }), 'private-env': Flags.boolean({ description: 'Mark all services as private', diff --git a/packages/compose-tunnel-agent/src/docker/events-client.ts b/packages/compose-tunnel-agent/src/docker/events-client.ts index 6b82aade..cdf41e58 100644 --- a/packages/compose-tunnel-agent/src/docker/events-client.ts +++ b/packages/compose-tunnel-agent/src/docker/events-client.ts @@ -1,6 +1,6 @@ import Docker from 'dockerode' import { tryParseJson, Logger, ScriptInjection } from '@preevy/common' -import { set, throttle } from 'lodash' +import { throttle } from 'lodash' import { filters } from './filters' import { containerToService } from './services' @@ -13,23 +13,6 @@ export type RunningService = { inject: ScriptInjection[] } -const reviveScriptInjection = ({ pathRegex, ...v }: ScriptInjection) => ({ - ...pathRegex && { pathRegex: new RegExp(pathRegex) }, - ...v, -}) - -export const scriptInjectionFromLabels = (labels : Record): ScriptInjection[] => { - const re = /^preevy\.inject_script\.(?.+?)\.(?[^.]+)$/ - const scripts:{[id:string]: Partial } = {} - for (const [label, value] of Object.entries(labels)) { - const match = label.match(re)?.groups - if (match) { - set(scripts, [match.id, match.attribute], value) - } - } - return (Object.values(scripts).filter(x => !!x.src) as ScriptInjection[]).map(reviveScriptInjection) -} - export const eventsClient = ({ log, docker, diff --git a/packages/core/src/compose/script-injection.test.ts b/packages/core/src/compose/script-injection.test.ts index ea21d6d9..1cc31f5b 100644 --- a/packages/core/src/compose/script-injection.test.ts +++ b/packages/core/src/compose/script-injection.test.ts @@ -16,7 +16,7 @@ describe('script injection', () => { }, } - const injector = scriptInjector('test', { src: 'https://mydomain.com/myscript.ts', async: true, pathRegex: /.*/ }) + const injector = scriptInjector('test', { src: 'https://mydomain.com/myscript.ts', async: true, pathRegex: /.*/ }) const newModel = injector.inject(model) expect(newModel.services?.frontend1?.labels).toMatchObject({ 'preevy.inject_script.test.src': 'https://mydomain.com/myscript.ts', 'preevy.inject_script.test.async': 'true', 'preevy.inject_script.test.path_regex': '.*' }) expect(newModel.services?.frontend2?.labels).toMatchObject({ other: 'value', 'preevy.inject_script.test.src': 'https://mydomain.com/myscript.ts', 'preevy.inject_script.test.async': 'true', 'preevy.inject_script.test.path_regex': '.*' }) diff --git a/packages/core/src/compose/script-injection.ts b/packages/core/src/compose/script-injection.ts index 2833dfcd..d9d79e09 100644 --- a/packages/core/src/compose/script-injection.ts +++ b/packages/core/src/compose/script-injection.ts @@ -35,4 +35,4 @@ export const scriptInjector = (id : string, script: ScriptInjection) => { } } -export const widgetScriptInjector = (url:string) => scriptInjector('preevy-widget', {src: url}) +export const widgetScriptInjector = (url:string) => scriptInjector('preevy-widget', { src: url })