From 69b53572dbe838c591e2537f10d9cbc8a3a1b13a Mon Sep 17 00:00:00 2001 From: Robin Walthuis Date: Tue, 7 Apr 2026 16:33:00 +0200 Subject: [PATCH 1/2] feat: add ability to push components with just the minimal data without the function json --- src/functions/publishWasmBlockStoreFunctions.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/functions/publishWasmBlockStoreFunctions.ts b/src/functions/publishWasmBlockStoreFunctions.ts index 20a642cf..f7f7278e 100644 --- a/src/functions/publishWasmBlockStoreFunctions.ts +++ b/src/functions/publishWasmBlockStoreFunctions.ts @@ -33,15 +33,6 @@ const publishWasmFunction = async ( } const functionJson = getFunctionJsonFromDir(functionDir); - if (!functionJson) { - console.log( - chalk.yellow( - `! No function.json file found in ${functionDir}, skipping...`, - ), - ); - return; - } - const blockName = path.basename(path.dirname(functionPath)); await uploadBlock({ @@ -64,11 +55,11 @@ const getWasmFileFromDir = (functionDir: string): File | null => { return null; }; -const getFunctionJsonFromDir = (functionDir: string): string | null => { +const getFunctionJsonFromDir = (functionDir: string): string => { const functionJsonPath = path.join(functionDir, 'function.json'); + const version = path.basename(functionDir); + const name = camelCase(path.basename(path.dirname(functionDir))); if (fs.existsSync(functionJsonPath)) { - const version = path.basename(functionDir); - const name = camelCase(path.basename(path.dirname(functionDir))); const json = { ...fs.readJsonSync(functionJsonPath), name, @@ -76,7 +67,7 @@ const getFunctionJsonFromDir = (functionDir: string): string | null => { }; return stringifyDefinition(json); } - return null; + return JSON.stringify([{ name, version }]); }; const stringifyDefinition = (definition: Record): string => { From e1ac3e13f4bdd8dedffd676ecf2c211645cf9839 Mon Sep 17 00:00:00 2001 From: Robin Walthuis Date: Wed, 8 Apr 2026 10:02:43 +0200 Subject: [PATCH 2/2] test: fix broken function definition tests --- __tests__/functions/functionDefinition.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/__tests__/functions/functionDefinition.test.ts b/__tests__/functions/functionDefinition.test.ts index 82328c5a..a7351cdd 100644 --- a/__tests__/functions/functionDefinition.test.ts +++ b/__tests__/functions/functionDefinition.test.ts @@ -77,7 +77,7 @@ test('creating a new functionDefinition', async (): Promise => { }); test('functionDefinitions for a directory with functions', async (): Promise => { - const [, { schema }] = await functionDefinitions(functionsPath); + const [{ schema }] = await functionDefinitions(functionsPath); expect(schema).toMatchObject({ label: 'Say Hello', }); @@ -89,18 +89,18 @@ test('functionDefinitions for a directory without functions', async (): Promise< }); test('stringifying function definitions', async (): Promise => { - const expected = `[{"name":"jsonToXml","version":"1.0","description":"Convert JSON to XML","label":"json to xml","category":"Misc","icon":{"name":"ChatIcon","color":"Teal"},"options":"[{\\"meta\\":{\\"type\\":\\"Text\\"},\\"name\\":\\"name\\",\\"label\\":\\"Name\\",\\"info\\":\\"The name of the XML root element.\\",\\"advanced\\":false,\\"configuration\\":{\\"placeholder\\":\\"Betty Blocks\\"}}]","yields":"NONE","paths":"{}"},{"name":"sayHello","version":"1.0","description":"Say Hello to the world","label":"Say Hello","category":"Misc","icon":{"name":"ChatIcon","color":"Teal"},"options":"[{\\"meta\\":{\\"type\\":\\"Text\\"},\\"name\\":\\"name\\",\\"label\\":\\"Name\\",\\"info\\":\\"The name that's going to be used to say hello to the world!\\",\\"advanced\\":false,\\"configuration\\":{\\"placeholder\\":\\"Betty Blocks\\"}}]","yields":"NONE","paths":"{}"}]`; + const expected = `[{"name":"sayHello","version":"1.0","description":"Say Hello to the world","label":"Say Hello","category":"Misc","icon":{"name":"ChatIcon","color":"Teal"},"options":"[{\\"meta\\":{\\"type\\":\\"Text\\"},\\"name\\":\\"name\\",\\"label\\":\\"Name\\",\\"info\\":\\"The name that's going to be used to say hello to the world!\\",\\"advanced\\":false,\\"configuration\\":{\\"placeholder\\":\\"Betty Blocks\\"}}]","yields":"NONE","paths":"{}"},{"name":"jsonToXml","version":"1.0","description":"Convert JSON to XML","label":"json to xml","category":"Misc","icon":{"name":"ChatIcon","color":"Teal"},"options":"[{\\"meta\\":{\\"type\\":\\"Text\\"},\\"name\\":\\"name\\",\\"label\\":\\"Name\\",\\"info\\":\\"The name of the XML root element.\\",\\"advanced\\":false,\\"configuration\\":{\\"placeholder\\":\\"Betty Blocks\\"}}]","yields":"NONE","paths":"{}"}]`; const definitions = await functionDefinitions(functionsPath); expect(stringifyDefinitions(definitions)).toEqual(expected); }); test('generating the package index.js', async (): Promise => { - const expected = `import { default as jsonToXml_1_0 } from './functions/jsonToXML/1.0'; -import { default as sayHello_1_0 } from './functions/say-hello/1.0'; + const expected = `import { default as sayHello_1_0 } from './functions/say-hello/1.0'; +import { default as jsonToXml_1_0 } from './functions/jsonToXML/1.0'; const fn = { - "jsonToXml 1.0": jsonToXml_1_0, "sayHello 1.0": sayHello_1_0, + "jsonToXml 1.0": jsonToXml_1_0, }; export default fn;