Skip to content

Commit

Permalink
Merge pull request #2 from Avivbens/support-workflowMetadata-config
Browse files Browse the repository at this point in the history
feat: support `workflowMetadata` configuration to update `info.plist` on new release 🥷
  • Loading branch information
Avivbens authored Jun 2, 2024
2 parents 2cbd0c6 + f8478ba commit fccc5c1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/common/workflow-metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -21,11 +22,21 @@ export async function readWorkflowMetadata(): Promise<WorkflowMetadata> {
}
}

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) {
Expand Down
5 changes: 5 additions & 0 deletions src/models/fast-alfred-config.model.ts
Original file line number Diff line number Diff line change
@@ -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'
>
}
4 changes: 3 additions & 1 deletion src/models/workflow-metadata.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface WorkflowMetadata {
description: string
category: string
category: Category
connections: { [key: string]: Connection[] }
version: string
userconfigurationconfig: UserConfigurationConfig[]
Expand All @@ -14,6 +14,8 @@ export interface WorkflowMetadata {
webaddress: string
}

export type Category = 'Tools' | 'Internet' | 'Productivity' | 'Uncategorised'

export interface Connection {
destinationuid: string
modifiers: number
Expand Down

0 comments on commit fccc5c1

Please sign in to comment.