diff --git a/src/common/workflow-metadata.service.ts b/src/common/workflow-metadata.service.ts index d771e93..e7893d1 100644 --- a/src/common/workflow-metadata.service.ts +++ b/src/common/workflow-metadata.service.ts @@ -4,6 +4,7 @@ import { cwd } from 'node:process' import type { PlistValue } from 'plist' import { build, parse } from 'plist' import type { WorkflowMetadata } from '@models/workflow-metadata.model' +import { readConfigFile } from './user-config.service' const WORKFLOW_METADATA_FILE = 'info.plist' @@ -21,11 +22,21 @@ export async function readWorkflowMetadata(): Promise { } } -export async function writeWorkflowMetadata(metadata: WorkflowMetadata) { +export async function writeWorkflowMetadata( + metadata: WorkflowMetadata, + { ignoreConfigFile = false } = { ignoreConfigFile: false }, +) { try { + const { workflowMetadata } = await readConfigFile() + const filePath = resolve(cwd(), WORKFLOW_METADATA_FILE) - const plistData = build(metadata as never as PlistValue, { allowEmpty: true, pretty: true }) + const dataToWrite = { + ...metadata, + ...(ignoreConfigFile ? {} : workflowMetadata ?? {}), + } + + const plistData = build(dataToWrite as never as PlistValue, { allowEmpty: true, pretty: true }) await writeFile(filePath, plistData) } catch (error) { diff --git a/src/models/fast-alfred-config.model.ts b/src/models/fast-alfred-config.model.ts index 9dff840..2737787 100644 --- a/src/models/fast-alfred-config.model.ts +++ b/src/models/fast-alfred-config.model.ts @@ -1,5 +1,10 @@ import type { BundlerOptions } from '@bundler/models' +import type { WorkflowMetadata } from './workflow-metadata.model' export interface FastAlfredConfig { bundlerOptions?: BundlerOptions + workflowMetadata?: Pick< + WorkflowMetadata, + 'readme' | 'createdby' | 'name' | 'category' | 'description' | 'webaddress' + > } diff --git a/src/models/workflow-metadata.model.ts b/src/models/workflow-metadata.model.ts index 38555f4..d2e24b2 100644 --- a/src/models/workflow-metadata.model.ts +++ b/src/models/workflow-metadata.model.ts @@ -1,6 +1,6 @@ export interface WorkflowMetadata { description: string - category: string + category: Category connections: { [key: string]: Connection[] } version: string userconfigurationconfig: UserConfigurationConfig[] @@ -14,6 +14,8 @@ export interface WorkflowMetadata { webaddress: string } +export type Category = 'Tools' | 'Internet' | 'Productivity' | 'Uncategorised' + export interface Connection { destinationuid: string modifiers: number