diff --git a/sample/scripts/build.js b/sample/scripts/build.js index 902390d..ab2cf44 100644 --- a/sample/scripts/build.js +++ b/sample/scripts/build.js @@ -1,41 +1,49 @@ /* 批处理脚本 */ /* - 如果有processTree,则先运行prcessTree,如果有返回,则进行后面的针对每个节点运行processNode - 如果没有定义processTree,则直接针对每个节点运行processNode + 如果有processTree,则先运行prcessTree,如果有返回,则进行后面的针对每个节点运行processNode + 如果没有定义processTree,则直接针对每个节点运行processNode - export interface TreeModel { - version: string; - name: string; - desc?: string; - export?: boolean; - firstid: number; - group: string[]; - import: string[]; - declvar: VarDef[]; - root: NodeModel; - } + export interface TreeModel { + version: string; + name: string; + desc?: string; + export?: boolean; + firstid: number; + group: string[]; + import: string[]; + declvar: VarDef[]; + root: NodeModel; + } - export interface NodeModel { - id: number; - name: string; - desc?: string; - args?: { [key: string]: any }; - input?: string[]; - output?: string[]; - children?: NodeModel[]; - debug?: boolean; - disabled?: boolean; - path?: string; - } + export interface NodeModel { + id: number; + name: string; + desc?: string; + args?: { [key: string]: any }; + input?: string[]; + output?: string[]; + children?: NodeModel[]; + debug?: boolean; + disabled?: boolean; + path?: string; + } - interface BuildScript { - processTree?(tree: TreeModel, path: string): TreeModel | null; - processNode?(node: NodeModel, tree: TreeModel): NodeModel | null; - onWriteFile?(path: string, tree: TreeModel): void; - onComplete?(status: "success" | "failure"): void; - } + interface BatchScript { + onSetup?(env: Env): void; + processTree?(tree: TreeModel, path: string): TreeModel | null; + processNode?(node: NodeModel, tree: TreeModel): NodeModel | null; + onWriteFile?(path: string, tree: TreeModel): void; + onComplete?(status: "success" | "failure"): void; + } */ ({ + onSetup: (env) => { + console.log("onSetup", env); + console.log(env.workdir); + console.log(env.nodeDefs.get("Wait")); + console.log(env.path.dirname("sample/scripts/build.js")); + console.log(env.fs.readFileSync("sample/scripts/build.js", "utf8")); + }, processTree: (tree) => { console.log(`processTree ${tree.name}`); return tree; diff --git a/sample/scripts/test.js b/sample/scripts/test.js index f5bba42..ea156dc 100644 --- a/sample/scripts/test.js +++ b/sample/scripts/test.js @@ -1,38 +1,40 @@ /* 批处理脚本 */ /* - 如果有processTree,则先运行prcessTree,如果有返回,则进行后面的针对每个节点运行processNode - 如果没有定义processTree,则直接针对每个节点运行processNode + 如果有processTree,则先运行prcessTree,如果有返回,则进行后面的针对每个节点运行processNode + 如果没有定义processTree,则直接针对每个节点运行processNode - export interface TreeModel { - version: string; - name: string; - desc?: string; - export?: boolean; - firstid: number; - group: string[]; - import: string[]; - declvar: VarDef[]; - root: NodeModel; - } + export interface TreeModel { + version: string; + name: string; + desc?: string; + export?: boolean; + firstid: number; + group: string[]; + import: string[]; + declvar: VarDef[]; + root: NodeModel; + } - export interface NodeModel { - id: number; - name: string; - desc?: string; - args?: { [key: string]: any }; - input?: string[]; - output?: string[]; - children?: NodeModel[]; - debug?: boolean; - disabled?: boolean; - path?: string; - } + export interface NodeModel { + id: number; + name: string; + desc?: string; + args?: { [key: string]: any }; + input?: string[]; + output?: string[]; + children?: NodeModel[]; + debug?: boolean; + disabled?: boolean; + path?: string; + } - interface BatchScript { - processTree?(tree: TreeModel, path: string): TreeModel; - - processNode?(node: NodeModel, tree: TreeModel): NodeModel; - } + interface BatchScript { + onSetup?(env: Env): void; + processTree?(tree: TreeModel, path: string): TreeModel | null; + processNode?(node: NodeModel, tree: TreeModel): NodeModel | null; + onWriteFile?(path: string, tree: TreeModel): void; + onComplete?(status: "success" | "failure"): void; + } */ ({ processTree: (tree) => { diff --git a/src/components/inspector.tsx b/src/components/inspector.tsx index c8fe503..dc954f8 100644 --- a/src/components/inspector.tsx +++ b/src/components/inspector.tsx @@ -1487,7 +1487,10 @@ const NodeDefInspector: FC = () => { form.setFieldValue("type", def.type); form.setFieldValue("desc", def.desc); form.setFieldValue("doc", def.doc); - form.setFieldValue("group", def.group); + form.setFieldValue( + "group", + def.group?.map((g) => ({ label: g, value: g })) + ); if (def.children === undefined || def.children === -1) { form.setFieldValue("children", t("node.children.unlimited")); } else { @@ -1526,7 +1529,12 @@ const NodeDefInspector: FC = () => { {workspace.groupDefs.length > 0 && def.group?.length && (