From 4967cd26ea5bb91dca73710ef02fcbd9c416c868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20J=C3=BCrisoo?= Date: Sun, 29 Sep 2024 10:04:19 +0200 Subject: [PATCH 1/2] Set Category on NodeJs nodes --- packages/nodejs/src/computers/JsonFileRead/JsonFileRead.ts | 1 + packages/nodejs/src/computers/JsonFileWrite/JsonFileWrite.ts | 1 + packages/nodejs/src/computers/ListFiles/ListFiles.ts | 1 + packages/nodejs/src/computers/ReadFiles/ReadFiles.ts | 1 + packages/nodejs/src/computers/RunCommand/RunCommand.ts | 1 + packages/nodejs/src/computers/WriteFile/WriteFile.ts | 1 + 6 files changed, 6 insertions(+) diff --git a/packages/nodejs/src/computers/JsonFileRead/JsonFileRead.ts b/packages/nodejs/src/computers/JsonFileRead/JsonFileRead.ts index e8190d2a..1f0ab877 100644 --- a/packages/nodejs/src/computers/JsonFileRead/JsonFileRead.ts +++ b/packages/nodejs/src/computers/JsonFileRead/JsonFileRead.ts @@ -5,6 +5,7 @@ import { Computer, get, serializeError, str, stringifyError } from '@data-story/ export const JsonFileRead: Computer = { name: 'JsonFile.read', label: 'JsonFile.read', + category: 'NodeJs', inputs: [], outputs: [ { diff --git a/packages/nodejs/src/computers/JsonFileWrite/JsonFileWrite.ts b/packages/nodejs/src/computers/JsonFileWrite/JsonFileWrite.ts index 7f8d42c6..a858368e 100644 --- a/packages/nodejs/src/computers/JsonFileWrite/JsonFileWrite.ts +++ b/packages/nodejs/src/computers/JsonFileWrite/JsonFileWrite.ts @@ -5,6 +5,7 @@ import { Computer, str } from '@data-story/core'; export const JsonFileWrite: Computer = { name: 'JsonFile.write', label: 'JsonFile.write', + category: 'NodeJs', inputs: [{ name: 'input', schema: {} diff --git a/packages/nodejs/src/computers/ListFiles/ListFiles.ts b/packages/nodejs/src/computers/ListFiles/ListFiles.ts index 4c20172a..7f13a11c 100644 --- a/packages/nodejs/src/computers/ListFiles/ListFiles.ts +++ b/packages/nodejs/src/computers/ListFiles/ListFiles.ts @@ -5,6 +5,7 @@ import * as nodePath from 'path' export const ListFiles: Computer = { name: 'ListFiles', label: 'ListFiles', + category: 'NodeJs', inputs: [{ name: 'input', schema: {}, diff --git a/packages/nodejs/src/computers/ReadFiles/ReadFiles.ts b/packages/nodejs/src/computers/ReadFiles/ReadFiles.ts index 3bf0f293..6bec5d63 100644 --- a/packages/nodejs/src/computers/ReadFiles/ReadFiles.ts +++ b/packages/nodejs/src/computers/ReadFiles/ReadFiles.ts @@ -5,6 +5,7 @@ import { Computer, createDefaultStringable } from '@data-story/core'; export const ReadFiles: Computer = { name: 'ReadFiles', label: 'ReadFiles', + category: 'NodeJs', inputs: [{ name: 'input', schema: {} diff --git a/packages/nodejs/src/computers/RunCommand/RunCommand.ts b/packages/nodejs/src/computers/RunCommand/RunCommand.ts index 4d8465fd..6386795d 100644 --- a/packages/nodejs/src/computers/RunCommand/RunCommand.ts +++ b/packages/nodejs/src/computers/RunCommand/RunCommand.ts @@ -23,6 +23,7 @@ async function awaitableExec(command: string): Promise<{ export const RunCommand: Computer = { name: 'RunCommand', label: 'RunCommand', + category: 'NodeJs', inputs: [{ name: 'input', schema: {}, diff --git a/packages/nodejs/src/computers/WriteFile/WriteFile.ts b/packages/nodejs/src/computers/WriteFile/WriteFile.ts index 5256d908..6be7cb89 100644 --- a/packages/nodejs/src/computers/WriteFile/WriteFile.ts +++ b/packages/nodejs/src/computers/WriteFile/WriteFile.ts @@ -4,6 +4,7 @@ import { Computer, str } from '@data-story/core'; export const WriteFile: Computer = { name: 'WriteFile', label: 'WriteFile', + category: 'NodeJs', inputs: [{ name: 'input', schema: {} From d3d972631985f2ad556029ce1fb989fed8937390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20J=C3=BCrisoo?= Date: Sun, 29 Sep 2024 10:49:36 +0200 Subject: [PATCH 2/2] Allow interpolation and no output for RunCommand --- .../src/computers/RunCommand/RunCommand.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/nodejs/src/computers/RunCommand/RunCommand.ts b/packages/nodejs/src/computers/RunCommand/RunCommand.ts index 6386795d..a980f7db 100644 --- a/packages/nodejs/src/computers/RunCommand/RunCommand.ts +++ b/packages/nodejs/src/computers/RunCommand/RunCommand.ts @@ -1,6 +1,6 @@ import { promisify } from 'util'; import { exec as execCallback } from 'child_process'; -import { Computer, createDefaultStringable } from '@data-story/core'; +import { Computer, str } from '@data-story/core'; const exec = promisify(execCallback); @@ -39,22 +39,18 @@ export const RunCommand: Computer = { }, ], params: [ - createDefaultStringable({ + str({ name: 'command', - label: 'Command', - help: 'Command to run', - multiline: true, - canInterpolate: false, - interpolate: false, - evaluations: [], - casts: [], value: 'say "Hello World"', + help: 'Command to run', + canInterpolate: true, }) ], - async *run({ input, output, params }) { + async *run({ input, output }) { while(true) { const [ incoming ] = input.pull(1) + const command = incoming.params.command as string const { stdout, stderr, error } = await awaitableExec(command); @@ -80,7 +76,7 @@ export const RunCommand: Computer = { continue; } - throw new Error('Unknown exec result!') + yield; } }, };