diff --git a/packages/protolib/bundles/os/context2/index.ts b/packages/protolib/bundles/os/context2/index.ts
index 8a20cd1f9..032abf545 100644
--- a/packages/protolib/bundles/os/context2/index.ts
+++ b/packages/protolib/bundles/os/context2/index.ts
@@ -2,9 +2,11 @@ import {readFile} from './readFile'
import {writeFile} from './writeFile'
import { runCommand } from './RunCommand'
import {listDir} from './listDir'
+import { makeDir } from './makeDir'
export default {
readFile,
writeFile,
listDir,
- runCommand
+ runCommand,
+ makeDir
}
\ No newline at end of file
diff --git a/packages/protolib/bundles/os/context2/makeDir.ts b/packages/protolib/bundles/os/context2/makeDir.ts
new file mode 100644
index 000000000..c31137d65
--- /dev/null
+++ b/packages/protolib/bundles/os/context2/makeDir.ts
@@ -0,0 +1,24 @@
+import fs from 'fs/promises';
+import { join } from 'path';
+
+export const makeDir = async(options: {
+ path: string,
+ done?: (dirPath) => {},
+ error?: (err) => {}
+}) => {
+ const path = options.path;
+ const done = options.done || (() => {});
+ const error = options.error;
+
+ try {
+ await fs.mkdir(join('../../', path), { recursive: true });
+ done(path)
+ return path;
+ } catch(err) {
+ if (error) {
+ error(err);
+ } else {
+ throw err;
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/protolib/bundles/os/masks/MkdirSync.tsx b/packages/protolib/bundles/os/masks/MkdirSync.tsx
index ddb95236e..521820448 100644
--- a/packages/protolib/bundles/os/masks/MkdirSync.tsx
+++ b/packages/protolib/bundles/os/masks/MkdirSync.tsx
@@ -29,6 +29,7 @@ export default {
id: 'CreateFolder',
type: 'CallExpression',
category: 'OS',
+ hidden: true,
keywords: ['fs', 'os', 'make', 'dir', 'mkdir'],
check: (node, nodeData) => {
return node.type == "CallExpression" && nodeData.to?.startsWith('context.os.createFolder')
diff --git a/packages/protolib/bundles/os/masks2/MakeDir.tsx b/packages/protolib/bundles/os/masks2/MakeDir.tsx
new file mode 100644
index 000000000..a349894b8
--- /dev/null
+++ b/packages/protolib/bundles/os/masks2/MakeDir.tsx
@@ -0,0 +1,46 @@
+import { Node, NodeOutput, NodeParams, filterObject, restoreObject } from 'protoflow';
+import { useColorFromPalette } from 'protoflow/src/diagram/Theme'
+import { FolderPlus } from 'lucide-react'
+
+const MakeDir = ({ node = {}, nodeData = {}, children }: any) => {
+ const color = useColorFromPalette(10) // Cambio de color para diferenciar del ListDir
+ return (
+
+
+
+
+
+
+ )
+}
+
+export default {
+ id: 'os2.makeDir',
+ type: 'CallExpression',
+ category: "OS",
+ keywords: ['fs', 'os', 'create', 'directory', 'mkdir'],
+ check: (node, nodeData) => {
+ return node.type == "CallExpression" && nodeData.to?.startsWith('context.os2.makeDir')
+ },
+ getComponent: (node, nodeData, children) => ,
+ filterChildren: filterObject({keys: {
+ path: 'input',
+ done: 'output',
+ error: 'output'
+ }}),
+ restoreChildren: restoreObject({keys: {
+ path: 'input',
+ done: { params: {'param-done': { key: "path"}}},
+ error: { params: { 'param-error': { key: "err"}}}
+ }}),
+ getInitialData: () => {
+ return {
+ await: true,
+ to: 'context.os2.makeDir',
+ "mask-path": {
+ value: "",
+ kind: "StringLiteral"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/protolib/bundles/os/masks2/index.tsx b/packages/protolib/bundles/os/masks2/index.tsx
index 57ec3794c..67aac630b 100644
--- a/packages/protolib/bundles/os/masks2/index.tsx
+++ b/packages/protolib/bundles/os/masks2/index.tsx
@@ -2,9 +2,11 @@ import ReadFile from "./ReadFile";
import WriteFile from './WriteFile';
import RunCommand from "./RunCommand";
import ListDir from "./ListDir";
+import MakeDir from "./MakeDir";
export default [
ReadFile,
WriteFile,
ListDir,
- RunCommand
+ RunCommand,
+ MakeDir
]
\ No newline at end of file