Skip to content

Commit

Permalink
formatting and removed dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Yshayy committed Oct 2, 2023
1 parent b933cfa commit a517d70
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/proxy/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Connect extends ProfileCommand<typeof Connect> {
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',
Expand Down
19 changes: 1 addition & 18 deletions packages/compose-tunnel-agent/src/docker/events-client.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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<string, string>): ScriptInjection[] => {
const re = /^preevy\.inject_script\.(?<id>.+?)\.(?<key>[^.]+)$/
const scripts:{[id:string]: Partial<ScriptInjection> } = {}
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,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/compose/script-injection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '.*' })
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/compose/script-injection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

0 comments on commit a517d70

Please sign in to comment.