Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
add log support
fix config loading
fix step placeholder in parameter editor
  • Loading branch information
Armaldio committed Nov 7, 2024
1 parent fe3c8ce commit 0155d34
Show file tree
Hide file tree
Showing 18 changed files with 522 additions and 127 deletions.
8 changes: 8 additions & 0 deletions .changeset/two-flies-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@pipelab/app': patch
---

improvements
add log support
fix config loading
fix step placeholder in parameter editor
16 changes: 8 additions & 8 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ https://remixicon.com/
---

Tests:
- View logs in realtime
- env (= copy variables)
- handle pipeline error gracefully
- display what happened in dialog
- handle steamworks

- prepare electron + install package
- process quickjs in webworker
View logs in realtime: started
env (= copy variables)
handle pipeline error gracefully
display what happened in dialog
handle steamworks

prepare electron + install package
process quickjs in webworker


12 changes: 9 additions & 3 deletions src/main/handler-func.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useLogger } from '@@/logger'
import { BrowserWindow } from 'electron'
import { usePluginAPI } from './api'
import { BlockCondition } from '@@/model'
import { HandleListenerSendFn } from './handlers'

const checkParams = (definitionParams: InputsDefinition, elementParams: Record<string, string>) => {
// get a list of all required params
Expand Down Expand Up @@ -46,7 +47,7 @@ const checkParams = (definitionParams: InputsDefinition, elementParams: Record<s
export const handleConditionExecute = async (
nodeId: string,
pluginId: string,
params: BlockCondition['params'],
params: BlockCondition['params']
// { send }: { send: HandleListenerSendFn<'condition:execute'> }
): Promise<End<'condition:execute'>> => {
const { plugins } = usePlugins()
Expand Down Expand Up @@ -116,7 +117,7 @@ export const handleActionExecute = async (
pluginId: string,
params: Record<string, string>,
mainWindow: BrowserWindow | undefined,
// { send }: { send: HandleListenerSendFn<'action:execute'> }
send: HandleListenerSendFn<'action:execute'>
): Promise<End<'action:execute'>> => {
const { plugins } = usePlugins()
const { logger } = useLogger()
Expand Down Expand Up @@ -160,7 +161,12 @@ export const handleActionExecute = async (
await node.runner({
inputs: resolvedInputs,
log: (...args) => {
logger().info(`[${node.node.name}]`, ...args)
const logArgs = [`[${node.node.name}]`, ...args]
logger().info(...logArgs)
send({
type: 'log',
data: logArgs
})
},
setOutput: (key, value) => {
outputs[key] = value
Expand Down
35 changes: 22 additions & 13 deletions src/main/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ export const registerIPCHandlers = () => {

const { canceled, filePath } = await dialog.showSaveDialog(mainWindow, value)

console.log('canceled', canceled)
console.log('filePath', filePath)

send({
type: 'end',
data: {
Expand Down Expand Up @@ -207,7 +210,7 @@ export const registerIPCHandlers = () => {

const mainWindow = BrowserWindow.fromWebContents(event.sender)

const result = await handleActionExecute(nodeId, pluginId, params, mainWindow)
const result = await handleActionExecute(nodeId, pluginId, params, mainWindow, send)

await send({
data: result,
Expand All @@ -231,13 +234,30 @@ export const registerIPCHandlers = () => {
})
})

const ensure = async (filesPath: string) => {
// create parent folder
await mkdir(dirname(filesPath), {
recursive: true
})

// ensure file exist
try {
await access(filesPath)
} catch {
// File doesn't exist, create it
await writeFile(filesPath, '{}') // json
}
}

handle('config:load', async (_, { send, value }) => {
const { config } = value

const userData = app.getPath('userData')

const filesPath = join(userData, 'config', config + '.json')

await ensure(filesPath)

let content = '{}'
try {
content = await readFile(filesPath, 'utf8')
Expand Down Expand Up @@ -265,18 +285,7 @@ export const registerIPCHandlers = () => {

const filesPath = join(userData, 'config', config + '.json')

// create parent folder
await mkdir(dirname(filesPath), {
recursive: true
})

// ensure file exist
try {
await access(filesPath)
} catch {
// File doesn't exist, create it
await writeFile(filesPath, '{}') // json
}
await ensure(filesPath)

await writeFile(filesPath, data, 'utf8')

Expand Down
Loading

0 comments on commit 0155d34

Please sign in to comment.