Files
windmill/frontend/src/lib/utils_deployable.ts
2024-08-14 02:09:22 +02:00

34 lines
843 B
TypeScript

import { minimatch } from 'minimatch'
import type { WorkspaceDeployUISettings } from './gen'
type DeployUIType = 'script' | 'flow' | 'app' | 'resource' | 'variable' | 'secret'
export function isDeployable(
type: DeployUIType,
path: string,
deployUiSettings: WorkspaceDeployUISettings | undefined
) {
if (deployUiSettings == undefined) {
return false
}
if (deployUiSettings.include_type != undefined && !deployUiSettings.include_type.includes(type)) {
return false
}
if (
deployUiSettings.include_path != undefined &&
deployUiSettings.include_path.length != 0 &&
deployUiSettings.include_path.every((x) => !minimatch(path, x))
) {
return false
}
return true
}
export const ALL_DEPLOYABLE: WorkspaceDeployUISettings = {
include_path: [],
include_type: ['script', 'flow', 'app', 'resource', 'variable', 'secret']
}